tem_timeControl_globalTriggered Function

public function tem_timeControl_globalTriggered(me, now, comm) result(hasTriggered)

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.

Arguments

Type IntentOptional 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.

Return Value logical

Result indicating if the time control has triggered.


Calls

proc~~tem_timecontrol_globaltriggered~~CallsGraph proc~tem_timecontrol_globaltriggered tem_timeControl_globalTriggered mpi_allreduce mpi_allreduce proc~tem_timecontrol_globaltriggered->mpi_allreduce mpi_iallreduce mpi_iallreduce proc~tem_timecontrol_globaltriggered->mpi_iallreduce mpi_wait mpi_wait proc~tem_timecontrol_globaltriggered->mpi_wait proc~tem_timecontrol_triggered tem_timeControl_triggered proc~tem_timecontrol_globaltriggered->proc~tem_timecontrol_triggered proc~tem_time_ge_trigger tem_time_ge_trigger proc~tem_timecontrol_triggered->proc~tem_time_ge_trigger proc~tem_time_gt_trigger tem_time_gt_trigger proc~tem_timecontrol_triggered->proc~tem_time_gt_trigger proc~tem_time_never tem_time_never proc~tem_timecontrol_triggered->proc~tem_time_never

Called by

proc~~tem_timecontrol_globaltriggered~~CalledByGraph proc~tem_timecontrol_globaltriggered tem_timeControl_globalTriggered proc~tem_timecontrol_check tem_timeControl_check proc~tem_timecontrol_check->proc~tem_timecontrol_globaltriggered proc~tem_convergence_check tem_convergence_check proc~tem_convergence_check->proc~tem_timecontrol_check proc~tem_tracking_has_triggered tem_tracking_has_triggered proc~tem_tracking_has_triggered->proc~tem_timecontrol_check proc~tem_tracker tem_tracker proc~tem_tracker->proc~tem_tracking_has_triggered

Source Code

  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