LAMMPS一键安装shell脚本
2017-08-14 本文已影响0人
Phonon_mode
本脚本仅在 Ubuntu16.04LTS版本下测试,任处于测试版,不保证能用,一键安装LAMMPS
#!/bin/bash
# Program
# 一键安装LAMMPS软件
# 适用于Ubuntu
# History:
# 2017/08/12 LiLiang First release
#
# =================确认执行安装===================
echo "一键安装LAMMPS软件,将所需软件下载到当前目录,fftw, openmpi, Python, zlib, jpeg,\n需要root权限,以sudo运行"
echo "建议将Ubuntu软件源更换为国内源,提高下载速度"
read -p "Do you want to continue? [y/n]" CONFIRM_INSTALL
case ${CONFIRM_INSTALL} in
y|Y|yes|Yes|YES)
echo "Initializing."
;;
n|N|no|No|NO)
exit 0
;;
esac
# 编译使用的内核数,64代表使用64个内核
#read -p "请输入编译使用内核数: " CORE_NUM
echo "开始安装"
# ==========安装编译器及其他所需软件=============
sudo apt-get update
sudo apt-get upgrade
sudo apt-get -y install gcc g++ gfortran make
sudo apt-get -y install tcsh mpich synaptic
sudo apt-get -y install emacs
# 下载所需软件,fftw,openmpi,Python,
read -p "Do you want to download fftw, openmpi, Python, zlib, jpeg from internet? [y/n]" CONFIRM_INSTALL
case ${CONFIRM_INSTALL} in
y|Y|yes|Yes|YES)
wget http://www.fftw.org/fftw-3.3.6-pl2.tar.gz # fftw
wget https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.gz # openmpi
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz # Python
wget http://zlib.net/zlib-1.2.11.tar.gz # zlib
;;
n|N|no|No|NO)
echo "请确认已下载fftw,openmpi,Python,zlib,jpeg,LAMMPS软件到当前文件夹下。"
read
;;
esac
# 解压缩软件包到 /usr/local/src
tar -zxvf ./fftw* -C /usr/local/src
tar -zxvf ./openmpi* -C /usr/local/src
tar -zxvf ./Python* -C /usr/local/src
tar -zxvf ./zlib* -C /usr/local/src
tar -zxvf ./jpeg* -C /usr/local/src
tar -zxvf ./lammps* -C /usr/local/src
# fftw安装 http://www.fftw.org/
cd /usr/local/src/fftw*
./configure
make -j
make install
# openmpi
cd /usr/local/src/openmpi*
./configure
make all install
# Python
cd /usr/local/src/Python*
./configure
make -j
make install
# zlib
cd /usr/local/src/zlib*
./configure
make -j
make install
# jpeg
cd /usr/local/src/jpeg*
./configure
make -j
make install
# ========安装32位支持库============
sudo apt-get -y install libc6-i386
sudo apt-get -y install libncurses5-i386
sudo apt-get -y install libstdctt6-i386
sudo apt-get -y install lib32z1
sudo apt-get -y install mpi-default-bin
sudo apt-get -y install mpi-default-dev
sudo apt-get -y install libfftw3-dev
sudo apt-get -y install libjpeg-dev
sudo apt-get -y install libpng12-dev
# =========编译LAMMPS可预处理包=======
cd /usr/local/src/lammps*
lammps_path=`pwd`
# atc
cd ${lammps_path}/lib/atc
make -f Makefile.g++
# awpmd
cd ${lammps_path}/lib/awpmd
make -f Makefile.mpicc
# colvars
cd ${lammps_path}/lib/colvars
make -f Makefile.g++
# reax
cd ${lammps_path}/lib/reax
make -f Makefile.gfortran
# meam
cd ${lammps_path}/lib/meam
make -f Makefile.gfortran
# poems
cd ${lammps_path}/lib/poems
make -f Makefile.g++
# qmmm
cd ${lammps_path}/lib/qmmm
make -f Makefile.gfortran
# ===========安装依赖包=============
sudo apt-get install g++*
sudo apt-get install mpi-default*
sudo apt-get install libfftw3-dev
# ==========编译LAMMPS==============
cd ${lammps_path}/src
# 添加与删除库
make yes-std
make no-gpu
make no-kim
make no-kokkos
make no-voronoi
make package-status # 列出需要安装的库
# 确认安装
read -p "Do you want to continue? [y/n]" CONFIRM_INSTALL
case ${CONFIRM_INSTALL} in
y|Y|yes|Yes|YES)
echo "INSTALL"
;;
n|N|no|No|NO)
exit 0
;;
esac
# 开始编译
cd MAKE
mv Makefile.mpi Makefile.mpi.bak # 备份 Makefile.mpi
cp ./MACHINES/Makefile.ubuntu ./Makefile.mpi # 复制 Makefile.ubuntu
make mpi # 编译
# 复制到/bin, /usr/bin
sudo cp lmp-mpi /bin
sudo cp lmp-mpi /usr/bin
echo "安装成功!"