udr13.f90 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ! { dg-do run }
  2. interface
  3. subroutine sub1 (x, y)
  4. integer, intent(in) :: y(:)
  5. integer, intent(out) :: x(:)
  6. end subroutine
  7. function fn2 (x, m1, m2, n1, n2)
  8. integer, intent(in) :: x(:,:), m1, m2, n1, n2
  9. integer :: fn2(m1:m2,n1:n2)
  10. end function
  11. subroutine sub3 (x, y)
  12. integer, allocatable, intent(in) :: y(:,:)
  13. integer, allocatable, intent(inout) :: x(:,:)
  14. end subroutine
  15. end interface
  16. !$omp declare reduction (foo : integer : sub3 (omp_out, omp_in)) &
  17. !$omp initializer (omp_priv = fn3 (omp_orig))
  18. !$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in, &
  19. !$omp & lbound (omp_out, 1), ubound (omp_out, 1))) &
  20. !$omp & initializer (sub1 (omp_priv, omp_orig))
  21. !$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) &
  22. !$omp initializer (omp_priv = fn2 (omp_orig, lbound (omp_priv, 1), &
  23. !$omp ubound (omp_priv, 1), lbound (omp_priv, 2), ubound (omp_priv, 2)))
  24. interface
  25. function fn1 (x, y, m1, m2)
  26. integer, intent(in) :: x(:), y(:), m1, m2
  27. integer :: fn1(m1:m2)
  28. end function
  29. subroutine sub2 (x, y)
  30. integer, intent(in) :: y(:,:)
  31. integer, intent(inout) :: x(:,:)
  32. end subroutine
  33. function fn3 (x)
  34. integer, allocatable, intent(in) :: x(:,:)
  35. integer, allocatable :: fn3(:,:)
  36. end function
  37. end interface
  38. integer :: a(10), b(3:5,7:9), r
  39. integer, allocatable :: c(:,:)
  40. a(:) = 0
  41. r = 0
  42. !$omp parallel reduction (bar : a) reduction (+: r)
  43. if (lbound (a, 1) /= 1 .or. ubound (a, 1) /= 10) call abort
  44. a = a + 2
  45. r = r + 1
  46. !$omp end parallel
  47. if (any (a /= 4 * r) ) call abort
  48. b(:,:) = 0
  49. allocate (c (4:6,8:10))
  50. c(:,:) = 0
  51. r = 0
  52. !$omp parallel reduction (baz : b, c) reduction (+: r)
  53. if (lbound (b, 1) /= 3 .or. ubound (b, 1) /= 5) call abort
  54. if (lbound (b, 2) /= 7 .or. ubound (b, 2) /= 9) call abort
  55. if (.not. allocated (c)) call abort
  56. if (lbound (c, 1) /= 4 .or. ubound (c, 1) /= 6) call abort
  57. if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 10) call abort
  58. b = b + 3
  59. c = c + 4
  60. r = r + 1
  61. !$omp end parallel
  62. if (any (b /= 3 * r) .or. any (c /= 4 * r)) call abort
  63. deallocate (c)
  64. allocate (c (0:1,7:11))
  65. c(:,:) = 0
  66. r = 0
  67. !$omp parallel reduction (foo : c) reduction (+: r)
  68. if (.not. allocated (c)) call abort
  69. if (lbound (c, 1) /= 0 .or. ubound (c, 1) /= 1) call abort
  70. if (lbound (c, 2) /= 7 .or. ubound (c, 2) /= 11) call abort
  71. c = c + 5
  72. r = r + 1
  73. !$omp end parallel
  74. if (any (c /= 10 * r)) call abort
  75. end
  76. function fn1 (x, y, m1, m2)
  77. integer, intent(in) :: x(:), y(:), m1, m2
  78. integer :: fn1(m1:m2)
  79. fn1 = x + 2 * y
  80. end function
  81. subroutine sub1 (x, y)
  82. integer, intent(in) :: y(:)
  83. integer, intent(out) :: x(:)
  84. x = 0
  85. end subroutine
  86. function fn2 (x, m1, m2, n1, n2)
  87. integer, intent(in) :: x(:,:), m1, m2, n1, n2
  88. integer :: fn2(m1:m2,n1:n2)
  89. fn2 = x
  90. end function
  91. subroutine sub2 (x, y)
  92. integer, intent(inout) :: x(:,:)
  93. integer, intent(in) :: y(:,:)
  94. x = x + y
  95. end subroutine
  96. function fn3 (x)
  97. integer, allocatable, intent(in) :: x(:,:)
  98. integer, allocatable :: fn3(:,:)
  99. fn3 = x
  100. end function
  101. subroutine sub3 (x, y)
  102. integer, allocatable, intent(inout) :: x(:,:)
  103. integer, allocatable, intent(in) :: y(:,:)
  104. x = x + 2 * y
  105. end subroutine