1! { dg-do run } 2! Test the error message when an unformatted file has become 3! corrupted. 4program main 5 implicit none 6 integer(kind=4) :: i1, i2 7 integer :: ios 8 character(len=50) :: msg 9 10 ! Write out a truncated unformatted sequential file by 11 ! using unformatted stream. 12 13 open (10, form="unformatted", access="stream", file="foo_unf_read_corrupted_1.dat", & 14 status="unknown") 15 write (10) 16_4, 1_4 16 close (10, status="keep") 17 18 ! Try to read 19 open (10, file="foo_unf_read_corrupted_1.dat", form="unformatted", access="sequential") 20 i1 = 0 21 i2 = 0 22 read (10, iostat=ios, iomsg=msg) i1, i2 23 if (ios == 0) STOP 1 24 if (i1 /= 1) STOP 2 25 if (msg /= "Unformatted file structure has been corrupted") STOP 3 26 close (10, status="delete") 27end program main 28