| 1 |
! { dg-do run } |
| 2 |
|
| 3 |
program foo |
| 4 |
integer, save :: f1count(3), f2count(3), g1count(3), g2count(3) |
| 5 |
|
| 6 |
f1count(1) = 0 |
| 7 |
f1count(2) = 0 |
| 8 |
f1count(3) = 0 |
| 9 |
f2count(1) = 0 |
| 10 |
f2count(2) = 0 |
| 11 |
f2count(3) = 0 |
| 12 |
|
| 13 |
g1count(1) = 0 |
| 14 |
g1count(2) = 0 |
| 15 |
g1count(3) = 0 |
| 16 |
g2count(1) = 0 |
| 17 |
g2count(2) = 0 |
| 18 |
g2count(3) = 0 |
| 19 |
|
| 20 |
call s1 (3, 4, 5) |
| 21 |
|
| 22 |
! All intervening code at the same depth must be executed the same |
| 23 |
! number of times. |
| 24 |
if (f1count(1) /= f2count(1)) error stop 101 |
| 25 |
if (f1count(2) /= f2count(2)) error stop 102 |
| 26 |
if (f1count(3) /= f2count(3)) error stop 103 |
| 27 |
if (g1count(1) /= f1count(1)) error stop 104 |
| 28 |
if (g2count(1) /= f1count(1)) error stop 105 |
| 29 |
if (g1count(2) /= f1count(2)) error stop 106 |
| 30 |
if (g2count(2) /= f1count(2)) error stop 107 |
| 31 |
if (g1count(3) /= f1count(3)) error stop 108 |
| 32 |
if (g2count(3) /= f1count(3)) error stop 109 |
| 33 |
|
| 34 |
! Intervening code must be executed at least as many times as the loop |
| 35 |
! that encloses it. |
| 36 |
if (f1count(1) < 3) error stop 111 |
| 37 |
if (f1count(2) < 3 * 4) error stop 112 |
| 38 |
|
| 39 |
! Intervening code must not be executed more times than the number |
| 40 |
! of logical iterations. |
| 41 |
if (f1count(1) > 3 * 4 * 5) error stop 121 |
| 42 |
if (f1count(2) > 3 * 4 * 5) error stop 122 |
| 43 |
|
| 44 |
! Check that the innermost loop body is executed exactly the number |
| 45 |
! of logical iterations expected. |
| 46 |
if (f1count(3) /= 3 * 4 * 5) error stop 131 |
| 47 |
|
| 48 |
contains |
| 49 |
|
| 50 |
subroutine f1 (depth, iter) |
| 51 |
integer :: depth, iter |
| 52 |
f1count(depth) = f1count(depth) + 1 |
| 53 |
end subroutine |
| 54 |
|
| 55 |
subroutine f2 (depth, iter) |
| 56 |
integer :: depth, iter |
| 57 |
f2count(depth) = f2count(depth) + 1 |
| 58 |
end subroutine |
| 59 |
|
| 60 |
subroutine g1 (depth, iter) |
| 61 |
integer :: depth, iter |
| 62 |
g1count(depth) = g1count(depth) + 1 |
| 63 |
end subroutine |
| 64 |
|
| 65 |
subroutine g2 (depth, iter) |
| 66 |
integer :: depth, iter |
| 67 |
g2count(depth) = g2count(depth) + 1 |
| 68 |
end subroutine |
| 69 |
|
| 70 |
subroutine s1 (a1, a2, a3) |
| 71 |
integer :: a1, a2, a3 |
| 72 |
integer :: i, j, k |
| 73 |
|
| 74 |
!$omp do collapse(3) |
| 75 |
do i = 1, a1 |
| 76 |
call f1 (1, i) |
| 77 |
block |
| 78 |
call g1 (1, i) |
| 79 |
do j = 1, a2 |
| 80 |
call f1 (2, j) |
| 81 |
block |
| 82 |
call g1 (2, j) |
| 83 |
do k = 1, a3 |
| 84 |
call f1 (3, k) |
| 85 |
block |
| 86 |
call g1 (3, k) |
| 87 |
call g2 (3, k) |
| 88 |
end block |
| 89 |
call f2 (3, k) |
| 90 |
end do |
| 91 |
call g2 (2, j) |
| 92 |
end block |
| 93 |
call f2 (2, j) |
| 94 |
end do |
| 95 |
call g2 (1, i) |
| 96 |
end block |
| 97 |
call f2 (1, i) |
| 98 |
end do |
| 99 |
|
| 100 |
end subroutine |
| 101 |
|
| 102 |
end program |