routine-1.f90 610 B

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