allocatable10.f90 4.5 KB

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