ESMF_DELayoutServiceOffer Function

public recursive function ESMF_DELayoutServiceOffer(delayout, keywordEnforcer, de, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_DELayout), intent(in) :: delayout
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(in) :: de
integer, intent(out), optional :: rc

Return Value type(ESMF_ServiceReply_Flag)


Source Code

  recursive function ESMF_DELayoutServiceOffer(delayout, keywordEnforcer, de, rc)
!         
! !RETURN VALUE:
    type(ESMF_ServiceReply_Flag) :: ESMF_DELayoutServiceOffer
!
! !ARGUMENTS:
    type(ESMF_DELayout),  intent(in)            :: delayout
    integer,              intent(in)            :: de
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,              intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!     \begin{sloppypar}
!     Offer service for a DE in the {\tt ESMF\_DELayout} object. This call
!     together with {\tt ESMF\_DELayoutServiceComplete()} provides the
!     synchronization primitives between the PETs of an ESMF multi-threaded VM
!     necessary for dynamic load balancing via a work queue approach.
!
!     The calling PET will either receive {\tt ESMF\_SERVICEREPLY\_ACCEPT} if
!     the service offer has been accepted by DELayout or 
!     {\tt ESMF\_SERVICEREPLY\_DENY} if the service offer was denied. The 
!     service offer paradigm is different from a simple mutex approach in that
!     the DELayout keeps track of the number of service offers issued for each
!     DE by each PET and accepts only one PET's offer for each offer increment.
!     This requires that all PETs use {\tt ESMF\_DELayoutServiceOffer()} in 
!     unison. See section \ref{const:servicereply_flag} for the potential return
!     values.
!     \end{sloppypar}
!
!     The arguments are:
!     \begin{description}
!     \item[delayout] 
!          Specified {\tt ESMF\_DELayout} object.
!     \item[de]
!          DE for which service is offered by the calling PET.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOP
!------------------------------------------------------------------------------
    integer                       :: localrc      ! local return code
    type(ESMF_ServiceReply_Flag)  :: reply

    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL
    
    ! initialize return value in case of early bail out
    ESMF_DELayoutServiceOffer = ESMF_SERVICEREPLY_DENY

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP(ESMF_DELayoutGetInit, delayout, rc)
    
    ! Call into the C++ interface, which will sort out optional arguments
    call c_ESMC_DELayoutServiceOffer(delayout, de, reply, localrc)
    ESMF_DELayoutServiceOffer = reply
!TODO: enable LogErr once it is thread-safe
!    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
!      ESMF_CONTEXT, rcToReturn=rc)) return
 
    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS
      
  end function ESMF_DELayoutServiceOffer