program OWvelan

use sep 
use OW_sembl1

implicit none

integer						:: ixs
integer						:: zn,gn,xn,rn,nwind
real						:: zd,gd,xd,rd,zo,go,xo,ro
real, allocatable					:: cig(:,:),semblance(:,:)

 call sep_init()
 call sep_begin_prog()

 call from_history("n1",zn) ; call from_history("d1",zd) ; call from_history("o1",zo)
 call from_history("n2",gn) ; call from_history("d2",gd) ; call from_history("o2",go)
 call from_history("n3",xn) ; call from_history("d3",xd) ; call from_history("o3",xo)

 call from_param ("nwind",nwind,81)
 call from_param ("ngamma",rn,81)
 call from_param ("dgamma",rd,0.015)
 call from_param ("ogamma",ro,0.4)

 call to_history("n1",zn) ; call to_history("d1",zd) ; call to_history("o1",zo)
 call to_history("n2",rn) ; call to_history("d2",rd) ; call to_history("o2",ro)
 call to_history("n3",xn) ; call to_history("d3",xd) ; call to_history("o3",xo)
 

!----------------------------------------------------
! Memory Allocation
!
allocate(cig(zn,gn))
allocate(semblance(zn,rn))

!--------------------------------------------------
!
!
write(0,*) "COMPUTES SEMBLANCE"
write(0,*) "=================="

open(unit=2,file='lixo')

call owsembl_init(zn,gn,xn,rn,zd,gd,xd,rd,zo,go,xo,ro,nwind)
do ixs=1,xn
   cig=0;semblance=0
   call sreed("in",cig,4*zn*gn)
   call owsembl1(cig,semblance)
   call srite("out",semblance,4*zn*rn)
   if (mod(ixs,10).eq.1) write(0,*) "Computed cig # ",ixs," OUT OF ",xn
end do

deallocate(cig,semblance)
close(2)
call sep_end_prog()
end program OWvelan
