Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / intrinsic_spread_2.f90
blob5530b3f366094567d54aab1b6034f8eecef11f67
1 ! { dg-do run }
2 ! { dg-require-effective-target fortran_large_real }
3 program foo
4 implicit none
5 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
7 real(kind=k), dimension(10) :: r_k
8 real(kind=k), dimension (2, 3) :: ar_k
9 real(kind=k), dimension (2, 2, 3) :: br_k
10 complex(kind=k), dimension(10) :: c_k
11 complex(kind=k), dimension (2, 3) :: ac_k
12 complex(kind=k), dimension (2, 2, 3) :: bc_k
13 character (len=200) line1, line2, line3
15 ar_k = reshape ((/1._k, 2._k, 3._k, 4._k, 5._k, 6._k/), (/2, 3/))
16 br_k = spread (ar_k, 1, 2)
17 if (any (br_k .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
18 & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) STOP 1
19 line1 = ' '
20 write(line1, 9010) br_k
21 line2 = ' '
22 write(line2, 9010) spread (ar_k, 1, 2)
23 if (line1 /= line2) STOP 2
24 line3 = ' '
25 write(line3, 9010) spread (ar_k, 1, 2) + 0._k
26 if (line1 /= line3) STOP 3
27 r_k = spread(1._k,1,10)
28 if (any(r_k /= 1._k)) STOP 4
30 ac_k = reshape ((/(1._k,-1._k), (2._k,-2._k), (3._k, -3._k), (4._k, -4._k), &
31 & (5._k,-5._k), (6._k,-6._k)/), (/2, 3/))
32 bc_k = spread (ac_k, 1, 2)
33 if (any (real(bc_k) .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
34 & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) STOP 5
35 if (any (-aimag(bc_k) .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
36 & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) STOP 6
37 line1 = ' '
38 write(line1, 9020) bc_k
39 line2 = ' '
40 write(line2, 9020) spread (ac_k, 1, 2)
41 if (line1 /= line2) STOP 7
42 line3 = ' '
43 write(line3, 9020) spread (ac_k, 1, 2) + 0._k
44 if (line1 /= line3) STOP 8
45 c_k = spread((1._k,-1._k),1,10)
46 if (any(c_k /= (1._k,-1._k))) STOP 9
48 9010 format(12F7.3)
49 9020 format(25F7.3)
51 end program