Fortran · 376 bytes Raw Blame History
1 ! REWIND test.
2 ! Writes a value, rewinds the file, reads it back.
3 ! Exercises: REWIND statement, file position reset.
4 !
5 ! CHECK: 99
6 program test_io_rewind
7 implicit none
8 integer :: x
9
10 open(10, file='/tmp/afs_rewind.dat', status='replace', action='readwrite')
11 write(10, *) 99
12 rewind(10)
13
14 x = 0
15 read(10, *) x
16 close(10)
17
18 print *, x
19 end program
20