Re: Need interpretation
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Dec 2005 01:51:42 -0600
Here is another program that sometimes gives odd results.
program eof
implicit none
integer i, ierr
character(len=*), parameter :: cmft='(i1)'
open(unit=10,file='temp.dat')
rewind 10
write(10,cmft) 1
write(10,cmft) 2
rewind 10
read(10,cmft) i
read(10,cmft) i
read(10,cmft,iostat=ierr) i ! this should generate an eof error
write(*,*) 'ierr=', ierr, ' (should be negative)'
backspace 10 ! backspace over the end-of-file
backspace 10 ! backspace over the "2" record
read(10,cmft) i
write(*,*) 'i=', i, ' (should be 2)'
end program eof
I think "2" should be the output on the last line, but some
compilers don't handle the implicit endfile correctly and they print
out "1" instead. My version of gfortran happens to print out "0",
which is just an outright error I think.
Is it correct that the standard does define what the above program
should write in that last write statement?
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: Need interpretation
- From: Steven G. Kargl
- Re: Need interpretation
- From: Richard Maine
- Re: Need interpretation
- References:
- Need interpretation
- From: Jerry DeLisle
- Need interpretation
- Prev by Date: Re: tutorials
- Next by Date: Re: Need interpretation
- Previous by thread: Re: Need interpretation
- Next by thread: Re: Need interpretation
- Index(es):