NERSCPowering Scientific Discovery Since 1974

FFTW2 Serial 1D Example Fortran Source

implicit none

      integer n
      parameter (n=16)

      integer fftw_fwd, fftw_bkwd, fftw_estimate
      parameter (fftw_fwd=-1, fftw_bkwd=1, fftw_estimate=0)
      integer*8 plan, iplan

      double complex in, out
      dimension in(N), out(N)

      integer i

c
      print *,"n = ",n
      print *,"input = "
      do i=1,n
         in(i) = (1.0, 0.0)
         print *,in(i)
      enddo

      print *,"fftw_fwd =      ",fftw_fwd
      print *,"fftw_bkwd =     ",fftw_bkwd
      print *,"fftw_estimate = ",fftw_estimate

      call fftw_f77_create_plan(plan,n,fftw_fwd,FFTW_ESTIMATE)
      call fftw_f77_create_plan(iplan,n,fftw_bkwd,FFTW_ESTIMATE)

      print *,"address of fwd plan =   ",plan
      print *,"address of bckwd plan = ",iplan

      call fftw_f77_one(plan,in,out)

      print *, 'output after forward fft:'
      do i=1,n
         print *, out(i)
      enddo

      call fftw_f77_one(iplan,out,in)

      print *, 'after inverse fft:'
      do i=1,n
         print *, in(i)
      enddo

      call fftw_f77_destroy_plan(plan)
      call fftw_f77_destroy_plan(iplan)

      end