This module provides standardized procedures (i.e., functions and subroutines) that serve as reusable building blocks for larger and more complex functionalities elsewhere. Specifically, procedures in this module are intended to be used by CAM-SIMA and therefore are compiled together with it.
Computational procedures implement formulas that are universal in atmospheric sciences. They
should be designated as elemental where possible to aid compiler optimizations, such as
vectorization.
Utility procedures implement simple and well-defined operations that can be easily tested.
Compute the Exner function pi from the pressure p. Essentially, .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the Exner function pi from the pressure p. Essentially, .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_kappa | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the pressure difference dp from the density rho and the height difference dz by hydrostatic equation.
Essentially, .
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_g | |||
| real(kind=real64), | intent(in) | :: | rho | |||
| real(kind=real64), | intent(in) | :: | dz |
Compute the Exner function pi from the pressure p. Essentially, .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the Exner function pi from the pressure p. Essentially, .
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_kappa | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the vertical pressure velocity omega as a function of the vertical velocity w and the density rho.
Essentially, .
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_g | |||
| real(kind=real64), | intent(in) | :: | w | |||
| real(kind=real64), | intent(in) | :: | rho |
Compute the pressure p from the density rho and the temperature t by equation of state. Essentially,
. Equation of state may take other forms, such as , ,
. Choose wisely which form to use.
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_r | |||
| real(kind=real64), | intent(in) | :: | rho | |||
| real(kind=real64), | intent(in) | :: | t |
Compute the pressure p2 at height z2 from the pressure p1 at height z1 by hypsometric equation.
tv is the mean virtual temperature between z1 and z2. Essentially,
.
(KCW, 2024-07-02)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_g | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | p1 | |||
| real(kind=real64), | intent(in) | :: | z1 | |||
| real(kind=real64), | intent(in) | :: | tv | |||
| real(kind=real64), | intent(in) | :: | z2 |
Compute the water vapor mixing ratio qv as a function of the specific humidity sh.
Essentially, .
(KCW, 2025-07-21)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | sh |
Reverse the order of elements in array.
(KCW, 2024-07-17)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | array(:) |
Compute the density rho from the pressure p and the temperature t by equation of state. Essentially,
. Equation of state may take other forms, such as , ,
. Choose wisely which form to use.
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_r | |||
| real(kind=real64), | intent(in) | :: | p | |||
| real(kind=real64), | intent(in) | :: | t |
Convert second(s) to hour(s), minute(s), and second(s). (KCW, 2024-02-07)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | sec |
Compute the specific humidity sh as a function of the water vapor mixing ratio qv.
Essentially, .
(KCW, 2025-07-21)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | qv |
Compute the temperature t from the pressure p and the density rho by equation of state. Essentially,
. Equation of state may take other forms, such as , ,
. Choose wisely which form to use.
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_r | |||
| real(kind=real64), | intent(in) | :: | p | |||
| real(kind=real64), | intent(in) | :: | rho |
Compute the temperature t at pressure p from the potential temperature theta at reference pressure p0 by
Poisson equation. Essentially, .
(KCW, 2025-07-14)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | theta | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the temperature t as a function of the potential temperature theta, the dry air density rhod, and
the water vapor mixing ratio qv. Essentially,
.
The formulation comes from Poisson equation with equation of state plugged in and arranging
for temperature. This function is the exact inverse of theta_of_t_rhod_qv, which means that:
t == t_of_theta_rhod_qv(..., theta_of_t_rhod_qv(..., t, rhod, qv), rhod, qv).
(KCW, 2024-09-13)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | constant_rv | |||
| real(kind=real64), | intent(in) | :: | theta | |||
| real(kind=real64), | intent(in) | :: | rhod | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the temperature t as a function of the modified moist temperature tm and the water vapor mixing ratio qv.
Essentially, . This modified "moist" temperature is described herein:
The paragraph below equation 2.7 in doi:10.5065/1DFH-6P97.
The paragraph below equation 2 in doi:10.1175/MWR-D-11-00215.1.
Similarly, it can be shown that the relation, , also holds.
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | constant_rv | |||
| real(kind=real64), | intent(in) | :: | tm | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the potential temperature theta at reference pressure p0 from the temperature t at pressure p by
Poisson equation. Essentially, .
(KCW, 2024-07-02)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | t | |||
| real(kind=real64), | intent(in) | :: | p |
Compute the potential temperature theta as a function of the temperature t, the dry air density rhod, and
the water vapor mixing ratio qv. Essentially,
.
The formulation comes from Poisson equation with equation of state plugged in and arranging
for potential temperature. This function is the exact inverse of t_of_theta_rhod_qv, which means that:
theta == theta_of_t_rhod_qv(..., t_of_theta_rhod_qv(..., theta, rhod, qv), rhod, qv).
(KCW, 2024-09-13)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_cpd | |||
| real(kind=real64), | intent(in) | :: | constant_p0 | |||
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | constant_rv | |||
| real(kind=real64), | intent(in) | :: | t | |||
| real(kind=real64), | intent(in) | :: | rhod | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the modified moist temperature tm as a function of the temperature t and the water vapor mixing ratio qv.
Essentially, . This modified "moist" temperature is described herein:
The paragraph below equation 2.7 in doi:10.5065/1DFH-6P97.
The paragraph below equation 2 in doi:10.1175/MWR-D-11-00215.1.
Similarly, it can be shown that the relation, , also holds.
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_rd | |||
| real(kind=real64), | intent(in) | :: | constant_rv | |||
| real(kind=real64), | intent(in) | :: | t | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the modified moist temperature tm as a function of the virtual temperature tv and
the water vapor mixing ratio qv.
Essentially, . This modified "moist" temperature is described herein:
The paragraph below equation 2.7 in doi:10.5065/1DFH-6P97.
The paragraph below equation 2 in doi:10.1175/MWR-D-11-00215.1.
Similarly, it can be shown that the relation, , also holds.
(KCW, 2025-07-11)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | tv | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the virtual temperature tv as a function of the modified moist temperature tm and
the water vapor mixing ratio qv.
Essentially, . This modified "moist" temperature is described herein:
The paragraph below equation 2.7 in doi:10.5065/1DFH-6P97.
The paragraph below equation 2 in doi:10.1175/MWR-D-11-00215.1.
Similarly, it can be shown that the relation, , also holds.
(KCW, 2025-07-11)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | tm | |||
| real(kind=real64), | intent(in) | :: | qv |
Compute the vertical velocity w as a function of the vertical pressure velocity omega and the density rho.
Essentially, .
(KCW, 2025-07-10)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | constant_g | |||
| real(kind=real64), | intent(in) | :: | omega | |||
| real(kind=real64), | intent(in) | :: | rho |