The coastguard waved his searchlight furiously to pilot the ship away from the submerged reef.