subroutine GetIndexSpaceArb(minIndex, maxIndex, &
arbIndexCount, arbIndexList, distDim, &
dimCount, distDimCount, isDistOut, distDimOut, minIndexOut, maxIndexOut, rc)
!
! !ARGUMENTS:
integer, intent(in), optional :: minIndex(:)
integer, intent(in) :: maxIndex(:)
integer, intent(in) :: arbIndexCount
integer, intent(in) :: arbIndexList(:,:)
integer, intent(in), optional :: distDim(:)
integer, intent(inout) :: dimCount
integer, intent(inout) :: distDimCount
logical, pointer :: isDistOut(:)
integer, pointer :: distDimOut(:)
integer, pointer :: minIndexOut(:)
integer, pointer :: maxIndexOut(:)
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
!
! This internal method creates a single tile, regularly distributed distgrid
! (see Figure \ref{fig:GridDecomps}).
! To specify the distribution, the user passes in an array
! ({\tt regDecomp}) specifying the number of DEs to divide each
! dimension into. The array {\tt decompFlag} indicates how the division into DEs is to
! occur. The default is to divide the range as evenly as possible.
!
! The arguments are:
! \begin{description}
! \item[{[minIndex]}]
! The bottom extent of the grid array. If not given then the value defaults
! to /1,1,1,.../.
! \item[{maxIndex}]
! The upper extent of the grid array.
! \item[{minIndexOut}]
! MinIndex of range, needs to be allocated to dimCount.
! \item[{maxIndexOut}]
! MaxIndex of range, needs to be allocated to dimCount.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
integer :: localrc
integer :: i
! Initialize return code; assume failure until success is certain
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Compute the Grid DimCount and Derivatives ---------------------------------------------------
! dimCount
dimCount=size(maxIndex)
if ((dimCount < 2) .or. (dimCount > 3)) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
msg="- maxIndex size and thus Grid dimCount must be either 2 or 3 when using create shape ", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! Error check index size
if (present(minIndex)) then
if (size(minIndex) /= dimCount) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
msg="- minIndex size must equal grid dimCount", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
endif
! number of distributed dimension, distDimCount, is determined by the second dim of
! arbIndexList
distDimCount = size(arbIndexList,2)
if (distDimCount > dimCount) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
msg="- the second dim of arbIndexList must be equal or less than grid dimension", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! compute distributed dimensions and isDist list
allocate(distDimOut(distDimCount), stat=localrc)
allocate(isDistOut(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating distDimLocal or isDist", &
ESMF_CONTEXT, rcToReturn=rc)) return
isDistOut(:)=.false.
! check distribution info
if (present(distDim)) then
if (size(distDim) /= distDimCount) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
msg="- distDim must match with the second dimension of arbIndexList", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
distDimOut(:)=distDim(:)
do i=1,distDimCount
isDistOut(distDimOut(i))=.true.
enddo
else
do i=1,distDimCount
distDimOut(i)=i
enddo
isDistOut(1:distDimCount)=.true.
endif
! Set default for minIndex
allocate(minIndexOut(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating minIndexOut", &
ESMF_CONTEXT, rcToReturn=rc)) return
if (present(minIndex)) then
minIndexOut(:)=minIndex(:)
else
do i=1,dimCount
minIndexOut(i)=1
enddo
endif
! Set default for maxIndex
allocate(maxIndexOut(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating maxIndexOut", &
ESMF_CONTEXT, rcToReturn=rc)) return
maxIndexOut(:)=maxIndex(:)
! Return successfully
if (present(rc)) rc = ESMF_SUCCESS
end subroutine GetIndexSpaceArb