Conservation work was ordered for Caerlaverock Castle near Dumfries after a study on the impact of climate change.