I am learning how to call fftw from fortran. My test program is the following:
Program Single_Thread_FFTW
use, intrinsic :: iso_c_binding
implicit none
integer, parameter :: N=16
type (c_ptr) :: plan_forward
integer :: k
complex (kind=8) :: in(N), out(N)
include 'fftw3.f03'
in=(/(sin(3.14159d0*k),k=1,N)/)
print *,in
plan_forward=fftw_plan_dft_1d(N,in,out,FFTW_FORWARD,FFTW_ESTIMATE)
call fftw_execute_dft(plan_forward,in,out)
print *,out
call fftw_destroy_plan(plan_forward)
End Program Single_Thread_FFTW
The first confusion came about because the fftw website suggests all the fftw call should be prefaced with the letter d, as in 'dfftw_plan_dft_1d'. However none of the functions/subroutines in fftw3.f03 (located in /usr/include) have the d prefix. When I try to compile/link with either
gfortran -I/usr/include -o example1 example1.f90 or
gfortran -I/usr/include -L/usr/lib/x86_64-linux-gnu -o example1 example1.f90
the linker throws the errors:
example1.f90:(.text+0xf3): undefined reference to `fftw_plan_dft_1d'
example1.f90:(.text+0x114): undefined reference to `fftw_execute_dft'
example1.f90:(.text+0x1cc): undefined reference to `fftw_destroy_plan'
even though the libraries are in /usr/lib/x86_64-linux-gnu. A separate point is that I would like to lear how to declare double precision complex variables without using the (kind=8) modifier. My compiler (gfortran) doesnt know about double complex.