dyn_procedure Module

This module provides standardized procedures (i.e., functions and subroutines) that serve as reusable building blocks for larger and more complex functionalities elsewhere.

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.


Used by

  • module~~dyn_procedure~~UsedByGraph module~dyn_procedure dyn_procedure none~init_shared_variables init_shared_variables none~init_shared_variables->module~dyn_procedure none~set_mpas_physics_tendency_rtheta set_mpas_physics_tendency_rtheta none~set_mpas_physics_tendency_rtheta->module~dyn_procedure none~set_mpas_physics_tendency_ru set_mpas_physics_tendency_ru none~set_mpas_physics_tendency_ru->module~dyn_procedure none~set_mpas_state_rho_base_theta_base set_mpas_state_rho_base_theta_base none~set_mpas_state_rho_base_theta_base->module~dyn_procedure none~set_mpas_state_rho_theta set_mpas_state_rho_theta none~set_mpas_state_rho_theta->module~dyn_procedure none~set_mpas_state_scalars set_mpas_state_scalars none~set_mpas_state_scalars->module~dyn_procedure none~set_mpas_state_u set_mpas_state_u none~set_mpas_state_u->module~dyn_procedure none~set_physics_state_column set_physics_state_column none~set_physics_state_column->module~dyn_procedure none~update_shared_variables update_shared_variables none~update_shared_variables->module~dyn_procedure proc~dyn_exchange_constituent_states dyn_exchange_constituent_states proc~dyn_exchange_constituent_states->module~dyn_procedure proc~dyn_readnl dyn_readnl proc~dyn_readnl->module~dyn_procedure

Functions

public pure elemental function dp_by_hydrostatic_equation(constant_g, rho, dz) result(dp)

Compute the pressure difference dp from the density rho and the height difference dz by hydrostatic equation. Essentially, . (KCW, 2025-07-10)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_g
real(kind=real64), intent(in) :: rho
real(kind=real64), intent(in) :: dz

Return Value real(kind=real64)

public pure elemental function exner_function(constant_cpd, constant_p0, constant_rd, p) result(pi)

Compute the Exner function pi from the pressure p. Essentially, .

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function omega_of_w_rho(constant_g, w, rho) result(omega)

Compute the vertical pressure velocity omega as a function of the vertical velocity w and the density rho. Essentially, . (KCW, 2025-07-10)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_g
real(kind=real64), intent(in) :: w
real(kind=real64), intent(in) :: rho

Return Value real(kind=real64)

public pure elemental function p_by_equation_of_state(constant_r, rho, t) result(p)

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)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_r
real(kind=real64), intent(in) :: rho
real(kind=real64), intent(in) :: t

Return Value real(kind=real64)

public pure elemental function p_by_hypsometric_equation(constant_g, constant_rd, p1, z1, tv, z2) result(p2)

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)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure function reverse(array)

Reverse the order of elements in array. (KCW, 2024-07-17)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: array(:)

Return Value real(kind=real64), (size(array))

public pure elemental function rho_by_equation_of_state(constant_r, p, t) result(rho)

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)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_r
real(kind=real64), intent(in) :: p
real(kind=real64), intent(in) :: t

Return Value real(kind=real64)

public pure function sec_to_hour_min_sec(sec) result(hour_min_sec)

Convert second(s) to hour(s), minute(s), and second(s). (KCW, 2024-02-07)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: sec

Return Value integer, (3)

public pure elemental function t_by_equation_of_state(constant_r, p, rho) result(t)

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)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_r
real(kind=real64), intent(in) :: p
real(kind=real64), intent(in) :: rho

Return Value real(kind=real64)

public pure elemental function t_by_poisson_equation(constant_cpd, constant_p0, constant_rd, theta, p) result(t)

Compute the temperature t at pressure p from the potential temperature theta at reference pressure p0 by Poisson equation. Essentially, . (KCW, 2025-07-14)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function t_of_theta_rhod_qv(constant_cpd, constant_p0, constant_rd, constant_rv, theta, rhod, qv) result(t)

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)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function t_of_tm_qv(constant_rd, constant_rv, tm, qv) result(t)

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)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function theta_by_poisson_equation(constant_cpd, constant_p0, constant_rd, t, p) result(theta)

Compute the potential temperature theta at reference pressure p0 from the temperature t at pressure p by Poisson equation. Essentially, . (KCW, 2024-07-02)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function theta_of_t_rhod_qv(constant_cpd, constant_p0, constant_rd, constant_rv, t, rhod, qv) result(theta)

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)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function tm_of_t_qv(constant_rd, constant_rv, t, qv) result(tm)

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)

Arguments

Type IntentOptional 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

Return Value real(kind=real64)

public pure elemental function tm_of_tv_qv(tv, qv) result(tm)

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)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: tv
real(kind=real64), intent(in) :: qv

Return Value real(kind=real64)

public pure elemental function tv_of_tm_qv(tm, qv) result(tv)

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)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: tm
real(kind=real64), intent(in) :: qv

Return Value real(kind=real64)

public pure elemental function w_of_omega_rho(constant_g, omega, rho) result(w)

Compute the vertical velocity w as a function of the vertical pressure velocity omega and the density rho. Essentially, . (KCW, 2025-07-10)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: constant_g
real(kind=real64), intent(in) :: omega
real(kind=real64), intent(in) :: rho

Return Value real(kind=real64)