Hello,
I encountered problems using stream access with pgf90, (version 11.3,linux 64 bits)
The program is the following:
(myfile is a file of 15 bytes)
program a
implicit none
character :: c
integer :: ios
character(200) :: message
open(1,file=‘myfile’,access=‘stream’,form=‘unformatted’)
read(1,pos=20,iostat=ios,iomsg=message) c
write(6,) ‘ios1=’,ios
write(6,) ‘mess1=’,trim(message)
read(1,pos=0,iostat=ios) c
write(6,) ‘ios2=’,ios
write(6,) ‘mess2=’,trim(message)
close(1)
end program a
The output is the following:
ios1= -1
mess1=
attempt to read past end of file
ios2= -1
mess2=
attempt to read past end of file
I understand the values of ios1 and mess1, since the first read statement
tried to read after the end of the file. However, I do not understand
the values of ios2 and mess2.
The pos=0 specifier in the second read statement doesn’t seem to be taken into account.
It seems that, as soon as the end of the file has been reached, is it impossible
to read again the file.
Is this a bug ?
This problem can be solved
- by closing and reopening the file between the two read statements
- by adding a rewind statement.
thank you for your answers and/or comments,
Jerome