Skip to content

Commit f87f18d

Browse files
committed
refactor alarm code for endofrun restart writes
1 parent c2c4274 commit f87f18d

File tree

3 files changed

+87
-495
lines changed

3 files changed

+87
-495
lines changed

dglc/glc_comp_nuopc.F90

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

738738
if (trim(glc_avg_period) == 'hour') then
739-
call dshr_alarm_init(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
739+
call alarmInit(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
740740
if (ChkErr(rc,__LINE__,u_FILE_u)) return
741741
else if (trim(glc_avg_period) == 'day') then
742-
call dshr_alarm_init(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
742+
call alarmInit(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc)
743743
if (ChkErr(rc,__LINE__,u_FILE_u)) return
744744
else if (trim(glc_avg_period) == 'yearly') then
745-
call dshr_alarm_init(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc)
745+
call alarmInit(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc)
746746
if (ChkErr(rc,__LINE__,u_FILE_u)) return
747747
else if (trim(glc_avg_period) == 'glc_coupling_period') then
748748
call ESMF_TimeIntervalGet(mtimestep, s=dtime, rc=rc)
749749
if (ChkErr(rc,__LINE__,u_FILE_u)) return
750-
call dshr_alarm_init(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc)
750+
call alarmInit(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc)
751751
if (ChkErr(rc,__LINE__,u_FILE_u)) return
752752
else
753753
call ESMF_LogWrite(trim(subname)// ": ERROR glc_avg_period = "//trim(glc_avg_period)//" not supported", &
@@ -760,55 +760,55 @@ subroutine ModelSetRunClock(gcomp, rc)
760760
if (ChkErr(rc,__LINE__,u_FILE_u)) return
761761

762762
!----------------
763-
! Restart alarm
763+
! Stop alarm
764764
!----------------
765-
call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO)
766-
if (ChkErr(rc,__LINE__,u_FILE_u)) return
767-
768-
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
765+
call ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO)
766+
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
769767
if (ChkErr(rc,__LINE__,u_FILE_u)) return
770768

771-
call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
769+
call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
772770
if (ChkErr(rc,__LINE__,u_FILE_u)) return
773-
read(cvalue,*) restart_n
771+
read(cvalue,*) stop_n
774772

775-
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc)
773+
call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
776774
if (ChkErr(rc,__LINE__,u_FILE_u)) return
777-
read(cvalue,*) restart_ymd
775+
read(cvalue,*) stop_ymd
778776

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

786-
call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc)
784+
call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc)
787785
if (ChkErr(rc,__LINE__,u_FILE_u)) return
788786

789787
!----------------
790-
! Stop alarm
788+
! Restart alarm
791789
!----------------
792-
call ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO)
793-
call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc)
790+
call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO)
794791
if (ChkErr(rc,__LINE__,u_FILE_u)) return
795792

796-
call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc)
793+
call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc)
797794
if (ChkErr(rc,__LINE__,u_FILE_u)) return
798-
read(cvalue,*) stop_n
799795

800-
call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc)
796+
call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc)
801797
if (ChkErr(rc,__LINE__,u_FILE_u)) return
802-
read(cvalue,*) stop_ymd
798+
read(cvalue,*) restart_n
803799

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

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

814814
end if

0 commit comments

Comments
 (0)