subroutine ESMF_GridGetCoordIntoArray(grid, coordDim, staggerloc, &
array, keywordEnforcer, rc)
!
! !ARGUMENTS:
type(ESMF_Grid), intent(in) :: grid
integer, intent(in) :: coordDim
type (ESMF_StaggerLoc), intent(in), optional :: staggerloc
type(ESMF_Array), intent(out) :: array
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer, intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
! This method allows the user to get access to the ESMF Array holding
! coordinate data at a particular stagger location. This is useful, for example,
! to set the coordinate values. To have an Array to access, the coordinate Arrays
! must have already been allocated, for example by {\tt ESMF\_GridAddCoord} or
! {\tt ESMF\_GridSetCoord}.
!
! The arguments are:
! \begin{description}
! \item[grid]
! The grid to get the coord array from.
! \item[coordDim]
! The coordinate dimension to get the data from (e.g. 1=x).
! \item[{[staggerloc]}]
! The stagger location from which to get the arrays.
! Please see Section~\ref{const:staggerloc} for a list
! of predefined stagger locations. If not present, defaults to ESMF\_STAGGERLOC\_CENTER.
! \item[array]
! An array into which to put the coordinate information.
! \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
type(ESMF_DataCopy_Flag) :: datacopyflag
! 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)
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
! Init datacopyflag
datacopyflag=ESMF_DATACOPY_REFERENCE
! Call C++ Subroutine to do the create
call c_ESMC_gridgetcoordintoarray(grid%this,tmp_staggerloc, coordDim, &
array, datacopyflag, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set Array as created
call ESMF_ArraySetInitCreated(array,localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GridGetCoordIntoArray