f_esmf_locstreamcollectgarbage Subroutine

subroutine f_esmf_locstreamcollectgarbage(locstream, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_LocStream) :: locstream
integer, intent(out) :: rc

Source Code

  subroutine f_esmf_locstreamcollectgarbage(locstream, rc)
#undef  ESMF_METHOD
#define ESMF_METHOD "f_esmf_fieldcollectgarbage()"
    use ESMF_UtilTypesMod
    use ESMF_BaseMod
    use ESMF_LogErrMod
    use ESMF_LocStreamMod

    implicit none

    type(ESMF_LocStream) :: locstream
    integer, intent(out) :: rc     
  
    integer :: localrc              
  
    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    rc = ESMF_RC_NOT_IMPL
  
    !print *, "collecting LocStream garbage"
  
    ! destruct internal data allocations
    call ESMF_LocStreamDestruct(locstream%lstypep, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
      ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! deallocate actual LocStreamType allocation      
    if (associated(locstream%lstypep)) then
      deallocate(locstream%lstypep, stat=localrc)
      if (ESMF_LogFoundAllocError(localrc, msg="Deallocating LocStream", &
        ESMF_CONTEXT, rcToReturn=rc)) return
    endif
    nullify(locstream%lstypep)

    ! return successfully  
    rc = ESMF_SUCCESS

  end subroutine f_esmf_locstreamcollectgarbage