#! /bin/bash ######################################################################################################################### ## Name of this file. fn must be in the same name as this file, without the .ii.txt suffix. fn=lammps_5May15 ######################################################################################################################### ######################################################################################################################### ## 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 if [ ! -d $dir/configrepo ];then mkdir $dir/configrepo else echo $dir/configrepo existed. Not making one. fi echo ' ' ######################################################################################################################### ## End of A. Initialisation ######################################################################################################################### ######################################################################################################################### ## B. Check system prerequisites ######################################################################################################################### declare -a ps=(make gcc g++ gfortran) rm -rf $dir/script/$fn.log for i in ${ps[@]}; do str=$(which $i) if [ ! "$str" ];then echo $i NOT found. Please install $i manually as root or sudo, then retry running this script. >> $dir/script/$fn.log else echo $i found. >> $dir/script/$fn.log fi done if grep -q 'NOT' "$dir/script/$fn.log"; then echo 'System prerequisites NOT met. To abort.' >> $dir/script/$fn.log cat $dir/script/$fn.log exit else echo 'System prerequisites met. To continue.' >> $dir/script/$fn.log # cat $dir/script/$fn.log fi echo ' ' ######################################################################################################################### ## End of B. Check system prerequisites ######################################################################################################################### ######################################################################################################################### ## C. Check and install prerequisite libraries if not existed ######################################################################################################################### rm -rf $dir/script/$fn.lib ## 1. openmpi-1.8.5 checklib=$dir/openmpi-1.8.5/lib/libmpi.so.1.6.0 echo $checklib >> $dir/script/$fn.lib if [ -f $checklib ];then echo $checklib found. Not to install them. else echo $checklib 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 checklib=$dir/fftw-3.3.4/lib/libfftw3f.a echo $checklib >> $dir/script/$fn.lib if [ -f $checklib ];then echo $checklib found. Not to install them. else echo c$hecklib 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 --prefix=/home/$USER/ii/fftw-3.3.4 --with-g77-wrappers --enable-mpi --enable-threads --enable-openmp CXX="/home/$USER/ii/openmpi-1.8.5/bin/mpicxx" CC="/home/$USER/ii/openmpi-1.8.5/bin/mpicc" CPP="/home/$USER/ii/openmpi-1.8.5/bin/mpic++ -E" CXXCPP="/home/$USER/ii/openmpi-1.8.5/bin/mpicxx -E" FC='gfortran' F77=gfortran FFLAGS="-I/$USER/ii/openmpi-1.8.5/include" LDFLAGS="-L/$USER/ii/openmpi-1.8.5/lib" CPPFLAGS="-I/$USER/ii/openmpi-1.8.5/includ"e --enable-shared --enable-float make -j 4 make install make check # optional #make installcheck # optional fi ## 3. blas-3.7.0 checklib=$dir/lib/libblas.a echo $checklib >> $dir/script/$fn.lib if [ -f $checklib ];then echo $checklib found. Not to install them. else echo $checklib 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 checklib=$dir/lib/liblapack.a echo $checklib >> $dir/script/$fn.lib if [ -f $checklib ];then echo $checklib found. Not to install them. else echo $checklib 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 ## 5. python-2.7.2 checklib=$dir/python-2.7.2/lib/libpython2.7.a echo $checklib >> $dir/script/$fn.lib if [ -f $checklib ];then echo $checklib found. Not to install them. else echo $checklib NOT found. To install them. cd $dir/configrepo rm -rf Python-2.7.2.tgz wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz tar zxfv Python-2.7.2.tgz find $dir/configrepo -type d | xargs chmod 0755 cd Python-2.7.2 ./configure --prefix=$dir/python-2.7.2 make make install fi echo ' ' ######################################################################################################################### ## End of C. Check and install prerequisite libraries if not existed ######################################################################################################################### ######################################################################################################################### #### D. Check whether installation of prerequisite libraries is successfull ########## ######################################################################################################################### ##echo $dir/ii/lib/gnuplot.a >> $dir/script/$fn.lib ## for trouble shooting for i in $(cat $dir/script/$fn.lib) do if [ -f $i ]; then echo $i found >> $dir/script/$fn.log else echo $i NOT found >> $dir/script/$fn.log fi done echo ' ' ######################################################################################################################### ## End of D. Check and install prerequisite libraries if not existed ######################################################################################################################### ######################################################################################################################### ## E. Install $fn ######################################################################################################################### if grep -q 'NOT' "$dir/script/$fn.log"; then echo 'NOT all prerequisite libraries are found for' $fn. To abort installation. >> $dir/script/$fn.log cat $dir/script/$fn.log exit else echo 'All prerequisite libraries are found for' $fn. To continue installation. >> $dir/script/$fn.log cat $dir/script/$fn.log #****************** begin installation of fn **************************************************************************** ## Install lammps (version xxx) ## Mandatory requirements: ## $dir/openmpi-1.8.5 ## $dir/fftw-3.3.4 ## -L/$dir/lib/ -llapack -lblas ## $dir/python-2.7.2 export PATH=$dir/python-2.7.2/bin:$PATH cd $dir/ # rm -rf lammps_5May15.tgz # wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/lammps/lammps_5May15.tgz tar -zxvf lammps_5May15.tgz mv lammps_5May15.tgz configrepo cd lammps_5May15 mylammpsdir=$(echo $PWD) # atc # cd $mylammpsdir/lib cd atc rm -f *.a *.o make -f Makefile.mpic++ # awpmd # cd $mylammpsdir/lib/awpmd make -f Makefile.mpicc # linalg # cd $mylammpsdir/lib/linalg rm -f *.a *.o make -f Makefile.gfortran # gpu ## Make only if NVIDIA CUDA is available on the machine cd $mylammpsdir/lib if [ -d "$mylammpsdir/lib/gpu" ];then cd gpu echo 'I am in gpu/' str=$(which nvcc) if [ ! "$str" ];then echo 'make no gpu' echo str= $str else echo 'make gpu' rm -f *.a *.o make -f Makefile.linux.double fi fi # cuda ## Make only if NVIDIA CUDA is available on the machine cd $mylammpsdir/lib if [ -d "$mylammpsdir/lib/cuda" ];then cd gpu echo 'I am in cuda/' str=$(which nvcc) if [ ! "$str" ];then echo 'make no cuda' echo str= $str else echo 'make cuda' rm -f *.a *.o make fi fi # meam # cd $mylammpsdir/lib cd meam rm -f *.a *.o make -f Makefile.gfortran # poems # cd $mylammpsdir/lib cd poems rm -f *.a *.o make -f Makefile.g++ # reax # cd $mylammpsdir/lib/reax rm -f *.a *.o make -f Makefile.gfortran # qmmm # cd $mylammpsdir/lib/qmmm rm -f *.a *.o make -f Makefile.gfortran # colvars # cd $mylammpsdir/lib/colvars rm -f *.a *.o make -f Makefile.g++ # voronoi # cd $mylammpsdir/lib/voronoi rm -rf includelink liblink python install.py -d ~/ii/configrepo/voronoi-build -g -b -i ~/ii/voronoi rm -rf includelink ln -s $dir/voronoi/include/voro++ includelink cd $mylammpsdir/src make yes-all make yes-voronoi make no-kim make no-user-quip make no-kokkos # gpu ## Make only if NVIDIA CUDA is available on the machine if [ -d "$mylammpsdir/lib/gpu" ];then str=$(which nvcc) if [ ! "$str" ];then make no-gpu else make yes-gpu fi fi # cuda ## Make only if NVIDIA CUDA is available on the machine if [ -d "$mylammpsdir/lib/cuda" ];then str=$(which nvcc) if [ ! "$str" ];then make no-user-cuda else make yes-user-cuda fi fi rm -rf lmp_gnu make gnu ln -s lmp_gnu lmp_ii ln -s $mylammpsdir/src/lmp_gnu $dir/bin/lmp_ii #****************** end installation of fn **************************************************************************** fi ######################################################################################################################### ## end of E. Install fn #########################################################################################################################