Creating higher level single point input files (for MOLPRO) from an xyz file and a MOLPRO input template can be rather tedious. The hitch with this one is sometimes the default (designated by -a) geometry optimization fails, and I need to run one or more subsequent geometry optimizations (designated -a2, -a3, etc). The original method I had used the below bash line:
for i in $( ls geom-method-tests/c6h7-int*rowb97xd-631*.xyz ) ; do outname="$( basename $i "-a.xyz" )-uccsdtf12-vtzf12-ad.inp" ; echo $outname; cp c6h7-template-uccsdtf12-vtzf12-ad.inp $outname ; tail -n13 $i >tmpfile ; sed -i -e '/geom={/r tmpfile' $outname ; done
One downside with the above code is when the xyz file ends with something other than -a.xyz basename does not properly parse the file name (the new input file ends up with -a2.xyz in the middle of it). Thankfully, replacing basename with parameter expansion (## and % in this case) solves this.
for i in $( ls geom-method-tests/c6h7-int*rohcth407hcth407-631*.xyz ) ; do filename=${i##*/} ; basename1=${filename%.xyz} ; suffix=${basename1##*-a} ; basename2=${basename1%-*} ; outname="${basename2}-uccsdtf12-vtzf12-ad${suffix}.inp" ; echo ${outname} ; cp c6h7-template-uccsdtf12-vtzf12-ad.inp $outname ; tail -n13 $i >tmpfile ; sed -i -e '/geom={/r tmpfile' $outname; echo "---------------" ; done
While the above is rather long, I left in all of the steps for clarity. Thus far it has worked like a champ!
No comments:
Post a Comment