By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,097 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,097 IT Pros & Developers. It's quick & easy.

Reading Fortran binary files

P: n/a
Hello,

I need to read a Fortran binary data file in Python.
The Fortran data file is organized thusly:

nx,ny,nz,ilog_scale # Record 1 (Header)
ihour,data3D_array # Record 2

Where every value above is a 2 byte Int. Further, the
first record is a header containing the dimensions of
the data that follows, as well as the scaling factor
of the data (log base 10). The second record contains
the hour, followed by the 3D array of data, which is
dimensioned by nx,ny,nz.

I also need to convert all the 2 byte Int values to
'regular' Int.

I realize that similar questions have previously been
posted to the group, but the most recent inquiries date
back to 2000 and 2001. I thought there may be newer and
easier ways to do this.
Thanks in advance for your help.
Daran Rife

da**********@PAMyahoo.com

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"drife" <da*******@yahoo.com> writes:
I need to read a Fortran binary data file in Python.
The Fortran data file is organized thusly:

nx,ny,nz,ilog_scale # Record 1 (Header)
ihour,data3D_array # Record 2

Where every value above is a 2 byte Int.


Have you looked at the struct module?

http://www.python.org/doc/2.4/lib/module-struct.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.