Fortran 90 subroutine ccm2_hydrostatic_matrix for computing the
CCM hydrostatic matrix H defined by Equation (3.a.109)
in NCAR Technical Note 382 (Hack et al., 1993). Based on the hydrostatic
matrix, the geopotential height is computed as
z =
s /g + (Rd /g) H
Tv,
where
s is the surface geopotential,
g the acceleration due to gravity, Rd the gas constant
for dry air, H the CCM hydrostatic matrix,
and Tv the virtual temperature which is given as
Tv = T(1 +
q) where T
is the temperature,
the ratio of molecular weight
of water vapor to that of dry air, and q the specific humidity.
Download
One can simply download the file SUBR_ccm2_hydrostatic_matrix.f90 using your browser.
Reference
Hack, J. J., B. A. Boville, B. P. Briegleb, J. T. Kiehl, P. J. Rasch, and D. L. Williamson, 1993: Description of the NCAR Community Climate Model (CCM2). NCAR Technical Note NCAR/TN-382+STR, 108 pp.
SUBROUTINE ccm2_hydrostatic_matrix(uppercaseK, pi, p, H)
! FILE: SUBR_ccm2_hydrostatic_matrix.f90
! AUTHOR: David Stepaniak, NCAR/CGD/CAS
! DATE INITIATED: 21 August 1998
! LAST MODIFIED: Tue Aug 25 12:03:56 MDT 1998
!
! NOTE: K and uppercaseK are used interchangeably in comments.
!
! DESCRIPTION: Denoting the number of midpoint model levels by K,
! SUBROUTINE ccm2_hydrostatic_matrix returns the [K x K] CCM2
! hydostatic matrix H defined by Equation (3.a.109)
! in NCAR Technical Note 382 (Hack et al., 1993). The
! notation in this code follows the notation found in
! the Technical Note.
!
! Let k be the row index of H, l the column index of
! H, p_k the midpoint pressure where k = 1,2...,K arranged
! from top to bottom, and pi the surface pressure.
! (The midpoint pressure values are derived, for example,
! from purely sigma or hybrid coordinate midpoint
! values.) Then, from Hack et al., p. 27, H(k,l) is
! defined as:
!
! / 0, l < k
! |
! | .5 ln( p_(k+1)/p_k ), l = k, k < K
! |
! H(k,l) = < .5 ln( p_(l+1)/p_(l-1) ), l > k, k < K
! |
! | .5 ln( pi^2/(p_(K-1)p_K) ), l = K, k < K
! |
! \ ln( pi/p_K ) l = K, k = K
!
!
!
! A prime example of the utility of H is in the calculation
! of Z2 (a code-defined derived field) from the CCM processor.
! Z2 is the geopotential height based on the CCM2 hydrostatic
! formulation. For a given vertical profile of virtual tempera-
! ture, say TV_k, Z2 in Fortran 90 is given by the matrix
! equation
!
! Z2 = PHIS/g + (R/g) * H * TV
!
! where PHIS is the surface geopotential and R is the gas
! constant for dry air. In this case the column vector Z2
! represents the geopotential height arranged from top to
! bottom.
!
! REFERENCE: Hack, J.J., B.A. Boville, B.P. Briegleb, J.T. Kiehl, P.J.
! Rasch, D.L. Williamson, 1993: Description of the NCAR
! Community Climate Model (CCM2). NCAR Technical Note
! NCAR/TN-382+STR, 108 pp.
!
IMPLICIT NONE
INTEGER, INTENT(IN) :: uppercaseK
! Number of midpoint model levels
REAL, INTENT(IN) :: pi
! Surface pressure, Pa or mb.
REAL, DIMENSION(1:uppercaseK), INTENT(IN) :: p
! Midpoint pressure values,
! ARRANGED FROM TOP TO BOTTOM.
! Units Pa or mb, but same as
! units used for pi. (In the NCEP
! reanalysis p = sigma*pi where
! sigma = 0.0027, 0.0101, 0.0183,
! 0.0288, 0.0418, 0.0580, 0.0782,
! 0.1028, 0.1326, 0.1682, 0.2101,
! 0.2582, 0.3125, 0.3720, 0.4357,
! 0.5017, 0.5681, 0.6329, 0.6943,
! 0.7508, 0.8014, 0.8458, 0.8838,
! 0.9159, 0.9425, 0.9644, 0.9821,
! 0.9950)
REAL, DIMENSION(1:uppercaseK,1:uppercaseK), INTENT(OUT) :: H
! CCM2 hydrostatic matrix defined
! by Equation (3.a.109) in Hack
! et al. (1993). H is indexed
! as H(k,l) where k and l are
! defined below.
! Local variables:
INTEGER :: k
! Lower case k representing the
! row index of H.
INTEGER :: l
! Lower case l representing the
! column index of H.
! Initialize all elements of H as 0.:
H = 0.
! Compute all diagonal elements of H except H(K,K):
DO k = 1, uppercaseK - 1
H(k,k) = .5 * LOG( p(k+1) / p(k) )
END DO
! Compute all off-diagonal elements of H, except for last two rows, and last
! column:
DO k = 1, uppercaseK - 2
DO l = k + 1, uppercaseK - 1
H(k,l) = .5 * LOG( p(l+1) / p(l-1) )
END DO
END DO
! Compute last column of H, except k = K:
DO k = 1, uppercaseK - 1
H(k,uppercaseK) = .5 * LOG( pi*pi / (p(uppercaseK-1)*p(uppercaseK)) )
END DO
! Compute H(K,K):
H(uppercaseK,uppercaseK) = LOG( pi / p(uppercaseK) )
END SUBROUTINE ccm2_hydrostatic_matrix
Back to `Derived Fields at 6-hourly Resolution', or
back to `Accessing the Data'.