      FUNCTION DEWPOINT(T,RH)
      IMPLICIT NONE
C
C**********************************************************************
C
C   NAME- DEWPOINT
C
C   LANGUAGE- FORTRAN   TYPE- FUNCTION        COMPUTER- IBM AIX
C
C   VERSION- 1.0    DATE- 03/15/06   PROGRAMMER- FRANK TILLEY (ERT)
C
C   FUNCTION-
C   THIS FUNCTION RETURNS THE DEW POINT (CELSIUS) GIVEN THE TEMPERATURE
C   (CELCIUS) AND RELATIVE HUMIDITY (%).
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE          TYPE  I/O  FUNCTION
C     --------          ----  ---  --------
C     T                 REAL   I   TEMPERATURE (CELSIUS)
C     RH                REAL   I   RELATIVE HUMIDITY (%)
C
C
C   LOCAL PARAMETERS-
C     VARIABLE          TYPE  FUNCTION
C     --------          ----  --------
C     KELVIN            REAL  FREEZING POINT IN DEGREES KELVIN.
C     KTEMP             REAL  TEMPERATURE CONVERTED TO DEGREES KELVIN.
C     SATVP             REAL  SATURATION VAPOR PRESSURE FOR TEMPERATURE
C     VPCOR             REAL  SATURATION VAPOR PRESSURE TIMES RELATIVE
C                             HUMIDITY (CORRECTED VAPOR PRESSURE).
C     X                 REAL  INTERMEDIATE VARIABLE FOR COMPUTING
C                             DEW POINT TEMPERATURE.
C
C   FUNCTIONS USED- VPSAT 
C
C
C**********************************************************************
C
      REAL   DEWPOINT, T, RH 
      REAL   VPSAT, VPCOR, X, KELVIN, KTEMP, SATVP
      PARAMETER (KELVIN=273.16)

C
C-- CONVERT THE CELSIUS TEMPERATURE TO KELVIN.
C
      KTEMP = T + KELVIN
C
C-- CONSTRAIN THE RELATIVE HUMIDITY TO 100% OR LESS
C
      IF(RH .GT. 99.99) RH = 100.0
C
C-- CALCULATE THE SATURATION VAPOR PRESSURE FOR THE TEMPERATURE
C
      SATVP = VPSAT(T)
C
C-- MULTIPLY THE SATURATION VAPOR PRESSURE BY THE RELATIVE HUMIDITY.
C
ccft  VPCOR = SATVP * RH
      VPCOR = SATVP * (RH*0.01)
C
C-- CALCULATE THE DEW POINT TEMPERATURE.
C
      X = ALOG(VPCOR / 6.1078)
      DEWPOINT = X * 283.3/(17.2694 - X)
C
      RETURN
      END
