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

 ra> We have a binary file written by a fortran77 application. How
 ra> do I read this file from a C program. Attempts with fread and
 ra> fscanf have failed. Perhaps I am missing something fundamental?.
 ra>
 ra> Any help or suggestions would be welcome. Thanks
 If I understand things correctly, a binary file is simply a dump to disk of
 how the compiler represents the information in memory.  This will be highly
 compiler dependent and may even be dependent on the optimisations used!

 This may be illustrated, in C at least, by defining a structure and then
 getting sizeof(structure) from several compilers.

 Generally, binary files are not portable between compilers/languages/
 platforms.

 Trevor D'Arcy-Evans

... "What?!? This isn't the Files section?!?"



Thu, 25 Sep 1997 03:00:00 GMT  
 Reading FORTRAN binary files from C

Quote:

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

... stuff cut ...
fread should work if you opened the file "rb", I've read FORTRAN77 files in C.
If you are on an IBM mainframe, you will have to watch the file organization
(FB, VB, etc). It usually hepls to get a hex dump of the file and use the
de{*filter*} to see exactly what the fread is pulling in.


Sat, 27 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