Sonntag, 3. April 2011

GAMESS 002: Copying to a new job type

When a batch of optimizations finished, the final coordinates need to be transfered to for example a HESSIAN job. At the same time, the file should change the extension from .log to .inp and the jobtype identifier should change from opt to hes. On the command line, this can be done in a for-loop by issueing:
mzh @ ~/shell $ for i in a-{1,2,3}-opt.log
HESLOG=${OPTLOG/opt/hes} # Rename jobtype
HESINP=${HESLOG/log/inp} # Rename extension
grep -i -A 29 "equilibrium" $OPTLOG|tail -n 26 >> $HESINP

I dont know how to rename two parts of a file name in the same step, i.e. how to get from 'a-{1,2,3}-job-opt.log' to 'a-{1,2,3}-job-hes.inp' in one command. That's why I rename part of the file step by step. Then, after I have the filename ready in a variable, the important content is written to this file. The molecule has 26 atoms, but the identifier is 29 lines above the end of the coordinate block, that's why I tail it (I dont know how to identify an empty line which terminates the coordinate block-- there is no identifier for the ending of the coordinate block). The generic command would be to insert N+3 where N is the number of atoms in the file.IMPORTANT: remember the '>>' append operator when transfering to the input file.

Now a more tricky part, transfering the Hessian matrix from the GAMESS output .dat file to the SADPOINT job file. How can this be automated in a smart way?
This line of code is the solution:

mzh ~/shell $ awk '/ \$HESS/,/^ \$END/' hess.dat >> sad.inp

I dont know what the ',' does. Note the quotes.

There also appear to be other ways of doing this:

mzh ~/shell $ ruby -ne 'print if /\$HESS/../\$END/' file


mzh ~/shell $ f=0;
while read l;
do [[ $l =~ \$HESS ]] && f=1;
[[ f -eq 1 ]] && echo $l;
[[ $l =~ \$END ]] && f=0;
done < file

These other options are less readable to me, but seem to work nicely.

Keine Kommentare:

Kommentar veröffentlichen