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 the MPAS subdriver and therefore are compiled into the MPAS library ahead of CAM-SIMA.
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.
Test if a
is divisible by b
, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | a | |||
real(kind=real32), | intent(in) | :: | b |
Test if a
is divisible by b
, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | a | |||
real(kind=real64), | intent(in) | :: | b |
Test a
and b
for approximate equality, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | a | |||
real(kind=real32), | intent(in) | :: | b | |||
real(kind=real32), | intent(in), | optional | :: | absolute_tolerance | ||
real(kind=real32), | intent(in), | optional | :: | relative_tolerance |
Test a
and b
for approximate equality, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | a | |||
real(kind=real64), | intent(in) | :: | b | |||
real(kind=real64), | intent(in), | optional | :: | absolute_tolerance | ||
real(kind=real64), | intent(in), | optional | :: | relative_tolerance |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all integers.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | x | |||
integer(kind=int32), | intent(in) | :: | xmin | |||
integer(kind=int32), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all integers.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | x | |||
integer(kind=int64), | intent(in) | :: | xmin | |||
integer(kind=int64), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all reals.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | x | |||
real(kind=real32), | intent(in) | :: | xmin | |||
real(kind=real32), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all reals.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | x | |||
real(kind=real64), | intent(in) | :: | xmin | |||
real(kind=real64), | intent(in) | :: | xmax |
Compute the difference in between u-wind levels dzu
from the difference in between
w-wind levels dzw
, where is the vertical coordinate, u-wind and w-wind levels are synonymous with
layer midpoints and interfaces in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the difference in between u-wind levels dzu
from the difference in between
w-wind levels dzw
, where is the vertical coordinate, u-wind and w-wind levels are synonymous with
layer midpoints and interfaces in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Compute the difference in between w-wind levels dzw
from the reciprocal difference in between
w-wind levels rdzw
, where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces
in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | rdzw |
Compute the difference in between w-wind levels dzw
from the reciprocal difference in between
w-wind levels rdzw
, where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces
in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | rdzw |
Parse a string into tokens. This subroutine implements the tokenize
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.210).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
integer, | intent(out), | allocatable | :: | first(:) | ||
integer, | intent(out), | allocatable | :: | last(:) |
Parse a string into tokens. This subroutine implements the tokenize
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.210).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
character(len=:), | intent(out), | allocatable | :: | tokens(:) | ||
character(len=:), | intent(out), | optional, | allocatable | :: | separator(:) |
Compute the coordinates at u-wind levels zu
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, u-wind and w-wind levels are synonymous with layer midpoints and interfaces
in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the coordinates at u-wind levels zu
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, u-wind and w-wind levels are synonymous with layer midpoints and interfaces
in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Compute the coordinates at w-wind levels zw
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the coordinates at w-wind levels zw
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Test if a
is divisible by b
, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | a | |||
real(kind=real32), | intent(in) | :: | b |
Test if a
is divisible by b
, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | a | |||
real(kind=real64), | intent(in) | :: | b |
Test a
and b
for approximate equality, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | a | |||
real(kind=real32), | intent(in) | :: | b | |||
real(kind=real32), | intent(in), | optional | :: | absolute_tolerance | ||
real(kind=real32), | intent(in), | optional | :: | relative_tolerance |
Test a
and b
for approximate equality, where a
and b
are both reals.
(KCW, 2024-05-25)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | a | |||
real(kind=real64), | intent(in) | :: | b | |||
real(kind=real64), | intent(in), | optional | :: | absolute_tolerance | ||
real(kind=real64), | intent(in), | optional | :: | relative_tolerance |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all integers.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | x | |||
integer(kind=int32), | intent(in) | :: | xmin | |||
integer(kind=int32), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all integers.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | x | |||
integer(kind=int64), | intent(in) | :: | xmin | |||
integer(kind=int64), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all reals.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | x | |||
real(kind=real32), | intent(in) | :: | xmin | |||
real(kind=real32), | intent(in) | :: | xmax |
Clamp/Limit the value of x
to the range of [xmin
, xmax
], where x
, xmin
, and xmax
are all reals.
No check is performed to ensure xmin
< xmax
.
(KCW, 2025-07-16)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | x | |||
real(kind=real64), | intent(in) | :: | xmin | |||
real(kind=real64), | intent(in) | :: | xmax |
Compute the difference in between u-wind levels dzu
from the difference in between
w-wind levels dzw
, where is the vertical coordinate, u-wind and w-wind levels are synonymous with
layer midpoints and interfaces in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the difference in between u-wind levels dzu
from the difference in between
w-wind levels dzw
, where is the vertical coordinate, u-wind and w-wind levels are synonymous with
layer midpoints and interfaces in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Compute the difference in between w-wind levels dzw
from the reciprocal difference in between
w-wind levels rdzw
, where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces
in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | rdzw |
Compute the difference in between w-wind levels dzw
from the reciprocal difference in between
w-wind levels rdzw
, where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces
in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | rdzw |
Return the index of unique elements in array
, which can be any intrinsic data types, as an integer array.
Please note that array
must only have one dimension, and the unique elements are returned by their first occurrences
in array
.
If array
contains zero element or is of unsupported data types, an empty integer array is produced.
For example, index_unique([1, 2, 3, 1, 2, 3, 4, 5])
returns [1, 2, 3, 7, 8]
.
(KCW, 2024-03-22)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | array(:) |
Convert one or more values of any intrinsic data types to a character string for pretty printing.
If value
contains more than one element, the elements will be stringified, delimited by separator
, then concatenated.
If value
contains exactly one element, the element will be stringified without using separator
.
If value
contains zero element or is of unsupported data types, an empty character string is produced.
If separator
is not supplied, it defaults to ", " (i.e., a comma and a space).
(KCW, 2024-02-04)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | value(:) | |||
character(len=*), | intent(in), | optional | :: | separator |
Compute the coordinates at u-wind levels zu
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, u-wind and w-wind levels are synonymous with layer midpoints and interfaces
in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the coordinates at u-wind levels zu
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, u-wind and w-wind levels are synonymous with layer midpoints and interfaces
in MPAS, respectively.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Compute the coordinates at w-wind levels zw
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | dzw(:) |
Compute the coordinates at w-wind levels zw
from the difference in between w-wind levels dzw
,
where is the vertical coordinate, and w-wind levels are synonymous with layer interfaces in MPAS.
(KCW, 2025-10-20)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | dzw(:) |
Parse a string into tokens, one at a time. This subroutine implements the split
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.196).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
integer, | intent(inout) | :: | pos | |||
logical, | intent(in), | optional | :: | back |
Parse a string into tokens. This subroutine implements the tokenize
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.210).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
integer, | intent(out), | allocatable | :: | first(:) | ||
integer, | intent(out), | allocatable | :: | last(:) |
Parse a string into tokens. This subroutine implements the tokenize
intrinsic procedure as defined in
the Fortran 2023 language standard (Section 16.9.210).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
character(len=*), | intent(in) | :: | set | |||
character(len=:), | intent(out), | allocatable | :: | tokens(:) | ||
character(len=:), | intent(out), | optional, | allocatable | :: | separator(:) |