From 1f7234f38ccaba880c5c1650ff3c587dfc87f295 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 30 Aug 2024 17:11:19 -0600 Subject: [PATCH 01/12] starting the translation --- datm/atm_comp_nuopc.F90 | 23 ++++++++++++----------- datm/datm_datamode_cfsr_mod.F90 | 8 ++++---- datm/datm_datamode_clmncep_mod.F90 | 8 ++++---- datm/datm_datamode_core2_mod.F90 | 8 ++++---- datm/datm_datamode_cplhist_mod.F90 | 8 ++++---- datm/datm_datamode_era5_mod.F90 | 8 ++++---- datm/datm_datamode_gefs_mod.F90 | 8 ++++---- datm/datm_datamode_jra_mod.F90 | 8 ++++---- datm/datm_datamode_simple_mod.F90 | 8 ++++---- dice/dice_datamode_ssmi_mod.F90 | 9 +++++---- dice/ice_comp_nuopc.F90 | 7 ++++--- dshr/dshr_mod.F90 | 19 ++++++++++--------- 12 files changed, 63 insertions(+), 59 deletions(-) diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index 7a2a41c7..9fd846f9 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -479,7 +479,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Run datm - call datm_comp_run(importstate, exportstate, current_ymd, current_tod, current_mon, & + call datm_comp_run(gcomp, importstate, exportstate, current_ymd, current_tod, current_mon, & orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write=.false., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -561,7 +561,7 @@ subroutine ModelAdvance(gcomp, rc) ! Run datm call ESMF_TraceRegionEnter('datm_run') - call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, & + call datm_comp_run(gcomp, importstate, exportstate, next_ymd, next_tod, mon, & orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit('datm_run') @@ -579,7 +579,7 @@ subroutine ModelAdvance(gcomp, rc) end subroutine ModelAdvance !=============================================================================== - subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, target_mon, & + subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod, target_mon, & orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) ! ---------------------------------- @@ -587,6 +587,7 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe ! ---------------------------------- ! input/output variables + type(ESMF_GridComp) , intent(in) :: gcomp type(ESMF_State) , intent(inout) :: importState type(ESMF_State) , intent(inout) :: exportState integer , intent(in) :: target_ymd ! model date @@ -650,21 +651,21 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe if (restart_read .and. .not. skip_restart_read) then select case (trim(datamode)) case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_core2_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('CORE_IAF_JRA') - call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_jra_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('CLMNCEP') - call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_clmncep_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('CPLHIST') - call datm_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_cplhist_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('ERA5') - call datm_datamode_era5_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_era5_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('GEFS') - call datm_datamode_gefs_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_gefs_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('CFSR') - call datm_datamode_cfsr_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_cfsr_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('SIMPLE') - call datm_datamode_simple_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call datm_datamode_simple_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) end select end if diff --git a/datm/datm_datamode_cfsr_mod.F90 b/datm/datm_datamode_cfsr_mod.F90 index 8ad8cd3d..c3aa6020 100644 --- a/datm/datm_datamode_cfsr_mod.F90 +++ b/datm/datm_datamode_cfsr_mod.F90 @@ -238,18 +238,18 @@ subroutine datm_datamode_cfsr_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine datm_datamode_cfsr_restart_write !=============================================================================== - subroutine datm_datamode_cfsr_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_cfsr_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_cfsr_restart_read diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index 41a9725c..e9c982af 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -610,18 +610,18 @@ subroutine datm_datamode_clmncep_restart_write(case_name, inst_suffix, ymd, tod, end subroutine datm_datamode_clmncep_restart_write !=============================================================================== - subroutine datm_datamode_clmncep_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_clmncep_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_clmncep_restart_read diff --git a/datm/datm_datamode_core2_mod.F90 b/datm/datm_datamode_core2_mod.F90 index 41d2caae..7e68893a 100644 --- a/datm/datm_datamode_core2_mod.F90 +++ b/datm/datm_datamode_core2_mod.F90 @@ -429,18 +429,18 @@ subroutine datm_datamode_core2_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine datm_datamode_core2_restart_write !=============================================================================== - subroutine datm_datamode_core2_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_core2_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_core2_restart_read diff --git a/datm/datm_datamode_cplhist_mod.F90 b/datm/datm_datamode_cplhist_mod.F90 index 482bb7a0..c13ccef9 100644 --- a/datm/datm_datamode_cplhist_mod.F90 +++ b/datm/datm_datamode_cplhist_mod.F90 @@ -220,18 +220,18 @@ subroutine datm_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, end subroutine datm_datamode_cplhist_restart_write !=============================================================================== - subroutine datm_datamode_cplhist_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_cplhist_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_cplhist_restart_read diff --git a/datm/datm_datamode_era5_mod.F90 b/datm/datm_datamode_era5_mod.F90 index e10fe302..84224a03 100644 --- a/datm/datm_datamode_era5_mod.F90 +++ b/datm/datm_datamode_era5_mod.F90 @@ -337,18 +337,18 @@ subroutine datm_datamode_era5_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine datm_datamode_era5_restart_write !=============================================================================== - subroutine datm_datamode_era5_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_era5_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_era5_restart_read diff --git a/datm/datm_datamode_gefs_mod.F90 b/datm/datm_datamode_gefs_mod.F90 index 86e6939a..16c97990 100644 --- a/datm/datm_datamode_gefs_mod.F90 +++ b/datm/datm_datamode_gefs_mod.F90 @@ -240,18 +240,18 @@ subroutine datm_datamode_gefs_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine datm_datamode_gefs_restart_write !=============================================================================== - subroutine datm_datamode_gefs_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_gefs_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_gefs_restart_read diff --git a/datm/datm_datamode_jra_mod.F90 b/datm/datm_datamode_jra_mod.F90 index 9eb81515..43bc3c2f 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -1,7 +1,7 @@ module datm_datamode_jra_mod use ESMF , only : ESMF_State, ESMF_StateGet, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO - use ESMF , only : ESMF_MeshGet + use ESMF , only : ESMF_MeshGet, ESMF_GridComp use ESMF , only : ESMF_StateItem_Flag, ESMF_STATEITEM_NOTFOUND, operator(/=) use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -323,18 +323,18 @@ subroutine datm_datamode_jra_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine datm_datamode_jra_restart_write !=============================================================================== - subroutine datm_datamode_jra_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine datm_datamode_jra_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_jra_restart_read diff --git a/datm/datm_datamode_simple_mod.F90 b/datm/datm_datamode_simple_mod.F90 index ca978c15..c614f046 100644 --- a/datm/datm_datamode_simple_mod.F90 +++ b/datm/datm_datamode_simple_mod.F90 @@ -361,18 +361,18 @@ subroutine datm_datamode_simple_restart_write(case_name, inst_suffix, ymd, tod, end subroutine datm_datamode_simple_restart_write !=============================================================================== - subroutine datm_datamode_simple_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine datm_datamode_simple_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + use ESMF, only : ESMF_GridComp ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) end subroutine datm_datamode_simple_restart_read diff --git a/dice/dice_datamode_ssmi_mod.F90 b/dice/dice_datamode_ssmi_mod.F90 index 6f15fc9c..1196c831 100644 --- a/dice/dice_datamode_ssmi_mod.F90 +++ b/dice/dice_datamode_ssmi_mod.F90 @@ -2,7 +2,7 @@ module dice_datamode_ssmi_mod use ESMF , only : ESMF_State, ESMF_LogWrite, ESMF_Array, ESMF_MeshGet use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_DistGrid - use ESMF , only : ESMF_ArrayCreate, ESMF_ArrayDestroy + use ESMF , only : ESMF_ArrayCreate, ESMF_ArrayDestroy, ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort @@ -586,9 +586,10 @@ subroutine dice_datamode_ssmi_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine dice_datamode_ssmi_restart_write !=============================================================================== - subroutine dice_datamode_ssmi_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - + subroutine dice_datamode_ssmi_restart_read(gcomp, rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + use nuopc_shr_methods, only : shr_get_rpointer_name ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit @@ -601,7 +602,7 @@ subroutine dice_datamode_ssmi_restart_read(rest_filem, inst_suffix, logunit, my_ allocate(water(sdat%model_lsize)) ! read restart - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat, & + call dshr_restart_read(gcomp, rest_filem, 'ice', nullstr, logunit, my_task, mpicom, sdat, & fld=water, fldname='water') end subroutine dice_datamode_ssmi_restart_read diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 63539e81..c5a44a48 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -450,7 +450,7 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Run dice - call dice_comp_run(importState, exportState, next_ymd, next_tod, cosarg, restart_write, rc) + call dice_comp_run(gcomp, importState, exportState, next_ymd, next_tod, cosarg, restart_write, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit(subname) @@ -458,13 +458,14 @@ subroutine ModelAdvance(gcomp, rc) end subroutine ModelAdvance !=============================================================================== - subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosarg, restart_write, rc) + subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod, cosarg, restart_write, rc) ! -------------------------- ! advance dice ! -------------------------- ! input/output variables: + type(ESMF_GridComp), intent(in) :: gcomp type(ESMF_State) , intent(inout) :: exportState type(ESMF_State) , intent(inout) :: importState integer , intent(in) :: target_ymd ! model date @@ -504,7 +505,7 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar if (restart_read) then select case (trim(datamode)) case('ssmi', 'ssmi_iaf') - call dice_datamode_ssmi_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call dice_datamode_ssmi_restart_read(gcomp, restfilm, inst_suffix, logunit, my_task, mpicom, sdat) end select end if diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index faa346b6..bfd33703 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -950,17 +950,19 @@ subroutine dshr_time_init( Time, ymd, cal, tod, rc) end subroutine dshr_time_init !=============================================================================== - subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & + subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & logunit, my_task, mpicom, sdat, fld, fldname) ! Read restart file use dshr_stream_mod, only : shr_stream_restIO use ESMF, only : ESMF_VMGetCurrent + use nuopc_shr_methods, only: shr_get_rpointer_name + ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: rpfile - character(len=*) , intent(in) :: inst_suffix + character(len=*) , intent(in) :: compname character(len=*) , intent(in) :: nullstr integer , intent(in) :: logunit integer , intent(in) :: my_task @@ -970,6 +972,7 @@ subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & character(len=*) , optional , intent(in) :: fldname ! local variables + character(len=ESMF_MAXSTR) :: rpfile type(ESMF_VM) :: vm integer :: nu logical :: exists ! file existance @@ -990,13 +993,11 @@ subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & exists = .false. if (trim(rest_filem) == trim(nullstr)) then if (my_task == main_task) then + call shr_get_rpointer_name(gcomp, compname, rpfile, 'read', rc) + write(logunit,F00) ' restart filename from rpointer' - inquire(file=trim(rpfile)//trim(inst_suffix), exist=exists) - if (.not.exists) then - write(logunit, F00) ' ERROR: rpointer file does not exist' - call shr_sys_abort(trim(subname)//' ERROR: rpointer file missing') - endif - open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') + + open(newunit=nu, file=trim(rpfile), form='formatted') read(nu, '(a)') rest_filem close(nu) inquire(file=trim(rest_filem), exist=exists) From 7cdf9a54fa75388d04a02bb5b5a237aae4ed5030 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 4 Sep 2024 09:29:59 -0600 Subject: [PATCH 02/12] modify restart read --- dglc/dglc_datamode_noevolve_mod.F90 | 102 ++++++++++++------------ dglc/glc_comp_nuopc.F90 | 11 +-- dice/ice_comp_nuopc.F90 | 2 +- dlnd/lnd_comp_nuopc.F90 | 2 +- docn/docn_datamode_copyall_mod.F90 | 7 +- docn/docn_datamode_cplhist_mod.F90 | 7 +- docn/docn_datamode_iaf_mod.F90 | 8 +- docn/docn_datamode_multilev_dom_mod.F90 | 8 +- docn/docn_datamode_multilev_mod.F90 | 7 +- docn/docn_datamode_som_mod.F90 | 10 +-- docn/ocn_comp_nuopc.F90 | 13 +-- drof/rof_comp_nuopc.F90 | 9 ++- dshr/dshr_mod.F90 | 1 + dwav/wav_comp_nuopc.F90 | 2 +- 14 files changed, 97 insertions(+), 92 deletions(-) diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index 0c5dd8bd..566a0101 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -4,7 +4,7 @@ module dglc_datamode_noevolve_mod use ESMF , only : ESMF_Mesh, ESMF_DistGrid, ESMF_FieldBundle, ESMF_Field use ESMF , only : ESMF_FieldBundleCreate, ESMF_FieldCreate, ESMF_MeshLoc_Element use ESMF , only : ESMF_FieldBundleAdd, ESMF_MeshGet, ESMF_DistGridGet, ESMF_Typekind_R8 - use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast, ESMF_VM + use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast, ESMF_VM, ESMF_GridComp use NUOPC , only : NUOPC_Advertise, NUOPC_IsConnected use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort @@ -515,14 +515,14 @@ subroutine dglc_datamode_noevolve_restart_write(model_meshes, case_name, & end subroutine dglc_datamode_noevolve_restart_write !=============================================================================== - subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, & - inst_suffix, logunit, my_task, main_task, mpicom, & + subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & + logunit, my_task, main_task, mpicom, & pio_subsystem, io_type, nx_global, ny_global, rc) - + use nuopc_shr_methods, only : shr_get_rpointer_name ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes character(len=*) , intent(inout) :: restfilem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: main_task @@ -537,6 +537,7 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, & type(ESMF_DistGrid) :: distgrid integer :: ns character(len=CS) :: cnum + character(len=CS) :: rpfile integer :: lsize integer, pointer :: gindex(:) ! domain decomposition of data type(ESMF_VM) :: vm @@ -551,6 +552,41 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, & !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + ! Determine restart file + exists = .false. + if (trim(restfilem) == trim(nullstr)) then + if (my_task == main_task) then + call shr_get_rpointer_name(gcomp, 'glc', rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + write(logunit,'(a)') trim(subname)//' restart filename from rpointer' + open(newunit=nu, file=trim(rpfile), form='formatted') + read(nu,'(a)') restfilem + close(nu) + inquire(file=trim(restfilem), exist=exists) + endif + call ESMF_VMBroadCast(vm, restfilem, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + ! use namelist already read + if (my_task == main_task) then + write(logunit, '(a)') trim(subname)//' restart filenames from namelist ' + inquire(file=trim(restfilem), exist=exists) + endif + endif + call ESMF_VMGetCurrent(vm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + tmp = 0 + if(exists) tmp=1 + call ESMF_VMBroadCast(vm, tmp, 1, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + exists = (tmp(1) == 1) + if (.not. exists .and. my_task == main_task) then + write(logunit, '(a)') trim(subname)//' file not found, skipping '//trim(restfilem) + ! Should we return here or just abort? + return + end if + do ns = 1,num_icesheets @@ -565,55 +601,17 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, & call ESMF_DistGridGet(distGrid, localDe=0, seqIndexList=gindex, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGetCurrent(vm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Determine restart file - exists = .false. - if (trim(restfilem) == trim(nullstr)) then - if (my_task == main_task) then - write(logunit,'(a)') trim(subname)//' restart filename from rpointer' - inquire(file=trim(rpfile)//trim(inst_suffix), exist=exists) - if (.not.exists) then - write(logunit, '(a)') trim(subname)//' ERROR: rpointer file does not exist' - call shr_sys_abort(trim(subname)//' ERROR: rpointer file missing') - endif - open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') - read(nu,'(a)') restfilem - close(nu) - inquire(file=trim(restfilem), exist=exists) - endif - call ESMF_VMBroadCast(vm, restfilem, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - else - ! use namelist already read - if (my_task == main_task) then - write(logunit, '(a)') trim(subname)//' restart filenames from namelist ' - inquire(file=trim(restfilem), exist=exists) - endif - endif - tmp = 0 - if(exists) tmp=1 - call ESMF_VMBroadCast(vm, tmp, 1, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - exists = (tmp(1) == 1) ! Read restart file - if (exists) then - if (my_task == main_task) then - write(logunit, '(a)') trim(subname)//' reading data model restart '//trim(restfilem) - end if - rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(restfilem), pio_nowrite) - call pio_initdecomp(pio_subsystem, pio_double, (/nx_global(ns),ny_global(ns)/), gindex, pio_iodesc) - rcode = pio_inq_varid(pioid, 'flgl_rofi'//cnum, varid) - call pio_read_darray(pioid, varid, pio_iodesc, Fgrg_rofi(ns)%ptr, rcode) - call pio_closefile(pioid) - call pio_freedecomp(pio_subsystem, pio_iodesc) - else - if (my_task == main_task) then - write(logunit, '(a)') trim(subname)//' file not found, skipping '//trim(restfilem) - end if - endif + if (my_task == main_task) then + write(logunit, '(a)') trim(subname)//' reading data model restart '//trim(restfilem) + end if + rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(restfilem), pio_nowrite) + call pio_initdecomp(pio_subsystem, pio_double, (/nx_global(ns),ny_global(ns)/), gindex, pio_iodesc) + rcode = pio_inq_varid(pioid, 'flgl_rofi'//cnum, varid) + call pio_read_darray(pioid, varid, pio_iodesc, Fgrg_rofi(ns)%ptr, rcode) + call pio_closefile(pioid) + call pio_freedecomp(pio_subsystem, pio_iodesc) ! Deallocate gindex deallocate(gindex) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index b74e56f7..3099ee9d 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -430,7 +430,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) end do ! end loop over ice sheets ! Run dglc - call dglc_comp_run(clock, current_ymd, current_tod, restart_write=.false., valid_inputs=.true., rc=rc) + call dglc_comp_run(gcomp, clock, current_ymd, current_tod, restart_write=.false., valid_inputs=.true., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit('dglc_strdata_init') @@ -503,7 +503,7 @@ subroutine ModelAdvance(gcomp, rc) end if ! run dglc - call dglc_comp_run(clock, next_ymd, next_tod, restart_write, valid_inputs, rc=rc) + call dglc_comp_run(gcomp, clock, next_ymd, next_tod, restart_write, valid_inputs, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit(subname) @@ -511,13 +511,14 @@ subroutine ModelAdvance(gcomp, rc) end subroutine ModelAdvance !=============================================================================== - subroutine dglc_comp_run(clock, target_ymd, target_tod, restart_write, valid_inputs, rc) + subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, valid_inputs, rc) ! -------------------------- ! advance dglc ! -------------------------- ! input/output variables: + type(ESMF_GridComp) ,intent(in) :: gcomp type(ESMF_Clock) , intent(in) :: clock integer , intent(in) :: target_ymd ! model date integer , intent(in) :: target_tod ! model sec into model date @@ -557,8 +558,8 @@ subroutine dglc_comp_run(clock, target_ymd, target_tod, restart_write, valid_inp ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then write(logunit,'(a)')' DEBUG: calling dglc_datamode_noevolve_restart_read' - call dglc_datamode_noevolve_restart_read(model_meshes, restfilm, & - inst_suffix, logunit, my_task, main_task, mpicom, & + call dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilm, & + logunit, my_task, main_task, mpicom, & sdat(1)%pio_subsystem, sdat(1)%io_type, nx_global, ny_global, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index c5a44a48..39a7c7f2 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -382,7 +382,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) cosArg = 2.0_R8*shr_const_pi*(jday - jday0)/365.0_R8 ! Run dice - call dice_comp_run(importState, exportState, current_ymd, current_tod, cosarg, restart_write=.false., rc=rc) + call dice_comp_run(gcomp, importState, exportState, current_ymd, current_tod, cosarg, restart_write=.false., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Add scalars to export state diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index 56a360c8..bea64c5a 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -303,7 +303,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Read restart if necessary if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, restfilm, 'lnd', nullstr, logunit, my_task, mpicom, sdat) end if ! get the time to interpolate the stream data to diff --git a/docn/docn_datamode_copyall_mod.F90 b/docn/docn_datamode_copyall_mod.F90 index 95d4b764..a6fa3e73 100644 --- a/docn/docn_datamode_copyall_mod.F90 +++ b/docn/docn_datamode_copyall_mod.F90 @@ -1,6 +1,7 @@ module docn_datamode_copyall_mod use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS + use ESMF , only : ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal @@ -148,18 +149,18 @@ subroutine docn_datamode_copyall_restart_write(case_name, inst_suffix, ymd, tod, end subroutine docn_datamode_copyall_restart_write !=============================================================================== - subroutine docn_datamode_copyall_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_copyall_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) end subroutine docn_datamode_copyall_restart_read diff --git a/docn/docn_datamode_cplhist_mod.F90 b/docn/docn_datamode_cplhist_mod.F90 index 3ff9e65c..81fead61 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -1,6 +1,7 @@ module docn_datamode_cplhist_mod use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS + use ESMF , only : ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal @@ -142,18 +143,18 @@ subroutine docn_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, end subroutine docn_datamode_cplhist_restart_write !=============================================================================== - subroutine docn_datamode_cplhist_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_cplhist_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) end subroutine docn_datamode_cplhist_restart_read diff --git a/docn/docn_datamode_iaf_mod.F90 b/docn/docn_datamode_iaf_mod.F90 index 032467f3..23b939a2 100644 --- a/docn/docn_datamode_iaf_mod.F90 +++ b/docn/docn_datamode_iaf_mod.F90 @@ -1,5 +1,5 @@ module docn_datamode_iaf_mod - + use ESMF , only : ESMF_GridComp use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_State use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -198,20 +198,20 @@ subroutine docn_datamode_iaf_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine docn_datamode_iaf_restart_write !=============================================================================== - subroutine docn_datamode_iaf_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_iaf_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! read restart file ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) end subroutine docn_datamode_iaf_restart_read diff --git a/docn/docn_datamode_multilev_dom_mod.F90 b/docn/docn_datamode_multilev_dom_mod.F90 index 7cd7fd9e..578e2b9b 100644 --- a/docn/docn_datamode_multilev_dom_mod.F90 +++ b/docn/docn_datamode_multilev_dom_mod.F90 @@ -1,5 +1,5 @@ module docn_datamode_multilev_dom_mod - + use ESMF , only : ESMF_GridComp use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -244,20 +244,20 @@ subroutine docn_datamode_multilev_dom_restart_write(case_name, inst_suffix, ymd, end subroutine docn_datamode_multilev_dom_restart_write !=============================================================================== - subroutine docn_datamode_multilev_dom_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_multilev_dom_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! read restart file ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) end subroutine docn_datamode_multilev_dom_restart_read diff --git a/docn/docn_datamode_multilev_mod.F90 b/docn/docn_datamode_multilev_mod.F90 index 897797f3..b522862e 100644 --- a/docn/docn_datamode_multilev_mod.F90 +++ b/docn/docn_datamode_multilev_mod.F90 @@ -1,4 +1,5 @@ module docn_datamode_multilev_mod + use ESMF , only : ESMF_GridComp use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -209,20 +210,20 @@ subroutine docn_datamode_multilev_restart_write(case_name, inst_suffix, ymd, tod end subroutine docn_datamode_multilev_restart_write !=============================================================================== - subroutine docn_datamode_multilev_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_multilev_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! read restart file ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) end subroutine docn_datamode_multilev_restart_read diff --git a/docn/docn_datamode_som_mod.F90 b/docn/docn_datamode_som_mod.F90 index 672c58d4..76b6bde9 100644 --- a/docn/docn_datamode_som_mod.F90 +++ b/docn/docn_datamode_som_mod.F90 @@ -1,9 +1,9 @@ module docn_datamode_som_mod - + use ESMF , only : ESMF_SUCCESS, ESMF_State, ESMF_Clock, ESMF_StateGet, ESMF_StateItem_Flag use ESMF , only : ESMF_TimeInterval, ESMF_ClockGet, ESMF_TimeIntervalGet use ESMF , only : ESMF_LOGMSG_INFO, ESMF_STATEITEM_NOTFOUND, operator(/=) - use ESMF , only : ESMF_LogWrite + use ESMF , only : ESMF_LogWrite, ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort @@ -326,13 +326,13 @@ subroutine docn_datamode_som_restart_write(case_name, inst_suffix, ymd, tod, & end subroutine docn_datamode_som_restart_write !=============================================================================== - subroutine docn_datamode_som_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_som_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) ! read restart file ! input/output arguments + type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom @@ -343,7 +343,7 @@ subroutine docn_datamode_som_restart_read(rest_filem, inst_suffix, logunit, my_t allocate(somtp(sdat%model_lsize)) ! read restart - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat, & + call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat, & fld=somtp, fldname='somtp') end subroutine docn_datamode_som_restart_read diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index f15ed9ec..1d7366a3 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -453,7 +453,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) ! Run docn - call docn_comp_run(importState, exportState, clock, current_ymd, current_tod, restart_write=.false., rc=rc) + call docn_comp_run(gcomp, importState, exportState, clock, current_ymd, current_tod, restart_write=.false., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Add scalars to export state @@ -512,19 +512,20 @@ subroutine ModelAdvance(gcomp, rc) restart_write = dshr_check_restart_alarm(clock, rc=rc) ! run docn - call docn_comp_run(importState, exportState, clock, next_ymd, next_tod, restart_write, rc=rc) + call docn_comp_run(gcomp, importState, exportState, clock, next_ymd, next_tod, restart_write, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine ModelAdvance !=============================================================================== - subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod, restart_write, rc) + subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, target_tod, restart_write, rc) ! -------------------------- ! advance docn ! -------------------------- ! input/output variables: + type(ESMF_GridComp) , intent(in) :: gcomp type(ESMF_Clock) , intent(in) :: clock type(ESMF_State) , intent(inout) :: importState type(ESMF_State) , intent(inout) :: exportState @@ -581,11 +582,11 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod 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) + call docn_datamode_copyall_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('iaf') - call docn_datamode_iaf_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call docn_datamode_iaf_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) case('som', 'som_aquap') - call docn_datamode_som_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call docn_datamode_som_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) end select end if diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index 959421a7..5b9e5ef1 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -310,7 +310,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) ! Run drof - call drof_comp_run(exportstate, current_ymd, current_tod, restart_write=.false., rc=rc) + call drof_comp_run(gcomp, exportstate, current_ymd, current_tod, restart_write=.false., rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Add scalars to export state @@ -365,19 +365,20 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! run drof - call drof_comp_run(exportState, next_ymd, next_tod, restart_write, rc=rc) + call drof_comp_run(gcomp, exportState, next_ymd, next_tod, restart_write, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine ModelAdvance !=============================================================================== - subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) + subroutine drof_comp_run(gcomp, exportState, target_ymd, target_tod, restart_write, rc) ! -------------------------- ! advance drof ! -------------------------- ! input/output variables: + type(ESMF_GridComp), intent(in) :: gcomp type(ESMF_State) , intent(inout) :: exportState integer , intent(in) :: target_ymd ! model date integer , intent(in) :: target_tod ! model sec into model date @@ -411,7 +412,7 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, restfilm, 'rof', nullstr, logunit, my_task, mpicom, sdat) end if first_time = .false. diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index bfd33703..e16b44c3 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -994,6 +994,7 @@ subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & if (trim(rest_filem) == trim(nullstr)) then if (my_task == main_task) then call shr_get_rpointer_name(gcomp, compname, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return write(logunit,F00) ' restart filename from rpointer' diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index 13728738..cb850e5d 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -290,7 +290,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Read restart if necessary if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(restfilm, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(gcomp, restfilm, 'wav', nullstr, logunit, my_task, mpicom, sdat) end if ! Get the time to interpolate the stream data to From e65d8d9832311faf19ec474b71cba833e99b5d6d Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 4 Sep 2024 15:27:02 -0600 Subject: [PATCH 03/12] save before reverting to main --- dshr/dshr_mod.F90 | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index d323ccf1..faa346b6 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -950,19 +950,17 @@ subroutine dshr_time_init( Time, ymd, cal, tod, rc) end subroutine dshr_time_init !=============================================================================== - subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & - logunit, my_task, mpicom, sdat, rc, fld, fldname) + subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & + logunit, my_task, mpicom, sdat, fld, fldname) ! Read restart file use dshr_stream_mod, only : shr_stream_restIO use ESMF, only : ESMF_VMGetCurrent - use nuopc_shr_methods, only: shr_get_rpointer_name - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: compname + character(len=*) , intent(in) :: rpfile + character(len=*) , intent(in) :: inst_suffix character(len=*) , intent(in) :: nullstr integer , intent(in) :: logunit integer , intent(in) :: my_task @@ -970,10 +968,8 @@ subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & type(shr_strdata_type) , intent(inout) :: sdat real(r8) , optional , pointer :: fld(:) character(len=*) , optional , intent(in) :: fldname - integer , intent(out) :: rc - + ! local variables - character(len=ESMF_MAXSTR) :: rpfile type(ESMF_VM) :: vm integer :: nu logical :: exists ! file existance @@ -981,11 +977,12 @@ subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & type(var_desc_t) :: varid type(io_desc_t) :: pio_iodesc integer :: rcode + integer :: rc integer :: tmp(1) character(*), parameter :: F00 = "('(dshr_restart_read) ',8a)" character(*), parameter :: subName = "(dshr_restart_read) " !------------------------------------------------------------------------------- - + ! no streams means no restart file is read. if(shr_strdata_get_stream_count(sdat) <= 0) return call ESMF_VMGetCurrent(vm, rc=rc) @@ -993,12 +990,13 @@ subroutine dshr_restart_read(gcomp, rest_filem, compname, nullstr, & exists = .false. if (trim(rest_filem) == trim(nullstr)) then if (my_task == main_task) then - call shr_get_rpointer_name(gcomp, compname, rpfile, 'read', rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - write(logunit,F00) ' restart filename from rpointer '//trim(rpfile) - - open(newunit=nu, file=trim(rpfile), form='formatted') + write(logunit,F00) ' restart filename from rpointer' + inquire(file=trim(rpfile)//trim(inst_suffix), exist=exists) + if (.not.exists) then + write(logunit, F00) ' ERROR: rpointer file does not exist' + call shr_sys_abort(trim(subname)//' ERROR: rpointer file missing') + endif + open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') read(nu, '(a)') rest_filem close(nu) inquire(file=trim(rest_filem), exist=exists) From 863def0c8a6295dbbb4b44b1055845d980cd5978 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 5 Sep 2024 13:58:15 -0600 Subject: [PATCH 04/12] restart ERS.f19_g17.2000_DATM%NYF_SLND_DICE%SSMI_DOCN%DOM_DROF%NYF_DGLC%NOEVOLVE_DWAV%CLIMO.derecho_intel passing --- datm/atm_comp_nuopc.F90 | 84 +++++++------------------ datm/datm_datamode_cfsr_mod.F90 | 40 ------------ datm/datm_datamode_clmncep_mod.F90 | 37 ----------- datm/datm_datamode_core2_mod.F90 | 39 ------------ datm/datm_datamode_cplhist_mod.F90 | 42 +------------ datm/datm_datamode_era5_mod.F90 | 41 +----------- datm/datm_datamode_gefs_mod.F90 | 38 ----------- datm/datm_datamode_jra_mod.F90 | 40 +----------- datm/datm_datamode_simple_mod.F90 | 38 ----------- dglc/dglc_datamode_noevolve_mod.F90 | 39 ++++-------- dglc/glc_comp_nuopc.F90 | 12 ++-- dice/dice_datamode_ssmi_mod.F90 | 20 +++--- dice/ice_comp_nuopc.F90 | 11 +++- dlnd/lnd_comp_nuopc.F90 | 24 ++++--- docn/docn_datamode_copyall_mod.F90 | 39 ------------ docn/docn_datamode_cplhist_mod.F90 | 39 ------------ docn/docn_datamode_iaf_mod.F90 | 46 +------------- docn/docn_datamode_multilev_dom_mod.F90 | 44 +------------ docn/docn_datamode_multilev_mod.F90 | 43 ------------- docn/docn_datamode_som_mod.F90 | 23 +++---- docn/ocn_comp_nuopc.F90 | 58 ++++++++--------- drof/rof_comp_nuopc.F90 | 17 +++-- dshr/dshr_mod.F90 | 29 ++++----- dwav/wav_comp_nuopc.F90 | 23 ++++--- 24 files changed, 163 insertions(+), 703 deletions(-) diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index 9fd846f9..9d7de76f 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -33,9 +33,9 @@ module cdeps_datm_comp use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_config, shr_strdata_advance use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_setOrbs - use dshr_mod , only : dshr_model_initphase, dshr_init + use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_restart_write use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance - use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm + use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm, dshr_restart_read use dshr_mod , only : dshr_orbital_init, dshr_orbital_update use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize @@ -43,50 +43,34 @@ module cdeps_datm_comp use datm_datamode_core2_mod , only : datm_datamode_core2_advertise use datm_datamode_core2_mod , only : datm_datamode_core2_init_pointers use datm_datamode_core2_mod , only : datm_datamode_core2_advance - use datm_datamode_core2_mod , only : datm_datamode_core2_restart_write - use datm_datamode_core2_mod , only : datm_datamode_core2_restart_read use datm_datamode_jra_mod , only : datm_datamode_jra_advertise use datm_datamode_jra_mod , only : datm_datamode_jra_init_pointers use datm_datamode_jra_mod , only : datm_datamode_jra_advance - use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write - use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advance - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_write - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_read use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advertise use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_init_pointers use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advance - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_write - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_read use datm_datamode_era5_mod , only : datm_datamode_era5_advertise use datm_datamode_era5_mod , only : datm_datamode_era5_init_pointers use datm_datamode_era5_mod , only : datm_datamode_era5_advance - use datm_datamode_era5_mod , only : datm_datamode_era5_restart_write - use datm_datamode_era5_mod , only : datm_datamode_era5_restart_read use datm_datamode_gefs_mod , only : datm_datamode_gefs_advertise use datm_datamode_gefs_mod , only : datm_datamode_gefs_init_pointers use datm_datamode_gefs_mod , only : datm_datamode_gefs_advance - use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_write - use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_read use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advertise use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_init_pointers use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advance - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_write - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_read use datm_datamode_simple_mod , only : datm_datamode_simple_advertise use datm_datamode_simple_mod , only : datm_datamode_simple_init_pointers use datm_datamode_simple_mod , only : datm_datamode_simple_advance - use datm_datamode_simple_mod , only : datm_datamode_simple_restart_write - use datm_datamode_simple_mod , only : datm_datamode_simple_restart_read implicit none private ! except @@ -157,7 +141,6 @@ module cdeps_datm_comp integer :: idt ! integer model timestep logical :: diagnose_data = .true. integer , parameter :: main_task = 0 ! task number of main task - character(len=*) , parameter :: rpfile = 'rpointer.atm' #ifdef CESMCOUPLED character(*) , parameter :: modName = "(atm_comp_nuopc)" #else @@ -581,13 +564,13 @@ end subroutine ModelAdvance !=============================================================================== subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod, target_mon, & orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) - + use nuopc_shr_methods, only : shr_get_rpointer_name ! ---------------------------------- ! run method for datm model ! ---------------------------------- ! input/output variables - type(ESMF_GridComp) , intent(in) :: gcomp + type(ESMF_GridComp) , intent(inout) :: gcomp type(ESMF_State) , intent(inout) :: importState type(ESMF_State) , intent(inout) :: exportState integer , intent(in) :: target_ymd ! model date @@ -602,7 +585,10 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile + character(len=16) :: timestr character(*), parameter :: subName = '(datm_comp_run) ' + integer :: yr, mon, day !------------------------------------------------------------------------------- rc = ESMF_SUCCESS @@ -614,7 +600,6 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod !-------------------- if (first_time) then - ! Initialize dfields call datm_init_dfields(rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -649,23 +634,14 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then + call shr_get_rpointer_name(gcomp, 'atm', target_ymd, target_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('CORE_IAF_JRA') - call datm_datamode_jra_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('CLMNCEP') - call datm_datamode_clmncep_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('CPLHIST') - call datm_datamode_cplhist_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('ERA5') - call datm_datamode_era5_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('GEFS') - call datm_datamode_gefs_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('CFSR') - call datm_datamode_cfsr_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('SIMPLE') - call datm_datamode_simple_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) + case('CORE2_NYF','CORE2_IAF','CORE_IAF_JRA','CLMNCEP','CPLHIST','ERA5','GEFS','CFSR','SIMPLE') + call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case default + call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') end select end if @@ -728,33 +704,15 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod ! Write restarts if needed if (restart_write) then + call shr_get_rpointer_name(gcomp, 'atm', target_ymd, target_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CORE_IAF_JRA') - call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CLMNCEP') - call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CPLHIST') - call datm_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('ERA5') - call datm_datamode_era5_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('GEFS') - call datm_datamode_gefs_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) + case('CORE2_NYF','CORE2_IAF','CORE_IAF_JRA','CLMNCEP','CPLHIST','ERA5','GEFS','CFSR','SIMPLE') + call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, target_ymd, target_tod, logunit, & + my_task, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CFSR') - call datm_datamode_cfsr_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('SIMPLE') - call datm_datamode_simple_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) + case default + call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') end select end if diff --git a/datm/datm_datamode_cfsr_mod.F90 b/datm/datm_datamode_cfsr_mod.F90 index c3aa6020..ec1ab7a8 100644 --- a/datm/datm_datamode_cfsr_mod.F90 +++ b/datm/datm_datamode_cfsr_mod.F90 @@ -8,7 +8,6 @@ module datm_datamode_cfsr_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -18,8 +17,6 @@ module datm_datamode_cfsr_mod public :: datm_datamode_cfsr_advertise public :: datm_datamode_cfsr_init_pointers public :: datm_datamode_cfsr_advance - public :: datm_datamode_cfsr_restart_write - public :: datm_datamode_cfsr_restart_read ! export state data real(r8), pointer :: Sa_z(:) => null() @@ -51,8 +48,6 @@ module datm_datamode_cfsr_mod real(r8) , parameter :: rdair = SHR_CONST_RDAIR ! dry air gas constant ~ J/K/kg real(r8) , parameter :: rhofw = SHR_CONST_RHOFW ! density of fresh water ~ kg/m^3 - character(*), parameter :: nullstr = 'undefined' - character(*), parameter :: rpfile = 'rpointer.atm' character(*), parameter :: u_FILE_u = & __FILE__ @@ -218,39 +213,4 @@ subroutine datm_datamode_cfsr_advance(exportstate, mainproc, logunit, mpicom, ta end subroutine datm_datamode_cfsr_advance - !=============================================================================== - subroutine datm_datamode_cfsr_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_cfsr_restart_write - - !=============================================================================== - subroutine datm_datamode_cfsr_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_cfsr_restart_read - end module datm_datamode_cfsr_mod diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index e9c982af..f11aa167 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -10,7 +10,6 @@ module datm_datamode_clmncep_mod use shr_const_mod , only : shr_const_pstd, shr_const_stebol, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -20,8 +19,6 @@ module datm_datamode_clmncep_mod public :: datm_datamode_clmncep_advertise public :: datm_datamode_clmncep_init_pointers public :: datm_datamode_clmncep_advance - public :: datm_datamode_clmncep_restart_write - public :: datm_datamode_clmncep_restart_read private :: datm_esat ! determine saturation vapor pressure ! export state data @@ -591,41 +588,7 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) end subroutine datm_datamode_clmncep_advance !=============================================================================== - subroutine datm_datamode_clmncep_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_clmncep_restart_write - - !=============================================================================== - subroutine datm_datamode_clmncep_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_clmncep_restart_read - - !=============================================================================== real(r8) function datm_eSat(tK,tKbot) !---------------------------------------------------------------------------- diff --git a/datm/datm_datamode_core2_mod.F90 b/datm/datm_datamode_core2_mod.F90 index 7e68893a..8b041f08 100644 --- a/datm/datm_datamode_core2_mod.F90 +++ b/datm/datm_datamode_core2_mod.F90 @@ -22,7 +22,6 @@ module datm_datamode_core2_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -32,8 +31,6 @@ module datm_datamode_core2_mod public :: datm_datamode_core2_advertise public :: datm_datamode_core2_init_pointers public :: datm_datamode_core2_advance - public :: datm_datamode_core2_restart_write - public :: datm_datamode_core2_restart_read private :: datm_get_adjustment_factors @@ -86,7 +83,6 @@ module datm_datamode_core2_mod -1.99_R8,-0.91_R8, 1.72_R8, 2.30_R8, 1.81_R8, 1.06_R8/ character(*), parameter :: nullstr = 'null' - character(*), parameter :: rpfile = 'rpointer.atm' character(*), parameter :: u_FILE_u = & __FILE__ @@ -409,41 +405,6 @@ subroutine datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_ end subroutine datm_datamode_core2_advance - !=============================================================================== - subroutine datm_datamode_core2_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_core2_restart_write - - !=============================================================================== - subroutine datm_datamode_core2_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_core2_restart_read - !=============================================================================== subroutine datm_get_adjustment_factors(sdat, fileName_mesh, fileName_data, windF, winddF, qsatF, rc) diff --git a/datm/datm_datamode_cplhist_mod.F90 b/datm/datm_datamode_cplhist_mod.F90 index c13ccef9..2765bc15 100644 --- a/datm/datm_datamode_cplhist_mod.F90 +++ b/datm/datm_datamode_cplhist_mod.F90 @@ -7,7 +7,6 @@ module datm_datamode_cplhist_mod use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -17,8 +16,6 @@ module datm_datamode_cplhist_mod public :: datm_datamode_cplhist_advertise public :: datm_datamode_cplhist_init_pointers public :: datm_datamode_cplhist_advance - public :: datm_datamode_cplhist_restart_write - public :: datm_datamode_cplhist_restart_read ! export state data real(r8), pointer :: Sa_z(:) => null() @@ -27,8 +24,8 @@ module datm_datamode_cplhist_mod real(r8), pointer :: Sa_tbot(:) => null() real(r8), pointer :: Sa_ptem(:) => null() real(r8), pointer :: Sa_shum(:) => null() -! TODO: water isotope support -! real(r8), pointer :: Sa_shum_wiso(:,:) => null() ! water isotopes + ! TODO: water isotope support + ! real(r8), pointer :: Sa_shum_wiso(:,:) => null() ! water isotopes real(r8), pointer :: Sa_dens(:) => null() real(r8), pointer :: Sa_pbot(:) => null() real(r8), pointer :: Sa_pslv(:) => null() @@ -200,39 +197,4 @@ subroutine datm_datamode_cplhist_advance(mainproc, logunit, mpicom, rc) end subroutine datm_datamode_cplhist_advance - !=============================================================================== - subroutine datm_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_cplhist_restart_write - - !=============================================================================== - subroutine datm_datamode_cplhist_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_cplhist_restart_read - end module datm_datamode_cplhist_mod diff --git a/datm/datm_datamode_era5_mod.F90 b/datm/datm_datamode_era5_mod.F90 index 84224a03..2ba91cc7 100644 --- a/datm/datm_datamode_era5_mod.F90 +++ b/datm/datm_datamode_era5_mod.F90 @@ -8,7 +8,6 @@ module datm_datamode_era5_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -18,8 +17,6 @@ module datm_datamode_era5_mod public :: datm_datamode_era5_advertise public :: datm_datamode_era5_init_pointers public :: datm_datamode_era5_advance - public :: datm_datamode_era5_restart_write - public :: datm_datamode_era5_restart_read private :: datm_eSat ! determine saturation vapor pressure ! export state data @@ -194,7 +191,7 @@ subroutine datm_datamode_era5_init_pointers(exportState, sdat, rc) end subroutine datm_datamode_era5_init_pointers - !=============================================================================== + !=============================================================================== subroutine datm_datamode_era5_advance(exportstate, mainproc, logunit, mpicom, target_ymd, target_tod, model_calendar, rc) use ESMF, only: ESMF_VMGetCurrent, ESMF_VMAllReduce, ESMF_REDUCE_MAX, ESMF_VM @@ -317,41 +314,7 @@ subroutine datm_datamode_era5_advance(exportstate, mainproc, logunit, mpicom, ta end subroutine datm_datamode_era5_advance - !=============================================================================== - subroutine datm_datamode_era5_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_era5_restart_write - - !=============================================================================== - subroutine datm_datamode_era5_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_era5_restart_read - + !=============================================================================== real(r8) function datm_eSat(tK,tKbot) !---------------------------------------------------------------------------- diff --git a/datm/datm_datamode_gefs_mod.F90 b/datm/datm_datamode_gefs_mod.F90 index 16c97990..66b991d8 100644 --- a/datm/datm_datamode_gefs_mod.F90 +++ b/datm/datm_datamode_gefs_mod.F90 @@ -8,7 +8,6 @@ module datm_datamode_gefs_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -18,8 +17,6 @@ module datm_datamode_gefs_mod public :: datm_datamode_gefs_advertise public :: datm_datamode_gefs_init_pointers public :: datm_datamode_gefs_advance - public :: datm_datamode_gefs_restart_write - public :: datm_datamode_gefs_restart_read ! export state data real(r8), pointer :: Sa_z(:) => null() @@ -220,39 +217,4 @@ subroutine datm_datamode_gefs_advance(exportstate, mainproc, logunit, mpicom, ta end subroutine datm_datamode_gefs_advance - !=============================================================================== - subroutine datm_datamode_gefs_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_gefs_restart_write - - !=============================================================================== - subroutine datm_datamode_gefs_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_gefs_restart_read - end module datm_datamode_gefs_mod diff --git a/datm/datm_datamode_jra_mod.F90 b/datm/datm_datamode_jra_mod.F90 index 43bc3c2f..e09844ac 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -1,7 +1,7 @@ module datm_datamode_jra_mod use ESMF , only : ESMF_State, ESMF_StateGet, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO - use ESMF , only : ESMF_MeshGet, ESMF_GridComp + use ESMF , only : ESMF_MeshGet use ESMF , only : ESMF_StateItem_Flag, ESMF_STATEITEM_NOTFOUND, operator(/=) use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -10,7 +10,6 @@ module datm_datamode_jra_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_pi, shr_const_rdair use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -20,8 +19,6 @@ module datm_datamode_jra_mod public :: datm_datamode_jra_advertise public :: datm_datamode_jra_init_pointers public :: datm_datamode_jra_advance - public :: datm_datamode_jra_restart_write - public :: datm_datamode_jra_restart_read ! export state pointers real(r8), pointer :: Sa_z(:) => null() @@ -303,39 +300,4 @@ subroutine datm_datamode_jra_advance(exportstate, target_ymd, target_tod, model_ end subroutine datm_datamode_jra_advance - !=============================================================================== - subroutine datm_datamode_jra_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_jra_restart_write - - !=============================================================================== - subroutine datm_datamode_jra_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_jra_restart_read - end module datm_datamode_jra_mod diff --git a/datm/datm_datamode_simple_mod.F90 b/datm/datm_datamode_simple_mod.F90 index c614f046..da88fc64 100644 --- a/datm/datm_datamode_simple_mod.F90 +++ b/datm/datm_datamode_simple_mod.F90 @@ -23,7 +23,6 @@ module datm_datamode_simple_mod use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -33,8 +32,6 @@ module datm_datamode_simple_mod public :: datm_datamode_simple_advertise public :: datm_datamode_simple_init_pointers public :: datm_datamode_simple_advance - public :: datm_datamode_simple_restart_write - public :: datm_datamode_simple_restart_read ! export state pointers real(r8), pointer :: Sa_u(:) => null() @@ -341,39 +338,4 @@ subroutine datm_datamode_simple_advance(target_ymd, target_tod, target_mon, & end subroutine datm_datamode_simple_advance - !=============================================================================== - subroutine datm_datamode_simple_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_simple_restart_write - - !=============================================================================== - subroutine datm_datamode_simple_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - use ESMF, only : ESMF_GridComp - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'atm', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_simple_restart_read - end module datm_datamode_simple_mod diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index d41b739f..7467a98a 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -4,7 +4,7 @@ module dglc_datamode_noevolve_mod use ESMF , only : ESMF_Mesh, ESMF_DistGrid, ESMF_FieldBundle, ESMF_Field use ESMF , only : ESMF_FieldBundleCreate, ESMF_FieldCreate, ESMF_MeshLoc_Element use ESMF , only : ESMF_FieldBundleAdd, ESMF_MeshGet, ESMF_DistGridGet, ESMF_Typekind_R8 - use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast, ESMF_VM, ESMF_GridComp + use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast, ESMF_VM use NUOPC , only : NUOPC_Advertise, NUOPC_IsConnected use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort @@ -71,7 +71,6 @@ module dglc_datamode_noevolve_mod character(len=*), parameter :: field_in_so_s_depth = 'So_s_depth' character(*) , parameter :: nullstr = 'null' - character(*) , parameter :: rpfile = 'rpointer.glc' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -433,12 +432,13 @@ end function is_ice_covered !=============================================================================== subroutine dglc_datamode_noevolve_restart_write(model_meshes, case_name, & - inst_suffix, ymd, tod, logunit, my_task, main_task, & + rpfile, inst_suffix, ymd, tod, logunit, my_task, main_task, & pio_subsystem, io_type, nx_global, ny_global, rc) ! input/output variables type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes character(len=*) , intent(in) :: case_name + character(len=*) , intent(in) :: rpfile character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: ymd ! model date integer , intent(in) :: tod ! model sec into model date @@ -519,14 +519,14 @@ subroutine dglc_datamode_noevolve_restart_write(model_meshes, case_name, & end subroutine dglc_datamode_noevolve_restart_write !=============================================================================== - subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & + subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, & logunit, my_task, main_task, mpicom, & pio_subsystem, io_type, nx_global, ny_global, rc) - use nuopc_shr_methods, only : shr_get_rpointer_name + ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes character(len=*) , intent(inout) :: restfilem + character(len=*) , intent(in) :: rpfile integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: main_task @@ -541,7 +541,6 @@ subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & type(ESMF_DistGrid) :: distgrid integer :: ns character(len=CS) :: cnum - character(len=CS) :: rpfile integer :: lsize integer, pointer :: gindex(:) ! domain decomposition of data type(ESMF_VM) :: vm @@ -557,14 +556,14 @@ subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & rc = ESMF_SUCCESS ! Determine restart file - exists = .false. - call ESMF_VMGetCurrent(vm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (trim(restfilem) == trim(nullstr)) then + exists = .false. + call ESMF_VMGetCurrent(vm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return if (my_task == main_task) then - call shr_get_rpointer_name(gcomp, 'glc', rpfile, 'read', rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - write(logunit,'(a)') trim(subname)//' restart filename from rpointer' + write(logunit,'(a)') trim(subname)//' restart filename from rpointer '//trim(rpfile) open(newunit=nu, file=trim(rpfile), form='formatted') read(nu,'(a)') restfilem close(nu) @@ -581,16 +580,12 @@ subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & endif tmp = 0 if(exists) tmp=1 - call ESMF_VMBroadCast(vm, tmp, 1, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return exists = (tmp(1) == 1) - if (.not. exists .and. my_task == main_task) then write(logunit, '(a)') trim(subname)//' file not found, skipping '//trim(restfilem) - ! Should we return here or just abort? return end if - + ! Read restart file if (my_task == main_task) then write(logunit, '(a)') trim(subname)//' reading data model restart '//trim(restfilem) @@ -610,14 +605,6 @@ subroutine dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilem, & call ESMF_DistGridGet(distGrid, localDe=0, seqIndexList=gindex, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Read restart file - if (my_task == main_task) then - write(logunit, '(a)') trim(subname)//' reading data model restart '//trim(restfilem) - end if - rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(restfilem), pio_nowrite) - call pio_initdecomp(pio_subsystem, pio_double, (/nx_global(ns),ny_global(ns)/), gindex, pio_iodesc) - rcode = pio_inq_varid(pioid, 'flgl_rofi'//cnum, varid) - call pio_read_darray(pioid, varid, pio_iodesc, Fgrg_rofi(ns)%ptr, rcode) call pio_initdecomp(pio_subsystem, pio_double, (/nx_global(ns),ny_global(ns)/), gindex, pio_iodesc) rcode = pio_inq_varid(pioid, 'flgl_rofi'//cnum, varid) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index 3099ee9d..a20be438 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -41,7 +41,7 @@ module cdeps_dglc_comp use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_check_restart_alarm use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_realize - + use nuopc_shr_methods, only : shr_get_rpointer_name ! Datamode specialized modules use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_advertise use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_init_pointers @@ -530,6 +530,7 @@ subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, va character(len=CS) :: cnum integer :: ns ! ice sheet index logical :: first_time = .true. + character(len=CS) :: rpfile character(*), parameter :: subName = "(dglc_comp_run) " !------------------------------------------------------------------------------- @@ -557,8 +558,9 @@ subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, va ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then - write(logunit,'(a)')' DEBUG: calling dglc_datamode_noevolve_restart_read' - call dglc_datamode_noevolve_restart_read(gcomp, model_meshes, restfilm, & + call shr_get_rpointer_name(gcomp, 'glc', target_ymd, target_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dglc_datamode_noevolve_restart_read(model_meshes, restfilm, rpfile, & logunit, my_task, main_task, mpicom, & sdat(1)%pio_subsystem, sdat(1)%io_type, nx_global, ny_global, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -612,7 +614,9 @@ subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, va if (my_task == main_task) then write(logunit,'(a)') 'calling dglc_datamode_noevolve_restart_write' end if - call dglc_datamode_noevolve_restart_write(model_meshes, case_name, & + call shr_get_rpointer_name(gcomp, 'glc', target_ymd, target_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dglc_datamode_noevolve_restart_write(model_meshes, case_name, rpfile, & inst_suffix, target_ymd, target_tod, logunit, my_task, main_task, & sdat(1)%pio_subsystem, sdat(1)%io_type, nx_global, ny_global, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/dice/dice_datamode_ssmi_mod.F90 b/dice/dice_datamode_ssmi_mod.F90 index 1196c831..79c4ac37 100644 --- a/dice/dice_datamode_ssmi_mod.F90 +++ b/dice/dice_datamode_ssmi_mod.F90 @@ -102,7 +102,6 @@ module dice_datamode_ssmi_mod real(r8) , parameter :: waterMax = 1000.0_r8 ! wrt iFrac comp & frazil ice (kg/m^2) character(*) , parameter :: nullstr = 'null' - character(*) , parameter :: rpfile = 'rpointer.ice' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -567,10 +566,11 @@ subroutine dice_datamode_ssmi_advance(exportState, importState, cosarg, flds_i2o end subroutine dice_datamode_ssmi_advance !=============================================================================== - subroutine dice_datamode_ssmi_restart_write(case_name, inst_suffix, ymd, tod, & + subroutine dice_datamode_ssmi_restart_write(rpfile, case_name, inst_suffix, ymd, tod, & logunit, my_task, sdat) ! input/output variables + character(len=*) , intent(in) :: rpfile character(len=*) , intent(in) :: case_name character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: ymd ! model date @@ -579,31 +579,33 @@ subroutine dice_datamode_ssmi_restart_write(case_name, inst_suffix, ymd, tod, & integer , intent(in) :: my_task type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - + integer :: rc call dshr_restart_write(rpfile, case_name, 'dice', inst_suffix, ymd, tod, & - logunit, my_task, sdat, fld=water, fldname='water') + logunit, my_task, sdat, rc, fld=water, fldname='water') + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine dice_datamode_ssmi_restart_write !=============================================================================== - subroutine dice_datamode_ssmi_restart_read(gcomp, rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - use nuopc_shr_methods, only : shr_get_rpointer_name + subroutine dice_datamode_ssmi_restart_read(gcomp, rest_filem, rpfile, logunit, my_task, mpicom, sdat) + ! input/output arguments type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix + character(len=*) , intent(in) :: rpfile integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - + integer :: rc ! allocate module memory for restart fields that are read in allocate(water(sdat%model_lsize)) ! read restart - call dshr_restart_read(gcomp, rest_filem, 'ice', nullstr, logunit, my_task, mpicom, sdat, & + call dshr_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat, rc,& fld=water, fldname='water') + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine dice_datamode_ssmi_restart_read diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 39a7c7f2..ad01ffdd 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -395,7 +395,6 @@ end subroutine InitializeRealize !=============================================================================== subroutine ModelAdvance(gcomp, rc) - ! input/output variables type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc @@ -459,6 +458,7 @@ end subroutine ModelAdvance !=============================================================================== subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod, cosarg, restart_write, rc) + use nuopc_shr_methods, only : shr_get_rpointer_name ! -------------------------- ! advance dice @@ -476,6 +476,7 @@ subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile character(*), parameter :: subName = "(dice_comp_run) " !------------------------------------------------------------------------------- @@ -503,9 +504,11 @@ subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod ! read restart if needed if (restart_read) then + call shr_get_rpointer_name(gcomp, 'ice', target_ymd, target_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return select case (trim(datamode)) case('ssmi', 'ssmi_iaf') - call dice_datamode_ssmi_restart_read(gcomp, restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call dice_datamode_ssmi_restart_read(gcomp, restfilm, rpfile, logunit, my_task, mpicom, sdat) end select end if @@ -550,9 +553,11 @@ subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod ! Write restarts if needed if (restart_write) then + call shr_get_rpointer_name(gcomp, 'ice', target_ymd, target_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return select case (trim(datamode)) case('ssmi', 'ssmi_iaf') - call dice_datamode_ssmi_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + call dice_datamode_ssmi_restart_write(rpfile, case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) if (ChkErr(rc,__LINE__,u_FILE_u)) return end select diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index bea64c5a..f7527da6 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -98,7 +98,6 @@ module cdeps_dlnd_comp integer :: glc_nec logical :: diagnose_data = .true. integer , parameter :: main_task=0 ! task number of main task - character(*) , parameter :: rpfile = 'rpointer.lnd' #ifdef CESMCOUPLED character(*) , parameter :: modName = "(lnd_comp_nuopc)" #else @@ -277,6 +276,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer :: current_mon ! model month integer :: current_day ! model day integer :: current_tod ! model sec into model date + character(len=cl) :: rpfile ! restart pointer file name character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- @@ -301,11 +301,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call dlnd_comp_realize(importState, exportState, export_all, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Read restart if necessary - if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(gcomp, restfilm, 'lnd', nullstr, logunit, my_task, mpicom, sdat) - end if - ! get the time to interpolate the stream data to call ESMF_ClockGet(clock, currTime=currTime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -313,6 +308,15 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) + ! Read restart if necessary + if (restart_read .and. .not. skip_restart_read) then + call shr_get_rpointer_name(gcomp, 'lnd', current_ymd, current_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + + ! Run dlnd to create export state call dlnd_comp_run(importState, exportState, current_ymd, current_tod, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -333,7 +337,7 @@ end subroutine InitializeRealize !=============================================================================== subroutine ModelAdvance(gcomp, rc) - + use nuopc_shr_methods, only : shr_get_rpointer_name ! input/output variables type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc @@ -349,6 +353,7 @@ subroutine ModelAdvance(gcomp, rc) integer :: mon ! month integer :: day ! day in month logical :: write_restart + character(len=CL) :: rpfile character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -379,8 +384,11 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (write_restart) then call ESMF_TraceRegionEnter('dlnd_restart') + call shr_get_rpointer_name(gcomp, 'lnd', next_ymd, next_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call dshr_restart_write(rpfile, case_name, 'dlnd', inst_suffix, next_ymd, next_tod, & - logunit, my_task, sdat) + logunit, my_task, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit('dlnd_restart') endif diff --git a/docn/docn_datamode_copyall_mod.F90 b/docn/docn_datamode_copyall_mod.F90 index a6fa3e73..85d625fe 100644 --- a/docn/docn_datamode_copyall_mod.F90 +++ b/docn/docn_datamode_copyall_mod.F90 @@ -1,14 +1,12 @@ module docn_datamode_copyall_mod use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS - use ESMF , only : ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type implicit none @@ -17,8 +15,6 @@ module docn_datamode_copyall_mod public :: docn_datamode_copyall_advertise public :: docn_datamode_copyall_init_pointers public :: docn_datamode_copyall_advance - public :: docn_datamode_copyall_restart_read - public :: docn_datamode_copyall_restart_write ! export fields real(r8), pointer :: So_omask(:) => null() ! real ocean fraction sent to mediator @@ -129,39 +125,4 @@ subroutine docn_datamode_copyall_advance(rc) end subroutine docn_datamode_copyall_advance - !=============================================================================== - subroutine docn_datamode_copyall_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine docn_datamode_copyall_restart_write - - !=============================================================================== - subroutine docn_datamode_copyall_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine docn_datamode_copyall_restart_read - end module docn_datamode_copyall_mod diff --git a/docn/docn_datamode_cplhist_mod.F90 b/docn/docn_datamode_cplhist_mod.F90 index 81fead61..81ac4022 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -1,14 +1,12 @@ module docn_datamode_cplhist_mod use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS - use ESMF , only : ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_type implicit none @@ -17,8 +15,6 @@ module docn_datamode_cplhist_mod public :: docn_datamode_cplhist_advertise public :: docn_datamode_cplhist_init_pointers public :: docn_datamode_cplhist_advance - public :: docn_datamode_cplhist_restart_read - public :: docn_datamode_cplhist_restart_write ! export fields real(r8), pointer :: So_omask(:) => null() ! real ocean fraction sent to mediator @@ -123,39 +119,4 @@ subroutine docn_datamode_cplhist_advance(rc) end subroutine docn_datamode_cplhist_advance - !=============================================================================== - subroutine docn_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine docn_datamode_cplhist_restart_write - - !=============================================================================== - subroutine docn_datamode_cplhist_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine docn_datamode_cplhist_restart_read - end module docn_datamode_cplhist_mod diff --git a/docn/docn_datamode_iaf_mod.F90 b/docn/docn_datamode_iaf_mod.F90 index 23b939a2..7e56afd4 100644 --- a/docn/docn_datamode_iaf_mod.F90 +++ b/docn/docn_datamode_iaf_mod.F90 @@ -1,5 +1,5 @@ module docn_datamode_iaf_mod - use ESMF , only : ESMF_GridComp + use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_State use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -8,7 +8,6 @@ module docn_datamode_iaf_mod use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use pio @@ -18,8 +17,6 @@ module docn_datamode_iaf_mod public :: docn_datamode_iaf_advertise public :: docn_datamode_iaf_init_pointers public :: docn_datamode_iaf_advance - public :: docn_datamode_iaf_restart_read - public :: docn_datamode_iaf_restart_write ! export fields real(r8), pointer :: So_omask(:) => null() ! real ocean fraction sent to mediator @@ -41,8 +38,6 @@ module docn_datamode_iaf_mod real(r8) , parameter :: tkfrz = shr_const_tkfrz ! freezing point, fresh water (kelvin) real(r8) , parameter :: ocnsalt = shr_const_ocn_ref_sal ! ocean reference salinity - character(*) , parameter :: nullstr = 'null' - character(*) , parameter :: rpfile = 'rpointer.ocn' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -176,43 +171,4 @@ subroutine docn_datamode_iaf_advance(rc) end subroutine docn_datamode_iaf_advance - !=============================================================================== - subroutine docn_datamode_iaf_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! write restart file - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine docn_datamode_iaf_restart_write - - !=============================================================================== - subroutine docn_datamode_iaf_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine docn_datamode_iaf_restart_read - end module docn_datamode_iaf_mod diff --git a/docn/docn_datamode_multilev_dom_mod.F90 b/docn/docn_datamode_multilev_dom_mod.F90 index 578e2b9b..9c8c35be 100644 --- a/docn/docn_datamode_multilev_dom_mod.F90 +++ b/docn/docn_datamode_multilev_dom_mod.F90 @@ -1,5 +1,5 @@ module docn_datamode_multilev_dom_mod - use ESMF , only : ESMF_GridComp + use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -7,7 +7,6 @@ module docn_datamode_multilev_dom_mod use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type, shr_strdata_get_stream_count implicit none @@ -16,8 +15,6 @@ module docn_datamode_multilev_dom_mod public :: docn_datamode_multilev_dom_advertise public :: docn_datamode_multilev_dom_init_pointers public :: docn_datamode_multilev_dom_advance - public :: docn_datamode_multilev_dom_restart_read - public :: docn_datamode_multilev_dom_restart_write ! pointers to export fields real(r8), pointer :: So_omask(:) => null() ! real ocean fraction sent to mediator @@ -222,43 +219,4 @@ subroutine docn_datamode_multilev_dom_advance(sdat, logunit, mainproc, rc) end subroutine docn_datamode_multilev_dom_advance - !=============================================================================== - subroutine docn_datamode_multilev_dom_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! write restart file - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine docn_datamode_multilev_dom_restart_write - - !=============================================================================== - subroutine docn_datamode_multilev_dom_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine docn_datamode_multilev_dom_restart_read - end module docn_datamode_multilev_dom_mod diff --git a/docn/docn_datamode_multilev_mod.F90 b/docn/docn_datamode_multilev_mod.F90 index b522862e..aaa24258 100644 --- a/docn/docn_datamode_multilev_mod.F90 +++ b/docn/docn_datamode_multilev_mod.F90 @@ -1,5 +1,4 @@ module docn_datamode_multilev_mod - use ESMF , only : ESMF_GridComp use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -7,7 +6,6 @@ module docn_datamode_multilev_mod use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use dshr_mod , only : dshr_restart_read, dshr_restart_write use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type implicit none @@ -16,8 +14,6 @@ module docn_datamode_multilev_mod public :: docn_datamode_multilev_advertise public :: docn_datamode_multilev_init_pointers public :: docn_datamode_multilev_advance - public :: docn_datamode_multilev_restart_read - public :: docn_datamode_multilev_restart_write ! pointers to export fields real(r8), pointer :: So_omask(:) => null() ! real ocean fraction sent to mediator @@ -188,43 +184,4 @@ subroutine docn_datamode_multilev_advance(sdat, logunit, mainproc, rc) end subroutine docn_datamode_multilev_advance - !=============================================================================== - subroutine docn_datamode_multilev_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! write restart file - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine docn_datamode_multilev_restart_write - - !=============================================================================== - subroutine docn_datamode_multilev_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp - character(len=*) , intent(inout) :: rest_filem - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat) - - end subroutine docn_datamode_multilev_restart_read - end module docn_datamode_multilev_mod diff --git a/docn/docn_datamode_som_mod.F90 b/docn/docn_datamode_som_mod.F90 index 76b6bde9..92e51c0f 100644 --- a/docn/docn_datamode_som_mod.F90 +++ b/docn/docn_datamode_som_mod.F90 @@ -1,9 +1,9 @@ module docn_datamode_som_mod - + use ESMF , only : ESMF_SUCCESS, ESMF_State, ESMF_Clock, ESMF_StateGet, ESMF_StateItem_Flag use ESMF , only : ESMF_TimeInterval, ESMF_ClockGet, ESMF_TimeIntervalGet use ESMF , only : ESMF_LOGMSG_INFO, ESMF_STATEITEM_NOTFOUND, operator(/=) - use ESMF , only : ESMF_LogWrite, ESMF_GridComp + use ESMF , only : ESMF_LogWrite use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort @@ -66,7 +66,6 @@ module docn_datamode_som_mod real(r8) , parameter :: ocnsalt = shr_const_ocn_ref_sal ! ocean reference salinity character(*) , parameter :: nullstr = 'null' - character(*) , parameter :: rpfile = 'rpointer.ocn' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -305,12 +304,13 @@ subroutine docn_datamode_som_advance(importState, exportState, clock, restart_re end subroutine docn_datamode_som_advance !=============================================================================== - subroutine docn_datamode_som_restart_write(case_name, inst_suffix, ymd, tod, & + subroutine docn_datamode_som_restart_write(rpfile, case_name, inst_suffix, ymd, tod, & logunit, my_task, sdat) ! write restart file ! input/output variables + character(len=*) , intent(in) :: rpfile character(len=*) , intent(in) :: case_name character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: ymd ! model date @@ -319,32 +319,33 @@ subroutine docn_datamode_som_restart_write(case_name, inst_suffix, ymd, tod, & integer , intent(in) :: my_task type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - + integer :: rc call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, ymd, tod, & - logunit, my_task, sdat, fld=somtp, fldname='somtp') + logunit, my_task, sdat, rc, fld=somtp, fldname='somtp') + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine docn_datamode_som_restart_write !=============================================================================== - subroutine docn_datamode_som_restart_read(gcomp, rest_filem, logunit, my_task, mpicom, sdat) + subroutine docn_datamode_som_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat) ! read restart file ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem + character(len=*) , intent(in) :: rpfile integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat !------------------------------------------------------------------------------- - + integer :: rc ! allocate module memory for restart fields that are read in allocate(somtp(sdat%model_lsize)) - ! read restart - call dshr_restart_read(gcomp, rest_filem, 'ocn', nullstr, logunit, my_task, mpicom, sdat, & + call dshr_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat, rc,& fld=somtp, fldname='somtp') + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine docn_datamode_som_restart_read diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index 1d7366a3..ce57ed8e 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -29,22 +29,20 @@ module cdeps_docn_comp use shr_log_mod , only : shr_log_setLogUnit use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_init_from_config - use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init + use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_restart_read use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_check_restart_alarm + use dshr_mod , only : dshr_restart_write use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_realize + use nuopc_shr_methods, only : shr_get_rpointer_name ! Datamode specialized modules use docn_datamode_copyall_mod , only : docn_datamode_copyall_advertise use docn_datamode_copyall_mod , only : docn_datamode_copyall_init_pointers use docn_datamode_copyall_mod , only : docn_datamode_copyall_advance - use docn_datamode_copyall_mod , only : docn_datamode_copyall_restart_read - use docn_datamode_copyall_mod , only : docn_datamode_copyall_restart_write use docn_datamode_iaf_mod , only : docn_datamode_iaf_advertise use docn_datamode_iaf_mod , only : docn_datamode_iaf_init_pointers use docn_datamode_iaf_mod , only : docn_datamode_iaf_advance - use docn_datamode_iaf_mod , only : docn_datamode_iaf_restart_read - use docn_datamode_iaf_mod , only : docn_datamode_iaf_restart_write use docn_datamode_som_mod , only : docn_datamode_som_advertise use docn_datamode_som_mod , only : docn_datamode_som_init_pointers use docn_datamode_som_mod , only : docn_datamode_som_advance @@ -56,18 +54,12 @@ module cdeps_docn_comp use docn_datamode_cplhist_mod , only : docn_datamode_cplhist_advertise use docn_datamode_cplhist_mod , only : docn_datamode_cplhist_init_pointers use docn_datamode_cplhist_mod , only : docn_datamode_cplhist_advance - use docn_datamode_cplhist_mod , only : docn_datamode_cplhist_restart_read - use docn_datamode_cplhist_mod , only : docn_datamode_cplhist_restart_write use docn_datamode_multilev_mod , only : docn_datamode_multilev_advertise use docn_datamode_multilev_mod , only : docn_datamode_multilev_init_pointers use docn_datamode_multilev_mod , only : docn_datamode_multilev_advance - use docn_datamode_multilev_mod , only : docn_datamode_multilev_restart_read - use docn_datamode_multilev_mod , only : docn_datamode_multilev_restart_write use docn_datamode_multilev_dom_mod, only : docn_datamode_multilev_dom_advertise use docn_datamode_multilev_dom_mod, only : docn_datamode_multilev_dom_init_pointers use docn_datamode_multilev_dom_mod, only : docn_datamode_multilev_dom_advance - use docn_datamode_multilev_dom_mod, only : docn_datamode_multilev_dom_restart_read - use docn_datamode_multilev_dom_mod, only : docn_datamode_multilev_dom_restart_write use docn_import_data_mod , only : docn_import_data_advertise implicit none @@ -525,7 +517,7 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar ! -------------------------- ! input/output variables: - type(ESMF_GridComp) , intent(in) :: gcomp + type(ESMF_GridComp), intent(in) :: gcomp type(ESMF_Clock) , intent(in) :: clock type(ESMF_State) , intent(inout) :: importState type(ESMF_State) , intent(inout) :: exportState @@ -536,6 +528,7 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile ! restart pointer file name character(*), parameter :: subName = "(docn_comp_run) " !------------------------------------------------------------------------------- @@ -580,13 +573,15 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then + call shr_get_rpointer_name(gcomp, 'ocn', target_ymd, target_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + select case (trim(datamode)) - case('sstdata', 'sst_aquap_file') - call docn_datamode_copyall_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) - case('iaf') - call docn_datamode_iaf_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) + case('sstdata', 'sst_aquap_file', 'iaf', 'cplhist', 'multilev', 'mulitilev_dom') + call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return case('som', 'som_aquap') - call docn_datamode_som_restart_read(gcomp, restfilm, logunit, my_task, mpicom, sdat) + call docn_datamode_som_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) end select end if @@ -643,21 +638,22 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar ! Write restarts if needed (no restarts for aquaplanet analytic or aquaplanet input file) if (restart_write) then - select case (trim(datamode)) - case('sstdata','sst_aquap_file') - call docn_datamode_copyall_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('iaf') - call docn_datamode_iaf_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('som','som_aquap') - call docn_datamode_som_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('cplhist') - call docn_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + call shr_get_rpointer_name(gcomp, 'ocn', target_ymd, target_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + select case (trim(datamode)) + case('sstdata', 'sst_aquap_file', 'iaf', 'cplhist', 'multilev', 'mulitilev_dom') + call dshr_restart_write(rpfile, case_name, 'docn', inst_suffix, target_ymd, target_tod, logunit, & + my_task, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('som', 'som_aquap') + call docn_datamode_som_restart_write(rpfile, case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) - end select - end if + case default + call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + end select + + endif call ESMF_TraceRegionExit('DOCN_RUN') diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index 5b9e5ef1..e35f78fd 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -36,6 +36,7 @@ module cdeps_drof_comp use dshr_mod , only : dshr_restart_read, dshr_restart_write, dshr_mesh_init use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize + use nuopc_shr_methods, only : shr_get_rpointer_name implicit none private ! except @@ -388,6 +389,7 @@ subroutine drof_comp_run(gcomp, exportState, target_ymd, target_tod, restart_wri ! local variables logical :: first_time = .true. integer :: n + character(len=CL) :: rpfile character(*), parameter :: subName = "(drof_comp_run) " !------------------------------------------------------------------------------- @@ -412,7 +414,10 @@ subroutine drof_comp_run(gcomp, exportState, target_ymd, target_tod, restart_wri ! Read restart if needed if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(gcomp, restfilm, 'rof', nullstr, logunit, my_task, mpicom, sdat) + call shr_get_rpointer_name(gcomp, 'rof', target_ymd, target_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if first_time = .false. @@ -447,11 +452,13 @@ subroutine drof_comp_run(gcomp, exportState, target_ymd, target_tod, restart_wri ! write restarts if needed if (restart_write) then - select case (trim(datamode)) - case('copyall') + if(trim(datamode) .eq. 'copyall') then + call shr_get_rpointer_name(gcomp, 'rof', target_ymd, target_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call dshr_restart_write(rpfile, case_name, 'drof', inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - end select + logunit, my_task, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + endif end if ! write diagnostics diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index faa346b6..8ea10dca 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -950,8 +950,8 @@ subroutine dshr_time_init( Time, ymd, cal, tod, rc) end subroutine dshr_time_init !=============================================================================== - subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & - logunit, my_task, mpicom, sdat, fld, fldname) + subroutine dshr_restart_read(rest_filem, rpfile, & + logunit, my_task, mpicom, sdat, rc, fld, fldname) ! Read restart file @@ -960,12 +960,11 @@ subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & ! input/output arguments character(len=*) , intent(inout) :: rest_filem character(len=*) , intent(in) :: rpfile - character(len=*) , intent(in) :: inst_suffix - character(len=*) , intent(in) :: nullstr integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat + integer , intent(out) :: rc real(r8) , optional , pointer :: fld(:) character(len=*) , optional , intent(in) :: fldname @@ -977,26 +976,20 @@ subroutine dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, & type(var_desc_t) :: varid type(io_desc_t) :: pio_iodesc integer :: rcode - integer :: rc integer :: tmp(1) character(*), parameter :: F00 = "('(dshr_restart_read) ',8a)" character(*), parameter :: subName = "(dshr_restart_read) " !------------------------------------------------------------------------------- - + rc = ESMF_SUCCESS ! no streams means no restart file is read. if(shr_strdata_get_stream_count(sdat) <= 0) return call ESMF_VMGetCurrent(vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return exists = .false. - if (trim(rest_filem) == trim(nullstr)) then + if (trim(rest_filem) == 'none') then if (my_task == main_task) then - write(logunit,F00) ' restart filename from rpointer' - inquire(file=trim(rpfile)//trim(inst_suffix), exist=exists) - if (.not.exists) then - write(logunit, F00) ' ERROR: rpointer file does not exist' - call shr_sys_abort(trim(subname)//' ERROR: rpointer file missing') - endif - open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') + write(logunit,F00) ' restart filename from rpointer '//trim(rpfile) + open(newunit=nu, file=trim(rpfile), form='formatted') read(nu, '(a)') rest_filem close(nu) inquire(file=trim(rest_filem), exist=exists) @@ -1035,7 +1028,7 @@ end subroutine dshr_restart_read !=============================================================================== subroutine dshr_restart_write(rpfile, case_name, model_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat, fld, fldname) + logunit, my_task, sdat, rc, fld, fldname) ! Write restart file @@ -1051,6 +1044,7 @@ subroutine dshr_restart_write(rpfile, case_name, model_name, inst_suffix, ymd, t integer , intent(in) :: logunit integer , intent(in) :: my_task type(shr_strdata_type) , intent(inout) :: sdat + integer , intent(out) :: rc real(r8) , optional , pointer :: fld(:) character(len=*) , optional , intent(in) :: fldname @@ -1067,6 +1061,7 @@ subroutine dshr_restart_write(rpfile, case_name, model_name, inst_suffix, ymd, t character(*), parameter :: F00 = "('(dshr_restart_write) ',2a,2(i0,2x))" !------------------------------------------------------------------------------- + rc = ESMF_SUCCESS ! no streams means no restart file is written. if (shr_strdata_get_stream_count(sdat) <= 0) return @@ -1075,10 +1070,10 @@ subroutine dshr_restart_write(rpfile, case_name, model_name, inst_suffix, ymd, t ! write restart info to rpointer file if (my_task == main_task) then - open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') + open(newunit=nu, file=trim(rpfile), form='formatted') write(nu,'(a)') rest_file_model close(nu) - write(logunit,F00)' writing ',trim(rest_file_model), ymd, tod + write(logunit,F00)' writing ',trim(rest_file_model) endif ! write data model restart data diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index cb850e5d..0a5a25d0 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -34,6 +34,7 @@ module cdeps_dwav_comp use dshr_mod , only : dshr_restart_read, dshr_restart_write, dshr_mesh_init use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize + use nuopc_shr_methods, only : shr_get_rpointer_name implicit none private ! except @@ -249,7 +250,6 @@ end subroutine InitializeAdvertise !=============================================================================== subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) - ! input/output variables type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState @@ -263,6 +263,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer :: current_mon ! model month integer :: current_day ! model day integer :: current_tod ! model sec into model date + character(len=CL):: rpfile character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- @@ -288,11 +289,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call dwav_comp_realize(importState, exportState, export_all, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Read restart if necessary - if (restart_read .and. .not. skip_restart_read) then - call dshr_restart_read(gcomp, restfilm, 'wav', nullstr, logunit, my_task, mpicom, sdat) - end if - ! Get the time to interpolate the stream data to call ESMF_ClockGet(clock, currTime=currTime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -300,6 +296,15 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) + + ! Read restart if necessary + if (restart_read .and. .not. skip_restart_read) then + call shr_get_rpointer_name(gcomp, 'wav', current_ymd, current_tod, rpfile, 'read', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + ! Run dwav to create export state call dwav_comp_run(logunit, current_ymd, current_tod, sdat, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -330,6 +335,7 @@ subroutine ModelAdvance(gcomp, rc) integer :: next_ymd ! model date integer :: next_tod ! model sec into model date logical :: write_restart + character(len=CL):: rpfile character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -364,9 +370,12 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_TraceRegionEnter('dwav_restart') call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + call shr_get_rpointer_name(gcomp, 'wav', next_ymd, next_tod, rpfile, 'write', rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call dshr_restart_write(rpfile, case_name, 'dwav', inst_suffix, next_ymd, next_tod, & - logunit, my_task, sdat) + logunit, my_task, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TraceRegionExit('dwav_restart') endif From 03057bd91d9a0e06dc92c4e9a7dea13916e1dc59 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 6 Sep 2024 09:59:57 -0600 Subject: [PATCH 05/12] add use statement in lnd and change to restart test for dglc --- dglc/cime_config/testdefs/testlist_dglc.xml | 2 +- dlnd/lnd_comp_nuopc.F90 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dglc/cime_config/testdefs/testlist_dglc.xml b/dglc/cime_config/testdefs/testlist_dglc.xml index 8383469c..2ab88bcc 100644 --- a/dglc/cime_config/testdefs/testlist_dglc.xml +++ b/dglc/cime_config/testdefs/testlist_dglc.xml @@ -1,7 +1,7 @@ - + diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index f7527da6..a40685bc 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -35,7 +35,8 @@ module cdeps_dlnd_comp use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize use glc_elevclass_mod , only : glc_elevclass_as_string, glc_elevclass_init - + use nuopc_shr_methods , only : shr_get_rpointer_name + implicit none private ! except From 93cc684b1196d505ba35cacd8160783b0f10a25e Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 6 Sep 2024 10:43:10 -0600 Subject: [PATCH 06/12] revert change to test, update nuopc_shr_methods --- dglc/cime_config/testdefs/testlist_dglc.xml | 2 +- share/nuopc_shr_methods.F90 | 169 +++++++++++++++++++- 2 files changed, 168 insertions(+), 3 deletions(-) diff --git a/dglc/cime_config/testdefs/testlist_dglc.xml b/dglc/cime_config/testdefs/testlist_dglc.xml index 2ab88bcc..8383469c 100644 --- a/dglc/cime_config/testdefs/testlist_dglc.xml +++ b/dglc/cime_config/testdefs/testlist_dglc.xml @@ -1,7 +1,7 @@ - + diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index d65a9cc6..e6bcfba5 100644 --- a/share/nuopc_shr_methods.F90 +++ b/share/nuopc_shr_methods.F90 @@ -18,6 +18,7 @@ module nuopc_shr_methods use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet, ESMF_ClockGetAlarm use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent + use ESMF , only : ESMF_ClockGetNextTime use NUOPC , only : NUOPC_CompAttributeGet use NUOPC_Model , only : NUOPC_ModelGet use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -35,11 +36,12 @@ module nuopc_shr_methods public :: state_setscalar public :: state_diagnose public :: alarmInit + public :: get_minimum_timestep public :: chkerr - + public :: shr_get_rpointer_name private :: timeInit private :: field_getfldptr - + ! Module data ! Clock and alarm options shared with esm_time_mod along with dtime_driver which is initialized there. @@ -760,6 +762,169 @@ end subroutine timeInit !=============================================================================== + integer function get_minimum_timestep(gcomp, rc) + ! Get the minimum timestep interval in seconds based on the nuopc.config variables *_cpl_dt, + ! if none of these variables are defined this routine will throw an error + type(ESMF_GridComp), intent(in) :: gcomp + integer, intent(out) :: rc + + character(len=CS) :: cvalue + integer :: atm_cpl_dt ! Atmosphere coupling interval + integer :: lnd_cpl_dt ! Land coupling interval + integer :: ice_cpl_dt ! Sea-Ice coupling interval + integer :: ocn_cpl_dt ! Ocean coupling interval + integer :: glc_cpl_dt ! Glc coupling interval + integer :: rof_cpl_dt ! Runoff coupling interval + integer :: wav_cpl_dt ! Wav coupling interval + logical :: is_present, is_set ! determine if these variables are used + integer :: esp_cpl_dt ! Esp coupling interval + + !--------------------------------------------------------------------------- + ! Determine driver clock timestep + !--------------------------------------------------------------------------- + get_minimum_timestep = huge(1) + + call NUOPC_CompAttributeGet(gcomp, name="atm_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="atm_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) atm_cpl_dt + get_minimum_timestep = min(atm_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="lnd_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="lnd_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) lnd_cpl_dt + get_minimum_timestep = min(lnd_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="ice_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="ice_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) ice_cpl_dt + get_minimum_timestep = min(ice_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="ocn_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="ocn_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) ocn_cpl_dt + get_minimum_timestep = min(ocn_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="glc_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="glc_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) glc_cpl_dt + get_minimum_timestep = min(glc_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="rof_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="rof_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) rof_cpl_dt + get_minimum_timestep = min(rof_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="wav_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="wav_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) wav_cpl_dt + get_minimum_timestep = min(wav_cpl_dt, get_minimum_timestep) + endif + + call NUOPC_CompAttributeGet(gcomp, name="esp_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name="esp_cpl_dt", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) esp_cpl_dt + get_minimum_timestep = min(esp_cpl_dt, get_minimum_timestep) + endif + if(get_minimum_timestep == huge(1)) then + call ESMF_LogWrite('minimum_timestep_error: this option is not supported ', ESMF_LOGMSG_ERROR) + rc = ESMF_FAILURE + return + endif + if(get_minimum_timestep <= 0) then + print *,__FILE__,__LINE__,atm_cpl_dt, lnd_cpl_dt, ocn_cpl_dt, ice_cpl_dt, glc_cpl_dt, rof_cpl_dt, wav_cpl_dt + call ESMF_LogWrite('minimum_timestep_error ERROR ', ESMF_LOGMSG_ERROR) + rc = ESMF_FAILURE + return + endif + end function get_minimum_timestep + + subroutine shr_get_rpointer_name(gcomp, compname, ymd, time, rpfile, mode, rc) + type(ESMF_GRIDCOMP), intent(in) :: gcomp + character(len=3), intent(in) :: compname + integer, intent(in) :: ymd + integer, intent(in) :: time + character(len=*), intent(out) :: rpfile + character(len=*), intent(in) :: mode + integer, intent(out) :: rc + + ! local vars + integer :: yr, mon, day + character(len=16) timestr + logical :: isPresent + character(len=ESMF_MAXSTR) :: inst_suffix + + character(len=*), parameter :: subname='shr_get_rpointer_name' + + rc = ESMF_SUCCESS + + inst_suffix = "" + call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', isPresent=isPresent, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if(ispresent) call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', value=inst_suffix, rc=rc) + + yr = ymd/10000 + mon = (ymd - yr*10000)/100 + day = (ymd - yr*10000 - mon*100) + write(timestr,'(i4.4,a,i2.2,a,i2.2,a,i5.5)') yr,'-',mon,'-',day,'-',time + + rpfile = "rpointer."//compname + if (trim(inst_suffix) .ne. "") then + write(rpfile,*) trim(rpfile),".",trim(inst_suffix) + endif + write(rpfile,*) trim(rpfile),".",timestr + if (mode.eq.'read') then + inquire(file=trim(rpfile), exist=isPresent) + if(.not. isPresent) then + rpfile = "rpointer."//compname + if (inst_suffix .ne. "") then + rpfile = trim(rpfile)//"."//trim(inst_suffix) + endif + inquire(file=trim(rpfile), exist=isPresent) + if(.not. isPresent) then + call shr_sys_abort( subname//'ERROR no rpointer file found in '//rpfile//' or in '//rpfile//'.'//timestr ) + endif + endif + endif + end subroutine shr_get_rpointer_name + logical function chkerr(rc, line, file) integer, intent(in) :: rc From f90b42e5d8358ecd9e65c43344c2072aa3085402 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 6 Sep 2024 12:53:09 -0600 Subject: [PATCH 07/12] add DATAMODELTEST compset alias --- cime_config/config_compsets.xml | 57 +++++++++++++++++++++ datm/atm_comp_nuopc.F90 | 2 - dglc/cime_config/testdefs/testlist_dglc.xml | 14 +++-- 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 cime_config/config_compsets.xml diff --git a/cime_config/config_compsets.xml b/cime_config/config_compsets.xml new file mode 100644 index 00000000..7c92d45f --- /dev/null +++ b/cime_config/config_compsets.xml @@ -0,0 +1,57 @@ + + + + + + ========================================= + compset naming convention + ========================================= + The compset longname below has the specified order + atm, lnd, ice, ocn, river, glc wave cesm-options + + The notation for the compset longname is + TIME_ATM[%phys]_LND[%phys]_ICE[%phys]_OCN[%phys]_ROF[%phys]_GLC[%phys]_WAV[%phys][_ESP%phys][_BGC%phys] + Where for the specific compsets below the following is supported + TIME = Time period (e.g. 2000, HIST, RCP8...) + ATM = [CAM40, CAM50, CAM60] + LND = [CLM45, CLM50, SLND] + ICE = [CICE, DICE, SICE] + OCN = [MOM6, DOCN, SOCN] + ROF = [RTM, MOSART, SROF] + GLC = [CISM2, DGLC, SGLC] + WAV = [WW3, DWAV, XWAV, SWAV] + ESP = [SESP] + BGC = optional BGC scenario + + The OPTIONAL %phys attributes specify submodes of the given system + For example DOCN%DOM is the data ocean model for DOCN + ALL the possible %phys choices for each component are listed. + ALL data models must have a %phys option that corresponds to the data model mode + + Each compset node is associated with the following elements + - lname + - alias + - support (optional description of the support level for this compset) + Each compset node can also have the following attributes + - grid (optional regular expression match for grid to work with the compset) + + + DATAMODELTEST + HIST_DATM%JRA_DLND%SCPL_DICE%SSMI_DOCN%DOM_DGLC%NOEVOLVE_DWAV%CLIMO + + + + + + + 0001-01-01 + 2000-01-01 + 1850-01-01 + 1955-01-01 + 2005-01-01 + 2013-01-01 + + + + + diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index 9d7de76f..12b462af 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -586,9 +586,7 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod ! local variables logical :: first_time = .true. character(len=CL) :: rpfile - character(len=16) :: timestr character(*), parameter :: subName = '(datm_comp_run) ' - integer :: yr, mon, day !------------------------------------------------------------------------------- rc = ESMF_SUCCESS diff --git a/dglc/cime_config/testdefs/testlist_dglc.xml b/dglc/cime_config/testdefs/testlist_dglc.xml index 8383469c..35253066 100644 --- a/dglc/cime_config/testdefs/testlist_dglc.xml +++ b/dglc/cime_config/testdefs/testlist_dglc.xml @@ -1,7 +1,7 @@ - + @@ -10,7 +10,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -29,4 +29,12 @@ + + + + + + + + From 743120d74c8c365da178a6d9359e8223491eabc8 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 11 Sep 2024 10:31:36 -0600 Subject: [PATCH 08/12] fix ocn_aquap analytic cases --- docn/ocn_comp_nuopc.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index ce57ed8e..4bf9e5ac 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -558,6 +558,7 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar call docn_datamode_som_init_pointers(importState, exportState, sdat, model_frac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('sst_aquap_analytic', 'sst_aquap_constant') + skip_restart_read=.true. call docn_datamode_aquaplanet_init_pointers(exportState, model_frac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('cplhist') @@ -649,6 +650,8 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar case('som', 'som_aquap') call docn_datamode_som_restart_write(rpfile, case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) + case('sst_aquap_analytic', 'sst_aquap_constant') + ! Do nothing case default call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') end select From 4fecfe394aaf1998c8aeb40fb668279ecc44899a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 30 Sep 2024 09:49:52 -0600 Subject: [PATCH 09/12] fix testlist_dglc formating --- dglc/cime_config/testdefs/testlist_dglc.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dglc/cime_config/testdefs/testlist_dglc.xml b/dglc/cime_config/testdefs/testlist_dglc.xml index 35253066..f87182fb 100644 --- a/dglc/cime_config/testdefs/testlist_dglc.xml +++ b/dglc/cime_config/testdefs/testlist_dglc.xml @@ -30,7 +30,9 @@ - + + + From 302c33fa1da5cf2b725fdefd0781a8b3b8a03c6f Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 1 Oct 2024 08:07:17 -0600 Subject: [PATCH 10/12] remove the config_compsets file --- cime_config/config_compsets.xml | 57 --------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 cime_config/config_compsets.xml diff --git a/cime_config/config_compsets.xml b/cime_config/config_compsets.xml deleted file mode 100644 index 7c92d45f..00000000 --- a/cime_config/config_compsets.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - ========================================= - compset naming convention - ========================================= - The compset longname below has the specified order - atm, lnd, ice, ocn, river, glc wave cesm-options - - The notation for the compset longname is - TIME_ATM[%phys]_LND[%phys]_ICE[%phys]_OCN[%phys]_ROF[%phys]_GLC[%phys]_WAV[%phys][_ESP%phys][_BGC%phys] - Where for the specific compsets below the following is supported - TIME = Time period (e.g. 2000, HIST, RCP8...) - ATM = [CAM40, CAM50, CAM60] - LND = [CLM45, CLM50, SLND] - ICE = [CICE, DICE, SICE] - OCN = [MOM6, DOCN, SOCN] - ROF = [RTM, MOSART, SROF] - GLC = [CISM2, DGLC, SGLC] - WAV = [WW3, DWAV, XWAV, SWAV] - ESP = [SESP] - BGC = optional BGC scenario - - The OPTIONAL %phys attributes specify submodes of the given system - For example DOCN%DOM is the data ocean model for DOCN - ALL the possible %phys choices for each component are listed. - ALL data models must have a %phys option that corresponds to the data model mode - - Each compset node is associated with the following elements - - lname - - alias - - support (optional description of the support level for this compset) - Each compset node can also have the following attributes - - grid (optional regular expression match for grid to work with the compset) - - - DATAMODELTEST - HIST_DATM%JRA_DLND%SCPL_DICE%SSMI_DOCN%DOM_DGLC%NOEVOLVE_DWAV%CLIMO - - - - - - - 0001-01-01 - 2000-01-01 - 1850-01-01 - 1955-01-01 - 2005-01-01 - 2013-01-01 - - - - - From d5da82e88995b42451bfbd2abbf26d1f9e163433 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 1 Oct 2024 11:19:18 -0600 Subject: [PATCH 11/12] update nuopc_shr_methods to share1.1.3 --- share/nuopc_shr_methods.F90 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index e6bcfba5..02de842f 100644 --- a/share/nuopc_shr_methods.F90 +++ b/share/nuopc_shr_methods.F90 @@ -905,18 +905,11 @@ subroutine shr_get_rpointer_name(gcomp, compname, ymd, time, rpfile, mode, rc) day = (ymd - yr*10000 - mon*100) write(timestr,'(i4.4,a,i2.2,a,i2.2,a,i5.5)') yr,'-',mon,'-',day,'-',time - rpfile = "rpointer."//compname - if (trim(inst_suffix) .ne. "") then - write(rpfile,*) trim(rpfile),".",trim(inst_suffix) - endif - write(rpfile,*) trim(rpfile),".",timestr + write(rpfile,*) "rpointer."//compname//trim(inst_suffix)//'.'//trim(timestr) if (mode.eq.'read') then inquire(file=trim(rpfile), exist=isPresent) if(.not. isPresent) then - rpfile = "rpointer."//compname - if (inst_suffix .ne. "") then - rpfile = trim(rpfile)//"."//trim(inst_suffix) - endif + rpfile = "rpointer."//compname//trim(inst_suffix) inquire(file=trim(rpfile), exist=isPresent) if(.not. isPresent) then call shr_sys_abort( subname//'ERROR no rpointer file found in '//rpfile//' or in '//rpfile//'.'//timestr ) From c2c4274e1ca4923c5b4963b035cff0e22c634615 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 3 Oct 2024 15:34:50 -0600 Subject: [PATCH 12/12] fix issue in docn --- docn/ocn_comp_nuopc.F90 | 2 +- dshr/dshr_mod.F90 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index 4bf9e5ac..bb0d3e78 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -582,7 +582,7 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('som', 'som_aquap') - call docn_datamode_som_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call docn_datamode_som_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat) end select end if diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 8ea10dca..7d6bd71f 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -985,10 +985,10 @@ subroutine dshr_restart_read(rest_filem, rpfile, & if(shr_strdata_get_stream_count(sdat) <= 0) return call ESMF_VMGetCurrent(vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - exists = .false. - if (trim(rest_filem) == 'none') then + inquire(file=trim(rest_filem), exist=exists) + if (trim(rest_filem) == 'none' .or. trim(rest_filem) == 'null') then if (my_task == main_task) then - write(logunit,F00) ' restart filename from rpointer '//trim(rpfile) + write(logunit,F00) ' restart filename from rpointer: '//trim(rpfile) open(newunit=nu, file=trim(rpfile), form='formatted') read(nu, '(a)') rest_filem close(nu)