1 在终端输入:
cd /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)
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 ./configure --prefix=/opt/fftw --enable -float 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 make make install (mpich即安装在/opt/mpich下) 然后配置环境变量 终端输入: cd vi .bashrc 开始编译为 If [ -f /etc/bashrc ]; then . /etc/bashrc fi expot PATH=/opt/mpich/bin:$PATH export LD_LIBRARY_PATH=/opt/mpich/lib:/opt/fftw/lib:$LD_LIBRARY_PATH 3 安装lammps cd /mnt gunzip lammps.tar.gz tar xvf lammps.tar mv lammps-5Dec10 lmp cd /lmp/src make yes-all make no-gpu make no-user-atc (几个特殊的package:meam,poems,reax,gpu,user-atc需要特别安装,如下) cd /mnt/lmp/lib/meam ls make –f Makefile.gfortran (安装meam) 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++ = 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 DEPFLAGS = -M LINK = g++4 g++4改为mpic++ LINKFLAGS = -g -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/opt/mpich/include -DMPICH_SKIP_MPICXX MPI_PATH = -L/opt/mpich/lib MPI_LIB = -L/opt/mpich/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/opt/fftw/include -DFFT_FFTW FFT_PATH = -L/opt/ffte/lib FFT_LIB = -L/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/mnt/lmp/lib/meam poems_SYSPATH= -L/mnt/lmp/lib/poems reax_SYSPATH = -L/mnt/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 cd /mnt/lmp/e*/shear /opt/mpich/bin/mpirun –np 4 /mnt/lmp/src/lmp