subroutine ESMF_GridCompWait(gridcomp, keywordEnforcer, syncflag, &
timeout, timeoutFlag, userRc, rc)
!
! !ARGUMENTS:
type(ESMF_GridComp), intent(inout) :: gridcomp
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
type(ESMF_Sync_Flag), intent(in), optional :: syncflag
integer, intent(in), optional :: timeout
logical, intent(out), optional :: timeoutFlag
integer, intent(out), optional :: userRc
integer, intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[5.3.0] Added argument {\tt timeout}.
! Added argument {\tt timeoutFlag}.
! The new arguments provide access to the fault-tolerant component
! features.
! \end{description}
! \end{itemize}
!
! !DESCRIPTION:
! When executing asynchronously, wait for an {\tt ESMF\_GridComp} to return.
!
! The arguments are:
! \begin{description}
! \item[gridcomp]
! {\tt ESMF\_GridComp} to wait for.
! \item[{[syncflag]}]
! Blocking behavior of this method call. See section \ref{const:sync}
! for a list of valid blocking options. Default option is
! {\tt ESMF\_SYNC\_VASBLOCKING} which blocks PETs and their spawned off threads
! across each VAS but does not synchronize PETs that run in different VASs.
! \item[{[timeout]}]
! The maximum period in seconds the actual component is allowed to execute
! a previously invoked component method before it must communicate back to
! the dual component. If the actual component does not communicate back in
! the specified time, a timeout condition is raised on the dual side (this
! side). The default is 3600, i.e. 1 hour. The {\tt timeout} argument is only
! supported for connected dual components.
! \item[{[timeoutFlag]}]
! Returns {\tt .true.} if the timeout was reached, {\tt .false.} otherwise.
! If {\tt timeoutFlag} was {\em not} provided, a timeout condition will lead
! to a return code of {\tt rc \textbackslash = ESMF\_SUCCESS}. Otherwise the
! return value of {\tt timeoutFlag} is the sole indicator of a timeout
! condition.
! \item[{[userRc]}]
! Return code set by {\tt userRoutine} before returning.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!------------------------------------------------------------------------------
integer :: localrc ! local error status
! initialize return code; assume routine not implemented
if (present(rc)) rc = ESMF_RC_NOT_IMPL
localrc = ESMF_RC_NOT_IMPL
ESMF_INIT_CHECK_DEEP(ESMF_GridCompGetInit,gridcomp,rc)
! check consistency between timeout argument and component argument
if (present(timeout).and. &
.not.ESMF_CompIsDualConnected(gridcomp%compp, rc=localrc)) then
call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
msg="'timeout' argument is only allowed for connected dual components",&
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! call Comp method
call ESMF_CompWait(gridcomp%compp, syncflag=syncflag, timeout=timeout, &
userRc=userRc, rc=localrc)
! conditionally filter out the RC_TIMEOUT and return success
if (present(timeoutFlag)) then
timeoutFlag = .false. ! initialize
if ((localrc==ESMF_RC_TIMEOUT).or.(localrc==ESMC_RC_TIMEOUT)) then
timeoutFlag = .true. ! indicate timeout through flag argument
localrc = ESMF_SUCCESS ! do not raise error condition on user level
endif
endif
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! return successfully
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GridCompWait