The flies are a species of Ephydridae. Lamai, Ko Samui, Thailand, February 2012. On the beach there were pieces of driftwood and flotsam with goose barnacles (Lepadidae) growing. Hundreds of these small flies were crawling over, under and around the barnacles, and would fly up in a cloud if disturbed. Thanks to Shane McEvey for the identification.