ESMF_ArrayBundleGetList Subroutine

private subroutine ESMF_ArrayBundleGetList(arraybundle, arrayName, arrayList, keywordEnforcer, itemorderflag, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_ArrayBundle), intent(in) :: arraybundle
character(len=*), intent(in) :: arrayName
type(ESMF_Array), intent(out) :: arrayList(:)
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_ItemOrder_Flag), intent(in), optional :: itemorderflag
integer, intent(out), optional :: rc

Source Code

    subroutine ESMF_ArrayBundleGetList(arraybundle, arrayName, arrayList, &
      keywordEnforcer, itemorderflag, rc)
!
! !ARGUMENTS:
    type(ESMF_ArrayBundle),    intent(in)            :: arraybundle
    character(len=*),          intent(in)            :: arrayName
    type(ESMF_Array),          intent(out)           :: arrayList(:)
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    type(ESMF_ItemOrder_Flag), intent(in),  optional :: itemorderflag
    integer,                   intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \item\apiStatusModifiedSinceVersion{5.2.0r}
! \begin{description}
! \item[6.1.0] Added argument {\tt itemorderflag}.
!              The new argument gives the user control over the order in which
!              the items are returned.
! \end{description}
! \end{itemize}
!
! !DESCRIPTION:
!   Get the list of Arrays from ArrayBundle that match {\tt arrayName}.
!
!   \begin{description}
!   \item [arraybundle]
!     {\tt ESMF\_ArrayBundle} to be queried.
!   \item [arrayName]
!     Specified name.
!   \item [arrayList]
!     List of Arrays in {\tt arraybundle} that match {\tt arrayName}. The
!     argument must be allocated to be at least of size {\tt arrayCount}
!     returned for this {\tt arrayName}.
!   \item[{[itemorderflag]}]
!     Specifies the order of the returned items in the {\tt arrayList}.
!     The default is {\tt ESMF\_ITEMORDER\_ABC}.
!     See \ref{const:itemorderflag} for a full list of options.
!   \item [{[rc]}]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOP
!------------------------------------------------------------------------------
    integer                       :: localrc      ! local return code
    integer                       :: opt_arrayCount         ! helper variable
    type(ESMF_Pointer), pointer   :: opt_arrayPtrList(:)    ! helper variable
    integer                       :: len_arrayPtrList       ! helper variable
    integer                       :: i                      ! helper variable
    type(ESMF_ItemOrder_Flag)     :: itemorderflagArg

    ! 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, arraybundle, rc)
    
    ! Deal with optional itemorderflag argument
    itemorderflagArg = ESMF_ITEMORDER_ABC ! default
    if (present(itemorderflag)) &
      itemorderflagArg = itemorderflag
    
    ! Prepare local variables
    len_arrayPtrList = size(arrayList)
    allocate(opt_arrayPtrList(len_arrayPtrList))

    ! Call into the C++ interface layer
    call c_ESMC_ArrayBundleGetList(arraybundle, trim(arrayName), &
      opt_arrayCount, opt_arrayPtrList, len_arrayPtrList, itemorderflagArg, &
      localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! Set init code for deep C++ objects
    do i=1, min(size(arrayList), opt_arrayCount)
      call ESMF_ArraySetThis(arrayList(i), opt_arrayPtrList(i), rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      call ESMF_ArraySetInitCreated(arrayList(i), rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    enddo
    
    ! Garbage collection
    deallocate(opt_arrayPtrList)

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS
  
  end subroutine ESMF_ArrayBundleGetList