Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculating online self-attraction and loading with spherical harmonic transforms #210

Merged
merged 9 commits into from
Oct 13, 2022

Conversation

herrwang0
Copy link

This PR adds the functionality of computing tidal self-attraction and loading (SAL) with spherical harmonic transforms (SHT). This is a loose adoption of the same functionality from the Model for Prediction Across Scales (MPAS)-Ocean developed by Los Alamos National Laboratory and University of Michigan (Barton et al. (2022) and Brus et al. (2022)).

The SAL term is calculated in a "brute-force" way by directly calculating the spherical harmonic transforms.

  1. At each grid point, the SSH field is projected onto a certain number of spherical harmonic modes.
  2. For each mode, the projection coefficients at all grid points are summed globally to get the spherical harmonic coefficient of that mode.
  3. The spherical harmonic coefficients are multiplied by a scaling factor, which is a function of mode number and mode-specific Love numbers
  4. The scaled spherical harmonic coefficients are inversely transformed to construct the SAL field.

Two new modules are introduced.

  • Module MOM_spherical_harmonics is a self-contained module to include all functions related to SHT, instead of embedded in the tidal module. It gives the flexibility to use SHT for any field.
  • Module MOM_load_love_number contains only a hard-code 4x1441 data array. This setup makes sure the tidal module is not getting overly inflated.

One module is modified.
Module MOM_tidal_forcing is modified for obvious reasons. At the moment, SAL calculation (either the scalar approximation or the added SHT methods) is embedded in the tidal forcing module. It would probably make sense to separate them out in the future, as the SAL effect is not necessarily limited to tides.

@codecov
Copy link

codecov bot commented Sep 29, 2022

Codecov Report

Merging #210 (aea1115) into dev/gfdl (b7018c6) will decrease coverage by 0.09%.
The diff coverage is 1.04%.

@@             Coverage Diff              @@
##           dev/gfdl     #210      +/-   ##
============================================
- Coverage     37.20%   37.11%   -0.10%     
============================================
  Files           262      263       +1     
  Lines         72871    73062     +191     
  Branches      13619    13644      +25     
============================================
+ Hits          27112    27114       +2     
- Misses        40743    40929     +186     
- Partials       5016     5019       +3     
Impacted Files Coverage Δ
...ameterizations/lateral/MOM_spherical_harmonics.F90 0.00% <0.00%> (ø)
...rc/parameterizations/lateral/MOM_tidal_forcing.F90 36.45% <3.92%> (-6.70%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an important new contribution to MOM6, and it is substantially complete and correct. I can envision a number of extensions or refinement to these new capabilities, but for now I think that this should be accepted into MOM6 as it is.

This is an initial step to add the functionality of calculating
self-attraction and loading (SAL) with the spherical harmonic transform
(SHT) method. The code in this commit is a direction translation and
adoption of the "parallel SAL" from MPAS-Ocean model developed at the
Department of Energy's Los Alamos National Laboratory
(Barton et al. (2022) and Brus et al. (2022)).

This commit serves as an "MVP" so that the MPAS-Ocean algorithm is
functional in MOM6. Further refactor, optimization and documentation
should be put in place.

* A new module MOM_spherical_harmonics is introduced to house
precomputed coefficients used for SHT.
* New subroutines are added in module MOM_tidal_forcing for calculating
SAL with the SHT method.
The actual calculation of SHT is stripped out of the tidal SAL
subroutine to make module MOM_spherical_harmonics self-contained.

* Forward and inverse spherical harmonic transform calculations are
imported from MOM_tidal_forcing module, as two new subroutines are in
module MOM_spherical_harmonics. This generalization allows the
spherical harmonic transforms to applications other than SSH based SAL.
* The main loops in the two new subroutine are also simplified.
* Child variables in the control structure for SHT are now private.
* The associated Legendre polynomials in the diagonal (n=m) is now
precomputed and stored, rather than recalculating at every step. This
does not have the memory cost as fully precomputing all the polynomials,
but still reduces some repeat calculations. The performance appears to
be improved with this change.
* SAL calculation is simplified as forward transform, scaling and
inverse transform.
* A few variables names inherited from MPAS-O are changed.
* A new module is introduced with the sole purpose of storing Love
numbers. This makes module MOM_tidal_forcing less chunkier and easier
to read.

* A new function in module MOM_spherical_harmonics is introduced to
calculate the starting index of the first element for each order m,
replacing a previous function of a similar purpose but a bit more
complicated.
* Option to do reproducing sums for forward spherical harmonic transform
is added, which is controlled by a runtime parameter.

* New timers are added to monitor the performance of the more expensive
global sum.
* Associated Legendre polynomials calculation is vectorized.

* Some redundant variables are removed.

* Fix filename suffix for module MOM_spherical_harmonics
* In MOM_tidal_forcing module, spherical harmonic coefficients (for SAL)
are now parts of tidal_forcing_CS to avoid repeated allocations. The
same applies to the Love number scaling factors.

* Allocations for arrays used for reproducing sums are moved to
subroutine spherical_harmonics_init in the MOM_spherical_harmonics
module.
* Documentations are added for all modules related to SHT SAL.
References from the MPAS-O group will need to be updated once they are
published.

* Variables names are shortened and changed to follow MOM6 style.
(from camel to snake)

* Change RhoE and RhoW in Love number scaling to runtime parameters

* Correct a bug in a_recur size

* Local arrays in SHT subroutines are properly initialized.
* Love number scaling coefficients multiplication is re-ordered to avoid
ambiguity and to follow MOM6 style.
* Coefficients for Pmm is simplified.

Both changes introduce bit-wise level answer change to previous SHT SAL
related unpublished commits.

* Patches for Doxygen
@Hallberg-NOAA
Copy link
Member

This PR has passed pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/17073. All answers in existing test cases are bitwise identical, but there is a new runtime parameter, so the MOM_parameter_doc files have changed.

@Hallberg-NOAA Hallberg-NOAA merged commit a907bfd into NOAA-GFDL:dev/gfdl Oct 13, 2022
@herrwang0 herrwang0 deleted the add_inline_sal_rebase branch May 20, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants