Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.
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
20 changes: 19 additions & 1 deletion src/framework/mpas_forcing.F
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,9 @@ subroutine cycle_forcing_clock(&!{{{
type(mpas_forcing_stream_type), pointer :: &
forcingStream

type (MPAS_Alarm_type), pointer :: &
alarmPtr

! check if cycling alarm is ringing
if (mpas_is_alarm_ringing(forcingGroup % forcingClock, forcingGroup % forcingCycleAlarmID)) then

Expand All @@ -1273,7 +1276,7 @@ subroutine cycle_forcing_clock(&!{{{
! if ringing cycle the clock
oldForingClockTime = mpas_get_clock_time(forcingGroup % forcingClock, MPAS_NOW)
newForcingClockTime = oldForingClockTime - forcingGroup % forcingCycleDuration
call mpas_set_clock_time(forcingGroup % forcingClock, newForcingClockTime, MPAS_NOW)
call mpas_set_clock_time(forcingGroup % forcingClock, newForcingClockTime, MPAS_NOW, calibrateAlarms=.false.)

! if ringing cycle the forcing times
forcingStream => forcingGroup % stream
Expand All @@ -1287,6 +1290,17 @@ subroutine cycle_forcing_clock(&!{{{
forcingStream => forcingStream % next
enddo

! cycle alarms
alarmPtr => forcingGroup % forcingClock % alarmListHead
do while (associated(alarmPtr))

if (alarmPtr % isSet) then
alarmPtr % prevRingTime = alarmPtr % prevRingTime - forcingGroup % forcingCycleDuration
endif

alarmPtr => alarmPtr % next
end do

endif ! forcingCycleAlarmID ringing

end subroutine cycle_forcing_clock!}}}
Expand Down Expand Up @@ -1583,6 +1597,10 @@ subroutine get_interpolants_linear(interpolants, forcingStream, currentTime)!{{{
interpolants(1) = diffr2 / diffr
interpolants(2) = 1.0_RKIND - interpolants(1) !diffr1 / diffr

if (interpolants(1) < 0.0_RKIND .or. interpolants(1) > 1.0_RKIND) then
call MPAS_dmpar_global_abort('Forcing: Error: get_interpolants_linear: Interpolant not in range [0,1]')
endif

end subroutine get_interpolants_linear!}}}

!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Expand Down
10 changes: 8 additions & 2 deletions src/framework/mpas_timekeeping.F
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,28 @@ subroutine mpas_advance_clock(clock, timeStep, ierr)
end subroutine mpas_advance_clock


subroutine mpas_set_clock_time(clock, clock_time, whichTime, ierr)
subroutine mpas_set_clock_time(clock, clock_time, whichTime, ierr, calibrateAlarms)

implicit none

type (MPAS_Clock_type), intent(inout) :: clock
type (MPAS_Time_type), intent(in) :: clock_time
integer, intent(in) :: whichTime
integer, intent(out), optional :: ierr
logical, intent(in), optional :: calibrateAlarms
integer :: threadNum

logical :: calibrateAlarmsUse

calibrateAlarmsUse = .true.
if (present(calibrateAlarms)) calibrateAlarmsUse = calibrateAlarms

threadNum = mpas_threading_get_thread_num()

if ( threadNum == 0 ) then
if (whichTime == MPAS_NOW) then
call ESMF_ClockSet(clock % c, CurrTime=clock_time%t, rc=ierr)
call mpas_calibrate_alarms(clock, ierr);
if (calibrateAlarmsUse) call mpas_calibrate_alarms(clock, ierr);
else if (whichTime == MPAS_START_TIME) then
call ESMF_ClockSet(clock % c, StartTime=clock_time%t, rc=ierr)
else if (whichTime == MPAS_STOP_TIME) then
Expand Down