C**********************************************************
C
      FUNCTION TEMPZ( ZZ )
C
      IMPLICIT REAL*8 ( A-H, O-Z )
C
C-----------------------------------------------------------
C
C
      call setcst
     O   ( GRAV, PSD, AMDRY, RDRY, CPDRY, RMVAP, ALATNT )

      gradad = grav / cpdry
      gradnad = 2.5D0 * 1.0D-3

      ttmin = 145.0d0

      if ( zz .lt. 10000.0D0 ) then
         tempz =  220.0d0 - zz * gradad
      else
         tempz = ( 220.0d0 - 10000.0D0 * gradad ) - 
     \        ( zz - 10000.0D0 ) * gradnad
      end if         

      tempz = max ( tempz, ttmin )

      RETURN
      END
