我正在尝试使用并行 python(PP 包)在 Python 2.7 中执行 Fortran 子例程。但是当我使用 pp.server().submit(...) 执行它时,什么也没有发生。我可能执行错了,我使用了这里numpy.f2py.compile()解释的。这样对吗?如果没有,我应该改变什么?
只是提到代码几乎肯定是正确的,因为它取自博士论文(代码,论文)。
在名为“design_operation”的 Python 2.7 模块中实现的子例程是:
import numpy.f2py
fsource = '''
subroutine matrix_op(grid_x,grid_t,eval_grid,pas,K,L,M,C)
COMPLEX :: i=(0.0,1.0)
INTEGER , intent(in) :: K,L,M
REAL , intent(in) :: pas
INTEGER :: u,v,w
REAL , dimension(1:M) , intent(in) :: grid_x
REAL , dimension(1:K) , intent(in) :: grid_t
REAL , dimension(1:L) , intent(in) :: eval_grid
COMPLEX, dimension(1:L,1:M) , intent(out) :: C
do u=1,L
do v=1,M
do w=1,K
C(u,v) = C(u,v) - i*pas*grid_t(w)*grid_x(v)*exp(-i*grid_t(w)*grid_x(v)*eval_grid(u))
end do
end do
end do
end subroutine matrix_op
'''
我总是收到以下错误:
零维数组不能串联。
因此,我认为错误来自任务的不正确执行,但也许我错了。
堆栈错误是:
An error has occured during the function execution
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\project\lib\site-packages\ppworker.py", line 90, in run
__result = __f(*__args)
File "<string>", line 2, in list_append
AttributeError: 'module' object has no attribute 'matrix_op'
An error has occured during the function execution
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\project\lib\site-packages\ppworker.py", line 90, in run
__result = __f(*__args)
File "<string>", line 2, in list_append
AttributeError: 'module' object has no attribute 'matrix_op'
Traceback (most recent call last):
File "<ipython-input-89-6cb5b50fd813>", line 5, in <module>
dM = np.concatenate((dM, job()))#
ValueError: zero-dimensional arrays cannot be concatenated
PS:我认为有一些不必要的代码,因此为了更清楚起见我没有包含它+ func= list_append 的参数是正确的。
万千封印
相关分类