An accurate radiative heating and cooling algorithm for use in a dynamical model of the middle atmosphere