I try to use the fftw3 library in Fortran. I get an undefined reference error when calling the planner subroutine.
As I am neither proficient in Fortran nor C, all I tried so far was re-reading the documentation and hoping to stumble over the solution. Neither the reading nor the stumbling were successful so far.
I work on ubuntu and use gfortran.
gfortran dft.f90 fftw3.f90 dft_variable.f90 -L/usr/lib/x86_64-linux-gnu -libfftw3
dft.f90 is the main program.
fftw3.f90 contains the fftw3 constants. They are found here: https://people.sc.fsu.edu/~jburkardt/f_src/fftw3/fftw3.f90
dft_variables.f90 contains some variables and parameters I need for the dft code.
Program simple_dft
use fftw3
use dft_variable
Implicit none
real, dimension(:),allocatable :: fft_in, fft_out, rho
integer*8 :: plan,
integer :: num_points
{...} ! Here happens the calculation of the initial density rho
allocate(fft_in(num_pts),fft_out(num_pts),rho(num_pts))
fft_in = rho
call dfftw_plan_dft_r2c_1d(plan,num_pts,fft_in,fft_out,FFTW_ESTIMATE)
call dfftw_execute_dft(plan, fft_in,fft_out)
End Program simple_dft
I expected the planner to create the plan necessary to calculate the FFT of rho.
_variable.f90 -L/usr/lib/x86_64-linux-gnu-libfftw3
/tmp/cc8nDlG7.o: In function `MAIN__':
dft.f90:(.text+0x3aeb): undefined reference to `dfftw_plan_dft_r2c_1d_'
dft.f90:(.text+0x3b0d): undefined reference to `dfftw_execute_dft_'
collect2: error: ld returned 1 exit status