#! /bin/bash # Note. For lib/atc and lib/awpmd, the lapack and blas libraries in Makefile.lammps.installed of awpmd and Makefile.lammps.linalg of atc have to be replaced by the following entries: # user-awpmd_SYSLIB or user-atc_SYSLIB = # /usr/lib -llapack -lblas #4. cd lib/atc ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.mpic++ ### filetomod=Makefile.mpic++ make -f $filetomod clean keyword=mpicxx # 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='CC = mpicxx' 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 ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.mpic++ ### ##!!!! To modify Makefile.lammps.installed in atc so that it is pointing to tunned atlast library library !!!!## cp Makefile.lammps.installed Makefile.lammps.installed.orig ################# create outfile.txt ################# /usr/lib/atlas-base/ line1='user-atc_SYSINC = -I/usr/include/atlas -I/usr/include' line2='user-atc_SYSLIB = -L/usr/lib/atlas-base -lf77blas -lptcblas -lcblas -llapack -lptf77blas -latlas' line3='user-atc_SYSPATH =' cat <outfile.txt $line1 $line2 $line3 EOF ################# create outfile.txt ################# mv outfile.txt Makefile.lammps.installed echo 'In atc, I need to generate Makefile.lammps with the content of Makefile.lammps.installed via Makefile.lammps.linalg' cp Makefile.lammps.linalg Makefile.lammps.linalg.orig cp Makefile.lammps.installed Makefile.lammps.linalg echo 'Makefile.lammps in' $PWD 'should be now modified to point to tunned atlas libraries' make -f $filetomod #5. cd ../awpmd ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.mpicc ### filetomod=Makefile.mpicc make -f $filetomod clean keyword=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 ### 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='CC = mpicxx' 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 ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.mpicc ### ##!!!! To modify Makefile.lammps.installed in awpmd so that it is pointing to tunned atlast library !!!!## cp Makefile.lammps.installed Makefile.lammps.installed.orig ################# line1='user-awpmd_SYSINC = -I/usr/include/atlas -I/usr/include' line2='user-awpmd_SYSLIB = -L/usr/lib/atlas-base -lf77blas -lptcblas -lcblas -llapack -lptf77blas -latlas' line3='user-awpmd_SYSPATH =' cat <outfile.txt $line1 $line2 $line3 EOF ################# #cat <outfile.txt mv outfile.txt Makefile.lammps.installed echo 'Makefile.lammps.installed in' $PWD modified to point to tunned atlas library ##!!!! To modify Makefile.lammps.installed in awpmd so that it is pointing to tunned atlast library !!!!## make -f $filetomod #6. linalg # cd ../linalg filetomod=Makefile.mpi make -f $filetomod clean make -f Makefile.gfortran #7. meam # cd ../meam filetomod=Makefile.gfortran make -f $filetomod clean make -f $filetomod #8. poems # cd ../poems ## !!!!!!!!!!!!!!!!!!!! to modify Makefile.mpi ### filetomod=Makefile.mpi make -f $filetomod clean cp $filetomod $filetomod'.orig' keyword='mpicxx' s2a='mpicxx' sed -i "s|$keyword|$s2a|g" $filetomod #### make -f $filetomod #9. reax # cd ../reax filetomod=Makefile.gfortran make -f $filetomod clean make -f $filetomod # 10. qmmm #### has to be linked against QE. Modify $filetomod so that $QETOPDIR is properly linked cd ../qmmm filetomod=Makefile.mpi cp $filetomod $filetomod'.orig' keyword='mpicxx' s2a='mpicxx' sed -i "s|$keyword|$s2a|g" $filetomod keyword='QETOPDIR=$(HOME)/compile/espresso' s2a='QETOPDIR=/share/apps/qe-6.3' sed -i "s|$keyword|$s2a|g" $filetomod make -f $filetomod #11. colvars # cd ../colvars filetomod=Makefile.mpi cp $filetomod $filetomod'.orig' keyword='mpicxx' s2a='mpicxx' sed -i "s|$keyword|$s2a|g" $filetomod make -f $filetomod