我有很多源代码,大部分是用Fortran90语言编写的,但有些部分是用C语言编写的。此代码为了正确编译需要安装MPI和HDF5。我现在已经安装了它们,当我尝试编译模型时(编译不是./compile
命令而是./install.sh
而是它会处理所有事情,包括编译)。我有一个很长的错误,所有都与头文件的路径有关。这是错误:
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: mpif.h
Can't find file: stdio.h
Can't find file: math.h
Can't find file: stdlib.h
Can't find file: malloc/malloc.h
Can't find file: malloc.h
Can't find file: stdlib.h
Can't find file: errno.h
Can't find file: string.h
Can't find file: ctype.h
Can't find file: dirent.h
Can't find file: string.h
之后还有其他一些错误,我认为它们与上述错误有关。我试图在./bashrc中设置PATH,当我搜索示例找到mpif.h时,它返回:
[hamid@localhost bin]$ locate mpif.h
/home/hamid/Downloads/ED-2.1/ED/build/bin/mpif.h
/home/hamid/Downloads/ED-2.1/ED/src/mpi/mpif.h
/home/hamid/Downloads/mpich-3.1.3/src/binding/fortran/mpif_h/mpif.h
/home/hamid/Downloads/mpich-3.1.3/src/binding/fortran/mpif_h/mpif.h.in
/home/hamid/Downloads/mpich-3.1.3/src/include/mpif.h
/home/hamid/mpich2-optimised/include/mpif.h
我还设置了LD_LIBRARY_PATH变量,如:
export LD_LIBRARY_PATH=$MPI_DIR/lib:$LD_LIBRARY_PATH
但似乎它似乎无法正常工作。我的猜测是它不仅与MPI或HDF路径设置有关,因为它们中的一些是GCC(C编译器)头文件。 什么可能是问题的任何想法?
答案 0 :(得分:0)
正如评论所说,您可以使用-I
指定目录,然后编译器将在那里找到.h
个文件。 E.g:
gfortran -o name.o -c -I/usr/lib/openmpi/include name.f90
如果您使用的是ifort
,另一种方法是将目录附加到FPATH
,或许可以:
FPATH=$FPATH:usr/lib/openmpi/include
但这并不适用于gfortran。我不知道其他编译器。
答案 1 :(得分:0)
您的安装脚本似乎正在尝试使用常规编译器来编译MPI代码,这就是为什么找不到所有这些标头的原因。尝试将mpich二进制目录添加到路径中。