program OW_shift

use sep 
implicit none

integer						:: iw,rechn,recwn,recxn,ih,ix
real						:: dt,rechd,recwd,recxd,recho,recwo,recxo
complex, allocatable				:: data(:,:)

 call sep_init()
 call sep_begin_prog()

 call from_history("n1",rechn);	call from_history("d1",rechd);	call from_history("o1",recho)
 call from_history("n3",recwn);	call from_history("d3",recwd);	call from_history("o3",recwo)
 call from_history("n2",recxn);	call from_history("d2",recxd);	call from_history("o2",recxo)  

 call to_history("n1",rechn);	call to_history("d1",rechd);	call to_history("o1",recho)
 call to_history("n3",recwn);	call to_history("d3",recwd);	call to_history("o3",recwo)
 call to_history("n2",recxn);	call to_history("d2",recxd);	call to_history("o2",recxo)  
 call to_history("n4",1) ; call to_history("d4",1) ; call to_history("o4",0)
 call to_history("n5",1); call to_history("d5",1); call to_history("o5",1)  
 call to_history("esize",8)

 call from_param("dt",dt)

!--------------------------------------------------
!
!
write(0,*) "ROTATE PHASE TO GET NEGATIVE TIMES"
write(0,*) "=================================="
!-----------------------------------------------------------------------------------------------      
allocate(data(rechn,recxn))

do iw=1,recwn
   data=0.
   call sreed("in",data,rechn*recxn*8)
   do ix=1,recxn
      do ih=1,rechn
         data(ih,ix)=data(ih,ix)*exp(cmplx(0,-2*3.14159*((iw-1)*recwd+recwo)*dt))
      end do
   end do
   call srite("out",data,rechn*recxn*8)
end do

deallocate(data)
call sep_end_prog()
end program OW_shift
