Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions driver-mct/shr/seq_timemgr_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ subroutine seq_timemgr_clockInit(SyncClock, nmlfile, restart, restart_file, pioi
integer(SHR_KIND_IN) :: wav_cpl_dt ! Wav coupling interval
integer(SHR_KIND_IN) :: iac_cpl_dt ! Iac coupling interval
integer(SHR_KIND_IN) :: esp_cpl_dt ! Esp coupling interval
integer(SHR_KIND_IN) :: min_cpl_dt ! Smallest component coupling interval (s)
integer(SHR_KIND_IN) :: histavg_dt ! Histavg interval in seconds
integer(SHR_KIND_IN) :: atm_cpl_offset ! Atmosphere coupling interval
integer(SHR_KIND_IN) :: lnd_cpl_offset ! Land coupling interval
integer(SHR_KIND_IN) :: ice_cpl_offset ! Sea-Ice coupling interval
Expand Down Expand Up @@ -711,6 +713,41 @@ subroutine seq_timemgr_clockInit(SyncClock, nmlfile, restart, restart_file, pioi
call shr_sys_abort( subname//': ERROR invalid start_ymd')
end if

! --- Histavg period vs coupling period ---------------------------------
! The coupler average-history averaging period must not be smaller than
! the smallest component coupling period. Otherwise an averaging window
! can close before some components have coupled even once, leaving their
! fields unset and producing wrong averages for that window.
min_cpl_dt = min(atm_cpl_dt, lnd_cpl_dt, ice_cpl_dt, ocn_cpl_dt, &

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would min_cpl_dt technically correspond to the rendezvous step?

glc_cpl_dt, rof_cpl_dt, wav_cpl_dt, esp_cpl_dt, iac_cpl_dt)

! Convert the absolute-time averaging options to seconds so they can be
! compared with the coupling period. nsteps averaging is always a whole
! number of driver steps (>= the smallest coupling period), and
! nmonth/nyear are always larger, so those need no check. never/none/
! other/date do no fixed-length averaging that can be compared here.
histavg_dt = -1
if ( trim(histavg_option) == trim(seq_timemgr_optNSeconds) .or. &
trim(histavg_option) == trim(seq_timemgr_optNSecond) ) then
histavg_dt = histavg_n
elseif ( trim(histavg_option) == trim(seq_timemgr_optNMinutes) .or. &
trim(histavg_option) == trim(seq_timemgr_optNMinute) ) then
histavg_dt = histavg_n * 60
elseif ( trim(histavg_option) == trim(seq_timemgr_optNHours) .or. &
trim(histavg_option) == trim(seq_timemgr_optNHour) ) then
histavg_dt = histavg_n * 3600
elseif ( trim(histavg_option) == trim(seq_timemgr_optNDays) .or. &
trim(histavg_option) == trim(seq_timemgr_optNDay) ) then
histavg_dt = histavg_n * 86400
end if

if ( histavg_dt > 0 .and. histavg_dt < min_cpl_dt ) then
write(logunit,*) trim(subname),' ERROR: histavg period (', histavg_dt, &
' s) is smaller than the smallest coupling period (', min_cpl_dt, ' s)'
call shr_sys_abort( subname// &
': ERROR histavg period must not be smaller than the smallest coupling period' )
end if

endif

!---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion driver-moab/main/cime_comp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5151,7 +5151,7 @@ subroutine cime_run_write_history(lnd2glc_averaged_now)
call t_startf('CPL:seq_hist_writeavg')
call seq_hist_writeavg(infodata, EClock_d, &
atm, lnd, ice, ocn, rof, glc, wav, iac, histavg_alarm, &
trim(cpl_inst_tag))
trim(cpl_inst_tag), rofrun_alarm)
call t_stopf('CPL:seq_hist_writeavg')

endif
Expand Down
17 changes: 10 additions & 7 deletions driver-moab/main/prep_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1396,13 +1396,16 @@ subroutine prep_rof_mrg_moab (infodata, timer_mrg)
if (ierr .ne. 0) then
call shr_sys_abort(subname//' error in getting fractions_om from rof instance ')
endif
! fill the r2x_rm, etc double array fields nflds
tagname = trim(seq_flds_x2r_fields)//C_NULL_CHAR
arrsize = nflds * lsize
ierr = iMOAB_GetDoubleTagStorage ( mbrxid, tagname, arrsize , ent_type, x2r_rm)
if (ierr .ne. 0) then
call shr_sys_abort(subname//' error in getting x2r_rm array ')
endif
! Zero-initialize x2r_rm rather than reading back the existing x2r tag.
! This merge is the only writer of the x2r tag on mbrxid, and it explicitly
! sets every field it computes below. Fields that are not computed for this
! configuration (e.g. So_ssh when ocn_rof_two_way is off, or the disabled
! coszen_str) must be zero to match driver-mct, whose x2r attribute vector is
! zero-filled at allocation. Reading the tag back instead would carry the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this deliberate?

! MOAB define-time default (garbage) into those unset fields, contaminating
! the coupler average-history file (the instantaneous history is unaffected
! because seq_io_write_moab_tags scrubs MOAB defaults on output).
x2r_rm(:,:) = 0.0_R8
! a2x_rm (lsize, naflds))

if (rof_heat) then
Expand Down
Loading