ESMF_CompSetVMMaxThreads Subroutine

public subroutine ESMF_CompSetVMMaxThreads(compp, max, pref_intra_process, pref_intra_ssi, pref_inter_ssi, pthreadMinStackSize, forceChildPthreads, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_CompClass), pointer :: compp
integer, intent(in), optional :: max
integer, intent(in), optional :: pref_intra_process
integer, intent(in), optional :: pref_intra_ssi
integer, intent(in), optional :: pref_inter_ssi
integer, intent(in), optional :: pthreadMinStackSize
logical, intent(in), optional :: forceChildPthreads
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_CompSetVMMaxThreads(compp, max, pref_intra_process, &
    pref_intra_ssi, pref_inter_ssi, pthreadMinStackSize, forceChildPthreads, &
    rc)
!
! !ARGUMENTS:
    type(ESMF_CompClass), pointer               :: compp
    integer,              intent(in),  optional :: max
    integer,              intent(in),  optional :: pref_intra_process
    integer,              intent(in),  optional :: pref_intra_ssi
    integer,              intent(in),  optional :: pref_inter_ssi
    integer,              intent(in),  optional :: pthreadMinStackSize
    logical,              intent(in),  optional :: forceChildPthreads
    integer,              intent(out), optional :: rc
!
! !DESCRIPTION:
!     Print VM internals
!
!     The arguments are:
!     \begin{description}
!     \item[compp] 
!          component object
!     \item[{[max]}] 
!          Maximum threading level
!     \item[{[pref\_intra\_process]}] 
!          Intra process communication preference
!     \item[{[pref\_intra\_ssi]}] 
!          Intra SSI communication preference
!     \item[{[pref\_inter\_ssi]}] 
!          Inter process communication preference
!     \item[{[pthreadMinStackSize]}] 
!          Minimum stack size for child PETs executing as Pthreads.
!     \item[{[forceChildPthreads]}] 
!          For {\tt .true.}, force each child PET to execute in its own Pthread.
!          By default, {\tt .false.}, single PETs spawned from a parent PET
!          execute in the same thread (or MPI process) as the parent PET. Multiple
!          child PETs spawned by the same parent PET always execute as their own
!          Pthreads.
!     \item[{[rc]}] 
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer                 :: localrc      ! local return code

    ! Initialize return code; assume not implemented until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Test incoming compp object
    if (.not.associated(compp)) then
      call ESMF_LogSetError(ESMF_RC_OBJ_BAD, &
        msg="Not a valid pointer to ESMF Component object", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    endif

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP(ESMF_CompClassGetInit, compp, rc)

    ! ensure that this is not a child_in_parent_vm plan
    if (compp%contextflag == ESMF_CONTEXT_PARENT_VM) then
      call ESMF_LogSetError(ESMF_RC_NOT_VALID, &
        msg="CompSetVM() calls are incompatible with CHILD_IN_PARENT_VM component", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    endif
    
    ! ensure that this component's VM wasn't already created
    if (compp%vm_info /= ESMF_NULL_POINTER) then
      call ESMF_LogSetError(ESMF_RC_NOT_VALID, &
        msg="CompSetVM() calls cannot be called on components with existing VM", &
        ESMF_CONTEXT, rcToReturn=rc)
      return
    endif

    ! call CompClass method
    call ESMF_VMPlanMaxThreads(compp%vmplan, compp%vm_parent, max, &
      pref_intra_process, pref_intra_ssi, pref_inter_ssi, &
      compp%npetlist, compp%petlist, forceChildPthreads, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! set MinStackSize
    call ESMF_VMPlanSetMinStackSize(compp%vmplan, pthreadMinStackSize, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_CompSetVMMaxThreads