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

[Feature] delnflux all nord #3

Merged
merged 16 commits into from
Feb 27, 2024
Merged

[Feature] delnflux all nord #3

merged 16 commits into from
Feb 27, 2024

Conversation

FlorianDeconinck
Copy link
Collaborator

@FlorianDeconinck FlorianDeconinck commented Feb 8, 2024

The original port of DelnFlux used the 3 first values of the nord_dictionary to compute. The original code reads the nord value for all K-levels and decides to execute the code or not.

GEOS use case showed that the assumption in pyFV3 is incorrect. On top of that, the time "optimized" by the strategy is minimal and by virtue of the DSL should not lie in the hands of the modelers.

In this PR:

  • We add version.py to introduce a IS_GEOS switch that can be used to differentiate between numerical choices between NOAA and NASA

  • Full nord coverage for DelnFlux

  • Add check on column calculation taken as hypothesis for downstream calculations

  • FV3GFS/GEOS differences solving:

    • d2_high_order_stencil as a difference of orders operations
    • nord & damp column calculation goes all the way to the n_sponge layer in GEOS

    NOTE: to do FV3GFS/GEOS swap we use the constant file in ndsl, a known refactorable entity.

GEOS/FV3GFS: d2_highord_stencil ops order difference
Add extra check on the value of nord which is taken as an hypothesis downstream
@FlorianDeconinck FlorianDeconinck changed the title Feature/delnflux all nord [Feature] delnflux all nord Feb 9, 2024
Vorticity damping GEOS differs from FV3GFS
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

One question for Lucas, one question for Florian, and one change to d_sw

pyFV3/stencils/d_sw.py Outdated Show resolved Hide resolved
pyFV3/version.py Show resolved Hide resolved
pyFV3/stencils/delnflux.py Show resolved Hide resolved
pyFV3/stencils/delnflux.py Show resolved Hide resolved
pyFV3/stencils/delnflux.py Show resolved Hide resolved
):
with computation(PARALLEL), interval(...):
if nord > current_nord:
d2 = ((fx - fx[1, 0, 0]) + (fy - fy[0, 1, 0])) * rarea
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lharris4 Mathematically this is the same as the version used in SHiELD, but with parens around the fx/fy subtraction to enforce the order of operations. Is it ok to merge these together or should we keep separate versions for GEOS and NOAA applications?

Choose a reason for hiding this comment

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

I think this is OK although the former may make it easier for the compiler to optimize. Is there any particular reason to do it this way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At double floating precision, this has minimal to no impact. At single precision, however the order of the subtraction has measurable impacts (especially because of close-to-zero behavior of a lot of those codes).

A large amount of those diff pattern have been corrected in the GEOS fork of FV3.

Choose a reason for hiding this comment

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

Great. We'd like to include a number of these in the GFDL FV3 also.

@FlorianDeconinck FlorianDeconinck changed the base branch from main to develop February 16, 2024 16:33
oelbert
oelbert previously approved these changes Feb 20, 2024
Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

This looks good. It would be nice to be able to combine the d2_higherorder stencils if possible, but that can happen in a subsequent PR. I'll open an issue for it.

@lharris4
Copy link

lharris4 commented Feb 21, 2024 via email

@FlorianDeconinck
Copy link
Collaborator Author

FlorianDeconinck commented Feb 21, 2024

Hi, Florian. Thank you for letting me know. We hadn't seen these changes in the GEOS fork of FV3 before; I know GMAO had been working on some order-of-operation changes to avoid rounding-error mass loss at single precision but hadn't heard whether they were successful. This would potentially be useful for the GFDL main branch too. Lucas

My pleasure. If this project can have the side effect of updating people on work that hasn't been diffused then I am doubly glad! I'll chat with Bill about it before we merge this.

@FlorianDeconinck
Copy link
Collaborator Author

@oelbert / @lharris4

As expected, those changes were part of the work to keep mass conservation at single precision. GEOS is running single precision by default for a while with good results on that side.

Going forward I'll push those changes in as fixes rather than code differences between the two agencies.

@FlorianDeconinck
Copy link
Collaborator Author

@oelbert Ready for merge (once tests come back happy)

Copy link
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

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

I'm happy with this 👍

Copy link
Contributor

@fmalatino fmalatino left a comment

Choose a reason for hiding this comment

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

Approved

):
with computation(PARALLEL), interval(...):
if nord > current_nord:
d2 = ((fx - fx[1, 0, 0]) + (fy - fy[0, 1, 0])) * rarea

Choose a reason for hiding this comment

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

Great. We'd like to include a number of these in the GFDL FV3 also.

@@ -1240,38 +639,40 @@ def __call__(self, q, fx2, fy2, damp_c, d2, mass=None):
"""

if mass is None:
self._d2_damp(q, d2, damp_c)
self._d2_damp(q=q, d2=d2, damp=damp_c, nord=self._nord)

Choose a reason for hiding this comment

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

Note that some of these damping coefficients are layer-dependent (ie. much stronger and lower-order damping in the sponge layer).

@fmalatino fmalatino merged commit 1780efb into develop Feb 27, 2024
2 checks passed
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.

4 participants