forked from mom-ocean/MOM6
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Open
Hallberg-NOAA
wants to merge
3
commits into
NOAA-GFDL:dev/gfdl
Choose a base branch
from
Hallberg-NOAA:fix_rotated_restarts
base: dev/gfdl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+(*)Grid rotation now works with restarts #787
Hallberg-NOAA
wants to merge
3
commits into
NOAA-GFDL:dev/gfdl
from
Hallberg-NOAA:fix_rotated_restarts
Conversation
This file contains 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
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. 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.
Hallberg-NOAA
added
bug
Something isn't working
enhancement
New feature or request
Parameter change
Input parameter changes (addition, removal, or description)
labels
Dec 26, 2024
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.
Hallberg-NOAA
force-pushed
the
fix_rotated_restarts
branch
from
December 26, 2024 20:59
e33f93f
to
dc3ed28
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
enhancement
New feature or request
Parameter change
Input parameter changes (addition, removal, or description)
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 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 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.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
.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: