Debian Codegraph @

gcc/testsuite/gfortran.dg/minmaxloc_18.f90

raw
1 ! { dg-do compile }
2 ! { dg-additional-options "-O -fdump-tree-original" }
3 ! { dg-final { scan-tree-dump-not "gfortran_\[sm\]?minloc" "original" } }
4 ! { dg-final { scan-tree-dump-not "gfortran_\[sm\]?maxloc" "original" } }
5 !
6 ! PR fortran/90608
7 ! Check that all MINLOC and MAXLOC calls are inlined with optimizations by default.
8
9 subroutine check_maxloc_without_mask
10 implicit none
11 integer, parameter :: data5(*) = (/ 1, 7, 2, 7, 0 /)
12 integer, parameter :: data64(*) = (/ 2, 5, 4, 6, 0, 9, 3, 5, &
13 4, 4, 1, 7, 3, 2, 1, 2, &
14 5, 4, 6, 0, 9, 3, 5, 4, &
15 4, 1, 7, 3, 2, 1, 2, 5, &
16 4, 6, 0, 9, 3, 5, 4, 4, &
17 1, 7, 3, 2, 1, 2, 5, 4, &
18 6, 0, 9, 3, 5, 4, 4, 1, &
19 7, 3, 2, 1, 2, 5, 4, 6 /)
20 call check_int_const_shape_rank_1
21 call check_int_const_shape_rank_3
22 call check_int_const_shape_empty_4
23 call check_int_alloc_rank_1
24 call check_int_alloc_rank_3
25 call check_real_const_shape_rank_1
26 call check_real_const_shape_rank_3
27 call check_real_const_shape_empty_4
28 call check_real_alloc_rank_1
29 call check_real_alloc_rank_3
30 contains
31 subroutine check_int_const_shape_rank_1()
32 integer :: a(5)
33 integer, allocatable :: m(:)
34 a = data5
35 m = maxloc(a)
36 if (size(m, dim=1) /= 1) stop 11
37 if (any(m /= (/ 2 /))) stop 12
38 end subroutine
39 subroutine check_int_const_shape_rank_3()
40 integer :: a(4,4,4)
41 integer, allocatable :: m(:)
42 a = reshape(data64, shape(a))
43 m = maxloc(a)
44 if (size(m, dim=1) /= 3) stop 21
45 if (any(m /= (/ 2, 2, 1 /))) stop 22
46 end subroutine
47 subroutine check_int_const_shape_empty_4()
48 integer :: a(9,3,0,7)
49 integer, allocatable :: m(:)
50 a = reshape((/ integer:: /), shape(a))
51 m = maxloc(a)
52 if (size(m, dim=1) /= 4) stop 31
53 if (any(m /= (/ 0, 0, 0, 0 /))) stop 32
54 end subroutine
55 subroutine check_int_alloc_rank_1()
56 integer, allocatable :: a(:)
57 integer, allocatable :: m(:)
58 allocate(a(5))
59 a(:) = data5
60 m = maxloc(a)
61 if (size(m, dim=1) /= 1) stop 41
62 if (any(m /= (/ 2 /))) stop 42
63 end subroutine
64 subroutine check_int_alloc_rank_3()
65 integer, allocatable :: a(:,:,:)
66 integer, allocatable :: m(:)
67 allocate(a(4,4,4))
68 a(:,:,:) = reshape(data64, shape(a))
69 m = maxloc(a)
70 if (size(m, dim=1) /= 3) stop 51
71 if (any(m /= (/ 2, 2, 1 /))) stop 52
72 end subroutine
73 subroutine check_real_const_shape_rank_1()
74 real :: a(5)
75 integer, allocatable :: m(:)
76 a = (/ real:: data5 /)
77 m = maxloc(a)
78 if (size(m, dim=1) /= 1) stop 71
79 if (any(m /= (/ 2 /))) stop 72
80 end subroutine
81 subroutine check_real_const_shape_rank_3()
82 real :: a(4,4,4)
83 integer, allocatable :: m(:)
84 a = reshape((/ real:: data64 /), shape(a))
85 m = maxloc(a)
86 if (size(m, dim=1) /= 3) stop 81
87 if (any(m /= (/ 2, 2, 1 /))) stop 82
88 end subroutine
89 subroutine check_real_const_shape_empty_4()
90 real :: a(9,3,0,7)
91 integer, allocatable :: m(:)
92 a = reshape((/ real:: /), shape(a))
93 m = maxloc(a)
94 if (size(m, dim=1) /= 4) stop 91
95 if (any(m /= (/ 0, 0, 0, 0 /))) stop 92
96 end subroutine
97 subroutine check_real_alloc_rank_1()
98 real, allocatable :: a(:)
99 integer, allocatable :: m(:)
100 allocate(a(5))
101 a(:) = (/ real:: data5 /)
102 m = maxloc(a)
103 if (size(m, dim=1) /= 1) stop 111
104 if (any(m /= (/ 2 /))) stop 112
105 end subroutine
106 subroutine check_real_alloc_rank_3()
107 real, allocatable :: a(:,:,:)
108 integer, allocatable :: m(:)
109 allocate(a(4,4,4))
110 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
111 m = maxloc(a)
112 if (size(m, dim=1) /= 3) stop 121
113 if (any(m /= (/ 2, 2, 1 /))) stop 122
114 end subroutine
115 end subroutine check_maxloc_without_mask
116 subroutine check_minloc_without_mask
117 implicit none
118 integer, parameter :: data5(*) = (/ 8, 2, 7, 2, 9 /)
119 integer, parameter :: data64(*) = (/ 7, 4, 5, 3, 9, 0, 6, 4, &
120 5, 5, 8, 2, 6, 7, 8, 7, &
121 4, 5, 3, 9, 0, 6, 4, 5, &
122 5, 8, 2, 6, 7, 8, 7, 4, &
123 5, 3, 9, 0, 6, 4, 5, 5, &
124 8, 2, 6, 7, 8, 7, 4, 5, &
125 3, 9, 0, 6, 4, 5, 5, 8, &
126 2, 6, 7, 8, 7, 4, 5, 3 /)
127 call check_int_const_shape_rank_1
128 call check_int_const_shape_rank_3
129 call check_int_const_shape_empty_4
130 call check_int_alloc_rank_1
131 call check_int_alloc_rank_3
132 call check_real_const_shape_rank_1
133 call check_real_const_shape_rank_3
134 call check_real_const_shape_empty_4
135 call check_real_alloc_rank_1
136 call check_real_alloc_rank_3
137 contains
138 subroutine check_int_const_shape_rank_1()
139 integer :: a(5)
140 integer, allocatable :: m(:)
141 a = data5
142 m = minloc(a)
143 if (size(m, dim=1) /= 1) stop 11
144 if (any(m /= (/ 2 /))) stop 12
145 end subroutine
146 subroutine check_int_const_shape_rank_3()
147 integer :: a(4,4,4)
148 integer, allocatable :: m(:)
149 a = reshape(data64, shape(a))
150 m = minloc(a)
151 if (size(m, dim=1) /= 3) stop 21
152 if (any(m /= (/ 2, 2, 1 /))) stop 22
153 end subroutine
154 subroutine check_int_const_shape_empty_4()
155 integer :: a(9,3,0,7)
156 integer, allocatable :: m(:)
157 a = reshape((/ integer:: /), shape(a))
158 m = minloc(a)
159 if (size(m, dim=1) /= 4) stop 31
160 if (any(m /= (/ 0, 0, 0, 0 /))) stop 32
161 end subroutine
162 subroutine check_int_alloc_rank_1()
163 integer, allocatable :: a(:)
164 integer, allocatable :: m(:)
165 allocate(a(5))
166 a(:) = data5
167 m = minloc(a)
168 if (size(m, dim=1) /= 1) stop 41
169 if (any(m /= (/ 2 /))) stop 42
170 end subroutine
171 subroutine check_int_alloc_rank_3()
172 integer, allocatable :: a(:,:,:)
173 integer, allocatable :: m(:)
174 allocate(a(4,4,4))
175 a(:,:,:) = reshape(data64, shape(a))
176 m = minloc(a)
177 if (size(m, dim=1) /= 3) stop 51
178 if (any(m /= (/ 2, 2, 1 /))) stop 52
179 end subroutine
180 subroutine check_real_const_shape_rank_1()
181 real :: a(5)
182 integer, allocatable :: m(:)
183 a = (/ real:: data5 /)
184 m = minloc(a)
185 if (size(m, dim=1) /= 1) stop 71
186 if (any(m /= (/ 2 /))) stop 72
187 end subroutine
188 subroutine check_real_const_shape_rank_3()
189 real :: a(4,4,4)
190 integer, allocatable :: m(:)
191 a = reshape((/ real:: data64 /), shape(a))
192 m = minloc(a)
193 if (size(m, dim=1) /= 3) stop 81
194 if (any(m /= (/ 2, 2, 1 /))) stop 82
195 end subroutine
196 subroutine check_real_const_shape_empty_4()
197 real :: a(9,3,0,7)
198 integer, allocatable :: m(:)
199 a = reshape((/ real:: /), shape(a))
200 m = minloc(a)
201 if (size(m, dim=1) /= 4) stop 91
202 if (any(m /= (/ 0, 0, 0, 0 /))) stop 92
203 end subroutine
204 subroutine check_real_alloc_rank_1()
205 real, allocatable :: a(:)
206 integer, allocatable :: m(:)
207 allocate(a(5))
208 a(:) = (/ real:: data5 /)
209 m = minloc(a)
210 if (size(m, dim=1) /= 1) stop 111
211 if (any(m /= (/ 2 /))) stop 112
212 end subroutine
213 subroutine check_real_alloc_rank_3()
214 real, allocatable :: a(:,:,:)
215 integer, allocatable :: m(:)
216 allocate(a(4,4,4))
217 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
218 m = minloc(a)
219 if (size(m, dim=1) /= 3) stop 121
220 if (any(m /= (/ 2, 2, 1 /))) stop 122
221 end subroutine
222 end subroutine check_minloc_without_mask
223 subroutine check_maxloc_with_mask
224 implicit none
225 integer, parameter :: data10(*) = (/ 7, 4, 7, 6, 6, 4, 6, 3, 9, 8 /)
226 logical, parameter :: mask10(*) = (/ .false., .true., .false., &
227 .false., .true., .true., &
228 .true. , .true., .false., &
229 .false. /)
230 integer, parameter :: data64(*) = (/ 2, 5, 4, 6, 0, 9, 3, 5, &
231 4, 4, 1, 7, 3, 2, 1, 2, &
232 5, 4, 6, 0, 9, 3, 5, 4, &
233 4, 1, 7, 3, 2, 1, 2, 5, &
234 4, 6, 0, 9, 3, 5, 4, 4, &
235 1, 7, 3, 2, 1, 2, 5, 4, &
236 6, 0, 9, 3, 5, 4, 4, 1, &
237 7, 3, 2, 1, 2, 5, 4, 6 /)
238 logical, parameter :: mask64(*) = (/ .true. , .false., .false., .false., &
239 .true. , .false., .true. , .false., &
240 .false., .true. , .true. , .false., &
241 .true. , .true. , .true. , .true. , &
242 .false., .true. , .false., .true. , &
243 .false., .true. , .false., .true. , &
244 .true. , .false., .false., .true. , &
245 .true. , .true. , .true. , .false., &
246 .false., .false., .true. , .false., &
247 .true. , .false., .true. , .true. , &
248 .true. , .false., .true. , .true. , &
249 .false., .true. , .false., .true. , &
250 .false., .true. , .false., .false., &
251 .false., .true. , .true. , .true. , &
252 .false., .true. , .false., .true. , &
253 .true. , .false., .false., .false. /)
254 call check_int_const_shape_rank_1
255 call check_int_const_shape_rank_3
256 call check_int_const_shape_rank_3_true_mask
257 call check_int_const_shape_rank_3_false_mask
258 call check_int_const_shape_rank_3_optional_mask_present
259 call check_int_const_shape_rank_3_optional_mask_absent
260 call check_int_const_shape_empty_4
261 call check_int_alloc_rank_1
262 call check_int_alloc_rank_3
263 call check_int_alloc_rank_3_true_mask
264 call check_int_alloc_rank_3_false_mask
265 call check_real_const_shape_rank_1
266 call check_real_const_shape_rank_3
267 call check_real_const_shape_rank_3_true_mask
268 call check_real_const_shape_rank_3_false_mask
269 call check_real_const_shape_rank_3_optional_mask_present
270 call check_real_const_shape_rank_3_optional_mask_absent
271 call check_real_const_shape_empty_4
272 call check_real_alloc_rank_1
273 call check_real_alloc_rank_3
274 call check_real_alloc_rank_3_true_mask
275 call check_real_alloc_rank_3_false_mask
276 contains
277 subroutine check_int_const_shape_rank_1()
278 integer :: a(10)
279 logical :: m(10)
280 integer, allocatable :: r(:)
281 a = data10
282 m = mask10
283 r = maxloc(a, mask = m)
284 if (size(r, dim = 1) /= 1) stop 11
285 if (any(r /= (/ 5 /))) stop 12
286 end subroutine
287 subroutine check_int_const_shape_rank_3()
288 integer :: a(4,4,4)
289 logical :: m(4,4,4)
290 integer, allocatable :: r(:)
291 a = reshape(data64, shape(a))
292 m = reshape(mask64, shape(m))
293 r = maxloc(a, mask = m)
294 if (size(r, dim = 1) /= 3) stop 21
295 if (any(r /= (/ 2, 3, 1 /))) stop 22
296 end subroutine
297 subroutine check_int_const_shape_rank_3_true_mask()
298 integer :: a(4,4,4)
299 integer, allocatable :: r(:)
300 a = reshape(data64, shape(a))
301 r = maxloc(a, mask = .true.)
302 if (size(r, dim = 1) /= 3) stop 31
303 if (any(r /= (/ 2, 2, 1 /))) stop 32
304 end subroutine
305 subroutine check_int_const_shape_rank_3_false_mask()
306 integer :: a(4,4,4)
307 integer, allocatable :: r(:)
308 a = reshape(data64, shape(a))
309 r = maxloc(a, mask = .false.)
310 if (size(r, dim = 1) /= 3) stop 41
311 if (any(r /= (/ 0, 0, 0 /))) stop 42
312 end subroutine
313 subroutine call_maxloc_int(r, a, m)
314 integer :: a(:,:,:)
315 logical, optional :: m(:,:,:)
316 integer, allocatable :: r(:)
317 r = maxloc(a, mask = m)
318 end subroutine
319 subroutine check_int_const_shape_rank_3_optional_mask_present()
320 integer :: a(4,4,4)
321 logical :: m(4,4,4)
322 integer, allocatable :: r(:)
323 a = reshape(data64, shape(a))
324 m = reshape(mask64, shape(m))
325 call call_maxloc_int(r, a, m)
326 if (size(r, dim = 1) /= 3) stop 51
327 if (any(r /= (/ 2, 3, 1 /))) stop 52
328 end subroutine
329 subroutine check_int_const_shape_rank_3_optional_mask_absent()
330 integer :: a(4,4,4)
331 integer, allocatable :: r(:)
332 a = reshape(data64, shape(a))
333 call call_maxloc_int(r, a)
334 if (size(r, dim = 1) /= 3) stop 61
335 if (any(r /= (/ 2, 2, 1 /))) stop 62
336 end subroutine
337 subroutine check_int_const_shape_empty_4()
338 integer :: a(9,3,0,7)
339 logical :: m(9,3,0,7)
340 integer, allocatable :: r(:)
341 a = reshape((/ integer:: /), shape(a))
342 m = reshape((/ logical:: /), shape(m))
343 r = maxloc(a, mask = m)
344 if (size(r, dim = 1) /= 4) stop 71
345 if (any(r /= (/ 0, 0, 0, 0 /))) stop 72
346 end subroutine
347 subroutine check_int_alloc_rank_1()
348 integer, allocatable :: a(:)
349 logical, allocatable :: m(:)
350 integer, allocatable :: r(:)
351 allocate(a(10), m(10))
352 a(:) = data10
353 m(:) = mask10
354 r = maxloc(a, mask = m)
355 if (size(r, dim = 1) /= 1) stop 81
356 if (any(r /= (/ 5 /))) stop 82
357 end subroutine
358 subroutine check_int_alloc_rank_3()
359 integer, allocatable :: a(:,:,:)
360 logical, allocatable :: m(:,:,:)
361 integer, allocatable :: r(:)
362 allocate(a(4,4,4), m(4,4,4))
363 a(:,:,:) = reshape(data64, shape(a))
364 m(:,:,:) = reshape(mask64, shape(m))
365 r = maxloc(a, mask = m)
366 if (size(r, dim = 1) /= 3) stop 91
367 if (any(r /= (/ 2, 3, 1 /))) stop 92
368 end subroutine
369 subroutine check_int_alloc_rank_3_true_mask()
370 integer, allocatable :: a(:,:,:)
371 integer, allocatable :: r(:)
372 allocate(a(4,4,4))
373 a(:,:,:) = reshape(data64, shape(a))
374 r = maxloc(a, mask = .true.)
375 if (size(r, dim = 1) /= 3) stop 101
376 if (any(r /= (/ 2, 2, 1 /))) stop 102
377 end subroutine
378 subroutine check_int_alloc_rank_3_false_mask()
379 integer, allocatable :: a(:,:,:)
380 integer, allocatable :: r(:)
381 allocate(a(4,4,4))
382 a(:,:,:) = reshape(data64, shape(a))
383 r = maxloc(a, mask = .false.)
384 if (size(r, dim = 1) /= 3) stop 111
385 if (any(r /= (/ 0, 0, 0 /))) stop 112
386 end subroutine
387 subroutine check_real_const_shape_rank_1()
388 real :: a(10)
389 logical :: m(10)
390 integer, allocatable :: r(:)
391 a = (/ real:: data10 /)
392 m = mask10
393 r = maxloc(a, mask = m)
394 if (size(r, dim = 1) /= 1) stop 131
395 if (any(r /= (/ 5 /))) stop 132
396 end subroutine
397 subroutine check_real_const_shape_rank_3()
398 real :: a(4,4,4)
399 logical :: m(4,4,4)
400 integer, allocatable :: r(:)
401 a = reshape((/ real:: data64 /), shape(a))
402 m = reshape(mask64, shape(m))
403 r = maxloc(a, mask = m)
404 if (size(r, dim = 1) /= 3) stop 141
405 if (any(r /= (/ 2, 3, 1 /))) stop 142
406 end subroutine
407 subroutine check_real_const_shape_rank_3_true_mask()
408 real :: a(4,4,4)
409 integer, allocatable :: r(:)
410 a = reshape((/ real:: data64 /), shape(a))
411 r = maxloc(a, mask = .true.)
412 if (size(r, dim = 1) /= 3) stop 151
413 if (any(r /= (/ 2, 2, 1 /))) stop 152
414 end subroutine
415 subroutine check_real_const_shape_rank_3_false_mask()
416 real :: a(4,4,4)
417 integer, allocatable :: r(:)
418 a = reshape((/ real:: data64 /), shape(a))
419 r = maxloc(a, mask = .false.)
420 if (size(r, dim = 1) /= 3) stop 161
421 if (any(r /= (/ 0, 0, 0 /))) stop 162
422 end subroutine
423 subroutine call_maxloc_real(r, a, m)
424 real :: a(:,:,:)
425 logical, optional :: m(:,:,:)
426 integer, allocatable :: r(:)
427 r = maxloc(a, mask = m)
428 end subroutine
429 subroutine check_real_const_shape_rank_3_optional_mask_present()
430 real :: a(4,4,4)
431 logical :: m(4,4,4)
432 integer, allocatable :: r(:)
433 a = reshape((/ real:: data64 /), shape(a))
434 m = reshape(mask64, shape(m))
435 call call_maxloc_real(r, a, m)
436 if (size(r, dim = 1) /= 3) stop 171
437 if (any(r /= (/ 2, 3, 1 /))) stop 172
438 end subroutine
439 subroutine check_real_const_shape_rank_3_optional_mask_absent()
440 real :: a(4,4,4)
441 integer, allocatable :: r(:)
442 a = reshape((/ real:: data64 /), shape(a))
443 call call_maxloc_real(r, a)
444 if (size(r, dim = 1) /= 3) stop 181
445 if (any(r /= (/ 2, 2, 1 /))) stop 182
446 end subroutine
447 subroutine check_real_const_shape_empty_4()
448 real :: a(9,3,0,7)
449 logical :: m(9,3,0,7)
450 integer, allocatable :: r(:)
451 a = reshape((/ real:: /), shape(a))
452 m = reshape((/ logical:: /), shape(m))
453 r = maxloc(a, mask = m)
454 if (size(r, dim = 1) /= 4) stop 191
455 if (any(r /= (/ 0, 0, 0, 0 /))) stop 192
456 end subroutine
457 subroutine check_real_alloc_rank_1()
458 real, allocatable :: a(:)
459 logical, allocatable :: m(:)
460 integer, allocatable :: r(:)
461 allocate(a(10), m(10))
462 a(:) = (/ real:: data10 /)
463 m(:) = mask10
464 r = maxloc(a, mask = m)
465 if (size(r, dim = 1) /= 1) stop 201
466 if (any(r /= (/ 5 /))) stop 202
467 end subroutine
468 subroutine check_real_alloc_rank_3()
469 real, allocatable :: a(:,:,:)
470 logical, allocatable :: m(:,:,:)
471 integer, allocatable :: r(:)
472 allocate(a(4,4,4), m(4,4,4))
473 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
474 m(:,:,:) = reshape(mask64, shape(m))
475 r = maxloc(a, mask = m)
476 if (size(r, dim = 1) /= 3) stop 211
477 if (any(r /= (/ 2, 3, 1 /))) stop 212
478 end subroutine
479 subroutine check_real_alloc_rank_3_true_mask()
480 real, allocatable :: a(:,:,:)
481 integer, allocatable :: r(:)
482 allocate(a(4,4,4))
483 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
484 r = maxloc(a, mask = .true.)
485 if (size(r, dim = 1) /= 3) stop 221
486 if (any(r /= (/ 2, 2, 1 /))) stop 222
487 end subroutine
488 subroutine check_real_alloc_rank_3_false_mask()
489 real, allocatable :: a(:,:,:)
490 integer, allocatable :: r(:)
491 allocate(a(4,4,4))
492 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
493 r = maxloc(a, mask = .false.)
494 if (size(r, dim = 1) /= 3) stop 231
495 if (any(r /= (/ 0, 0, 0 /))) stop 232
496 end subroutine
497 end subroutine check_maxloc_with_mask
498 subroutine check_minloc_with_mask
499 implicit none
500 integer, parameter :: data10(*) = (/ 2, 5, 2, 3, 3, 5, 3, 6, 0, 1 /)
501 logical, parameter :: mask10(*) = (/ .false., .true., .false., &
502 .false., .true., .true., &
503 .true. , .true., .false., &
504 .false. /)
505 integer, parameter :: data64(*) = (/ 7, 4, 5, 3, 9, 0, 6, 4, &
506 5, 5, 8, 2, 6, 7, 8, 7, &
507 4, 5, 3, 9, 0, 6, 4, 5, &
508 5, 8, 2, 6, 7, 8, 7, 4, &
509 5, 3, 9, 0, 6, 4, 5, 5, &
510 8, 2, 6, 7, 8, 7, 4, 5, &
511 3, 9, 0, 6, 4, 5, 5, 8, &
512 2, 6, 7, 8, 7, 4, 5, 3 /)
513 logical, parameter :: mask64(*) = (/ .true. , .false., .false., .false., &
514 .true. , .false., .true. , .false., &
515 .false., .true. , .true. , .false., &
516 .true. , .true. , .true. , .true. , &
517 .false., .true. , .false., .true. , &
518 .false., .true. , .false., .true. , &
519 .true. , .false., .false., .true. , &
520 .true. , .true. , .true. , .false., &
521 .false., .false., .true. , .false., &
522 .true. , .false., .true. , .true. , &
523 .true. , .false., .true. , .true. , &
524 .false., .true. , .false., .true. , &
525 .false., .true. , .false., .false., &
526 .false., .true. , .true. , .true. , &
527 .false., .true. , .false., .true. , &
528 .true. , .false., .false., .false. /)
529 call check_int_const_shape_rank_1
530 call check_int_const_shape_rank_3
531 call check_int_const_shape_rank_3_true_mask
532 call check_int_const_shape_rank_3_false_mask
533 call check_int_const_shape_rank_3_optional_mask_present
534 call check_int_const_shape_rank_3_optional_mask_absent
535 call check_int_const_shape_empty_4
536 call check_int_alloc_rank_1
537 call check_int_alloc_rank_3
538 call check_int_alloc_rank_3_true_mask
539 call check_int_alloc_rank_3_false_mask
540 call check_real_const_shape_rank_1
541 call check_real_const_shape_rank_3
542 call check_real_const_shape_rank_3_true_mask
543 call check_real_const_shape_rank_3_false_mask
544 call check_real_const_shape_rank_3_optional_mask_present
545 call check_real_const_shape_rank_3_optional_mask_absent
546 call check_real_const_shape_empty_4
547 call check_real_alloc_rank_1
548 call check_real_alloc_rank_3
549 call check_real_alloc_rank_3_true_mask
550 call check_real_alloc_rank_3_false_mask
551 contains
552 subroutine check_int_const_shape_rank_1()
553 integer :: a(10)
554 logical :: m(10)
555 integer, allocatable :: r(:)
556 a = data10
557 m = mask10
558 r = minloc(a, mask = m)
559 if (size(r, dim = 1) /= 1) stop 11
560 if (any(r /= (/ 5 /))) stop 12
561 end subroutine
562 subroutine check_int_const_shape_rank_3()
563 integer :: a(4,4,4)
564 logical :: m(4,4,4)
565 integer, allocatable :: r(:)
566 a = reshape(data64, shape(a))
567 m = reshape(mask64, shape(m))
568 r = minloc(a, mask = m)
569 if (size(r, dim = 1) /= 3) stop 21
570 if (any(r /= (/ 2, 3, 1 /))) stop 22
571 end subroutine
572 subroutine check_int_const_shape_rank_3_true_mask()
573 integer :: a(4,4,4)
574 integer, allocatable :: r(:)
575 a = reshape(data64, shape(a))
576 r = minloc(a, mask = .true.)
577 if (size(r, dim = 1) /= 3) stop 31
578 if (any(r /= (/ 2, 2, 1 /))) stop 32
579 end subroutine
580 subroutine check_int_const_shape_rank_3_false_mask()
581 integer :: a(4,4,4)
582 integer, allocatable :: r(:)
583 a = reshape(data64, shape(a))
584 r = minloc(a, mask = .false.)
585 if (size(r, dim = 1) /= 3) stop 41
586 if (any(r /= (/ 0, 0, 0 /))) stop 42
587 end subroutine
588 subroutine call_minloc_int(r, a, m)
589 integer :: a(:,:,:)
590 logical, optional :: m(:,:,:)
591 integer, allocatable :: r(:)
592 r = minloc(a, mask = m)
593 end subroutine
594 subroutine check_int_const_shape_rank_3_optional_mask_present()
595 integer :: a(4,4,4)
596 logical :: m(4,4,4)
597 integer, allocatable :: r(:)
598 a = reshape(data64, shape(a))
599 m = reshape(mask64, shape(m))
600 call call_minloc_int(r, a, m)
601 if (size(r, dim = 1) /= 3) stop 51
602 if (any(r /= (/ 2, 3, 1 /))) stop 52
603 end subroutine
604 subroutine check_int_const_shape_rank_3_optional_mask_absent()
605 integer :: a(4,4,4)
606 integer, allocatable :: r(:)
607 a = reshape(data64, shape(a))
608 call call_minloc_int(r, a)
609 if (size(r, dim = 1) /= 3) stop 61
610 if (any(r /= (/ 2, 2, 1 /))) stop 62
611 end subroutine
612 subroutine check_int_const_shape_empty_4()
613 integer :: a(9,3,0,7)
614 logical :: m(9,3,0,7)
615 integer, allocatable :: r(:)
616 a = reshape((/ integer:: /), shape(a))
617 m = reshape((/ logical:: /), shape(m))
618 r = minloc(a, mask = m)
619 if (size(r, dim = 1) /= 4) stop 71
620 if (any(r /= (/ 0, 0, 0, 0 /))) stop 72
621 end subroutine
622 subroutine check_int_alloc_rank_1()
623 integer, allocatable :: a(:)
624 logical, allocatable :: m(:)
625 integer, allocatable :: r(:)
626 allocate(a(10), m(10))
627 a(:) = data10
628 m(:) = mask10
629 r = minloc(a, mask = m)
630 if (size(r, dim = 1) /= 1) stop 81
631 if (any(r /= (/ 5 /))) stop 82
632 end subroutine
633 subroutine check_int_alloc_rank_3()
634 integer, allocatable :: a(:,:,:)
635 logical, allocatable :: m(:,:,:)
636 integer, allocatable :: r(:)
637 allocate(a(4,4,4), m(4,4,4))
638 a(:,:,:) = reshape(data64, shape(a))
639 m(:,:,:) = reshape(mask64, shape(m))
640 r = minloc(a, mask = m)
641 if (size(r, dim = 1) /= 3) stop 91
642 if (any(r /= (/ 2, 3, 1 /))) stop 92
643 end subroutine
644 subroutine check_int_alloc_rank_3_true_mask()
645 integer, allocatable :: a(:,:,:)
646 integer, allocatable :: r(:)
647 allocate(a(4,4,4))
648 a(:,:,:) = reshape(data64, shape(a))
649 r = minloc(a, mask = .true.)
650 if (size(r, dim = 1) /= 3) stop 101
651 if (any(r /= (/ 2, 2, 1 /))) stop 102
652 end subroutine
653 subroutine check_int_alloc_rank_3_false_mask()
654 integer, allocatable :: a(:,:,:)
655 integer, allocatable :: r(:)
656 allocate(a(4,4,4))
657 a(:,:,:) = reshape(data64, shape(a))
658 r = minloc(a, mask = .false.)
659 if (size(r, dim = 1) /= 3) stop 111
660 if (any(r /= (/ 0, 0, 0 /))) stop 112
661 end subroutine
662 subroutine check_real_const_shape_rank_1()
663 real :: a(10)
664 logical :: m(10)
665 integer, allocatable :: r(:)
666 a = (/ real:: data10 /)
667 m = mask10
668 r = minloc(a, mask = m)
669 if (size(r, dim = 1) /= 1) stop 131
670 if (any(r /= (/ 5 /))) stop 132
671 end subroutine
672 subroutine check_real_const_shape_rank_3()
673 real :: a(4,4,4)
674 logical :: m(4,4,4)
675 integer, allocatable :: r(:)
676 a = reshape((/ real:: data64 /), shape(a))
677 m = reshape(mask64, shape(m))
678 r = minloc(a, mask = m)
679 if (size(r, dim = 1) /= 3) stop 141
680 if (any(r /= (/ 2, 3, 1 /))) stop 142
681 end subroutine
682 subroutine check_real_const_shape_rank_3_true_mask()
683 real :: a(4,4,4)
684 integer, allocatable :: r(:)
685 a = reshape((/ real:: data64 /), shape(a))
686 r = minloc(a, mask = .true.)
687 if (size(r, dim = 1) /= 3) stop 151
688 if (any(r /= (/ 2, 2, 1 /))) stop 152
689 end subroutine
690 subroutine check_real_const_shape_rank_3_false_mask()
691 real :: a(4,4,4)
692 integer, allocatable :: r(:)
693 a = reshape((/ real:: data64 /), shape(a))
694 r = minloc(a, mask = .false.)
695 if (size(r, dim = 1) /= 3) stop 161
696 if (any(r /= (/ 0, 0, 0 /))) stop 162
697 end subroutine
698 subroutine call_minloc_real(r, a, m)
699 real :: a(:,:,:)
700 logical, optional :: m(:,:,:)
701 integer, allocatable :: r(:)
702 r = minloc(a, mask = m)
703 end subroutine
704 subroutine check_real_const_shape_rank_3_optional_mask_present()
705 real :: a(4,4,4)
706 logical :: m(4,4,4)
707 integer, allocatable :: r(:)
708 a = reshape((/ real:: data64 /), shape(a))
709 m = reshape(mask64, shape(m))
710 call call_minloc_real(r, a, m)
711 if (size(r, dim = 1) /= 3) stop 171
712 if (any(r /= (/ 2, 3, 1 /))) stop 172
713 end subroutine
714 subroutine check_real_const_shape_rank_3_optional_mask_absent()
715 real :: a(4,4,4)
716 integer, allocatable :: r(:)
717 a = reshape((/ real:: data64 /), shape(a))
718 call call_minloc_real(r, a)
719 if (size(r, dim = 1) /= 3) stop 181
720 if (any(r /= (/ 2, 2, 1 /))) stop 182
721 end subroutine
722 subroutine check_real_const_shape_empty_4()
723 real :: a(9,3,0,7)
724 logical :: m(9,3,0,7)
725 integer, allocatable :: r(:)
726 a = reshape((/ real:: /), shape(a))
727 m = reshape((/ logical:: /), shape(m))
728 r = minloc(a, mask = m)
729 if (size(r, dim = 1) /= 4) stop 191
730 if (any(r /= (/ 0, 0, 0, 0 /))) stop 192
731 end subroutine
732 subroutine check_real_alloc_rank_1()
733 real, allocatable :: a(:)
734 logical, allocatable :: m(:)
735 integer, allocatable :: r(:)
736 allocate(a(10), m(10))
737 a(:) = (/ real:: data10 /)
738 m(:) = mask10
739 r = minloc(a, mask = m)
740 if (size(r, dim = 1) /= 1) stop 201
741 if (any(r /= (/ 5 /))) stop 202
742 end subroutine
743 subroutine check_real_alloc_rank_3()
744 real, allocatable :: a(:,:,:)
745 logical, allocatable :: m(:,:,:)
746 integer, allocatable :: r(:)
747 allocate(a(4,4,4), m(4,4,4))
748 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
749 m(:,:,:) = reshape(mask64, shape(m))
750 r = minloc(a, mask = m)
751 if (size(r, dim = 1) /= 3) stop 211
752 if (any(r /= (/ 2, 3, 1 /))) stop 212
753 end subroutine
754 subroutine check_real_alloc_rank_3_true_mask()
755 real, allocatable :: a(:,:,:)
756 integer, allocatable :: r(:)
757 allocate(a(4,4,4))
758 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
759 r = minloc(a, mask = .true.)
760 if (size(r, dim = 1) /= 3) stop 221
761 if (any(r /= (/ 2, 2, 1 /))) stop 222
762 end subroutine
763 subroutine check_real_alloc_rank_3_false_mask()
764 real, allocatable :: a(:,:,:)
765 integer, allocatable :: r(:)
766 allocate(a(4,4,4))
767 a(:,:,:) = reshape((/ real:: data64 /), shape(a))
768 r = minloc(a, mask = .false.)
769 if (size(r, dim = 1) /= 3) stop 231
770 if (any(r /= (/ 0, 0, 0 /))) stop 232
771 end subroutine
772 end subroutine check_minloc_with_mask