reduction1.f90 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. ! { dg-do run }
  2. !$ use omp_lib
  3. integer :: i, ia (6), n, cnt
  4. real :: r, ra (4)
  5. double precision :: d, da (5)
  6. complex :: c, ca (3)
  7. logical :: v
  8. i = 1
  9. ia = 2
  10. r = 3
  11. ra = 4
  12. d = 5.5
  13. da = 6.5
  14. c = cmplx (7.5, 1.5)
  15. ca = cmplx (8.5, -3.0)
  16. v = .false.
  17. cnt = -1
  18. !$omp parallel num_threads (3) private (n) reduction (.or.:v) &
  19. !$omp & reduction (+:i, ia, r, ra, d, da, c, ca)
  20. !$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true.
  21. !$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true.
  22. !$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true.
  23. !$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true.
  24. n = omp_get_thread_num ()
  25. if (n .eq. 0) then
  26. cnt = omp_get_num_threads ()
  27. i = 4
  28. ia(3:5) = -2
  29. r = 5
  30. ra(1:2) = 6.5
  31. d = -2.5
  32. da(2:4) = 8.5
  33. c = cmplx (2.5, -3.5)
  34. ca(1) = cmplx (4.5, 5)
  35. else if (n .eq. 1) then
  36. i = 2
  37. ia(4:6) = 5
  38. r = 1
  39. ra(2:4) = -1.5
  40. d = 8.5
  41. da(1:3) = 2.5
  42. c = cmplx (0.5, -3)
  43. ca(2:3) = cmplx (-1, 6)
  44. else
  45. i = 1
  46. ia = 1
  47. r = -1
  48. ra = -1
  49. d = 1
  50. da = -1
  51. c = 1
  52. ca = cmplx (-1, 0)
  53. end if
  54. !$omp end parallel
  55. if (v) call abort
  56. if (cnt .eq. 3) then
  57. if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort
  58. if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort
  59. if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort
  60. if (c .ne. cmplx (11.5, -5)) call abort
  61. if (ca(1) .ne. cmplx (12, 2)) call abort
  62. if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort
  63. end if
  64. i = 1
  65. ia = 2
  66. r = 3
  67. ra = 4
  68. d = 5.5
  69. da = 6.5
  70. c = cmplx (7.5, 1.5)
  71. ca = cmplx (8.5, -3.0)
  72. v = .false.
  73. cnt = -1
  74. !$omp parallel num_threads (3) private (n) reduction (.or.:v) &
  75. !$omp & reduction (-:i, ia, r, ra, d, da, c, ca)
  76. !$ if (i .ne. 0 .or. any (ia .ne. 0)) v = .true.
  77. !$ if (r .ne. 0 .or. any (ra .ne. 0)) v = .true.
  78. !$ if (d .ne. 0 .or. any (da .ne. 0)) v = .true.
  79. !$ if (c .ne. cmplx (0) .or. any (ca .ne. cmplx (0))) v = .true.
  80. n = omp_get_thread_num ()
  81. if (n .eq. 0) then
  82. cnt = omp_get_num_threads ()
  83. i = 4
  84. ia(3:5) = -2
  85. r = 5
  86. ra(1:2) = 6.5
  87. d = -2.5
  88. da(2:4) = 8.5
  89. c = cmplx (2.5, -3.5)
  90. ca(1) = cmplx (4.5, 5)
  91. else if (n .eq. 1) then
  92. i = 2
  93. ia(4:6) = 5
  94. r = 1
  95. ra(2:4) = -1.5
  96. d = 8.5
  97. da(1:3) = 2.5
  98. c = cmplx (0.5, -3)
  99. ca(2:3) = cmplx (-1, 6)
  100. else
  101. i = 1
  102. ia = 1
  103. r = -1
  104. ra = -1
  105. d = 1
  106. da = -1
  107. c = 1
  108. ca = cmplx (-1, 0)
  109. end if
  110. !$omp end parallel
  111. if (v) call abort
  112. if (cnt .eq. 3) then
  113. if (i .ne. 8 .or. any (ia .ne. (/3, 3, 1, 6, 6, 8/))) call abort
  114. if (r .ne. 8 .or. any (ra .ne. (/9.5, 8.0, 1.5, 1.5/))) call abort
  115. if (d .ne. 12.5 .or. any (da .ne. (/8.0, 16.5, 16.5, 14.0, 5.5/))) call abort
  116. if (c .ne. cmplx (11.5, -5)) call abort
  117. if (ca(1) .ne. cmplx (12, 2)) call abort
  118. if (ca(2) .ne. cmplx (6.5, 3) .or. ca(2) .ne. ca(3)) call abort
  119. end if
  120. i = 1
  121. ia = 2
  122. r = 4
  123. ra = 8
  124. d = 16
  125. da = 32
  126. c = 2
  127. ca = cmplx (0, 2)
  128. v = .false.
  129. cnt = -1
  130. !$omp parallel num_threads (3) private (n) reduction (.or.:v) &
  131. !$omp & reduction (*:i, ia, r, ra, d, da, c, ca)
  132. !$ if (i .ne. 1 .or. any (ia .ne. 1)) v = .true.
  133. !$ if (r .ne. 1 .or. any (ra .ne. 1)) v = .true.
  134. !$ if (d .ne. 1 .or. any (da .ne. 1)) v = .true.
  135. !$ if (c .ne. cmplx (1) .or. any (ca .ne. cmplx (1))) v = .true.
  136. n = omp_get_thread_num ()
  137. if (n .eq. 0) then
  138. cnt = omp_get_num_threads ()
  139. i = 3
  140. ia(3:5) = 2
  141. r = 0.5
  142. ra(1:2) = 2
  143. d = -1
  144. da(2:4) = -2
  145. c = 2.5
  146. ca(1) = cmplx (-5, 0)
  147. else if (n .eq. 1) then
  148. i = 2
  149. ia(4:6) = -2
  150. r = 8
  151. ra(2:4) = -0.5
  152. da(1:3) = -1
  153. c = -3
  154. ca(2:3) = cmplx (0, -1)
  155. else
  156. ia = 2
  157. r = 0.5
  158. ra = 0.25
  159. d = 2.5
  160. da = -1
  161. c = cmplx (0, -1)
  162. ca = cmplx (-1, 0)
  163. end if
  164. !$omp end parallel
  165. if (v) call abort
  166. if (cnt .eq. 3) then
  167. if (i .ne. 6 .or. any (ia .ne. (/4, 4, 8, -16, -16, -8/))) call abort
  168. if (r .ne. 8 .or. any (ra .ne. (/4., -2., -1., -1./))) call abort
  169. if (d .ne. -40 .or. any (da .ne. (/32., -64., -64., 64., -32./))) call abort
  170. if (c .ne. cmplx (0, 15)) call abort
  171. if (ca(1) .ne. cmplx (0, 10)) call abort
  172. if (ca(2) .ne. cmplx (-2, 0) .or. ca(2) .ne. ca(3)) call abort
  173. end if
  174. end