This routine checks globally if the control has triggered.
It takes care of communication as well. A reduction of the trigger status might be needed, depending on the time definitions in the trigger. This communication is done with the MPI communicator comm, and all processes calling this routine should be members of comm. The communication is only done, if necessary. If the trigger became active since the last check or update, the triggered argument will be set to true. If delay_check is true, the communication is done with a nonblocking allreduce, which performs the check essentially on the previous check interval, rather than the current one.
If this should be done in combination with other status communications to avoid unnecessary synchronisation points, the separate routines tem_timeControl_triggered and tem_timeControl_update have to be used instead.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_timeControl_type), | intent(inout) | :: | me |
Time control to check if it was triggered across all processes. |
||
type(tem_time_type), | intent(in) | :: | now |
Current time to use for the comparison. |
||
integer, | intent(in) | :: | comm |
Communicator to use for the global reduction. |
Result indicating if the time control has triggered.
function tem_timeControl_globalTriggered(me, now, comm) result (hasTriggered) ! -------------------------------------------------------------------- ! !> Time control to check if it was triggered across all processes. type(tem_timeControl_type), intent(inout) :: me !> Current time to use for the comparison. type(tem_time_type), intent(in) :: now !> Communicator to use for the global reduction. integer, intent(in) :: comm !> Result indicating if the time control has triggered. logical :: hasTriggered ! -------------------------------------------------------------------- ! logical :: local_triggered integer :: iError integer :: sync_status(MPI_STATUS_SIZE) ! -------------------------------------------------------------------- ! local_triggered = tem_timeControl_triggered(me, now) hasTriggered = local_triggered if (me%needs_reduce .and. me%delay_check) then if (me%check_request /= MPI_REQUEST_NULL) then call MPI_WAIT(me%check_request, sync_status, iError) hasTriggered = me%globally_triggered end if end if if (me%needs_reduce .and. (mod(now%iter, me%check_iter) == 0)) then if (me%delay_check) then me%globally_triggered = local_triggered call MPI_IAllreduce(MPI_IN_PLACE, me%globally_triggered, & & 1, MPI_LOGICAL, MPI_LOR, comm, me%check_request, & & iError ) ! has_triggered is set by the check after waiting on the completion ! of the previous allreduce above. else call MPI_Allreduce(local_triggered, me%globally_triggered, 1, & & MPI_LOGICAL, MPI_LOR, comm, iError ) hasTriggered = me%globally_triggered end if end if end function tem_timeControl_globalTriggered