美文网首页分子动力学
lammps-mpi并行安装

lammps-mpi并行安装

作者: Yuanshuo | 来源:发表于2019-11-06 13:34 被阅读0次

    1.准备安装文件

    1. mkdir lammps #新建lammps文件夹
    2. cd lammps/ #进入lammps/
    3. wget http://www.fftw.org/fftw-3.3.8.tar.gz #下载fftw-3.3.8.tar.gz
    4. wget http://www.mpich.org/static/downloads/3.3.1/mpich-3.3.1.tar.gz #下载mpich-3.3.1.tar.gz
    5. wget https://lammps.sandia.gov/tars/lammps-stable.tar.gz #下载lammps-stable.tar.gz

    2.解压安装文件

    1. tar -xvf fftw-3.3.8.tar.gz #解压后为fftw-3.3.8
    2. tar -xvf mpich-3.3.1.tar.gz #解压后为mpich-3.3.1
    3. tar -xvf lammps-stable.tar.gz #解压后为lammps-7Aug19

    3.安装fftw

    lammps/ 文件夹下
    1. mkdir fftw3 #新建fftw3文件夹
    2. cd fftw-3.3.8/ #进入fftw-3.3.8/
    3. ./configure --prefix=/share/home/.../lammps/fftw3/ --enable-shared=yes #/share/home/.../lammps/fftw3/安装到此目录下,自指定
    4. make
    5. make install

    4.安装mpich

    lammps/ 文件夹下
    1. mkdir mpich3
    2. cd mpich-3.3.1/
    3. ./configure --prefix=/share/home/.../lammps/mpich3/
    4. make
    5. make install

    5.安装lammps

    lammps/ 文件夹下
    1. cd lammps-7Aug19/src/MAKE/
    2. vi Makefile.mpi #修改mpi和fftw链接路径

    # mpi = MPI with its default compiler
    
    SHELL = /bin/sh
    
    # ---------------------------------------------------------------------
    # compiler/linker settings
    # specify flags and libraries needed for your compiler
    
    CC =        g++   #需修改
    CCFLAGS =   -g -O3 
    SHFLAGS =   -fPIC
    DEPFLAGS =  -M
    
    LINK =      g++   #需修改
    LINKFLAGS = -g -O3
    LIB = 
    SIZE =      size
    
    ARCHIVE =   ar
    ARFLAGS =   -rc
    SHLIBFLAGS =    -shared
    
    # ---------------------------------------------------------------------
    # LAMMPS-specific settings, all OPTIONAL
    # specify settings for LAMMPS features you will use
    # if you change any -D setting, do full re-compile after "make clean"
    
    # LAMMPS ifdef settings
    # see possible settings in Section 2.2 (step 4) of manual
    
    LMP_INC =   -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64
    
    # MPI library
    # see discussion in Section 2.2 (step 5) of manual
    # MPI wrapper compiler/linker can provide this info
    # can point to dummy MPI library in src/STUBS as in Makefile.serial
    # use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts
    # INC = path for mpi.h, MPI compiler settings
    # PATH = path for MPI library
    # LIB = name of MPI library
    
    MPI_INC =       -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I/home/lammps/mpich3/include #需安自定修改路径
    MPI_PATH =      -L/home/lammps/mpich3/lib #需安自定修改路径
    MPI_LIB =   -lmpich -lmpl -lpthread #需修改
    
    # FFT library
    # see discussion in Section 2.2 (step 6) of manual
    # 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 =       -DFFT_FFTW3 -I/home/lammps/fftw3/include #需安自定修改路径
    FFT_PATH =      -L/home/lammps/fftw3/lib #需安自定修改路径
    FFT_LIB =   -lfftw3 #需修改
    
    
    # JPEG and/or PNG library
    # see discussion in Section 2.2 (step 7) of manual
    # only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC
    # INC = path(s) for jpeglib.h and/or png.h
    # PATH = path(s) for JPEG library and/or PNG library
    # LIB = name(s) of JPEG library and/or PNG library
    
    JPG_INC =       
    JPG_PATH =  
    JPG_LIB =   
    
    # ---------------------------------------------------------------------
    # build rules and dependencies
    # do not 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)
    EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS)
    EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS)
    
    # Path to src files
    
    vpath %.cpp ..
    vpath %.h ..
    
    # Link target
    
    $(EXE): $(OBJ) $(EXTRA_LINK_DEPENDS)
        $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
        $(SIZE) $(EXE)
    
    # Library targets
    
    lib:    $(OBJ) $(EXTRA_LINK_DEPENDS)
        $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
    
    shlib:  $(OBJ) $(EXTRA_LINK_DEPENDS)
        $(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
            $(OBJ) $(EXTRA_LIB) $(LIB)
    
    # Compilation rules
    
    %.o:%.cpp
        $(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<
    
    # Individual dependencies
    
    depend : fastdep.exe $(SRC)
        @./fastdep.exe $(EXTRA_INC) -- $^ > .depend || exit 1
    
    fastdep.exe: ../DEPEND/fastdep.c
        cc -O -o $@ $<
    
    sinclude .depend
    
    

    3. cd .. #返回上层src文件夹
    4. make mpi
    src下出现lmp_mpi安装成功

    6.建立软链

    ln -s /share/home/.../lmp_mpi /usr/bin/lmp_mpi #为lmp_mpi创建软连接

    7.测试

    1. cd lammps-7Aug19/examples/shear
    2. mpirun -np 3 lmp_mpi -in in.shear #调用3核心运行
    输出dump.shear成功!!!!

    8.祝好运!!!

    相关文章

      网友评论

        本文标题:lammps-mpi并行安装

        本文链接:https://www.haomeiwen.com/subject/fgkubctx.html