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

+Fix dimensional rescaling with HARMONICS_SAL #503

Merged

Conversation

Hallberg-NOAA
Copy link
Member

Corrected dimensional rescaling bugs in the spherical harmonics SAL code. An issue with horizontal length scaling was corrected by using G%Rad_Earth_L in place of G%Rad_Earth in spherical_harmonics_init. There are new optional tmp_scale arguments to calc_SAL and spherical_harmonics_forward to allow the rescaling to be undone before calling the reproducing sums.

This commit also modifies the call to the reproducing sums in spherical_harmonics_forward so that all real or imaginary components are calculated with a single call, which reduces the cost of the SAL calculation reproducing sums from about 6.7 times the cost with non-reproducing sums to just 5.5 times as much in testing with the tides_025 test case.

There is also code added to avoid NaNs arising from a square root operating on a negative argument from a 32-bit integer roll-over when a very large number of harmonics components (more than 1024 x 1024) are unadvisedly being used.

While this commit corrects the dimensional scaling when HARMONICS_SAL is true, all answers are bitwise identical when no rescaling is used or when the spherical harmonics SAL is not used. There are new optional arguments to two publicly visible interfaces.

@Hallberg-NOAA Hallberg-NOAA added bug Something isn't working enhancement New feature or request labels Oct 13, 2023
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #503 (90be302) into dev/gfdl (467d1dd) will increase coverage by 0.00%.
The diff coverage is 8.33%.

❗ Current head 90be302 differs from pull request most recent head ae5bc65. Consider uploading reports for the commit ae5bc65 to get more accurate results

@@            Coverage Diff            @@
##           dev/gfdl     #503   +/-   ##
=========================================
  Coverage     37.52%   37.53%           
=========================================
  Files           270      270           
  Lines         79059    79064    +5     
  Branches      14629    14630    +1     
=========================================
+ Hits          29670    29673    +3     
- Misses        43923    43925    +2     
  Partials       5466     5466           
Files Coverage Δ
src/core/MOM_PressureForce_FV.F90 39.47% <33.33%> (ø)
src/core/MOM_PressureForce_Montgomery.F90 9.86% <0.00%> (ø)
...c/parameterizations/lateral/MOM_self_attr_load.F90 38.15% <33.33%> (ø)
...ameterizations/lateral/MOM_spherical_harmonics.F90 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

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

@Hallberg-NOAA Hallberg-NOAA force-pushed the spherical_harm_scaling_fix branch from 0295d4e to 7a65f46 Compare October 13, 2023 13:38
@marshallward
Copy link
Member

@herrwang Do you mind reviewing these changes?

Copy link

@herrwang0 herrwang0 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

src/parameterizations/lateral/MOM_spherical_harmonics.F90 Outdated Show resolved Hide resolved
  Corrected dimensional rescaling bugs in the spherical harmonics SAL code.  An
issue with horizontal length scaling was corrected by using G%Rad_Earth_L in
place of G%Rad_Earth in spherical_harmonics_init.  There are new optional
tmp_scale arguments to calc_SAL and spherical_harmonics_forward to allow the
rescaling to be undone before calling the reproducing sums.

  This commit also modifies the call to the reproducing sums in
spherical_harmonics_forward so that all real or imaginary components are
calculated with a single call, which reduces the cost of the SAL calculation
reproducing sums from about 6.7 times the cost with non-reproducing sums to just
5.5 times as much in testing with the tides_025 test case.

  There is also code added to avoid NaNs arising from a square root operating
on a negative argument from a 32-bit integer roll-over when a very large
number of harmonics components (more than 1024 x 1024) are unadvisedly being
used.

  While this commit corrects the dimensional scaling when HARMONICS_SAL is true,
all answers are bitwise identical when no rescaling is used or when the
spherical harmonics SAL is not used.  There are new optional arguments to two
publicly visible interfaces.
@Hallberg-NOAA Hallberg-NOAA force-pushed the spherical_harm_scaling_fix branch from 7a65f46 to b589181 Compare October 30, 2023 14:54
Copy link
Member

@marshallward marshallward left a comment

Choose a reason for hiding this comment

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

@marshallward
Copy link
Member

Gaea regression: https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/21155 ✔️

@marshallward marshallward merged commit 19f0147 into NOAA-GFDL:dev/gfdl Oct 30, 2023
10 checks passed
@Hallberg-NOAA Hallberg-NOAA deleted the spherical_harm_scaling_fix branch November 8, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants