Part of LOM

This blog is part of web activities of the Laboratory of Organic Materials (LOM) of the Institute of Solid State Physics of the University of Latvia.

Friday, June 23, 2017

Small bash code to check how many calculations in a batch have been done (updated 20.09.17.)

Maybe this will be useful. Output contains also last modification time for the .out file.
The script has three assumptions:
  1. title section is marked by initial ::: — we usually have the title section with some certain word fields for automated processing of files and getting them to the database;
  2. the output file is named same as the input file, only with different extension (.out instead of .gjf);
  3. the working directory should be specified in the third line of the script, or within the file name; or You can left out the lines remembering present directory, changing to the working directory and going back in the end.

Arguments are names of the output files.

#!/bin/bash
iamhere=$(pwd
) # can left this line out
cd /your/working/directory # can left this line out

dos2unix $@
for werqt in $@; do wass=$(grep -c 'Normal termin' $werqt); shouldd=$(grep -c '#' ${werqt%.out}.gjf); echo -e "$werqt: $(tput bold)$wass / $shouldd -> $((shouldd-wass))$(tput sgr0)\t$(ls -l $werqt | xargs | cut -f 6-8 -d ' ')"; tac $werqt | grep -m 2 -B 3 -e '^ #' -e '^ :::' | tac  > sneg.foo; routeklis=$(sed -n '/^ #/ {/\\/!{:bulka N; s/\n //g;/---/!b bulka; s/-//g;p}}' sneg.foo); echo -e "Last route/title is:\n$routeklis\n$(sed -n '/^ :::/ {/\\/!{:bulka N; s/\n //g;/---/!b bulka; s/-//g;p}}' sneg.foo)"; [ $(echo $routeklis | grep -c -e ' Opt' -e ' opt') -gt 0 ] && echo "As for now, step $(tac $werqt | sed -n '1,/Normal termin/p' | grep -c 'Step number') is being done."

echo
done
rm sneg.foo
cd $iamhere
# can left this line out

An example result (the script is named howresults):

$ howresults IN_436_M062X_plus_DL2_2_U1.out
IN_436_M062X_plus_DL2_2_U1.out: 0 / 164 -> 164 Jun 23 19:17
Last route/title is:
  #N MaxDisk=250GB M062X/6311G(d,p) Opt=(CalcAll,NoRaman,MaxStep=1) Volume=Tight Guess=Mix scrf=(cpcm,solvent=TetraHydroFuran)
  ::: IN17_436_M062X_ufg_6311_thf IN17_436_M062X_6311_thf GeometryOptimization GeomOpt GeometryOptimization 2

As for now, step 10 is being done.

No comments:

Post a Comment