This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch,libgfortran] PR29053 Consecutive STREAM I/O file positions mixed up


Jerry DeLisle wrote:

! { dg-do run }
! PR29053 Stream IO test 9.
! Contributed by Jerry DeLisle <jvdelisle@verizon.net>.
! Test case derived from that given in PR by Steve Kargl.
program pr29053
   implicit none
   real dt, t, u, a(10), b(10)
   integer i, place
   dt = 1.e-6
   a = real( (/ (i, i=1, 10) /) )
   b = a
   open(unit=11, file='a.dat', access='stream')
   open(unit=12, file='b.dat', access='stream')
   do i = 1, 10
      t = i * dt
      write(11) t
      write(12) a
   end do
   rewind(11)
   rewind(12)
   do i = 1, 10
      t = i * dt
      read(12) a
      if (any(a.ne.b)) print *, "a failed"
      read(11) u
      if (u.ne.t) print *, "t failed"
   end do
   close(11, status="delete")
   close(12, status="delete")
end program pr29053

oops!
The print statements will be changed to "call abort()". As a note of explanation the order of the READs is reversed from the order of the WRITEs in an attempt to detect the bug.


Regards,

Jerry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]