calc_rh.f90

References to this file elsewhere.
1 !
2 ! An adaptation of KWM's subroutine for computing RH.
3 !
4 
5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6 !     PURPOSE  COMPUTES THE RELATIVE HUMIDITY FROM THE TEMPERATURE,
7 !              MIXING RATIO, AND PRESSURE.
8 !
9 !     INPUT       Q        MIXING RATIO               kg/kg
10 !                 T        T                          K
11 !                 P        P                          Pa
12 !
13 !     OUTPUT      RH       RELATIVE HUMIDITY          %
14 !
15 !      DIMENSION Q ,T, P
16 !      DIMENSION RH
17 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18 function calc_rh(t, q, p)
19 
20    implicit none
21 
22    ! Arguments
23    real t, q, p
24 
25    ! Return value
26    real calc_rh
27 
28    ! Local variables
29    real :: es, qs
30  
31    real, parameter :: e0    = 611.2
32    real, parameter :: svp2  = 17.67
33    real, parameter :: svp3  = 29.65
34    real, parameter :: t00   = 273.15
35    real, parameter :: eps   = 0.622
36 
37    es=e0*exp(svp2*(t-t00)/(t-svp3))
38    qs=eps*es/(p-es)
39    calc_rh=100.*q/qs
40 
41 end function calc_rh