+(*)Grid rotation now works with restarts#787
Merged
Hallberg-NOAA merged 3 commits intoNOAA-GFDL:dev/gfdlfrom Feb 13, 2025
Merged
+(*)Grid rotation now works with restarts#787Hallberg-NOAA merged 3 commits intoNOAA-GFDL:dev/gfdlfrom
Hallberg-NOAA merged 3 commits intoNOAA-GFDL:dev/gfdlfrom
Conversation
dc3ed28 to
23f6aa8
Compare
23f6aa8 to
3a94606
Compare
marshallward
approved these changes
Feb 12, 2025
Member
|
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
Member
Author
|
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 was referenced Apr 23, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_restartand the initialization of the model from a re start file.Added the new
zero_zerosoptional argument to the 10MOM_write_field()routines inMOM_ioand the 6rescale_comp_data()routines inMOM_domain_infrato 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
turnsoptional argument to 6 versions of theMOM_read_data()routines to allow for the reading to override the number of turns in theMOM_domainthat is passed into these routines. Several internalturnsvariables in the same routines were renamedqturnsto allow for the new optional arguments. Also check for whether theMOM_domain%domain_inpointer 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
checksumsstored 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
conversionfactors 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_pairoptional 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_gridcharacter 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_gridstrings 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: