1269369Sbr! { dg-do run }
2269369Sbr! { dg-options "-std=legacy" }
3269369Sbr!
4269369Sbr! pr 16597
5269369Sbr! libgfortran
6269369Sbr! reading a direct access record after it was written did
7269369Sbr! not always return the correct data.
8269369Sbr
9269369Sbr      program gfbug4
10269369Sbr      implicit none
11269369Sbr
12269369Sbr      integer      strlen
13269369Sbr      parameter    (strlen = 4)
14269369Sbr
15269369Sbr      integer      iunit
16269369Sbr      character    string *4
17269369Sbr
18269369Sbr      iunit = 99
19269369Sbr      open (UNIT=iunit,FORM='unformatted',ACCESS='direct',RECL=strlen)
20269369Sbr      write (iunit, rec=1) 'ABCD'
21269369Sbr      read (iunit, rec=1) string
22282576Sandrew      close (iunit, status = 'delete')
23269369Sbr      if (string.ne.'ABCD') call abort
24269369Sbr
25269369Sbr      open (UNIT=iunit,FORM='unformatted',ACCESS='direct',STATUS='scratch',RECL=strlen)
26269369Sbr      write (iunit, rec=1) 'ABCD'
27269369Sbr      read (iunit, rec=1) string
28269369Sbr      close (iunit)
29269369Sbr      if (string.ne.'ABCD') call abort
30269369Sbr      end
31269369Sbr