pr42162.f90 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ! PR fortran/42162
  2. ! { dg-do run }
  3. subroutine sub1(k, a)
  4. implicit none
  5. integer :: k, a(3)
  6. !$omp do
  7. do k=1,3
  8. a(k) = a(k) + 1
  9. enddo
  10. !$omp end do
  11. end subroutine sub1
  12. subroutine sub2(k, a)
  13. implicit none
  14. integer :: k, a(3)
  15. !$omp do private (k)
  16. do k=1,3
  17. a(k) = a(k) + 1
  18. enddo
  19. !$omp end do
  20. end subroutine sub2
  21. subroutine sub3(k, a)
  22. implicit none
  23. integer :: k, a(3)
  24. !$omp do lastprivate (k)
  25. do k=1,3
  26. a(k) = a(k) + 1
  27. enddo
  28. !$omp end do
  29. end subroutine sub3
  30. program pr42162
  31. implicit none
  32. integer :: k, a(3), b(3), c(3)
  33. a = 1
  34. b = 2
  35. c = 3
  36. k = 3
  37. !$omp parallel num_threads(3)
  38. call sub1 (k, a)
  39. !$omp end parallel
  40. k = 4
  41. !$omp parallel num_threads(3)
  42. call sub2 (k, b)
  43. !$omp end parallel
  44. k = 10
  45. !$omp parallel num_threads(3)
  46. call sub3 (k, c)
  47. !$omp end parallel
  48. if (k.ne.4.or.any(a.ne.2).or.any(b.ne.3).or.any(c.ne.4)) call abort
  49. end