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

Use bottom pressure anomaly for self-attraction and loading #731

Open
wants to merge 6 commits into
base: dev/gfdl
Choose a base branch
from

Conversation

herrwang0
Copy link

@herrwang0 herrwang0 commented Sep 29, 2024

This PR adds the option of using bottom pressure anomaly to calculate self-attraction and loading (SAL). Currently, sea surface height (SSH) is used for SAL, which is only accurate for barotropic flows. (SSH is the barotropic equivalent of bottom pressure anomaly.)

  • A new runtime parameter SAL_USE_BPA is added to use bottom pressure anomaly. The option requires an input file for long term mean reference bottom pressure.

    • The reference bottom pressure field is stored with SAL_CS rather than PressureForce_FV_CS.
    • When SAL_USE_BPA is true, total bottom pressure field is used as the input for subroutine calc_SAL(), the reference pressure is subtracted within the subroutine.
  • SAL calculation in Boussinesq mode is refactored in order to

    1. calculate SAL after bottom pressure is calculated.
    2. fix a longstand bug that SAL and tides geopotential height anomaly is added to interface height before density is calculated. Note that even though the newly-added parameter SSH_IN_EOS_PRESSURE_FOR_PGF also fix this bug, the refactor avoids having SAL code appear in multiple places.
  • Add an alternative method for SAL and tides in Boussinesq mode, controlled by runtime parameter BOUSSINESQ_SAL_TIDES (default=False). The current method in Boussinesq mode has a baroclinic component of tidal forcing and SAL. While it is arguably consistent with the Boussinesq approximation, it might also be confusing. The alternative method directly calculate the gradients of tidal forcing and SAL and add them to PF[uv].

  • Old answers with TIDES_ANSWER_DATE<=20230630 are not changed. But answers with TIDES_ANSWER_DATE>20230630 in Boussinesq mode are changed at bit-level. Since the default of TIDES_ANSWER_DATE is currently 20230630, there is probably no compelling reason to preserve answers after that date.

  • All old answers are preserved with the correct answer date value.

Self-attraction and loading calculation in Boussinesq pressure gradient
force is refactored to be consistent with the algorithm in
non-Boussinesq version.
Using SSH to calculate self-attraction and loading (SAL) is only
accurate for barotropic flows. Bottom pressure anomaly should really be
used for general purposes.

* New runtime parameter
A runtime parameter SAL_USE_BPA is added to use bottom pressure anomaly.
The option requires an input file for long term mean reference bottom
pressure. The reference bottom pressure field is stored with SAL_CS.

* Refactor SAL and tides in Boussinesq mode
As the total bottom pressure is needed for bottom pressure anomaly, SAL
calculation in Boussinesq mode needs to be refactored. In addition,
there is a longstanding bug in Boussinesq mode that interface height is
modified by SAL and tides, and the modified interface height is
erroneously used for density and pressure calculation later on.
Therefore the SAL and tides are refactored by moving their calculations
after pressure is calculated. Tide answers before 20230630 is retained.
Answers after 20230630 are changed for Boussinesq mode.
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.61%. Comparing base (df2cd12) to head (9f6c39b).
Report is 7 commits behind head on dev/gfdl.

Additional details and impacted files
@@             Coverage Diff              @@
##           dev/gfdl     #731      +/-   ##
============================================
- Coverage     36.68%   36.61%   -0.07%     
============================================
  Files           274      274              
  Lines         84037    84211     +174     
  Branches      15808    15854      +46     
============================================
+ Hits          30829    30835       +6     
- Misses        47393    47547     +154     
- Partials       5815     5829      +14     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

I think that this code is technically correct, and a compiler should have no problem with it, but I found the use of the pbot_anom and bpa with different units and meanings to be very confusing.

I would strongly prefer that we simply have separate 2-d arrays, with different well-described units for SSH in [Z ~> m] and pbot_anom in [R L2 Z2 ~> Pa]. I think that the added computational cost of one added 2-d array that is not actually used would be negligible compared to the human-time cost of making this code harder to understand and more susceptible to bugs if we ever had to revise it!

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.

With the recent updates, I think that this code is now correct and constitutes the addition of some valuable new capabilities.

@Hallberg-NOAA Hallberg-NOAA added enhancement New feature or request Parameter change Input parameter changes (addition, removal, or description) labels Nov 29, 2024
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.

Upon further reflection, I think that there is a minor problem with this PR. Answers should only change when an answer_date is set to a higher value than the date at which a change is made or anticipated to be merged in. Failing to do so runs the risk of breaking regression testing.

This commit will change answers if TIDES_ANSWER_DATE > 20230630. I think that this PR needs to be modified so that if TIDES_ANSWER_DATE > 20230630 but TIDES_ANSWER_DATE < 20241201, and answers are only changed to the new values if TIDES_ANSWER_DATE >= 20241201 (or perhaps another date like 20250101).

* Local variable SSH is renamed to pbot_anom.
* Tides related local variable names are changed to be less confusing.
Notably, `e_sal_tide` is renamed to `e_sal_and_tide` (the summation of
sal and tide), not to be confused with `e_tide_sal`, which is renamed to
`e_tidal_sal` (sal from tides).
* Fix e_tidal diagnostics in Boussinesq mode. The term was not assigned
if tide answer date is >20230630.
Add an alternative method for SAL and tides in Boussinesq mode. The
current method adjusts interface heights with geopotential height
anomaly for SAL and tides. For non-Boussinesq mode, the current method
is algebraically the same as taking the gradient of SAL and tide
geopotential (body forcing). For Boussinesq mode, there is a baroclinic
component of tidal forcing and SAL. The alternative method is added to
calculate the gradient of tidal forcing and SAL directly at the cost of
additional multiplications. The new method is controlled by runtime
parameter BOUSSINESQ_SAL_TIDES.
* Instead of rescaling bottom pressure to height unit,
calc_Loving_scaling is modified to be conditionally dimensional. When
calculating self-attraction and loading, Love numbers are now
dimensional when bottom pressure anomaly is used as an input. This
change eliminate Love numbers' dependence on mean seawater density.

* A new coefficient called linear_scaling is added to SAL CS for the
same purpose, although to use bottom pressure anomaly for scalar
approximation is not quite justifiable. A WARNING is given when users
try to do that.

* Two separate field, SSH (sea surface height anomaly) and pbot (total
bottom pressure), are used for calculating self attraction and loading
when SAL_USE_BPA = False and SAL_USE_BPA = True, respectively. The
change is to enhance code readability.
A new date for TIDES_ANSWER_DATE is added to recover answers for tides
in Boussinesq mode before 20250201.
@herrwang0
Copy link
Author

A new critical answer date (20250201) is added to recover answers in Boussinesq mode between [20230701, 20250201). Some thorough tests are done offline to assure that all answers can be recovered with the correct date value.

I also squashed some of the minor middle commits and made sure each of the existing commit is compilable. It seems to me that each of the current six commits has its own purpose and is self-contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Parameter change Input parameter changes (addition, removal, or description)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants