subroutine ESMF_GridGetItem2DR8(grid, itemflag, keywordEnforcer, &
staggerloc, localDE, farrayPtr, datacopyflag, &
exclusiveLBound, exclusiveUBound, exclusiveCount, &
computationalLBound, computationalUBound, computationalCount, &
totalLBound, totalUBound, totalCount, rc)
!
! !ARGUMENTS:
type(ESMF_Grid), intent(in) :: grid
type (ESMF_GridItem_Flag), intent(in) :: itemflag
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
type (ESMF_StaggerLoc), intent(in), optional :: staggerloc
integer, intent(in),optional :: localDE
real(ESMF_KIND_R8), pointer :: farrayPtr(:,:)
type(ESMF_DataCopy_Flag), intent(in), optional :: datacopyflag
integer, target, intent(out), optional :: exclusiveLBound(:)
integer, target, intent(out), optional :: exclusiveUBound(:)
integer, target, intent(out), optional :: exclusiveCount(:)
integer, target, intent(out), optional :: computationalLBound(:)
integer, target, intent(out), optional :: computationalUBound(:)
integer, target, intent(out), optional :: computationalCount(:)
integer, target, intent(out), optional :: totalLBound(:)
integer, target, intent(out), optional :: totalUBound(:)
integer, target, intent(out), optional :: totalCount(:)
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! This method gets a Fortran pointer to the piece of memory which holds the
! item data for the stagger locations on the given local DE.
! This is useful, for example, for setting the item values in a Grid, or
! for reading the item values.
!
! The arguments are:
! \begin{description}
! \item[{grid}]
! Grid to get the information from.
! \item[{itemflag}]
! The item to get the information for. Please see Section~\ref{const:griditem} for a
! list of valid items.
! \item[{staggerloc}]
! The stagger location to get the information for.
! Please see Section~\ref{const:staggerloc} for a list
! of predefined stagger locations. If not present, defaults to
! ESMF\_STAGGERLOC\_CENTER.
! \item[{[localDE]}]
! The local DE for which information is requested. {\tt [0,..,localDECount-1]}.
! For {\tt localDECount==1} the {\tt localDE} argument may be omitted,
! in which case it will default to {\tt localDE=0}.
! \item[{farrayPtr}]
! The pointer to the item data.
! \item[{[datacopyflag]}]
! If not specified, default to {\tt ESMF\_DATACOPY\_REFERENCE}, in this case
! farrayPtr is a reference to the data in the Grid item arrays.
! Please see Section~\ref{const:datacopyflag} for further description and a
! list of valid values.
! \item[{[exclusiveLBound]}]
! Upon return this holds the lower bounds of the exclusive region.
! {\tt exclusiveLBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[exclusiveUBound]}]
! Upon return this holds the upper bounds of the exclusive region.
! {\tt exclusiveUBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[exclusiveCount]}]
! Upon return this holds the number of items in the exclusive region per dimension
! (i.e. {\tt exclusiveUBound-exclusiveLBound+1}). {\tt exclusiveCount} must
! be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[computationalLBound]}]
! Upon return this holds the lower bounds of the stagger region.
! {\tt computationalLBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[computationalUBound]}]
! Upon return this holds the upper bounds of the stagger region.
! {\tt exclusiveUBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[computationalCount]}]
! Upon return this holds the number of items in the computational region per dimension
! (i.e. {\tt computationalUBound-computationalLBound+1}). {\tt computationalCount}
! must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[totalLBound]}]
! Upon return this holds the lower bounds of the total region.
! {\tt totalLBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[totalUBound]}]
! Upon return this holds the upper bounds of the total region.
! {\tt totalUBound} must be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[totalCount]}]
! Upon return this holds the number of items in the total region per dimension
! (i.e. {\tt totalUBound-totalLBound+1}). {\tt totalCount} must
! be allocated to be of size equal to the item dimCount.
! Please see Section~\ref{sec:grid:usage:bounds} for a description
! of the regions and their associated bounds and counts.
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
! Local variables
type(ESMF_Array) :: array
integer :: localrc ! local error status
integer :: dimCount
type(ESMF_TypeKind_Flag) :: typekind
type(ESMF_LocalArray) :: localarray
type(ESMF_DataCopy_Flag) :: datacopyflagInt
integer :: coordDimCount(ESMF_MAXDIM)
type(ESMF_InterArray) :: exclusiveLBoundArg ! helper variable
type(ESMF_InterArray) :: exclusiveUBoundArg ! helper variable
type(ESMF_InterArray) :: exclusiveCountArg ! helper variable
type(ESMF_InterArray) :: computationalLBoundArg ! helper variable
type(ESMF_InterArray) :: computationalUBoundArg ! helper variable
type(ESMF_InterArray) :: computationalCountArg ! helper variable
type(ESMF_InterArray) :: totalLBoundArg ! helper variable
type(ESMF_InterArray) :: totalUBoundArg ! helper variable
type(ESMF_InterArray) :: totalCountArg ! helper variable
integer :: tmp_staggerloc
! Initialize return code
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check init status of arguments
ESMF_INIT_CHECK_DEEP(ESMF_GridGetInit, grid, rc)
! Check consistency
call ESMF_GridGet(grid, dimCount=dimCount, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Require farrayPtr dimCount to match grid dimCount
if (dimCount /= 2) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_INCOMP, &
msg="- farrayPtr dimCount does not match requested item dimCount", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! Set Defaults
if (present(datacopyflag)) then
datacopyflagInt=datacopyflag
else
datacopyflagInt=ESMF_DATACOPY_REFERENCE
endif
!! localDE is error checked inside ESMF_ArrayGet() and GetCoordBounds(), so don't do it here !!
! handle staggerloc
if (present(staggerloc)) then
tmp_staggerloc=staggerloc%staggerloc
else
tmp_staggerloc=ESMF_STAGGERLOC_CENTER%staggerloc ! default
endif
! Get the Array
call ESMF_GridGetItemIntoArray(grid, itemflag, staggerloc, array, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_ArrayGet(array, localDE=localDE, localarray=localarray, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_LocalArrayGet(localarray, farrayPtr, &
datacopyflag=datacopyflag, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! process optional arguments
exclusiveLBoundArg=ESMF_InterArrayCreate(exclusiveLBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
exclusiveUBoundArg=ESMF_InterArrayCreate(exclusiveUBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
exclusiveCountArg=ESMF_InterArrayCreate(exclusiveCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
computationalLBoundArg=ESMF_InterArrayCreate(computationalLBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
computationalUBoundArg=ESMF_InterArrayCreate(computationalUBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
computationalCountArg=ESMF_InterArrayCreate(computationalCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
totalLBoundArg=ESMF_InterArrayCreate(totalLBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
totalUBoundArg = ESMF_InterArrayCreate(totalUBound, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
totalCountArg = ESMF_InterArrayCreate(totalCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Call into the C++ interface, which will sort out optional arguments
call c_ESMC_GridGetItemBounds(grid, localDE, tmp_staggerloc, itemflag, &
exclusiveLBoundArg, exclusiveUBoundArg, exclusiveCountArg, &
computationalLBoundArg, computationalUBoundArg, computationalCountArg,&
totalLBoundArg, totalUBoundArg, totalCountArg, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Deallocate interface ints
call ESMF_InterArrayDestroy(exclusiveLBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(exclusiveUBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(exclusiveCountArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(computationalLBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(computationalUBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(computationalCountArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(totalLBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(totalUBoundArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InterArrayDestroy(totalCountArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Return successfully
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GridGetItem2DR8