【发布时间】:2017-03-20 11:02:58
【问题描述】:
我正在尝试为我前段时间编写的 Python 实现获得一些加速,并决定为此使用 f2py。我目前仍在测试一些东西,并认为我需要一些帮助才能让 FFTW3 正常工作。对于第一次测试,我编写了以下子例程:
subroutine initFFT(planF, a, res, n)
implicit none
include "fftw3.f"
integer, INTENT(IN) :: n
complex(KIND=8), dimension(n) :: a, res
integer(KIND=8), intent(OUT) :: planF
call dfftw_plan_dft(planF, 1, n, a, res, FFTW_FORWARD, FFTW_MEASURE)
end subroutine initFFT
subroutine operation(a, res, n, planF)
implicit none
INCLUDE 'fftw3.f'
integer :: n
integer(KIND=8) :: planF
complex(KIND=8), dimension(n), intent(IN) :: a
complex(KIND=8), dimension(n), intent(OUT) :: res
call dfftw_execute_dft(planF, a, res)
end subroutine operation
我用一个简单的主程序对此进行了测试
program test
implicit none
integer, parameter :: n = 3
integer(KIND=8) :: planF
complex(KIND=8), dimension(n) :: res, a
call initFFT(planF, a, res, n)
a = (/ 1., 1., 1./)
call operation(a, res, n, planF)
end program test
并编译
gfortran -o ftest myFun.f90 -L/usr/lib -lfftw3 -I/usr/include
一切正常并返回了正确的结果。现在我尝试通过以下方式将其与 f2py 一起使用:
f2py -c myFun.f90 -m modf --f90flags="-L/usr/lib -lfftw3 -I/usr/include"
问题是,当我尝试在 Python 中导入创建的模块(使用 import modf)时,我收到以下错误消息:
导入错误:modf.so 未定义符号:dfftw_execute_dft_
我已经在 Google 上度过了一段时间,但不知何故,到目前为止我还没有发现任何有用的东西。有谁知道如何解决这个问题?
【问题讨论】:
-
顺便说一句,dfftw* 过程是为
double precision参数定义的。丑陋的kind=8不保证兼容。 -
谢谢,是的,在生产代码中我将其命名为
double precision- 不过仍然习惯于“旧”格式..
标签: python fortran wrapper fftw f2py