| 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, |
| 8 |
! when DIM is a constant, and either ARRAY has REAL type or MASK is non-scalar. |
| 9 |
|
| 10 |
subroutine check_real_maxloc |
| 11 |
implicit none |
| 12 |
integer, parameter :: data60(*) = (/ 2, 5, 4, 6, 0, 9, 3, 5, 4, 4, & |
| 13 |
1, 7, 3, 2, 1, 2, 5, 4, 6, 0, & |
| 14 |
9, 3, 5, 4, 4, 1, 7, 3, 2, 1, & |
| 15 |
2, 5, 4, 6, 0, 9, 3, 5, 4, 4, & |
| 16 |
1, 7, 3, 2, 1, 2, 5, 4, 6, 0, & |
| 17 |
9, 3, 5, 4, 4, 1, 7, 3, 2, 1 /) |
| 18 |
integer, parameter :: data1(*) = (/ 2, 3, 2, 3, & |
| 19 |
1, 2, 3, 2, & |
| 20 |
3, 1, 2, 3, & |
| 21 |
2, 3, 1, 2, & |
| 22 |
3, 2, 3, 1 /) |
| 23 |
integer, parameter :: data2(*) = (/ 2, 1, 2, & |
| 24 |
3, 2, 3, & |
| 25 |
4, 3, 4, & |
| 26 |
2, 1, 2, & |
| 27 |
1, 2, 1 /) |
| 28 |
integer, parameter :: data3(*) = (/ 5, 1, 5, & |
| 29 |
1, 2, 1, & |
| 30 |
2, 1, 2, & |
| 31 |
3, 2, 3 /) |
| 32 |
call check_real_const_shape_rank_3 |
| 33 |
call check_real_const_shape_empty_4 |
| 34 |
call check_real_alloc_rank_3 |
| 35 |
call check_real_alloc_empty_4 |
| 36 |
contains |
| 37 |
subroutine check_real_const_shape_rank_3() |
| 38 |
real :: a(3,4,5) |
| 39 |
integer, allocatable :: r(:,:) |
| 40 |
a = reshape((/ real:: data60 /), shape(a)) |
| 41 |
r = maxloc(a, dim=1) |
| 42 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 1 |
| 43 |
if (any(r /= reshape((/ real:: data1 /), (/ 4, 5 /)))) error stop 2 |
| 44 |
r = maxloc(a, dim=2) |
| 45 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 3 |
| 46 |
if (any(r /= reshape((/ real:: data2 /), (/ 3, 5 /)))) error stop 4 |
| 47 |
r = maxloc(a, dim=3) |
| 48 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 5 |
| 49 |
if (any(r /= reshape((/ real:: data3 /), (/ 3, 4 /)))) error stop 6 |
| 50 |
end subroutine |
| 51 |
subroutine check_real_const_shape_empty_4() |
| 52 |
real :: a(9,3,0,7) |
| 53 |
integer, allocatable :: r(:,:,:) |
| 54 |
a = reshape((/ real:: /), shape(a)) |
| 55 |
r = maxloc(a, dim=1) |
| 56 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 11 |
| 57 |
r = maxloc(a, dim=2) |
| 58 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 12 |
| 59 |
r = maxloc(a, dim=3) |
| 60 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 13 |
| 61 |
if (any(r /= 0)) error stop 14 |
| 62 |
r = maxloc(a, dim=4) |
| 63 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 15 |
| 64 |
end subroutine |
| 65 |
subroutine check_real_alloc_rank_3() |
| 66 |
real, allocatable :: a(:,:,:) |
| 67 |
integer, allocatable :: r(:,:) |
| 68 |
allocate(a(3,4,5)) |
| 69 |
a(:,:,:) = reshape((/ real:: data60 /), shape(a)) |
| 70 |
r = maxloc(a, dim=1) |
| 71 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 21 |
| 72 |
if (any(r /= reshape((/ real:: data1 /), shape=(/ 4, 5 /)))) error stop 22 |
| 73 |
r = maxloc(a, dim=2) |
| 74 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 23 |
| 75 |
if (any(r /= reshape((/ real:: data2 /), shape=(/ 3, 5 /)))) error stop 24 |
| 76 |
r = maxloc(a, dim=3) |
| 77 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 25 |
| 78 |
if (any(r /= reshape((/ real:: data3 /), shape=(/ 3, 4 /)))) error stop 26 |
| 79 |
end subroutine |
| 80 |
subroutine check_real_alloc_empty_4() |
| 81 |
real, allocatable :: a(:,:,:,:) |
| 82 |
integer, allocatable :: r(:,:,:) |
| 83 |
allocate(a(9,3,0,7)) |
| 84 |
a(:,:,:,:) = reshape((/ real:: /), shape(a)) |
| 85 |
r = maxloc(a, dim=1) |
| 86 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 31 |
| 87 |
r = maxloc(a, dim=2) |
| 88 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 32 |
| 89 |
r = maxloc(a, dim=3) |
| 90 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 33 |
| 91 |
if (any(r /= 0)) error stop 34 |
| 92 |
r = maxloc(a, dim=4) |
| 93 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 35 |
| 94 |
end subroutine |
| 95 |
end subroutine |
| 96 |
|
| 97 |
subroutine check_maxloc_with_mask |
| 98 |
implicit none |
| 99 |
integer, parameter :: data60(*) = (/ 2, 5, 4, 6, 0, 9, 3, 5, 4, 4, & |
| 100 |
1, 7, 3, 2, 1, 2, 5, 4, 6, 0, & |
| 101 |
9, 3, 5, 4, 4, 1, 7, 3, 2, 1, & |
| 102 |
2, 5, 4, 6, 0, 9, 3, 5, 4, 4, & |
| 103 |
1, 7, 3, 2, 1, 2, 5, 4, 6, 0, & |
| 104 |
9, 3, 5, 4, 4, 1, 7, 3, 2, 1 /) |
| 105 |
logical, parameter :: mask60(*) = (/ .true. , .false., .false., .false., & |
| 106 |
.true. , .false., .true. , .false., & |
| 107 |
.false., .true. , .true. , .false., & |
| 108 |
.true. , .true. , .true. , .true. , & |
| 109 |
.false., .true. , .false., .true. , & |
| 110 |
.false., .true. , .false., .true. , & |
| 111 |
.true. , .false., .false., .true. , & |
| 112 |
.true. , .true. , .true. , .false., & |
| 113 |
.false., .false., .true. , .false., & |
| 114 |
.true. , .false., .true. , .true. , & |
| 115 |
.true. , .false., .true. , .true. , & |
| 116 |
.false., .true. , .false., .true. , & |
| 117 |
.false., .true. , .false., .false., & |
| 118 |
.false., .true. , .true. , .true. , & |
| 119 |
.false., .true. , .false., .true. /) |
| 120 |
integer, parameter :: data1(*) = (/ 2, 3, 2, 3, & |
| 121 |
1, 2, 3, 2, & |
| 122 |
3, 1, 2, 3, & |
| 123 |
2, 3, 1, 2, & |
| 124 |
3, 2, 3, 1 /) |
| 125 |
integer, parameter :: data2(*) = (/ 2, 1, 2, & |
| 126 |
3, 2, 3, & |
| 127 |
4, 3, 4, & |
| 128 |
2, 1, 2, & |
| 129 |
1, 2, 1 /) |
| 130 |
integer, parameter :: data3(*) = (/ 5, 1, 5, & |
| 131 |
1, 2, 1, & |
| 132 |
2, 1, 2, & |
| 133 |
3, 2, 3 /) |
| 134 |
integer, parameter :: data1m(*) = (/ 1, 2, 1, 1, & |
| 135 |
1, 3, 2, 3, & |
| 136 |
1, 1, 1, 2, & |
| 137 |
3, 1, 1, 3, & |
| 138 |
2, 3, 1, 1 /) |
| 139 |
integer, parameter :: data2m(*) = (/ 4, 4, 0, & |
| 140 |
1, 1, 2, & |
| 141 |
1, 2, 2, & |
| 142 |
2, 3, 1, & |
| 143 |
3, 3, 2 /) |
| 144 |
integer, parameter :: data3m(*) = (/ 3, 2, 4, & |
| 145 |
4, 3, 2, & |
| 146 |
5, 4, 0, & |
| 147 |
1, 1, 2 /) |
| 148 |
call check_int_const_shape_rank_3 |
| 149 |
call check_int_const_shape_empty_4 |
| 150 |
call check_int_alloc_rank_3 |
| 151 |
call check_int_alloc_empty_4 |
| 152 |
call check_real_const_shape_rank_3 |
| 153 |
call check_real_const_shape_empty_4 |
| 154 |
call check_real_alloc_rank_3 |
| 155 |
call check_real_alloc_empty_4 |
| 156 |
contains |
| 157 |
subroutine check_int_const_shape_rank_3() |
| 158 |
integer :: a(3,4,5) |
| 159 |
logical :: m(3,4,5) |
| 160 |
integer, allocatable :: r(:,:) |
| 161 |
a = reshape(data60, shape(a)) |
| 162 |
m = reshape(mask60, shape(m)) |
| 163 |
r = maxloc(a, dim = 1, mask = m) |
| 164 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 41 |
| 165 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 42 |
| 166 |
r = maxloc(a, dim = 2, mask = m) |
| 167 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 43 |
| 168 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 44 |
| 169 |
r = maxloc(a, dim = 3, mask = m) |
| 170 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 45 |
| 171 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 46 |
| 172 |
end subroutine |
| 173 |
subroutine check_int_const_shape_empty_4() |
| 174 |
integer :: a(9,3,0,7) |
| 175 |
logical :: m(9,3,0,7) |
| 176 |
integer, allocatable :: r(:,:,:) |
| 177 |
a = reshape((/ integer:: /), shape(a)) |
| 178 |
m = reshape((/ logical:: /), shape(m)) |
| 179 |
r = maxloc(a, dim = 1, mask = m) |
| 180 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 51 |
| 181 |
r = maxloc(a, dim = 2, mask = m) |
| 182 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 52 |
| 183 |
r = maxloc(a, dim = 3, mask = m) |
| 184 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 53 |
| 185 |
if (any(r /= 0)) error stop 54 |
| 186 |
r = maxloc(a, dim = 4, mask = m) |
| 187 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 55 |
| 188 |
end subroutine |
| 189 |
subroutine check_int_alloc_rank_3() |
| 190 |
integer, allocatable :: a(:,:,:) |
| 191 |
logical, allocatable :: m(:,:,:) |
| 192 |
integer, allocatable :: r(:,:) |
| 193 |
allocate(a(3,4,5), m(3,4,5)) |
| 194 |
a(:,:,:) = reshape(data60, shape(a)) |
| 195 |
m(:,:,:) = reshape(mask60, shape(m)) |
| 196 |
r = maxloc(a, dim = 1, mask = m) |
| 197 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 61 |
| 198 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 62 |
| 199 |
r = maxloc(a, dim = 2, mask = m) |
| 200 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 63 |
| 201 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 64 |
| 202 |
r = maxloc(a, dim = 3, mask = m) |
| 203 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 65 |
| 204 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 66 |
| 205 |
end subroutine |
| 206 |
subroutine check_int_alloc_empty_4() |
| 207 |
integer, allocatable :: a(:,:,:,:) |
| 208 |
logical, allocatable :: m(:,:,:,:) |
| 209 |
integer, allocatable :: r(:,:,:) |
| 210 |
allocate(a(9,3,0,7), m(9,3,0,7)) |
| 211 |
a(:,:,:,:) = reshape((/ integer:: /), shape(a)) |
| 212 |
m(:,:,:,:) = reshape((/ logical:: /), shape(m)) |
| 213 |
r = maxloc(a, dim = 1, mask = m) |
| 214 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 71 |
| 215 |
r = maxloc(a, dim = 2, mask = m) |
| 216 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 72 |
| 217 |
r = maxloc(a, dim = 3, mask = m) |
| 218 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 73 |
| 219 |
if (any(r /= 0)) error stop 74 |
| 220 |
r = maxloc(a, dim = 4, mask = m) |
| 221 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 75 |
| 222 |
end subroutine |
| 223 |
subroutine check_real_const_shape_rank_3() |
| 224 |
real :: a(3,4,5) |
| 225 |
logical :: m(3,4,5) |
| 226 |
integer, allocatable :: r(:,:) |
| 227 |
a = reshape((/ real:: data60 /), shape(a)) |
| 228 |
m = reshape(mask60, shape(m)) |
| 229 |
r = maxloc(a, dim = 1, mask = m) |
| 230 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 81 |
| 231 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 82 |
| 232 |
r = maxloc(a, dim = 2, mask = m) |
| 233 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 83 |
| 234 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 84 |
| 235 |
r = maxloc(a, dim = 3, mask = m) |
| 236 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 85 |
| 237 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 86 |
| 238 |
end subroutine |
| 239 |
subroutine check_real_const_shape_empty_4() |
| 240 |
real :: a(9,3,0,7) |
| 241 |
logical :: m(9,3,0,7) |
| 242 |
integer, allocatable :: r(:,:,:) |
| 243 |
a = reshape((/ real:: /), shape(a)) |
| 244 |
m = reshape((/ logical:: /), shape(m)) |
| 245 |
r = maxloc(a, dim = 1, mask = m) |
| 246 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 91 |
| 247 |
r = maxloc(a, dim = 2, mask = m) |
| 248 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 92 |
| 249 |
r = maxloc(a, dim = 3, mask = m) |
| 250 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 93 |
| 251 |
if (any(r /= 0)) error stop 94 |
| 252 |
r = maxloc(a, dim = 4, mask = m) |
| 253 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 95 |
| 254 |
end subroutine |
| 255 |
subroutine check_real_alloc_rank_3() |
| 256 |
real, allocatable :: a(:,:,:) |
| 257 |
logical, allocatable :: m(:,:,:) |
| 258 |
integer, allocatable :: r(:,:) |
| 259 |
allocate(a(3,4,5), m(3,4,5)) |
| 260 |
a(:,:,:) = reshape((/ real:: data60 /), shape(a)) |
| 261 |
m(:,:,:) = reshape(mask60, shape(m)) |
| 262 |
r = maxloc(a, dim = 1, mask = m) |
| 263 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 101 |
| 264 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 102 |
| 265 |
r = maxloc(a, dim = 2, mask = m) |
| 266 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 103 |
| 267 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 104 |
| 268 |
r = maxloc(a, dim = 3, mask = m) |
| 269 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 105 |
| 270 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 106 |
| 271 |
end subroutine |
| 272 |
subroutine check_real_alloc_empty_4() |
| 273 |
real, allocatable :: a(:,:,:,:) |
| 274 |
logical, allocatable :: m(:,:,:,:) |
| 275 |
integer, allocatable :: r(:,:,:) |
| 276 |
allocate(a(9,3,0,7), m(9,3,0,7)) |
| 277 |
a(:,:,:,:) = reshape((/ real:: /), shape(a)) |
| 278 |
m(:,:,:,:) = reshape((/ logical :: /), shape(m)) |
| 279 |
r = maxloc(a, dim = 1, mask = m) |
| 280 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 111 |
| 281 |
r = maxloc(a, dim = 2, mask = m) |
| 282 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 112 |
| 283 |
r = maxloc(a, dim = 3, mask = m) |
| 284 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 113 |
| 285 |
if (any(r /= 0)) error stop 114 |
| 286 |
r = maxloc(a, dim = 4, mask = m) |
| 287 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 115 |
| 288 |
end subroutine |
| 289 |
end subroutine |
| 290 |
|
| 291 |
subroutine check_real_minloc |
| 292 |
implicit none |
| 293 |
integer, parameter :: data60(*) = (/ 7, 4, 5, 3, 9, 0, 6, 4, 5, 5, & |
| 294 |
8, 2, 6, 7, 8, 7, 4, 5, 3, 9, & |
| 295 |
0, 6, 4, 5, 5, 8, 2, 6, 7, 8, & |
| 296 |
7, 4, 5, 3, 9, 0, 6, 4, 5, 5, & |
| 297 |
8, 2, 6, 7, 8, 7, 4, 5, 3, 9, & |
| 298 |
0, 6, 4, 5, 5, 8, 2, 6, 7, 8 /) |
| 299 |
integer, parameter :: data1(*) = (/ 2, 3, 2, 3, & |
| 300 |
1, 2, 3, 2, & |
| 301 |
3, 1, 2, 3, & |
| 302 |
2, 3, 1, 2, & |
| 303 |
3, 2, 3, 1 /) |
| 304 |
integer, parameter :: data2(*) = (/ 2, 1, 2, & |
| 305 |
3, 2, 3, & |
| 306 |
4, 3, 4, & |
| 307 |
2, 1, 2, & |
| 308 |
1, 2, 1 /) |
| 309 |
integer, parameter :: data3(*) = (/ 5, 1, 5, & |
| 310 |
1, 2, 1, & |
| 311 |
2, 1, 2, & |
| 312 |
3, 2, 3 /) |
| 313 |
call check_real_const_shape_rank_3 |
| 314 |
call check_real_const_shape_empty_4 |
| 315 |
call check_real_alloc_rank_3 |
| 316 |
call check_real_alloc_empty_4 |
| 317 |
contains |
| 318 |
subroutine check_real_const_shape_rank_3() |
| 319 |
real :: a(3,4,5) |
| 320 |
integer, allocatable :: r(:,:) |
| 321 |
a = reshape((/ real:: data60 /), shape(a)) |
| 322 |
r = minloc(a, dim=1) |
| 323 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 141 |
| 324 |
if (any(r /= reshape((/ real:: data1 /), (/ 4, 5 /)))) error stop 142 |
| 325 |
r = minloc(a, dim=2) |
| 326 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 143 |
| 327 |
if (any(r /= reshape((/ real:: data2 /), (/ 3, 5 /)))) error stop 144 |
| 328 |
r = minloc(a, dim=3) |
| 329 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 145 |
| 330 |
if (any(r /= reshape((/ real:: data3 /), (/ 3, 4 /)))) error stop 146 |
| 331 |
end subroutine |
| 332 |
subroutine check_real_const_shape_empty_4() |
| 333 |
real :: a(9,3,0,7) |
| 334 |
integer, allocatable :: r(:,:,:) |
| 335 |
a = reshape((/ real:: /), shape(a)) |
| 336 |
r = minloc(a, dim=1) |
| 337 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 151 |
| 338 |
r = minloc(a, dim=2) |
| 339 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 152 |
| 340 |
r = minloc(a, dim=3) |
| 341 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 153 |
| 342 |
if (any(r /= 0)) error stop 154 |
| 343 |
r = minloc(a, dim=4) |
| 344 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 155 |
| 345 |
end subroutine |
| 346 |
subroutine check_real_alloc_rank_3() |
| 347 |
real, allocatable :: a(:,:,:) |
| 348 |
integer, allocatable :: r(:,:) |
| 349 |
allocate(a(3,4,5)) |
| 350 |
a(:,:,:) = reshape((/ real:: data60 /), shape(a)) |
| 351 |
r = minloc(a, dim=1) |
| 352 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 161 |
| 353 |
if (any(r /= reshape((/ real:: data1 /), shape=(/ 4, 5 /)))) error stop 162 |
| 354 |
r = minloc(a, dim=2) |
| 355 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 163 |
| 356 |
if (any(r /= reshape((/ real:: data2 /), shape=(/ 3, 5 /)))) error stop 164 |
| 357 |
r = minloc(a, dim=3) |
| 358 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 165 |
| 359 |
if (any(r /= reshape((/ real:: data3 /), shape=(/ 3, 4 /)))) error stop 166 |
| 360 |
end subroutine |
| 361 |
subroutine check_real_alloc_empty_4() |
| 362 |
real, allocatable :: a(:,:,:,:) |
| 363 |
integer, allocatable :: r(:,:,:) |
| 364 |
allocate(a(9,3,0,7)) |
| 365 |
a(:,:,:,:) = reshape((/ real:: /), shape(a)) |
| 366 |
r = minloc(a, dim=1) |
| 367 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 171 |
| 368 |
r = minloc(a, dim=2) |
| 369 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 172 |
| 370 |
r = minloc(a, dim=3) |
| 371 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 173 |
| 372 |
if (any(r /= 0)) error stop 174 |
| 373 |
r = minloc(a, dim=4) |
| 374 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 175 |
| 375 |
end subroutine |
| 376 |
end subroutine |
| 377 |
|
| 378 |
subroutine check_minloc_with_mask |
| 379 |
implicit none |
| 380 |
integer, parameter :: data60(*) = (/ 7, 4, 5, 3, 9, 0, 6, 4, 5, 5, & |
| 381 |
8, 2, 6, 7, 8, 7, 4, 5, 3, 9, & |
| 382 |
0, 6, 4, 5, 5, 8, 2, 6, 7, 8, & |
| 383 |
7, 4, 5, 3, 9, 0, 6, 4, 5, 5, & |
| 384 |
8, 2, 6, 7, 8, 7, 4, 5, 3, 9, & |
| 385 |
0, 6, 4, 5, 5, 8, 2, 6, 7, 8 /) |
| 386 |
logical, parameter :: mask60(*) = (/ .true. , .false., .false., .false., & |
| 387 |
.true. , .false., .true. , .false., & |
| 388 |
.false., .true. , .true. , .false., & |
| 389 |
.true. , .true. , .true. , .true. , & |
| 390 |
.false., .true. , .false., .true. , & |
| 391 |
.false., .true. , .false., .true. , & |
| 392 |
.true. , .false., .false., .true. , & |
| 393 |
.true. , .true. , .true. , .false., & |
| 394 |
.false., .false., .true. , .false., & |
| 395 |
.true. , .false., .true. , .true. , & |
| 396 |
.true. , .false., .true. , .true. , & |
| 397 |
.false., .true. , .false., .true. , & |
| 398 |
.false., .true. , .false., .false., & |
| 399 |
.false., .true. , .true. , .true. , & |
| 400 |
.false., .true. , .false., .true. /) |
| 401 |
integer, parameter :: data1(*) = (/ 2, 3, 2, 3, & |
| 402 |
1, 2, 3, 2, & |
| 403 |
3, 1, 2, 3, & |
| 404 |
2, 3, 1, 2, & |
| 405 |
3, 2, 3, 1 /) |
| 406 |
integer, parameter :: data2(*) = (/ 2, 1, 2, & |
| 407 |
3, 2, 3, & |
| 408 |
4, 3, 4, & |
| 409 |
2, 1, 2, & |
| 410 |
1, 2, 1 /) |
| 411 |
integer, parameter :: data3(*) = (/ 5, 1, 5, & |
| 412 |
1, 2, 1, & |
| 413 |
2, 1, 2, & |
| 414 |
3, 2, 3 /) |
| 415 |
integer, parameter :: data1m(*) = (/ 1, 2, 1, 1, & |
| 416 |
1, 3, 2, 3, & |
| 417 |
1, 1, 1, 2, & |
| 418 |
3, 1, 1, 3, & |
| 419 |
2, 3, 1, 1 /) |
| 420 |
integer, parameter :: data2m(*) = (/ 4, 4, 0, & |
| 421 |
1, 1, 2, & |
| 422 |
1, 2, 2, & |
| 423 |
2, 3, 1, & |
| 424 |
3, 3, 2 /) |
| 425 |
integer, parameter :: data3m(*) = (/ 3, 2, 4, & |
| 426 |
4, 3, 2, & |
| 427 |
5, 4, 0, & |
| 428 |
1, 1, 2 /) |
| 429 |
call check_int_const_shape_rank_3 |
| 430 |
call check_int_const_shape_empty_4 |
| 431 |
call check_int_alloc_rank_3 |
| 432 |
call check_int_alloc_empty_4 |
| 433 |
call check_real_const_shape_rank_3 |
| 434 |
call check_real_const_shape_empty_4 |
| 435 |
call check_real_alloc_rank_3 |
| 436 |
call check_real_alloc_empty_4 |
| 437 |
call check_lower_bounds |
| 438 |
call check_dependencies |
| 439 |
contains |
| 440 |
subroutine check_int_const_shape_rank_3() |
| 441 |
integer :: a(3,4,5) |
| 442 |
logical :: m(3,4,5) |
| 443 |
integer, allocatable :: r(:,:) |
| 444 |
a = reshape(data60, shape(a)) |
| 445 |
m = reshape(mask60, shape(m)) |
| 446 |
r = minloc(a, dim = 1, mask = m) |
| 447 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 181 |
| 448 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 182 |
| 449 |
r = minloc(a, dim = 2, mask = m) |
| 450 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 183 |
| 451 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 184 |
| 452 |
r = minloc(a, dim = 3, mask = m) |
| 453 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 185 |
| 454 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 186 |
| 455 |
end subroutine |
| 456 |
subroutine check_int_const_shape_empty_4() |
| 457 |
integer :: a(9,3,0,7) |
| 458 |
logical :: m(9,3,0,7) |
| 459 |
integer, allocatable :: r(:,:,:) |
| 460 |
a = reshape((/ integer:: /), shape(a)) |
| 461 |
m = reshape((/ logical:: /), shape(m)) |
| 462 |
r = minloc(a, dim = 1, mask = m) |
| 463 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 191 |
| 464 |
r = minloc(a, dim = 2, mask = m) |
| 465 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 192 |
| 466 |
r = minloc(a, dim = 3, mask = m) |
| 467 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 193 |
| 468 |
if (any(r /= 0)) error stop 194 |
| 469 |
r = minloc(a, dim = 4, mask = m) |
| 470 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 195 |
| 471 |
end subroutine |
| 472 |
subroutine check_int_alloc_rank_3() |
| 473 |
integer, allocatable :: a(:,:,:) |
| 474 |
logical, allocatable :: m(:,:,:) |
| 475 |
integer, allocatable :: r(:,:) |
| 476 |
allocate(a(3,4,5), m(3,4,5)) |
| 477 |
a(:,:,:) = reshape(data60, shape(a)) |
| 478 |
m(:,:,:) = reshape(mask60, shape(m)) |
| 479 |
r = minloc(a, dim = 1, mask = m) |
| 480 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 201 |
| 481 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 202 |
| 482 |
r = minloc(a, dim = 2, mask = m) |
| 483 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 203 |
| 484 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 204 |
| 485 |
r = minloc(a, dim = 3, mask = m) |
| 486 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 205 |
| 487 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 206 |
| 488 |
end subroutine |
| 489 |
subroutine check_int_alloc_empty_4() |
| 490 |
integer, allocatable :: a(:,:,:,:) |
| 491 |
logical, allocatable :: m(:,:,:,:) |
| 492 |
integer, allocatable :: r(:,:,:) |
| 493 |
allocate(a(9,3,0,7), m(9,3,0,7)) |
| 494 |
a(:,:,:,:) = reshape((/ integer:: /), shape(a)) |
| 495 |
m(:,:,:,:) = reshape((/ logical:: /), shape(m)) |
| 496 |
r = minloc(a, dim = 1, mask = m) |
| 497 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 211 |
| 498 |
r = minloc(a, dim = 2, mask = m) |
| 499 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 212 |
| 500 |
r = minloc(a, dim = 3, mask = m) |
| 501 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 213 |
| 502 |
if (any(r /= 0)) error stop 214 |
| 503 |
r = minloc(a, dim = 4, mask = m) |
| 504 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 215 |
| 505 |
end subroutine |
| 506 |
subroutine check_real_const_shape_rank_3() |
| 507 |
real :: a(3,4,5) |
| 508 |
logical :: m(3,4,5) |
| 509 |
integer, allocatable :: r(:,:) |
| 510 |
a = reshape((/ real:: data60 /), shape(a)) |
| 511 |
m = reshape(mask60, shape(m)) |
| 512 |
r = minloc(a, dim = 1, mask = m) |
| 513 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 221 |
| 514 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 222 |
| 515 |
r = minloc(a, dim = 2, mask = m) |
| 516 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 223 |
| 517 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 224 |
| 518 |
r = minloc(a, dim = 3, mask = m) |
| 519 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 225 |
| 520 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 226 |
| 521 |
end subroutine |
| 522 |
subroutine check_real_const_shape_empty_4() |
| 523 |
real :: a(9,3,0,7) |
| 524 |
logical :: m(9,3,0,7) |
| 525 |
integer, allocatable :: r(:,:,:) |
| 526 |
a = reshape((/ real:: /), shape(a)) |
| 527 |
m = reshape((/ logical:: /), shape(m)) |
| 528 |
r = minloc(a, dim = 1, mask = m) |
| 529 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 231 |
| 530 |
r = minloc(a, dim = 2, mask = m) |
| 531 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 232 |
| 532 |
r = minloc(a, dim = 3, mask = m) |
| 533 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 233 |
| 534 |
if (any(r /= 0)) error stop 234 |
| 535 |
r = minloc(a, dim = 4, mask = m) |
| 536 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 235 |
| 537 |
end subroutine |
| 538 |
subroutine check_real_alloc_rank_3() |
| 539 |
real, allocatable :: a(:,:,:) |
| 540 |
logical, allocatable :: m(:,:,:) |
| 541 |
integer, allocatable :: r(:,:) |
| 542 |
allocate(a(3,4,5), m(3,4,5)) |
| 543 |
a(:,:,:) = reshape((/ real:: data60 /), shape(a)) |
| 544 |
m(:,:,:) = reshape(mask60, shape(m)) |
| 545 |
r = minloc(a, dim = 1, mask = m) |
| 546 |
if (any(shape(r) /= (/ 4, 5 /))) error stop 241 |
| 547 |
if (any(r /= reshape(data1m, (/ 4, 5 /)))) error stop 242 |
| 548 |
r = minloc(a, dim = 2, mask = m) |
| 549 |
if (any(shape(r) /= (/ 3, 5 /))) error stop 243 |
| 550 |
if (any(r /= reshape(data2m, (/ 3, 5 /)))) error stop 244 |
| 551 |
r = minloc(a, dim = 3, mask = m) |
| 552 |
if (any(shape(r) /= (/ 3, 4 /))) error stop 245 |
| 553 |
if (any(r /= reshape(data3m, (/ 3, 4 /)))) error stop 246 |
| 554 |
end subroutine |
| 555 |
subroutine check_real_alloc_empty_4() |
| 556 |
real, allocatable :: a(:,:,:,:) |
| 557 |
logical, allocatable :: m(:,:,:,:) |
| 558 |
integer, allocatable :: r(:,:,:) |
| 559 |
allocate(a(9,3,0,7), m(9,3,0,7)) |
| 560 |
a(:,:,:,:) = reshape((/ real:: /), shape(a)) |
| 561 |
m(:,:,:,:) = reshape((/ logical :: /), shape(m)) |
| 562 |
r = minloc(a, dim = 1, mask = m) |
| 563 |
if (any(shape(r) /= (/ 3, 0, 7 /))) error stop 251 |
| 564 |
r = minloc(a, dim = 2, mask = m) |
| 565 |
if (any(shape(r) /= (/ 9, 0, 7 /))) error stop 252 |
| 566 |
r = minloc(a, dim = 3, mask = m) |
| 567 |
if (any(shape(r) /= (/ 9, 3, 7 /))) error stop 253 |
| 568 |
if (any(r /= 0)) error stop 254 |
| 569 |
r = minloc(a, dim = 4, mask = m) |
| 570 |
if (any(shape(r) /= (/ 9, 3, 0 /))) error stop 255 |
| 571 |
end subroutine |
| 572 |
end subroutine |