gcc/fortran/
[official-gcc.git] / gcc / testsuite / gfortran.dg / write_rewind_2.f
blob501995c6eb53ddf129199d64618f11238e77fd0f
1 ! { dg-do run }
2 ! PR 26499 Test write with rewind sequences to make sure buffering and
3 ! end-of-file conditions are handled correctly. Derived from test case by Dale
4 ! Ranta. Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
5 program test
6 dimension idata(1011)
7 idata = -42
8 open(unit=11,form='unformatted')
9 idata(1) = -705
10 idata( 1011) = -706
11 write(11)idata
12 idata(1) = -706
13 idata( 1011) = -707
14 write(11)idata
15 idata(1) = -707
16 idata( 1011) = -708
17 write(11)idata
18 read(11,end= 1000 )idata
19 call abort()
20 1000 continue
21 rewind 11
22 read(11,end= 1001 )idata
23 if(idata(1).ne. -705.or.idata( 1011).ne. -706)call abort()
24 1001 continue
25 close(11,status='keep')
26 open(unit=11,form='unformatted')
27 rewind 11
28 read(11)idata
29 if(idata(1).ne.-705)then
30 call abort()
31 endif
32 read(11)idata
33 if(idata(1).ne.-706)then
34 call abort()
35 endif
36 read(11)idata
37 if(idata(1).ne.-707)then
38 call abort()
39 endif
40 close(11,status='delete')
41 stop
42 end