关注九天学者
微信公众号(扫码关注)第一时间获取技术贴更新!
FIHSES是基于MUMPS开发的用于热液流体模拟的,开发者将MUMPS源代码直接放在了FISHES里面,所以在进行编译FISHES
之前必须先编译MUMPS。这里用到的是MUMPS_5.0.1。而MUMPS又依赖于OpenMPI,BLAS,LAPACK,SCALLAPACK,SCOTCH,METIS.编译器是基于gfortran的mpif90.
程序包清单
-
MPICH : 版本 mpich-3.2.1 (stable
release) - OpenMPI:
- BLAS:
- LAPACK:
- SCALLAPACK:
- SCOTCH:
- METIS
安装过程
为了不让brew等安装的杂乱版本所影响,在用户主目录下新建一个opt目录
mkdir ~/opt
,在opt目录下新建一个lib目录作为安装这些库的目录.
mkdir ~/opt
mkdir ~/opt/lib
安装前准备
在 ~/.bashrc 中定义几个变量,并且 source ~/.bashrc 使其生效,标量如下
# add path of gcc: no root account install gcc
export LOCAL_OPT=/home/zhikui/opt
export LD_LIBRARY_PATH=$LOCAL_OPT/gcc/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LOCAL_OPT/gcc/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$LOCAL_OPT/gcc/include:$CPLUS_INCLUDE_PATH
export PATH=$LOCAL_OPT/gcc/bin:$PATH
m4
版本: 1.4.18
tar xvf m4-1.4.18.tar.xz
cd m4-1.4.18
./configure --prefix=$LOCAL_OPT/gcc
make
make check
make install
下面的几个都是一个讨论,先 configure
然后 make check
,最后
make install
。
gmp
版本:
gmp-6.1.2.tar.xz
tar xvf gmp-6.1.2.tar.xz
cd gmp-6.1.2
./configure --prefix=$LOCAL_OPT/gcc --with-m4-lib=$LOCAL_OPT/gcc/lib --with-m4-include=$LOCAL_OPT/gcc/include
mpfr
tar xvf mpfr-3.1.6.tar.xz
cd mpfr-3.1.6
./configure --prefix=$LOCAL_OPT/gcc --with-m4-lib=$LOCAL_OPT/gcc/lib --with-m4-include=$LOCAL_OPT/gcc/include --with-gmp-lib=$LOCAL_OPT/gcc/lib --with-gmp-include=$LOCAL_OPT/gcc/include
mpc
版本: mpc-1.0.2.tar.gz
tar xvf mpc-1.0.2.tar
cd mpc-1.0.2
./configure --prefix=$LOCAL_OPT/gcc --with-m4-lib=$LOCAL_OPT/gcc/lib --with-m4-include=$LOCAL_OPT/gcc/include --with-gmp-lib=$LOCAL_OPT/gcc/lib --with-gmp-include=$LOCAL_OPT/gcc/include --with-mpfr-lib=$LOCAL_OPT/gcc/lib --with-mpfr-include=$LOCAL_OPT/gcc/include
gcc
tar xvf gcc-4.6.0.tar.bz2
cd gcc-4.6.0
./configure --prefix=$LOCAL_OPT/gcc --with-mpfr-lib=$LOCAL_OPT/gcc/lib --with-mpfr-include=$LOCAL_OPT/gcc/include --with-mpc-lib=$LOCAL_OPT/gcc/lib --with-gmp-lib=$LOCAL_OPT/gcc/lib --disable-multilib
安装MUMPS依赖库
MPICH
安装完成添加环境变量
# MPICH
export PATH="/home/zhikui/opt/lib/mpich/bin:$PATH"
export LIBPATH="/home/zhikui/opt/lib/mpich/lib:$LIBPATH"
BLAS
tar xvf blas-3.8.0.tgz
mv BLAS-3.8.0 ~/opt/lib/
cd ~/opt/lib/BLAS-3.8.0
gfortran -shared -O2 *.f -o libblas.so -fPIC
LAPACK
tar xvf lapack-3.8.0.tar.gz
mv lapack-3.8.0 ~/opt/lib/
cd ~/opt/lib/lapack-3.8.0
cp make.inc.example make.inc
- 修改make.inc文件中的
和
选项,后面添加 -fPIC
,并且修改lib的后缀名为 so ,然后保存
OPTS = -O2 -frecursive -fPIC
DRVOPTS = $(OPTS)
NOOPT = -O0 -frecursive -fPIC
BLASLIB = ../../librefblas.so
LAPACKLIB = liblapack.so
- 修改./SRC/Makefile
修改第517行的内容
../$(LAPACKLIB): $(ALLOBJ) $(ALLXOBJ) $(DEPRECATED)
$(ARCH) $(ARCHFLAGS) $@ $^
$(RANLIB) $@
改为:
../$(LAPACKLIB): $(ALLOBJ)
$(LOADER) $(LOADOPTS) -shared -Wl,-soname,liblapack.so -o $@ $(ALLOBJ) ../librefblas.so
- 修改./BLAS/SRC/Makefile
将140行内容
$(BLASLIB): $(ALLOBJ)
$(ARCH) $(ARCHFLAGS) $@ $^
$(RANLIB) $@
改为:
$(BLASLIB): $(ALLOBJ)
$(LOADER) $(LOADOPTS) -z muldefs -shared -Wl,-soname,librefblas.so -o $@ $(ALLOBJ)
继续运行编译命令
make blaslib
make lapacklib
最后生成两个lib文件: librefblas.so 和 liblapack.so
- 修改环境变量:
export LIBPATH="/home/zhikui/opt/lib/lapack-3.8.0:$LIBPATH"
Scotch
- 解压:
tar xvf scotch_5.1.12_esmumps.tar.gz
- 进入:
cd scotch_5.1.12_esmumps/src
- 修改Makefile: 在36行中加入
prefix=/home/zhikui/opt/lib/scotch_5.1.12_esmumps
作为安装目录的指示。 - 设置Makefile.inc: 参考 网络帖子
设置如下:
EXE =
LIB = .a
OBJ = .o
MAKE = make
AR = ar
ARFLAGS = -ruv
CAT = cat
CCS = gcc
CCP = mpicc
CCD = mpicc
CFLAGS = -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_RENAME_PARSER -DSCOTCH_PTHREAD -Drestrict=__restrict -DIDXSIZE64
CLIBFLAGS =
LDFLAGS = -lz -lm -lrt
CP = cp
LEX = flex -Pscotchyy -olex.yy.c
LN = ln
MKDIR = mkdir
MV = mv
RANLIB = ranlib
YACC = bison -pscotchyy -y -b y
关注九天学者
微信公众号(扫码关注)第一时间获取技术贴更新!
网友评论