打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[转载]Lammps并行安装全解读

 

Lammps并行安装全解读

 

这里的lammps安装是在Ubuntu11.04下安装,Ubuntu12.10Redhat 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,版本号30Aug12http://www.kuaipan.cn/file/id_34521031569913839.htm

4. Makefile.g++, http://www.kuaipan.cn/file/id_34521031569913836.htm

 

然后检查下自己的机器是否已经安装cfortran编译器

Linux一般有gccg++gfortranintelfortran ,可以用which g++which gfortran查看是否存在安装目录。

这里用ubuntu源里的g++gfortran,保证联网的情况下用以下命令:

sudoapt-get install build-essential

sudoapt-get install g++

sudoapt-get install gfortran

无法联网的自己下载或者拷贝吧,到网上找解决办法

 

 

开始安装:

1 安装fftw

终端输入:

cd/mnt        (进入mnt文件夹)

这个是fftw临时存放文件夹,不是安装目录,服务器中最好放在自己的文件夹下面,例如cd /zhangsan/mnt

gunzipfftw-3.3.2.tar.gz         (解压文件)

源码包fftw-2.1.5.tar.gz已经拷贝在/mnt下,可通过“cp fftw全路径fftw目标路径”操作,具体参照cp命令

tarxvffftw-3.3.2.tar          (解压文件)

cdfftw-3.3.2               (进入fftw-3.3.2文件夹)

./configure --prefix=/opt/fftw --enable-float(进行安装前注册)

/opt/fftw是安装目录,可根据需要进行更改,这个路径对后面的Makefile.g++有影响,

make                       (预编译)

makeinstall                 (安装fftw-3.3.2即安装在/opt/fftw)

 

2 安装mpich

终端输入:

cd/mnt

gunzip mpich2-1.4.1p1.tar.gz

tarxvf mpich2-1.4.1p1.tar

cd/mpich2-1.4.1p1

./configure --prefix=/opt/mpich

make

sudomake install   (mpich即安装在/opt/mpich)

修改环境变量

cd

gedit.bashrc

在弹出的环境变量文件末尾添加下面代码:

If [-f /etc/bashrc ]; then

./etc/bashrc

fi

 

expot PATH=/opt/mpich/bin:$PATH

exportLD_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

makeyes-peri   make yes-*

也可以make yes-all,会因缺少文件出错所以不建议,也可都卸载make no-all

 (几个特殊的package:meam,poems,reax,gpu,user-atc需要特别安装,如下)

同时注意,因为你用的是gfortran编译器,所以里面有个Makefile.lammps的文件需要修改一下,poems不用它用的是g++编译器:

cd /mnt/lmp/lib/meam

gedit Makefile.lammps

其中

meam_SYSINC =

meam_SYSLIB = -lifcore -lsvml–lompstub-limf   画线部分改为-lgfortran

meam_SYSPATH =-L/opt/intel/fce/10.0.023/lib    删除画线部分

make -fMakefile.gfortran  (安装meam)

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   画线部分改为-lgfortran

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 yourcompiler

 

CC=                  g++

CCFLAGS=     -g -O # -Wunused

DEPFLAGS =  -M

LINK=               g++

LINKFLAGS =   -g-O

LIB=       

ARCHIVE=      ar

ARFLAGS=     -rc

SIZE=               size

 

#---------------------------------------------------------------------

# LAMMPS-specific settings

# specify settings for LAMMPS features you willuse

# if you change any -D setting, do full re-compileafter "make clean"

 

# LAMMPS ifdef settings, OPTIONAL

# see possible settings indoc/Section_start.html#2_2 (step 4)

 

LMP_INC=      -DLAMMPS_GZIP  #不要多加东西

 

# MPI library, REQUIRED

# see discussion in doc/Section_start.html#2_2(step 5)

# can point to dummy MPI library in src/STUBS asin Makefile.serial

# INC = path for mpi.h, MPI compilersettings

# PATH = path for MPI library

# LIB = name of MPI library

 

MPI_INC=    -I/opt/mpich/include   -DMPICH_SKIP_MPICXX

MPI_PATH=    -L/opt/mpich/lib 

MPI_LIB=        -lmpich -lpthread

 

 

# FFT library, OPTIONAL

# see discussion in doc/Section_start.html#2_2(step 6)

# can be left blank to use provided KISS FFTlibrary

# INC = -DFFT setting, e.g. -DFFT_FFTW, FFTcompiler settings

# PATH = path for FFT library

# LIB = name of FFT library

 

FFT_INC = -I/opt/fftw/include     -DFFT_FFTW

FFT_PATH = -L/opt/fftw/lib

FFT_LIB=        -lfftw3f  #记不清了,这个是/opt/fftw/lib文件夹下面的libfftw*.a文件全名,查看一下对

 

# JPEG library, OPTIONAL

# see discussion in doc/Section_start.html#2_2(step 7)

# only needed if -DLAMMPS_JPEG listed withLMP_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    Makefile.package.settings

include    Makefile.package

 

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):    $(OBJ)

        $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o$(EXE)

        $(SIZE) $(EXE)

 

# Library target

 

lib:   $(OBJ)

        $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)

 

# Compilation rules

 

%.o:%.cpp

        $(CC) $(CCFLAGS) $(EXTRA_INC) -c $<

 

%.d:%.cpp

        $(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $<> $@

 

# Individual dependencies

 

DEPENDS = $(OBJ:.o=.d)

include $(DEPENDS)

 

保存后开始安装lammps

cd /mnt/lmp/src

make clean-all

makeserial    (lammps开始安装,最后可生成lmp_serial的可执行文件)

mv lmp_serial lmp (改名为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    (lammps开始计算)

 

b:终端输入(方法二,比较简单,直接给mpirunlmp的绝对路径,不需要拷贝了)

cd /mnt/lmp/e*/shear

/opt/mpich/bin/mpirun –np 4/mnt/lmp/src/lmp<in.shear

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Ubuntu 12.04单机安装并行高富帅版LAMMPS (DRAFT) - 止水的日志 - 网易博客
Ubuntu9.10下安装配置lammps,vmd,fortran
树莓派&qt5交叉编译
sony gdb 修改Makefile
linux小白到大神的成长之路:了解linux系统目录,home,lib,lost+found,media,mnt,opt!
arm qt移植全程详解
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服