module killwave
  use OW_parms_areal
  use OW_type
  use killwave_mod
  use killwave_ns
  implicit none
!!
!infile=in.H verb=2 verb1=1 nfilt=9 nang=40 dip=dip1.H destroy=n outfile=outfile5
!!
  contains

  subroutine ow_kill(infile,indips)
  real, dimension(:)                   :: indips
  double precision, dimension(:)       :: infile
  real                                 :: dips_(img%z%n*img%xm%n),infile_(img%z%n*img%xm%n)
  integer                              :: i,j,k

  do k=1,img%z%n
     do i=1,img%xm%n
        infile_((i-1)*img%z%n+k)=sngl(infile((k-1)*img%xm%n+i))
        dips_((i-1)*img%z%n+k)  =     indips((k-1)*img%xm%n+i)
     end do
  end do

  call dip_params()
  call killA_init(nang,nfilt)
  call killwave_io_init(nang,nfilt) 
  call ns_init()
  call ns_lop(infile_,dips_)
  call killA_close()
  do k=1,img%z%n
     do i=1,img%xm%n
        infile((k-1)*img%xm%n+i)=dble(infile_((i-1)*img%z%n+k))
     end do
  end do

  end subroutine
end module
