[SciPy-Dev] Adding an unformatted Fortran file reader to Scipy

Cera, Tim tim@cerazone....
Mon Apr 15 08:12:33 CDT 2013


> My recollection is, that the unformatted fortran files are machine
> specific, so cannot be moved to different architectures.
>

The situation is even stranger than that.  The 'unformatted' format is
compiler specific.  In fact, though this would be a silly thing for a
compiler to do there is nothing to stop a change in between versions of the
same compiler.  Usually, though here also there is no guarantee, compilers
that run on different machines will create the same 'unformatted' format.
 Of course there is always the little endian/big endian issue - but that is
a problem with all FORTRAN binary files.  Another reason to use one of the
abstracted high-level formats like NetCDF, HDF,...etc. as pointed out by
Paul.

A programmer is expected to read and write 'unformatted' files with FORTRAN
programs compiled with the same compiler on the same machine.

We ran into this issue where we had an unchangeable Windows based analysis
environment that was programmed to read an 'unformatted' file created using
a Lahey FORTRAN compiled program on Windows, but we were creating the
binary file with gfortran on Linux. A colleague rewrote the writing
routines to recreate the Lahey 'unformatted' binary format, irregardless of
compiler. Pain, but it allowed us to use our cluster for computation and
the Windows analysis environment to read and process the data.

Since then I have created a hand coded Python reader for the specific
dataset mentioned above using Construct (
https://pypi.python.org/pypi/construct). I actually side-step the
'unformatted' format issue by using searches for particular strings.  My
application is hspfbintoolbox (https://pypi.python.org/pypi/hspfbintoolbox).

So that is the reason that I probably will not use this since I have
climbed this mountain, and don't expect to climb it again.  On the other
hand this PR could be useful to others, but they will have to speak up.

As mentioned by Paul and in the discussion of the PR it should be clear in
the documentation which compilers/platforms it works with.

Kindest regards,

Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20130415/f2ddf127/attachment.html 


More information about the SciPy-Dev mailing list