subroutine ESMF_ArraySMMStoreNFTP(srcArray, dstArray, routehandle, &
transposeRoutehandle, keywordEnforcer, ignoreUnmatchedIndices, &
srcTermProcessing, pipelineDepth, rc)
!
! !ARGUMENTS:
type(ESMF_Array), intent(inout) :: srcArray
type(ESMF_Array), intent(inout) :: dstArray
type(ESMF_RouteHandle), intent(inout) :: routehandle
type(ESMF_RouteHandle), intent(inout) :: transposeRoutehandle
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
logical, intent(in), optional :: ignoreUnmatchedIndices
integer, intent(inout), optional :: srcTermProcessing
integer, intent(inout), optional :: pipelineDepth
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! \label{ArraySMMStoreNFTP}
! {\tt ESMF\_ArraySMMStore()} is a collective method across all PETs of the
! current Component. The interface of the method is overloaded, allowing
! -- in principle -- each PET to call into {\tt ESMF\_ArraySMMStore()}
! through a different entry point. Restrictions apply as to which combinations
! are sensible. All other combinations result in ESMF run time errors. The
! complete semantics of the {\tt ESMF\_ArraySMMStore()} method, as provided
! through the separate entry points shown in \ref{ArraySMMStoreTKTP} and
! \ref{ArraySMMStoreNFTP}, is described in the following paragraphs as a whole.
!
! \begin{sloppypar}
! Store an Array sparse matrix multiplication operation from {\tt srcArray}
! to {\tt dstArray}. PETs that specify non-zero matrix coefficients must use
! the <type><kind> overloaded interface and provide the {\tt factorList} and
! {\tt factorIndexList} arguments. Providing {\tt factorList} and
! {\tt factorIndexList} arguments with {\tt size(factorList) = (/0/)} and
! {\tt size(factorIndexList) = (/2,0/)} or {\tt (/4,0/)} indicates that a
! PET does not provide matrix elements. Alternatively, PETs that do not
! provide matrix elements may also call into the overloaded interface
! {\em without} {\tt factorList} and {\tt factorIndexList} arguments.
! \end{sloppypar}
!
! Both {\tt srcArray} and {\tt dstArray} are interpreted as sequentialized
! vectors. The sequence is defined by the order of DistGrid dimensions and
! the order of tiles within the DistGrid or by user-supplied arbitrary
! sequence indices. See section \ref{Array:SparseMatMul} for details on the
! definition of {\em sequence indices}.
!
! Source and destination Arrays, as well as the supplied {\tt factorList}
! argument, may be of different <type><kind>. Further source and
! destination Arrays may differ in shape and number of elements.
!
! It is erroneous to specify the identical Array object for {\tt srcArray} and
! {\tt dstArray} arguments.
!
! The routine returns an {\tt ESMF\_RouteHandle} that can be used to call
! {\tt ESMF\_ArraySMM()} on any pair of Arrays that matches
! {\tt srcArray} and {\tt dstArray} in {\em type}, {\em kind}, and
! memory layout of the {\em distributed} dimensions. However, the size,
! number, and index order of {\em undistributed} dimensions may be different.
! See section \ref{RH:Reusability} for a more detailed discussion of
! RouteHandle reusability.
!
! This call is {\em collective} across the current VM.
!
! \begin{description}
!
! \item [srcArray]
! {\tt ESMF\_Array} with source data. The data in this Array may be
! destroyed by this call.
!
! \item [dstArray]
! {\tt ESMF\_Array} with destination data. The data in this Array may be
! destroyed by this call.
!
! \item [routehandle]
! Handle to the precomputed Route.
!
! \item [{[transposeRoutehandle]}]
! Handle to the transposed matrix operation. The transposed operation goes
! from {\tt dstArray} to {\tt srcArray}.
!
! \item [{[ignoreUnmatchedIndices]}]
! A logical flag that affects the behavior for when sequence indices
! in the sparse matrix are encountered that do not have a match on the
! {\tt srcArray} or {\tt dstArray} side. The default setting is
! {\tt .false.}, indicating that it is an error when such a situation is
! encountered. Setting {\tt ignoreUnmatchedIndices} to {\tt .true.} ignores
! entries with unmatched indices.
!
! \item [{[srcTermProcessing]}]
! The {\tt srcTermProcessing} parameter controls how many source terms,
! located on the same PET and summing into the same destination element,
! are summed into partial sums on the source PET before being transferred
! to the destination PET. A value of 0 indicates that the entire arithmetic
! is done on the destination PET; source elements are neither multiplied
! by their factors nor added into partial sums before being sent off by the
! source PET. A value of 1 indicates that source elements are multiplied
! by their factors on the source side before being sent to the destination
! PET. Larger values of {\tt srcTermProcessing} indicate the maximum number
! of terms in the partial sums on the source side.
!
! Note that partial sums may lead to bit-for-bit differences in the results.
! See section \ref{RH:bfb} for an in-depth discussion of {\em all}
! bit-for-bit reproducibility aspects related to route-based communication
! methods.
!
! \begin{sloppypar}
! The {\tt ESMF\_ArraySMMStore()} method implements an auto-tuning scheme
! for the {\tt srcTermProcessing} parameter. The intent on the
! {\tt srcTermProcessing} argument is "{\tt inout}" in order to
! support both overriding and accessing the auto-tuning parameter.
! If an argument $>= 0$ is specified, it is used for the
! {\tt srcTermProcessing} parameter, and the auto-tuning phase is skipped.
! In this case the {\tt srcTermProcessing} argument is not modified on
! return. If the provided argument is $< 0$, the {\tt srcTermProcessing}
! parameter is determined internally using the auto-tuning scheme. In this
! case the {\tt srcTermProcessing} argument is re-set to the internally
! determined value on return. Auto-tuning is also used if the optional
! {\tt srcTermProcessing} argument is omitted.
! \end{sloppypar}
!
! \item [{[pipelineDepth]}]
! The {\tt pipelineDepth} parameter controls how many messages a PET
! may have outstanding during a sparse matrix exchange. Larger values
! of {\tt pipelineDepth} typically lead to better performance. However,
! on some systems too large a value may lead to performance degradation,
! or runtime errors.
!
! Note that the pipeline depth has no effect on the bit-for-bit
! reproducibility of the results. However, it may affect the performance
! reproducibility of the exchange.
!
! The {\tt ESMF\_ArraySMMStore()} method implements an auto-tuning scheme
! for the {\tt pipelineDepth} parameter. The intent on the
! {\tt pipelineDepth} argument is "{\tt inout}" in order to
! support both overriding and accessing the auto-tuning parameter.
! If an argument $>= 0$ is specified, it is used for the
! {\tt pipelineDepth} parameter, and the auto-tuning phase is skipped.
! In this case the {\tt pipelineDepth} argument is not modified on
! return. If the provided argument is $< 0$, the {\tt pipelineDepth}
! parameter is determined internally using the auto-tuning scheme. In this
! case the {\tt pipelineDepth} argument is re-set to the internally
! determined value on return. Auto-tuning is also used if the optional
! {\tt pipelineDepth} argument is omitted.
!
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!------------------------------------------------------------------------------
integer :: localrc ! local return code
type(ESMF_Logical) :: opt_ignoreUnmatched ! 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
ESMF_INIT_CHECK_DEEP(ESMF_ArrayGetInit, srcArray, rc)
ESMF_INIT_CHECK_DEEP(ESMF_ArrayGetInit, dstArray, rc)
! Set default flags
opt_ignoreUnmatched = ESMF_FALSE
if (present(ignoreUnmatchedIndices)) opt_ignoreUnmatched = ignoreUnmatchedIndices
! Call into the C++ interface, which will sort out optional arguments
call c_ESMC_ArraySMMStoreNF(srcArray, dstArray, routehandle, &
opt_ignoreUnmatched, srcTermProcessing, pipelineDepth, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Mark routehandle object as being created
call ESMF_RouteHandleSetInitCreated(routehandle, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Compute the transposeRoutehandle
! Call into the C++ interface, which will sort out optional arguments
call c_ESMC_ArraySMMStoreNF(dstArray, srcArray, transposeRoutehandle, &
opt_ignoreUnmatched, srcTermProcessing, pipelineDepth, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Mark transposeRoutehandle object as being created
call ESMF_RouteHandleSetInitCreated(transposeRoutehandle, 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_ArraySMMStoreNFTP