Binary I/O (bug/missing ?) ?

Binary I/O (bug/missing ?) ?

I'm porting some fortran code over from another compiler and I'm having trouble with reading the last entry of a file opened for Binary I/O. I've created a small program (below) to demonstate this and its output is shown ( below). Is this bug or am I missing some flag/feature that permits this behaviour?

*******
PROGRAM TEST
C
IMPLICIT NONE
C
INTEGER IOSTATUS, I
C
DOUBLE PRECISION ARRAY(4)
C
DO I=1,4
ARRAY(I) = 3.0*I
ENDDO

OPEN (UNIT=95, FILE="temp.dat", IOSTAT=IOSTATUS, ERR=123,
1 STATUS='UNKNOWN', ACCESS='DIRECT', FORM='BINARY',
2 RECL=8)

DO I=1,4
WRITE(95,IOSTAT=IOSTATUS, ERR=123,REC=I) ARRAY(I)
PRINT *,'I = ',I,' ARRAY(I) = ',ARRAY(I),' IOSTAT = ',IOSTATUS
ENDDO
DO I=1,4
READ(95,IOSTAT=IOSTATUS, ERR=123,REC=I) ARRAY(I)
PRINT *,'I = ',I,' ARRAY(I) = ',ARRAY(I),' IOSTAT = ',IOSTATUS
ENDDO

PRINT *,'DONE'

CLOSE (95)

123 PRINT *,'ERROR: IOSTAT = ',IOSTATUS
STOP
END
**********
compiled with: ifc test.for -o test.x
**********
output is:
I = 1 ARRAY(I) = 3.00000000000000 IOSTAT = 0
I = 2 ARRAY(I) = 6.00000000000000 IOSTAT = 0
I = 3 ARRAY(I) = 9.00000000000000 IOSTAT = 0
I = 4 ARRAY(I) = 12.0000000000000 IOSTAT = 0
I = 1 ARRAY(I) = 3.00000000000000 IOSTAT = 0
I = 2 ARRAY(I) = 6.00000000000000 IOSTAT = 0
I = 3 ARRAY(I) = 9.00000000000000 IOSTAT = 0
ERROR: IOSTAT = 154

Any ideas,

J

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Looks like a bug to me. Please report it to http://premier.intel.com/

Steve

Steve - Intel Developer Support

Try removing the FORM='BINARY' from the open.

Thanks, but doesn't quite fix my issue.

removing FORM='BINARY' from the open causes the open to default back to FORM='UNFORMATTED' which does work.

But I am converting another code and I don't wish to have to do this each time a new version is sent to me.

In any event the binary option SHOULD work and while I can get by with unformatted at the moment, in the past it has caused me grief when I have output from other languages/platforms.

It is a BUG and I have lodged it as an issue ( #190486 )

thanks tho

J

Leave a Comment

Please sign in to add a comment. Not a member? Join today