A consistent treatment of the boundary layer for atmospheric models. (12th October 2018)