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

+Add and use optional conversion argument to register_field in MOM_io_file #780

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

Conversation

Hallberg-NOAA
Copy link
Member

@Hallberg-NOAA Hallberg-NOAA commented Dec 15, 2024

This PR consists of three commits, the first of which adds the ability to rescale output variables that are written by the MOM_io_file routines analogously to what is already available for variables that are written via MOM_write_field() or via MOM_diag_mediator(). The second commit uses this new capability in write_energy() and revises the internal calculations in write_energy() to work almost entirely with rescaled variables. The third commit corrects 4 conversion arguments to var_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 10 write_field() routines, changes to modify_vardesc() and query_vardesc() to properly store and retrieve conversion factors, and the use of these new capabilities in ocean_register_diag() and write_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:

  • e2be48235 Fix 4 conversion arguments to var_desc calls
  • cb2f49094 Specify conversion factors in write_energy
  • c3da6766e +Add optional conversion argument to register_field

@Hallberg-NOAA Hallberg-NOAA added enhancement New feature or request refactor Code cleanup with no changes in functionality or results labels Dec 15, 2024
@Hallberg-NOAA Hallberg-NOAA changed the title +Add and use optional conversion argument to register_field file +Add and use optional conversion argument to register_field in MOM_io_file Dec 15, 2024
  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.
@Hallberg-NOAA Hallberg-NOAA force-pushed the conversion_in_MOM_io_file branch from 0340817 to e2be482 Compare December 29, 2024 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Code cleanup with no changes in functionality or results
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant