<div dir="ltr">The script PW/tests/check-pw.x.j parses times as follows:<br><br><div><div class="gmail_extra"># convert from "1h23m45.6s" to seconds<br> # the following line prevents cases such as "2m 7.5s"<br> grep 'WALL$' $1.ref | sed 's/m /m0/' > $1.tmp<br> # in order to get cpu instead of wall time, replace $3 to $5<br> tref=`awk '{ str = $5; h = m = s = 0;<br> if (split(str, x, "h") == 2) { h = x[1]; str = x[2]; }<br> if (split(str, x, "m") == 2) { m = x[1]; str = x[2]; }<br> if (split(str, x, "s") == 2) { s = x[1]; str = x[2]; }<br> t += h * 3600 + m * 60 + s; }<br> END { printf("%.2f\n", t); }' \<br> $1.tmp`<br><br></div><div class="gmail_extra">Parsing the output is always a bad idea because the output is not made for parsing but for reading and may change any time.<br>Assuming a fixed format is an even worse idea.<br><br></div><div class="gmail_extra">Paolo<br><br><br></div><div class="gmail_extra"><div class="gmail_quote">On Wed, May 27, 2015 at 12:03 PM, Blair Lebert <span dir="ltr"><<a href="mailto:Blair.Lebert@impmc.upmc.fr" target="_blank">Blair.Lebert@impmc.upmc.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>I found a very small 'bug' with the output of the computation time. I wanted to parse multiple files to get the their wall time. I thought it was fixed width but as seen below the times without minutes at the top are all shifted by one space. Also using fields to grab the data is also troublesome since a space is put between minutes and seconds when the seconds are less than 10 (highlight in red)</div><div><br></div><img src="cid:ii_14d94c9864bf6a53" alt="Inline image 2" height="255" width="436"><br><div><br></div><div>One (probably poor) way of grabbing the wall time isn't very straight-forward:</div><div><div><font face="monospace, monospace">line=`grep PWSCF Fe.scf.out_s${s}_k${k} | tail -n 1`</font></div><div><font face="monospace, monospace">minutes=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*m" | tr -d m`</font></div><div><font face="monospace, monospace">seconds=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*\.[0-9]*s" | tr -d s`</font></div><div><font face="monospace, monospace">t=`echo "${minutes:-0}*60 + $seconds" | bc`</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">Cheers,</font></div><div><font face="arial, helvetica, sans-serif">Blair</font></div></div>
<br>_______________________________________________<br>
Q-e-developers mailing list<br>
<a href="mailto:Q-e-developers@qe-forge.org" target="_blank">Q-e-developers@qe-forge.org</a><br>
<a href="http://qe-forge.org/mailman/listinfo/q-e-developers" target="_blank">http://qe-forge.org/mailman/listinfo/q-e-developers</a><br>
<br></blockquote></div><br></div></div></div>