-
Notifications
You must be signed in to change notification settings - Fork 237
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
separate diagnostic fill of total tend from passing of total tend to pkg/layers #720
base: master
Are you sure you want to change the base?
Conversation
The values for tottend[T,S] are calculated when (1) diagnostics of tottend[T,S] are requested outside of pkg/layers AND/OR (2) diagnostics of tottend[T,S] are requested INSIDE pkg/layers. In case of (2) inside pkg/layers, prior to being diagnosed, the tottend variables are being passed around as input arguments for subroutines layers_calc.F and layers_fluxcalc.F, prior to the final diagnostic call. Here, we introduce (a) option LAYERS_DIAG_TOTTEND in LAYERS_OPTIONS.h (default to #define) to strip all array definitions, subroutine arguments, and related calculations, thus saving memory and computed time, and (b) logical "layers_diag_tottendTS" (default to .TRUE.) to allow the filling of the layers diagnotics.
@jm-c I made some changes, as you will see, by introducing two new things:
The reason for 1 is explained above: even if we don't want to diagnose, we're still passing around very large arrays and computing things that are all zeros. The reason for 2, instead of just using diagnostic_is_on , is that the names of the diagnostics are not fixed, with a number "1" or "2" floating around depending on order of T/S (although it might have been hardcoded 1=T, 2=S, or the other way around... but I dont want to make a mess in diagnostics_fill_state.F to determine this string, which requiring several other pkg/layers variables.. so i make it easier by defining the associated/accompanied logical. |
Due to the way tottend variables are being used, defined, calculated, and subsequently diagnosed within pkg/layers, the best approach is to wrap it around the ifdef block as now done with previously defined LAYERS_DIAG_TOTTEND compiling option without the need of accompanied complexity of another logical. Now, outside of pkg/layers, if uselayers is true, the tottend is being computed and a call is done to pass it into pkg/layers. However, inside pkg/layers, only within #ifdef LAYERS_DIAG_TOTTEND block will any calculations and diagnostics relevant to tottend will be done.
@jm-c after looking more carefully at the way tottend variables are used in pkg/layers and how to call this from outside, i've simplified the problem by a. doing as you suggested in diagnostics_fill_state.F: simply hook in the additional check for useLayers. Even though this variable is defined outside of pkg/layers, a subsequent call to routine layers_fill requires the additional wrap "#ifdef ALLOW_LAYERS" . Edit: the failed readthedoc is not due to any of my changes i believe. |
@antnguyen13 I tried to run "testreport -devel" using gfortran but got this error when running
Could you check ? |
@jm-c eeks, i'm appalled by my sloppiness.. now should be ok! ps- I will ask for your help at the next devel meeting on which tot[T,S]tend to diagnose, as it turns out the one I'm trying to get correct here is useless for nlfs, and so even when pkg/layers is compiled, the tot[T,S]tend being passed in are not useful at all for closing budgets. What i'm hoping to diagnose is the tot[T,S]tend that accounts for the changing hFac such that when diagnosed at THIS timestep it is equivalent to snap shots of NEXT time-step minus THIS timestep (the type we use for closing offline budgets). |
2 comments:
|
- Register the use of Layers-Thermodynamics code by setting new switch "layers_useThermo", set at compile time (CPP option LAYERS_THERMODYNAMICS) since, currently, there is no run-time params for this ; - Add a stop if Layers-Thermodynamics code is use without pkg/diagnostics (since all the calls are within "IF ( useDiagnostics )" ; Note: put new switch in (new) dedicated header file "LAYERS_SWITCH.h" to facilitate access from outside pkg/layers (no need to include LAYERS_OPTIONS.h)
using the (new) "layers_useThermo" switch (instead of "useLayers") allow to refine the condition and only call pkg/layers S/R when Layers-Thermodynamics code is used also some minor changes that minimize differences with original version
@antnguyen13 I pushed my little changes. If you don't like these we could revert the 2 commits. |
What changes does this PR introduce?
Enable users to calculate the total tendencies of theta and salt and pass to pkg/layers independent of whether diagnostics TOTTTEND and TOTSTEND are filled or not.
What is the current behaviour?
The calculation of total tendencies for theta/salt and passing of these to pkg/layers will be non-zeroes only if the diagnostics to TOT[T,S]TEND are filled. If not, zeros are passed to pkg/layers, variable layers_tottend is filled with zeros inside subroutine layers_fill inside layers_save.F and diagnostics LTto[1SLT,2TH,3RHO] and LSto[1SLT,2TH,3RHO] are all zeros.
What is the new behaviour
Separate the if/def block for filling the diagnostics from the calculation of tendencies, such that non-zeros tendencies can be passed to pkg/layers independent of whether the diagnostics are filled.
Does this PR introduce a breaking change?
None.
Other information:
Suggested addition to
tag-index
(To avoid unnecessary merge conflicts, please don't update
tag-index
. One of the admins will do that when merging your pull request.)