module OW_parms_renorm

use sep
use OW_type

implicit none

character*12,public, save                                   :: sufx
character*6,public, save                                    :: extrap,cgsolv
character*7,public, save                                    :: imgcon
logical,public, save				:: adj,dot,icwind,impulse,dso,resmig,light,moddso,smooth,imgnorm
logical,public, save				:: zweight,resmig_lin,areal,timeshift,l1norm,envelope,born2,renorm
type (axis) ,public, save				:: kxm, kym, h, w, xd, yd, xm, ym, z, shx, shy, kz, kshx, kshy,th
type (dat_grid)	 ,public, save			:: rec, sou
type (mod_grid)	 ,public, save			:: img
type (velo) ,public, save				:: v
integer	 ,public, save				:: windx,windh,windz,frame,tc1,tc2,freq
integer	 ,public, save				:: nref,iwb,nz,nzmin,nzmax,nitercg
integer	 ,public, save				:: tapertrx,padtracesx,nsecdimx
integer	 ,public, save				:: tapertry,padtracesy,nsecdimy
integer	 ,public, save				:: isp,nwbott,node,niter,n_wind,n_sampt,nxfilt,nh0,dipop
real ,public, save					:: ymin,ymax,zmin,zmax,pi,dwbott,osecdim,dsecdim,thresh
real, public, save					:: vsal,rho,maxang,damp,beta,xv_min,xv_max,yv_min,yv_max
real, public, save					:: trick,expdso,zwgt
!integer, public, save				:: nxw, nah,nax
real, public, save					:: dah,oah,dax,oax
type(axis), public, save               		          :: axk, ayk, azk
real, public, save                               		:: axkd, aykd, azkd, axko, ayko, azko
integer, public, save                            		:: axkn, aykn, azkn
! using lloyd
logical,public, save				:: lloyd,perc_start
real,public,save					:: min_r_pct,min_s_pct,slow_own
integer,public,save					:: niter_over
!! DIPS
!logical,public,save					:: dipflt
!!logical,public,save				:: dips,verb,v3d,dave
!!character*20,public,save				:: method
!!integer,public,save				:: maxsize,nl_iter,niter_dip,nwind
!!real, public,save					:: eps,eps2
real, public, save                                          :: epscg
!
integer, public, save                                       :: serg_na, serg_niter, dip_niter
real, public, save                                          :: serg_eps1, serg_eps2, serg_epsh, dip_eps
contains

subroutine owparam()

real						:: wbott,dd1,dd2,od1,od2,dv1,dv2,ov1,ov2
real						:: deltat, d_sampt,dzref,ozref
integer						:: iw,nt, i, m,nd1,nd2,nv1,nv2,nzref,jh
logical						:: inversion,migration

 call from_param("dipflt",dipflt,.false.)
 if (dipflt) call from_param('frame',frame,50)
call from_param("epscg",epscg,1.)
call from_param("nitercg",nitercg,50)
call from_param("cgsolv",cgsolv,"      ")
call from_param("oxk", axko, 0.); call from_param("dxk", axkd, 1.); call from_param("nxk", axkn, 99999 )
call from_param("oyk", ayko, 0.); call from_param("dyk", aykd, 1.); call from_param("nyk", aykn, 99999 )
call from_param("ozk", azko, 0.); call from_param("dzk", azkd, 1.); call from_param("nzk", azkn, 99999 )
if (axkn.ne.99999 .or. azkn.ne.99999) then
   axk%d=axkd
   ayk%d=aykd
   azk%d=azkd
   axk%n=axkn
   ayk%n=aykn
   azk%n=azkn
   axk%o=axko
   ayk%o=ayko
   azk%o=azko
end if
!!!!!!!!!!!!!!!!!!
!
! for smoothing along dips
!  call from_param("smooth",smooth,.true.)
!  if (smooth) then
!     call from_param("serg_na"    ,serg_na,8)
!     call from_param("serg_epsh"  ,serg_epsh,0.01)
!  ! Set smoothing factors for SERGEY
!     call from_param("serg_niter",serg_niter,30) 
!     call from_param("serg_eps1",serg_eps1,0.002)
!     call from_param("serg_eps2",serg_eps2,0.002)
!     call from_param("dip_niter",dip_niter,100)
!     call from_param("dip_eps",dip_eps,10.)
!!!!!!!!!!!!!!!!!!!
!  end if
call from_param("sufx",sufx,"_")
call from_param("dot",dot,.false.)
call from_param("adj",adj,.true.)
call from_param("inversion",inversion,.false.)
call from_param("dso",dso,.false.)
call from_param("windx",windx,11)
call from_param("windh",windh,3)
call from_param("windz",windz,11)
call from_param("extrapolator",extrap,"ffd")
call from_param("zwgt",zwgt,99999.)
if (extrap(1:3).eq."ffd") then
   call from_param("dipop",dipop,45)
   call from_param("trick",trick,0.14)
end if
if (dso) then
   call from_param("maxvchg",maxvchg,0.15)
   call from_param("moddso",moddso,.false.)
   call from_param("expdso",expdso,1.)
   call from_param("envelope",envelope,.false.)
   if (envelope) then
     call from_param("tc1",tc1,25)
     call from_param("tc2",tc2,5)
     call from_param("freq",freq,0)
   end if
end if
call from_param("born2",born2,.false.)
call from_param("renorm",renorm,.false.)
if (moddso) call from_param("beta",beta,0.1)
call from_param("migration",migration,.false.)
call from_param("areal",areal,.true.)
call from_param("timeshift",timeshift,.false.)
call from_param("imgcon",imgcon,"imgprim")
call from_param("imgnorm",imgnorm,.false.)
if (imgcon(1:7).ne."imgprim".or.imgcon(1:7).ne."imgmult") then
   write(0,*) imgcon
!   call seperr("Which img.condition to use? It must be imgprim(primaries) or imgmult(multiples)")
end if
if (inversion) then
   if (not(dso)) then
      call from_param("resmig",resmig,.false.)
      call from_param("rho",rho,1.)
      if (not(resmig)) then
         call from_param("resmig_lin",resmig_lin,.false.)
         if (not(resmig_lin)) then
            call seperr("How to compute the perturbed image?")
         end if
      end if
   end if
end if
call from_param("zmin",zmin,0.)
call from_param("zmax",zmax,(v%z%n-1)*v%z%d+v%z%o)
call from_param("node",node,9999)
call from_param("niter",niter,5) ; write(0,*) "****** NITER  = ", niter
call from_param("nxfilt",nxfilt,99999)
call from_param("nyfilt",nyfilt,99999)
call from_param("wbott",wbott,0.)
call from_param("traces_in_taper_x",tapertrx,0)
call from_param("traces_in_taper_y",tapertry,0)
call from_param("padtraces_x",padtracesx,tapertr)
call from_param("padtraces_y",padtracesy,tapertr)
call from_param("maxang",maxang,89.)
call from_param("damp", damp, 25000.)
call from_param("zweight",zweight,.false.)

 call from_aux("rec","n1",rec%hx%n);	call from_aux("rec","d1",rec%hx%d);call from_aux("rec","o1",rec%hx%o)
 call from_aux("rec","n2",rec%hy%n);	call from_aux("rec","d2",rec%hy%d);call from_aux("rec","o2",rec%hy%o)
 call from_aux("rec","n3",rec%w%n);	call from_aux("rec","d3",rec%w%d);call from_aux("rec","o3",rec%w%o)
 call from_aux("rec","n4",rec%xd%n);call from_aux("rec","d4",rec%xd%d);call from_aux("rec","o4",rec%xd%o)  

 call from_aux("sou","n1",sou%hx%n);	call from_aux("sou","d1",sou%hx%d);	call from_aux("sou","o1",sou%hx%o)
 call from_aux("sou","n2",sou%hy%n);	call from_aux("sou","d2",sou%hy%d);	call from_aux("sou","o2",sou%hy%o)
 call from_aux("sou","n3",sou%w%n);	call from_aux("sou","d3",sou%w%d);	call from_aux("sou","o3",sou%w%o)
 call from_aux("sou","n4",sou%xd%n);	call from_aux("sou","d4",sou%xd%d);	call from_aux("sou","o4",sou%xd%o)  

 call from_aux("vel","n1",v%xm%n);	call from_aux("vel","d1",v%xm%d);	call from_aux("vel","o1",v%xm%o)
 call from_aux("vel","n2",v%ym%n);	call from_aux("vel","d2",v%ym%d);	call from_aux("vel","o2",v%ym%o)
 call from_aux("vel","n3",v%z%n);	call from_aux("vel","d3",v%z%d);	call from_aux("vel","o3",v%z%o)

if (extrap(1:4).eq."pspi") then
   call from_param("nrefvel",nref,1) 
   call from_param("lloyd",lloyd,.false.)
   if (lloyd) then
       call from_param("min_region_pct",min_r_pct,1.)
       min_r_pct=min_r_pct/100.
       !MINIMUM ALLOWED DEVIATION BETWEEN CENTROIDS
       call from_param("min_slow_dev",min_s_pct,9.)
       min_s_pct=min_s_pct/100.
       call from_param("perc_start",perc_start,.false.)
       call from_param("vel_own",slow_own,-1.)
       slow_own=1./slow_own
       !NUMBER OF ITERATIONS
       call from_param("niter_lloyd",niter_over,-1)
   else
       call from_param("vsal",vsal)
   end if
end if
 if (sou%w%n .ne. rec%w%n) then
    call seperr("# source freq. .ne. # receiver freq.")
 end if
 if (sou%w%d .ne. rec%w%d) then
    call seperr("source freq.interval .ne. receiver freq.interval")
 end if
 if (sou%w%o .ne. rec%w%o) then
    call seperr("source freq.origin .ne. receiver freq.origin")
 end if
 if (sou%xd%n .ne. rec%xd%n) then
    call seperr("# areal sources. .ne. # areal receivers")
 end if
 if (sou%hx%n .ne. rec%hx%n) then
    call seperr("# source xlines. .ne. # receiver xlines")
 end if
 if (sou%hy%n .ne. rec%hy%n) then
    call seperr("# source ilines. .ne. # receiver ilines")
 end if


call from_param("icwind",icwind,.false.)
if (icwind) then
   call from_param("deltat",deltat,0.048)
   call from_param("dt",d_sampt,0.008)
   n_sampt=1;
   do while (rec%w%n > n_sampt)
      n_sampt=n_sampt*2
   end do 
   n_sampt=n_sampt*2
   n_wind=int(deltat/d_sampt)
   if (mod(n_wind,2) == 0) n_wind=n_wind+1
   deltat=n_wind*d_sampt 
end if

if (areal) then
   img%xm%n=rec%h%n+2*padtracesx+2*tapertrx
   img%xm%d=rec%h%d
   img%xm%o=rec%h%o-(padtracesx+tapertrx)*img%xm%d
   img%ym%n=rec%hy%n+2*padtracesy+2*tapertry
   img%ym%d=rec%hy%d
   img%ym%o=rec%hy%o-(padtracesy+tapertry)*img%ym%d
!else
!   img%xm%n=rec%h%n+2*padtraces+2*tapertr+(rec%xd%n-1)*rec%xd%d/rec%h%d
!   img%xm%d=rec%h%d
!   img%xm%o=rec%h%o-(padtraces+tapertr)*img%xm%d+rec%xd%o
end if

if (inversion) then
   call from_param("xv_min",xv_min,img%xm%o+10*img%xm%d)
   call from_param("xv_max",xv_max,(img%xm%n-1)*img%xm%d+img%xm%o-10*img%xm%d)
   call from_param("yv_min",yv_min,img%ym%o+10*img%ym%d)
   call from_param("yv_max",yv_max,(img%ym%n-1)*img%ym%d+img%ym%o-10*img%ym%d)
end if

  if (img%xm%o < v%xm%o ) call seperr("Min.x-image space < Min.x-velocity")
  if ((img%xm%n-1)*img%xm%d+img%xm%o > v%xm%o+(v%xm%n-1)*v%xm%d ) call seperr("Max.x-image space > Max.x-velocity")
  if (img%ym%o < v%ym%o ) call seperr("Min.y-image space < Min.y-velocity")
  if ((img%ym%n-1)*img%ym%d+img%ym%o > v%ym%o+(v%ym%n-1)*v%ym%d ) call seperr("Max.y-image space > Max.y-velocity")
 
 if (zmin < v%z%o ) call seperr("Min.z-image < Min.z-velocity")
 if (zmax > v%z%o+(v%z%n-1)*v%z%d ) call seperr("Max.z-image > Max.z-velocity")

 nz=int((zmax-zmin)/v%z%d)+1.5
 nzmax=int((zmax-v%z%o)/v%z%d)+1.5
 nzmin=int((zmin-v%z%o)/v%z%d)+1.5
 img%z%o=zmin

 write(0,*) "*************************"
 write(0,*) "* ",nz,nzmax,nzmin," *"
 write(0,*) "*************************"


  call from_param("wbott",wbott,0.)

  if(.not.adj.or.dot.or.inversion.or.migration) then
    call from_param("nhx",img%shx%n,1)
    call from_param("jhx",jhx,1)
    call from_param("dhx",img%shx%d,jhx*img%xm%d)
    call from_param("ohx",img%shx%o,-int(img%shx%n/2)*img%shx%d)

    call from_param("nhy",img%shy%n,1)
    call from_param("jhy",jhy,1)
    call from_param("dhy",img%shy%d,jhy*img%ym%d)
    call from_param("ohy",img%shy%o,-int(img%shy%n/2)*img%shy%d)
  end if
!----------------------------------------------
!
! Migration output
!
if (.not.adj.or.dot.or.inversion.or.migration) then
  img%z%n=nz
  img%z%o=zmin
  img%z%d=v%z%d
end if

if (migration) then
   call to_history("n1",img%xm%n,"bkgimg"); call to_history("d1",img%xm%d,"bkgimg"); call to_history("o1",img%xm%o,"bkgimg")  
   call to_history("n2",img%shx%n,"bkgimg") ; call to_history("d2",img%shx%d,"bkgimg") ; call to_history("o2",img%shx%o,"bkgimg")
   call to_history("n3",img%ym%n,"bkgimg"); call to_history("d3",img%ym%d,"bkgimg"); call to_history("o3",img%ym%o,"bkgimg")  
   call to_history("n4",img%shy%n,"bkgimg") ; call to_history("d4",img%shy%d,"bkgimg") ; call to_history("o4",img%shy%o,"bkgimg")
   call to_history("n5",nz,"bkgimg") ; call to_history("d5",img%z%d,"bkgimg") ; call to_history("o5",zmin,"bkgimg")
   call to_history("esize",4,"bkgimg")
end if

if (not(inversion)) then
   if (adj) then
      call to_history("n1",img%xm%n); call to_history("d1",img%xm%d); call to_history("o1",img%xm%o)  
      call to_history("n2",img%ym%n); call to_history("d2",img%ym%d); call to_history("o2",img%ym%o)  
      call to_history("n3",nz) ; call to_history("d3",img%z%d) ; call to_history("o3",zmin)
      call to_history("n4",1) ; call to_history("d4",1.) ; call to_history("o4",0.)
      call to_history("esize",4)
   else
      call to_history("n1",img%xm%n); call to_history("d1",img%xm%d); call to_history("o1",img%xm%o)  
      call to_history("n2",img%shx%n) ; call to_history("d2",img%shx%d) ; call to_history("o2",img%shx%o)
      call to_history("n3",img%ym%n); call to_history("d3",img%ym%d); call to_history("o3",img%ym%o)  
      call to_history("n4",img%shy%n) ; call to_history("d4",img%shy%d) ; call to_history("o4",img%shy%o)
      call to_history("n5",nz) ; call to_history("d5",img%z%d) ; call to_history("o5",zmin)
      call to_history("esize",4)
   end if
else
   if (exist_file("grad")) then
    call to_history("n1",img%xm%n,"grad"); call to_history("d1",img%xm%d,"grad"); call to_history("o1",img%xm%o,"grad")  
    call to_history("n2",img%ym%n,"grad"); call to_history("d2",img%ym%d,"grad"); call to_history("o2",img%ym%o,"grad")  
    call to_history("n3",nz,"grad") ; call to_history("d3",img%z%d,"grad") ; call to_history("o3",zmin,"grad")
    call to_history("n4",1,"grad") ; call to_history("d4",1.,"grad") ; call to_history("o4",0.,"grad")
    call to_history("esize",4,"grad")
   end if
   if (exist_file("Velout")) then
    call to_history("n1",img%xm%n,"Velout"); call to_history("d1",img%xm%d,"Velout"); call to_history("o1",img%xm%o,"Velout")  
    call to_history("n2",img%ym%n,"Velout"); call to_history("d2",img%ym%d,"Velout"); call to_history("o2",img%ym%o,"Velout")  
    call to_history("n3",nz,"Velout") ; call to_history("d3",img%z%d,"Velout") ; call to_history("o3",zmin,"Velout")
    call to_history("n4",1,"Velout") ; call to_history("d4",1.,"Velout") ; call to_history("o4",0.,"Velout")
    call to_history("esize",4,"Velout")
   end if
   if (exist_file("Dimage")) then
    call to_history("n1",img%xm%n,"Dimage"); call to_history("d1",img%xm%d,"Dimage"); call to_history("o1",img%xm%o,"Dimage")  
    call to_history("n2",img%shx%n,"Dimage") ; call to_history("d2",img%shx%d,"Dimage") ; call to_history("o2",img%shx%o,"Dimage")
    call to_history("n3",img%ym%n,"Dimage"); call to_history("d3",img%ym%d,"Dimage"); call to_history("o3",img%ym%o,"Dimage")  
    call to_history("n4",img%shy%n,"Dimage") ; call to_history("d4",img%shy%d,"Dimage") ; call to_history("o4",img%shy%o,"Dimage")
    call to_history("n5",nz,"Dimage") ; call to_history("d5",img%z%d,"Dimage") ; call to_history("o5",zmin,"Dimage")
    call to_history("esize",4,"Dimage")
   end if
   if (exist_file("bkgimg")) then
    call to_history("n1",img%xm%n,"bkgimg"); call to_history("d1",img%xm%d,"bkgimg"); call to_history("o1",img%xm%o,"bkgimg")  
    call to_history("n2",img%shx%n,"bkgimg") ; call to_history("d2",img%shx%d,"bkgimg") ; call to_history("o2",img%shx%o,"bkgimg")
    call to_history("n3",img%ym%n,"bkgimg"); call to_history("d3",img%ym%d,"bkgimg"); call to_history("o3",img%ym%o,"bkgimg")  
    call to_history("n4",img%shy%n,"bkgimg") ; call to_history("d4",img%shy%d,"bkgimg") ; call to_history("o4",img%shy%o,"bkgimg")
    call to_history("n5",nz,"bkgimg") ; call to_history("d5",img%z%d,"bkgimg") ; call to_history("o5",zmin,"bkgimg")
    call to_history("esize",4,"bkgimg")
   end if
end if

  wbott=int(wbott/v%z%d)*v%z%d
  nwbott=int(wbott/v%z%d)+1
  dwbott=wbott/2.

pi=4*atan(1.)
!isp=abs(floor(rec%h%o/rec%h%d)) + 1

!--------------------------------------------------
! Depth vector
!
allocate(img%z%all(img%z%n))
do iwb = 1,nz
   img%z%all(iwb) = img%z%o + (iwb - 1) * v%z%d
end do

!--------------------------------------------------
! Wavenumber vectors
!
! BUG DANGER: img%z%n ==> nz !!!!!
!
!
!if (resmig.or.resmig_lin) then
!!!kz
   kz%n = img%z%n
   allocate(kz%all(kz%n))
   kz%all=0.
   if(kz%n/=1) then
     m = kz%n/2
     do i=1,m+1
        kz%all(i)=i-1
     end do
     do i=m+2,kz%n
        kz%all(i)=i-kz%n-1
     end do
   else
     kz%all=0. !! make sure k=0 if n=1
   end if
   kz%all = kz%all / (kz%n*img%z%d)      !! 1/length
   kz%all = 2 * PI * kz%all     !! radians
   kz%d = kz%all(2)-kz%all(1)
!!! kshx
   kshx%n = img%shx%n
   allocate(kshx%all(kshx%n))
   kshx%all=0.
   if(kshx%n/=1) then
     m = kshx%n/2
     do i=1,m+1
        kshx%all(i)=i-1
     end do
     do i=m+2,kshx%n
        kshx%all(i)=i-kshx%n-1
     end do
   else
     kshx%all=0. !! make sure k=0 if n=1
   end if
   kshx%all = kshx%all / (kshx%n*img%shx%d)      !! 1/length
   kshx%all = 2 * PI * kshx%all     !! radians
   if (kshx%n/=1) then
      kshx%d = kshx%all(2)-kshx%all(1)
   else
      kshx%d=1/img%shx%d
   end if
!!! kshy
   kshy%n = img%shy%n
   allocate(kshy%all(kshy%n))
   kshy%all=0.
   if(kshy%n/=1) then
     m = kshy%n/2
     do i=1,m+1
        kshy%all(i)=i-1
     end do
     do i=m+2,kshy%n
        kshy%all(i)=i-kshy%n-1
     end do
   else
     kshy%all=0. !! make sure k=0 if n=1
   end if
   kshy%all = kshy%all / (kshy%n*img%shy%d)      !! 1/length
   kshy%all = 2 * PI * kshy%all     !! radians
   if (kshy%n/=1) then
      kshy%d = kshy%all(2)-kshy%all(1)
   else
      kshy%d=1/img%shy%d
   end if

!!! kxm
kxm%n = rec%h%n+2*(tapertrx+padtracesx)
kxm%d = 1./(kxm%n*rec%hx%d)
kxm%o = 1./(2*rec%hx%d)-kxm%d
allocate(kxm%all(kxm%n))
do i=1,kxm%n
   kxm%all(i) = mod(kxm%o+(i-1)*kxm%d,1./rec%hx%d)-kxm%o
end do
kxm%all = 2*pi * kxm%all

!!! kym
kym%n = rec%hy%n+2*(tapertry+padtracesy)
kym%d = 1./(kym%n*rec%hy%d)
kym%o = 1./(2*rec%hy%d)-kym%d
allocate(kym%all(kym%n))
do i=1,kym%n
   kym%all(i) = mod(kym%o+(i-1)*kym%d,1./rec%hy%d)-kym%o
end do
kym%all = 2*pi * kym%all

nsecdimx=img%shx%n
dsecdimx=img%shx%d
osecdimx=img%shx%o

nsecdimy=img%shy%n
dsecdimy=img%shy%d
osecdimy=img%shy%o

!--------------------------------------------------
! Frequency vector
! no zero frequency component
!
rec%w%o   = 2*pi * rec%w%o
rec%w%d   = 2*pi * rec%w%d
allocate(rec%w%all(rec%w%n))
do iwb = 1,rec%w%n
   rec%w%all(iwb) = rec%w%o + (iwb - 1) * rec%w%d
end do

!----------------------------------------------------
write(0,*) "   PARM   "
write(0,*) "=========="
write(0,*) "PARAMETERS"
write(0,*) "=========="
write(0,*) //
if (extrapolator.eq."pspi") write(0,*) "no.ref.velocities   = ",nref
write(0,*) "min.x-coord         = ",xmin
write(0,*) "max.x-coord         = ",xmax
write(0,*) "min.y-coord         = ",ymin
write(0,*) "max.y-coord         = ",ymax
write(0,*) "min.depth           = ",zmin
write(0,*) "max.depth           = ",zmax
write(0,*) "traces in taper  x   = ",tapertrx
write(0,*) "padded traces    x   = ",padtracesx
write(0,*) "traces in taper  y   = ",tapertry
write(0,*) "padded traces    y   = ",padtracesy
write(0,*) //
write(0,*) "============"
write(0,*) "HEADER WORDS"
write(0,*) "============"
write(0,*) //
write(0,*) "SHOTS"
write(0,*) "====="
write(0,*) "number of recv  x = ", rec%hx%n
write(0,*) "recv spacing    x = ", rec%hx%d
write(0,*) "min.recv offset x = ", rec%hx%o
write(0,*) "number of recv  y = ", rec%hy%n
write(0,*) "recv spacing    y = ", rec%hy%d
write(0,*) "min.recv offset y = ", rec%hy%o
write(0,*) "number of freq  = ", rec%w%n
write(0,*) "freq spacing    = ", rec%w%d/(2*pi)
write(0,*) "minimum freq    = ", rec%w%o/(2*pi)
write(0,*) "number of shots = ", rec%xd%n
write(0,*) //
write(0,*) "SOURCE FUNCTION"
write(0,*) "==============="
write(0,*) "no.of traces  x  = ", sou%hx%n
write(0,*) "trace spacing x  = ", sou%hx%d
write(0,*) "min.trace   x    = ", sou%hx%o
write(0,*) "no.of traces  y  = ", sou%hy%n
write(0,*) "trace spacing y  = ", sou%hy%d
write(0,*) "min.trace   y    = ", sou%hy%o
write(0,*) "number of freq  = ", sou%w%n
write(0,*) "freq spacing    = ", sou%w%d/(2*pi)
write(0,*) "minimum freq    = ", sou%w%o/(2*pi)
write(0,*) "no.of s.fnct    = ", sou%xd%n
write(0,*) //
write(0,*) "VELOCITY MODEL"
write(0,*) "=============="
write(0,*) "no.of traces  x  = ", v%xm%n
write(0,*) "trace spacing x  = ", v%xm%d
write(0,*) "min.trace-x   x  = ", v%xm%o
write(0,*) "no.of traces  y  = ", v%ym%n
write(0,*) "trace spacing y  = ", v%ym%d
write(0,*) "min.trace-x   y  = ", v%ym%o
write(0,*) "no.depth samples= ", v%z%n
write(0,*) "depth interval  = ", v%z%d
write(0,*) "minimum depth   = ", v%z%o
write(0,*) //
write(0,*) "IMAGE SPACE"
write(0,*) "==========="
write(0,*) "no.of traces  x  = ", img%xm%n
write(0,*) "trace spacing x  = ", img%xm%d
write(0,*) "min.trace-x   x  = ", img%xm%o
write(0,*) "no.of traces  y  = ", img%ym%n
write(0,*) "trace spacing y  = ", img%ym%d
write(0,*) "min.trace-x   y  = ", img%ym%o
write(0,*) "no.of offsets  x  = ", img%shx%n
write(0,*) "offset spacing x  = ", img%shx%d
write(0,*) "offset origin  x  = ", img%shx%o
write(0,*) "no.of offsets  y  = ", img%shy%n
write(0,*) "offset spacing y  = ", img%shy%d
write(0,*) "offset origin  y  = ", img%shy%o
write(0,*) "no.depth samples= ", img%z%n
write(0,*) "depth interval  = ", v%z%d
write(0,*) "minimum depth   = ", img%z%o

write(0,*) //
write(0,*) "WAVENUMBER"
write(0,*) "=========="
write(0,*) "no.wavenumbers x = ", kxm%n
write(0,*) "waveno.spacing x = ", kxm%d
write(0,*) "waveno.origin  x = ", kxm%o
write(0,*) "no.wavenumbers y = ", kym%n
write(0,*) "waveno.spacing y = ", kym%d
write(0,*) "waveno.origin  y = ", kym%o
write(0,*) //

write(0,*) "*****************************************************"
end if
end subroutine

end module
