2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / direct_io_5.f90
blob621399844523cf513ec8dd4eec83e5f61fbb9aef
1 ! { dg-do run }
2 ! PR27757 Problems with direct access I/O
3 ! This test checks a series of random writes followed by random reads.
4 ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>
6 program testdirect
7 implicit none
8 integer, dimension(100) :: a
9 integer :: i,j,k,ier
10 real :: x
11 data a / 13, 9, 34, 41, 25, 98, 6, 12, 11, 44, 79, 3,&
12 & 64, 61, 77, 57, 59, 2, 92, 38, 71, 64, 31, 60, 28, 90, 26,&
13 & 97, 47, 26, 48, 96, 95, 82, 100, 90, 45, 71, 71, 67, 72,&
14 & 76, 94, 49, 85, 45, 100, 22, 96, 48, 13, 23, 40, 14, 76, 99,&
15 & 96, 90, 65, 2, 8, 60, 96, 19, 45, 1, 100, 48, 91, 20, 92,&
16 & 72, 81, 59, 24, 37, 43, 21, 54, 68, 31, 19, 79, 63, 41,&
17 & 42, 12, 10, 62, 43, 9, 30, 9, 54, 35, 4, 5, 55, 3, 94 /
19 open(unit=15,file="testdirectio",access="direct",form="unformatted",recl=89)
20 do i=1,100
21 k = a(i)
22 write(unit=15, rec=k) k
23 enddo
24 do j=1,100
25 read(unit=15, rec=a(j), iostat=ier) k
26 if (ier.ne.0) then
27 call abort()
28 else
29 if (a(j) /= k) call abort()
30 endif
31 enddo
32 close(unit=15, status="delete")
33 end program testdirect