PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / random_3.f90
blob8f0fbaf57b9eccaf019a8cc23a6ae6e7b60755f1
1 ! { dg-do run }
2 ! { dg-require-effective-target fortran_large_real }
3 ! Check that the random_seed for real(10) exists and that
4 ! real(8) and real(10) random number generators
5 ! return the same sequence of values.
6 ! Mostly copied from random_2.f90
7 program random_3
8 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
10 integer, dimension(:), allocatable :: seed
11 real(kind=8), dimension(10) :: r8
12 real(kind=k), dimension(10) :: r10
13 real, parameter :: delta = 1.d-10
14 integer n
16 ! Run the test only if real(10) is available. With the current
17 ! xorshift1024* PRNG the real(16) generator uses two uint64_t values
18 ! for every real(16) value generated, and hence the sequences won't
19 ! be the same as with real(4,8,10).
20 if (k == 10) then
21 call random_seed (size=n)
22 allocate (seed(n))
23 call random_seed (get=seed)
24 ! Test both array valued and scalar routines.
25 call random_number(r8)
26 call random_number (r8(10))
28 ! Reset the seed and get the real(8) values.
29 call random_seed (put=seed)
30 call random_number(r10)
31 call random_number (r10(10))
33 if (any ((r8 - r10) .gt. delta)) STOP 1
34 end if
35 end program random_3