| 1 |
module m |
| 2 |
implicit none (type, external) |
| 3 |
type t |
| 4 |
integer, allocatable :: arr(:,:) |
| 5 |
integer :: var |
| 6 |
integer, allocatable :: slr |
| 7 |
end type t |
| 8 |
|
| 9 |
contains |
| 10 |
|
| 11 |
subroutine check_it (is_present, dummy_alloced, inner_alloc, & |
| 12 |
scalar, array, a_scalar, a_array, & |
| 13 |
l_scalar, l_array, la_scalar, la_array, & |
| 14 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 15 |
type(t), intent(inout) :: & |
| 16 |
scalar, array(:,:), opt_scalar, opt_array(:,:), a_scalar, a_array(:,:), & |
| 17 |
a_opt_scalar, a_opt_array(:,:), & |
| 18 |
l_scalar, l_array(:,:), la_scalar, la_array(:,:) |
| 19 |
optional :: opt_scalar, opt_array, a_opt_scalar, a_opt_array |
| 20 |
allocatable :: a_scalar, a_array, a_opt_scalar, a_opt_array, la_scalar, la_array |
| 21 |
logical, value :: is_present, dummy_alloced, inner_alloc |
| 22 |
integer :: i, j, k, l |
| 23 |
|
| 24 |
! CHECK VALUE |
| 25 |
if (scalar%var /= 42) stop 1 |
| 26 |
if (l_scalar%var /= 42) stop 1 |
| 27 |
if (is_present) then |
| 28 |
if (opt_scalar%var /= 42) stop 2 |
| 29 |
end if |
| 30 |
if (any (shape(array) /= [3,2])) stop 1 |
| 31 |
if (any (shape(l_array) /= [3,2])) stop 1 |
| 32 |
if (is_present) then |
| 33 |
if (any (shape(opt_array) /= [3,2])) stop 1 |
| 34 |
end if |
| 35 |
do j = 1, 2 |
| 36 |
do i = 1, 3 |
| 37 |
if (array(i,j)%var /= i*97 + 100*41*j) stop 3 |
| 38 |
if (l_array(i,j)%var /= i*97 + 100*41*j) stop 3 |
| 39 |
if (is_present) then |
| 40 |
if (opt_array(i,j)%var /= i*97 + 100*41*j) stop 4 |
| 41 |
end if |
| 42 |
end do |
| 43 |
end do |
| 44 |
|
| 45 |
if (dummy_alloced) then |
| 46 |
if (a_scalar%var /= 42) stop 1 |
| 47 |
if (la_scalar%var /= 42) stop 1 |
| 48 |
if (is_present) then |
| 49 |
if (a_opt_scalar%var /= 42) stop 1 |
| 50 |
end if |
| 51 |
if (any (shape(a_array) /= [3,2])) stop 1 |
| 52 |
if (any (shape(la_array) /= [3,2])) stop 1 |
| 53 |
if (is_present) then |
| 54 |
if (any (shape(a_opt_array) /= [3,2])) stop 1 |
| 55 |
end if |
| 56 |
do j = 1, 2 |
| 57 |
do i = 1, 3 |
| 58 |
if (a_array(i,j)%var /= i*97 + 100*41*j) stop 1 |
| 59 |
if (la_array(i,j)%var /= i*97 + 100*41*j) stop 1 |
| 60 |
if (is_present) then |
| 61 |
if (a_opt_array(i,j)%var /= i*97 + 100*41*j) stop 1 |
| 62 |
end if |
| 63 |
end do |
| 64 |
end do |
| 65 |
else |
| 66 |
if (allocated (a_scalar)) stop 1 |
| 67 |
if (allocated (la_scalar)) stop 1 |
| 68 |
if (allocated (a_array)) stop 1 |
| 69 |
if (allocated (la_array)) stop 1 |
| 70 |
if (is_present) then |
| 71 |
if (allocated (a_opt_scalar)) stop 1 |
| 72 |
if (allocated (a_opt_array)) stop 1 |
| 73 |
end if |
| 74 |
end if |
| 75 |
|
| 76 |
if (inner_alloc) then |
| 77 |
if (scalar%slr /= 467) stop 5 |
| 78 |
if (l_scalar%slr /= 467) stop 5 |
| 79 |
if (a_scalar%slr /= 467) stop 6 |
| 80 |
if (la_scalar%slr /= 467) stop 6 |
| 81 |
if (is_present) then |
| 82 |
if (opt_scalar%slr /= 467) stop 7 |
| 83 |
if (a_opt_scalar%slr /= 467) stop 8 |
| 84 |
end if |
| 85 |
do j = 1, 2 |
| 86 |
do i = 1, 3 |
| 87 |
if (array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 9 |
| 88 |
if (l_array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 9 |
| 89 |
if (a_array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 10 |
| 90 |
if (la_array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 10 |
| 91 |
if (is_present) then |
| 92 |
if (opt_array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 11 |
| 93 |
if (a_opt_array(i,j)%slr /= (i*97 + 100*41*j) + 467) stop 12 |
| 94 |
end if |
| 95 |
end do |
| 96 |
end do |
| 97 |
|
| 98 |
do l = 1, 5 |
| 99 |
do k = 1, 4 |
| 100 |
if (any (shape(scalar%arr) /= [4,5])) stop 1 |
| 101 |
if (any (shape(l_scalar%arr) /= [4,5])) stop 1 |
| 102 |
if (any (shape(a_scalar%arr) /= [4,5])) stop 1 |
| 103 |
if (any (shape(la_scalar%arr) /= [4,5])) stop 1 |
| 104 |
if (scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 13 |
| 105 |
if (l_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 13 |
| 106 |
if (a_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 14 |
| 107 |
if (la_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 14 |
| 108 |
if (is_present) then |
| 109 |
if (any (shape(opt_scalar%arr) /= [4,5])) stop 1 |
| 110 |
if (any (shape(a_opt_scalar%arr) /= [4,5])) stop 1 |
| 111 |
if (opt_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 15 |
| 112 |
if (a_opt_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467) stop 16 |
| 113 |
end if |
| 114 |
end do |
| 115 |
end do |
| 116 |
do j = 1, 2 |
| 117 |
do i = 1, 3 |
| 118 |
if (any (shape(array(i,j)%arr) /= [i,j])) stop 1 |
| 119 |
if (any (shape(l_array(i,j)%arr) /= [i,j])) stop 1 |
| 120 |
if (any (shape(a_array(i,j)%arr) /= [i,j])) stop 1 |
| 121 |
if (any (shape(la_array(i,j)%arr) /= [i,j])) stop 1 |
| 122 |
if (is_present) then |
| 123 |
if (any (shape(opt_array(i,j)%arr) /= [i,j])) stop 1 |
| 124 |
if (any (shape(a_opt_array(i,j)%arr) /= [i,j])) stop 1 |
| 125 |
endif |
| 126 |
do l = 1, j |
| 127 |
do k = 1, i |
| 128 |
if (array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 17 |
| 129 |
if (l_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 17 |
| 130 |
if (a_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 18 |
| 131 |
if (la_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 18 |
| 132 |
if (is_present) then |
| 133 |
if (opt_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 19 |
| 134 |
if (a_opt_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l) stop 20 |
| 135 |
end if |
| 136 |
end do |
| 137 |
end do |
| 138 |
end do |
| 139 |
end do |
| 140 |
else if (dummy_alloced) then |
| 141 |
if (allocated (scalar%slr)) stop 1 |
| 142 |
if (allocated (l_scalar%slr)) stop 1 |
| 143 |
if (allocated (a_scalar%slr)) stop 1 |
| 144 |
if (allocated (la_scalar%slr)) stop 1 |
| 145 |
if (is_present) then |
| 146 |
if (allocated (opt_scalar%slr)) stop 1 |
| 147 |
if (allocated (a_opt_scalar%slr)) stop 1 |
| 148 |
endif |
| 149 |
if (allocated (scalar%arr)) stop 1 |
| 150 |
if (allocated (l_scalar%arr)) stop 1 |
| 151 |
if (allocated (a_scalar%arr)) stop 1 |
| 152 |
if (allocated (la_scalar%arr)) stop 1 |
| 153 |
if (is_present) then |
| 154 |
if (allocated (opt_scalar%arr)) stop 1 |
| 155 |
if (allocated (a_opt_scalar%arr)) stop 1 |
| 156 |
endif |
| 157 |
end if |
| 158 |
|
| 159 |
! SET VALUE |
| 160 |
scalar%var = 42 + 13 |
| 161 |
l_scalar%var = 42 + 13 |
| 162 |
if (is_present) then |
| 163 |
opt_scalar%var = 42 + 13 |
| 164 |
endif |
| 165 |
do j = 1, 2 |
| 166 |
do i = 1, 3 |
| 167 |
array(i,j)%var = i*97 + 100*41*j + 13 |
| 168 |
l_array(i,j)%var = i*97 + 100*41*j + 13 |
| 169 |
if (is_present) then |
| 170 |
opt_array(i,j)%var = i*97 + 100*41*j + 13 |
| 171 |
end if |
| 172 |
end do |
| 173 |
end do |
| 174 |
|
| 175 |
if (dummy_alloced) then |
| 176 |
a_scalar%var = 42 + 13 |
| 177 |
la_scalar%var = 42 + 13 |
| 178 |
if (is_present) then |
| 179 |
a_opt_scalar%var = 42 + 13 |
| 180 |
endif |
| 181 |
do j = 1, 2 |
| 182 |
do i = 1, 3 |
| 183 |
a_array(i,j)%var = i*97 + 100*41*j + 13 |
| 184 |
la_array(i,j)%var = i*97 + 100*41*j + 13 |
| 185 |
if (is_present) then |
| 186 |
a_opt_array(i,j)%var = i*97 + 100*41*j + 13 |
| 187 |
endif |
| 188 |
end do |
| 189 |
end do |
| 190 |
end if |
| 191 |
|
| 192 |
if (inner_alloc) then |
| 193 |
scalar%slr = 467 + 13 |
| 194 |
l_scalar%slr = 467 + 13 |
| 195 |
a_scalar%slr = 467 + 13 |
| 196 |
la_scalar%slr = 467 + 13 |
| 197 |
if (is_present) then |
| 198 |
opt_scalar%slr = 467 + 13 |
| 199 |
a_opt_scalar%slr = 467 + 13 |
| 200 |
end if |
| 201 |
do j = 1, 2 |
| 202 |
do i = 1, 3 |
| 203 |
array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 204 |
l_array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 205 |
a_array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 206 |
la_array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 207 |
if (is_present) then |
| 208 |
opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 209 |
a_opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 + 13 |
| 210 |
end if |
| 211 |
end do |
| 212 |
end do |
| 213 |
|
| 214 |
do l = 1, 5 |
| 215 |
do k = 1, 4 |
| 216 |
scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 217 |
l_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 218 |
a_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 219 |
la_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 220 |
if (is_present) then |
| 221 |
opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 222 |
a_opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 + 13 |
| 223 |
end if |
| 224 |
end do |
| 225 |
end do |
| 226 |
do j = 1, 2 |
| 227 |
do i = 1, 3 |
| 228 |
do l = 1, j |
| 229 |
do k = 1, i |
| 230 |
array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 231 |
l_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 232 |
a_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 233 |
la_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 234 |
if (is_present) then |
| 235 |
opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 236 |
a_opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l + 13 |
| 237 |
end if |
| 238 |
end do |
| 239 |
end do |
| 240 |
end do |
| 241 |
end do |
| 242 |
end if |
| 243 |
|
| 244 |
end subroutine |
| 245 |
subroutine check_reset (is_present, dummy_alloced, inner_alloc, & |
| 246 |
scalar, array, a_scalar, a_array, & |
| 247 |
l_scalar, l_array, la_scalar, la_array, & |
| 248 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 249 |
type(t), intent(inout) :: & |
| 250 |
scalar, array(:,:), opt_scalar, opt_array(:,:), a_scalar, a_array(:,:), & |
| 251 |
a_opt_scalar, a_opt_array(:,:), & |
| 252 |
l_scalar, l_array(:,:), la_scalar, la_array(:,:) |
| 253 |
optional :: opt_scalar, opt_array, a_opt_scalar, a_opt_array |
| 254 |
allocatable :: a_scalar, a_array, a_opt_scalar, a_opt_array, la_scalar, la_array |
| 255 |
logical, value :: is_present, dummy_alloced, inner_alloc |
| 256 |
integer :: i, j, k, l |
| 257 |
|
| 258 |
! CHECK VALUE |
| 259 |
if (scalar%var /= 42 + 13) stop 1 |
| 260 |
if (l_scalar%var /= 42 + 13) stop 1 |
| 261 |
if (is_present) then |
| 262 |
if (opt_scalar%var /= 42 + 13) stop 2 |
| 263 |
end if |
| 264 |
if (any (shape(array) /= [3,2])) stop 1 |
| 265 |
if (any (shape(l_array) /= [3,2])) stop 1 |
| 266 |
if (is_present) then |
| 267 |
if (any (shape(opt_array) /= [3,2])) stop 1 |
| 268 |
end if |
| 269 |
do j = 1, 2 |
| 270 |
do i = 1, 3 |
| 271 |
if (array(i,j)%var /= i*97 + 100*41*j + 13) stop 3 |
| 272 |
if (l_array(i,j)%var /= i*97 + 100*41*j + 13) stop 3 |
| 273 |
if (is_present) then |
| 274 |
if (opt_array(i,j)%var /= i*97 + 100*41*j + 13) stop 4 |
| 275 |
end if |
| 276 |
end do |
| 277 |
end do |
| 278 |
|
| 279 |
if (dummy_alloced) then |
| 280 |
if (a_scalar%var /= 42 + 13) stop 1 |
| 281 |
if (la_scalar%var /= 42 + 13) stop 1 |
| 282 |
if (is_present) then |
| 283 |
if (a_opt_scalar%var /= 42 + 13) stop 1 |
| 284 |
end if |
| 285 |
if (any (shape(a_array) /= [3,2])) stop 1 |
| 286 |
if (any (shape(la_array) /= [3,2])) stop 1 |
| 287 |
if (is_present) then |
| 288 |
if (any (shape(a_opt_array) /= [3,2])) stop 1 |
| 289 |
end if |
| 290 |
do j = 1, 2 |
| 291 |
do i = 1, 3 |
| 292 |
if (a_array(i,j)%var /= i*97 + 100*41*j + 13) stop 1 |
| 293 |
if (la_array(i,j)%var /= i*97 + 100*41*j + 13) stop 1 |
| 294 |
if (is_present) then |
| 295 |
if (a_opt_array(i,j)%var /= i*97 + 100*41*j + 13) stop 1 |
| 296 |
end if |
| 297 |
end do |
| 298 |
end do |
| 299 |
else |
| 300 |
if (allocated (a_scalar)) stop 1 |
| 301 |
if (allocated (la_scalar)) stop 1 |
| 302 |
if (allocated (a_array)) stop 1 |
| 303 |
if (allocated (la_array)) stop 1 |
| 304 |
if (is_present) then |
| 305 |
if (allocated (a_opt_scalar)) stop 1 |
| 306 |
if (allocated (a_opt_array)) stop 1 |
| 307 |
end if |
| 308 |
end if |
| 309 |
|
| 310 |
if (inner_alloc) then |
| 311 |
if (scalar%slr /= 467 + 13) stop 5 |
| 312 |
if (l_scalar%slr /= 467 + 13) stop 5 |
| 313 |
if (a_scalar%slr /= 467 + 13) stop 6 |
| 314 |
if (la_scalar%slr /= 467 + 13) stop 6 |
| 315 |
if (is_present) then |
| 316 |
if (opt_scalar%slr /= 467 + 13) stop 7 |
| 317 |
if (a_opt_scalar%slr /= 467 + 13) stop 8 |
| 318 |
end if |
| 319 |
do j = 1, 2 |
| 320 |
do i = 1, 3 |
| 321 |
if (array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 9 |
| 322 |
if (l_array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 9 |
| 323 |
if (a_array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 10 |
| 324 |
if (la_array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 10 |
| 325 |
if (is_present) then |
| 326 |
if (opt_array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 11 |
| 327 |
if (a_opt_array(i,j)%slr /= (i*97 + 100*41*j) + 467 + 13) stop 12 |
| 328 |
end if |
| 329 |
end do |
| 330 |
end do |
| 331 |
|
| 332 |
do l = 1, 5 |
| 333 |
do k = 1, 4 |
| 334 |
if (any (shape(scalar%arr) /= [4,5])) stop 1 |
| 335 |
if (any (shape(l_scalar%arr) /= [4,5])) stop 1 |
| 336 |
if (any (shape(a_scalar%arr) /= [4,5])) stop 1 |
| 337 |
if (any (shape(la_scalar%arr) /= [4,5])) stop 1 |
| 338 |
if (scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 13 |
| 339 |
if (l_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 13 |
| 340 |
if (a_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 14 |
| 341 |
if (la_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 14 |
| 342 |
if (is_present) then |
| 343 |
if (any (shape(opt_scalar%arr) /= [4,5])) stop 1 |
| 344 |
if (any (shape(a_opt_scalar%arr) /= [4,5])) stop 1 |
| 345 |
if (opt_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 15 |
| 346 |
if (a_opt_scalar%arr(k,l) /= (i*27 + 1000*11*j) + 467 + 13) stop 16 |
| 347 |
end if |
| 348 |
end do |
| 349 |
end do |
| 350 |
do j = 1, 2 |
| 351 |
do i = 1, 3 |
| 352 |
if (any (shape(array(i,j)%arr) /= [i,j])) stop 1 |
| 353 |
if (any (shape(l_array(i,j)%arr) /= [i,j])) stop 1 |
| 354 |
if (any (shape(a_array(i,j)%arr) /= [i,j])) stop 1 |
| 355 |
if (any (shape(la_array(i,j)%arr) /= [i,j])) stop 1 |
| 356 |
if (is_present) then |
| 357 |
if (any (shape(opt_array(i,j)%arr) /= [i,j])) stop 1 |
| 358 |
if (any (shape(a_opt_array(i,j)%arr) /= [i,j])) stop 1 |
| 359 |
endif |
| 360 |
do l = 1, j |
| 361 |
do k = 1, i |
| 362 |
if (array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 17 |
| 363 |
if (l_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 17 |
| 364 |
if (a_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 18 |
| 365 |
if (la_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 18 |
| 366 |
if (is_present) then |
| 367 |
if (opt_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 19 |
| 368 |
if (a_opt_array(i,j)%arr(k,l) /= i*27 + 1000*11*j + 467 + 3*k +53*l + 13) stop 20 |
| 369 |
end if |
| 370 |
end do |
| 371 |
end do |
| 372 |
end do |
| 373 |
end do |
| 374 |
else if (dummy_alloced) then |
| 375 |
if (allocated (scalar%slr)) stop 1 |
| 376 |
if (allocated (l_scalar%slr)) stop 1 |
| 377 |
if (allocated (a_scalar%slr)) stop 1 |
| 378 |
if (allocated (la_scalar%slr)) stop 1 |
| 379 |
if (is_present) then |
| 380 |
if (allocated (opt_scalar%slr)) stop 1 |
| 381 |
if (allocated (a_opt_scalar%slr)) stop 1 |
| 382 |
endif |
| 383 |
if (allocated (scalar%arr)) stop 1 |
| 384 |
if (allocated (l_scalar%arr)) stop 1 |
| 385 |
if (allocated (a_scalar%arr)) stop 1 |
| 386 |
if (allocated (la_scalar%arr)) stop 1 |
| 387 |
if (is_present) then |
| 388 |
if (allocated (opt_scalar%arr)) stop 1 |
| 389 |
if (allocated (a_opt_scalar%arr)) stop 1 |
| 390 |
endif |
| 391 |
end if |
| 392 |
|
| 393 |
! (RE)SET VALUE |
| 394 |
scalar%var = 42 |
| 395 |
l_scalar%var = 42 |
| 396 |
if (is_present) then |
| 397 |
opt_scalar%var = 42 |
| 398 |
endif |
| 399 |
do j = 1, 2 |
| 400 |
do i = 1, 3 |
| 401 |
array(i,j)%var = i*97 + 100*41*j |
| 402 |
l_array(i,j)%var = i*97 + 100*41*j |
| 403 |
if (is_present) then |
| 404 |
opt_array(i,j)%var = i*97 + 100*41*j |
| 405 |
end if |
| 406 |
end do |
| 407 |
end do |
| 408 |
|
| 409 |
if (dummy_alloced) then |
| 410 |
a_scalar%var = 42 |
| 411 |
la_scalar%var = 42 |
| 412 |
if (is_present) then |
| 413 |
a_opt_scalar%var = 42 |
| 414 |
endif |
| 415 |
do j = 1, 2 |
| 416 |
do i = 1, 3 |
| 417 |
a_array(i,j)%var = i*97 + 100*41*j |
| 418 |
la_array(i,j)%var = i*97 + 100*41*j |
| 419 |
if (is_present) then |
| 420 |
a_opt_array(i,j)%var = i*97 + 100*41*j |
| 421 |
endif |
| 422 |
end do |
| 423 |
end do |
| 424 |
end if |
| 425 |
|
| 426 |
if (inner_alloc) then |
| 427 |
scalar%slr = 467 |
| 428 |
l_scalar%slr = 467 |
| 429 |
a_scalar%slr = 467 |
| 430 |
la_scalar%slr = 467 |
| 431 |
if (is_present) then |
| 432 |
opt_scalar%slr = 467 |
| 433 |
a_opt_scalar%slr = 467 |
| 434 |
end if |
| 435 |
do j = 1, 2 |
| 436 |
do i = 1, 3 |
| 437 |
array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 438 |
l_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 439 |
a_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 440 |
la_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 441 |
if (is_present) then |
| 442 |
opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 443 |
a_opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 444 |
end if |
| 445 |
end do |
| 446 |
end do |
| 447 |
|
| 448 |
do l = 1, 5 |
| 449 |
do k = 1, 4 |
| 450 |
scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 451 |
l_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 452 |
a_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 453 |
la_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 454 |
if (is_present) then |
| 455 |
opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 456 |
a_opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 457 |
end if |
| 458 |
end do |
| 459 |
end do |
| 460 |
do j = 1, 2 |
| 461 |
do i = 1, 3 |
| 462 |
do l = 1, j |
| 463 |
do k = 1, i |
| 464 |
array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 465 |
l_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 466 |
a_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 467 |
la_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 468 |
if (is_present) then |
| 469 |
opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 470 |
a_opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 471 |
end if |
| 472 |
end do |
| 473 |
end do |
| 474 |
end do |
| 475 |
end do |
| 476 |
end if |
| 477 |
end subroutine |
| 478 |
|
| 479 |
subroutine test(scalar, array, a_scalar, a_array, opt_scalar, opt_array, & |
| 480 |
a_opt_scalar, a_opt_array) |
| 481 |
type(t) :: scalar, array(:,:), opt_scalar, opt_array(:,:), a_scalar, a_array(:,:) |
| 482 |
type(t) :: a_opt_scalar, a_opt_array(:,:) |
| 483 |
type(t) :: l_scalar, l_array(3,2), la_scalar, la_array(:,:) |
| 484 |
allocatable :: a_scalar, a_array, a_opt_scalar, a_opt_array, la_scalar, la_array |
| 485 |
optional :: opt_scalar, opt_array, a_opt_scalar, a_opt_array |
| 486 |
|
| 487 |
integer :: i, j, k, l |
| 488 |
logical :: is_present, dummy_alloced, local_alloced, inner_alloc |
| 489 |
is_present = present(opt_scalar) |
| 490 |
dummy_alloced = allocated(a_scalar) |
| 491 |
inner_alloc = allocated(scalar%slr) |
| 492 |
|
| 493 |
l_scalar%var = 42 |
| 494 |
do j = 1, 2 |
| 495 |
do i = 1, 3 |
| 496 |
l_array(i,j)%var = i*97 + 100*41*j |
| 497 |
end do |
| 498 |
end do |
| 499 |
|
| 500 |
if (dummy_alloced) then |
| 501 |
allocate(la_scalar, la_array(3,2)) |
| 502 |
a_scalar%var = 42 |
| 503 |
la_scalar%var = 42 |
| 504 |
do j = 1, 2 |
| 505 |
do i = 1, 3 |
| 506 |
l_array(i,j)%var = i*97 + 100*41*j |
| 507 |
la_array(i,j)%var = i*97 + 100*41*j |
| 508 |
end do |
| 509 |
end do |
| 510 |
end if |
| 511 |
|
| 512 |
if (inner_alloc) then |
| 513 |
l_scalar%slr = 467 |
| 514 |
la_scalar%slr = 467 |
| 515 |
do j = 1, 2 |
| 516 |
do i = 1, 3 |
| 517 |
l_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 518 |
la_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 519 |
end do |
| 520 |
end do |
| 521 |
|
| 522 |
allocate(l_scalar%arr(4,5), la_scalar%arr(4,5)) |
| 523 |
do l = 1, 5 |
| 524 |
do k = 1, 4 |
| 525 |
l_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 526 |
la_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 527 |
end do |
| 528 |
end do |
| 529 |
do j = 1, 2 |
| 530 |
do i = 1, 3 |
| 531 |
allocate(l_array(i,j)%arr(i,j), la_array(i,j)%arr(i,j)) |
| 532 |
do l = 1, j |
| 533 |
do k = 1, i |
| 534 |
l_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 535 |
la_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 536 |
end do |
| 537 |
end do |
| 538 |
end do |
| 539 |
end do |
| 540 |
end if |
| 541 |
|
| 542 |
! implicit mapping |
| 543 |
!$omp target |
| 544 |
if (is_present) then |
| 545 |
call check_it (is_present, dummy_alloced, inner_alloc, & |
| 546 |
scalar, array, a_scalar, a_array, & |
| 547 |
l_scalar, l_array, la_scalar, la_array, & |
| 548 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 549 |
else |
| 550 |
call check_it (is_present, dummy_alloced, inner_alloc, & |
| 551 |
scalar, array, a_scalar, a_array, & |
| 552 |
l_scalar, l_array, la_scalar, la_array) |
| 553 |
end if |
| 554 |
!$omp end target |
| 555 |
|
| 556 |
if (is_present) then |
| 557 |
call check_reset (is_present, dummy_alloced, inner_alloc, & |
| 558 |
scalar, array, a_scalar, a_array, & |
| 559 |
l_scalar, l_array, la_scalar, la_array, & |
| 560 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 561 |
else |
| 562 |
call check_reset (is_present, dummy_alloced, inner_alloc, & |
| 563 |
scalar, array, a_scalar, a_array, & |
| 564 |
l_scalar, l_array, la_scalar, la_array) |
| 565 |
endif |
| 566 |
|
| 567 |
! explicit mapping |
| 568 |
!$omp target map(scalar, array, opt_scalar, opt_array, a_scalar, a_array) & |
| 569 |
!$omp& map(a_opt_scalar, a_opt_array) & |
| 570 |
!$omp& map(l_scalar, l_array, la_scalar, la_array) |
| 571 |
if (is_present) then |
| 572 |
call check_it (is_present, dummy_alloced, inner_alloc, & |
| 573 |
scalar, array, a_scalar, a_array, & |
| 574 |
l_scalar, l_array, la_scalar, la_array, & |
| 575 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 576 |
else |
| 577 |
call check_it (is_present, dummy_alloced, inner_alloc, & |
| 578 |
scalar, array, a_scalar, a_array, & |
| 579 |
l_scalar, l_array, la_scalar, la_array) |
| 580 |
endif |
| 581 |
!$omp end target |
| 582 |
|
| 583 |
if (is_present) then |
| 584 |
call check_reset (is_present, dummy_alloced, inner_alloc, & |
| 585 |
scalar, array, a_scalar, a_array, & |
| 586 |
l_scalar, l_array, la_scalar, la_array, & |
| 587 |
opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 588 |
else |
| 589 |
call check_reset (is_present, dummy_alloced, inner_alloc, & |
| 590 |
scalar, array, a_scalar, a_array, & |
| 591 |
l_scalar, l_array, la_scalar, la_array) |
| 592 |
endif |
| 593 |
end subroutine |
| 594 |
end module |
| 595 |
|
| 596 |
program main |
| 597 |
use m |
| 598 |
implicit none (type, external) |
| 599 |
type(t) :: scalar, array(3,2), opt_scalar, opt_array(3,2), a_scalar, a_array(:,:) |
| 600 |
type(t) :: a_opt_scalar, a_opt_array(:,:) |
| 601 |
allocatable :: a_scalar, a_array, a_opt_scalar, a_opt_array |
| 602 |
integer :: i, j, k, l, n |
| 603 |
|
| 604 |
scalar%var = 42 |
| 605 |
opt_scalar%var = 42 |
| 606 |
do j = 1, 2 |
| 607 |
do i = 1, 3 |
| 608 |
array(i,j)%var = i*97 + 100*41*j |
| 609 |
opt_array(i,j)%var = i*97 + 100*41*j |
| 610 |
end do |
| 611 |
end do |
| 612 |
|
| 613 |
! unallocated |
| 614 |
call test (scalar, array, a_scalar, a_array) |
| 615 |
call test (scalar, array, a_scalar, a_array, opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 616 |
|
| 617 |
! allocated |
| 618 |
allocate(a_scalar, a_opt_scalar, a_array(3,2), a_opt_array(3,2)) |
| 619 |
a_scalar%var = 42 |
| 620 |
a_opt_scalar%var = 42 |
| 621 |
do j = 1, 2 |
| 622 |
do i = 1, 3 |
| 623 |
a_array(i,j)%var = i*97 + 100*41*j |
| 624 |
a_opt_array(i,j)%var = i*97 + 100*41*j |
| 625 |
end do |
| 626 |
end do |
| 627 |
|
| 628 |
call test (scalar, array, a_scalar, a_array) |
| 629 |
call test (scalar, array, a_scalar, a_array, opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 630 |
|
| 631 |
! comps allocated |
| 632 |
scalar%slr = 467 |
| 633 |
a_scalar%slr = 467 |
| 634 |
opt_scalar%slr = 467 |
| 635 |
a_opt_scalar%slr = 467 |
| 636 |
do j = 1, 2 |
| 637 |
do i = 1, 3 |
| 638 |
array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 639 |
a_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 640 |
opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 641 |
a_opt_array(i,j)%slr = (i*97 + 100*41*j) + 467 |
| 642 |
end do |
| 643 |
end do |
| 644 |
|
| 645 |
allocate(scalar%arr(4,5), a_scalar%arr(4,5), opt_scalar%arr(4,5), a_opt_scalar%arr(4,5)) |
| 646 |
do l = 1, 5 |
| 647 |
do k = 1, 4 |
| 648 |
scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 649 |
a_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 650 |
opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 651 |
a_opt_scalar%arr(k,l) = (i*27 + 1000*11*j) + 467 |
| 652 |
end do |
| 653 |
end do |
| 654 |
do j = 1, 2 |
| 655 |
do i = 1, 3 |
| 656 |
allocate(array(i,j)%arr(i,j), a_array(i,j)%arr(i,j), opt_array(i,j)%arr(i,j), a_opt_array(i,j)%arr(i,j)) |
| 657 |
do l = 1, j |
| 658 |
do k = 1, i |
| 659 |
array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 660 |
a_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 661 |
opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 662 |
a_opt_array(i,j)%arr(k,l) = i*27 + 1000*11*j + 467 + 3*k +53*l |
| 663 |
end do |
| 664 |
end do |
| 665 |
end do |
| 666 |
end do |
| 667 |
|
| 668 |
call test (scalar, array, a_scalar, a_array) |
| 669 |
call test (scalar, array, a_scalar, a_array, opt_scalar, opt_array, a_opt_scalar, a_opt_array) |
| 670 |
|
| 671 |
deallocate(a_scalar, a_opt_scalar, a_array, a_opt_array) |
| 672 |
end |