2017-04-10 11:32:00 +00:00
|
|
|
! { dg-do run }
|
|
|
|
! { dg-options "-fno-inline" }
|
|
|
|
|
|
|
|
program main
|
|
|
|
implicit none
|
|
|
|
integer, parameter :: n = 10
|
|
|
|
integer :: a(n), i
|
|
|
|
integer, external :: fact
|
|
|
|
!$acc routine (fact)
|
|
|
|
!$acc parallel
|
|
|
|
!$acc loop
|
|
|
|
do i = 1, n
|
|
|
|
a(i) = fact (i)
|
|
|
|
end do
|
|
|
|
!$acc end parallel
|
|
|
|
do i = 1, n
|
2018-12-28 15:30:48 +00:00
|
|
|
if (a(i) .ne. fact(i)) STOP 1
|
2017-04-10 11:32:00 +00:00
|
|
|
end do
|
|
|
|
end program main
|
|
|
|
|
|
|
|
recursive function fact (x) result (res)
|
|
|
|
implicit none
|
|
|
|
!$acc routine (fact)
|
|
|
|
integer, intent(in) :: x
|
|
|
|
integer :: res
|
|
|
|
if (x < 1) then
|
|
|
|
res = 1
|
|
|
|
else
|
|
|
|
res = x * fact(x - 1)
|
|
|
|
end if
|
|
|
|
end function fact
|