Skip to content

Commit

Permalink
+Added register_unit_conversion_restarts
Browse files Browse the repository at this point in the history
  Added the new subroutine register_unit_conversion_restarts to store unit
conversion factors in the SIS2 restart files, and call this new routine at
appropriate spots in ice_model_init.  The answers in the Baltic test case
are bitwise identical.
  • Loading branch information
Hallberg-NOAA committed Oct 18, 2019
1 parent 68e01da commit bedeace
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/SIS_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module SIS_types
use MOM_file_parser, only : param_file_type
use MOM_hor_index, only : hor_index_type
use MOM_time_manager, only : time_type, time_type_to_real
use MOM_unit_scaling, only : unit_scale_type
use SIS_diag_mediator, only : SIS_diag_ctrl, post_data=>post_SIS_data
use SIS_diag_mediator, only : register_SIS_diag_field, register_static_field
use SIS_debugging, only : chksum, Bchksum, Bchksum_pair, hchksum, uvchksum
Expand All @@ -38,7 +39,7 @@ module SIS_types
public :: ice_ocean_flux_type, alloc_ice_ocean_flux, dealloc_ice_ocean_flux
public :: ocean_sfc_state_type, alloc_ocean_sfc_state, dealloc_ocean_sfc_state
public :: fast_ice_avg_type, alloc_fast_ice_avg, dealloc_fast_ice_avg, copy_FIA_to_FIA
public :: IOF_chksum, FIA_chksum
public :: IOF_chksum, FIA_chksum, register_unit_conversion_restarts
public :: ice_rad_type, ice_rad_register_restarts, dealloc_ice_rad
public :: simple_OSS_type, alloc_simple_OSS, dealloc_simple_OSS, copy_sOSS_to_sOSS
public :: redistribute_IST_to_IST, redistribute_FIA_to_FIA, redistribute_sOSS_to_sOSS
Expand Down Expand Up @@ -542,6 +543,29 @@ subroutine ice_state_register_restarts(IST, G, IG, Ice_restart, restart_file)

end subroutine ice_state_register_restarts

subroutine register_unit_conversion_restarts(US, Ice_restart, restart_file)
type(unit_scale_type), intent(inout) :: US !< A structure with unit conversion factors
type(restart_file_type), pointer :: Ice_restart !< A pointer to the restart type for the ice
character(len=*), intent(in) :: restart_file !< The name of the ice restart file

integer :: idr

! Register scalar unit conversion factors.
idr = register_restart_field(Ice_restart, restart_file, "m_to_Z", US%m_to_Z_restart, &
longname="The conversion factor from m to SIS2 height units.", &
units= "Z meter-1", no_domain=.true., mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, "m_to_L", US%m_to_L_restart, &
longname="The conversion factor from m to SIS2 length units.", &
units="L meter-1", no_domain=.true., mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, "s_to_T", US%s_to_T_restart, &
longname="The conversion factor from s to SIS2 time units.", &
units="T second-1", no_domain=.true., mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, "kg_m3_to_R", US%kg_m3_to_R_restart, &
longname="The conversion factor from kg m-3 to SIS2 density units.", &
units="R m3 kg-1", no_domain=.true., mandatory=.false.)

end subroutine register_unit_conversion_restarts

!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> ice_state_read_alt_restarts reads in alternative variables that might have
!! been in the restart file, specifically dealing with changing between
Expand Down
4 changes: 4 additions & 0 deletions src/ice_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module ice_model_mod
use SIS_types, only : ice_state_type, alloc_IST_arrays, dealloc_IST_arrays
use SIS_types, only : IST_chksum, IST_bounds_check, ice_state_register_restarts
use SIS_types, only : ice_state_read_alt_restarts, register_fast_to_slow_restarts
use SIS_types, only : register_unit_conversion_restarts
use SIS_types, only : copy_IST_to_IST, copy_FIA_to_FIA, copy_sOSS_to_sOSS
use SIS_types, only : copy_TSF_to_TSF, redistribute_TSF_to_TSF
use SIS_types, only : copy_Rad_to_Rad, redistribute_Rad_to_Rad
Expand Down Expand Up @@ -2081,6 +2082,7 @@ subroutine ice_model_init(Ice, Time_Init, Time, Time_step_fast, Time_step_slow,

call alloc_IST_arrays(sHI, sIG, sIST, omit_tsurf=Eulerian_tsurf, do_ridging=do_ridging)
call ice_state_register_restarts(sIST, sG, sIG, Ice%Ice_restart, restart_file)
call register_unit_conversion_restarts(Ice%sCS%US, Ice%Ice_restart, restart_file)

call alloc_ocean_sfc_state(Ice%sCS%OSS, sHI, sIST%Cgrid_dyn, gas_fields_ocn)
Ice%sCS%OSS%kmelt = kmelt
Expand Down Expand Up @@ -2228,6 +2230,8 @@ subroutine ice_model_init(Ice, Time_Init, Time, Time_step_fast, Time_step_slow,
! whether the Ice%Ice...restart types are associated.
call ice_type_fast_reg_restarts(fGD%mpp_domain, CatIce, &
param_file, Ice, Ice%Ice_fast_restart, fast_rest_file)
if (split_restart_files) &
call register_unit_conversion_restarts(Ice%fCS%US, Ice%Ice_fast_restart, fast_rest_file)

if (redo_fast_update .or. .not.single_IST) then
call alloc_IST_arrays(fHI, Ice%fCS%IG, Ice%fCS%IST, &
Expand Down

0 comments on commit bedeace

Please sign in to comment.