Python调用使用MPI的(fortran)库
我想加载并调用一个使用MPI的库.
我想象每个等级加载自己的库版本,然后库将相互通信.我不想从库调用者进行任何通信或MPI处理. 无论我是否加载使用mpi的库或使用openmp的库,python代码都将保持不变.当我从C动态加载和调用库时,我设法使它工作.但是使用python它失败了:
[..]
[..]
[..] 我想知道我要为python做些什么.像openmpi重新编译python的东西? 我举一个例子如下: testMPI.py #!/usr/bin/env python from ctypes import * # Loading library raw = cdll.LoadLibrary('./libtest.so.1.0') print "hello world " raw.test() test.f90 subroutine test() bind(c,name='test') use MPI implicit none integer :: nprocs =-1 !< total number of process integer :: rank=0 !< rank in comm world integer :: ierr =-1 !< call MPI_init(ierr) call MPI_comm_size(MPI_comm_world,nprocs,ierr) call MPI_comm_rank(MPI_comm_world,rank,ierr) write(*,*)"hello world from "," of ",nprocs call MPI_finalize(ierr) end subroutine Makefile文件 FC=mpif90.openmpi FFLAGS=-free -fPIC -g -Wall all: obj test test: mpirun.openmpi -n 4 ./testMPI.py obj: $(FC) $(FFLAGS) -c test.f90 $(FC) $(FFLAGS) -shared -Wl,-soname,libtest.so.1 -o libtest.so.1.0 test.o clean: rm *.o libtest* 解决方法
我有类似的问题,有一个解决方法:
当您运行configure以编译openmpi时,请使用以下标志: ./configure –disable-dlopen 希望这对你有用! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |