Reading fortran 'unformatted' binary files
Tim Peters
tim_one at email.msn.com
Mon May 8 01:55:39 EDT 2000
[Tony Keating]
> I'm sure this has been asked before, but I can't seem to find any
> information on deja or on the web. How can I get python (with
> Numpy) to read in arrays from a file created from a fortran code? ...
Because Fortran files have a record structure, every Fortran implementation
invents (because it must, on any OS without native record structures, which
is almost all OSes these days) its own low-level file formats. If you can
reverse-engineer your Fortran's format, you can build a binary file reader
out of, e.g., Python's std "struct" module.
Easier would be to write a Fortran program (using the same implementation as
was used to create the files) to read the files in and write the data out as
formatted strings. 7-bit ASCII is God's solution to portability <wink>.
can't-get-there-from-here-but-can-from-two-steps-left-ly y'rs - tim
More information about the Python-list
mailing list