Reputation: 45
I am currently trying to run fftw
with OpenMP on Fortran but I am having some problems running any programs.
I believe I have installed/configured fftw correctly:
./configure --enable-openmp --enable-threads
and I seem to have all the correct libraries and files but i cannot get any program to run, I keep getting the error
undefined reference to 'fftw_init_threads'
The code I use is below:
program trial
use omp_lib
implicit none
include "fftw3.f"
integer :: id, nthreads, void
integer :: error
call fftw_init_threads(void)
!$omp parallel private(id)
id = omp_get_thread_num()
write (*,*) 'Hello World from thread', id
!$omp barrier
if ( id == 0 ) then
nthreads = omp_get_num_threads()
write (*,*) 'There are', nthreads, 'threads'
end if
!$omp end parallel
end program
and to run it I do
gfortran trial.f90 -I/home/files/include -L/home/files/lib -lfftw3_omp -lfftw3 -lm -fopenmp
It would be greatly appreciated, if anyone could help me.
Upvotes: 4
Views: 2241
Reputation: 18098
The old FORTRAN interface seems not to support OpenMP... I suggest you take the new Fortran 2003 interface. Please note that fftw_init_threads()
is a function!
You also need to include the ISO_C_binding
module:
program trial
use,intrinsic :: ISO_C_binding
use omp_lib
implicit none
include "fftw3.f03"
integer :: id, nthreads, void
integer :: error
void = fftw_init_threads()
!$omp parallel private(id)
id = omp_get_thread_num()
write (*,*) 'Hello World from thread', id
!$omp barrier
if ( id == 0 ) then
nthreads = omp_get_num_threads()
write (*,*) 'There are', nthreads, 'threads'
end if
!$omp end parallel
end program
Upvotes: 4