[转载]Lammps并行安装全解读
(2013-01-12 16:21:27)
标签:
转载 |
Lammps并行安装全解读
这里的lammps安装是在Ubuntu11.04下安装,Ubuntu12.10和Redhat Enterprise也有成功案例。不同版本系统可能与下面一些安装包不兼容,这个要自己负责了,出错要自己排查是什么问题。非并行安装就不写了,太Easy,网上找的基本不会错。还有,我这篇文章参考了很多文章,我都记不清了,如果有人需要备注,给我留言吧。我连续研究了一周,还有零碎的时间没算进去。遇到一堆错误,看了一堆资料。有问题的也可以问我,仅限2012年以后就难说啦。
首先做下准备,把需要的软件包都找好。
1.fftw-3.3.2.tar.gz,可以到这里下, http://www.kuaipan.cn/file/id_34521031569913834.htm
2.mpich2-1.4.1p1.tar, 可以到这里下http://www.kuaipan.cn/file/id_34521031569913840.htm
3.lammps.tar.gz,版本号30Aug12,http://www.kuaipan.cn/file/id_34521031569913839.htm
4. Makefile.g++, http://www.kuaipan.cn/file/id_34521031569913836.htm
然后检查下自己的机器是否已经安装c和fortran编译器
Linux一般有gcc,g++,gfortran和intel的fortran ,可以用which g++和which gfortran查看是否存在安装目录。
这里用ubuntu源里的g++和gfortran,保证联网的情况下用以下命令:
sudo apt-get install build-essential
sudo apt-get install g++
sudo apt-get install gfortran
无法联网的自己下载或者拷贝吧,到网上找解决办法
开始安装:
1 安装fftw
终端输入:
cd
/mnt
这个是fftw临时存放文件夹,不是安装目录,服务器中最好放在自己的文件夹下面,例如cd /zhangsan/mnt
gunzip
fftw-3.3.2.tar.gz
源码包fftw-2.1.5.tar.gz已经拷贝在 /mnt下,可通过“cp fftw全路径 fftw目标路径”操作,具体参照cp命令
tar
xvf
fftw-3.3.2.tar
cd
fftw-3.3.2
./configure --prefix=/opt/fftw --enable-float (进行安装前注册)
/opt/fftw是安装目录,可根据需要进行更改,这个路径对后面的Makefile.g++有影响,
make
make
install
2 安装mpich
终端输入:
cd /mnt
gunzip mpich2-1.4.1p1.tar.gz
tar xvf mpich2-1.4.1p1.tar
cd /mpich2-1.4.1p1
./configure --prefix=/opt/mpich
make
sudo
make install
修改环境变量
cd
gedit .bashrc
在弹出的环境变量文件末尾添加下面代码:
If [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
expot
export LD_LIBRARY_PATH=/opt/mpich/lib:/opt/fftw/lib:$LD_LIBRARY_PATH
注:如果你的mpich不是装在/opt/mpich下面,需要把上面代码修改成实际路径
3 安装lammps
cd /mnt
gunzip lammps.tar.gz
tar xvf lammps.tar
mv lammps-30Aug12 lmp
cd /lmp/src
查看已经安装了那些包
make package-status
需要特殊安装就
make yes-meam
make yes-reax
make
yes-peri
也可以make yes-all,会因缺少文件出错所以不建议,也可都卸载make no-all
同时注意,因为你用的是gfortran编译器,所以里面有个Makefile.lammps的文件需要修改一下,poems不用它用的是g++编译器:
cd /mnt/lmp/lib/meam
gedit Makefile.lammps
其中
meam_SYSINC =
meam_SYSLIB = -lifcore -lsvml
–lompstub-limf
meam_SYSPATH =
-L/opt/intel/fce/10.0.023/lib
make -f
Makefile.gfortran
cd /mnt/lmp/lib/poems
make -f Makefile.g++
cd /mnt/lmp/lib/reax
gedit Makefile.lammps
其中
reax_SYSINC =
reax_SYSLIB = -lifcore -lsvml
–lompstub-limf
reax_SYSPATH =
-L/opt/intel/fce/10.0.023/lib
make -f Makefile.gfortran
下面就是重要的Makefile.g++的编译了,也可以Makefiel.serial
这里的东西比较难改,我已经做好了一个如果路径一样可以直接用我的Makefile.g++,
如果路径不一样,黑体字部分路径需要修改,先敲两行命令调出Makefile。
cd /mnt/lmp/src/MAKE
gedit Makefile.g++
开始修改
# g++ = RedHat Linux box, g++4, MPICH2, FFTW
SHELL = /bin/sh
# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC
=
CCFLAGS
=
DEPFLAGS =
LINK
=
LINKFLAGS =
LIB
=
ARCHIVE
=
ARFLAGS
=
SIZE
=
# ---------------------------------------------------------------------
# LAMMPS-specific settings
# specify settings for LAMMPS features you will use
# if you change any -D setting, do full re-compile after "make clean"
# LAMMPS ifdef settings, OPTIONAL
# see possible settings in doc/Section_start.html#2_2 (step 4)
LMP_INC
=
# MPI library, REQUIRED
# see discussion in doc/Section_start.html#2_2 (step 5)
# can point to dummy MPI library in src/STUBS as in Makefile.serial
# INC = path for mpi.h, MPI compiler settings
# PATH = path for MPI library
# LIB = name of MPI library
MPI_INC
=
MPI_PATH
=
MPI_LIB
=
# FFT library, OPTIONAL
# see discussion in doc/Section_start.html#2_2 (step 6)
# can be left blank to use provided KISS FFT library
# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
# PATH = path for FFT library
# LIB = name of FFT library
FFT_INC =
FFT_PATH = -L/opt/fftw/lib
FFT_LIB
=
# JPEG library, OPTIONAL
# see discussion in doc/Section_start.html#2_2 (step 7)
# only needed if -DLAMMPS_JPEG listed with LMP_INC
# INC = path for jpeglib.h
# PATH = path for JPEG library
# LIB = name of JPEG library
JPG_INC
=
JPG_PATH =
JPG_LIB
=
# ---------------------------------------------------------------------
# build rules and dependencies
# no need to edit this section
include
include
EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)
EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)
EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)
# Link target
$(EXE):
# Library target
lib:
# Compilation rules
%.o:%.cpp
%.d:%.cpp
# Individual dependencies
DEPENDS = $(OBJ:.o=.d)
include $(DEPENDS)
保存后开始安装lammps
cd /mnt/lmp/src
make clean-all
make
serial
mv lmp_serial lmp
4 并行计算一example
a:终端输入
cd
/mnt/lmp/examples/shear
cp /opt/mpich/bin/mpirun /mnt/lmp/e*/shear
cp /mnt/lmp/src/lmp
/mnt/lmp/e*/shear
mpirun –np 4
./lmp<in.shear
b:终端输入(方法二,比较简单,直接给mpirun和lmp的绝对路径,不需要拷贝了)
cd /mnt/lmp/e*/shear
/opt/mpich/bin/mpirun –np 4 /mnt/lmp/src/lmp<in.shear

加载中…