task1.f90 561 B

12345678910111213141516171819202122232425262728
  1. ! { dg-do run }
  2. program tasktest
  3. use omp_lib
  4. integer :: i, j
  5. common /tasktest_j/ j
  6. j = 0
  7. !$omp parallel private (i)
  8. i = omp_get_thread_num ()
  9. if (i.lt.2) then
  10. !$omp task if (.false.) default(firstprivate)
  11. call subr (i + 1)
  12. !$omp end task
  13. end if
  14. !$omp end parallel
  15. if (j.gt.0) call abort
  16. contains
  17. subroutine subr (i)
  18. use omp_lib
  19. integer :: i, j
  20. common /tasktest_j/ j
  21. if (omp_get_thread_num ().ne.(i - 1)) then
  22. !$omp atomic
  23. j = j + 1
  24. end if
  25. end subroutine subr
  26. end program tasktest