| 1 |
! { dg-do run } |
| 2 |
! PR25828 Stream IO test 6, random writes and reads. |
| 3 |
! Contributed by Jerry DeLisle <[email protected]>. |
| 4 |
program streamio_6 |
| 5 |
implicit none |
| 6 |
integer, dimension(100) :: a |
| 7 |
character(1) :: c |
| 8 |
integer :: i,j,k,ier |
| 9 |
real :: x |
| 10 |
data a / 13, 9, 34, 41, 25, 98, 6, 12, 11, 44, 79, 3,& |
| 11 |
& 64, 61, 77, 57, 59, 2, 92, 38, 71, 64, 31, 60, 28, 90, 26,& |
| 12 |
& 97, 47, 26, 48, 96, 95, 82, 100, 90, 45, 71, 71, 67, 72,& |
| 13 |
& 76, 94, 49, 85, 45, 100, 22, 96, 48, 13, 23, 40, 14, 76, 99,& |
| 14 |
& 96, 90, 65, 2, 8, 60, 96, 19, 45, 1, 100, 48, 91, 20, 92,& |
| 15 |
& 72, 81, 59, 24, 37, 43, 21, 54, 68, 31, 19, 79, 63, 41,& |
| 16 |
& 42, 12, 10, 62, 43, 9, 30, 9, 54, 35, 4, 5, 55, 3, 94 / |
| 17 |
|
| 18 |
open(unit=15,file="teststream_streamio_6",access="stream",form="unformatted") |
| 19 |
do i=1,100 |
| 20 |
k = a(i) |
| 21 |
write(unit=15, pos=k) achar(k) |
| 22 |
enddo |
| 23 |
do j=1,100 |
| 24 |
read(unit=15, pos=a(j), iostat=ier) c |
| 25 |
if (ier.ne.0) then |
| 26 |
STOP 1 |
| 27 |
else |
| 28 |
if (achar(a(j)) /= c) STOP 2 |
| 29 |
endif |
| 30 |
enddo |
| 31 |
close(unit=15, status="delete") |
| 32 |
end program streamio_6 |