read Fortran created data into C programme 
Author Message
 read Fortran created data into C programme

has anybody an example programme at hand that could teach me
how to read any kind of data files (ie (un)formatted, sequential ...)
created with a fortran programme into C programmes?

thanks
gunfried


Sat, 23 Aug 1997 15:29:54 GMT  
 read Fortran created data into C programme
|> has anybody an example programme at hand that could teach me
|> how to read any kind of data files (ie (un)formatted, sequential ...)
|> created with a fortran programme into C programmes?

|> thanks
|> gunfried
|>
I suspect you are having trouble with file written unformatted,
sequential in Fortran.  The problem here is that unformatted data have
no inherent record boundaries (i.e. no newline character).  The Fortrans
I am familiar with begin and end each record with a byte count.  Thus
you would have   00000013xxxxxxxxxxxxxxxxxxx00000013 (where x represents
a byte of data (13 hex or 19 dec).  Knowing this you can, in c, read
the first bytes as an int (or whatever on your platform), then read
as many ints, floats, chars or whatever it takes to satisfy the byte
count, then read the trailing 4 bytes.

A complication arises when sharing data across mixed-endian platforms.
ULTRIX Fortran, for example, would write the byte count as 13000000.  

--
| Chick Racer                     Chevron Petroleum Technology Co. |
| (713) 596-2430                  P.O. Box 42832                   |

| 4209 Hayes Rd.                                                   |



Mon, 25 Aug 1997 06:06:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. reading fortran data file from C program

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

3. Looking for function to parse FORTRAN formatted data

4. read with a FORTRAN format description

5. C calling fortran:complex data type

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

7. Help! Reading SUN keyboard chars in SUN FORTRAN

8. read binary file written in fortran format

9. Reading Unformatted Fortran using C

10. Reading FORTRAN binary files from C

11. Reading FORTRAN binary files from C

12. Reading Fortran-style formatted floats?

 

 
Powered by phpBB® Forum Software