<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">or a sed, bc solution which is space agnostic</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">
<div>
<span style="font-family:monospace"><br><span style="color:rgb(24,178,24)">[14:56:55 alin@abaddon:</span><span style="font-weight:bold;color:rgb(255,255,84)">~</span><span style="color:rgb(24,178,24)">]:</span><span style="color:rgb(0,0,0)"> echo "1h23m45.6s" | sed "s/h/*3600+/g; s/m/*60+/g; s/s//g" | bc -l </span><br>5025.6
<br><span style="color:rgb(24,178,24)">[14:57:09 alin@abaddon:</span><span style="font-weight:bold;color:rgb(255,255,84)">~</span><span style="color:rgb(24,178,24)">]:</span><span style="color:rgb(0,0,0)"> echo "1 h 23 m 45.6 s" | sed "s/h/*3600+/g; s/m/*60+/g; s/s//g" | bc -l </span><br>5025.6<br>
<br></span></div><div><span style="font-family:monospace">regards,</span></div><div><span style="font-family:monospace">Alin</span></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Without Questions there are no Answers!<br>______________________________________________________________________<br>Dr. Alin Marin ELENA<br><a href="http://alin.elenaworld.net/" target="_blank">http://alin.elena.space/</a><br>______________________________________________________________________</div></div></div></div>
<br><div class="gmail_quote">On 2 June 2015 at 14:33, Paolo Giannozzi <span dir="ltr"><<a href="mailto:p.giannozzi@gmail.com" target="_blank">p.giannozzi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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"><div><div class="h5">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></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5"><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></div></div>_______________________________________________<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>
<br>_______________________________________________<br>
Q-e-developers mailing list<br>
<a href="mailto:Q-e-developers@qe-forge.org">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>