Skip to content

Commit

Permalink
+Add unit conversion capability for restarts
Browse files Browse the repository at this point in the history
  Added optional arguments to framework code to permit the restart files to work
with dimensionally unscaled variables.  All answers are bitwise identical, but
there are new optional arguments for multiple public interfaces.

 - Added a new conversion factor element, conv, to the field_restart type to
   specify how a field is to be unscaled before writing, and whose reciprocal is
   used to scale restart fields as they are read in.

 - Added the new optional argument conversion to each of the
   register_restart_field() and register_restart_pair() routines, which is used
   to specify how each field will be rescaled when it is written to or read from
   a restart file.  The default is the same as setting this to 1.

 - Added the new optional argument unscaled to fix_restart_scaling() and
   fix_restart_unit_scaling() to reset the unit conversion factors that will be
   save to the restart files to 1, consistent with writing out fields without
   scaling to the restart files.
  • Loading branch information
Hallberg-NOAA committed Mar 21, 2022
1 parent 966d50f commit 11d03b1
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 67 deletions.
9 changes: 8 additions & 1 deletion src/core/MOM_verticalGrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,17 @@ subroutine verticalGridInit( param_file, GV, US )
end subroutine verticalGridInit

!> Set the scaling factors for restart files to the scaling factors for this run.
subroutine fix_restart_scaling(GV)
subroutine fix_restart_scaling(GV, unscaled)
type(verticalGrid_type), intent(inout) :: GV !< The ocean's vertical grid structure
logical, optional, intent(in) :: unscaled !< If true, set the restart factors as though the
!! model would be unscaled, which is appropriate if the
!! scaling is undone when writing a restart file.

GV%m_to_H_restart = GV%m_to_H
if (present(unscaled)) then ; if (unscaled) then
GV%m_to_H_restart = 1.0
endif ; endif

end subroutine fix_restart_scaling

!> Returns the model's thickness units, usually m or kg/m^2.
Expand Down
Loading

0 comments on commit 11d03b1

Please sign in to comment.