program aa
  use solver_mod
  use sep
  use cgstep_mod
  use lin_mod
  use weight
  integer :: n1,nrec,n2,i1
  real, pointer :: dat(:),mod(:),temp(:)
  real :: o1,d1

  call sep_init()
  call from_history("o2",o1)
  call from_history("d2",d1)
  call from_history("n2",n1)
  call from_param("nrec",nrec,44)
  
  call linear_init(o1,d1)
  allocate(mod(2),dat(nrec),temp(nrec))
  do i2=1,n1/nrec
    call sreed("in",dat,size(dat)*4)
    call solver(linear_op,cgstep,mod,dat,2,res=temp)
    call cgstep_close()
    temp=1./sqrt(abs(temp)+.0001)
    call solver(linear_op,cgstep,mod,dat,2,wt=temp)
    call cgstep_close()
    dat=-dat 
    i1=linear_op(.false.,.true.,mod,dat)
    call srite("out",dat,size(dat)*4)
  end do

end program

