在fortran上使用openmp和fftw
我目前正试图在Fortran上用OpenMP运行在fortran上使用openmp和fftw,fortran,openmp,fftw,Fortran,Openmp,Fftw,我目前正试图在Fortran上用OpenMP运行fftw,但在运行任何程序时遇到一些问题 我相信我已正确安装/配置fftw: ./configure --enable-openmp --enable-threads 我似乎有所有正确的库和文件,但我无法运行任何程序,我不断得到错误 undefined reference to 'fftw_init_threads' 我使用的代码如下: program trial use omp_lib implicit none
fftw
,但在运行任何程序时遇到一些问题
我相信我已正确安装/配置fftw:
./configure --enable-openmp --enable-threads
我似乎有所有正确的库和文件,但我无法运行任何程序,我不断得到错误
undefined reference to 'fftw_init_threads'
我使用的代码如下:
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
而要运行它,我需要
gfortran trial.f90 -I/home/files/include -L/home/files/lib -lfftw3_omp -lfftw3 -lm -fopenmp
如果有人能帮助我,我将不胜感激 旧的FORTRAN接口似乎不支持OpenMP。。。我建议您使用新的Fortran 2003接口。请注意,
fftw\u init\u threads()
是一个函数
您还需要包括ISO_C_绑定
模块:
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
正在工作,非常感谢!!如果可以的话,我还有一个问题,那就是它说我现在应该调用void fftw\u plan\u和n个reads(int n个reads);这是否意味着我只是说call fftw_plan_nthreads(int,nthreads),其中int和nthreads都被定义为整数值,非常感谢,不,
int nthreads
来自C语言,它只是意味着nthreads
是一个整数。只需拨打一个电话:用n个字母(int(n个字母,c个字母))呼叫fftw\u plan\u
(请参阅底部)。太棒了,非常感谢。让我的生活轻松了一百万倍