我尝试从python调用Fotran的MPI。
这是helloword.f90
subroutine hello
include 'mpif.h'
integer ierr, rank, size
!character(len=MPI_MAX_LIBRARY_VERSION_STRING) version
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
!call MPI_GET_LIBRARY_VERSION(version, len, ierr)
print*,'hello I am ', rank,'of ', size
call MPI_FINALIZE(ierr)
end subroutine hello
在hello.py中,我哭了
import helloworld
hellworld.hello()
但是,在Ubuntu 18.04中,我使用PYTHON 3.7.4,无法使用命令创建file.so:
f2py -c helloworld.f90 -m helloworld
这是我的错误:
helloworld.f90:3: Error: Can't open included file 'mpif.h'
error: Command "/usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops -I/tmp/tmptfpctvyb/src.linux-x86_64-3.7 -I/home/kimduyen/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/home/kimduyen/anaconda3/include/python3.7m -c -c helloworld.f90 -o /tmp/tmptfpctvyb/helloworld.o" failed with exit status 1
您能帮我解决此错误,还是提供其他命令来创建file.so,以便从PYTHON运行FORTRAN的MPI。
我的计算机成功地从PYTHON运行FORTRAN的openMP。另外,我在FORTRAN中成功运行MPI。但是,我无法从PYTHON调用FORTRAN的MPI。
谢谢您的帮助
mpirun.openmpi hello.py
我有一个错误:
mpirun.openmpi was unable to find the specified executable file, and therefore
没有启动工作。首次报告此错误是为了处理等级0;其他过程也可能发生过。
NOTE: A common cause for this error is misspelling a mpirun.openmpi command
line parameter option (remember that mpirun.openmpi interprets the first
unrecognized command line token as the executable).
所以您能帮我修复它。