subroutine ESMF_ArrayRedistStoreR8TP(srcArray, dstArray, routehandle, &
transposeRoutehandle, factor, keywordEnforcer, srcToDstTransposeMap, &
ignoreUnmatchedIndices, 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
real(ESMF_KIND_R8), intent(in) :: factor
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer, intent(in), optional :: srcToDstTransposeMap(:)
logical, intent(in), optional :: ignoreUnmatchedIndices
integer, intent(inout), optional :: pipelineDepth
integer, intent(out), optional :: rc
!
!EOPI
!------------------------------------------------------------------------------
integer :: localrc ! local return code
type(ESMF_InterArray) :: srcToDstTransposeMapArg ! index helper
type(ESMF_Logical) :: opt_ignoreUnmatched ! helper variable
integer, allocatable :: dstToSrcTransposeMap(:) ! helper variable
integer :: i
! 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)
! Deal with (optional) array arguments
srcToDstTransposeMapArg = ESMF_InterArrayCreate(srcToDstTransposeMap, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! 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_ArrayRedistStore(srcArray, dstArray, routehandle, &
srcToDstTransposeMapArg, ESMF_TYPEKIND_R8, factor, opt_ignoreUnmatched, &
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
! Invert the srcToDstTransposeMap
if (present(srcToDstTransposeMap)) then
allocate(dstToSrcTransposeMap(size(srcToDstTransposeMap)))
do i=1, size(srcToDstTransposeMap)
dstToSrcTransposeMap(srcToDstTransposeMap(i))=i
enddo
! garbage collection
call ESMF_InterArrayDestroy(srcToDstTransposeMapArg, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! create new srcToDstTransposeMapArg
srcToDstTransposeMapArg = ESMF_InterArrayCreate(dstToSrcTransposeMap,&
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
! Call into the C++ interface, which will sort out optional arguments
call c_ESMC_ArrayRedistStore(dstArray, srcArray, transposeRoutehandle, &
srcToDstTransposeMapArg, ESMF_TYPEKIND_I4, factor, opt_ignoreUnmatched, &
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
! cleanup
if (present(srcToDstTransposeMap)) then
deallocate(dstToSrcTransposeMap)
endif
! garbage collection
call ESMF_InterArrayDestroy(srcToDstTransposeMapArg, 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_ArrayRedistStoreR8TP