Improved BASH script to extract stationary structure from Gaussian09 scan log file.

I have published a blog before to do this at Recently, I did a lot scan for a ring structure. And for some scan, Gaussian tried thousand times to find the stationary points. The previous script is too slow to extract structure from huge log file (>100M). So I improved it, the speed can not compare with perl or python. But it’s enough for daily use.



read -p "Gaussian log file " log
((atom=`grep "NAtoms=" $log | head -1 |cut -f2 -d"N" | cut -f2- -d" "`))
head=`cat $log | head -3 | tail -1 | cut -f1 -d"." | cut -f2 -d"="`
((m=`grep "Stationary point found" $log | wc -l`)) #get the total number of statoinary point step
((n=`grep "Z-Matrix orientation" $log | wc -l`)) #get the total number of scan step

a=(`grep -n "Stationary point found" $log | cut -f1 -d":"`)
b=(`grep -n "Z-Matrix orientation" $log | cut -f1 -d":"`)
for ((i=0;i<${#a[*]};i++));do
#echo i $i p $p
        for ((j=$p;j<${#b[*]};j++));do
                if (( ${b[$j]} > ${a[$i]} )); then
                        (( c= ${b[$jj]} + 4 + $atom ))
                        echo $atom > "$head"_stationary_point"$q".xyz
                        echo >> "$head"_stationary_point"$q".xyz
                        cat $log | head -"$c" | tail -"$atom" | cut -c 15-20,31- >> "$head"_stationary_point"$q".xyz

mkdir "$head"_stationary_point
mv "$head"_stationary_point*.xyz ./"$head"_stationary_point
cd "$head"_stationary_point
for ((i=1;i<=$m;i++));do
        if (( $i == 1 ));then
        echo mol new "$head"_stationary_point"$i".xyz > combine.tcl
        echo mol addfile "$head"_stationary_point"$i".xyz >> combine.tcl
unset a b

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s