task3.f90 567 B

12345678910111213141516171819202122232425262728
  1. ! { dg-do run }
  2. ! { dg-options "-fopenmp" }
  3. !
  4. ! PR fortran/47886
  5. !
  6. ! Test case contributed by Bill Long
  7. ! derived from OpenMP test OMP3f/F03_2_7_1d.F90
  8. program F03_2_7_1d
  9. use omp_lib
  10. implicit none
  11. integer, parameter :: NT = 4
  12. integer :: sum = 0
  13. call omp_set_num_threads(NT);
  14. !$omp parallel
  15. !$omp task if(omp_get_num_threads() > 0)
  16. !$omp atomic
  17. sum = sum + 1
  18. !$omp end task
  19. !$omp end parallel
  20. if (sum /= NT) then
  21. print *, "FAIL - sum == ", sum, " (expected ", NT, ")"
  22. call abort
  23. end if
  24. end program F03_2_7_1d