function ESMF_GridCreate2PeriDimI(minIndex, &
countsPerDEDim1,countsPerDeDim2, keywordEnforcer, &
countsPerDEDim3, &
coordSys, coordTypeKind, &
coordDep1, coordDep2, coordDep3, &
gridEdgeLWidth, gridEdgeUWidth, gridAlign, &
gridMemLBound, indexflag, petMap, name, rc)
!
! !RETURN VALUE:
type(ESMF_Grid) :: ESMF_GridCreate2PeriDimI
!
! !ARGUMENTS:
integer, intent(in), optional :: minIndex(:)
integer, intent(in) :: countsPerDEDim1(:)
integer, intent(in) :: countsPerDEDim2(:)
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer, intent(in), optional :: countsPerDEDim3(:)
type(ESMF_CoordSys_Flag), intent(in), optional :: coordSys
type(ESMF_TypeKind_Flag), intent(in), optional :: coordTypeKind
integer, intent(in), optional :: coordDep1(:)
integer, intent(in), optional :: coordDep2(:)
integer, intent(in), optional :: coordDep3(:)
integer, intent(in), optional :: gridEdgeLWidth(:)
integer, intent(in), optional :: gridEdgeUWidth(:)
integer, intent(in), optional :: gridAlign(:)
integer, intent(in), optional :: gridMemLBound(:)
type(ESMF_Index_Flag), intent(in), optional :: indexflag
integer, intent(in), optional :: petMap(:,:,:)
character (len=*), intent(in), optional :: name
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
!
! This method creates a single tile, irregularly distributed grid
! (see Figure \ref{fig:GridDecomps}) with two periodic dimensions.
! To specify the irregular distribution, the user passes in an array
! for each grid dimension, where the length of the array is the number
! of DEs in the dimension. Currently this call only
! supports creating 2D or 3D Grids. A 2D Grid can be specified using the
! countsPerDEDim1 and countsPerDEDim2 arguments. A 3D Grid can
! be specified by also using the optional countsPerDEDim3 argument.
! The index of each array element in these arguments corresponds to
! a DE number. The array value at the index is the number of grid
! cells on the DE in that dimension.
!
! Section \ref{example:2DIrregUniGrid} shows an example
! of using this method to create a 2D Grid with uniformly spaced
! coordinates. This creation method can also be used as the basis for
! grids with rectilinear coordinates or curvilinear coordinates.
!
! The arguments are:
! \begin{description}
! \item[{[minIndex]}]
! Tuple to start the index ranges at. If not present, defaults
! to /1,1,1,.../.
! \item[countsPerDEDim1]
! This arrays specifies the number of cells per DE for index dimension 1
! for the exclusive region (the center stagger location).
! \item[countsPerDEDim2]
! This array specifies the number of cells per DE for index dimension 2
! for the exclusive region (center stagger location).
! \item[{[countsPerDEDim3]}]
! This array specifies the number of cells per DE for index dimension 3
! for the exclusive region (center stagger location).
! If not specified then grid is 2D.
! \item[{[coordSys]}]
! The coordinate system of the grid coordinate data.
! For a full list of options, please see Section~\ref{const:coordsys}.
! If not specified then defaults to ESMF\_COORDSYS\_SPH\_DEG.
! \item[{[coordTypeKind]}]
! The type/kind of the grid coordinate data. All {\em numerical} types
! listed under section~\ref{const:typekind} are supported.
! If not specified then defaults to ESMF\_TYPEKIND\_R8.
! \item[{[coordDep1]}]
! This array specifies the dependence of the first
! coordinate component on the three index dimensions
! described by {\tt coordsPerDEDim1,2,3}. The size of the
! array specifies the number of dimensions of the first
! coordinate component array. The values specify which
! of the index dimensions the corresponding coordinate
! arrays map to. If not present the default is 1,2,...,grid rank.
! \item[{[coordDep2]}]
! This array specifies the dependence of the second
! coordinate component on the three index dimensions
! described by {\tt coordsPerDEDim1,2,3}. The size of the
! array specifies the number of dimensions of the second
! coordinate component array. The values specify which
! of the index dimensions the corresponding coordinate
! arrays map to. If not present the default is 1,2,...,grid rank.
! \item[{[coordDep3]}]
! This array specifies the dependence of the third
! coordinate component on the three index dimensions
! described by {\tt coordsPerDEDim1,2,3}. The size of the
! array specifies the number of dimensions of the third
! coordinate component array. The values specify which
! of the index dimensions the corresponding coordinate
! arrays map to. If not present the default is 1,2,...,grid rank.
! \item[{[gridEdgeLWidth]}]
! The padding around the lower edges of the grid. This padding is between
! the index space corresponding to the cells and the boundary of the
! the exclusive region. This extra space is to contain the extra
! padding for non-center stagger locations, and should be big enough
! to hold any stagger in the grid. If this and gridAlign are not present then
! defaults to 0, 0, ..., 0 (all zeros).
! \item[{[gridEdgeUWidth]}]
! The padding around the upper edges of the grid. This padding is between
! the index space corresponding to the cells and the boundary of the
! the exclusive region. This extra space is to contain the extra
! padding for non-center stagger locations, and should be big enough
! to hold any stagger in the grid. If this and gridAlign are not present then
! defaults to 1, 1, ..., 1 (all ones).
! \item[{[gridAlign]}]
! Specification of how the stagger locations should align with the cell
! index space (can be overridden by the individual staggerAligns). If
! the gridEdgeWidths are not specified than this argument
! implies the gridEdgeWidths. If the gridEdgeWidths are specified and this argument isn't
! then this argument is implied by the gridEdgeWidths.
! If this and the gridEdgeWidths are not specified, then defaults to
! -1, -1, ..., -1 (all negative ones).
! \item[{[gridMemLBound]}]
! Specifies the lower index range of the memory of every DE in this Grid.
! Only used when indexflag is {\tt ESMF\_INDEX\_USER}. May be overridden
! by staggerMemLBound.
! \item[{[indexflag]}]
! Indicates the indexing scheme to be used in the new Grid. Please see
! Section~\ref{const:indexflag} for the list of options. If not present,
! defaults to ESMF\_INDEX\_DELOCAL.
! \item[{[petMap]}]
! \begin{sloppypar}
! Sets the mapping of pets to the created DEs. This 3D
! should be of size size(countsPerDEDim1) x size(countsPerDEDim2) x
! size(countsPerDEDim3). If countsPerDEDim3 isn't present, then
! the last dimension is of size 1.
! \end{sloppypar}
! \item[{[name]}]
! {\tt ESMF\_Grid} name.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
type(ESMF_DistGrid) :: distgrid
integer, pointer :: coordDimCount(:)
integer, pointer :: coordDimMap(:,:)
integer :: localrc
integer :: dimCount
integer, pointer :: gridEdgeLWidthLocal(:)
integer, pointer :: gridEdgeUWidthLocal(:)
integer, pointer :: gridAlignLocal(:)
integer, pointer :: minIndexLocal(:)
integer, pointer :: maxIndexLocal(:)
type(ESMF_DistgridConnection), pointer :: connList(:)
type(ESMF_CoordSys_Flag) :: coordSysLocal
! Initialize return code; assume failure until success is certain
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Get the dimension and extent of the index space
call GetIndexSpaceIrreg(minIndex, &
countsPerDEDim1,countsPerDeDim2, &
countsPerDEDim3, dimCount, minIndexLocal, maxIndexLocal, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Build connection list
call Setup2PeriodicConn(dimCount, minIndexLocal, maxIndexLocal, &
connList, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Create Irregular distgrid and error check associated input and set defaults
distgrid=ESMF_GridCreateDistgridIrreg(dimCount, minIndexLocal, maxIndexLocal, &
countsPerDEDim1,countsPerDeDim2, &
countsPerDEDim3, indexflag, petMap, connList, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (present(name)) then
call ESMF_DistGridSet(distgrid, name="DG-"//trim(name), rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
! Set default widths and alignment and error check
allocate(gridEdgeLWidthLocal(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating gridEdgeLWidthLocal", &
ESMF_CONTEXT, rcToReturn=rc)) return
allocate(gridEdgeUWidthLocal(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating gridEdgeUWidthLocal", &
ESMF_CONTEXT, rcToReturn=rc)) return
allocate(gridAlignLocal(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating gridAlignLocal", &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_GridLUA2PeriDim(dimCount, 1, 2,&
gridEdgeLWidth, gridEdgeUWidth, gridAlign, &
gridEdgeLWidthLocal, gridEdgeUWidthLocal, gridAlignLocal, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Convert coordDeps to coordDimCount and coordDimMap
allocate(coordDimCount(dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating coordDimCount", &
ESMF_CONTEXT, rcToReturn=rc)) return
allocate(coordDimMap(dimCount,dimCount), stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating coordDimMap", &
ESMF_CONTEXT, rcToReturn=rc)) return
call CoordInfoFromCoordDep(dimCount, coordDep1, coordDep2, coordDep3,&
coordDimCount, coordDimMap, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set Default coordSys
if (present(coordSys)) then
coordSysLocal=coordSys
else
coordSysLocal=ESMF_COORDSYS_SPH_DEG
endif
! Create Grid from specification
ESMF_GridCreate2PeriDimI=ESMF_GridCreateFrmDistGrid( &
distgrid, &
coordSys=coordSysLocal, &
coordTypeKind=coordTypeKind, &
coordDimCount=coordDimCount, coordDimMap=coordDimMap, &
gridEdgeLWidth=gridEdgeLWidthLocal, &
gridEdgeUWidth=gridEdgeUWidthLocal, &
gridAlign=gridAlignLocal, &
gridMemLBound=gridMemLBound, &
indexflag=indexflag, &
name=name, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set internal items to be destroyed with grid
Call ESMF_GridSetDestroyDistgrid( ESMF_GridCreate2PeriDimI,destroy=.true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_GridSetDestroyDELayout( ESMF_GridCreate2PeriDimI,destroy=.true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Clean up memory
deallocate(connList)
deallocate(minIndexLocal)
deallocate(maxIndexLocal)
deallocate(coordDimCount)
deallocate(coordDimMap)
deallocate(gridEdgeLWidthLocal)
deallocate(gridEdgeUWidthLocal)
deallocate(gridAlignLocal)
! Return successfully
if (present(rc)) rc = ESMF_SUCCESS
end function ESMF_GridCreate2PeriDimI