2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / intrinsic_pack_2.f90
blob642cd5c1f825a9232a9f0e97fe698dc3701507cc
1 ! { dg-do run }
2 ! { dg-require-effective-target fortran_large_real }
3 ! Take the pack intrinsic through its paces, with all types that are
4 ! normally accessible.
5 program main
6 implicit none
7 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
8 integer :: i
9 real(kind=k), dimension(3,3) :: rk
10 real(kind=k), dimension(9) :: vrk
11 real(kind=k), dimension(9) :: rrk
12 complex(kind=k), dimension(3,3) :: ck
13 complex(kind=k), dimension(9) :: vck
14 complex(kind=k), dimension(9) :: rck
16 vrk = (/(i+10,i=1,9)/)
17 rk = reshape((/1.0_k, -3.0_k, 2.1_k, -4.21_k, 1.2_k, 0.98_k, -1.2_k, &
18 & -7.1_k, -9.9_k, 0.3_k /), shape(rk))
19 rrk = pack(rk,rk>0,vrk)
20 if (any(rrk /= (/ 1.0_k, 2.1_k, 1.2_k, 0.98_k, 15._k, 16._k, 17._k, &
21 & 18._k, 19._k /))) call abort
23 vck = (/(i+10,i=1,9)/)
24 ck = reshape((/1.0_k, -3.0_k, 2.1_k, -4.21_k, 1.2_k, 0.98_k, -1.2_k, &
25 & -7.1_k, -9.9_k, 0.3_k /), shape(ck))
26 rck = pack(ck,real(ck)>0,vck)
27 if (any(real(rck) /= (/ 1.0_k, 2.1_k, 1.2_k, 0.98_k, 15._k, 16._k, 17._k, &
28 & 18._k, 19._k /))) call abort
29 if (any(aimag(rck) /= 0)) call abort
31 end program main