1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
! { dg-do run }
! PR 16946
! Not all allowed combinations of arguments for MAXVAL, MINVAL,
! PRODUCT and SUM were supported.
program reduction_mask
implicit none
logical :: equal(3)
integer, parameter :: res(4*9) = (/ 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, &
1, 1, 1, 1, 1, 6, 6, 6, 2, 2, 2, 2, 2, 2, 6, 6, 6, 3, 3, 3, 3, 3, 3 /)
integer :: val(4*9)
complex :: cval(2*9), cin(3)
equal = (/ .true., .true., .false. /)
! use all combinations of the dim and mask arguments for the
! reduction intrinsics
val( 1) = maxval((/ 1, 2, 3 /))
val( 2) = maxval((/ 1, 2, 3 /), 1)
val( 3) = maxval((/ 1, 2, 3 /), dim=1)
val( 4) = maxval((/ 1, 2, 3 /), equal)
val( 5) = maxval((/ 1, 2, 3 /), mask=equal)
val( 6) = maxval((/ 1, 2, 3 /), 1, equal)
val( 7) = maxval((/ 1, 2, 3 /), 1, mask=equal)
val( 8) = maxval((/ 1, 2, 3 /), dim=1, mask=equal)
val( 9) = maxval((/ 1, 2, 3 /), mask=equal, dim=1)
val(10) = minval((/ 1, 2, 3 /))
val(11) = minval((/ 1, 2, 3 /), 1)
val(12) = minval((/ 1, 2, 3 /), dim=1)
val(13) = minval((/ 1, 2, 3 /), equal)
val(14) = minval((/ 1, 2, 3 /), mask=equal)
val(15) = minval((/ 1, 2, 3 /), 1, equal)
val(16) = minval((/ 1, 2, 3 /), 1, mask=equal)
val(17) = minval((/ 1, 2, 3 /), dim=1, mask=equal)
val(18) = minval((/ 1, 2, 3 /), mask=equal, dim=1)
val(19) = product((/ 1, 2, 3 /))
val(20) = product((/ 1, 2, 3 /), 1)
val(21) = product((/ 1, 2, 3 /), dim=1)
val(22) = product((/ 1, 2, 3 /), equal)
val(23) = product((/ 1, 2, 3 /), mask=equal)
val(24) = product((/ 1, 2, 3 /), 1, equal)
val(25) = product((/ 1, 2, 3 /), 1, mask=equal)
val(26) = product((/ 1, 2, 3 /), dim=1, mask=equal)
val(27) = product((/ 1, 2, 3 /), mask=equal, dim=1)
val(28) = sum((/ 1, 2, 3 /))
val(29) = sum((/ 1, 2, 3 /), 1)
val(30) = sum((/ 1, 2, 3 /), dim=1)
val(31) = sum((/ 1, 2, 3 /), equal)
val(32) = sum((/ 1, 2, 3 /), mask=equal)
val(33) = sum((/ 1, 2, 3 /), 1, equal)
val(34) = sum((/ 1, 2, 3 /), 1, mask=equal)
val(35) = sum((/ 1, 2, 3 /), dim=1, mask=equal)
val(36) = sum((/ 1, 2, 3 /), mask=equal, dim=1)
if (any (val /= res)) call abort
! Tests for complex arguments. These were broken by the original fix.
cin = cmplx((/1,2,3/))
cval(1) = product(cin)
cval(2) = product(cin, 1)
cval(3) = product(cin, dim=1)
cval(4) = product(cin, equal)
cval(5) = product(cin, mask=equal)
cval(6) = product(cin, 1, equal)
cval(7) = product(cin, 1, mask=equal)
cval(8) = product(cin, dim=1, mask=equal)
cval(9) = product(cin, mask=equal, dim=1)
cval(10) = sum(cin)
cval(11) = sum(cin, 1)
cval(12) = sum(cin, dim=1)
cval(13) = sum(cin, equal)
cval(14) = sum(cin, mask=equal)
cval(15) = sum(cin, 1, equal)
cval(16) = sum(cin, 1, mask=equal)
cval(17) = sum(cin, dim=1, mask=equal)
cval(18) = sum(cin, mask=equal, dim=1)
if (any (cval /= cmplx(res(19:36)))) call abort
end program reduction_mask
|