- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am trying to write & read integers into a binary file. The field size varies for the variables. The write statement syntax belowseems to work fine
OPEN (4, FILE = "Bin", ACTION = "WRITE", FORM = "BINARY", &
ACCESS = "SEQUENTIAL", STATUS = "UNKNOWN" )
ACCESS = "SEQUENTIAL", STATUS = "UNKNOWN" )
WRITE(4) AREA(I),STRESS(I)
But I am unable to read the file I write. I have tried closing & reopening & also rewinding. Any help is appretiated
Thanks
GK
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used the following statements to write :-
open (55,file=cgbf,access='DIRECT',form='BINARY',recl=1)
write (55,rec=1) itype,ifc,ibyte,biatch,goe,gon
write (55,rec=55) e0,n0,e9,n9
close (55)
Note the variables itype, ifc, ibyte etc are all different sizes - int2, int4, real4 & real 8, you just need to keep track of the current location.
Then to read I use the opposite :-
open (55,file=cgbf,access='DIRECT',form='BINARY',recl=1)
read (55,rec=1) itype,ifc,ibyte,biatch,goe,gon
read (55,rec=55) e0,n0,e9,n9
close (55)
Therefore I would think
OPEN (4, FILE = "Bin",FORM = "BINARY",ACCESS = "DIRECT", RECL=1 )
WRITE(4,rec=1) AREA(I),STRESS(I)
should work- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thaks for the tip. It worked
Cheers
GK

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