#! /bin/bash #### Mandatory requirements: intel parallel_studio_xe_2015 or above and ifftw3 have been installed #### 1. libz-dev is installed. Else install it using # apt-get install libz-dev ###### automatically sourcing intel parallel studio ########################## # Assiming intel parallel studio has been installed, the following script extracts automatically intel path automatically in a machine. Tested for intel parallel studio XE 2017 # this package should be included in any installation of package that would make use of intel compilers # Mandatory for this script to work: libfftw3xf_intel.a is found in $MKLROOT/lib/intel64/ #### 2. source $(locate compilervars.sh | awk 'NR==1') intel64 source $(locate mpivars.sh | awk 'NR==1') intel64 source $(locate mklvars.sh | awk 'NR==1') intel64 echo '$MKLROOT=' $MKLROOT mklroot=$(echo $MKLROOT) echo 'mklroot=' $mklroot #### wifort=$(which ifort) echo $wifort ifortpath=$(echo $wifort | awk -F "/ifort" '{print $1}') echo $ifortpath intelbinpath=$(echo $wifort | awk -F "/intel64/ifort" '{print $1}') echo $intelbinpath source $intelbinpath/compilervars.sh intel64 source $intelbinpath/compilervars_global.sh intel64 mklroot=$(echo $MKLROOT) echo $MKLROOT wmpiifort=$(which mpiifort) echo $wmpiifort mpibinpath=$(echo $wmpiifort | awk -F "/mpiifort" '{print $1}') echo $mpibinpath mpipath=$(echo $wmpiifort | awk -F "/bin/mpiifort" '{print $1}') echo $mpipath mpilibpath=$(echo $wmpiifort | awk -F "/bin/mpiifort" '{print $1}')/lib echo $mpilibpath mpiincpath=$(echo $wmpiifort | awk -F "/bin/mpiifort" '{print $1}')/include echo $mpiincpath source $mpibinpath/mpivars.sh intel64 ###### end of automatically sourcing intel parallel studio ########################## #3. install lammps in ~/share/apps mkdir ~/share mkdir ~/share/apps mkdir ~/share/apps/configrepo #4. cd ~/share/apps/configrepo mkdir lammps-16Mar18 cd lammps-16Mar18 filesize=$(ls -la stable.zip | awk '{print $5}') if [ "$filesize" -eq 98837930 ]; then echo 'found stable.zip with the right size =' $filesize'. Not to wget it from the cloud' else echo 'found stable.zip with the wrong size =' $filesize'. To wget it from the cloud' echo "$filesize" rm -rf stable.zip wget https://www.dropbox.com/s/5vpk14vj7qg0ie8/stable.zip?dl=0 -O stable.zip fi ### wget http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/lammps/lammps-16Mar18/stable.zip ### Note that the date for stable version is to be updated from time to time #5. cd ~/share/apps; unzip configrepo/lammps-16Mar18/stable.zip mv lammps-stable lammps-16Mar18; cd lammps-16Mar18/ #6. cd lib/atc rm -f *.a *.o ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.icc filetomod=Makefile.icc keyword=fPIC # backup orig $filetomod copy cp $filetomod $filetomod'.orig' ### target line number to be replaced #lineno=$(cat $filetomod | awk -v keyword=$keyword '/keyword/ {print NR}') lineno=$(cat $filetomod | awk -v keyword=$keyword '$0 ~ keyword {print NR}') #echo $lineno ### end of target line number to be replaced #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') #echo $os #### end of original target string #### modified string ## s2a='-I/opt/intel/impi_latest/include64' s2a='-I'$mpiincpath ns=$os' '$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod ## end of !!!!!!!!!!!!!!!!!!!! to modify Makefile.icc ## To modify Makefile.lammps.installed so that it is pointing to mkl library cp Makefile.lammps.installed Makefile.lammps.installed.orig ###################### #cat <outfile.txt #user-atc_SYSINC = -I/opt/intel/mkl/include #user-atc_SYSLIB = -L/opt/intel/mkl/lib/intel64 #-lblas -llapack #user-atc_SYSPATH = -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core ## -lmkl_lapack95_lp64 #EOF ################ line1='user-atc_SYSINC = -I/opt/intel/mkl/include' line2='user-atc_SYSLIB = -L/opt/intel/mkl/lib/intel64 #-lblas -llapack' line3='user-atc_SYSPATH = -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core ## -lmkl_lapack95_lp64' cat <outfile.txt $line1 $line2 $line3 EOF ################# mv outfile.txt Makefile.lammps.installed echo 'Makefile.lammps.installed in' $PWD modified to point to mkl library ## end of To modify Makefile.lammps.installed so that it is pointing to mkl library make -f $filetomod #7. cd ../awpmd rm -f *.a *.o ## To modify Makefile.lammps.installed so that it is pointing to mkl library cp Makefile.lammps.installed Makefile.lammps.installed.orig ################# line1='user-awpmd_SYSINC = -I$(MKLROOT)/include' line2='user-awpmd_SYSPATH = -L$(MKLROOT)/lib/intel64' line3='user-awpmd_SYSLIB = -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core ## -lmkl_lapack95_lp64' cat <outfile.txt $line1 $line2 $line3 EOF ################# #cat <outfile.txt #user-awpmd_SYSINC = -I$(MKLROOT)/include #user-awpmd_SYSPATH = -L$(MKLROOT)/lib/intel64 #user-awpmd_SYSLIB = -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core ## -lmkl_lapack95_lp64 #EOF mv outfile.txt Makefile.lammps.installed echo 'Makefile.lammps.installed in' $PWD modified to point to mkl library ## end of To modify Makefile.lammps.installed so that it is pointing to mkl library make -f Makefile.mpicc #8. linalg # cd ../linalg rm -f *.a *.o ## To modify Makefile.mpi so that it is using mpiifort filetomod=Makefile.mpi keyword=mpifort ## backup orig $filetomod copy cp $filetomod $filetomod'.orig' ### target line number to be replaced lineno=$(cat $filetomod | awk -v keyword=$keyword '$0 ~ keyword {print NR}') #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') #echo $os #### end of original target string #### modified string s2a='FC = mpiifort' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod ## end of To modify Makefile.mpi so that it is using mpiifort make -f Makefile.mpi #9. meam # cd ../meam rm -f *.a *.o ## To modify Makefile.lammps.ifort so that it is pointing to the right mkl library targetf=Makefile.lammps.ifort cp $targetf $targetf'.orig' #cat <outfile.txt #meam_SYSINC = -I$(MKLROOT)/include #meam_SYSLIB = -lifcore -lsvml -liompstubs5 -limf -lintlc #-lompstub #meam_SYSPATH = -L$(MKLROOT)/lib/intel64 -L/opt/intel/lib/intel64 #-L/opt/intel/fce/10.0.023/lib #EOF ################# line1='meam_SYSINC = -I$(MKLROOT)/include' line2='meam_SYSLIB = -lifcore -lsvml -liompstubs5 -limf -lintlc #-lompstub' line3='meam_SYSPATH = -L$(MKLROOT)/lib/intel64 -L/opt/intel/lib/intel64 #-L/opt/intel/fce/10.0.023/lib' cat <outfile.txt $line1 $line2 $line3 EOF ################# mv outfile.txt $targetf echo $targetf 'in' $PWD is modified to point to mkl library ## end of To modify Makefile.lammps.ifort so that it is pointing to the right mkl library make -f Makefile.ifort #10. poems # cd ../poems rm -f *.a *.o make -f Makefile.icc #11. reax # cd ../reax rm -f *.a *.o make -f Makefile.ifort # 12. qmmm #### has to be linked against QE. Modify Makefile.ifort so that $QETOPDIR is properly linked cd ../qmmm rm -f *.a *.o make -f Makefile.ifort #13. colvars # cd ../colvars rm -f *.a *.o make -f Makefile.mpi #14. src # cd ../../src make yes-all make no-kokkos make no-user-netcdf make no-user-quip make no-voronoi make no-user-h5md make no-kim make no-latte make no-mscg make no-user-smd make no-user-vtk make no-gpu #15. make gpu # ### check if nvidia-smi is working. If yes, make yes-gpu; else make no-gpu command=nvidia-smi $command > /dev/null 2>&1 if [ $? -eq 0 ]; then echo command $command OK echo To install gpu cd ../lib/gpu make -f Makefile.linux clean make -f Makefile.linux cd ../../src make yes-gpu else echo command $command FAIL echo Not to install gpu make no-gpu fi ### end of check if nvidia-smi is working. If yes, make yes-gpu; else make no-gpu #16. To modify Makefile.xx in MAKE/OPTIONS and copy it to MAKE filetomod=Makefile.intel_cpu_intelmpi cd MAKE cp OPTIONS/$filetomod . ## 1 keyword='-DMPICH_SKIP_MPICXX' ## backup orig $filetomod copy cp $filetomod $filetomod'.orig' ### target line number to be replaced lineno=$(cat $filetomod | awk -v keyword=$keyword '$0 ~ keyword {print NR}') # echo $lineno #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') #echo $os #### end of original target string #### modified string s2a='MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I'$mpiincpath # /opt/intel/impi_latest/include64' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod echo '1 is done' echo ' ' ### 2 ### target line number to be replaced keyword='MPI_PATH =' lineno=$(cat $filetomod | awk -v keyword='MPI_PATH =' '$0 ~ keyword {print NR}') echo $lineno #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') echo $os #### end of original target string #### modified string s2a='MPI_PATH = -L$mpilibpath # /opt/intel/impi_latest/lib64' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod echo '2 is done' echo ' ' ### 3 ### target line number to be replaced keyword='MPI_LIB =' lineno=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print NR}') echo $lineno #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') echo $os #### end of original target string #### modified string s2a='MPI_LIB = -lmpi' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod echo '3 is done' echo ' ' ### 4 ### target line number to be replaced keyword='FFT_PATH = ' lineno=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print NR}') echo $lineno #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') echo $os #### end of original target string #### modified string s2a='FFT_PATH = -L$(MKLROOT)/lib/intel64' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod echo '4 is done' echo ' ' ### 5 ### target line number to be replaced keyword='FFT_LIB =' lineno=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print NR}') echo $lineno #### original target string os=$(cat $filetomod | awk -v keyword="$keyword" '$0 ~ keyword {print}') echo $os #### end of original target string #### modified string s2a='FFT_LIB = -lfftw3xf_intel #-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core ' ns=$s2a #### end of modified string echo To replace echo $os echo 'in line' "$lineno" 'in' $filetomod echo by echo $ns cat $filetomod | awk -v lineno=$lineno -v ns="$ns" 'NR==lineno {$0=ns} {print}' > output.txt mv output.txt $filetomod echo '5 is done' echo ' ' ### 6 ### to delete the specific line ERR=$(( $lineno + 1 )) line2del=$(cat $filetomod | awk -v ERR=$ERR 'NR==ERR {print}') echo $line2del 'in line' "$ERR" 'in' $filetomod 'is deleted' awk -v no="$ERR" 'NR!=no' $filetomod > output.txt mv output.txt $filetomod echo '6 is done' echo ' ' ## end To modify Makefile.xx in MAKE/OPTIONS and copy it to MAKE cd ../ fn=$(echo $filetomod | awk -F "." '{print $2}') make $fn