4 ! The library used to not set the bounds and content of the resulting array
5 ! of a reduction function if the input array had zero extent along the
14 call check_minloc_char
15 call check_maxloc_real
16 call check_maxloc_char
18 call check_minval_char
19 call check_maxval_real
20 call check_maxval_char
26 logical(kind
=1) :: m(3,0,2)
28 integer, allocatable
:: r(:,:)
29 a
= reshape((/ integer:: /), shape(a
))
30 m
= reshape((/ logical(kind
=1):: /), shape(m
))
32 r
= iall(a
, dim
=i
, mask
=m
)
33 if (any(lbound(r
) /= 1)) stop 11
34 if (any(ubound(r
) /= (/ 3, 2 /))) stop 12
35 if (any(shape(r
) /= (/ 3, 2 /))) stop 13
36 if (any(r
/= int(z
'FFFFFFFF'))) stop 14
39 integer(kind
=8) :: a(2,3,0)
40 logical(kind
=1) :: m(2,3,0)
42 integer(kind
=8), allocatable
:: r(:,:)
43 a
= reshape((/ integer(kind
=8):: /), shape(a
))
44 m
= reshape((/ logical(kind
=1):: /), shape(m
))
46 r
= iany(a
, dim
=i
, mask
=m
)
47 if (any(lbound(r
) /= 1)) stop 21
48 if (any(ubound(r
) /= (/ 2, 3 /))) stop 22
49 if (any(shape(r
) /= (/ 2, 3 /))) stop 23
50 if (any(r
/= 0)) stop 24
52 subroutine check_iparity
53 integer(kind
=2) :: a(0,2,3)
54 logical(kind
=1) :: m(0,2,3)
56 integer, allocatable
:: r(:,:)
57 a
= reshape((/ integer(kind
=2):: /), shape(a
))
58 m
= reshape((/ logical(kind
=1):: /), shape(m
))
60 r
= iparity(a
, dim
=i
, mask
=m
)
61 if (any(lbound(r
) /= 1)) stop 31
62 if (any(ubound(r
) /= (/ 2, 3 /))) stop 32
63 if (any(shape(r
) /= (/ 2, 3 /))) stop 33
64 if (any(r
/= 0)) stop 34
66 subroutine check_minloc_int
68 logical(kind
=1) :: m(3,0,2)
70 integer, allocatable
:: r(:,:)
71 a
= reshape((/ integer:: /), shape(a
))
72 m
= reshape((/ logical(kind
=1):: /), shape(m
))
74 r
= minloc(a
, dim
=i
, mask
=m
)
75 if (any(lbound(r
) /= 1)) stop 41
76 if (any(ubound(r
) /= (/ 3, 2 /))) stop 42
77 if (any(shape(r
) /= (/ 3, 2 /))) stop 43
78 if (any(r
/= 0)) stop 44
80 subroutine check_minloc_char
82 logical(kind
=1) :: m(2,3,0)
84 integer, allocatable
:: r(:,:)
85 a
= reshape((/ character:: /), shape(a
))
86 m
= reshape((/ logical(kind
=1):: /), shape(m
))
88 r
= minloc(a
, dim
=i
, mask
=m
)
89 if (any(lbound(r
) /= 1)) stop 51
90 if (any(ubound(r
) /= (/ 2, 3 /))) stop 52
91 if (any(shape(r
) /= (/ 2, 3 /))) stop 53
92 if (any(r
/= 0)) stop 54
94 subroutine check_maxloc_real
96 logical(kind
=1) :: m(0,2,3)
98 integer, allocatable
:: r(:,:)
99 a
= reshape((/ real:: /), shape(a
))
100 m
= reshape((/ logical(kind
=1):: /), shape(m
))
102 r
= maxloc(a
, dim
=i
, mask
=m
)
103 if (any(lbound(r
) /= 1)) stop 61
104 if (any(ubound(r
) /= (/ 2, 3 /))) stop 62
105 if (any(shape(r
) /= (/ 2, 3 /))) stop 63
106 if (any(r
/= 0)) stop 64
108 subroutine check_maxloc_char
109 character(len
=2) :: a(3,0,2)
110 logical(kind
=1) :: m(3,0,2)
112 integer, allocatable
:: r(:,:)
113 a
= reshape((/ character(len
=2):: /), shape(a
))
114 m
= reshape((/ logical(kind
=1):: /), shape(m
))
116 r
= maxloc(a
, dim
=i
, mask
=m
)
117 if (any(lbound(r
) /= 1)) stop 71
118 if (any(ubound(r
) /= (/ 3, 2 /))) stop 72
119 if (any(shape(r
) /= (/ 3, 2 /))) stop 73
120 if (any(r
/= 0)) stop 74
122 subroutine check_minval_int
123 integer(kind
=2) :: a(3,2,0)
124 logical(kind
=1) :: m(3,2,0)
126 integer, allocatable
:: r(:,:)
127 a
= reshape((/ integer(kind
=2):: /), shape(a
))
128 m
= reshape((/ logical(kind
=1):: /), shape(m
))
130 r
= minval(a
, dim
=i
, mask
=m
)
131 if (any(lbound(r
) /= 1)) stop 81
132 if (any(ubound(r
) /= (/ 3, 2 /))) stop 82
133 if (any(shape(r
) /= (/ 3, 2 /))) stop 83
134 if (any(r
/= huge(1_2))) stop 84
136 subroutine check_minval_char
137 character(kind
=4) :: a(0,3,2)
138 logical(kind
=1) :: m(0,3,2)
140 character(kind
=4), allocatable
:: r(:,:)
141 a
= reshape((/ character(kind
=4):: /), shape(a
))
142 m
= reshape((/ logical(kind
=1):: /), shape(m
))
144 r
= minval(a
, dim
=i
, mask
=m
)
145 if (any(lbound(r
) /= 1)) stop 91
146 if (any(ubound(r
) /= (/ 3, 2 /))) stop 92
147 if (any(shape(r
) /= (/ 3, 2 /))) stop 93
148 if (any(r
/= char(int(z
'FFFFFFFF', kind
=8), kind
=4))) stop 94
150 subroutine check_maxval_real
151 real(kind
=8) :: a(0,2,3)
152 logical(kind
=1) :: m(0,2,3)
154 real(kind
=8), allocatable
:: r(:,:)
155 a
= reshape((/ real(kind
=8):: /), shape(a
))
156 m
= reshape((/ logical(kind
=1):: /), shape(m
))
158 r
= maxval(a
, dim
=i
, mask
=m
)
159 if (any(lbound(r
) /= 1)) stop 101
160 if (any(ubound(r
) /= (/ 2, 3 /))) stop 102
161 if (any(shape(r
) /= (/ 2, 3 /))) stop 103
162 if (any(r
/= -huge(1._8
))) stop 104
164 subroutine check_maxval_char
165 character(kind
=4,len
=2) :: a(3,0,2), e
166 logical(kind
=1) :: m(3,0,2)
168 character(len
=2,kind
=4), allocatable
:: r(:,:)
169 a
= reshape((/ character(kind
=4,len
=2):: /), shape(a
))
170 m
= reshape((/ logical(kind
=1):: /), shape(m
))
172 r
= maxval(a
, dim
=i
, mask
=m
)
173 if (any(lbound(r
) /= 1)) stop 111
174 if (any(ubound(r
) /= (/ 3, 2 /))) stop 112
175 if (any(shape(r
) /= (/ 3, 2 /))) stop 113
176 e
= repeat(char(0, kind
=4), len(a
))
177 if (any(r
/= e
)) stop 114
180 integer(kind
=1) :: a(2,3,0)
181 logical(kind
=1) :: m(2,3,0)
183 integer, allocatable
:: r(:,:)
184 a
= reshape((/ integer:: /), shape(a
))
185 m
= reshape((/ logical(kind
=1):: /), shape(m
))
187 r
= sum(a
, dim
=i
, mask
=m
)
188 if (any(lbound(r
) /= 1)) stop 121
189 if (any(ubound(r
) /= (/ 2, 3 /))) stop 122
190 if (any(shape(r
) /= (/ 2, 3 /))) stop 123
191 if (any(r
/= 0)) stop 124
193 subroutine check_product
194 real(kind
=8) :: a(0,2,3)
195 logical(kind
=1) :: m(0,2,3)
197 integer, allocatable
:: r(:,:)
198 a
= reshape((/ real(kind
=8):: /), shape(a
))
199 m
= reshape((/ logical(kind
=1):: /), shape(m
))
201 r
= product(a
, dim
=i
, mask
=m
)
202 if (any(lbound(r
) /= 1)) stop 131
203 if (any(ubound(r
) /= (/ 2, 3 /))) stop 132
204 if (any(shape(r
) /= (/ 2, 3 /))) stop 133
205 if (any(r
/= 1.0_8
)) stop 134