- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I just started using Fortran and I couldn't find information I needed online.
I am trying to read binary data. The file contains mixed 4 and 8 bytes of data.
What's the most efficient way to read different sizes of data?
Thanks,
Min
I just started using Fortran and I couldn't find information I needed online.
I am trying to read binary data. The file contains mixed 4 and 8 bytes of data.
What's the most efficient way to read different sizes of data?
Thanks,
Min
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you open the file with FORM='BINARY', you can use unformatted reads with the appropriate sized variables and it will just transfer the data directly as a byte stream. This is a non-standard extension in Intel Fortran.
For example:
This reads 10 4-byte values and then 10 8-byte values.
For example:
integer(4) i4(10)
integer(8) i8(10)
open (unit=1,file='foo.dat',form='binary')
read (1) i4,i8
This reads 10 4-byte values and then 10 8-byte values.
Message Edited by Steve_Lionel on 06-20-2006 09:06 PM

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page