subroutine ESMF_FieldRedist(srcField, dstField, routehandle, keywordEnforcer, &
checkflag, rc)
!
! !ARGUMENTS:
type(ESMF_Field), intent(in),optional :: srcField
type(ESMF_Field), intent(inout),optional :: dstField
type(ESMF_RouteHandle), intent(inout) :: routehandle
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
logical, intent(in), optional :: checkflag
integer, intent(out), optional :: rc
!
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
! Execute a precomputed Field redistribution from {\tt srcField} to
! {\tt dstField}.
! Both {\tt srcField} and {\tt dstField} must match the respective Fields
! used during {\tt ESMF\_FieldRedistStore()} in {\em type}, {\em kind}, and
! memory layout of the {\em gridded} dimensions. However, the size, number,
! and index order of {\em ungridded} dimensions may be different. See section
! \ref{RH:Reusability} for a more detailed discussion of RouteHandle
! reusability.
!
! The {\tt srcField} and {\tt dstField} arguments are optional in support of
! the situation where {\tt srcField} and/or {\tt dstField} are not defined on
! all PETs. The {\tt srcField} and {\tt dstField} must be specified on those
! PETs that hold source or destination DEs, respectively, but may be omitted
! on all other PETs. PETs that hold neither source nor destination DEs may
! omit both arguments.
!
! It is erroneous to specify the identical Field object for {\tt srcField} and
! {\tt dstField} arguments.
!
! See {\tt ESMF\_FieldRedistStore()} on how to precompute
! {\tt routehandle}.
!
! This call is {\em collective} across the current VM.
!
! For examples and associated documentation regarding this method see Section
! \ref{sec:field:usage:redist_1dptr}.
!
! \begin{description}
! \item [{[srcField]}]
! {\tt ESMF\_Field} with source data.
! \item [{[dstField]}]
! {\tt ESMF\_Field} with destination data.
! \item [routehandle]
! Handle to the precomputed Route.
! \item [{[checkflag]}]
! If set to {\tt .TRUE.} the input Field pair will be checked for
! consistency with the precomputed operation provided by {\tt routehandle}.
! If set to {\tt .FALSE.} {\em (default)} only a very basic input check
! will be performed, leaving many inconsistencies undetected. Set
! {\tt checkflag} to {\tt .FALSE.} to achieve highest performance.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!------------------------------------------------------------------------------
integer :: localrc ! local return code
! local variables to buffer optional arguments
type(ESMF_Array) :: l_srcArray ! helper variable
type(ESMF_Array) :: l_dstArray ! helper variable
! initialize return code; assume routine not implemented
localrc = ESMF_RC_NOT_IMPL
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check init status of arguments, deal with optional Field args
ESMF_INIT_CHECK_DEEP(ESMF_RouteHandleGetInit, routehandle, rc)
ESMF_INIT_CHECK_DEEP(ESMF_FieldGetInit, srcField, rc)
ESMF_INIT_CHECK_DEEP(ESMF_FieldGetInit, dstField, rc)
if (present(srcField)) then
call ESMF_FieldGet(srcField, array=l_srcArray, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else
call ESMF_ArraySetThisNull(l_srcArray, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(dstField)) then
call ESMF_FieldGet(dstField, array=l_dstArray, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else
call ESMF_ArraySetThisNull(l_dstArray, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
! perform Field redist through internal array
call ESMF_ArrayRedist(srcArray=l_srcArray, dstArray=l_dstArray, &
routehandle=routehandle, checkflag=checkflag, 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_FieldRedist