program test_fact
use sep
use helderiv_mod
use createhelix_mod
implicit none


type(filter)                        ::aaa 
integer,dimension(:),allocatable    ::nd,na,center,gap
real   ,dimension(:),allocatable    ::cube
integer                             ::stat,n1,nf,ix    
real                                ::eps    
real   ,dimension(:,:),allocatable  ::data,modl
logical                             :: F,T, iso
real, allocatable     :: infile(:)
real, allocatable     :: outfile(:)
real                  :: dx, dy, dz, ox, oy, oz
integer               :: nx, ny, nz 
integer               :: ix1, iy1, iz1 
integer               :: ix2, iy2, iz2 
integer               ::     iy, iz 
real                  :: x1, y1, z1 
real                  :: x2, y2, z2 
real                  :: x, y, z 
real                  :: add
call initpar()
  F=.false.
  T=.true.

  ny=1
  if (exist_file("infile"))then
      call from_aux("infile","n1",nz); call from_aux("infile","d1",dz); call from_aux("infile","o1",oz)
      call from_aux("infile","n2",nx); call from_aux("infile","d2",dx); call from_aux("infile","o2",ox)
!     call from_aux("infile","n3",ny); call from_aux("infile","d3",dy); call from_aux("infile","o3",oy)
      allocate(infile(nz*nx*ny)); 
      call sreed("infile", infile, 4*nz*nx*ny)
  else
       call from_history('n1',nz); call from_history('d1',dz);  call from_history('o1',oz); 
       call from_history('n2',nx); call from_history('d2',dx);  call from_history('o2',ox); 
!      call from_history('n3',ny); call from_history('d3',dy);  call from_history('o3',oy); 
       allocate(infile(nz*nx*ny)); 
       call sreed("in", infile, 4*nz*nx*ny)
  endif
  allocate(outfile(nz*nx*ny)); 
  call to_history("n1", nz); call to_history("d1", dz); call to_history("o1", oz)
  call to_history("n2", nx); call to_history("d2", dx); call to_history("o2", ox)
  call to_history("n3", ny); call to_history("d3", dy); call to_history("o3", oy)
  call to_history("label1", 'z'); call to_history("label2", 'x'); call to_history("label3", 'y')
  call to_history("esize", 4);  
  outfile=0.
  call from_param('nf' ,nf ,8); call from_param('eps',eps,0.); eps=0.; nf=8
  call from_param('iso',iso,F); 

!#####Finished init
  call helderiv_init(nz,nx,5,5,nf,eps,iso)
  stat = helderiv_lop(F,F,infile,outfile)
!###start write out
  call srite("out", outfile, 4*nz*nx*ny)
  deallocate(infile,outfile)
end
