-
Notifications
You must be signed in to change notification settings - Fork 65
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
+Add and use optional conversion argument to register_field in MOM_io_file #780
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.
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. |
e2be482
to
f0026ca
Compare
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 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: