MODULE Temp_RH !----------------------------------------------------------------------- ! Module that contains the following subprograms for processing ! temperatures on various scales and for calcluating relative humdity ! and dew point depression. ! Fahr_to_Celsius, a Fahrenheit-to-conversion function ! Celsius_to_Fahr, a Celsius-to-Fahrenheit conversion function ! Celsius_to_Kelven, a Celsius-to-Kelvin conversion function ! vapor_pressure, a function for calculating saturation vapor pressure ! from the temperature. ! moisture_calc, a subroutine which uses the vapor_pressure function ! to calculate relative humdity and dew point depression ! from the temperature and dew point. ! !----------------------------------------------------------------------- IMPLICIT NONE CONTAINS !-Fahr_to_Celsius ---------------------------------------------------- ! Function to convert a Fahrenheit temperature to Celsius. ! Accepts: A temperature Temp in Fahrenheit ! Returns: The corresponding Celsius temperature !--------------------------------------------------------------------- FUNCTION Fahr_to_Celsius(Temp) REAL:: Fahr_to_Celsius REAL, INTENT(IN) :: Temp Fahr_to_Celsius = (Temp - 32.0) / 1.8 END FUNCTION Fahr_to_Celsius !-Celsius_to_Fahr----------------------------------------------------- ! Function to convert a Celsius temperature to Fahrenheit. ! Accepts: A temperature Temp in Celsius ! Returns: The corresponding Fahrenheit temperature !--------------------------------------------------------------------- FUNCTION Celsius_to_Fahr(Temp) REAL:: Celsius_to_Fahr REAL, INTENT(IN) :: Temp Celsius_to_Fahr = 1.8 * Temp + 32.0 END FUNCTION Celsius_to_Fahr !-Celsius_to_Kelvin---------------------------------------------------- ! Function to convert a Celsius temperature to Kelvin. ! Accepts: A temperature Temp in Celsius ! Returns: The corresponding Kelvin temperature !--------------------------------------------------------------------- FUNCTION Celsius_to_Kelvin(Temp) REAL:: Celsius_to_Kelvin REAL, INTENT(IN) :: Temp Celsius_to_Kelvin = Temp + 273.15 END FUNCTION Celsius_to_Kelvin !-vapor_pressure----------------------------------------------------- ! Function to calcuate the saturation vapor pressure from the ! temperature. ! Accepts: A temperature Temp in Celsius ! Returns: The saturation vapor pressure of air at that temperature !--------------------------------------------------------------------- FUNCTION vapor_pressure(Temp) ! Function requires that the input temperature be in Celsisus. ! L is the latent heat of vaporization and Rv is the moist air gas ! constant. REAL, parameter :: L = 2.5E6 REAL, parameter :: Rv = 461 REAL, INTENT(IN) :: Temp REAL :: Temp_K REAL :: ARG REAL :: vapor_pressure ! Use Celsius to Kelvin conversion function to get temperature in ! Kelvin as required by the Clausius-Clapeyron equation. Temp_K = Celsius_to_Kelvin(Temp) ! Use the Clausius-Clapeyron equation to calculate the saturation ! vapor pressure of air at that temperature. ARG = (L/Rv)*((1/273.15) - (1/Temp_K)) vapor_pressure = 6.11*exp(ARG) END FUNCTION vapor_pressure !-moisture_calc------------------------------------------------------ ! Subroutine that calculates the relative humidity and dew point ! depression from temperatures and dew points entered in degrees ! Celsius. The subroutine calls the vapor pressure function for both ! the temperature and dew point to calculate the relative humidity. ! Accepts: Temperature and dew point in Celsius ! Returns: Relative humidty and dew point depression !- -------------------------------------------------------------------- SUBROUTINE moisture_calc(Temp, DTemp, RH, TDD) REAL, INTENT(IN) :: Temp, DTemp REAL, INTENT(OUT) :: RH, TDD REAL :: vapor_press, sat_vapor_press ! Call saturation vapor pressure function with the dew point to get ! the pressure exerted by the actual amount of moisture in the air. vapor_press = vapor_pressure(DTemp) ! Call saturation vapor pressure function with the temperature to get ! the pressure exerted by the moisture in the air when saturated. sat_vapor_press = vapor_pressure(Temp) ! Use this information to calculate the relative humidity. RH = (vapor_press/sat_vapor_press)*100. ! Use the temperature and the dew point to get the dew point ! depression. TDD = Temp - DTemp END SUBROUTINE moisture_calc END MODULE Temp_RH