#! /bin/bash ######################################################################################################################### ## A. Initialisation ######################################################################################################################### dir=$HOME/ii export dir=$dir ## mkdir ## if [ ! -d $dir ];then mkdir $dir else echo $dir existed. Not making one. fi if [ ! -d $dir/script ];then mkdir $dir/script else echo $dir/script existed. Not making one. fi if [ ! -d $dir/include ];then mkdir $dir/include else echo $dir/include existed. Not making one. fi if [ ! -d $dir/lib ];then mkdir $dir/lib else echo $dir/lib existed. Not making one. fi ######################################################################################################################### ## End of Initialisation ######################################################################################################################### ######################################################################################################################### ## B. Check system prerequisites ######################################################################################################################### rm -rf $dir/script/prerequisite_sys.log for i in tar make gcc g++ gfortran python-config; do # sudo apt-get install gcc gfortran python-dev str=$(which $i) if [ ! "$str" ];then echo $i not found. Prerequisite not met. Abort installation. echo Please install $i manually and retry running this script. echo $i not found. Prerequisite not met. Abort installation. > $dir/script/prerequisite_sys.log echo Please install $i manually and retry running this script. >> $dir/script/prerequisite_sys.log exit else echo $i found fi done echo 'System prerequisites met.' echo 'System prerequisites met.' >> $dir/script/prerequisite_sys.log ## Install it manually as root if system libraries not found. ######################################################################################################################### ## End of Check system prerequisites ######################################################################################################################### ######################################################################################################################### ## C. Check and install prerequisite libraries if not existed ######################################################################################################################### ## 1. openmpi-1.8.5 if [ -f $dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 ];then echo $dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 found. Not to install them. else echo $dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 NOT found. To install them. cd $dir/configrepo rm -rf openmpi-1.8.5.tar.gz wget http://www2.fizik.usm.my/configrepo/howto/openmpi/openmpi-1.8.5.tar.gz tar -zxvf openmpi-1.8.5.tar.gz cd openmpi-1.8.5 ./configure --prefix=$dir/openmpi-1.8.5 --disable-dlopen make make install fi ## 2. fftw-3.3.4 if [ -f $dir/fftw-3.3.4/lib/libfftw3f.a ];then echo $dir/fftw-3.3.4/lib/libfftw3f.a found. Not to install them. else echo $dir/fftw-3.3.4/lib/libfftw3f.a NOT found. To install them. cd $dir/configrepo rm -rf fftw-3.3.4.tar.gz wget http://www2.fizik.usm.my/configrepo/howto/fftw/fftw-3.3.4.tar.gz tar -zxvf fftw-3.3.4.tar.gz cd fftw-3.3.4 ./configure --with-g77-wrappers --enable-mpi --enable-threads --enable-openmp CXX="$dir/openmpi-1.8.5/bin/mpicxx" CC="$dir/openmpi-1.8.5/bin/mpicc" CPP="$dir/openmpi-1.8.5/bin/mpic++ -E" CXXCPP="$dir/openmpi-1.8.5/bin/mpicxx -E" FC='gfortran' --prefix=$dir/fftw-3.3.4 Fi77=gfortran FFLAGS="-I/$dir/openmpi-1.8.5/include" LDFLAGS=-L/$dir/openmpi-1.8.5/lib CPPFLAGS="-I/$dir/openmpi-1.8.5/include" --enable-shared --enable-float make -j 4 make install make check # optional #make installcheck # optional fi ## 3. blas-3.7.0 if [ -f $dir/lib/libblas.a ];then echo $dir/lib/libblas.a found. Not to install them. else echo $dir/lib/libblas.a NOT found. To install them. cd $dir/configrepo rm -rf blas-3.7.0.tgz wget http://www.netlib.org/blas/blas-3.7.0.tgz tar -xzvf blas-3.7.0.tgz cd BLAS-3.7.0 gfortran -c -O3 *.f ar rv libblas.a *.o cp $dir/configrepo/BLAS-3.7.0/libblas.a $dir/lib/ fi ## 4. lapack-3.7.0 if [ -f $dir/lib/liblapack.a ];then echo $dir/lib/liblapack.a found. Not to install them. else echo $dir/lib/liblapack.a NOT found. To install them. cd $dir/configrepo rm -rf lapack-3.7.0.tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/BLAS_and_LAPACK/lapack-3.7.0.tgz tar -xzvf lapack-3.7.0.tgz cd lapack-3.7.0 which g77 || sed -i -e 's/g77/gfortran/' make.inc ulimit -s unlimited make tmglib blaslib cblaslib lapack_install lapacklib -j 4 #make lapack_testing ## optional ## cd TESTING; make ### execute this line if want to perform testing on the lapack library installed. cp $dir/configrepo/lapack-3.7.0/*.a $dir/lib/ fi ######################################################################################################################### ## End of Check and install prerequisite libraries if not existed ######################################################################################################################### ######################################################################################################################### #### D. Check whether installation of prerequisite libraries is successfull ########## ######################################################################################################################### rm -rf $dir/script/prerequisite.log if [ -f $dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 ] && [ -f $dir/fftw-3.3.4/lib/libfftw3f.a ] && [ -f $dir/lib/libblas.a ] && [ -f $dir/lib/liblapack.a ];then echo Checked that ALL prerequisite libraries are found echo Checked that ALL prerequisite libraries are found >> $dir/script/prerequisite.log else echo Checked that NOT ALL prerequisite libraries are found echo Checked that NOT ALL prerequisite libraries are found >> $dir/script/prerequisite.log fi ######################################################################################################################### ## End of Check and install prerequisite libraries if not existed ######################################################################################################################### ######################################################################################################################### ## E. Install lammps ######################################################################################################################### if [ ! -f $dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 ] && [ ! -f $dir/fftw-3.3.4/lib/libfftw3f.a ] && [ ! -f $dir/lib/libblas.a ] && [ ! -f $dir/lib/liblapack.a ];then echo Prerequisite libraries not met even after ./prerequisite.sh. To exit installation. exit else cd $dir/script rm -rf inst_lammps_5May15.txt wget http://comsics.usm.my/tlyoon/configrepo/howto/ii/script/inst_lammps_5May15.txt chmod +x inst_lammps_5May15.txt ./inst_lammps_5May15.txt fi