reduction2.f90 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ! { dg-do run }
  2. !$ use omp_lib
  3. logical :: l, la (4), m, ma (4), v
  4. integer :: n, cnt
  5. l = .true.
  6. la = (/.true., .false., .true., .true./)
  7. m = .false.
  8. ma = (/.false., .false., .false., .true./)
  9. v = .false.
  10. cnt = -1
  11. !$omp parallel num_threads (3) private (n) reduction (.or.:v) &
  12. !$omp & reduction (.and.:l, la) reduction (.or.:m, ma)
  13. !$ if (.not. l .or. any (.not. la)) v = .true.
  14. !$ if (m .or. any (ma)) v = .true.
  15. n = omp_get_thread_num ()
  16. if (n .eq. 0) then
  17. cnt = omp_get_num_threads ()
  18. l = .false.
  19. la(3) = .false.
  20. ma(2) = .true.
  21. else if (n .eq. 1) then
  22. l = .false.
  23. la(4) = .false.
  24. ma(1) = .true.
  25. else
  26. la(3) = .false.
  27. m = .true.
  28. ma(1) = .true.
  29. end if
  30. !$omp end parallel
  31. if (v) call abort
  32. if (cnt .eq. 3) then
  33. if (l .or. any (la .neqv. (/.true., .false., .false., .false./))) call abort
  34. if (.not. m .or. any (ma .neqv. (/.true., .true., .false., .true./))) call abort
  35. end if
  36. l = .true.
  37. la = (/.true., .false., .true., .true./)
  38. m = .false.
  39. ma = (/.false., .false., .false., .true./)
  40. v = .false.
  41. cnt = -1
  42. !$omp parallel num_threads (3) private (n) reduction (.or.:v) &
  43. !$omp & reduction (.eqv.:l, la) reduction (.neqv.:m, ma)
  44. !$ if (.not. l .or. any (.not. la)) v = .true.
  45. !$ if (m .or. any (ma)) v = .true.
  46. n = omp_get_thread_num ()
  47. if (n .eq. 0) then
  48. cnt = omp_get_num_threads ()
  49. l = .false.
  50. la(3) = .false.
  51. ma(2) = .true.
  52. else if (n .eq. 1) then
  53. l = .false.
  54. la(4) = .false.
  55. ma(1) = .true.
  56. else
  57. la(3) = .false.
  58. m = .true.
  59. ma(1) = .true.
  60. end if
  61. !$omp end parallel
  62. if (v) call abort
  63. if (cnt .eq. 3) then
  64. if (.not. l .or. any (la .neqv. (/.true., .false., .true., .false./))) call abort
  65. if (.not. m .or. any (ma .neqv. (/.false., .true., .false., .true./))) call abort
  66. end if
  67. end