summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gfortran.dg/intrinsic_spread_2.f90
blob: 0a91be7b599aeced6d06d8edc4aba5472d1b8844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
! { dg-do run }
! { dg-require-effective-target fortran_large_real }
program foo
   implicit none
   integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)

   real(kind=k), dimension(10) :: r_k
   real(kind=k), dimension (2, 3) :: ar_k
   real(kind=k), dimension (2, 2, 3) :: br_k
   complex(kind=k), dimension(10) :: c_k
   complex(kind=k), dimension (2, 3) :: ac_k
   complex(kind=k), dimension (2, 2, 3) :: bc_k
   character (len=200) line1, line2, line3

   ar_k = reshape ((/1._k, 2._k, 3._k, 4._k, 5._k, 6._k/), (/2, 3/))
   br_k = spread (ar_k, 1, 2)
   if (any (br_k .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
   & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) call abort
   line1 = ' '
   write(line1, 9010) br_k
   line2 = ' '
   write(line2, 9010) spread (ar_k, 1, 2)
   if (line1 /= line2) call abort
   line3 = ' '
   write(line3, 9010) spread (ar_k, 1, 2) + 0._k
   if (line1 /= line3) call abort
   r_k = spread(1._k,1,10)
   if (any(r_k /= 1._k)) call abort

   ac_k = reshape ((/(1._k,-1._k), (2._k,-2._k), (3._k, -3._k), (4._k, -4._k), &
                   & (5._k,-5._k), (6._k,-6._k)/), (/2, 3/))
   bc_k = spread (ac_k, 1, 2)
   if (any (real(bc_k) .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
   & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) call abort
   if (any (-aimag(bc_k) .ne. reshape ((/1._k, 1._k, 2._k, 2._k, 3._k, 3._k, &
   & 4._k, 4._k, 5._k, 5._k, 6._k, 6._k/), (/2, 2, 3/)))) call abort
   line1 = ' '
   write(line1, 9020) bc_k
   line2 = ' '
   write(line2, 9020) spread (ac_k, 1, 2)
   if (line1 /= line2) call abort
   line3 = ' '
   write(line3, 9020) spread (ac_k, 1, 2) + 0._k
   if (line1 /= line3) call abort
   c_k = spread((1._k,-1._k),1,10)
   if (any(c_k /= (1._k,-1._k))) call abort

9010 format(12F7.3)
9020 format(25F7.3)

end program
OpenPOWER on IntegriCloud