Reading FORTRAN binary files from C 
Author Message
 Reading FORTRAN binary files from C

We have a binary file written by a fortran77 application. How
do I read this file from a C program. Attempts with fread and
fscanf have failed. Perhaps I am missing something fundamental?.

Any help or suggestions would be welcome. Thanks

--
The Ann Arbor Chamber of Commerce takes no responsability for and has
no knowledge of this posting.



Tue, 16 Sep 1997 03:00:00 GMT  
 Reading FORTRAN binary files from C

Quote:

>We have a binary file written by a FORTRAN77 application. How
>do I read this file from a C program. Attempts with fread and
>fscanf have failed. Perhaps I am missing something fundamental?.

Fortran files created by unformatted WRITE statements contain record
control information as well as the data written by the user.  You have
to figure out somehow how to distinguish between data and "meta data".
A good starting point is the documentation of the Fortran compiler.

If the documentation is not available or the information is not there,
try to experiment with short files, containing known data.  Chances are
that you'll manage to understand the structure of the file.

Don't forget to open the file in binary mode and read it with fread or
getc.  fscanf isn't the most natural approach to reading binary files.

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Wed, 17 Sep 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Writing binary files in C to be read in MS FORTRAN 4.0

2. read binary file written in fortran format

3. Reading FORTRAN binary files from C

4. Reading a binary sequential Fortran written file by C/C++

5. Newbie: separate big .cs file into small .cs files

6. reading a binary file back to binary

7. Binary file read to New text file save grief

8. Binary files C <--> FORTRAN

9. reading fortran data file from C program

10. HELP!! fread reads Fortran Direct files incorrectly

11. Please help: reading FORTRAN files using C code

12. need help reading fortran unformatted file from a c program

 

 
Powered by phpBB® Forum Software