ESMF_ArrayBundleRedistStoreI4 Subroutine

private subroutine ESMF_ArrayBundleRedistStoreI4(srcArrayBundle, dstArrayBundle, routehandle, factor, keywordEnforcer, ignoreUnmatchedIndicesFlag, srcToDstTransposeMap, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_ArrayBundle), intent(in) :: srcArrayBundle
type(ESMF_ArrayBundle), intent(inout) :: dstArrayBundle
type(ESMF_RouteHandle), intent(inout) :: routehandle
integer(kind=ESMF_KIND_I4), intent(in) :: factor
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
logical, intent(in), optional :: ignoreUnmatchedIndicesFlag(:)
integer, intent(in), optional :: srcToDstTransposeMap(:)
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_ArrayBundleRedistStoreI4(srcArrayBundle, dstArrayBundle, &
    routehandle, factor, keywordEnforcer, ignoreUnmatchedIndicesFlag, &
    srcToDstTransposeMap, rc)
!
! !ARGUMENTS:
    type(ESMF_ArrayBundle), intent(in)            :: srcArrayBundle
    type(ESMF_ArrayBundle), intent(inout)         :: dstArrayBundle
    type(ESMF_RouteHandle), intent(inout)         :: routehandle
    integer(ESMF_KIND_I4),  intent(in)            :: factor
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    logical,                intent(in),  optional :: ignoreUnmatchedIndicesFlag(:)
    integer,                intent(in),  optional :: srcToDstTransposeMap(:)
    integer,                intent(out), optional :: rc
!
!EOPI
!------------------------------------------------------------------------------
    integer                       :: localrc      ! local return code
    type(ESMF_Logical), pointer   :: opt_ignoreUnmatched(:)
    type(ESMF_Logical), target    :: def_ignoreUnmatched(1)
    integer                       :: len_ignoreUnmatched
    type(ESMF_InterArray)         :: srcToDstTransposeMapArg

    ! 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_SHORT(ESMF_ArrayBundleGetInit, srcArrayBundle, rc)
    ESMF_INIT_CHECK_DEEP_SHORT(ESMF_ArrayBundleGetInit, dstArrayBundle, rc)
    
    ! Deal with ignoreUnmatchedIndicesFlag
    def_ignoreUnmatched(1) = .false.
    if (present(ignoreUnmatchedIndicesFlag)) then
      if (size(ignoreUnmatchedIndicesFlag)==0) then
        call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
          msg="Size of 'ignoreUnmatchedIndicesFlag' argument must not be zero.",&
          ESMF_CONTEXT, rcToReturn=rc)
        return ! bail out
      endif
      allocate(opt_ignoreUnmatched(size(ignoreUnmatchedIndicesFlag)))
      opt_ignoreUnmatched(:) = ignoreUnmatchedIndicesFlag(:)
    else
      opt_ignoreUnmatched => def_ignoreUnmatched
    endif
    len_ignoreUnmatched = size(opt_ignoreUnmatched)

    ! Deal with srcToDstTransposeMap
    srcToDstTransposeMapArg = ESMF_InterArrayCreate(srcToDstTransposeMap, &
      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_ArrayBundleRedistStore(srcArrayBundle, dstArrayBundle, &
      routehandle, opt_ignoreUnmatched(1), len_ignoreUnmatched, &
      srcToDstTransposeMapArg, ESMF_TYPEKIND_I4, factor, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    
    ! Mark routehandle object as being created
    call ESMF_RouteHandleSetInitCreated(routehandle, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    
    ! garbage collection
    call ESMF_InterArrayDestroy(srcToDstTransposeMapArg, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
    if (present(ignoreUnmatchedIndicesFlag)) then
      deallocate(opt_ignoreUnmatched)
    endif

    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_ArrayBundleRedistStoreI4