Writing binary files in C to be read in MS FORTRAN 4.0 
Author Message
 Writing binary files in C to be read in MS FORTRAN 4.0

I need to output some data from a C program into a binary file that can
be read by MS fortran 4.0.  I'm a fairly strong C programmer, but I'm
lost when it comes to FORTRAN.  I understand that this is possible to do
by embedding flags which describe how large the data values are.  What I
need to know is how large the flags need to be and what exactly should
be stored in them (and anything else that I'm missing).  Also, how would
the data be read into FORTRAN?  Are there any generic libraries that
will do this?

One problem I have with this is that I don't currently have access to a
FORTRAN compiler of any kind.  This data file is going to be shipped to
someone in Boston (I'm in Ithaca, NY).  So I can't really do any trial
and error testing.

I know one solution is to just convert to ASCII; however, when I say
"some data", I'm talking about a binary file on the order of 1-2 GB of
varying sized data values.  Going to ASCII would bloat this to at least
10 GB (depending on the nature of the data, of course), so I'd like to
stay in a binary format.  Also the recipient of the data file does not
have a high-speed network connection, so it'll be quicker to transfer
the data on removable storage.  Keeping the file as small as possible is
a plus.

Any help would be appreciated!

Thanks!

-Tom Johnson

--
Thomas P. Johnson
CORSIM
322 Uris Hall
Cornell University
Ithaca, NY 14853

(607) 255-1410


http://www.*-*-*.com/
http://www.*-*-*.com/



Fri, 05 Nov 1999 03:00:00 GMT  
 Writing binary files in C to be read in MS FORTRAN 4.0



Quote:
> I need to output some data from a C program into a binary file that can
> be read by MS FORTRAN 4.0.  I'm a fairly strong C programmer, but I'm
> lost when it comes to FORTRAN.  I understand that this is possible to do
> by embedding flags which describe how large the data values are.  What I
> need to know is how large the flags need to be and what exactly should
> be stored in them (and anything else that I'm missing).  Also, how would
> the data be read into FORTRAN?  Are there any generic libraries that
> will do this?

<snipped>

If this is a one time transfer then I would stick with ascii and just
compress the file when you are finished.

If this is going to be an ongoing transfer you will have to work with the
person on the other end to agree upon the record structure.  FORTRAN can
read/write binary files, FORMAT=UNFORMATTED.  FORTRAN prepends and appends
values to the data that it writes out so you will have to work with the
other person to code and test this.  In addition you would probably want to
user a C structure and have the FORTRAN/90 application use a matching user
defined TYPE.  The two applications would have to synchronies on this
structure.

good luck
-Bruce Callen



Sat, 06 Nov 1999 03:00:00 GMT  
 Writing binary files in C to be read in MS FORTRAN 4.0


Quote:
>I need to output some data from a C program into a binary file that can
>be read by MS FORTRAN 4.0.  I'm a fairly strong C programmer, but I'm
>lost when it comes to FORTRAN.  I understand that this is possible to do
>by embedding flags which describe how large the data values are.  What I
>need to know is how large the flags need to be and what exactly should
>be stored in them (and anything else that I'm missing).  Also, how would
>the data be read into FORTRAN?  Are there any generic libraries that
>will do this?

If you don't care about portability, you can use the Microsoft extension
of FORM='BINARY' to deal with a straight binary file.

I used this in the past to have a PC create an output file that was
identical to what a Sun would have produced using FORM='UNFORMATTED' so
that an existing program on the Sun could analyze the output even though
it was produced on a PC.

I used to for output but you may be able to put it to good use for
input.  Hope this helps.

<snip>

--

All opinions expressed are my own and not my employer's.

To email me, please remove the word REMOVE from my email address.
Sorry, the spam has just been getting too thick lately
--



Sat, 06 Nov 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. read binary file written in fortran format

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

3. Reading FORTRAN binary files from C

4. Reading FORTRAN binary files from C

5. reading and writing to binary files

6. Reading and Writing Ascii and Binary Files

7. read binary files written by VB with C

8. read/write structs, that use a pointer as a member, to a file (binary)

9. Help - Reading & Writing binary file

10. Help - Reading & Writing binary files with bitfields

11. MS Fortran compatability with UN*X Fortran (and use with MS C)

12. Truncating a binary file opened for read and write

 

 
Powered by phpBB® Forum Software