The adaptation of dunes to changes in river flow