MOM_spherical_harmonics module reference
Laplace's spherical harmonic transforms (SHT)
Data Types
Control structure for spherical harmonic transforms |
Functions/Subroutines
Calculates forward spherical harmonics transforms |
|
Calculates inverse spherical harmonics transforms |
|
Calculate precomputed coefficients |
|
Deallocate any variables allocated in spherical_harmonics_init |
|
Calculates the number of real elements (cosine) of spherical harmonics given maximum degree Nd. |
|
Calculates the one-dimensional index number at (n=0, m=m), given order m and maximum degree Nd. It is sequenced with degree (n) changing first and order (m) changing second. |
Detailed Description
Spherical harmonics
This module contains the subroutines to calculate spherical harmonic transforms (SHT), namely, forward transform of a two-dimensional field into a given number of spherical harmonic modes and its inverse transform. This module is primarily used to but not limited to calculate self-attraction and loading (SAL) term, which is mostly relevant to high frequency motions such as tides. Should other needs arise in the future, this API can be easily modified. Currently, the transforms are for t-cell fields only.
This module is stemmed from SAL calculation in Model for Prediction Across Scales (MPAS)-Ocean developed by Los Alamos National Laboratory and University of Michigan [[9] and [15]]. The algorithm for forward and inverse transforms loosely follows [73].
In forward transform, a two-dimensional physical field can be projected into a series of spherical harmonics. The spherical harmonic coefficient of degree n and order m for a field \(f(\theta, \phi)\) is calculated as follows:
and
where \(P^m_n(\cos \theta)\) is the normalized associated Legendre polynomial of degree n and order m. \(\phi\) is the longitude and \(\theta\) is the colatitude. Or, written in the discretized form:
where \(A\) is the area of the cell and \(r_e\) is the radius of the Earth.
In inverse transform, the first N degree spherical harmonic coefficients are used to reconstruct a two-dimensional physical field:
The exponential coefficients are pre-computed and stored in the memory. The associated Legendre polynomials are computed "on-the-fly", using the recurrence relationships to avoid large memory usage and take the advantage of array vectorization.
The maximum degree of the spherical harmonics is a runtime parameter and the maximum used by all SHT applications. At the moment, it is only decided by SAL_HARMONICS_DEGREE.
The forward transforms involve a global summation. Runtime flag SHT_REPRODUCING_SUM controls whether this is done in a bit-wise reproducing way or not.
References:
Barton, K.N., Pal, N., Brus, S.R., Petersen, M.R., Arbic, B.K., Engwirda, D., Roberts, A.F., Westerink, J.J., Wirasaet, D. and Schindelegger, M., 2022. Global Barotropic Tide Modeling Using Inline Self‐Attraction and Loading in MPAS‐Ocean. Journal of Advances in Modeling Earth Systems, 14(11), p.e2022MS003207. https://doi.org/10.1029/2022MS003207
Brus, S.R., Barton, K.N., Pal, N., Roberts, A.F., Engwirda, D., Petersen, M.R., Arbic, B.K., Wirasaet, D., Westerink, J.J. and Schindelegger, M., 2023. Scalable self attraction and loading calculations for unstructured ocean tide models. Ocean Modelling, p.102160. https://doi.org/10.1016/j.ocemod.2023.102160
Schaeffer, N., 2013. Efficient spherical harmonic transforms aimed at pseudospectral numerical simulations. Geochemistry, Geophysics, Geosystems, 14(3), pp.751-758. https://doi.org/10.1002/ggge.20071
Type Documentation
- type, public :: sht_CS
Control structure for spherical harmonic transforms
- Parameters
initialized
True if this control structure has been initialized.
ndegree
Maximum degree of the spherical harmonics [nondim].
lmax
Number of associated Legendre polynomials of nonnegative m [lmax=(ndegree+1)*(ndegree+2)/2] [nondim].
cos_clatT
Precomputed cosine of colatitude at the t-cells [nondim].
Pmm
Precomputed associated Legendre polynomials (m=n) at the t-cells [nondim].
cos_lonT
Precomputed cosine factors at the t-cells [nondim].
sin_lonT
Precomputed sine factors at the t-cells [nondim].
cos_lonT_wtd
Precomputed area-weighted cosine factors at the t-cells [nondim]
sin_lonT_wtd
Precomputed area-weighted sine factors at the t-cells [nondim]
a_recur
Precomputed recurrence coefficients a [nondim].
b_recur
Precomputed recurrence coefficients b [nondim].
reprod_sum
True if use reproducible global sums
Functions/Subroutine Documentation
- subroutine spherical_harmonics_forward(G, CS, var, Snm_Re, Snm_Im, Nd, tmp_scale)
Calculates forward spherical harmonics transforms
- Parameters
G [in]
The ocean's grid structure.
CS [inout]
Control structure for SHT
var [in]
Input 2-D variable in arbitrary mks units [a] or in arbitrary rescaled units [A ~> a] if tmp_scale is present
Snm_Re [out]
SHT coefficients for the real modes (cosine) in the same arbitrary units as var [a] or [A ~> a]
Snm_Im [out]
SHT coefficients for the imaginary modes (sine) in the same arbitrary units as var [a] or [A ~> a]
Nd [in]
Maximum degree of the spherical harmonics overriding ndegree in the CS [nondim]
tmp_scale [in]
A temporary rescaling factor to convert var to MKS units during the reproducing sums [a A-1 ~> 1]
Callees call graph
Text view
mom_spherical_harmonics::spherical_harmonics_forward → mom_coms::interface::reproducing_sum
mom_spherical_harmonics::spherical_harmonics_forward → mom_coms_infra::interface::sum_across_pes
mom_spherical_harmonics::spherical_harmonics_forward → mom_cpu_clock_infra::cpu_clock_begin
mom_spherical_harmonics::spherical_harmonics_forward → mom_cpu_clock_infra::cpu_clock_end
mom_spherical_harmonics::spherical_harmonics_forward → mom_error_handler::mom_error
mom_spherical_harmonics::spherical_harmonics_forward → mom_spherical_harmonics::calc_lmax
mom_spherical_harmonics::spherical_harmonics_forward → mom_spherical_harmonics::order2index
Callers call graph
- subroutine spherical_harmonics_inverse(G, CS, Snm_Re, Snm_Im, var, Nd)
Calculates inverse spherical harmonics transforms
- Parameters
G [in]
The ocean's grid structure.
CS [in]
Control structure for SHT
Snm_Re [in]
SHT coefficients for the real modes (cosine) in arbitrary units [a] or [A ~> a]
Snm_Im [in]
SHT coefficients for the imaginary modes (sine) in the same arbitrary units as Snm_Re [a] or [A ~> a]
var [out]
Output 2-D variable in the same arbitrary units as Snm_Re and Snm_Im [a] or [A ~> a]
Nd [in]
Maximum degree of the spherical harmonics overriding ndegree in the CS [nondim]
Callees call graph
Text view
mom_spherical_harmonics::spherical_harmonics_inverse → mom_cpu_clock_infra::cpu_clock_begin
mom_spherical_harmonics::spherical_harmonics_inverse → mom_cpu_clock_infra::cpu_clock_end
mom_spherical_harmonics::spherical_harmonics_inverse → mom_error_handler::mom_error
mom_spherical_harmonics::spherical_harmonics_inverse → mom_spherical_harmonics::order2index
Callers call graph
- subroutine spherical_harmonics_init(G, param_file, CS)
Calculate precomputed coefficients
- Parameters
G [in]
The ocean's grid structure.
param_file [in]
A structure indicating
CS [inout]
Control structure for spherical harmonic transforms
Callees call graph
Text view
mom_spherical_harmonics::spherical_harmonics_init → mom_cpu_clock_infra::cpu_clock_id
mom_spherical_harmonics::spherical_harmonics_init → mom_file_parser::interface::get_param
mom_spherical_harmonics::spherical_harmonics_init → mom_file_parser::interface::log_version
mom_spherical_harmonics::spherical_harmonics_init → mom_spherical_harmonics::calc_lmax
Callers call graph
- subroutine spherical_harmonics_end(CS)
Deallocate any variables allocated in spherical_harmonics_init
- Parameters
CS [inout]
Control structure for spherical harmonic transforms
Callers call graph
- function calc_lmax(Nd) result(lmax)
Calculates the number of real elements (cosine) of spherical harmonics given maximum degree Nd.
- Parameters
lmax
Number of real spherical harmonic modes [nondim]
Nd [in]
Maximum degree [nondim]
- function order2index(m, Nd) result(l)
Calculates the one-dimensional index number at (n=0, m=m), given order m and maximum degree Nd. It is sequenced with degree (n) changing first and order (m) changing second.
- Parameters
l
One-dimensional index number [nondim]
m [in]
Current order number [nondim]
Nd [in]
Maximum degree [nondim]
Callers call graph
Text view
mom_self_attr_load::calc_love_scaling → mom_spherical_harmonics::order2index
mom_self_attr_load::calc_sal → mom_spherical_harmonics::order2index
mom_spherical_harmonics::spherical_harmonics_forward → mom_spherical_harmonics::order2index
mom_spherical_harmonics::spherical_harmonics_inverse → mom_spherical_harmonics::order2index