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

Collocate units and conversion for register_diag_field calls #1390

Merged
merged 3 commits into from
May 19, 2021

Conversation

Hallberg-NOAA
Copy link
Collaborator

Rearranged arguments in register_diag_field calls to facilitate the detection
of inconsistent units and scaling factors using simple methods, by placing the
unit and conversion arguments on the same line. At some point, we will develop
more sophisticated methods for detecting such inconsistencies, at which these
changes will lose their value but become benign. Also, made use of the scaling
factor GV%H_to_MKS, which handles conversion of thickness units to m or kg m-2,
depending on whether the code is being run in Boussinesq or non-Boussinesq mode,
instead of having logic scattered in several places throughout the code to
select GV%H_to_m or GV%H_to_kg_m2. This commit closes MOM6 issue #1384. All
answers and output are bitwise identical, and these are mostly essentially
whitespace changes.

  Rearranged arguments in register_diag_field calls to facilitate the detection
of inconsistent units and scaling factors using simple methods, by placing the
unit and conversion arguments on the same line.  At some point, we will develop
more sophisticated methods for detecting such inconsistencies, at which these
changes will lose their value but become benign.  Also, made use of the scaling
factor GV%H_to_MKS, which handles conversion of thickness units to m or kg m-2,
depending on whether the code is being run in Boussinesq or non-Boussinesq mode,
instead of having logic scattered in several places throughout the code to
select GV%H_to_m or GV%H_to_kg_m2.  This commit closes MOM6 issue mom-ocean#1384.  All
answers and output are bitwise identical, and these are mostly essentially
whitespace changes.
@marshallward
Copy link
Collaborator

The following grep seems capable of printing register_diag_field calls which contain a conversion argument:

grep -rPazo 'register_diag_field *\((.|(?<!\))\n)*conversion *=(.*?)\)\n' src/

It assumes lines end with )\n. It can probably be extended to handle comments.

Copy link
Collaborator

@marshallward marshallward left a comment

Choose a reason for hiding this comment

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

While generally one should avoid coding to the tool (in this case grep), I agree that this is a benign change that will make it easier to detect unit consistency.

@marshallward
Copy link
Collaborator

marshallward commented May 19, 2021

@marshallward marshallward merged commit 1562e8f into mom-ocean:dev/gfdl May 19, 2021
@Hallberg-NOAA Hallberg-NOAA deleted the conversion_arg_order branch July 30, 2021 17:58
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.

2 participants