! File: fft35.f90
! Public domain 2004 James Van Buskirk
module mykinds
   implicit none
   integer, parameter :: sp = selected_real_kind(6,30)
   integer, parameter :: dp = selected_real_kind(15,300)
end module mykinds

module dp_mod
   use mykinds, only: wp => dp
   implicit none
   private wp
   contains
include 'fft35.i90'
end module dp_mod

program test
   use mykinds
   use dp_mod
   implicit none
   integer, parameter :: N = 35
   complex(dp) h1(0:N-1)
   complex(dp) h2(0:N-1)
   complex(dp), parameter :: ri(2) = (/(1,0),(0,1)/)
   integer i, j, k, L
   real(dp) pi
   real(dp) err, maxerr

   pi = 4*atan(1.0_dp)
   maxerr = 0
   do i = 0, N-1
      do j = 1, 2
         h2 = 0
         h2(i) = ri(j)
         h1 = (/(sum((/(exp(-2*pi*(0,1)*mod(k*L,N)/N)*h2(L),L=0,N-1)/)),k=0,N-1)/)
         call fft35(h2)
         err = max(maxval(abs(real(h1-h2))),maxval(abs(aimag(h1-h2))))
         write(*,*) i, j, err
         maxerr = max(err, maxerr)
      end do
   end do
   write(*,*)
   write(*,*) maxerr
end program test

