-
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
+(*)Grid rotation now works with restarts #787
+(*)Grid rotation now works with restarts #787
Conversation
dc3ed28
to
23f6aa8
Compare
23f6aa8
to
3a94606
Compare
This solves several issues that were unresolved in the rotational grid support.
The option |
Added the new zero_zeros optional argument to the 10 MOM_write_field routines in MOM_io and the 6 rescale_comp_data routines in MOM_domain_infra to cause negative zeros to replaced with ordinary signless zeros before they are written out to files. This has no impact at all on answers, but it does help with comparisons between rotated restart files, in which meaningless differences between positive and negative zeros were leading to false differences between files. All answers are bitwise identical, and all output is equivalent, but there are new optional arguments to 16 routines covered by 2 publicly visible interfaces.
Added a new turns optional argument to 6 versions of the MOM_read_data routines to allow for the reading to override the number of turns in the MOM_domain that is passed into these routines. Several internal turns variables in the same routines were renamed qturns to allow for the new optional arguments. Also check for whether the MOM_domain%domain_in pointer is associated before it is used, avoiding a segmentation fault that was occurring when a restart file is read and ROTATE_INDEX is true. Also added rotate_array calls to ensure that the halo values are retained while reading data into a rotated array. These changes are necessary to allow for the model to be initialized from a restart files with rotated grids. Several instances of continuation line indentation that do not follow the typical 4-space pattern used elsewhere in the MOM6 code and documented in the MOM6 style guide were also altered to follow the standard. All answers that previously worked are bitwise identical, but there are new optional arguments to publicly visible interfaces.
Modified MOM_restart so that restart files generated by rotated runs match unrotated restart files, and the model can be properly initialized from a restart file when the grid is rotated. Also added runtime options to convert negative zeros into ordinary zeros before they are written to restart files (selected with RESTART_UNSIGNED_ZEROS) and to properly do the checksums on the velocity points on all of the faces (selected with RESTART_SYMMETRIC_CHECKSUMS). Also added the new interfaces copy_restart_var and copy_restart vector to use the names of restart variables and the pointers stored in the restart control structure to obtain a copy of the variables as the restart variables with the option to undo the rotation. These routines are necessary because the reading of restart files occurs during a phase of the model initialization that works on an unrotated grid, and they are called from inside of MOM_initialize_state. The ranges for the checksums are now set correctly for each variable, depending on where it is discretized, but when RESTART_SYMMETRIC_CHECKSUMS is false, the previous ranges are still used so answers do not change in unrotated test case. The conversion factors used for the pair of register_restart_field calls in register_restart_pair now include the necessary sign changes for the rotation, as set in the new internal routine set_conversion_pair. There is also now a scalar_pair optional argument to the register_restart_pair routines to accommodate the rotation of pairs of scalars that do not change sign when rotated (e.g., grid-lengths). Instead of working with the hor_grid character string, the restart code has been modified to instead use the encoded integer position argument returned from query_vardesc. This avoids several redundant blocks of code that translate the hor_grid strings into positions. All answers are bitwise identical when there is no grid rotation, but with grid rotation the restart files that are created are modified to have the correct signs and replicate the restart fields with no rotation. Also, cases with grid rotation can now be reinitialized from restart files, while previously this simply did not work, either giving an incorrect reinitialized state or a segmentation fault. There are also two new runtime parameters in some MOM_parameter_doc files.
3a94606
to
258ca83
Compare
This PR has passed pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/pipelines/26358 with the expected warnings about new entries in MOM_parameter_doc files. |
This PR consists of 3 commits that together will allow for simulations with grid rotation to properly read restart files and write restart files that are equivalent to those that are generated with an unrotated grid. The restart are not identical because the FMS
field_chksum()
function is giving different answers for equivalent arrays for reasons that are not yet understood, so for now the use of the restart files with rotated grids will only work in some cases whenRESTART_CHECKSUMS_REQUIRED = False
. The first two commits add new optional arguments to I/O related framework routines to facilitate these changes, while the third commit makes the necessary changes toMOM_restart
and the initialization of the model from a re start file.Added the new
zero_zeros
optional argument to the 10MOM_write_field()
routines inMOM_io
and the 6rescale_comp_data()
routines inMOM_domain_infra
to cause negative zeros to replaced with ordinary signless zeros before they are written out to files. This has no impact at all on answers, but it does help with comparisons between rotated restart files, in which meaningless differences between positive and negative zeros were leading to false differences between files.Added a new
turns
optional argument to 6 versions of theMOM_read_data()
routines to allow for the reading to override the number of turns in theMOM_domain
that is passed into these routines. Several internalturns
variables in the same routines were renamedqturns
to allow for the new optional arguments. Also check for whether theMOM_domain%domain_in
pointer is associated before it is used, avoiding a segmentation fault that was occurring when a restart file is read andROTATE_INDEX = true
. Also added rotate_array calls toensure that the halo values are retained while reading data into a rotated array.Modified
MOM_restart()
so that restart files generated by rotated runs match unrotated restart files, and the model can be properly initialized from a restart file when the grid is rotated. Also added runtime options to convert negative zeros into ordinary zeros before they are written to restart files (selected withRESTART_UNSIGNED_ZEROS
) and to properly do the checksums on the velocity points on all of the faces (selected withRESTART_SYMMETRIC_CHECKSUMS
).Also added the new interfaces
copy_restart_var()
andcopy_restart_vector()
to use the names of restart variables and the pointers stored in the restart control structure to obtain a copy of the variables as the restart variables with theoption to undo grid rotation. These routines are necessary because the reading of restart files occurs during a phase of the model initialization that works on an unrotated grid, and they are called from inside of MOM_initialize_state.
The ranges for the
checksums
stored in restart files are now set correctly for each variable, depending on where it is discretized, but whenRESTART_SYMMETRIC_CHECKSUMS = false
(the default), the previous ranges are still used so answers do not change in unrotated test case.The
conversion
factors used for the pair ofregister_restart_field()
calls inregister_restart_pair()
now include the necessary sign changes for the rotation, as set in the new internal routineset_conversion_pair()
. There is also now ascalar_pair
optional argument to theregister_restart_pair()
routines to accommodate the rotation of pairs ofscalars that do not change sign when rotated (e.g., grid-lengths).
Instead of working with the
hor_grid
character string, the restart code has been modified to instead use the encoded integer position argument returned fromquery_vardesc()
. This avoids several redundant blocks of code that translate thehor_grid
strings into positions.All answers are bitwise identical when there is no grid rotation, but with grid rotation the restart files that are created are modified to have the correct signs and replicate the restart fields with no rotation. Also, cases with grid rotation can now be reinitialized from restart files, while previously this simply did not work, either giving an incorrect reinitialized state or a
segmentation fault. There are two new runtime parameters in some MOM_parameter_doc files, and there are new optional arguments to several publicly visible routines. This commits in this PR include: