主题:Fortran调用FFTW的问题
最近要用到fftw,按照fftw的说明文档写了下面这个简单的测试程序:
---------------------------------------------------------------------------
program fftwtest
integer*8,parameter::N=2,M=2
double precision in
dimension in(0:M,0:N)
double complex out
dimension out(0:M/2, 0:N)
integer*8 plan,i,j
open(10,file='in.txt')
do i=0,M
do j=0,N
read(10,*) i,j,in(i,j)
end do
end do
close(10)
open(15,file='in_1.txt')
do i=0,M
do j=0,N
write(15,*) i,j,in(i,j)
end do
end do
close(15)
call dfftw_plan_dft_r2c_2d(plan,M,N,in,out,FFTW_FORWARD,FFTW_ESTIMATE)
call dfftw_execute_dft_r2c(plan, in, out)
call dfftw_destroy_plan(plan)
open(20,file='out.txt')
do i=0,M/2
do j=0,N
write(20,*) i,j,out(i,j)
end do
end do
close(20)
print*, 'Program finished'
end program
——————————————————————————————————————————
我用pgi编译如下:
pgf90 -fast -o fftw fftwtest1.f90 -L/opt/fftw/lib -lfftw3_f77 -lm
编译的时候只是说我在读in(i,j)的时候有两个警告,其他没有问题。编译后的程序能够顺利运行,但是不管输入什么数据,结果都是0,不知道是哪里出了问题?请各位兄弟帮小弟看看。
以下是我的输入文件:
0 0 1
0 1 2
0 2 4
1 0 4
1 1 5
1 2 6
2 0 7
2 1 9
2 2 3
下面是运算结果:
0 0
(0.000000000000000,0.000000000000000)
0 1
(0.000000000000000,0.000000000000000)
0 2
(0.000000000000000,0.000000000000000)
1 0
(0.000000000000000,0.000000000000000)
1 1
(0.000000000000000,0.000000000000000)
1 2
(0.000000000000000,0.000000000000000)
---------------------------------------------------------------------------
program fftwtest
integer*8,parameter::N=2,M=2
double precision in
dimension in(0:M,0:N)
double complex out
dimension out(0:M/2, 0:N)
integer*8 plan,i,j
open(10,file='in.txt')
do i=0,M
do j=0,N
read(10,*) i,j,in(i,j)
end do
end do
close(10)
open(15,file='in_1.txt')
do i=0,M
do j=0,N
write(15,*) i,j,in(i,j)
end do
end do
close(15)
call dfftw_plan_dft_r2c_2d(plan,M,N,in,out,FFTW_FORWARD,FFTW_ESTIMATE)
call dfftw_execute_dft_r2c(plan, in, out)
call dfftw_destroy_plan(plan)
open(20,file='out.txt')
do i=0,M/2
do j=0,N
write(20,*) i,j,out(i,j)
end do
end do
close(20)
print*, 'Program finished'
end program
——————————————————————————————————————————
我用pgi编译如下:
pgf90 -fast -o fftw fftwtest1.f90 -L/opt/fftw/lib -lfftw3_f77 -lm
编译的时候只是说我在读in(i,j)的时候有两个警告,其他没有问题。编译后的程序能够顺利运行,但是不管输入什么数据,结果都是0,不知道是哪里出了问题?请各位兄弟帮小弟看看。
以下是我的输入文件:
0 0 1
0 1 2
0 2 4
1 0 4
1 1 5
1 2 6
2 0 7
2 1 9
2 2 3
下面是运算结果:
0 0
(0.000000000000000,0.000000000000000)
0 1
(0.000000000000000,0.000000000000000)
0 2
(0.000000000000000,0.000000000000000)
1 0
(0.000000000000000,0.000000000000000)
1 1
(0.000000000000000,0.000000000000000)
1 2
(0.000000000000000,0.000000000000000)