GetIndexSpaceReg Subroutine

private subroutine GetIndexSpaceReg(minIndex, maxIndex, dimCount, minIndexOut, maxIndexOut, rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: minIndex(:)
integer, intent(in) :: maxIndex(:)
integer, intent(inout) :: dimCount
integer, pointer :: minIndexOut(:)
integer, pointer :: maxIndexOut(:)
integer, intent(out), optional :: rc

Source Code

      subroutine GetIndexSpaceReg(minIndex, maxIndex, &
          dimCount, minIndexOut, maxIndexOut,  rc)

!
! !ARGUMENTS:
       integer,               intent(in),  optional :: minIndex(:)
       integer,               intent(in)            :: maxIndex(:)
       integer,               intent(inout)         :: dimCount
       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


    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


    ! 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 GetIndexSpaceReg