PR27757 Errors with direct IO - serious errors

Paul Thomas paulthomas2@wanadoo.fr
Sat May 27 13:36:00 GMT 2006


This works correctly:

program testdirect
implicit none
integer, dimension(100) :: a
integer :: i,j,k,ier
real :: x

a = 0
call random_seed()
open(unit=15,file="testdirectio",access="direct",form="unformatted",recl=4)
do i=1,100
call random_number(x)
k= int(x * 100)+1
a(i)=k
write(unit=15, rec=k) k
enddo
! ---------close/open necessary for successful 
regurgitation-----------------
close (15)
open(unit=15,file="testdirectio",access="direct",form="unformatted",recl=4)
! 
--------------------------*sigh*-------------------------------------------
do j=1,100
read(unit=15, rec=a(j), iostat=ier) k

print *, "ier = ", ier, " a(j) = ", a(j), " k = ", k
close(unit=15, status="delete")
end program testdirect

I thought that FLUSH might do the job but it makes no difference.

It looks pretty bad, I must admit. I guess that a buffer needs flushing, 
someplace?

Paul



More information about the Fortran mailing list