udr9.f90 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ! { dg-do run }
  2. module udr9m1
  3. integer, parameter :: a = 6
  4. integer :: b
  5. !$omp declare reduction (foo : integer : combiner1 (omp_out, omp_in)) &
  6. !$omp & initializer (initializer1 (omp_priv, omp_orig))
  7. !$omp declare reduction (.add. : integer : &
  8. !$omp & combiner1 (omp_out, omp_in)) &
  9. !$omp & initializer (initializer1 (omp_priv, omp_orig))
  10. interface operator (.add.)
  11. module procedure f1
  12. end interface
  13. contains
  14. integer function f1 (x, y)
  15. integer, intent (in) :: x, y
  16. f1 = x + y
  17. end function f1
  18. elemental subroutine combiner1 (x, y)
  19. integer, intent (inout) :: x
  20. integer, intent (in) :: y
  21. x = x + iand (y, -4)
  22. end subroutine
  23. subroutine initializer1 (x, y)
  24. integer :: x, y
  25. if (y .ne. 3) call abort
  26. x = y
  27. end subroutine
  28. end module udr9m1
  29. module udr9m2
  30. use udr9m1
  31. type dt
  32. integer :: x
  33. end type
  34. !$omp declare reduction (+ : dt : combiner2 (omp_in, omp_out)) &
  35. !$omp & initializer (initializer2 (omp_priv))
  36. interface operator (+)
  37. module procedure f2
  38. end interface
  39. contains
  40. type(dt) function f2 (x, y)
  41. type(dt), intent (in) :: x, y
  42. f2%x = x%x + y%x
  43. end function f2
  44. subroutine combiner2 (x, y)
  45. type(dt) :: x, y
  46. y = y + x
  47. end subroutine combiner2
  48. subroutine initializer2 (x)
  49. type(dt), intent(out) :: x
  50. x%x = 0
  51. end subroutine initializer2
  52. end module udr9m2
  53. use udr9m2
  54. integer :: i, j
  55. type(dt) :: d
  56. j = 3
  57. d%x = 0
  58. !$omp parallel do reduction (.add.: j) reduction (+ : d)
  59. do i = 1, 100
  60. j = j.add.iand (i, -4)
  61. d = d + dt(i)
  62. end do
  63. if (d%x /= 5050 .or. j /= 4903) call abort
  64. end