#!/bin/bash
export MOL=$1
export FCHK=$2
export SUBDIR=~+
export GAUSS_SCRDIR=~/tmp/gaussian/$
export GAUSS_EXEDIR=xxxxxxxxxxxxxxxx #写自己的gaussian路径
export USERNAME=`whoami`
if [ null$MOL == null ]; then
echo -e "\n\033[31m ************************************* \033[0m"
echo -e "\033[31m Please input the name of a .com file! \033[0m"
echo -e "\033[31m ************************************* \033[0m"
exit
fi
full=`date --rfc-2822` #时间这儿,这样写,适合中文系统的同学想获得英文缩写。
week=${full%,*}
submit=`date "+%Y-%m-%d, $week, %T"`
start=`date +%s`
if [ -e $SUBDIR/$MOL.com ] ; then
echo -e "\n *******************************************************"
echo " Gaussian Task:"
echo " Now calculating $SUBDIR/$MOL.com!"
echo " *******************************************************"
mkdir -p $GAUSS_SCRDIR
cd $GAUSS_SCRDIR
echo -e "\033[31m Now $SUBDIR/$MOL.com is still calculated in the background~ \033[0m" >> ~/tmp/now.log
$GAUSS_EXEDIR/g09 $SUBDIR/$MOL.com $SUBDIR/$MOL.log
else
echo -e "\n\033[31m ************************************************************************* \033[0m"
echo -e "\033[31m Cannot find $SUBDIR/$MOL.com! Please check your PATH! \033[0m"
echo -e "\033[31m ************************************************************************* \033[0m"
exit
fi
if grep -i '%chk=' $SUBDIR/$MOL.com ; then
if [ -e *.chk ] ; then
mv -f *.chk $SUBDIR/$MOL.chk
fi
else
echo -e "\nYou didn't request the .chk file!"
fi
if [ -e *.wfx ] ; then
mv -f *.wfx $SUBDIR/$MOL.wfx
fi
if [ -e *.wfn ] ; then #这部分自己想要啥文件自己加就好
mv -f *.wfn $SUBDIR/$MOL.wfn
fi
for ((k=31; k<=41; k++))
do
if [ -e *.$k ] ; then
mv -f *.$k $SUBDIR/$MOL.$k
fi
done
if [ $FCHK !="fchk" ] || [ null$2 == null ] ; then > /dev/null
echo "You didn't request to produce the .fchk file!"
else
if [ -e $SUBDIR/$MOL.chk ] ; then
formchk $SUBDIR/$MOL.chk $SUBDIR/$MOL.fchk
echo ".fchk file formed sucessfully"
else
echo "So cannot form .fchk file!"
fi
fi
rm -rf $GAUSS_SCRDIR
echo -e "\n=========================================================================="
echo "The temporary folder $GAUSS_SCRDIR of calculation was deleted"
stop=`date +%s`
time=`expr "$stop" - "$start"`
end=`date "+%Y-%m-%d, $week, %T"`
echo "**************************************************************************" >> $SUBDIR/$MOL.log
echo File: $SUBDIR/$MOL.com >> $SUBDIR/$MOL.log
if [ $time -le 60 ] ; then
echo Time consuming: $time seconds >> $SUBDIR/$MOL.log
elif [ $time -gt 60 -a $time -le 3600 ] ; then
echo "Time consuming: `echo "scale=2;$time/60"|bc` minutes" >> $SUBDIR/$MOL.log
elif [ $time -gt 3600 -a $time -le 86400 ] ; then
echo "Time consuming: `echo "scale=2;$time/3600"|bc` hours" >> $SUBDIR/$MOL.log
elif [ $time -gt 86400 ] ; then
echo "Time consuming: `echo "scale=2;$time/86400"|bc` days" >> $SUBDIR/$MOL.log
fi
echo Submission time: $submit >> $SUBDIR/$MOL.log
echo Ending time: $end >> $SUBDIR/$MOL.log
echo "**************************************************************************" >> $SUBDIR/$MOL.log
echo Temporary folder is $GAUSS_SCRDIR >> $SUBDIR/$MOL.log
echo "=========================================================================="
tail -25 $SUBDIR/$MOL.log
echo "These last 25 lines are from file: $SUBDIR/$MOL.log"
echo "=========================================================================="
echo -e "\n\033[31m ************************************************************************************** \033[0m" >> ~/tmp/results.log
echo -e "\033[31m Gaussian Task:\033[0m" >> ~/tmp/results.log
grep -q "Normal termination" $SUBDIR/$MOL.log
if [ $? -eq 1 ] ; then
echo -e "\033[31m $SUBDIR/$MOL.com !!!ERROR TERMINATED!!! at $end \033[0m" >> ~/tmp/results.log
else
echo -e "\033[31m $SUBDIR/$MOL.com !!!NORMAL TERMINATED!!! at $end \033[0m" >> ~/tmp/results.log
fi
echo -e "\033[31m ************************************************************************************** \033[0m" >> ~/tmp/results.log
w|grep "$USERNAME"|head -n 1|sed 's/ //g' > /dev/null
if [ $? -eq 0 ] ; then
rm -f ~/tmp/results.log
fi
sed -i '/'$MOL.com'/d' ~/tmp/now.log