[Q-e-developers] Parsing wall time, bug with fixed width?
Alin Marin Elena
alinm.elena at gmail.com
Tue Jun 2 15:59:33 CEST 2015
or a sed, bc solution which is space agnostic
[14:56:55 alin at abaddon:~]: echo "1h23m45.6s" | sed "s/h/*3600+/g;
s/m/*60+/g; s/s//g" | bc -l
5025.6
[14:57:09 alin at abaddon:~]: echo "1 h 23 m 45.6 s" | sed "s/h/*3600+/g;
s/m/*60+/g; s/s//g" | bc -l
5025.6
regards,
Alin
Without Questions there are no Answers!
______________________________________________________________________
Dr. Alin Marin ELENA
http://alin.elena.space/ <http://alin.elenaworld.net/>
______________________________________________________________________
On 2 June 2015 at 14:33, Paolo Giannozzi <p.giannozzi at gmail.com> wrote:
> The script PW/tests/check-pw.x.j parses times as follows:
>
> # convert from "1h23m45.6s" to seconds
> # the following line prevents cases such as "2m 7.5s"
> grep 'WALL$' $1.ref | sed 's/m /m0/' > $1.tmp
> # in order to get cpu instead of wall time, replace $3 to $5
> tref=`awk '{ str = $5; h = m = s = 0;
> if (split(str, x, "h") == 2) { h = x[1]; str = x[2]; }
> if (split(str, x, "m") == 2) { m = x[1]; str = x[2]; }
> if (split(str, x, "s") == 2) { s = x[1]; str = x[2]; }
> t += h * 3600 + m * 60 + s; }
> END { printf("%.2f\n", t); }' \
> $1.tmp`
>
> Parsing the output is always a bad idea because the output is not made for
> parsing but for reading and may change any time.
> Assuming a fixed format is an even worse idea.
>
> Paolo
>
>
> On Wed, May 27, 2015 at 12:03 PM, Blair Lebert <Blair.Lebert at impmc.upmc.fr
> > wrote:
>
>> Hello,
>>
>> 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)
>>
>> [image: Inline image 2]
>>
>> One (probably poor) way of grabbing the wall time isn't very
>> straight-forward:
>> line=`grep PWSCF Fe.scf.out_s${s}_k${k} | tail -n 1`
>> minutes=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*m" | tr -d m`
>> seconds=`echo $line | sed 's/.*CPU //g' | egrep -o "[0-9]*\.[0-9]*s" | tr
>> -d s`
>> t=`echo "${minutes:-0}*60 + $seconds" | bc`
>>
>>
>> Cheers,
>> Blair
>>
>> _______________________________________________
>> Q-e-developers mailing list
>> Q-e-developers at qe-forge.org
>> http://qe-forge.org/mailman/listinfo/q-e-developers
>>
>>
>
> _______________________________________________
> Q-e-developers mailing list
> Q-e-developers at qe-forge.org
> http://qe-forge.org/mailman/listinfo/q-e-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/developers/attachments/20150602/3b29a755/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PWSCF_fixed.png
Type: image/png
Size: 12581 bytes
Desc: not available
URL: <http://lists.quantum-espresso.org/pipermail/developers/attachments/20150602/3b29a755/attachment.png>
More information about the developers
mailing list