ESMF_CplCompSetServices Subroutine

public recursive subroutine ESMF_CplCompSetServices(cplcomp, userRoutine, keywordEnforcer, userRc, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_CplComp), intent(inout) :: cplcomp
private subroutine userRoutine(cplcomp, rc)
Arguments
Type IntentOptional Attributes Name
type(ESMF_CplComp) :: cplcomp
integer, intent(out) :: rc
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: userRc
integer, intent(out), optional :: rc

Source Code

  recursive subroutine ESMF_CplCompSetServices(cplcomp, userRoutine, &
     keywordEnforcer, userRc, rc)
!
! !ARGUMENTS:
    type(ESMF_CplComp), intent(inout)         :: cplcomp
    interface
      subroutine userRoutine(cplcomp, rc)
        use ESMF_CompMod
        implicit none
        type(ESMF_CplComp)         :: cplcomp  ! must not be optional
        integer, intent(out)       :: rc       ! must not be optional
      end subroutine
    end interface
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,            intent(out), optional :: userRc
    integer,            intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
! \label{CplComp:SetServices}
! Call into user provided {\tt userRoutine} which is responsible
! for setting Component's Initialize(), Run(), and Finalize() services.
!
! The arguments are:
! \begin{description}
! \item[cplcomp]
!   Coupler Component.
! \item[userRoutine]
!  The Component writer must supply a subroutine with the exact interface
!  shown above for the {\tt userRoutine} argument. Arguments in {\tt userRoutine}
!  must not be declared as optional, and the types, intent and order must match.
!   Prior to Fortran-2008, the subroutine must be either a module scope procedure,
!   or an external procedure that has a matching interface block specified for it.
!   An internal procedure which is contained within another procedure must not be used.
!   From Fortran-2008 onwards, an internal procedure contained within either a main program
!   or a module procedure may be used.  If the internal procedure is contained within a
!   module procedure, it is subject to initialization requirements.  See: \ref{sec:AppDriverIntProc}
!
!  \begin{sloppypar}
!  The {\tt userRoutine}, when called by the framework, must make successive calls to
!  {\tt ESMF\_CplCompSetEntryPoint()} to preset callback routines for standard
!  Component Initialize(), Run(), and Finalize() methods.
!  \end{sloppypar}
! \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
    integer :: localUserRc

    ! 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_CplCompGetInit, cplcomp, rc)

    call c_ESMC_SetServices(cplcomp, userRoutine, localUserRc, localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! now indicate that this Component has a VM associated
    cplcomp%compp%compStatus%vmIsPresent = .true.

    ! pass back userRc
    if (present(userRc)) userRc = localUserRc

    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS
  end subroutine ESMF_CplCompSetServices