網頁

2018年9月13日 星期四

ubuntu lammps install




前置作業
1.建立mpich3 fftw voro++三個資料夾
終端機輸入sudo nautilus
在/home裡面新增mpich3 fftw voro++三個資料夾

sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install mpi-default-*
sudo apt-get install libfftw3*
sudo apt-get install libjpeg-*
sudo apt-get install libpng12-*

2. 安裝mpi
sudo apt install lam4-dev
sudo apt install libmpich-dev
sudo apt install libopenmpi-dev

檢查是否安裝成功
#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[])
{
  int n;
  int total;

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &n);
  MPI_Comm_size(MPI_COMM_WORLD, &total);
  printf("This is Raspberry Pi %d of %d\n", n+1, total);

  MPI_Finalize();
  return 0;
}

mpicc -o test test.c
mpirun -n 4 ./test

3.避免發生一些error
fatal error: jpeglib.h: 沒有此一檔案或目錄
sudo apt-get install libjpeg-dev

fatal error: png.h: 沒有此一檔案或目錄
sudo apt-get install libpng16-dev

fatal error: fftw3.h: 沒有此一檔案或目錄
sudo apt-get install libfftw3-dev

正式安裝
1.
在home建立mpich3資料夾
下載http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
解壓縮到mpich3資料夾
終端機cd /home/mpich3
執行
./configure --prefix=/usr/local --disable-fast CC=gcc CFLAGS=-m64 MPICHLIB_CFLAGS=-O3 --enable-cxx CXX=g++ CXXFLAGS=-m64 MPICHLIB_CXXFLAGS=-O3 --enable-fortran=yes FC=gfortran FCFLAGS=-m64 MPICHLIB_FCFLAGS=-O3 F77=gfortran F77FLAGS=-m64 MPICHLIB_FFLAGS=-O3 --enable-romio

make clean
make
make install

source /home/chiustin/bin/compilervars.sh intel64
export PATH=/home/chiustin/lib/mpich3-intel/bin:$PATH
export LD_LIBRARY_PATH=/home/chiustin/lib/mpich3-intel/lib64:$LD_LIBRARY_PATH

2.
在home建立fftw資料夾
下載http://www.fftw.org/fftw-3.3.6-pl2.tar.gz
解壓縮到mpich3資料夾
終端機cd /home/fftw
執行
./configure --prefix=/home/chiustin/lib/fftw3-intel --enable-shared --enable-sse2 \
--enable-mpi --enable-openmp --enable-threads \
CC=gcc CFLAGS=-m64 F77=gfortran FFLAGS=-m64 MPICC=mpicc

make clean
make
make install

3.
在home建立voro++資料夾
下載http://math.lbl.gov/voro++/download/dir/voro++-0.4.6.tar.gz
解壓縮到voro++資料夾
終端機cd /home/voro++
vi config.mk

# C++ compiler
CXX=g++

# Flags for the C++ compiler
CFLAGS=-Wall -ansi -pedantic -O3

# Relative include and library paths for compilation of the examples
E_INC=-I /home/voro++/src
E_LIB=-L /home/voro++/src

# Installation directory
PREFIX=/home/chiustin/lib/voro++-intel

make clean
make
make install

source /home/chiustin/bin/compilervars.sh intel64
export PATH=/home/chiustin/lib/voro++-intel/bin:${HOME}/lib/fftw3-intel/bin:
/home/chiustin/lib/mpich3-intel/bin:$PATH
export LD_LIBRARY_PATH =${HOME}/lib/voro++-intel/lib:/home/chiustin/lib/fftw3-
intel/lib:/home/chiustin/lib/mpich3-intel/lib64:$LD_LIBRARY_PATH

4.
在home建立lammps資料夾
官網下載lammps-stable.tar.gz
解壓縮到lammps資料夾
vi /home/lammps/src/MAKE/Makefile.serial

# serial = g++ compiler, no MPI
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 -O
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_JPEG -DLAMMPS_PNG

# 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 = -I../STUBS
MPI_PATH = -L../STUBS
MPI_LIB = -lmpi_stubs
# FFT library
# see discussion in Section 2.2 (step 6) of manaul
# 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/usr/include
FFT_PATH = -L/usr/lib64
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 = -I/usr/include -I/usr/include/libpng16
JPG_PATH = -L/usr/lib64
JPG_LIB = -ljpeg -lpng16

5.
cd /home/lammps/src/STUBS
make
產生libmpi_stubs.a

6.
cd /home/lammps/src/
make yes-meam
make yes-voronoi
make yes-class2
make yes-manybody
make yes-kspace
make yes-molecule
make yes-dipole

make package-status 可以看哪些package沒安裝

7.
vi /home/lammps/lib/meam/Makefile.lammps.gfortran

# Settings that the LAMMPS build will import when this package library is used
meam_SYSINC =
meam_SYSLIB = -lgfortran
meam_SYSPATH =

make -f Makefile.gfortran clean
make -f Makefile.gfortran
產生libmeam.a

8.
vi /home/lammps/lib/voronoi/Makefile.lammps

# Settings that the LAMMPS build will import when this package library is used

voronoi_SYSINC = -I/home/voro++/src
voronoi_SYSLIB = -lvoro++
voronoi_SYSPATH = -L/home/voro++/src

9.
cd /home/lammps/src
make serial
有顯示lmp_serial就算成功

也可以參考
http://blog.sciencenet.cn/home.php?mod=space&uid=3675&do=blog&id=1102979
https://www.jianshu.com/p/a0fef427972c
http://plasmaphys.dlut.edu.cn/info/1013/1122.htm







沒有留言:

張貼留言