- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
*******
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try removing the FORM='BINARY' from the open.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
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