Fortran array in python (f2py?)...
kwmsmith at gmail.com
Sat Feb 14 21:34:18 CET 2009
On Sat, Feb 14, 2009 at 2:06 PM, tripp <tripplowe at gmail.com> wrote:
> OK. It sounds like it would be easiest for me, then, to dump the
> arrays to a binary file (much faster than dumping it to a text) from
> the fortran program. Then use f2py to load a fortran module to read
I've done something similar and have written some wrapper functions (in pure
python) that read in fortran binary arrays and puts them into a numpy
array. You have to deal with fortran records, which (for the fortran
compiler I'm using) puts a 4-byte record length indicator at the beginning
and end of each record, with the raw binary data between. The issue is
mildly complicated if you have to deal with endianness incompatibilites
between computers. IIRC, the format of the records is compiler dependent,
although I've found that gfortran, g77 and xlfortran are consistent with
If you like I'd be happy to send you the code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list