castep_outputs.bin_parsers.fortran_bin_parser#
General parser for the Fortran Unformatted file format.
Functions
|
Yield the elements of a Fortran unformatted file. |
- castep_outputs.bin_parsers.fortran_bin_parser.binary_file_reader(file)[source]#
Yield the elements of a Fortran unformatted file.
- Parameters:
file (BinaryIO) – Open file to get binary data from.
bool (int |) – Skip/rewind amount (
True
==-1
).
- Yields:
bytes – Binary data record from Fortran file.
- Return type:
Notes
Each “record” is:
(pre_nbytes: 4; data: nbytes; post_nbytes: 4)
Where
pre_nbytes == post_nbytes
(this is used in Fortran for rewinding).So when we rewind, we rewind the current size +
post_nbytes
(current) +pre_nbytes
(current) +post_nbytes
(previous) [cursor now before post_nbytes (previous)] which is then read putting the cursor after post_nbytes (previous).When we do the final rewind, we put the cursor before
pre_nbytes
ready to read the record.