subroutine ESMF_GridAddCoordNoValues(grid, keywordEnforcer, staggerloc, &
staggerEdgeLWidth, staggerEdgeUWidth, staggerAlign, &
staggerLBound,rc)
!
! !ARGUMENTS:
type(ESMF_Grid), intent(in) :: grid
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
type (ESMF_StaggerLoc), intent(in), optional :: staggerloc
integer, intent(in), optional :: staggerEdgeLWidth(:)
integer, intent(in), optional :: staggerEdgeUWidth(:)
integer, intent(in), optional :: staggerAlign(:)
integer, intent(in), optional :: staggerLBound(:)
integer, intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!
! When a Grid is created all of its potential stagger locations can hold coordinate
! data, but none of them have storage allocated. This call allocates coordinate
! storage (creates internal ESMF\_Arrays and associated memory) for a particular
! stagger location. Note that this
! call doesn't assign any values to the storage, it only allocates it. The
! remaining options {\tt staggerEdgeLWidth}, etc. allow the user to adjust the
! padding on the coordinate arrays.
!
! The arguments are:
! \begin{description}
! \item[grid]
! Grid to allocate coordinate storage in.
! \item[{[staggerloc]}]
! The stagger location to add. Please see Section~\ref{const:staggerloc} for a list
! of predefined stagger locations. If not present, defaults to ESMF\_STAGGERLOC\_CENTER.
! \item[{[staggerEdgeLWidth]}]
! This array should be the same dimCount as the grid. It specifies the lower corner of the stagger
! region with respect to the lower corner of the exclusive region.
! \item[{[staggerEdgeUWidth]}]
! This array should be the same dimCount as the grid. It specifies the upper corner of the stagger
! region with respect to the upper corner of the exclusive region.
! \item[{[staggerAlign]}]
! This array is of size grid dimCount.
! For this stagger location, it specifies which element
! has the same index value as the center. For example,
! for a 2D cell with corner stagger it specifies which
! of the 4 corners has the same index as the center.
! If this is set and either staggerEdgeUWidth or staggerEdgeLWidth is not,
! this determines the default array padding for a stagger.
! If not set, then this defaults to all negative. (e.g.
! The most negative part of the stagger in a cell is aligned with the
! center and the padding is all on the positive side.)
! \item[{[staggerLBound]}]
! Specifies the lower index range of the memory of every DE in this staggerloc in this Grid.
! Only used when Grid indexflag is {\tt ESMF\_INDEX\_USER}.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
integer :: tmp_staggerloc
integer :: localrc ! local error status
type(ESMF_GridDecompType) :: decompType ! Arbitrary or not
type(ESMF_InterArray) :: staggerEdgeLWidthArg ! Language Interface Helper Var
type(ESMF_InterArray) :: staggerEdgeUWidthArg ! Language Interface Helper Var
type(ESMF_InterArray) :: staggerAlignArg ! Language Interface Helper Var
type(ESMF_InterArray) :: staggerLBoundArg ! Language Interface Helper Var
! Initialize return code; assume failure until success is certain
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
! handle staggerloc
if (present(staggerloc)) then
if ((decompType == ESMF_GRID_ARBITRARY) .and. &
(staggerloc /= ESMF_STAGGERLOC_CENTER)) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="- staggerloc has to be ESMF_STAGGERLOC_CENTER for arbitrary grid", &
ESMF_CONTEXT, rcToReturn=rc)
return
else
tmp_staggerloc=staggerloc%staggerloc
endif
else
tmp_staggerloc=ESMF_STAGGERLOC_CENTER%staggerloc
endif
if (decompType == ESMF_GRID_ARBITRARY) then
if (present(staggerEdgeLWidth) .or. present(staggerEdgeUWidth) .or. &
present(staggerAlign)) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="- stagger arguments should not be set for arbitrary grid", &
ESMF_CONTEXT, rcToReturn=rc)
return
else
! Call C++ Subroutine to do the create
call c_ESMC_gridaddcoordarb(grid%this,tmp_staggerloc, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
else
!! staggerEdgeLWidth
staggerEdgeLWidthArg = ESMF_InterArrayCreate(staggerEdgeLWidth, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
!! staggerEdgeUWidth
staggerEdgeUWidthArg = ESMF_InterArrayCreate(staggerEdgeUWidth, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
!! staggerAlign
staggerAlignArg = ESMF_InterArrayCreate(staggerAlign, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
!! staggerMemLBound
staggerLBoundArg = ESMF_InterArrayCreate(staggerLBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Call C++ Subroutine to do the create
call c_ESMC_gridaddcoord(grid%this,tmp_staggerloc, &
staggerEdgeLWidthArg, staggerEdgeUWidthArg, staggerAlignArg, staggerLBoundArg, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Deallocate helper variables
call ESMF_InterArrayDestroy(staggerEdgeLWidthArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(staggerEdgeUWidthArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(staggerAlignArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(staggerLBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GridAddCoordNoValues