+Add and use optional conversion argument to register_field in MOM_io_file#780
Merged
Hallberg-NOAA merged 3 commits intoNOAA-GFDL:dev/gfdlfrom Jan 30, 2025
Merged
Conversation
0340817 to
e2be482
Compare
Added the option to rescale variables as they are written out via MOM_io_file. These involved adding optional conversion arguments to register_field_infra and register_field_nc, which are then stored in a new element in the MOM_field type, and use the conversion factors to unscale variables before they are written in the ten write_field routines in MOM_io_file. The new optional arguments to register_field are used in MOM_create_file, taking their values from the vardesc types sent to this routine. This commit also alters modify_vardesc to store the value of the conversion optional argument in the conversion element of the vardesc type. Also modified query_vardesc so that the conversion factor is returned via the conversion optional argument. These steps had been intended when these optional arguments were first added, but for some reason they had not actually been used. The conversion values stored in a vardesc type are also now used in the register_diag_field call in ocean_register_diag. However, it does not appear that ocean_register_diag is actually used anymore, so it might be a candidate for deletion. All answers are bitwise identical, but there are new optional arguments to publicly visible routines.
Revised write_energy to use conversion arguments to var_desc to unscale variables. Their units are also documented in the same calls, so this is now analogous to what is done the register_diag_field calls for diagnostics that are handled by the MOM_diag_mediator. All calculations in write_energy and almost all internal variables are now in rescaled units. All answers and output are bitwise identical.
Corrected 4 conversion arguments in calls to var_desc for temperatures and salinities, so that they are consistent with the units of these variables and the described purpose of the conversion element of the var_desc type. Until the conversion arguments to modify_vardesc and query_vardesc, these incorrect values were inconsequential, but now they need to be fixed before they are inadvertently used. All answers are bitwise identical.
Member
|
I can't recall if The only comment I have is that implicit allocation could simplify some of these functions. The you could use implicit allocation and write it as Or you just put in the argument All of these should be equivalent, so I will tenatively approve this and let you decide if you want to make the adjustment. |
marshallward
approved these changes
Jan 29, 2025
e2be482 to
f0026ca
Compare
This was referenced Apr 23, 2025
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 three commits, the first of which adds the ability to rescale output variables that are written by the
MOM_io_fileroutines analogously to what is already available for variables that are written viaMOM_write_field()or viaMOM_diag_mediator(). The second commit uses this new capability inwrite_energy()and revises the internal calculations inwrite_energy()to work almost entirely with rescaled variables. The third commit corrects 4 conversion arguments tovar_desc()calls now that they might actually be used.The specific changes include the addition of a new optional conversion argument to
register_field(), code to rescale variables in 10write_field()routines, changes tomodify_vardesc()andquery_vardesc()to properly store and retrieve conversion factors, and the use of these new capabilities inocean_register_diag()andwrite_energy().All answers and output are bitwise identical, but there are new optional arguments to publicly visible types. The specific commits in this PR include: