Difference between revisions of "Grep binary files for ascii text"
From PHASTA Wiki
(Created page with "The phasta files (restart and geombc) includes ascii headers, potentially (but not necessarily) followed by an associated binary block of data. Listing the headers included in yo...") |
|||
Line 1: | Line 1: | ||
− | The phasta files (restart and geombc) | + | The phasta files (restart and geombc) include ascii headers, potentially (but not necessarily) followed by an associated binary block of data. A good example is the solution field in a restart file whose header typically looks like this: |
− | Listing the headers included in your phasta files may be very useful. | + | |
+ | solution : < 60193 > 1254 6 0 | ||
+ | |||
+ | For the short story, | ||
+ | * if the number between <> is larger than 0, it means this header is followed by a data block in binary format. In this case, this number between <> represents the size of the data block in bytes -1. | ||
+ | * The following numbers are peculiar to the header but for most of the fields in the restart files, the first number after the > sign represents the number of vertices in the considered mesh part (here 1254). | ||
+ | * Then, 6 represents the number of variables per nodes. | ||
+ | * Finally the last number (0 here) is the time step. | ||
+ | Do the math: 1254 vertices * 6 variables per vertex * 8 bytes for a double = 60194. | ||
+ | |||
+ | Listing the headers included in your phasta files may be very useful. For that purpose, use the following command for instance: | ||
+ | |||
+ | grep -a ' : < ' restart.0.1 | ||
+ | |||
+ | It will search for the ascii text ' : < ' (space : space < space) in the hybrid ascii - binary file restart.0.1. The output will look like this for instance: | ||
+ | |||
+ | byteorder magic number : < 5 > 1 | ||
+ | number of modes : < 0 > 1254 | ||
+ | number of variables : < 0 > 6 | ||
+ | solution : < 60193 > 1254 6 0 | ||
+ | mapping_partid : < 10033 > 1254 1 0 | ||
+ | mapping_vtxid : < 10033 > 1254 1 0 |
Revision as of 18:09, 26 February 2015
The phasta files (restart and geombc) include ascii headers, potentially (but not necessarily) followed by an associated binary block of data. A good example is the solution field in a restart file whose header typically looks like this:
solution : < 60193 > 1254 6 0
For the short story,
- if the number between <> is larger than 0, it means this header is followed by a data block in binary format. In this case, this number between <> represents the size of the data block in bytes -1.
- The following numbers are peculiar to the header but for most of the fields in the restart files, the first number after the > sign represents the number of vertices in the considered mesh part (here 1254).
- Then, 6 represents the number of variables per nodes.
- Finally the last number (0 here) is the time step.
Do the math: 1254 vertices * 6 variables per vertex * 8 bytes for a double = 60194.
Listing the headers included in your phasta files may be very useful. For that purpose, use the following command for instance:
grep -a ' : < ' restart.0.1
It will search for the ascii text ' : < ' (space : space < space) in the hybrid ascii - binary file restart.0.1. The output will look like this for instance:
byteorder magic number : < 5 > 1 number of modes : < 0 > 1254 number of variables : < 0 > 6 solution : < 60193 > 1254 6 0 mapping_partid : < 10033 > 1254 1 0 mapping_vtxid : < 10033 > 1254 1 0