Skip to content

Instantly share code, notes, and snippets.

@platinhom
Created May 31, 2018 06:20
Show Gist options
  • Save platinhom/eebd27ae88896c1fb8c5d8b26feaece2 to your computer and use it in GitHub Desktop.
Save platinhom/eebd27ae88896c1fb8c5d8b26feaece2 to your computer and use it in GitHub Desktop.
网上一个gout到gjf的脚本
#!/bin/bash
#
# 目的:从高斯输出文件中提取坐标信息生成xyz文件和输入文件
# 用法: gout2gjf xxxx.out 后面为高斯输出文件名作为参数
#
# ChemiAndy, 2014.03.11
#
# get the prefix of the gaussian output file
NAME=`echo $1|sed "s/\..*$//"`
# Find CHARGE and MULTIPlicity, get the first value in case more than one result found
CHARGE=`awk '/Charge =/{print $3}' $1 | awk 'NR==1'`
MULTIP=`awk '/Charge =/{print $6}' $1 | awk 'NR==1'`
# Find how many atoms by reading the first string of the last line
NATOM=`grep "NAtoms=" $1 | tail -1 | awk '{print $2}' `
echo "$NATOM in inputfile $1 "
echo "Charge: $CHARGE"
echo "Multiplicity: $MULTIP"
# Find the block of the coordination, delete extra lines, and
# Change the element index into their NAMEs, to be improved
sed '/Standard orientation:/,/Rotational constants/!d' $1 | grep -v -E 'I|C|N|D|R|\-\-\-' | tail -$NATOM | awk '{gsub(17,"Cl",$2); gsub(16,"S",$2); gsub("1","H",$2); gsub(6,"C",$2); gsub(7,"N",$2); gsub(8,"O",$2); printf "%5s %10.6f %10.6f %10.6f\n", $2, $4, $5, $6}' > $NAME.tmp
# Create xyz file
cat $NAME.tmp | sed "1i ${NATOM}\n${NAME}" > $NAME.xyz
echo "$NAME.xyz created."
cat $NAME.tmp | sed -e "1i %chk=${NAME}.chk\n%mem=1024MB\n#MP2\/aug-cc-pvdz\n\n${NAME}\n\n${CHARGE} ${MULTIP}" -e '$a \\n' > $NAME.gjf
echo "$NAME.gjf created."
# Clean tmp file
rm $NAME.tmp
echo "$NAME.tmp deleted."
echo "End!"
@platinhom
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment