#!/bin/bash
#build-tools
sudo apt-get install gcc g++ gfortran python -y
#sudo apt-get install gcc g++ gfortran python ctags vim -y
#sudo apt-get install mpich -y
sudo apt-get install git wget -y
# peridigm依赖包
sudo apt-get update
sudo apt-get install zlib1g-dbg zlib1g-dev -y
sudo apt-get install libcurlpp-dev libflickcurl-dev -y
sudo apt-get install libblas-dev -y
sudo apt-get install liblapack-dev -y
sudo apt-get install mpich -y
sudo apt-get install libx11-dev -y
sudo apt-get install libxext-dev -y
sudo apt-get install libxtst-dev libxrender-dev libxmu-dev libxmuu-dev -y
#Install yaml-cpp-dev
sudo apt-get install libyaml-cpp-dev -y
#########################################################################
#Bulding OpenMPI 3.0.0
home=$HOME
openmpi_path="openmpi-3.0.0"
cd
cd package
#wget https://download.open-mpi.org/release/open-mpi/v3.0/openmpi-3.0.0.tar.gz
tar -xvf openmpi-3.0.0.tar.gz
cd $openmpi_path
mkdir -p build
cd build
pwd
echo "config_openmpi**********************************"
../configure --prefix=$home/local/openmpi
make -j8
make install
#########################################################################
#导入环境变量
#环境变量的生存周期为:直到关闭终端,并不永久生效
export CC=$home/local/openmpi/bin/mpicc
export CXX=$home/local/openmpi/bin/mpicxx
export CF=$home/local/openmpi/bin/mpif90
export FC=$home/local/openmpi/bin/mpif90
export F77=$home/local/openmpi/bin/mpif77
export LIBRARY_PATH=$home/local/openmpi/lib/:${
LIBRARY_PATH}
export PATH=$home/local/openmpi/bin/:$PATH
#Bullding Boost 1.58.0
echo "Boost Start>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
cd
cd package
#wget https://dl.bintray.com/boostorg/release/1.58.0/source/boost_1_58_0.tar.gz
tar -xvf boost_1_58_0.tar.gz
cd boost_1_58_0
echo "using mpi ;" >> user-config.jam
./bootstrap.sh --prefix=$home/local/boost
./b2 --layout=tagged -j
./b2 install
#########################################################################
#Building HDF5 (hdf5-1.8.16-patch1)
cd
cd package
#wget https://launchpadlibrarian.net/251920078/hdf5_1.8.16+docs.orig.tar.gz
tar -xvf hdf5-1.8.16.tar.gz
cd hdf5-1.8.16
mkdir build -p
cd build
../configure --prefix=$home/local/hdf5 --enable-parallel
make -j8
#make test
make install
#########################################################################
#Building NETCDF (netcdf-4.3.3.1)
sudo apt-get install m4 -y
cd
cd package
#wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-cxx4-4.3.1.tar.gz
tar -xvf netcdf-4.3.3.1.tar.gz
cd netcdf-4.3.3.1
H5DIR="$home/local/hdf5-1.8.15"
export CPPFLAGS=-I${
H5DIR}/include/
export LDFLAGS=-L${
H5DIR}/lib/
# Configure NetCDF
mkdir build -p
cd build
pwd
../configure --prefix=$home/local/netcdf --disable-netcdf-4 --disable-dap --enable-parallel
make -j8
make install
#########################################################################
#Building Trilions (trilinos-12.12.1)
#新装系统shell的系统资源限制为1024,编译过程中会出现文件过多的提示
ulimit -n 65535
trilinos_path=Trilinos-trilinos-release-12-6-4
cd
cd package
#wget https://github.com/trilinos/Trilinos/archive/trilinos-release-12-6-4.tar.gz
tar -xvf trilinos-12.12.1-Source.tar.gz
cd trilinos-12.12.1-Source
mkdir build -p
cd build
rm -rf CMakeCache.txt CMakeFiles
#配置Trilions
cmake \
-D CMAKE_INSTALL_PREFIX:PATH=$home/local/trilinos \
-D MPI_BASE_DIR:PATH="$home/local/openmpi/" \
-D CMAKE_CXX_FLAGS:STRING="-O2 -std=c++11 -pedantic -ftrapv -Wall -Wno-long-long" \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
-D Trilinos_WARNINGS_AS_ERRORS_FLAGS:STRING="" \
-D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
-D BUILD_SHARED_LIBS:BOOL=ON \
-D Trilinos_ENABLE_Fortran:BOOL=ON \
-D Trilinos_ENABLE_Teuchos:BOOL=ON \
-D Trilinos_ENABLE_Shards:BOOL=ON \
-D Trilinos_ENABLE_Sacado:BOOL=ON \
-D Trilinos_ENABLE_Epetra:BOOL=ON \
-D Trilinos_ENABLE_EpetraExt:BOOL=ON \
-D Trilinos_ENABLE_Ifpack:BOOL=ON \
-D Trilinos_ENABLE_AztecOO:BOOL=ON \
-D Trilinos_ENABLE_Amesos:BOOL=ON \
-D Trilinos_ENABLE_Anasazi:BOOL=ON \
-D Trilinos_ENABLE_Belos:BOOL=ON \
-D Trilinos_ENABLE_ML:BOOL=ON \
-D Trilinos_ENABLE_Phalanx:BOOL=ON \
-D Trilinos_ENABLE_Intrepid:BOOL=ON \
-D Trilinos_ENABLE_NOX:BOOL=ON \
-D Trilinos_ENABLE_Stratimikos:BOOL=ON \
-D Trilinos_ENABLE_Thyra:BOOL=ON \
-D Trilinos_ENABLE_Rythmos:BOOL=ON \
-D Trilinos_ENABLE_MOOCHO:BOOL=ON \
-D Trilinos_ENABLE_TriKota:BOOL=OFF \
-D Trilinos_ENABLE_Stokhos:BOOL=ON \
-D Trilinos_ENABLE_Zoltan:BOOL=ON \
-D Trilinos_ENABLE_Piro:BOOL=ON \
-D Trilinos_ENABLE_Teko:BOOL=ON \
-D Trilinos_ENABLE_SEACASIoss:BOOL=ON \
-D Trilinos_ENABLE_SEACAS:BOOL=ON \
-D Trilinos_ENABLE_SEACASBlot:BOOL=ON \
-D Trilinos_ENABLE_Pamgen:BOOL=ON \
-D Trilinos_ENABLE_EXAMPLES:BOOL=OFF \
-D Trilinos_ENABLE_TESTS:BOOL=ON \
-D TPL_ENABLE_Matio=OFF \
-D TPL_ENABLE_HDF5:BOOL=ON \
-D HDF5_INCLUDE_DIRS:PATH=$home/local/hdf5/include/ \
-D HDF5_LIBRARY_DIRS:PATH=$home/local/hdf5/lib/ \
-D TPL_ENABLE_Netcdf:BOOL=ON \
-D Netcdf_INCLUDE_DIRS:PATH=$home/local/netcdf/include/ \
-D Netcdf_LIBRARY_DIRS:PATH=$home/local/netcdf/lib/ \
-D TPL_ENABLE_MPI:BOOL=ON \
-D TPL_ENABLE_BLAS:BOOL=ON \
-D TPL_BLAS_LIBRATIES:FILEPATH=/usr/lib/libblas.so \
-D TPL_ENABLE_LAPACK:BOOL=ON \
-D TPL_LAPACK_LIBRATIES:FILEPATH=/usr/lib/liblapack.so \
-D TPL_ENABLE_Boost:BOOL=ON \
-D Boost_INCLUDE_DIRS:PATH=$home/local/boost/include/ \
-D Boost_LIBRARY_DIRS:PATH=$home/local/boost/lib/ \
-D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF \
-D Trilinos_VERBOSE_CONFIGURE:BOOL=OFF \
-D TPL_ENABLE_Zlib:BOOL=ON \
-D TPL_ENABLE_yaml-cpp:BOOL=ON \
$home/package/trilinos-12.12.1-Source/
make -j8
make install
#########################################################################
#Building Peridigm (1.4.1)
ulimit -n 65535
cd
cd package
pwd
#git clone https://github.com/peridigm/peridigm.git
unzip peridigm-master
peridigm_name=peridigm-master
cd $peridigm_name
mkdir -p build
cd build
pwd
#配置 安装Peridim
#配置安装路径为$home/local
#-D CMAKE_INSTALL_PREFIX:PATH=$home/local/peridigm \
cmake \
-D CMAKE_BUILD_TYPE:STRING=Release \
-D Boost_NO_SYSTEM_PATHS=ON \
-D Trilinos_DIR:PATH=$home/local/trilinos/lib/cmake/Trilinos/ \
-D CMAKE_CXX_COMPILER=$home/local/openmpi/bin/mpicxx \
-D CMAKE_C_COMPILER=$home/local/openmpi/bin/mpicc \
-D BOOST_ROOT=$home/local/boost/ \
-D CMAKE_CXX_FLAGS:STRING="-O2 -Wall -ansi -pedantic -Wno-long-long -ftrapv -Wno-deprecated -std=gnu++11 " \
$home/package/$peridigm_name/
make -j8
sudo make install
#更改环境变量
cd
#备份.bashrc
cp .bashrc .bashrc_backup
#在.bashrc末尾追加环境变量
echo "
export LD_LIBRARY_PATH=$home/local/openmpi/lib/:$home/local/openmpi/lib/:$LD_LIBRARY_PATH
export LIBRARY_PATH=$home/local/openmpi/lib/:$home/local/openmpi/lib/:$LIBRARY_PATH
" >> .bashrc
source .bashrc
#添加全局环境变量 --当把peridigm的安装路径设置为$home/local时,把下面的注释去掉
#sudo echo "
#export PATH=$PATH:$home/local/bin
#" >> /etc/bash.bashrc
#2020年 01月 24日 星期五 15:37:48 CST
为了方便需要的朋友,已经将peridigm需要的依赖包、分段脚本、遇到的问题打包成压缩包,下载地址:添加链接描述