Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alarms based on nsteps #447

Merged
merged 20 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 9 additions & 49 deletions cesm/driver/esm_time_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module esm_time_mod
use ESMF , only : operator(<=), operator(>), operator(==)
use NUOPC , only : NUOPC_CompAttributeGet
use esm_utils_mod , only : chkerr

implicit none
private ! default private

Expand Down Expand Up @@ -54,7 +54,7 @@ module esm_time_mod
!===============================================================================

subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintask, rc)

use nuopc_shr_methods, only : get_minimum_timestep, dtime_drv
jedwards4b marked this conversation as resolved.
Show resolved Hide resolved
! input/output variables
type(ESMF_GridComp) :: ensemble_driver, instance_driver
integer, intent(in) :: logunit
Expand All @@ -81,20 +81,11 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
integer :: stop_ymd ! Stop date (YYYYMMDD)
integer :: stop_tod ! Stop time-of-day
character(CS) :: stop_option ! Stop option units
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
! integer :: esp_cpl_dt ! Esp coupling interval
character(CS) :: glc_avg_period ! Glc avering coupling period
logical :: read_restart
character(len=CL) :: restart_file
character(len=CL) :: restart_pfile
character(len=CL) :: cvalue
integer :: dtime_drv ! time-step to use
integer :: yr, mon, day ! Year, month, day as integers
integer :: unitn ! unit number
integer :: ierr ! Return code
Expand Down Expand Up @@ -122,44 +113,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) start_tod

!---------------------------------------------------------------------------
! Determine driver clock timestep
!---------------------------------------------------------------------------

call NUOPC_CompAttributeGet(ensemble_driver, name="atm_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) atm_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="lnd_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) lnd_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="ice_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) ice_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="ocn_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) ocn_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="glc_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) glc_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="rof_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) rof_cpl_dt

call NUOPC_CompAttributeGet(ensemble_driver, name="wav_cpl_dt", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) wav_cpl_dt

dtime_drv = minval((/atm_cpl_dt, lnd_cpl_dt, ocn_cpl_dt, ice_cpl_dt, glc_cpl_dt, rof_cpl_dt, wav_cpl_dt/))
if(maintask) then
write(tmpstr,'(i10)') dtime_drv
call ESMF_LogWrite(trim(subname)//': driver time interval is : '// trim(tmpstr), ESMF_LOGMSG_INFO, rc=rc)
write(logunit,*) trim(subname)//': driver time interval is : '// trim(tmpstr)
endif
call ESMF_GridCompGet(ensemble_driver, vm=envm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -282,6 +236,12 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
call ESMF_TimeSet( RefTime, yy=yr, mm=mon, dd=day, s=ref_tod, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

dtime_drv = get_minimum_timestep(ensemble_driver, rc)
if(maintask) then
write(tmpstr,'(i10)') dtime_drv
call ESMF_LogWrite(trim(subname)//': driver time interval is : '// trim(tmpstr), ESMF_LOGMSG_INFO, rc=rc)
write(logunit,*) trim(subname)//': driver time interval is : '// trim(tmpstr)
endif
call ESMF_TimeIntervalSet( TimeStep, s=dtime_drv, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand All @@ -292,7 +252,7 @@ subroutine esm_time_clockInit(ensemble_driver, instance_driver, logunit, maintas
! Create the clock
clock = ESMF_ClockCreate(TimeStep, StartTime, refTime=RefTime, name='ESMF Driver Clock', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Advance the clock to the current time (in case of a restart)
call ESMF_ClockGet(clock, currTime=clocktime, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
Loading
Loading