Skip to content

Commit

Permalink
Switch timeSeriesStats to use simulationStartTime
Browse files Browse the repository at this point in the history
Previously, timeSeriesStats was using the start time of the current
run as the beginning of stats.  Since this time starts over at
restarts, it was not triggering a reset of the stats as it should
have at the beginning of a restart interval that is commensurate
with the time-averaging interval.

With this merge, we now use the `simulationStartTime` to determine
when time-averaging began, so that alarms are correctly triggered
on restart.
  • Loading branch information
xylar committed Oct 5, 2022
1 parent fb21b5d commit d063071
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module ocn_time_series_stats
use mpas_stream_manager

use ocn_constants
use ocn_diagnostics_variables

implicit none
private
Expand Down Expand Up @@ -262,13 +263,7 @@ subroutine ocn_init_time_series_stats(domain, instance, err)!{{{

! set xtime start if it is still unset, for very first time step
! (i.e., no restarts)
start_time = mpas_get_clock_time(domain%clock, MPAS_START_TIME, err_tmp)
call mpas_get_time(start_time, dateTimeString=start_xtime, ierr=err_tmp)
if (err_tmp /= 0) then
call mpas_log_write('Error getting start time in init', &
MPAS_LOG_ERR, masterOnly=.true., flushNow=.true.)
err = ior(err, err_tmp)
endif
start_xtime = simulationStartTime

call mpas_pool_get_config(domain % configs, 'config_output_reference_time', &
config_output_reference_time)
Expand Down Expand Up @@ -1813,8 +1808,8 @@ subroutine set_times(series, alarms, clock, which, config, ok, err)
! set the time
if (which == START_TIMES) then
if (time == INITIAL_TIME_TOKEN) then
alarms(b) % start_time = &
mpas_get_clock_time(clock, MPAS_START_TIME, err)
call mpas_set_time(alarms(b) % start_time, &
dateTimeString=simulationStartTime)
else
call mpas_set_time(alarms(b) % start_time, &
dateTimeString=time, ierr=err)
Expand Down

0 comments on commit d063071

Please sign in to comment.