#! /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 if [ ! -d $dir/bin ];then mkdir $dir/bin else echo $dir/bin existed. Not making one. fi rm -rf $dir/script/$fn.lib rm -rf $dir/script/"$fn"var.txt rm -rf $dir/script/$fn.log echo 'export LD_LIBRARY_PATH='$dir/lib':$LD_LIBRARY_PATH' >> $dir/script/"$fn"var.txt echo 'export PATH='$dir/bin':$PATH' >> $dir/script/"$fn"var.txt echo ' ' ######################################################################################################################### ## End of A. Initialisation ######################################################################################################################### ######################################################################################################################### ## B. Check system prerequisites ######################################################################################################################### declare -a ps=(make gcc g++ gfortran) 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 ######################################################################################################################### ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## 1. blas-3.7.0 #### libname2install=blas-3.7.0 libfile2check=libblas.a #### checklib=$dir/lib/$libfile2check 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. echo To install $checklib >> $dir/script/$fn.log cd $dir/configrepo rm -rf $libname2install.tgz wget http://www.netlib.org/blas/blas-3.7.0.tgz tar -xzvf $libname2install.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 source $dir/script/"$fn"var.txt ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## 2. lapack-3.7.0 #### libname2install=lapack-3.7.0 libfile2check=liblapack.a #### checklib=$dir/lib/$libfile2check 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. echo To install $checklib >> $dir/script/$fn.log cd $dir/configrepo rm -rf $libname2install.tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/BLAS_and_LAPACK/lapack-3.7.0.tgz tar -xzvf $libname2install.tgz cd $libname2install 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 source $dir/script/"$fn"var.txt ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## 3. openmpi-2.1.1 #### libname2install=openmpi-2.1.1 libfile2check=libmpi.so #### checklib=$dir/$libname2install/lib/$libfile2check 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. echo To install $checklib >> $dir/script/$fn.log cd $dir/configrepo rm -rf $libname2install.tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/openmpi/openmpi-2.1.1.tgz tar -zxvf $libname2install.tgz cd $libname2install ./configure --prefix=$dir/$libname2install --disable-dlopen make make install fi echo 'export LD_LIBRARY_PATH='$dir/$libname2install/lib':$LD_LIBRARY_PATH' >> $dir/script/"$fn"var.txt echo 'export PATH='$dir/$libname2install/bin':$PATH' >> $dir/script/"$fn"var.txt source $dir/script/"$fn"var.txt ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## 4. fftw-3.3.6 #### libname2install=fftw-3.3.6 libfile2check=libfftw3.a #### checklib=$dir/$libname2install/lib/$libfile2check 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. echo To install $checklib >> $dir/script/$fn.log cd $dir/configrepo rm -rf libname2install.tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/fftw/fftw-3.3.6.tgz tar -zxvf fftw-3.3.6.tgz cd fftw-3.3.6-pl2 # export LD_LIBRARY_PATH=/home/tlyoon/ii/openmpi-1.8.5/lib:$LD_LIBRARY_PATH # export PATH=/home/tlyoon/ii/openmpi-1.8.5/bin:$PATH ./configure --prefix=$dir/$libname2install --with-g77-wrappers --enable-mpi --enable-threads --enable-openmp CC="cc" FC="mpif90" make -j 4 make install # make check # optional #make installcheck # optional fi echo 'export LD_LIBRARY_PATH='$dir/$libname2install/lib':$LD_LIBRARY_PATH' >> $dir/script/"$fn"var.txt echo 'export PATH='$dir/$libname2install/bin':$PATH' >> $dir/script/"$fn"var.txt source $dir/script/"$fn"var.txt ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ## 5. python-2.7.13 #### libname2install=python-2.7.13 libfile2check=libpython2.7.a #### checklib=$dir/$libname2install/lib/$libfile2check 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. echo To install $checklib >> $dir/script/$fn.log cd $dir/configrepo rm -rf Python-2.7.13.tgz wget http://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz tar zxfv Python-2.7.13.tgz find $dir/configrepo -type d | xargs chmod 0755 cd Python-2.7.13 ./configure --prefix=$dir/python-2.7.13 make make install fi echo 'export LD_LIBRARY_PATH='$dir/$libname2install/lib':$LD_LIBRARY_PATH' >> $dir/script/"$fn"var.txt echo 'export PATH='$dir/$libname2install/bin':$PATH' >> $dir/script/"$fn"var.txt source $dir/script/"$fn"var.txt ## &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ## ######################################################################################################################### ## End of C. Check and install prerequisite libraries if not existed ######################################################################################################################### ######################################################################################################################### #### D. Determine whether any 'NOT' keyword appears in $dir/script/$fn.log ########## ######################################################################################################################### ## 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 ' ' ######################################################################################################################### #### D. Determine whether any 'NOT' keyword appears in $dir/script/$fn.log ########## ######################################################################################################################### ######################################################################################################################### ## 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 # &&&&&&&&&&& Add a line of 'source '$dir/script/"$fn"var.txt in $HOME/.bashrc for $USER &&&&&&&&&&&&&& # if grep -q 'source '$dir/script/"$fn"var.txt "$HOME/.bashrc"; then echo 'source '$dir/script/"$fn"var.txt already added to $HOME/.bashrc >> $dir/script/$fn.log echo 'source '$dir/script/"$fn"var.txt already added to $HOME/.bashrc else echo source $dir/script/"$fn"var.txt has not been added to $HOME/.bashrc. To add it now. >> $dir/script/$fn.log echo source $dir/script/"$fn"var.txt has not been added to $HOME/.bashrc. To add it now. echo '## Line added by ii ' >> $HOME/.bashrc echo 'source '$dir/script/"$fn"var.txt >> $HOME/.bashrc fi # &&&&&&&&&&& end of Add a line of 'source '$dir/script/"$fn"var.txt in $HOME/.bashrc for $USER &&&&&&&&&&&&&& # #****************** begin installation of fn **************************************************************************** cd $dir/configrepo if [ -f "$fn".tgz ];then filesize=$(ls -la "$fn".tgz | awk '{print $5}') if [ $filesize == 25382622 ]; then #### provide the original file size of $fn.tgz echo "$fn".tgz is present and file size tallies in $dir/configrepo. Proceed without downloading. >> $dir/script/$fn.log cat $dir/script/$fn.log else echo "$fn".tgz is present but file size fails to tally in $dir/configrepo. Proceed with downloading. >> $dir/script/$fn.log cat $dir/script/$fn.log rm -rf "$fn".tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/ii/lammps_5May15.tgz fi else echo "$fn".tgz is absent in $dir/configrepo. Proceed with downloading. >> $dir/script/$fn.log cat $dir/script/$fn.log rm -rf "$fn".tgz wget http://comsics.usm.my/tlyoon/configrepo/howto/ii/lammps_5May15.tgz fi cd $dir rm -rf "$fn" tar -zxvf configrepo/"$fn".tgz cd "$fn" 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 clean-gnu make yes-all make no-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 make no-user-cuda make no-gpu rm -rf lmp_gnu make gnu if [ -f lmp_gnu ];then rm -rf lmp_ii ln -s lmp_gnu lmp_ii ln -s lmp_gnu lmp_ggpu rm -rf $dir/bin/lmp_ii ln -s $mylammpsdir/src/lmp_ii $dir/bin/ rm -rf $dir/bin/lmp_ggpu ln -s $mylammpsdir/src/lmp_ggpu $dir/bin/ echo intstant installation for $fn completed. >> $dir/script/$fn.log echo instant installation for $fn completed else echo lmp_gnu not found. intstant installation for $fn failed. >> $dir/script/$fn.log echo lmp_gnu not found. intstant installation for $fn failed. fi #****************** end installation of fn **************************************************************************** fi ######################################################################################################################### ## end of E. Install fn #########################################################################################################################