Update the given timeControl if it just triggered.
The timeControl will be updated to trigger after the next complete interval, or at least after now. The update is only done if the timeControl actually triggered since the last update, or the optional argument hasTriggered is true.
Usually, this routine should be called right after checking the status of the time control with tem_timeControl_triggered. However, due to the fact, that the hasTriggered might need to be reduced across all processes in between (if the clock measurement is involved in the trigger), this communication has to be done first, and the hasTriggered argument can be used to pass the result from the allreduce. To avoid unnecessary communication, this allreduce might be used for other flags as well, therefore it is not included in these routines.
If such a separation is not desirable, use tem_timeControl_check, which probe the trigger and update it if needed, including communication if the clock time setting is used in the trigger definition.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_timeControl_type), | intent(inout) | :: | me |
Time control object to update. |
||
type(tem_time_type), | intent(in) | :: | now |
Current time to use for the update. |
||
logical, | intent(in), | optional | :: | hasTriggered |
Flag to indicate if the time control already has triggered. If this argument is not present, the check for the trigger status of the time control will be done internally. |
|
logical, | intent(in), | optional | :: | localTriggered |
Flag to indicate if the local time control already has triggered. This will be used in place of the hasTriggered, if delayCheck is true to avoid subsequent multiple checks of the same interval. |
subroutine tem_timeControl_update(me, now, hasTriggered, localTriggered)
! -------------------------------------------------------------------- !
!> Time control object to update.
type(tem_timeControl_type), intent(inout) :: me
!> Current time to use for the update.
type(tem_time_type), intent(in) :: now
!> Flag to indicate if the time control already has triggered.
!!
!! If this argument is not present, the check for the trigger status of
!! the time control will be done internally.
logical, intent(in), optional :: hasTriggered
!> Flag to indicate if the local time control already has triggered.
!!
!! This will be used in place of the hasTriggered, if delayCheck is
!! true to avoid subsequent multiple checks of the same interval.
logical, intent(in), optional :: localTriggered
! -------------------------------------------------------------------- !
logical :: triggered
! -------------------------------------------------------------------- !
if (present(hasTriggered)) then
triggered = hasTriggered
if (present(localTriggered) .and. me%delay_check) then
triggered = localTriggered
end if
else
triggered = tem_timeControl_triggered(me, now)
end if
if (triggered) then
me%trigger = max(me%trigger + me%interval, now)
end if
end subroutine tem_timeControl_update