Skip to content

Commit

Permalink
addition of namelist based skip restart functionality to dlnd, docn, …
Browse files Browse the repository at this point in the history
…drof, dwav (#180)

* add skip_restart functionality to all components that can use it
  • Loading branch information
mvertens authored Aug 25, 2022
1 parent a42fb93 commit 7c3a567
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 19 deletions.
10 changes: 10 additions & 0 deletions dlnd/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@
<desc>ending year to loop data over (only used when DLND_MODE is CPLHIST or GLC_CPLHIST)</desc>
</entry>

<entry id="DLND_SKIP_RESTART_READ">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_dlnd</group>
<file>env_run.xml</file>
<desc> If set to true, than dlnd restarts will not be read on a continuation run.
</desc>
</entry>

<help>
=========================================
DLND naming conventions
Expand Down
13 changes: 13 additions & 0 deletions dlnd/cime_config/namelist_definition_dlnd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@
</values>
</entry>

<entry id="skip_restart_read" modify_via_xml="DLND_SKIP_RESTART_READ">
<type>logical</type>
<category>dlnd</category>
<group>dlnd_nml</group>
<desc>
If set to true, than dlnd restarts will not be read on a continuation run.
This capability is used, for example, in CTSM spinup runs.
</desc>
<values>
<value>$DLND_SKIP_RESTART_READ</value>
</values>
</entry>

</entry_id>
22 changes: 11 additions & 11 deletions dlnd/lnd_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module cdeps_dlnd_comp
character(CL) :: restfilm = nullstr ! model restart file namelist
integer :: nx_global ! global nx dimension of model mesh
integer :: ny_global ! global ny dimension of model mesh

logical :: skip_restart_read = .false. ! true => skip restart read in continuation
! linked lists
type(fldList_type) , pointer :: fldsExport => null()
type(dfield_type) , pointer :: dfields => null()
Expand Down Expand Up @@ -173,7 +173,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

namelist / dlnd_nml / datamode, model_meshfile, model_maskfile, &
nx_global, ny_global, restfilm, force_prognostic_true
nx_global, ny_global, restfilm, skip_restart_read

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -207,17 +207,17 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(nx_global , mpicom, 'nx_global')
call shr_mpi_bcast(ny_global , mpicom, 'ny_global')
call shr_mpi_bcast(restfilm , mpicom, 'restfilm')
call shr_mpi_bcast(force_prognostic_true , mpicom, 'force_prognostic_true')
call shr_mpi_bcast(skip_restart_read , mpicom, 'skip_restart_read')

! write namelist input to standard out
if (my_task == main_task) then
write(logunit,F00)' model_meshfile = ',trim(model_meshfile)
write(logunit,F00)' model_maskfile = ',trim(model_maskfile)
write(logunit ,*)' datamode = ',datamode
write(logunit ,*)' nx_global = ',nx_global
write(logunit ,*)' ny_global = ',ny_global
write(logunit ,*)' restfilm = ',trim(restfilm)
write(logunit ,*)' force_prognostic_true = ',force_prognostic_true
write(logunit,F00)' model_meshfile = ',trim(model_meshfile)
write(logunit,F00)' model_maskfile = ',trim(model_maskfile)
write(logunit,F00)' datamode = ',datamode
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F02)' skip_restart_read = ',skip_restart_read
endif

! Validate sdat datamode
Expand Down Expand Up @@ -278,7 +278,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Read restart if necessary
if (restart_read) then
if (restart_read .and. .not. skip_restart_read) then
call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat)
end if

Expand Down
6 changes: 6 additions & 0 deletions docn/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
if type(streamlist) == type(str()):
streamlist = []

# Determine if skip restart is asked for and if it is a valid request
skip_restart_read = case.get_value('DOCN_SKIP_RESTART_READ')
if skip_restart_read:
if docn_mode == 'som' or docn_mode == 'som_aquap':
expect (False, f"xml variable DOCN_SKIP_RESTART_READ cannot be TRUE for docn_mode {docn_mode}")

# Generate docn.streams.xml if needed
print("docn_mode is {}".format(docn_mode))
if (re.search(r'sst_aquap[0-9]+',docn_mode) is not None) or (docn_mode == 'sst_aquap_constant'):
Expand Down
10 changes: 10 additions & 0 deletions docn/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@
This is only used when DOCN_MODE=prescribed.</desc>
</entry>

<entry id="DOCN_SKIP_RESTART_READ">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_docn</group>
<file>env_run.xml</file>
<desc> If set to true, than docn restarts will not be read on a continuation run.
</desc>
</entry>

<help>
=========================================
DOCN naming conventions
Expand Down
13 changes: 13 additions & 0 deletions docn/cime_config/namelist_definition_docn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,17 @@
</values>
</entry>

<entry id="skip_restart_read" modify_via_xml="DOCN_SKIP_RESTART_READ">
<type>logical</type>
<category>docn</category>
<group>docn_nml</group>
<desc>
If set to true, than docn restarts will not be read on a continuation run.
This capability is used, for example, in CTSM spinup runs.
</desc>
<values>
<value>$DOCN_SKIP_RESTART_READ</value>
</values>
</entry>

</entry_id>
7 changes: 5 additions & 2 deletions docn/ocn_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ module cdeps_docn_comp
character(CL) :: restfilm = nullstr ! model restart file namelist
integer :: nx_global
integer :: ny_global
logical :: skip_restart_read = .false. ! true => skip restart read in continuation run

! linked lists
type(fldList_type) , pointer :: fldsImport => null()
Expand Down Expand Up @@ -191,7 +192,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

namelist / docn_nml / datamode, &
model_meshfile, model_maskfile, &
restfilm, nx_global, ny_global, sst_constant_value
restfilm, nx_global, ny_global, sst_constant_value, skip_restart_read

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -227,6 +228,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F02)' skip_restart_read = ',skip_restart_read
endif

! Broadcast namelist input
Expand All @@ -237,6 +239,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(ny_global , mpicom, 'ny_global')
call shr_mpi_bcast(restfilm , mpicom, 'restfilm')
call shr_mpi_bcast(sst_constant_value , mpicom, 'sst_constant_value')
call shr_mpi_bcast(skip_restart_read , mpicom, 'skip_restart_read')

! Special logic for prescribed aquaplanet
if (datamode(1:9) == 'sst_aquap' .and. trim(datamode) /= 'sst_aquap_constant') then
Expand Down Expand Up @@ -499,7 +502,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod
end select

! Read restart if needed
if (restart_read) then
if (restart_read .and. .not. skip_restart_read) then
select case (trim(datamode))
case('sstdata', 'sst_aquap_file')
call docn_datamode_copyall_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat)
Expand Down
10 changes: 10 additions & 0 deletions drof/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@
<desc>ending year to loop data over (only used when DROF_MODE is CPLHIST)</desc>
</entry>

<entry id="DROF_SKIP_RESTART_READ">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_drof</group>
<file>env_run.xml</file>
<desc> If set to true, than drof restarts will not be read on a continuation run.
</desc>
</entry>

<help>
=========================================
DROF naming conventions
Expand Down
13 changes: 13 additions & 0 deletions drof/cime_config/namelist_definition_drof.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,17 @@
</values>
</entry>

<entry id="skip_restart_read" modify_via_xml="DROF_SKIP_RESTART_READ">
<type>logical</type>
<category>drof</category>
<group>drof_nml</group>
<desc>
If set to true, than drof restarts will not be read on a continuation run.
This capability is used, for example, in CTSM spinup runs.
</desc>
<values>
<value>$DROF_SKIP_RESTART_READ</value>
</values>
</entry>

</entry_id>
8 changes: 5 additions & 3 deletions drof/rof_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module cdeps_drof_comp
character(CL) :: restfilm = nullstr ! model restart file namelist
integer :: nx_global
integer :: ny_global

logical :: skip_restart_read = .false. ! true => skip restart read
logical :: diagnose_data = .true.
integer , parameter :: main_task=0 ! task number of main task
character(*) , parameter :: rpfile = 'rpointer.rof'
Expand Down Expand Up @@ -171,7 +171,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

namelist / drof_nml / datamode, model_meshfile, model_maskfile, &
restfilm, nx_global, ny_global
restfilm, nx_global, ny_global, skip_restart_read

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -206,6 +206,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F02)' skip_restart_read = ',skip_restart_read
end if

! broadcast namelist input
Expand All @@ -215,6 +216,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(nx_global , mpicom, 'nx_global')
call shr_mpi_bcast(ny_global , mpicom, 'ny_global')
call shr_mpi_bcast(restfilm , mpicom, 'restfilm')
call shr_mpi_bcast(skip_restart_read , mpicom, 'skip_restart_read')

! Validate datamode
if (trim(datamode) == 'copyall') then
Expand Down Expand Up @@ -389,7 +391,7 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Read restart if needed
if (restart_read) then
if (restart_read .and. .not. skip_restart_read) then
call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat)
end if

Expand Down
10 changes: 10 additions & 0 deletions dwav/cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
<desc>DWAV mode</desc>
</entry>

<entry id="DWAV_SKIP_RESTART_READ">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_dwav</group>
<file>env_run.xml</file>
<desc> If set to true, than dwav restarts will not be read on a continuation run.
</desc>
</entry>

<help>
=========================================
DWAV naming conventions
Expand Down
13 changes: 13 additions & 0 deletions dwav/cime_config/namelist_definition_dwav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,17 @@
</values>
</entry>

<entry id="skip_restart_read" modify_via_xml="DWAV_SKIP_RESTART_READ">
<type>logical</type>
<category>dwav</category>
<group>dwav_nml</group>
<desc>
If set to true, than dwav restarts will not be read on a continuation run.
This capability is used, for example, in CTSM spinup runs.
</desc>
<values>
<value>$DWAV_SKIP_RESTART_READ</value>
</values>
</entry>

</entry_id>
8 changes: 5 additions & 3 deletions dwav/wav_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module cdeps_dwav_comp
character(CL) :: restfilm = nullstr ! model restart file namelist
integer :: nx_global
integer :: ny_global

logical :: skip_restart_read = .false. ! true => skip restart read
! constants
logical :: diagnose_data = .true.
integer , parameter :: main_task=0 ! task number of main task
Expand Down Expand Up @@ -168,7 +168,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

namelist / dwav_nml / datamode, model_meshfile, model_maskfile, &
restfilm, nx_global, ny_global
restfilm, nx_global, ny_global, skip_restart_read

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -203,6 +203,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F02)' skip_restart_read = ',skip_restart_read
endif

! broadcast namelist input
Expand All @@ -212,6 +213,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(nx_global , mpicom, 'nx_global')
call shr_mpi_bcast(ny_global , mpicom, 'ny_global')
call shr_mpi_bcast(restfilm , mpicom, 'restfilm')
call shr_mpi_bcast(skip_restart_read , mpicom, 'skip_restart_read')

! Call advertise phase
if (trim(datamode) == 'copyall') then
Expand Down Expand Up @@ -266,7 +268,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Read restart if necessary
if (restart_read) then
if (restart_read .and. .not. skip_restart_read) then
call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat)
end if

Expand Down

0 comments on commit 7c3a567

Please sign in to comment.