2 ! Handle eor and eof conditions with missing eor in file.
3 ! Test case modified from case presented by Ian Harvey on clf.
5 use, intrinsic :: iso_fortran_env
, only
: iostat_end
, iostat_eor
7 integer, parameter :: unit
=10
8 integer :: ios1
, ios2
, ios3
9 character(25) :: buffer
10 character(100) :: themessage
12 open(10,file
="eieio", form
="unformatted", access
="stream", status
="replace")
13 write(10) "Line-1" // char(10)
20 read (unit
,"(a)",advance
="no",iostat
=ios1
, pad
="yes") buffer
21 if (ios1
/= iostat_eor
.and
. buffer
/= "Line-1") call abort
24 read (unit
,"(a)",advance
="no",iostat
=ios2
,pad
="yes") buffer
25 if (ios2
/= iostat_eor
.and
. buffer
/= "Line-2") call abort
28 read (unit
,"(a)",advance
="no",iostat
=ios3
, iomsg
=themessage
) buffer
29 if (ios3
/= iostat_end
.and
. buffer
/= "5678") call abort
34 read (unit
,"(a)",advance
="no",iostat
=ios1
, pad
="no") buffer
35 if (ios1
/= iostat_eor
.and
. buffer
/= "abcdefg") call abort
38 read (unit
,"(a)",advance
="no",iostat
=ios2
,pad
="no") buffer
39 if (ios2
/= iostat_eor
.and
. buffer
/= "<") call abort
42 read (unit
,"(a)",advance
="no",iostat
=ios3
, iomsg
=themessage
) buffer
43 if (ios3
<= 0 .and
. buffer
/= "1234") call abort
45 close(unit
, status
="delete")
46 end program eieio_stat