1! { dg-do run } 2! 3! PR fortran/94690 4! PR middle-end/66199 5 6module m 7 implicit none 8 integer u(0:1023), v(0:1023), w(0:1023) 9 !$omp declare target (u, v, w) 10 11contains 12 13subroutine f1 (a, b) 14 integer a, b, d 15 !$omp target teams distribute parallel do default(none) firstprivate (a, b) shared(u, v, w) 16 do d = a, b-1 17 u(d) = v(d) + w(d) 18 end do 19end 20 21subroutine f2 (a, b, c) 22 integer a, b, c, d, e 23 !$omp target teams distribute parallel do default(none) firstprivate (a, b, c) shared(u, v, w) lastprivate(d, e) 24 do d = a, b-1 25 u(d) = v(d) + w(d) 26 e = c + d * 5 27 end do 28end 29 30subroutine f3 (a1, b1, a2, b2) 31 integer :: a1, b1, a2, b2, d1, d2 32 !$omp target teams distribute parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) & 33 !$omp& lastprivate(d1, d2) collapse(2) 34 do d1 = a1, b1-1 35 do d2 = a2, b2-1 36 u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2) 37 end do 38 end do 39end 40 41subroutine f4 (a1, b1, a2, b2) 42 integer :: a1, b1, a2, b2, d1, d2 43 !$omp target teams distribute parallel do default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) & 44 !$omp& collapse(2) 45 do d1 = a1, b1-1 46 do d2 = a2, b2-1 47 u(d1 * 32 + d2) = v(d1 * 32 + d2) + w(d1 * 32 + d2) 48 end do 49 end do 50end 51end module m 52 53program main 54 use m 55 implicit none 56 call f1 (0, 1024) 57 call f2 (0, 1024, 17) 58 call f3 (0, 32, 0, 32) 59 call f4 (0, 32, 0, 32) 60end 61