subroutine ESMF_GridGetPLocalDe(grid, localDE, keywordEnforcer, &
isLBound,isUBound, arbIndexCount, arbIndexList, tile, rc)
!
! !ARGUMENTS:
type(ESMF_Grid), intent(in) :: grid
integer, intent(in) :: localDE
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
logical, intent(out), optional :: isLBound(:)
logical, intent(out), optional :: isUBound(:)
integer, intent(out), optional :: arbIndexCount
integer, target, intent(out), optional :: arbIndexList(:,:)
integer, intent(out), optional :: tile
integer, intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[7.1.0r] Added argument {\tt tile}. This new argument allows the user to
! query the tile within which the localDE is contained.
! \end{description}
! \end{itemize}
!
! !DESCRIPTION:
! This call gets information about a particular local DE in a Grid.
!
!The arguments are:
!\begin{description}
!\item[grid]
! Grid to get the information from.
!\item[localDE]
! The local DE from which to get the information. {\tt [0,..,localDECount-1]}
!\item[{[isLBound]}]
! Upon return, for each dimension this indicates if the DE is a lower bound of the Grid.
! {\tt isLBound} must be allocated to be of size equal to the Grid dimCount.
!\item[{[isUBound]}]
! Upon return, for each dimension this indicates if the DE is an upper bound of the Grid.
! {\tt isUBound} must be allocated to be of size equal to the Grid dimCount.
! \item[{[arbIndexCount]}]
! The number of local cells for an arbitrarily distributed grid
! \item[{[arbIndexList]}]
! The 2D array storing the local cell indices for an arbitrarily distributed grid. The size of the array
! is arbIndexCount * arbDimCount
!\item[{[tile]}]
! The number of the tile in which localDE is contained. Tile numbers range from 1 to TileCount.
!\item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!\end{description}
!
!EOP
integer :: localrc ! local error status
integer :: isLBoundTmp(ESMF_MAXDIM)
integer :: isUBoundTmp(ESMF_MAXDIM)
integer :: dimCount,i
type(ESMF_GridDecompType) :: decompType ! check if arbitrary
type(ESMF_InterArray) :: arbIndexListArg ! Language Interface Helper Var
! Initialize return code
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check init status of arguments
ESMF_INIT_CHECK_DEEP_SHORT(ESMF_GridGetInit, grid, rc)
! Get Grid decomposition type
call ESMF_GridGetDecompType(grid, decompType, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (decompType == ESMF_Grid_NONARBITRARY) then
if (present(arbIndexCount) .or. present(arbIndexList)) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_NOT_IMPL, &
msg="- arbIndexCount, or arbIndexList do not exist for a non-arbitrarily distributed grid", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
else if (decompType == ESMF_Grid_ARBITRARY) then
if (present(isUBound) .or. present(isLBound)) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_NOT_IMPL, &
msg="- isLBound and/or isUBound not supported for arbitrary Grids", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
endif
! Get Grid Dimension
call ESMF_GridGet(grid, dimCount=dimCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Error check input
if (present(isLBound)) then
if (size(isLBound) < dimCount) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_RANK, &
msg="- isLBound must have at least the same size as the grid dimCount", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
endif
if (present(isUBound)) then
if (size(isUBound) < dimCount) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_RANK, &
msg="- isUBound must have at least the same size as the grid dimCount", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
endif
!! Arbitrarily distributed grid local indices
arbIndexListArg = ESMF_InterArrayCreate(farray2D=arbIndexList, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Call into the C++ interface, which will sort out optional arguments
call c_ESMC_GridGetPLocalDe(grid, localDE, &
dimCount, isLBoundTmp, isUBoundTmp, arbIndexCount, arbIndexListArg, &
tile, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Process return values
if (present(isLBound)) then
isLBound=.false.
do i=1,dimCount
if (isLBoundTmp(i) == 1) isLBound(i)=.true.
enddo
endif
if (present(isUBound)) then
isUBound=.false.
do i=1,dimCount
if (isUBoundTmp(i) == 1) isUBound(i)=.true.
enddo
endif
call ESMF_InterArrayDestroy(arbIndexListArg, 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_GridGetPLocalDe