!
!   This program illustrates the effect of deleting allocated memory.
!   The program should never run to completion.
!
      program allocation
          integer, allocatable, target :: p1(:)
          integer, pointer :: p2(:)
 
          print*, "Program entered."
          allocate(p1(10))
          p2 => p1
          call destroy
          p2 = 10
          print*, "Program terminated, logical error not detected."
 
      contains
          subroutine destroy
              deallocate(p1)
          end subroutine
      end
 
