This module contains routines for determining the saturation vapor pressure (ES) from lookup tables constructed using equations given in the Smithsonian tables. The ES lookup tables are valid between -160C and +100C (approx 113K to 373K).
The values of ES are computed over ice from -160C to -20C, over water from 0C to 100C, and a blended value (over water and ice) from -20C to 0C.
This version was written for non-vector machines. See the notes section for details on vectorization.
fms_mod constants_mod
use sat_vapor_pres_mod [, only: lookup_es, lookup_des, compute_es, sat_vapor_pres_init ]
call lookup_es ( temp, esat ) call lookup_des ( temp, desat ) DESCRIPTION For the given temperatures these routines return the saturation vapor pressure (esat) or the derivative of esat w.r.t. temperature (desat). The return values are derived from lookup tables (see notes below). INPUT temp Temperature in degrees Kelvin. May be a scalar, 1d, 2d, or 3d array. [real] OUTPUT esat Saturation vapor pressure in pascals. May be a scalar, 1d, 2d, or 3d array. Must have the same order and size as temp. [real] desat Derivative of saturation vapor pressure w.r.t. temperature in pascals/degree. May be a scalar, 1d, 2d, or 3d array. Must have the same order and size as temp. [real]
esat = compute_es ( temp ) DESCRIPTION Computes saturation vapor pressure for the given temperature using the equations given in the Smithsonian Meteorological Tables. Between -20C and 0C a blended value over ice and water is returned. INPUT temp Temperature in degrees Kelvin. May be a scalar, 1d, 2d, or 3d array. [real] RETURNS esat Saturation vapor pressure in pascals. May be a scalar, 1d, 2d, or 3d array. Must have the same order and size as temp. [real]
call sat_vapor_pres_init DESCRIPTION Initializes the lookup tables for saturation vapor pressure. This routine will be called automatically the first time lookup_es or lookup_des is called, the user does not need to call this routine. There are no arguments.
To create a vector version the lookup routines need to be modified. The local variables: tmp, del, ind, should be changed to arrays with the same size and order as input array temp.
The tables are constructed using the saturation vapor pressure (ES) equations in the Smithsonian tables. The tables are valid between -160C to +100C with increments at 1/10 degree. Between -160C and -20C values of ES over ice are used, between 0C and 100C values of ES over water are used, between -20C and 0C blended values of ES (over water and over ice) are used.
There are three tables constructed: ES, first derivative (ES'), and second derivative (ES''). The ES table is constructed directly from the equations in the Smithsonian tables. The ES' table is constructed by bracketing temperature values at +/- 0.01 degrees. The ES'' table is estimated by using centered differencing of the ES' table.
Values of the saturation vapor pressure (es) and the derivative (es') are determined at temperature (T) from the lookup tables (ES, ES', ES'') using the following formula.
es (T) = ES(t) + ES'(t) * dt + 0.5 * ES''(t) * dt**2 es'(T) = ES'(t) + ES''(t) * dt where t = lookup table temperature closest to T dt = T - t
These parameters can be modified to increase/decrease the size/range of the lookup tables.
tcmin The minimum temperature (in deg C) in the lookup tables. [integer, default: tcmin = -160] tcmax The maximum temperature (in deg C) in the lookup tables. [integer, default: tcmin = +100]
program test_sat_vapor_pres use sat_vapor_pres_mod implicit none integer, parameter :: ipts=500, jpts=100, kpts=50, nloop=1 real, dimension(ipts,jpts,kpts) :: t,es,esn,des,desn integer :: n ! generate temperatures between 120K and 340K call random_number (t) t = 130. + t * 200. ! initialize the tables (optional) call sat_vapor_pres_init ! compute actual es and "almost" actual des es = compute_es (t) des = compute_des (t) do n = 1, nloop ! es and des call lookup_es (t, esn) call lookup_des (t,desn) enddo ! terminate, print deviation from actual print *, 'size=',ipts,jpts,kpts,nloop print *, 'err es = ', sum((esn-es)**2) print *, 'err des = ', sum((desn-des)**2) contains !---------------------------------- ! routine to estimate derivative function compute_des (tem) result (des) real, intent(in) :: tem(:,:,:) real, dimension(size(tem,1),size(tem,2),size(tem,3)) :: des,esp,esm real, parameter :: tdel = .01 esp = compute_es (tem+tdel) esm = compute_es (tem-tdel) des = (esp-esm)/(2*tdel) end function compute_des !---------------------------------- end program test_sat_vapor_pres