Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compiler construction 编译使用mpi(AGMG)的库_Compiler Construction_Fortran_Mpi_Openmpi - Fatal编程技术网

Compiler construction 编译使用mpi(AGMG)的库

Compiler construction 编译使用mpi(AGMG)的库,compiler-construction,fortran,mpi,openmpi,Compiler Construction,Fortran,Mpi,Openmpi,我正在试图编译这个库 并行示例的make文件如下所示: # MPIopt = -I/... (where to find mpif.h) # MUMPSPopt = -I/... (where to find files to be included by # applications using MUMPS) # MUMPSlib = -l... (link reference for MUMPS) # SCALAP = -l...

我正在试图编译这个库

并行示例的make文件如下所示:

# MPIopt    = -I/... (where to find mpif.h)
# MUMPSPopt = -I/... (where to find files to be included by 
#                     applications using MUMPS)
# MUMPSlib  = -l...  (link reference for MUMPS)
# SCALAP    = -l...  (link reference for SCALAPACK, needed by MUMPS)
# BLASLAPACK= -l...  (link reference for LAPACK & BLAS)
# MPIlib    = -l...  (link reference for MPI)
在我的Debian mpif.h上可以找到:

$ ls /usr/lib/openmpi/include/mpi.h 
/usr/lib/openmpi/include/mpi.h
$ dpkg -L libscalapack-mpi-dev 
/.
/usr
/usr/lib
/usr/lib/libscalapack-openmpi.a
所以我在Makefile中写道:

MPIopt  =   -I/usr/lib/openmpi/include/
MPIlib    = -lmpi
但无论如何,当我尝试编译时,会出现以下错误:

:~/AGMG_3.0/Example_par$ make
cd ../SRC;make dpar
make[1]: Entering directory `AGMG_3.0/SRC'
make[1]: Nothing to be done for `dpar'.
make[1]: Leaving directory `AGMG_3.0/SRC'
gfortran-4.4 -O4 -o Example_par Example_par.o ../SRC/dagmg_par.o   -lmpi 
Example_par.o: In function `MAIN__':
Example_par.f90:(.text+0x77): undefined reference to `mpi_init_'
....
....
....
dagmg_par.f90:(.text+0x19fc9): undefined reference to `mpi_comm_rank_'
dagmg_par.f90:(.text+0x19fdd): undefined reference to `mpi_comm_size_'
collect2: ld returned 1 exit status
make: *** [Example_par] Error 1
我现在很困惑,我尝试过成功的方法,但是我在scaplap上遇到了问题 以及其他要求。 scalap可在以下位置找到:

$ ls /usr/lib/openmpi/include/mpi.h 
/usr/lib/openmpi/include/mpi.h
$ dpkg -L libscalapack-mpi-dev 
/.
/usr
/usr/lib
/usr/lib/libscalapack-openmpi.a
流行性腮腺炎位于/usr/lib/libsmps.a中,头文件位于/usr/include/smumps_c.h中

那么,我该如何把这些放在一起呢

我知道对于更高级的fortran或C开发人员来说,这将是微不足道的

提前感谢你的帮助

编辑: 我将完整的Makefile定义放在这里,希望它能帮助其他人:

MPIopt = -I/usr/lib/openmpi/include -I/usr/lib/openmpi/lib -L/usr/lib/openmpi/lib -pthread 
MPIlib = -lmpi_f90 -lmpi_f77 -lmpi 
MUMPSPopt = -I/usr/lib/libsmumps.a -I/usr/lib/libdmumps.a
MUMPSlib = -lsmumps  -ldmumps
BLASLAPACK=-L/usr/lib -llapack -lblas 
BLASLAPACK=-L/usr/lib -llapack -lblas 
SCALAP = -L/usr/lib/libscalapack-openmpi.a -lscalapack-openmpi

F90=gfortran-4.6    

这就建立了它。谢谢你的回复

我认为您缺少fortran MPI库的内容。您应该使用安装的mpi编译器包装,通常称为mpif90。如果要手动指定所有库,可以使用

mpif90 --showme

用于openmpi或某些类似标志,具体取决于您的MPI库。

这些是链接器错误。看起来您的包含文件已成功拾取,但链接器未看到MPI库。尝试将MPIlib=-lmpi更改为包含libmpi.a路径的内容,例如MPIlib=-L/usr/lib/openmpi/lib-lmpi


或者,按照@haraldkl的建议,尝试使用MPI编译器包装器。这些应该注意自动链接到MPI。

谢谢您的回答。虽然这向我展示了有关MPI的内容,但我仍然在与其他库进行斗争。另一个答案告诉我如何为别人做,所以我接受了。谢谢!这告诉了我怎么做-L/Path/to/Library.a-llibName!