1 在终端输入:
cd /mnt (不一定要mnt啦)
(源码包lammps.tar.gz放在/mnt下 (cp /home/lab/Desktop/lammps.tar.gz /mnt))
gunzip lamps.tar.gz
tar -xvf lamps.tar
mv lammps-5Dec10 lmp (重命名为lmp,重命名也不一定要是lmp啦)
cd lmp/src/STUBS
make clean
make
cd /mnt/lmp/src/MAKE
vi Makefile.serial 后出现
# g++ = RedHat Linux box, g++4, gfortran, no MPI,no FFT
SHELL = /bin/sh
# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC = g++4 g++4该为g++
CCFLAGS = -g -O
DEPFLAGS = -M
LINK = g++4 g++4改为g++
LINKFLAGS = -g -O
LIB =
ARCHIVE = ar
ARFLAGS = -rc
SIZE = size
# ---------------------------------------------------------------------
然后存档,退出,终端输入
cd /mnt/lmp/src
make clean-all
make serial
之后linux开始编译,最后会在/mnt/lmp/src下生成lmp_serial的可执行文件。
mv lmp_serial lmp
2 计算一example
终端输入:
cd /mnt/lmp/e*/shear
cp /mnt/lmp/src/lmp /mnt/lmp/e*/shear
./lmp 1 安装fftw 终端输入: cd /mnt gunzip fftw-2.1.5.tar.gz (源码包fftw-2.1.5.tar.gz在 /mnt下) tar xvf fftw-2.1.5.tar cd fftw-2.1.5 (find . -type f | xargs -n 5 touch)此步表示系统时间不对时采取的,一般不要。) ./configure --prefix=/public/home/zhangchao/opt/fftw --enable –float红字不要,prefix=指定安装在fftw中,要写出绝对路径,绝对路径获得方法:先cd opt/fftw,然后pwd,就获得绝对路径,经过鼠标copy(不能Ctrl C)就可获得,最后进入cd/mnt/fftw-2.1.5, 输入./configure --prefix=再右击鼠标paste即可 make make install (fftw-2.1.5即安装在/opt/fftw下) 2 安装mpich 终端输入: cd /mnt gunzip mpich2-1.3.1.tar.gz tar xvf mpich2-1.3.1.tar cd /mpich2-1.3.1 ./configure --prefix=/… …opt/mpich 方法同fftw make make install (mpich即安装在/opt/mpich下) 然后配置环境变量 终端输入: cd vi .bashrc 本人没有.bashrc利用了.bash_profile,因此编辑 vi .bash_profile, .bashrc和.bash_profile都是隐藏文件在自己的用户名zhangchao下,需要ls –al,才可以看到。 开始编译为 If [ -f /etc/bashrc ]; then . /etc/bashrc fi export PATH=/public/home/zhangchao/opt/mpich/bin:$PATH export LD_LIBRARY_PATH=/public/home/zhangchao /opt/mpich/lib: /public/home/zhangchao /opt/fftw/lib:$LD_LIBRARY_PATH (注意export后仅仅一个空格,其余地方都无空格) 3 安装lammps cd /mnt gunzip lammps.tar.gz tar xvf lammps.tar mv lammps-5Dec10 lmp 改名(也可以 lmp在自己的用户名下,与mnt同级) cd /lmp/src make package-status make yes-all (第一次安装直接make yes-all,否则要先make clean-all) make no-gpu Make no-kim make no-user-atc (尽量加上) (几个特殊的package:meam,poems,reax,gpu,user-atc需要特别安装(如果不需要安装就直接make no-MEAM; make no-POEMS; make no-REAX),如下) cd /mnt/lmp/lib/meam ls make –f Makefile.gfortran (安装meam,必须有gfortran编译器) cd /mnt/lmp/lib/poems ls make –f Makefile.g++ cd /mnt/lmp/lib/reax ls make –f Makefile.gfortran (然后对Makefile.serial文件进行编译) cd /mnt/lmp/src/MAKE vi Makefile.serial (按下i可修改) (下面例子是g++的,都一样最好改serial,改法一样,蓝字是对serial的修改) # g++ = RedHat Linux box, g++4, gfortran, MPICH2, FFTW SHELL = /bin/sh # --------------------------------------------------------------------- # compiler/linker settings # specify flags and libraries needed for your compiler CC = g++4 g++4改为mpic++ CCFLAGS = -g –O ( 或者是 CCFLAGS = –O) DEPFLAGS = -M LINK = g++4 g++4改为mpic++ LINKFLAGS = -g –O (或者是LINKFLAGS = -O) LIB = ARCHIVE = ar ARFLAGS = -rc SIZE = size # --------------------------------------------------------------------- # LAMMPS-specific settings # specify settings for LAMMPS features you will use # LAMMPS ifdef options, see doc/Section_start.html LMP_INC = -DLAMMPS_GZIP # MPI library, can be src/STUBS dummy lib # INC = path for mpi.h, MPI compiler settings # PATH = path for MPI library # LIB = name of MPI library MPI_INC = -I/public/home/zhangchao/opt/mpich/include -DMPICH_SKIP_MPICXX MPI_PATH = -L/public/home/zhangchao/opt/mpich/lib MPI_LIB = -L/public/home/zhangchao/opt/mpich/lib/libmpich.a (或者是MPI_LIB = -L/public/home/zhangchao/opt/mpich/lib -lmpich –lpthread) (或者是MPI_LIB = -L/public/home/zhangchao/opt/mpich/lib) # FFT library, can be -DFFT_NONE if not using PPPM from KSPACE package # INC = -DFFT_FFTW, -DFFT_INTEL, -DFFT_NONE, etc, FFT compiler settings # PATH = path for FFT library # LIB = name of FFT library FFT_INC = -I/ public/home/zhangchao/opt/fftw/include -DFFT_FFTW FFT_PATH = -L/ public/home/zhangchao/opt/fftw/lib FFT_LIB = -L/ public/home/zhangchao/opt/fftw/lib -lfftw (勿写成libfftw.a) # additional system libraries needed by LAMMPS package libraries # these settings are IGNORED if the corresponding LAMMPS package # (e.g. gpu, meam) is NOT included in the LAMMPS build # SYSLIB = names of libraries # SYSPATH = paths of libraries # gpu_SYSLIB = -lcudart # meam_SYSLIB = -lmeam –lgfortran # poems_SYSLIB= -lpoems -lgfortran # reax_SYSLIB = -lreax -lgfortran # user-atc_SYSLIB = -lblas -llapack # gpu_SYSPATH = -L/usr/local/cuda/lib # meam_SYSPATH = -L/public/home/zhangchao/mnt/lmp/lib/meam # poems_SYSPATH= -L/public/home/zhangchao/mnt/lmp/lib/poems # reax_SYSPATH = -L/public/home/zhangchao/mnt/lmp/lib/reax # user-atc_SYSPATH = 注意:红字部分当需要安装meam, poems,reax三个包时,将前面的#号去除,但很容易报错,如果计算不需要这几个包时,就可以不需要安装。 # --------------------------------------------------------------------- # build rules and dependencies # no need to edit this section include Makefile.package EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(PKG_SYSPATH) EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_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) 存档退出(esc :wq exit),终端输入: # serial = RedHat Linux box, g++4, gfortran, no MPI, no FFTs SHELL = /bin/sh # --------------------------------------------------------------------- # compiler/linker settings # generally no need to edit this section # unless additional compiler/linker flags or libraries needed for your machine CC = mpic++ CCFLAGS = -O DEPFLAGS = -M LINK = mpic++ LINKFLAGS = -O LIB = ARCHIVE = ar ARFLAGS = -rc SIZE = size # --------------------------------------------------------------------- # LAMMPS-specific settings # edit as needed for your machine # LAMMPS ifdef options, see doc/Section_start.html LMP_INC = -DLAMMPS_GZIP # MPI library, can be src/STUBS dummy lib # INC = path for mpi.h, MPI compiler settings # PATH = path for MPI library # LIB = name of MPI library MPI_INC = -I/public/home/zhangchao/opt/mpich/include -DMPICH_SKIP_MPICXX MPI_PATH = -L/public/home/zhangchao/opt/mpich/lib MPI_LIB = -L/public/home/zhangchao/opt/lib -lmpich -lpthread # FFT library, can be -DFFT_NONE if not using PPPM from kspace package # INC = -DFFT_FFTW, -DFFT_INTEL, -DFFT_NONE, etc, FFT compiler settings # PATH = path for FFT library # LIB = name of FFT library FFT_INC = -I/public/home/zhangchao/opt/fftw/include -DFFT_FFTW FFT_PATH = -L/public/home/zhangchao/opt/fftw/lib FFT_LIB = -L/public/home/zhangchao/opt/fftw/lib -lfftw # additional system libraries needed by LAMMPS package libraries # these settings are IGNORED if the corresponding LAMMPS package # (e.g. gpu, meam) is NOT included in the LAMMPS build # SYSLIB = names of libraries # SYSPATH = paths of libraries #gpu_SYSLIB = -lcudart #meam_SYSLIB = -lmeam -lgfortran #poems_SYSLIB= -lpoems -lgfortran #reax_SYSLIB = -lreax -lgfortran #user-atc_SYSLIB = -lblas -llapack #gpu_SYSPATH = -L/usr/local/cuda/lib #meam_SYSPATH = -L/public/home/zhangchao/lmp/lib/meam #poems_SYSPATH= -L/public/home/zhangchao/lmp/lib/poems #reax_SYSPATH = -L/public/home/zhangchao/lmp/lib/reax #user-atc_SYSPATH = # --------------------------------------------------------------------- # build rules and dependencies # no need to edit this section include Makefile.package EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(PKG_SYSPATH) EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_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) 存档退出(esc :wq exit),终端输入: cd /mnt/lmp/src make clean-all (前面加了就不加) make serial (lammps开始安装,最后可生成lmp_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 (lammps开始计算) b:终端输入 cd /mnt/lmp/e*/shear /opt/mpich/bin/mpirun –np 4 /mnt/lmp/src/lmp 比如编译reax模块是需要单独编译: make –f Makefile.gfortran 如果系统无gfortran编译器,仅有ifort编译器,可参照下面进行修改,红色标记处为修改处。 vi Makefile.gfortran # * # *_________________________________________________________________________* # * Fortran Library for Reactive Force Field * # * DESCRIPTION: SEE READ-ME * # * FILE NAME: Makefile * # * CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL) * # * and Greg Wagner(SNL) * # * CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov * # *_________________________________________________________________________*/ # To compile and link LAMMPS to the reax library generated by this Makefile, # try appending the following definitions to the standard definitions in # whatever LAMMPS Makefile your are using. # CCFLAGS = -I../../lib/reax # LINKFLAGS = -L../../lib/reax # USRLIB = -lreax -lgfortran SHELL = /bin/sh # ------ FILES ------ SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F FILES = $(SRC) Makefile # ------ DEFINITIONS ------ LIB = libreax.a OBJ = $(SRC:.F=.o) # ------ SETTINGS ------ F90 = gfortran gfortran改为ifort F90FLAGS = -O -fno-second-underscore ARCHIVE = ar "Makefile.gfortran" 57L, 1532C written dos2unix rp1200r0 由windows转换为linux unrar x aa.rar unrar e aa.rar x参数 是解压到一个文件夹里 e参数是把所有文件解压到当前目录下 注意这个命令比较特殊参数之前不能加- 在daijinxia用户下建立文件夹bin 将lmp_serial 拷贝到bin里 在.bashrc隐藏文件里添加 #for bin export PATH=/public/home/daijinxia/bin:$PATH 然后source .bashrc