diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index 7a2a41c7..12b462af 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 @@ -479,7 +462,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 +544,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,14 +562,15 @@ 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) - + use nuopc_shr_methods, only : shr_get_rpointer_name ! ---------------------------------- ! run method for datm model ! ---------------------------------- ! input/output variables + 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 @@ -601,6 +585,7 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile character(*), parameter :: subName = '(datm_comp_run) ' !------------------------------------------------------------------------------- @@ -613,7 +598,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe !-------------------- if (first_time) then - ! Initialize dfields call datm_init_dfields(rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -648,23 +632,14 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe ! 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(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CORE_IAF_JRA') - call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CLMNCEP') - call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CPLHIST') - call datm_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('ERA5') - call datm_datamode_era5_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('GEFS') - call datm_datamode_gefs_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CFSR') - call datm_datamode_cfsr_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('SIMPLE') - call datm_datamode_simple_restart_read(restfilm, inst_suffix, 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 @@ -727,33 +702,15 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe ! 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 8ad8cd3d..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 41a9725c..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 41d2caae..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 482bb7a0..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 e10fe302..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 86e6939a..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 9eb81515..e09844ac 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 ca978c15..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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - end subroutine datm_datamode_simple_restart_read - end module datm_datamode_simple_mod diff --git a/dglc/cime_config/testdefs/testlist_dglc.xml b/dglc/cime_config/testdefs/testlist_dglc.xml index 8383469c..f87182fb 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,14 @@ + + + + + + + + + + diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index 6a7caa58..a7ed1359 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -73,7 +73,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__ @@ -508,12 +507,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 @@ -594,14 +594,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(model_meshes, restfilem, rpfile, & + logunit, my_task, main_task, mpicom, & pio_subsystem, io_type, nx_global, ny_global, rc) ! input/output arguments type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes character(len=*) , intent(inout) :: restfilem - character(len=*) , intent(in) :: inst_suffix + character(len=*) , intent(in) :: rpfile integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: main_task @@ -638,13 +638,8 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, & call ESMF_VMGetCurrent(vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return 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') + 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) inquire(file=trim(restfilem), exist=exists) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index 68623456..39c6620f 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 @@ -518,7 +518,7 @@ subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, va ! -------------------------- ! input/output variables: - type(ESMF_GridComp) :: gcomp + 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 @@ -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,9 +558,10 @@ 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(model_meshes, restfilm, & - inst_suffix, logunit, my_task, main_task, mpicom, & + 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 end if @@ -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 6f15fc9c..79c4ac37 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 @@ -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,30 +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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + 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(rest_filem, rpfile, inst_suffix, 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 63539e81..ad01ffdd 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 @@ -395,7 +395,6 @@ end subroutine InitializeRealize !=============================================================================== subroutine ModelAdvance(gcomp, rc) - ! input/output variables type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc @@ -450,7 +449,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 +457,15 @@ 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) + use nuopc_shr_methods, only : shr_get_rpointer_name ! -------------------------- ! 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 @@ -475,6 +476,7 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile character(*), parameter :: subName = "(dice_comp_run) " !------------------------------------------------------------------------------- @@ -502,9 +504,11 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar ! 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(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 @@ -549,9 +553,11 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar ! 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 56a360c8..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 @@ -98,7 +99,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 +277,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 +302,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(restfilm, rpfile, inst_suffix, 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 +309,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 +338,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 +354,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 +385,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 95d4b764..85d625fe 100644 --- a/docn/docn_datamode_copyall_mod.F90 +++ b/docn/docn_datamode_copyall_mod.F90 @@ -7,7 +7,6 @@ module docn_datamode_copyall_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_type implicit none @@ -16,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 @@ -128,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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 3ff9e65c..81ac4022 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -7,7 +7,6 @@ module docn_datamode_cplhist_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_type implicit none @@ -16,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 @@ -122,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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - 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) - - 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 032467f3..7e56afd4 100644 --- a/docn/docn_datamode_iaf_mod.F90 +++ b/docn/docn_datamode_iaf_mod.F90 @@ -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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - 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) - - 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 7cd7fd9e..9c8c35be 100644 --- a/docn/docn_datamode_multilev_dom_mod.F90 +++ b/docn/docn_datamode_multilev_dom_mod.F90 @@ -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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - 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) - - 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 897797f3..aaa24258 100644 --- a/docn/docn_datamode_multilev_mod.F90 +++ b/docn/docn_datamode_multilev_mod.F90 @@ -6,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 @@ -15,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 @@ -187,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(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! read restart file - - ! input/output arguments - 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) - - 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 672c58d4..92e51c0f 100644 --- a/docn/docn_datamode_som_mod.F90 +++ b/docn/docn_datamode_som_mod.F90 @@ -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(rest_filem, inst_suffix, 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 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(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(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 f15ed9ec..bb0d3e78 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 @@ -453,7 +445,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 +504,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 @@ -535,6 +528,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod ! local variables logical :: first_time = .true. + character(len=CL) :: rpfile ! restart pointer file name character(*), parameter :: subName = "(docn_comp_run) " !------------------------------------------------------------------------------- @@ -564,6 +558,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod 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') @@ -579,13 +574,15 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod ! 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(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('iaf') - call docn_datamode_iaf_restart_read(restfilm, inst_suffix, 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(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 @@ -642,21 +639,24 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod ! 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('sst_aquap_analytic', 'sst_aquap_constant') + ! Do nothing + 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 959421a7..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 @@ -310,7 +311,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 +366,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 @@ -387,6 +389,7 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) ! local variables logical :: first_time = .true. integer :: n + character(len=CL) :: rpfile character(*), parameter :: subName = "(drof_comp_run) " !------------------------------------------------------------------------------- @@ -411,7 +414,10 @@ 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 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. @@ -446,11 +452,13 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) ! 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..7d6bd71f 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 + 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' - 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 13728738..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(restfilm, rpfile, inst_suffix, 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 diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index d65a9cc6..02de842f 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,162 @@ 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 + + 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//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 ) + endif + endif + endif + end subroutine shr_get_rpointer_name + logical function chkerr(rc, line, file) integer, intent(in) :: rc