program main
  use base_wavelt_mod
  use base_fftwdr_mod
  use base_ioutil_mod
  use base_struct_mod
  use sep
  implicit none
  complex  , dimension(:,:), pointer :: data
  integer*8, dimension(:)  , pointer :: plan_1dt
  integer*8 :: plan
  type(axis)                         :: at, ax
  real                               :: fm, t 
  integer                            :: it, ix, stat

  call initpar()

  fm = 20
  at%n = 4000; at%o = 0.; at%d = 0.002 
  ax%n = 101 ; ax%o = 0 ; ax%d = 10
  allocate(data(at%n,ax%n))
  allocate(plan_1dt(ax%n))

  do ix=1, ax%n
  do it=1, at%n
     t = at%o + (it-1)*at%d
     data(it,ix) =  wavelet(t-0.1, fm, 1)
  end do
  end do

  write(0,*)"data", minval(cabs(data)), maxval(cabs(data))


!  call sfftw_plan_dft_1d(plan_1dt(1), at%n, data, data, FFTW_FORWARD, FFTW_ESTIMATE)
!  call sfftw_execute(plan_1dt(1))
!  call sfftw_destroy_plan(plan_1dt(1))

  do ix=1, ax%n
     stat = sfftw_dft_1dt_init(plan_1dt(ix), data(:,ix), at%n, +1)
  end do
  do ix=1, ax%n
     stat = sfftw_dft_1dt_oper(plan_1dt(ix))
  end do

!  call sfftw_execute(plan_1dt(1))

!  call sfftw_destroy_plan(plan_1dt(1))

  call to_history("n1", at%n); call to_history("d1", at%d); call to_history("o1", at%o)
  call to_history("n2", ax%n); call to_history("d2", ax%d); call to_history("o2", ax%o)
  call to_history("esize", 8)
  call sep_write(data)

end program
