subroutine SetupQueue (DebrisHead, DebrisTail)

use UserTypes

implicit none

integer :: MyVariable

type (DEBRIS_PROPS_TYPE), Pointer :: DebrisHead    !Pointer to head of list
type (DEBRIS_PROPS_TYPE), Pointer :: DebrisTail    !Pointer to tail of list
type (DEBRIS_PROPS_TYPE), Pointer :: DebrisPtr

MyVariable = 0 !Initialize

ClearList:  do
   if (.not. associated (DebrisHead)) then         !Check if there is still a list from previous run)
      MyVariable = 1 !IF=TRUE
      exit
    else
      MyVariable = 2 !IF=FALSE
      DebrisPtr => DebrisHead                      !Point to head of list
      DebrisHead => DebrisPtr%Next                 !Point head to next item in list
      deallocate (DebrisPtr)                       !Deallocate the node
      nullify (DebrisPtr)
   endif
enddo ClearList

return
end