Number of Output Pages

Moderators: cyao, michael_borland

Post Reply
JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Number of Output Pages

Post by JoelFrederico » 01 Jun 2011, 19:11

Is there a way to find out how many pages are in a particle output file programmatically, in particular that would be fast over very large files with hundreds of pages?

For instance, a series of bash commands that would print out how many pages are in a file?

michael_borland
Posts: 2008
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Number of Output Pages

Post by michael_borland » 01 Jun 2011, 19:24

Joel,

You can use "sdds2stream -npages=bare <filename>" . This program also has the ability to report the number of rows (-rows=bare).

--Michael

michael_borland
Posts: 2008
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Number of Output Pages

Post by michael_borland » 01 Jun 2011, 19:25

Joel,

Another tip: if the file is very large, it might be faster to look at another, smaller file that is generated by the same elegant run and will have the same number of pages.

--Michael

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Re: Number of Output Pages

Post by JoelFrederico » 02 Jun 2011, 13:51

Michael,

Thanks. This method takes about 5 minutes on a 6 GB file, so we'll keep looking for alternate methods. I was hoping to avoid the secondary file method, but that seems like the only solution now. Unless maybe there's a character sequence in the binary format that represents a new page that we could grep (or something similar)?

Joel

litos
Posts: 1
Joined: 20 May 2011, 14:21

Re: Number of Output Pages

Post by litos » 02 Jun 2011, 17:50

Hi Joel and Michael,

I think I have come up with a faster solution for finding the page count of an sdds file. I use sddscollapse on the original input file, then define a parameter in the new file that is simply the number of rows in the new file, which should be equal to the number of pages in the original input file. This can then be printed with sddsprintout.

For example:

Code: Select all

sddscollapse $1 -pipe=out -noWarning |\
    sddsprocess -pipe -noWarnings \
    "-define=parameter,pagecount,n_rows,type=long" |\
    sddsprintout -pipe=in -par=pagecount
I found this code can give the page count on a 6 GB file in about 10 seconds (the same file Joel was using for benchmarking, I believe).

-Mike Litos

Post Reply