routine-3.f90 506 B

12345678910111213141516171819202122232425262728
  1. ! { dg-do run }
  2. ! { dg-options "-fno-inline" }
  3. integer, parameter :: n = 10
  4. integer :: a(n), i
  5. integer, external :: fact
  6. !$acc routine (fact)
  7. !$acc parallel
  8. !$acc loop
  9. do i = 1, n
  10. a(i) = fact (i)
  11. end do
  12. !$acc end parallel
  13. do i = 1, n
  14. if (a(i) .ne. fact(i)) call abort
  15. end do
  16. end
  17. recursive function fact (x) result (res)
  18. !$acc routine
  19. integer, intent(in) :: x
  20. integer :: res
  21. if (x < 1) then
  22. res = 1
  23. else
  24. res = x * fact (x - 1)
  25. end if
  26. end function fact