Skip to content

Commit 4c50216

Browse files
authored
Merge pull request #312 from jedwards4b/add_rpointer_timestamp
refactor alarm code for endofrun restart writes
2 parents ec0a0c8 + 92a99c7 commit 4c50216

File tree

3 files changed

+58
-477
lines changed

3 files changed

+58
-477
lines changed

dglc/dglc_datamode_noevolve_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ subroutine dglc_datamode_noevolve_restart_write(model_meshes, case_name, &
549549
write(rest_file_model ,"(7a)") trim(case_name),'.','dglc',trim(inst_suffix),'.r.',trim(date_str),'.nc'
550550
! write restart info to rpointer file
551551
if (my_task == main_task) then
552-
open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted')
552+
open(newunit=nu, file=trim(rpfile), form='formatted')
553553
write(nu,'(a)') rest_file_model
554554
close(nu)
555555
write(logunit,'(a,2x,i0,2x,i0)')' writing with no streams '//trim(rest_file_model), ymd, tod

dglc/glc_comp_nuopc.F90

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ module cdeps_dglc_comp
3636
#endif
3737
use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck
3838
use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_init_from_config
39-
use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_alarm_init
39+
use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init
4040
use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_check_restart_alarm
4141
use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy
4242
use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_realize
43-
use nuopc_shr_methods, only : shr_get_rpointer_name
43+
use nuopc_shr_methods, only : shr_get_rpointer_name, alarmInit
4444
! Datamode specialized modules
4545
use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_advertise
4646
use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_init_pointers
@@ -737,18 +737,18 @@ subroutine ModelSetRunClock(gcomp, rc)
737737
if (ChkErr(rc,__LINE__,u_FILE_u)) return
738738

739739
if (trim(glc_avg_period) == 'hour') then
740-
call dshr_alarm_init(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
740+
call alarmInit(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
741741
if (ChkErr(rc,__LINE__,u_FILE_u)) return
742742
else if (trim(glc_avg_period) == 'day') then
743-
call dshr_alarm_init(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
743+
call alarmInit(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
744744
if (ChkErr(rc,__LINE__,u_FILE_u)) return
745745
else if (trim(glc_avg_period) == 'yearly') then
746-
call dshr_alarm_init(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc)
746+
call alarmInit(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc)
747747
if (ChkErr(rc,__LINE__,u_FILE_u)) return
748748
else if (trim(glc_avg_period) == 'glc_coupling_period') then
749749
call ESMF_TimeIntervalGet(mtimestep, s=dtime, rc=rc)
750750
if (ChkErr(rc,__LINE__,u_FILE_u)) return
751-
call dshr_alarm_init(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc)
751+
call alarmInit(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc)
752752
if (ChkErr(rc,__LINE__,u_FILE_u)) return
753753
else
754754
call ESMF_LogWrite(trim(subname)// ": ERROR glc_avg_period = "//trim(glc_avg_period)//" not supported", &
@@ -761,55 +761,55 @@ subroutine ModelSetRunClock(gcomp, rc)
761761
if (ChkErr(rc,__LINE__,u_FILE_u)) return
762762

763763
!----------------
764-
! Restart alarm
764+
! Stop alarm
765765
!----------------
766-
call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO)
767-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
768-
769-
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
766+
call ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO)
767+
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
770768
if (ChkErr(rc,__LINE__,u_FILE_u)) return
771769

772-
call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
770+
call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
773771
if (ChkErr(rc,__LINE__,u_FILE_u)) return
774-
read(cvalue,*) restart_n
772+
read(cvalue,*) stop_n
775773

776-
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc)
774+
call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
777775
if (ChkErr(rc,__LINE__,u_FILE_u)) return
778-
read(cvalue,*) restart_ymd
776+
read(cvalue,*) stop_ymd
779777

780-
call dshr_alarm_init(mclock, restart_alarm, restart_option, &
781-
opt_n = restart_n, &
782-
opt_ymd = restart_ymd, &
778+
call alarmInit(mclock, stop_alarm, stop_option, &
779+
opt_n = stop_n, &
780+
opt_ymd = stop_ymd, &
783781
RefTime = mcurrTime, &
784-
alarmname = 'alarm_restart', rc=rc)
782+
alarmname = 'alarm_stop', rc=rc)
785783
if (ChkErr(rc,__LINE__,u_FILE_u)) return
786784

787-
call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc)
785+
call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc)
788786
if (ChkErr(rc,__LINE__,u_FILE_u)) return
789787

790788
!----------------
791-
! Stop alarm
789+
! Restart alarm
792790
!----------------
793-
call ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO)
794-
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
791+
call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO)
795792
if (ChkErr(rc,__LINE__,u_FILE_u)) return
796793

797-
call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
794+
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
798795
if (ChkErr(rc,__LINE__,u_FILE_u)) return
799-
read(cvalue,*) stop_n
800796

801-
call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
797+
call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
802798
if (ChkErr(rc,__LINE__,u_FILE_u)) return
803-
read(cvalue,*) stop_ymd
799+
read(cvalue,*) restart_n
804800

805-
call dshr_alarm_init(mclock, stop_alarm, stop_option, &
806-
opt_n = stop_n, &
807-
opt_ymd = stop_ymd, &
801+
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc)
802+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
803+
read(cvalue,*) restart_ymd
804+
805+
call alarmInit(mclock, restart_alarm, restart_option, &
806+
opt_n = restart_n, &
807+
opt_ymd = restart_ymd, &
808808
RefTime = mcurrTime, &
809-
alarmname = 'alarm_stop', rc=rc)
809+
alarmname = 'alarm_restart', rc=rc)
810810
if (ChkErr(rc,__LINE__,u_FILE_u)) return
811811

812-
call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc)
812+
call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc)
813813
if (ChkErr(rc,__LINE__,u_FILE_u)) return
814814

815815
end if

0 commit comments

Comments
 (0)