SUBROUTINE rdtemp
  !
  ! $Author: CPTEC $
  ! $Date: 2000/02/24 13:15:43 $
  ! $Revision: 1.0 $
  !
  !
  ! subprogram:    rdtemp      radiative temperature change
  !   prgrmmr: black           org: w/np2      date: 93-12-29
  !     
  ! abstract:
  !     rdtemp applies the temperature tendencies due to
  !     radiation at all layers at each adjustment time step
  !     
  ! program history log:
  !   87-09-??  black      - originator
  !   95-03-25  black      - conversion from 1-d to 2-d in horizontal
  !   95-11-20  abeles     - parallel optimization
  !     
  ! usage: call rdtemp from main program ebu
  !   input argument list:
  !     none
  !  
  !   output argument list: 
  !     none
  !     
  !   output files:
  !     none
  !     
  !   subprograms called:
  !  
  !     unique: none
  !  
  !     library: none
  !  
  !   common blocks: ctlblk
  !                  masks
  !                  vrbls
  !                  pvrbls
  !                  phys
  !                  acmrds
  !                  acmrdl
  !   
  IMPLICIT NONE

  !*** problem size

  INCLUDE "parmeta.f90"
  INCLUDE "parm.tbl.f90"
  INTEGER, PARAMETER :: lp1=lm+1

  !*** global variables

  INCLUDE "ctlblk.f90"   ! ntsd(in); dt(in)
  INCLUDE "masks.f90"    ! htm(in); hbm2(in)
  INCLUDE "vrbls.f90"    ! t(inout)
  INCLUDE "phys.f90"     ! czen(in); czmean(in)
  INCLUDE "acmrds.f90"   ! rswtt(in)
  INCLUDE "acmrdl.f90"   ! rlwtt(in)

  !*** local variables

  INTEGER                :: i, j, l
  REAL                   :: times
  REAL                   :: dayi
  REAL                   :: hour
  REAL                   :: ttndkl
  REAL, DIMENSION(im,jm) :: factr

  !*** get current value of cos(zenith angle)

  times=(ntsd-1)*dt
  CALL zenith(times,dayi,hour)
  DO j=1,jm
     DO i=1,im
        IF(czmean(i,j).GT.0.)THEN 
           factr(i,j)=czen(i,j)/czmean(i,j)
        ELSE
           factr(i,j)=0.
        ENDIF
     END DO
  END DO
  DO l=1,lm
     DO j=1,jm
        DO i=1,im
           ttndkl=rswtt(i,j,l)*factr(i,j)+rlwtt(i,j,l)
           t(i,j,l)=t(i,j,l)+ttndkl*dt*htm(i,j,l)*hbm2(i,j)
        END DO
     END DO
  END DO
END SUBROUTINE rdtemp
