- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to read in binary files (written using C)
and also write binary files.
my small test program is:
PROGRAM TEST
IMPLICIT NONE
INTEGER A, B, C
A = 20
B = 40
C = 70
OPEN(11, file='test.tmp', form='unformatted')
write(11) A, B, C
close(11)
stop
END
compiled with:
ifc -extend_source -w -nbs -zero -O3 -c test.for
program TEST
17 Lines Compiled
ifc -extend_source -w -nbs -zero -O3 test.o -zero -L. -o test.x
but.... my output has an extra variable in it .
$ od -l test.tmp
0000000 12 20 40 70
0000020 12
0000024
Why is this occuring - I thought unformatted ouptut like this wouldn't put record info(?) at the start of the file. Am I missing something really simple here ?
I must also add that I am just starting to use this compiler.
Thanks
John
I'm trying to read in binary files (written using C)
and also write binary files.
my small test program is:
PROGRAM TEST
IMPLICIT NONE
INTEGER A, B, C
A = 20
B = 40
C = 70
OPEN(11, file='test.tmp', form='unformatted')
write(11) A, B, C
close(11)
stop
END
compiled with:
ifc -extend_source -w -nbs -zero -O3 -c test.for
program TEST
17 Lines Compiled
ifc -extend_source -w -nbs -zero -O3 test.o -zero -L. -o test.x
but.... my output has an extra variable in it .
$ od -l test.tmp
0000000 12 20 40 70
0000020 12
0000024
Why is this occuring - I thought unformatted ouptut like this wouldn't put record info(?) at the start of the file. Am I missing something really simple here ?
I must also add that I am just starting to use this compiler.
Thanks
John
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The options for binary compatibility with C files, unfortunately, require you to choose between portability and convenience. If you look in the .pdf documentation, there is an option form='BINARY' which should suppress the record size information and give you C binary file compatibility.
Another option, I believe, is to used direct access, with RECL=1, to read 1 byte at a time.
Another option, I believe, is to used direct access, with RECL=1, to read 1 byte at a time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Grrrrrrrrrrrr
Ok, I figured it out, their is a FORM='BINARY' option to the OPEN statement, However, reading through the documentation I can find no mention of this.
i.e.
in for_prg.pdf page 10-137 makes only mention of UNFORMATTED or FORMATTED
in for_ug_lnx.pdf: page 107-108 the example uses unformatted to produce what i think looks like binary.
Ok, I figured it out, their is a FORM='BINARY' option to the OPEN statement, However, reading through the documentation I can find no mention of this.
i.e.
in for_prg.pdf page 10-137 makes only mention of UNFORMATTED or FORMATTED
in for_ug_lnx.pdf: page 107-108 the example uses unformatted to produce what i think looks like binary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're right, it's not fully documented that I can see except in the help pages for the CVF Windows compiler. I hope this takes care of your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Tomothy,
it does help, but without trying to sound too critical - why would I be looking through the documentation for the CVF Windows compiler when I have linux manuals and are programming on linux ?
I suppose that this will now be added to the manuals ?
it does help, but without trying to sound too critical - why would I be looking through the documentation for the CVF Windows compiler when I have linux manuals and are programming on linux ?
I suppose that this will now be added to the manuals ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
submitted as documentation issue 180559
Tim
what a hassle, can't login from Opera tonight
Tim
what a hassle, can't login from Opera tonight
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reported as planned for correction of documentation.

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