2014-11-04 90 views
3

我想加载并调用使用MPI的库。 我会想象每个级别加载它自己的库的版本,然后库将相互沟通。我不想从库调用者那里进行任何通信或MPI处理。 无论我加载使用mpi的库还是使用openmp的库,python代码都将保持不变。我设法使我的时候动态加载和C.调用库但随着蟒蛇它失败,它的工作:Python调用使用MPI的(fortran)库

MCA:基地:component_find:无法打开 /usr/lib中/的openmpi/lib中/的openmpi/mca_paffinity_hwloc:可能缺少 符号,或者编译为不同版本的Open MPI? (忽略)

[..]

它看起来像opal_init由于某种原因失败;

[..]

opal_shmem_base_select失败 - >的返回值 -1代替OPAL_SUCCESS ompi_mpi_init:orte_init失败 - 而不是 “成功”>返回 “错误”(-1) (0)

[..]

我不知道我有它做与蟒蛇。就像用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 ",rank," of ",nprocs 
    call MPI_finalize(ierr) 
end subroutine 

生成文件

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* 

回答

1

我也有类似的问题,有此一解决方法: 当您运行配置编译了openmpi,请使用以下标志:

的./configure --disable-的dlopen

希望它适合你!

+0

您可能会考虑添加一些[格式](http://stackoverflow.com/editing-help)您的答案以提高其质量。 – 2015-02-12 16:21:56

+0

我有点忙,但我会尽快回复并接受它。谢谢! – 2015-02-15 14:56:52