Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I want to read numerical model output file in Python. This model output file is unformatted Fortran output file.

So, to read in Fortran

OPEN(10, FILE=FILE_NAME, STATUS="OLD", ACCESS="DIRECT", FORM="UNFORMATTED", RECL=NX*NY, CONVERT="big_endian")

and to write other format(NetCDF), output format is f8(float) format.

I'm trying to read the 1-bit binary file in Python, (fromfile function in the NumPy module, struct module, etc..) but I am getting the wrong data or read error.

share|improve this question
    
So, in Fortran you can read that data with this open statement, and you want to know how to read the same data in python? What do you mean with "1-bit"? Is that file storing booleans? – chw21 17 hours ago
    
Yes, I want same data in python. but, I'm trying to read binary in python, reading data is different. – wxmin 17 hours ago
    
@Daniel When editing first posts please try to fix as many problems as possible including spelling, capital letters and grammar (depending on your English skills), especially if your edits still have to be approved by reviewers. – Vladimir F 15 hours ago
    
@wxmin You must show your Python code and your error nessages, otherwise your question is likely to he closed. Also show how the Fortran data is written, not just how the file is openned. Don't forget the file is bigendian. – Vladimir F 15 hours ago
    
It's been a good while since I used FORTRAN but back then, I remember that unformatted data was record-structured by the FORTRAN runtime library (i.e. was not a simple Unix/Linux binary stream). So reading it correctly using Python may involve reverse-engineering your runtime library and may be dependant on the particular FORTRAN compiler and platform in question. – nigel222 15 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.