gcc/fortran/
[official-gcc.git] / gcc / testsuite / gfortran.dg / maxlocval_4.f90
blob029abe3d1a7b424541bba7efcabb48738f3936e4
1 ! { dg-do run }
2 ! { dg-add-options ieee }
3 ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
4 real :: a(3,3), b(3), nan, minf, pinf, h
5 logical :: l, l2
6 logical :: l3(3,3), l4(3,3), l5(3,3)
8 nan = 0.0
9 minf = 0.0
10 pinf = 0.0
11 nan = 0.0/nan
12 minf = -1.0/minf
13 pinf = 1.0/pinf
14 h = -huge(h)
15 l = .false.
16 l2 = .true.
17 l3 = .false.
18 l4 = .true.
19 l5 = .true.
20 l5(1,1) = .false.
21 l5(1,2) = .false.
22 l5(2,3) = .false.
23 a = reshape ((/ nan, nan, nan, minf, minf, minf, minf, pinf, minf /), (/ 3, 3 /))
24 if (maxval (a).ne.pinf) call abort
25 if (any (maxloc (a).ne.(/ 2, 3 /))) call abort
26 b = maxval (a, dim = 1)
27 if (.not.isnan(b(1))) call abort
28 b(1) = 0.0
29 if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
30 if (any (maxloc (a, dim = 1).ne.(/ 1, 1, 2 /))) call abort
31 b = maxval (a, dim = 2)
32 if (any (b.ne.(/ minf, pinf, minf /))) call abort
33 if (any (maxloc (a, dim = 2).ne.(/ 2, 3, 2 /))) call abort
34 if (maxval (a, mask = l).ne.h) call abort
35 if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
36 b = maxval (a, dim = 1, mask = l)
37 if (any (b.ne.(/ h, h, h /))) call abort
38 if (any (maxloc (a, dim = 1, mask = l).ne.(/ 0, 0, 0 /))) call abort
39 b = maxval (a, dim = 2, mask = l)
40 if (any (b.ne.(/ h, h, h /))) call abort
41 if (any (maxloc (a, dim = 2, mask = l).ne.(/ 0, 0, 0 /))) call abort
42 if (maxval (a, mask = l3).ne.h) call abort
43 if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
44 b = maxval (a, dim = 1, mask = l3)
45 if (any (b.ne.(/ h, h, h /))) call abort
46 if (any (maxloc (a, dim = 1, mask = l3).ne.(/ 0, 0, 0 /))) call abort
47 b = maxval (a, dim = 2, mask = l3)
48 if (any (b.ne.(/ h, h, h /))) call abort
49 if (any (maxloc (a, dim = 2, mask = l3).ne.(/ 0, 0, 0 /))) call abort
50 if (maxval (a, mask = l2).ne.pinf) call abort
51 if (maxval (a, mask = l4).ne.pinf) call abort
52 if (any (maxloc (a, mask = l2).ne.(/ 2, 3 /))) call abort
53 if (any (maxloc (a, mask = l4).ne.(/ 2, 3 /))) call abort
54 b = maxval (a, dim = 1, mask = l2)
55 if (.not.isnan(b(1))) call abort
56 b(1) = 0.0
57 if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
58 if (any (maxloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
59 b = maxval (a, dim = 2, mask = l2)
60 if (any (b.ne.(/ minf, pinf, minf /))) call abort
61 if (any (maxloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
62 b = maxval (a, dim = 1, mask = l4)
63 if (.not.isnan(b(1))) call abort
64 b(1) = 0.0
65 if (any (b.ne.(/ 0.0, minf, pinf /))) call abort
66 if (any (maxloc (a, dim = 1, mask = l2).ne.(/ 1, 1, 2 /))) call abort
67 b = maxval (a, dim = 2, mask = l4)
68 if (any (b.ne.(/ minf, pinf, minf /))) call abort
69 if (any (maxloc (a, dim = 2, mask = l2).ne.(/ 2, 3, 2 /))) call abort
70 if (maxval (a, mask = l5).ne.minf) call abort
71 if (any (maxloc (a, mask = l5).ne.(/ 2, 2 /))) call abort
72 b = maxval (a, dim = 1, mask = l5)
73 if (.not.isnan(b(1))) call abort
74 b(1) = 0.0
75 if (any (b.ne.(/ 0.0, minf, minf /))) call abort
76 if (any (maxloc (a, dim = 1, mask = l5).ne.(/ 2, 2, 1 /))) call abort
77 b = maxval (a, dim = 2, mask = l5)
78 if (any (b.ne.(/ minf, minf, minf /))) call abort
79 if (any (maxloc (a, dim = 2, mask = l5).ne.(/ 3, 2, 2 /))) call abort
80 a = nan
81 if (.not.isnan(maxval (a))) call abort
82 if (maxval (a, mask = l).ne.h) call abort
83 if (.not.isnan(maxval (a, mask = l2))) call abort
84 if (maxval (a, mask = l3).ne.h) call abort
85 if (.not.isnan(maxval (a, mask = l4))) call abort
86 if (.not.isnan(maxval (a, mask = l5))) call abort
87 if (any (maxloc (a).ne.(/ 1, 1 /))) call abort
88 if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
89 if (any (maxloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
90 if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
91 if (any (maxloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
92 if (any (maxloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
93 a = minf
94 if (maxval (a).ne.minf) call abort
95 if (maxval (a, mask = l).ne.h) call abort
96 if (maxval (a, mask = l2).ne.minf) call abort
97 if (maxval (a, mask = l3).ne.h) call abort
98 if (maxval (a, mask = l4).ne.minf) call abort
99 if (maxval (a, mask = l5).ne.minf) call abort
100 if (any (maxloc (a).ne.(/ 1, 1 /))) call abort
101 if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
102 if (any (maxloc (a, mask = l2).ne.(/ 1, 1 /))) call abort
103 if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
104 if (any (maxloc (a, mask = l4).ne.(/ 1, 1 /))) call abort
105 if (any (maxloc (a, mask = l5).ne.(/ 2, 1 /))) call abort
106 a = nan
107 a(1,3) = minf
108 if (maxval (a).ne.minf) call abort
109 if (maxval (a, mask = l).ne.h) call abort
110 if (maxval (a, mask = l2).ne.minf) call abort
111 if (maxval (a, mask = l3).ne.h) call abort
112 if (maxval (a, mask = l4).ne.minf) call abort
113 if (maxval (a, mask = l5).ne.minf) call abort
114 if (any (maxloc (a).ne.(/ 1, 3 /))) call abort
115 if (any (maxloc (a, mask = l).ne.(/ 0, 0 /))) call abort
116 if (any (maxloc (a, mask = l2).ne.(/ 1, 3 /))) call abort
117 if (any (maxloc (a, mask = l3).ne.(/ 0, 0 /))) call abort
118 if (any (maxloc (a, mask = l4).ne.(/ 1, 3 /))) call abort
119 if (any (maxloc (a, mask = l5).ne.(/ 1, 3 /))) call abort