ESMF_XGridGetEle Subroutine

private subroutine ESMF_XGridGetEle(xgrid, localDE, keywordEnforcer, elementCount, exclusiveCount, exclusiveLBound, exclusiveUBound, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_XGrid), intent(in) :: xgrid
integer, intent(in) :: localDE
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: elementCount
integer, intent(out), optional :: exclusiveCount
integer, intent(out), optional :: exclusiveLBound
integer, intent(out), optional :: exclusiveUBound
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_XGridGetEle(xgrid, localDE, keywordEnforcer, &
    elementCount, exclusiveCount, exclusiveLBound, exclusiveUBound, &
    rc) 

!
! !ARGUMENTS:
type(ESMF_XGrid), intent(in)            :: xgrid
integer,          intent(in)            :: localDE
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer,          intent(out), optional :: elementCount
integer,          intent(out), optional :: exclusiveCount
integer,          intent(out), optional :: exclusiveLBound
integer,          intent(out), optional :: exclusiveUBound
integer,          intent(out), optional :: rc 
!
! !DESCRIPTION:
!      Get localDE specific information about XGrid
!
!     The arguments are:
!     \begin{description}
!     \item [xgrid]
!       The {\tt ESMF\_XGrid} object used to retrieve information from.
!     \item [localDE]
!       Local DE for which information is requested. Correct value is an element of
!          [0,..,localDeCount-1]
!     \item [{[elementCount]}]
!          Number of elements in exclusive region per DE
!     \item [{[exclusiveLBound]}]
!          Lower bound of sequence indices in exclusive region per DE
!     \item [{[exclusiveUBound]}]
!          Upper bound of sequence indices in exclusive region per DE
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} only if the {\tt ESMF\_XGrid} 
!           is created.
!     \end{description}
!
!EOPI

    type(ESMF_XGridType), pointer   :: xgtypep
    type(ESMF_DELayout)             :: delayout
    integer                         :: deCount, localrc
    integer, allocatable            :: minIndex(:,:), maxIndex(:,:)

    ! Initialize
    localrc = ESMF_RC_NOT_IMPL

    ! Initialize return code   
    if(present(rc)) rc = ESMF_RC_NOT_IMPL

    ! check init status of input XGrid
    ESMF_INIT_CHECK_DEEP(ESMF_XGridGetInit,xgrid,rc)

    xgtypep => xgrid%xgtypep

    if(present(elementCount)) then
        call ESMF_DistGridGet(xgtypep%distgridM, localDE, elementCount=elementCount, &
            rc=localrc)
        if (ESMF_LogFoundError(localrc, &
            ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return
    endif

    call ESMF_DistGridGet(xgtypep%distgridM, delayout=delayout, &
        rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    call ESMF_DELayoutGet(delayout, deCount=deCount, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

    allocate(minIndex(1, deCount))
    call ESMF_DistGridGet(xgtypep%distgridM, minIndexPDe=minIndex, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    if(present(exclusiveLBound)) then
        exclusiveLBound = minIndex(1,localDE+1)
    endif

    allocate(maxIndex(1, deCount))
    call ESMF_DistGridGet(xgtypep%distgridM, maxIndexPDe=maxIndex, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    if(present(exclusiveUBound)) then
        exclusiveUBound = maxIndex(1,localDE+1)
    endif

    if(present(exclusiveCount)) then
        exclusiveCount = maxIndex(1,localDE+1) - minIndex(1,localDE+1) + 1
    endif

    deallocate(minIndex)
    deallocate(maxIndex)

    if(present(rc)) rc = ESMF_SUCCESS

    end subroutine ESMF_XGridGetEle