ESMF_ContainerGarbageGetFL Subroutine

private subroutine ESMF_ContainerGarbageGetFL(container, keywordEnforcer, garbageList, garbageCount, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Container), intent(in) :: container
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_Field), optional, pointer :: garbageList(:)
integer, intent(out), optional :: garbageCount
integer, intent(out), optional :: rc

Calls

proc~~esmf_containergarbagegetfl~~CallsGraph proc~esmf_containergarbagegetfl ESMF_ContainerGarbageGetFL c_esmc_containergarbagecount c_esmc_containergarbagecount proc~esmf_containergarbagegetfl->c_esmc_containergarbagecount c_esmc_containergarbageget c_esmc_containergarbageget proc~esmf_containergarbagegetfl->c_esmc_containergarbageget c_esmc_containergetvfield c_esmc_containergetvfield proc~esmf_containergarbagegetfl->c_esmc_containergetvfield c_esmc_containerreleasevector c_esmc_containerreleasevector proc~esmf_containergarbagegetfl->c_esmc_containerreleasevector proc~esmf_containergetinit ESMF_ContainerGetInit proc~esmf_containergarbagegetfl->proc~esmf_containergetinit proc~esmf_imerr ESMF_IMErr proc~esmf_containergarbagegetfl->proc~esmf_imerr proc~esmf_logfoundallocerror ESMF_LogFoundAllocError proc~esmf_containergarbagegetfl->proc~esmf_logfoundallocerror proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_containergarbagegetfl->proc~esmf_logfounderror proc~esmf_logseterror ESMF_LogSetError proc~esmf_containergarbagegetfl->proc~esmf_logseterror proc~esmf_imerr->proc~esmf_logfounderror proc~esmf_initcheckdeep ESMF_InitCheckDeep proc~esmf_imerr->proc~esmf_initcheckdeep esmf_breakpoint esmf_breakpoint proc~esmf_logfoundallocerror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfoundallocerror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfoundallocerror->proc~esmf_logwrite proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logfounderror->proc~esmf_logwrite proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

proc~~esmf_containergarbagegetfl~~CalledByGraph proc~esmf_containergarbagegetfl ESMF_ContainerGarbageGetFL interface~esmf_containergarbageget~2 ESMF_ContainerGarbageGet interface~esmf_containergarbageget~2->proc~esmf_containergarbagegetfl proc~nuopc_fielddictionarydestroyi NUOPC_FieldDictionaryDestroyI proc~nuopc_fielddictionarydestroyi->interface~esmf_containergarbageget~2 program~esmf_containerutest ESMF_ContainerUTest program~esmf_containerutest->interface~esmf_containergarbageget~2 proc~nuopc_fielddictionaryegestyamli NUOPC_FieldDictionaryEgestYAMLI proc~nuopc_fielddictionaryegestyamli->proc~nuopc_fielddictionarydestroyi proc~nuopc_fielddictionaryremove NUOPC_FieldDictionaryRemove proc~nuopc_fielddictionaryremove->proc~nuopc_fielddictionarydestroyi proc~nuopc_fielddictionaryegesti NUOPC_FieldDictionaryEgestI proc~nuopc_fielddictionaryegesti->proc~nuopc_fielddictionaryegestyamli proc~nuopc_fielddictionarysetupfile NUOPC_FieldDictionarySetupFile proc~nuopc_fielddictionarysetupfile->proc~nuopc_fielddictionaryremove

Source Code

  subroutine ESMF_ContainerGarbageGetFL(container, keywordEnforcer, &
    garbageList, garbageCount, rc)
!
! !ARGUMENTS:
    type(ESMF_Container), intent(in)            :: container
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    type(ESMF_Field),     pointer,     optional :: garbageList(:)
    integer,              intent(out), optional :: garbageCount
    integer,              intent(out), optional :: rc
!         
! !DESCRIPTION:
!   Get items from a {\tt ESMF\_Container} object.
!
!   The arguments are:
!   \begin{description}
!   \item[container]
!     {\tt ESMF\_Container} object to be queried.
!   \item[{[garbageCount]}]
!     Number of objects in {\tt container} garbage.
!   \item[{[garbageList]}]
!     List of objects in {\tt container} garbage. This argument has the pointer
!     attribute. If the argument comes into this call associated the memory 
!     allocation is not changed. Instead the size of the memory allocation is
!     checked against the total number of elements in the container gargbage,
!     and if sufficiently sized the container garbage elements are returned in
!     the provided memory allocation. If the argument comes into this call
!     unassociated, memory will be allocated internally and filled with the
!     container garbage elements. In the latter case the size of the returned
!     {\tt garbageList} will be identical to the number of items in the
!     container garbage - even if that number is zero.
!     In both cases the returned {\tt garbageList} will be associated. It is the
!     responsibility of the caller to deallocate the memory.
!   \item[{[rc]}]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer                       :: localrc      ! local return code
    integer                       :: stat
    integer                       :: i, garbageC
    type(ESMF_Pointer)            :: vector
    type(ESMF_Field)              :: field

    ! Initialize return code; assume failure until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! Check init status of arguments
    ESMF_INIT_CHECK_DEEP_SHORT(ESMF_ContainerGetInit, container, rc)
    
    ! Call into the C++ interface
    call c_ESMC_ContainerGarbageCount(container, garbageC, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return
      
    if (present(garbageList)) then
      if (associated(garbageList)) then
        if (size(garbageList) < garbageC) then
          call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_SIZE, &
            msg="garbageList is too small", &
            ESMF_CONTEXT, rcToReturn=rc)
          return  ! bail out
        endif
      else
        allocate(garbageList(garbageC), stat=stat)
        if (ESMF_LogFoundAllocError(stat, msg= "allocating garbageList", &
          ESMF_CONTEXT, rcToReturn=rc)) return ! bail out
      endif
      

      ! Call into the C++ interface to set up the vector on the C++ side
      call c_ESMC_ContainerGarbageGet(container, vector, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      
      do i=0, garbageC-1 ! C-style indexing, zero-based
        
        ! Call into the C++ interface to get item from vector
        call c_ESMC_ContainerGetVField(container, vector, i, field, localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
        garbageList(i+1) = field ! makes object passing robust

      enddo
      
      ! release vector here
      ! Call into the C++ interface to release the vector on the C++ side
      call c_ESMC_ContainerReleaseVector(container, vector, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      
    endif
    
    if (present(garbageCount)) then
      garbageCount = garbageC
    endif
    
    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS
 
  end subroutine ESMF_ContainerGarbageGetFL