From f67cb8a8c587f23a9d50c41ed618147d3e38f513 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 30 Aug 2024 07:50:49 -0600 Subject: [PATCH 1/6] add timestamps to rpointer files --- cesm/driver/esm_time_mod.F90 | 26 +++++++++++++++++++++++-- cime_config/buildnml | 2 -- cime_config/config_component.xml | 11 +++++++++++ cime_config/namelist_definition_drv.xml | 4 ++-- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/cesm/driver/esm_time_mod.F90 b/cesm/driver/esm_time_mod.F90 index a1a39a78..4debc1cf 100644 --- a/cesm/driver/esm_time_mod.F90 +++ b/cesm/driver/esm_time_mod.F90 @@ -95,6 +95,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas logical :: isPresent logical :: inDriver logical, save :: firsttime=.true. + logical :: exists character(len=*), parameter :: subname = '('//__FILE__//':esm_time_clockInit) ' !------------------------------------------------------------------------------- @@ -144,9 +145,17 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas inst_suffix = "" endif - restart_pfile = trim(restart_file)//inst_suffix + restart_pfile = replace_text(restart_file, ".cpl", ".cpl."//inst_suffix) if (maintask) then + print *,__FILE__,__LINE__,trim(restart_file) + inquire( file=trim(restart_file), exist=exists) + if (.not. exists) then + restart_pfile = "rpointer.cpl" + if (inst_suffix .ne. "") restart_pfile = trim(restart_pfile)//'.'//inst_suffix + endif + print *,__FILE__,__LINE__,trim(restart_file) + call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), & ESMF_LOGMSG_INFO) open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old',iostat=ierr) @@ -323,7 +332,20 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas if (ChkErr(rc,__LINE__,u_FILE_u)) return firsttime = .false. endif - end subroutine esm_time_clockInit + contains + FUNCTION Replace_Text (s,text,rep) RESULT(outs) + CHARACTER(*) :: s,text,rep + CHARACTER(LEN(s)+100) :: outs ! provide outs with extra 100 char len + INTEGER :: i, nt, nr + + outs = s ; nt = LEN_TRIM(text) ; nr = LEN_TRIM(rep) + DO + i = INDEX(outs,text(:nt)) ; IF (i == 0) EXIT + outs = outs(:i-1) // rep(:nr) // outs(i+nt:) + END DO + END FUNCTION Replace_Text + + end subroutine esm_time_clockInit !=============================================================================== diff --git a/cime_config/buildnml b/cime_config/buildnml index 44116d98..6cc593b9 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -382,8 +382,6 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files): nmlgen.set_value( "component_list", value=valid_comps_string.replace("CPL", "MED") ) - # the driver restart pointer will look like a mediator is present even if it is not - nmlgen.set_value("drv_restart_pointer", value="rpointer.cpl") logger.info("Writing nuopc_runconfig for components {}".format(valid_comps)) nuopc_config_file = os.path.join(confdir, "nuopc.runconfig") diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 63e1b09a..dfdc0279 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -402,6 +402,17 @@ + + char + rpointer.cpl + run_begin_stop_restart + env_run.xml + + Name of the restart pointer file, this can be used to restart from an + intermediate restart by appending the restart date and time in format YYYY-MM-DD-SSSSS + + + char none,never,nsteps,nseconds,nminutes,nhours,ndays,nmonths,nyears diff --git a/cime_config/namelist_definition_drv.xml b/cime_config/namelist_definition_drv.xml index 0d72779b..a9d3eb78 100644 --- a/cime_config/namelist_definition_drv.xml +++ b/cime_config/namelist_definition_drv.xml @@ -162,7 +162,7 @@ - + char expdef DRIVER_attributes @@ -170,7 +170,7 @@ Driver restart pointer file to initialize time info - rpointer.cpl + $DRV_RESTART_POINTER From 0341aebe58d21af78f551a03ebf15bfd7c15d969 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 6 Sep 2024 10:46:43 -0600 Subject: [PATCH 2/6] add timestamps to rpointer files --- cesm/driver/esm_time_mod.F90 | 13 +++----- mediator/med_phases_restart_mod.F90 | 51 +++++++++++++---------------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/cesm/driver/esm_time_mod.F90 b/cesm/driver/esm_time_mod.F90 index 4debc1cf..b65f467a 100644 --- a/cesm/driver/esm_time_mod.F90 +++ b/cesm/driver/esm_time_mod.F90 @@ -131,7 +131,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas if (read_restart) then - call NUOPC_CompAttributeGet(instance_driver, name='drv_restart_pointer', value=restart_file, rc=rc) + call NUOPC_CompAttributeGet(instance_driver, name='drv_restart_pointer', value=restart_pfile, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (trim(restart_file) /= 'none') then @@ -141,20 +141,17 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas if(isPresent) then call NUOPC_CompAttributeGet(instance_driver, name="inst_suffix", value=inst_suffix, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + restart_pfile = replace_text(restart_file, ".cpl", ".cpl."//inst_suffix) else inst_suffix = "" endif - - restart_pfile = replace_text(restart_file, ".cpl", ".cpl."//inst_suffix) - if (maintask) then - print *,__FILE__,__LINE__,trim(restart_file) - inquire( file=trim(restart_file), exist=exists) + inquire( file=trim(restart_pfile), exist=exists) + print *,__FILE__,__LINE__,trim(restart_pfile), exists if (.not. exists) then restart_pfile = "rpointer.cpl" if (inst_suffix .ne. "") restart_pfile = trim(restart_pfile)//'.'//inst_suffix endif - print *,__FILE__,__LINE__,trim(restart_file) call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), & ESMF_LOGMSG_INFO) @@ -334,7 +331,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas endif contains FUNCTION Replace_Text (s,text,rep) RESULT(outs) - CHARACTER(*) :: s,text,rep + CHARACTER(len=*) :: s,text,rep CHARACTER(LEN(s)+100) :: outs ! provide outs with extra 100 char len INTEGER :: i, nt, nr diff --git a/mediator/med_phases_restart_mod.F90 b/mediator/med_phases_restart_mod.F90 index 887aab8d..d21a3ada 100644 --- a/mediator/med_phases_restart_mod.F90 +++ b/mediator/med_phases_restart_mod.F90 @@ -138,7 +138,7 @@ subroutine med_phases_restart_write(gcomp, rc) use med_io_mod , only : med_io_close, med_io_date2yyyymmdd, med_io_sec2hms use med_phases_history_mod, only : auxcomp use med_constants_mod , only : SecPerDay => med_constants_SecPerDay - + use nuopc_shr_methods , only : shr_get_rpointer_name ! Input/output variables type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc @@ -172,9 +172,9 @@ subroutine med_phases_restart_write(gcomp, rc) character(ESMF_MAXSTR) :: case_name ! case name character(ESMF_MAXSTR) :: restart_file ! Local path to restart filename character(ESMF_MAXSTR) :: restart_pfile ! Local path to restart pointer filename - character(ESMF_MAXSTR) :: cpl_inst_tag ! instance tag character(ESMF_MAXSTR) :: restart_dir ! Optional restart directory name character(ESMF_MAXSTR) :: cvalue ! attribute string + character(ESMF_MAXSTR) :: cpl_inst_tag ! instance tag logical :: alarmIsOn ! generic alarm flag real(R8) :: tbnds(2) ! CF1.0 time bounds logical :: isPresent @@ -197,14 +197,6 @@ subroutine med_phases_restart_write(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', isPresent=isPresent, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if(isPresent) then - call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', value=cpl_inst_tag, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - else - cpl_inst_tag = "" - endif call NUOPC_CompAttributeGet(gcomp, name='restart_dir', isPresent=isPresent, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if(isPresent) then @@ -296,12 +288,20 @@ subroutine med_phases_restart_write(gcomp, rc) ! Use nexttimestr rather than currtimestr here since that is the time at the end of ! the timestep and is preferred for restart file names !--------------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', isPresent=isPresent, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', value=cpl_inst_tag, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + cpl_inst_tag = "" + endif write(restart_file,"(6a)") trim(restart_dir)//trim(case_name),'.cpl', trim(cpl_inst_tag),'.r.',& trim(nexttimestr),'.nc' if (maintask) then - restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag) + call shr_get_rpointer_name(gcomp, 'cpl', next_ymd, next_tod, restart_pfile, 'write', rc) call ESMF_LogWrite(trim(subname)//" write rpointer file = "//trim(restart_pfile), ESMF_LOGMSG_INFO) open(newunit=unitn, file=restart_pfile, form='FORMATTED') write(unitn,'(a)') trim(restart_file) @@ -480,13 +480,14 @@ subroutine med_phases_restart_read(gcomp, rc) ! Read mediator restart - use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_Clock, ESMF_Time, ESMF_MAXSTR - use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS, ESMF_FAILURE - use ESMF , only : ESMF_LOGMSG_ERROR, ESMF_VMBroadCast - use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_ClockPrint - use ESMF , only : ESMF_FieldBundleIsCreated, ESMF_TimeGet - use NUOPC , only : NUOPC_CompAttributeGet - use med_io_mod , only : med_io_read + use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_Clock, ESMF_Time, ESMF_MAXSTR + use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS, ESMF_FAILURE + use ESMF , only : ESMF_LOGMSG_ERROR, ESMF_VMBroadCast + use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_ClockPrint + use ESMF , only : ESMF_FieldBundleIsCreated, ESMF_TimeGet + use NUOPC , only : NUOPC_CompAttributeGet + use med_io_mod , only : med_io_read + use nuopc_shr_methods, only : shr_get_rpointer_name ! Input/output variables type(ESMF_GridComp) :: gcomp @@ -501,10 +502,10 @@ subroutine med_phases_restart_read(gcomp, rc) integer :: n integer :: ierr, unitn integer :: yr,mon,day,sec ! time units + integer :: curr_ymd character(ESMF_MAXSTR) :: case_name ! case name character(ESMF_MAXSTR) :: restart_file ! Local path to restart filename character(ESMF_MAXSTR) :: restart_pfile ! Local path to restart pointer filename - character(ESMF_MAXSTR) :: cpl_inst_tag ! instance tag logical :: isPresent character(len=*), parameter :: subname='(med_phases_restart_read)' !--------------------------------------- @@ -520,14 +521,6 @@ subroutine med_phases_restart_read(gcomp, rc) ! Get case name and inst suffix call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', isPresent=isPresent, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (isPresent) then - call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', value=cpl_inst_tag, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - else - cpl_inst_tag = "" - endif ! Get the clock info call ESMF_GridCompGet(gcomp, clock=clock) @@ -536,6 +529,8 @@ subroutine med_phases_restart_read(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_TimeGet(currtime,yy=yr, mm=mon, dd=day, s=sec, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ymd2date(yr,mon,day,curr_ymd) + write(currtimestr,'(i4.4,a,i2.2,a,i2.2,a,i5.5)') yr,'-',mon,'-',day,'-',sec if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": currtime = "//trim(currtimestr), ESMF_LOGMSG_INFO) @@ -546,8 +541,8 @@ subroutine med_phases_restart_read(gcomp, rc) endif ! Get the restart file name from the pointer file - restart_pfile = "rpointer.cpl"//trim(cpl_inst_tag) if (maintask) then + call shr_get_rpointer_name(gcomp, 'cpl', curr_ymd, sec, restart_pfile, 'read', rc) call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), ESMF_LOGMSG_INFO) open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old', iostat=ierr) read (unitn,'(a)', iostat=ierr) restart_file From 27c2af7dc990bcc660c98b0b11572949df35e0db Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 1 Oct 2024 08:30:48 -0600 Subject: [PATCH 3/6] remove unused subroutine --- cesm/driver/esm_time_mod.F90 | 39 +++++++++--------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/cesm/driver/esm_time_mod.F90 b/cesm/driver/esm_time_mod.F90 index b65f467a..c423b96f 100644 --- a/cesm/driver/esm_time_mod.F90 +++ b/cesm/driver/esm_time_mod.F90 @@ -23,7 +23,7 @@ module esm_time_mod implicit none private ! default private - public :: esm_time_clockInit ! initialize driver clock (assumes default calendar) + public :: esm_time_clockinit ! initialize driver clock (assumes default calendar) private :: esm_time_date2ymd @@ -52,7 +52,7 @@ module esm_time_mod contains !=============================================================================== - subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintask, rc) + subroutine esm_time_clockinit(ensemble_driver, instance_driver, logunit, maintask, rc) use nuopc_shr_methods, only : get_minimum_timestep, dtime_drv ! input/output variables type(ESMF_GridComp) :: ensemble_driver, instance_driver @@ -134,25 +134,17 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas call NUOPC_CompAttributeGet(instance_driver, name='drv_restart_pointer', value=restart_pfile, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (trim(restart_file) /= 'none') then + if (trim(restart_pfile) /= 'none') then - call NUOPC_CompAttributeGet(instance_driver, name="inst_suffix", isPresent=isPresent, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if(isPresent) then - call NUOPC_CompAttributeGet(instance_driver, name="inst_suffix", value=inst_suffix, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - restart_pfile = replace_text(restart_file, ".cpl", ".cpl."//inst_suffix) - else - inst_suffix = "" - endif if (maintask) then + write(logunit,*) " read rpointer file = "//trim(restart_pfile) inquire( file=trim(restart_pfile), exist=exists) - print *,__FILE__,__LINE__,trim(restart_pfile), exists if (.not. exists) then - restart_pfile = "rpointer.cpl" - if (inst_suffix .ne. "") restart_pfile = trim(restart_pfile)//'.'//inst_suffix + rc = ESMF_FAILURE + call ESMF_LogWrite(trim(subname)//' ERROR rpointer file '//trim(restart_pfile)//' not found', & + ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__) + return endif - call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), & ESMF_LOGMSG_INFO) open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old',iostat=ierr) @@ -329,20 +321,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas if (ChkErr(rc,__LINE__,u_FILE_u)) return firsttime = .false. endif - contains - FUNCTION Replace_Text (s,text,rep) RESULT(outs) - CHARACTER(len=*) :: s,text,rep - CHARACTER(LEN(s)+100) :: outs ! provide outs with extra 100 char len - INTEGER :: i, nt, nr - - outs = s ; nt = LEN_TRIM(text) ; nr = LEN_TRIM(rep) - DO - i = INDEX(outs,text(:nt)) ; IF (i == 0) EXIT - outs = outs(:i-1) // rep(:nr) // outs(i+nt:) - END DO - END FUNCTION Replace_Text - - end subroutine esm_time_clockInit + end subroutine esm_time_clockinit !=============================================================================== From 3cc308f4c18532e1bcdf1209f206dec24ea52d38 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 14 Oct 2024 12:29:48 -0600 Subject: [PATCH 4/6] debug github workflow --- .github/workflows/srt.yml | 1 + cime_config/namelist_definition_drv.xml | 18 ++++-------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/srt.yml b/.github/workflows/srt.yml index a94205d7..dc3e9f92 100644 --- a/.github/workflows/srt.yml +++ b/.github/workflows/srt.yml @@ -86,6 +86,7 @@ jobs: git checkout main cd ../cime git checkout master + git status if [[ ! -e "${PWD}/.gitmodules.bak" ]] then echo "Converting git@github.com to https://github.com urls in ${PWD}/.gitmodules" diff --git a/cime_config/namelist_definition_drv.xml b/cime_config/namelist_definition_drv.xml index 6d8b3bc1..849cacc8 100644 --- a/cime_config/namelist_definition_drv.xml +++ b/cime_config/namelist_definition_drv.xml @@ -233,18 +233,6 @@ - - - logical - nuopc - ALLCOMP_attributes - - .false. - .false. - .false. - - - char nuopc @@ -2862,7 +2850,7 @@ - + logical time CLOCK_attributes @@ -2874,7 +2862,9 @@ default: false - .false. + .true. + .false. + .false. From 8a892c5134153c3d32e13f5a5f38928d52e2aa56 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 14 Oct 2024 12:56:02 -0600 Subject: [PATCH 5/6] rearrange externals --- .github/workflows/srt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/srt.yml b/.github/workflows/srt.yml index dc3e9f92..fc75ec26 100644 --- a/.github/workflows/srt.yml +++ b/.github/workflows/srt.yml @@ -81,7 +81,7 @@ jobs: git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" pushd cesm - ./bin/git-fleximod update ccs_config cdeps share mct parallelio cime + ./bin/git-fleximod update cime ccs_config cdeps share mct parallelio cd ccs_config git checkout main cd ../cime From 4883961d284402f0234c1a4bed6b6a3ffa7b04d8 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 09:02:59 -0600 Subject: [PATCH 6/6] do not stop ringing alarm --- mediator/med_diag_mod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/mediator/med_diag_mod.F90 b/mediator/med_diag_mod.F90 index 4c9ba6b4..bb0139cc 100644 --- a/mediator/med_diag_mod.F90 +++ b/mediator/med_diag_mod.F90 @@ -2116,8 +2116,6 @@ subroutine med_phases_diag_print(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then output_level = max(output_level, budget_print_ltend) - call ESMF_AlarmRingerOff( stop_alarm, rc=rc ) - if (ChkErr(rc,__LINE__,u_FILE_u)) return endif endif