+Improved buoyancy flux diagnostics in non-Boussinesq or layered mode - #1167
Open
Hallberg-NOAA wants to merge 5 commits into
Open
+Improved buoyancy flux diagnostics in non-Boussinesq or layered mode#1167Hallberg-NOAA wants to merge 5 commits into
Hallberg-NOAA wants to merge 5 commits into
Conversation
Moved two identical blocks of code that calculate terms related to the stratification after mixing and the work done by various mixing terms into a new internal subroutine, diagnose_strat_Kd_work(), that is now called from both diabatic_ALE() and diabatic_ALE_legacy(). There is also some refactoring of the code in diagnose_strat_Kd_work() to avoid array-syntax math and bring it into alignment with the MOM6 code style. All answers are bitwise identical.
Added a new call to diagnose_strat_Kd_work() from within diabatic_layer() when temperature and salinity are used as state variables. Also fixed the diagnostics of Kd_heat and Kd_salt in layered mode by setting the pertinent variables even when KPP or double diffusion are not being used. As written, the `Bflx_dia_...` diagnostics are meaningless without temperature and salinity as state variables, so there is a new `use_EOS` argument to Kd_work_init() and these diagnostics are no longer offered in runs without an equation of state. All answers are bitwise identical, but there are new diagnostics available in some non-ALE mode runs and fewer diagnostics in the available_diags file for others.
Eliminated the separate non-Boussinesq code to calculate N2_salt and N2_temp in diagnose_Kd_work(). The non-Boussinesq code previously used the Boussinesq reference density (via GV%Z_to_H) for several diagnostics, which is inconsistent with not making the Boussinesq approximation. Ironically, the Boussinesq code did not depend on the Boussinesq reference density when run in non-Boussinesq mode, because it used GV%H_to_RZ instead of GV%Rho0. So this commit both simplifies the code and fixes the diagnostics of the stratification in non-Boussinesq mode. All solutions are bitwise identical, but some diagnostics do change in non-Boussinesq mode.
Revised the interface to KdWork_Diagnostics() to pass in Kd_salt and Kd_heat rather than storing them in the VBF_CS. These arrays are always available when KdWork_Diagnostics is called, and storing them just leads to an extra 3-d array copy. Internally within the diabatic_driver code, these arrays are also being passed into diagnose_strat_Kd_work(), which calls KdWork_Diagnostics(). All answers are bitwise identical, but there are changes to a publicly visible interface.
Moved Bflx_salt, Bflx_temp, Bflx_salt_dz and Bflx_temp_dz from the VBF_CS into KdWork_Diagnostics() as simple local arrays. These were not exposed outside of KdWork_Diagnostics(), so there was no reason for them to have the more persistent memory that their inclusion in the type entailed. Also added local variables with the combinations of scaling factors that are repeatedly used for spatially integrating the layer-integrated buoyancy fluxes or as conversion factors for work or buoyancy flux diagnostics. All answers are bitwise identical, but there are 4 fewer arrays in a transparent type.
Hallberg-NOAA
force-pushed
the
revise_strat_Kd_work_diags
branch
from
August 28, 2026 18:39
d144434 to
e456e9b
Compare
|
Are there any updates on this pending pull request, @Hallberg-NOAA and @breichl ? I see it failed some tests. |
|
Hi @knlowman, I have inspected the code and agree with the proposed changes. I am planning to do some tests in OM5 as soon as possible to confirm that the updated diagnostics look right before I approve the PR, but I anticipate things should be okay. I am unsure why there are failed tests, but I do not think that they are problematic. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR consists of a series of 5 commits that make the
Kd_heatandKd_saltdiagnostics and the variousBflx_dia_...diagnostics work when MOM6 is run in layered mode and temperature and salinity are used as state variables. When temperature and salinity are not state variables, these diagnostics do not make sense, so they are no longer registered as diagnostics and no longer appear in theavailable_diagsfiles.The duplicated code the stratification diagnostics in the diabatic driver was consolidated into the new internal subroutine
diagnose_strat_Kd_work(), which is now called with all 3 options in the diabatic driver.This PR also eliminates the separate non-Boussinesq code to calculate
N2_saltandN2_tempindiagnose_Kd_work(). The non-Boussinesq code previously used the Boussinesq reference density (viaGV%Z_to_H) for several diagnostics, which is inconsistent with not making the Boussinesq approximation. Ironically, the Boussinesq code did not depend on the Boussinesq reference density when run in non-Boussinesq mode, because it usedGV%H_to_RZinstead ofGV%Rho0. So this commit both simplifies the code and fixes the diagnostics of the stratification in non-Boussinesq mode.Finally, there are two sets of changes refactoring
KdWork_Diagnostics()for better memory use and to limit the unnecessary exposure of arrays that are not intended to be used outside of this routine. This PR includes a commit that revises the interface to KdWork_Diagnostics() to pass inKd_saltandKd_heatrather than storing them in the VBF_CS. These arrays are always available whenKdWork_Diagnostics()is called, and storing them just leads to an extra 3-d array copy. Internally within the diabatic driver code, these arrays are also being passed intodiagnose_strat_Kd_work(), which callsKdWork_Diagnostics(). The final commit movesBflx_salt,Bflx_temp,Bflx_salt_dzandBflx_temp_dzfrom theVBF_CSintoKdWork_Diagnostics()as simple local arrays. These were not exposed outside ofKdWork_Diagnostics(), so there was no reason for them to have the more persistent memory that their inclusion in the type entailed. As a part of the refactoring of MOM_diagnose_KdWork.F90, it also adds local variables with the combinations of scaling factors that are repeatedly used for spatially integrating the layer-integrated buoyancy fluxes or as conversion factors for work or buoyancy flux diagnostics, and it does some minor clean-up on the syntax of theregister_diag_field()calls inKdWork_init()to follow the MOM6 style guide.All solutions are bitwise identical, but there are (deliberate) changes in some non-Boussinesq diagnostics and other layer-mode diagnostics that were previously just reporting zeros, while other diagnostics are no longer being offered in cases when they would have been nonsensical.