f=${1/.out/}
f=${f/.in/}
if [ ! -e $f.out ]
  then echo 'file?'
  exit 1
fi
if grep -q 'MOL>' $f.out
then t=1
elif grep -q '^<$mol' $f.out
then t=2
else echo 'mol?' $f ; exit 1
fi
mv $f.{in,bak}
sed -n -e '/$molecule/q' -e p                   $f.bak  > $f.in
if [ $t = 1 ]
then
  sed -n '/MOL>/s/MOL>//p'                      $f.out >> $f.in
else
  sed -n '/^<$mol/,/^<$end/s/<//p'              $f.out >> $f.in
fi
sed -n -e '/dipole/h' -e '${g;/.*0\.000.*/d;p}' $f.out >> $f.in
diff $f.{bak,in} | tail -n 64

