! Phase shift modeling and migration.
! adj=0 means model. adj=1 means migrate.
! <in.H phase_shift.x adj= vel=vel.H > out.H

program phase

use sep


implicit none

integer 				:: n1,n2					! ,n3 
real, allocatable, dimension (:,:) 	:: modl(:,:), data(:,:), vel(:,:)
real 					:: o1,d1,o2,d2	 				! ,o3,d3
logical					:: adj

  call initpar()

  call from_history('n1',n1);  call from_history('n2',n2); 		! call from_history('n3',n3)
  call from_history('o1',o1);  call from_history('o2',o2);		! call from_history('o3',o3)
  call from_history('d1',d1);  call from_history('d2',d2);		! call from_history('d3',d3)

  call to_history('n1',n1);  call to_history('d1',d1);  call to_history('o1',o1);
  call to_history('n2',n2);  call to_history('d2',d2);  call to_history('o2',o2);
!  call to_history('n3',n3);  call to_history('d3',d3);  call to_history('o3',o3);

  call from_param('adj',adj,.true.)

  allocate(modl(n1,n2),data(n1,n2),vel(n1,n2))

  data=0.; modl=0; vel=0.

  call sreed( 'vel', vel, n1*n2*4)
  if ( adj ) then
    call sreed( 'in', data, n1*n2*4)
  else
    call sreed( 'in', modl, n1*n2*4)
  end if

  call phsh_init(vel,n1,d1,o1,n2,d2,o2)!,n3,d3,o3)
  stat = phsh_lop( adj, .false., modl, data)

 if ( adj ) then
   call srite( 'out', modl, n1*n2*4)
 else
   call srite( 'out', data, n1*n2*4)
 end if
end program
