Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Feature request: "reference time" for output_interval in streams #1307

Closed
matthewhoffman opened this issue May 3, 2017 · 4 comments
Closed

Comments

@matthewhoffman
Copy link
Member

reference_time only controls the naming / timebreaks of filename_interval. Right now, output is always relative to the time of the start of the current simulation (even it it is a restart). There is no way to force, say, monthly output (i.e. on the 1st of every month) if your restart does not start on the first of a month.

Alternative idea: allow restarts to 'know' the start time of the original 'cold' start simulation.

@matthewhoffman
Copy link
Member Author

General consensus from telecon has been to extend existing reference_time to output_interval. Potential issue to figure out is if reference_time applies to alarms or just clocks. We would need reference_time applied to each alarm independently so that different streams could have different reference times.

@matthewhoffman
Copy link
Member Author

I think the problem may be here in mpas_timekeeping.F:

 530          if (present(alarmTimeInterval)) then
 531             alarmPtr % isRecurring = .true.
 532             alarmPtr % ringTimeInterval = alarmTimeInterval
 533             if(clock % direction == MPAS_FORWARD) then
 534                alarmPtr % prevRingTime = alarmTime - alarmTimeInterval
 535             else
 536                alarmPtr % prevRingTime = alarmTime + alarmTimeInterval
 537             end if
 538          else
 539             alarmPtr % isRecurring = .false.
 540             alarmPtr % prevRingTime = alarmTime
 541          end if
 542          if (present(ierr)) then
 543             if (ierr == ESMF_SUCCESS) ierr = 0
 544          end if
 545       end if

If I understand this correctly, when an alarm is created, the previous ring time (from which the next ring time is calculated) is the current time which is the start of the current simulation (because the alarms are created on init).

A solution may be to modify the call to mpas_clock_alarm here in mpas_stream_manager.F:

5866     if (trim(alarmTime) == 'start' .and. trim(alarmInterval) == 'final_only') then
5867         alarmTime_local = mpas_get_clock_time(clock, MPAS_STOP_TIME, ierr=ierr)
5868         call mpas_get_time(alarmTime_local, dateTimeString=alarmString)
5869         call MPAS_stream_mgr_set_property(manager, streamID, MPAS_STREAM_PROPERTY_REF_TIME, alarmString, ierr=ierr)
5870     else if (trim(alarmTime) == 'start') then
5871         alarmTime_local = mpas_get_clock_time(clock, MPAS_START_TIME, ierr=ierr)
5872     else
5873         call mpas_set_time(alarmTime_local, dateTimeString=alarmTime)
5874     end if
5875
5876     if (trim(alarmInterval) == 'initial_only' .or. trim(alarmInterval) == 'final_only') then
5877         call mpas_add_clock_alarm(clock, alarmID, alarmTime_local, ierr=ierr)
5878     else
5879         call mpas_set_timeInterval(alarmInterval_local, timeString=alarmInterval)
5880         call mpas_add_clock_alarm(clock, alarmID, alarmTime_local, alarmTimeInterval=alarmInterval_local, ierr=ierr)
5881     end if

Naively I would think one could just pass in the reference_time for that stream instead of alarmTime_local. However, that reference time is often in the distant past, which would lead to the alarm immediately ringing. (reference_time also could be in the distant future...) So I think there would need to be an additional step to adjust the reference_time by as many output_intervals needed to get to the simulation start time (current time).

@matthewhoffman
Copy link
Member Author

I opened a PR to address this: #1418

mark-petersen added a commit that referenced this issue Oct 10, 2017
…' into develop

Previously, a stream's reference_time only applied to determining the
filename breaks. Right now, output is always relative to the time of
the start of the current simulation (even if it is a restart). There is
no way to force, say, monthly output (i.e. on the 1st of every month) if
your restart does not start on the first of a month.

This commit extends reference_time to also apply to
determining when individual records should be written. Thus, output
stream behavior will not change after a restart.

This is done by adding a new routine to mpas_timekeeping that adjusts
the prevRingTime of an alarm to be an integer multiple of the stream's
output_interval away from the stream's reference_time. This routine is
called for each output stream created by the stream manager.

Fixes Issue #1307.
@matthewhoffman
Copy link
Member Author

Fixed by #1418

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant