RISC-V: Refactor Dynamic LMUL codes
[official-gcc.git] / gcc / testsuite / gfortran.dg / minloc_string_1.f90
blob2ef2fa8491d2abd08c64d0b5e5a54a10cc3d50c9
1 ! { dg-do run }
2 ! Test minloc for strings for different code paths
4 program main
5 implicit none
6 integer, parameter :: n=4
7 character(len=4), dimension(n,n) :: c
8 integer, dimension(n,n) :: a
9 integer, dimension(2) :: res1, res2
10 real, dimension(n,n) :: r
11 logical, dimension(n,n) :: amask
12 logical(kind=8) :: smask
13 integer :: i,j
14 integer, dimension(n) :: q1, q2
15 character(len=4,kind=4), dimension(n,n) :: c4
16 character(len=4), dimension(n*n) :: e
17 integer, dimension(n*n) :: f
18 logical, dimension(n*n) :: cmask
20 call random_number (r)
21 a = int(r*100)
22 do j=1,n
23 do i=1,n
24 write (unit=c(i,j),fmt='(I4.4)') a(i,j)
25 write (unit=c4(i,j),fmt='(I4.4)') a(i,j)
26 end do
27 end do
28 res1 = minloc(c)
29 res2 = minloc(a)
31 if (any(res1 /= res2)) STOP 1
32 res1 = minloc(c4)
33 if (any(res1 /= res2)) STOP 2
35 amask = a < 50
36 res1 = minloc(c,mask=amask)
37 res2 = minloc(a,mask=amask)
39 if (any(res1 /= res2)) STOP 3
41 amask = .false.
42 res1 = minloc(c,mask=amask)
43 if (any(res1 /= 0)) STOP 4
45 amask(2,3) = .true.
46 res1 = minloc(c,mask=amask)
47 if (any(res1 /= [2,3])) STOP 5
49 res1 = minloc(c,mask=.false.)
50 if (any(res1 /= 0)) STOP 6
52 res2 = minloc(a)
53 res1 = minloc(c,mask=.true.)
54 if (any(res1 /= res2)) STOP 7
56 q1 = minloc(c, dim=1)
57 q2 = minloc(a, dim=1)
58 if (any(q1 /= q2)) STOP 8
60 q1 = minloc(c, dim=2)
61 q2 = minloc(a, dim=2)
62 if (any(q1 /= q2)) STOP 9
64 q1 = minloc(c, dim=1, mask=amask)
65 q2 = minloc(a, dim=1, mask=amask)
66 if (any(q1 /= q2)) STOP 10
68 q1 = minloc(c, dim=2, mask=amask)
69 q2 = minloc(a, dim=2, mask=amask)
70 if (any(q1 /= q2)) STOP 11
72 amask = a < 50
74 q1 = minloc(c, dim=1, mask=amask)
75 q2 = minloc(a, dim=1, mask=amask)
76 if (any(q1 /= q2)) STOP 12
78 q1 = minloc(c, dim=2, mask=amask)
79 q2 = minloc(a, dim=2, mask=amask)
80 if (any(q1 /= q2)) STOP 13
82 e = reshape(c, shape(e))
83 f = reshape(a, shape(f))
84 if (minloc(e,dim=1) /= minloc(f,dim=1)) STOP 14
86 cmask = .false.
87 if (minloc(e,dim=1,mask=cmask) /= 0) STOP 15
89 cmask = f > 50
90 if ( minloc(e, dim=1, mask=cmask) /= minloc (f, dim=1, mask=cmask)) STOP 16
91 end program main