routine-2.f90 545 B

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