PR ipa/83051
[official-gcc.git] / gcc / testsuite / gfortran.dg / internal_pack_2.f90
blob1f0473e2455f1b453907293e4cebd88bb43294b1
1 ! { dg-do run }
2 ! { dg-require-effective-target fortran_large_real }
3 ! Test that the internal pack and unpack routines work OK
4 ! for our large real type.
6 program main
7 implicit none
8 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
9 real(kind=k), dimension(3) :: rk
10 complex(kind=k), dimension(3) :: ck
12 rk = (/ -1.0_k, 1.0_k, -3.0_k /)
13 call sub_rk(rk(1:3:2))
14 if (any(rk /= (/ 3.0_k, 1.0_k, 2.0_k/))) call abort
16 ck = (/ (-1.0_k, 0._k), (1.0_k, 0._k), (-3.0_k, 0._k) /)
17 call sub_ck(ck(1:3:2))
18 if (any(real(ck) /= (/ 3.0_k, 1.0_k, 2.0_k/))) call abort
19 if (any(aimag(ck) /= 0._k)) call abort
21 end program main
23 subroutine sub_rk(r)
24 implicit none
25 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
26 real(kind=k), dimension(2) :: r
27 if (r(1) /= -1._k) call abort
28 if (r(2) /= -3._k) call abort
29 r(1) = 3._k
30 r(2) = 2._k
31 end subroutine sub_rk
33 subroutine sub_ck(r)
34 implicit none
35 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
36 complex(kind=k), dimension(2) :: r
37 if (r(1) /= (-1._k,0._k)) call abort
38 if (r(2) /= (-3._k,0._k)) call abort
39 r(1) = 3._k
40 r(2) = 2._k
41 end subroutine sub_ck