!     ------------------------------------------------------------
!     define saturation pressure function
!     to make vectorisation possible
!
!     Gerard Cats  KNMI 24 September 1992
!     Fortran 90 version by Bent Sass August 2004. 
!
      real(kind=jprb)   ::  esatw,desdtw,esati, &
  &                         desdti,esat,desdt,tt,zccc2,zccc4,zes
      real(kind=jprb)   ::  c1es,c2es,c2is,c3es,c4es,c4is

!     constants used in saturation vapour pressure calculations

      parameter (      &    
     &    c1es=610.78_jprb, &
     &    c2es=17.269_jprb, &
     &    c2is=21.875_jprb, &
     &    c3es=273.16_jprb, &
     &    c4es=35.86_jprb,  &
     &    c4is=7.66_jprb    )

      zccc2(tt)=c2is + min(1._jprb,max(0._jprb, &
    &                 (tt-c3es+15._jprb)/15._jprb))*( c2es-c2is )
      zccc4(tt)=c4is + min(1._jprb,max(0._jprb, &
    &                 (tt-c3es+15._jprb)/15._jprb))*( c4es-c4is )
!
      esatw(tt)=c1es*exp(c2es*(tt-c3es)/(tt-c4es))
!      
!     pure saturation pressure over ice for tt <0 C,
!     esatw otherwise.
!
      esati(tt)=  &
     & (0.5_jprb +SIGN(0.5_jprb,tt-c3es) )* &
     &  c1es*exp(c2es*(tt-c3es)/(tt-c4es)) - &
     & (SIGN(0.5_jprb ,tt-c3es)-0.5_jprb)* &
     &  c1es*exp(c2is*(tt-c3es)/(tt-c4is))
!
      zes(tt)=zccc2(tt)*(tt-c3es)/(tt-zccc4(tt))
      esat(tt)=c1es*exp(zes(tt))
      desdt(tt)=c1es*exp(zes(tt))*zccc2(tt)* &
     & (c3es-zccc4(tt))/(tt-zccc4(tt))**2

!     pure saturation pressure over water
      desdtw(tt)= & 
     & c1es*exp(c2es*(tt-c3es)/(tt-c4es))* &
     & c2es*(c3es-c4es)/(tt-c4es)**2

!      desdti(tt)= pure saturation pressure over ice (Has no
!      meaning for T > 0 C)
!      +c1es*exp(c2is*(tt-c3es)/(tt-c4is))*c2is*(c3es-c4is)/(tt-c4is)**2
!      (value  over ice for T < 0 C and over water otherwise )

      desdti(tt)= & 
     &  (0.5_jprb +SIGN(0.5_jprb,tt-c3es) )* &
     &  c1es*exp(c2es*(tt-c3es)/ &
     & (tt-c4es))*c2es*(c3es-c4es)/(tt-c4es)**2 - &
     & (SIGN(0.5_jprb ,tt-c3es)-0.5_jprb)* &
     & c1es*exp(c2is*(tt-c3es)/(tt-c4is))* &
     & c2is*(c3es-c4is)/(tt-c4is)**2
