我正在尝试与Python和Fortran进行交互。
我被困在最简单的例子中(从这里mpi4py and f2py)。
该示例定义了以下Fortran子例程:
! file: helloworld.f90
subroutine sayhello(comm)
use mpi
implicit none
integer :: comm, rank, size, ierr
call MPI_Comm_size(comm, size, ierr)
call MPI_Comm_rank(comm, rank, ierr)
print *, 'Hello, World! I am process ',rank,' of ',size,'.'
end subroutine sayhello
通过此命令(Linux CLI)使用f2py处理上述子例程:
$ f2py -c --fcompiler=gnu95 --f90exec=mpif90 --include-paths /usr/local/include/ -L/usr/local/lib/lib -lmpi helloworld.f90 -m helloworld
命令成功结束,并创建对象helloworld.so。
我创建了以下python驱动程序脚本(文件driver_helloworld.py
)
#!/usr/bin/env python
#--------------
# Loaded Modules
#--------------
from mpi4py import MPI
import helloworld
#------------------------------------
# Set the MPI communicator
#-------------------------------------
fcomm = MPI.COMM_WORLD.py2f()
#-----------------------------------------
# Calling the Fortran subroutine
#-----------------------------------------
helloworld.sayhello(fcomm)
上面串口运行脚本工作正常,即:
$ python driver_helloworld.py
输出是预期的:
Hello, World! I am process 0 of 1 .
然而,当我尝试通过mpiexec时,即:
$ mpiexec -n 2 python driver_helloworld.py
我收到以下错误:
[linux-box] [[INVALID],INVALID] ORTE_ERROR_LOG: Not found in file ess_env_module.c at line 367
[linux-box] [[INVALID],INVALID] ORTE_ERROR_LOG: Not found in file ess_env_module.c at line 367
[linux-box] tcp_peer_recv_connect_ack: invalid header type: 259457024
[linux-box] tcp_peer_recv_connect_ack: invalid header type: 259457024
我正在使用:
有人知道问题的原因/位置吗?