1! { dg-do run }
2
3module e_53_1_mod
4  integer :: THRESHOLD = 20
5contains
6  integer recursive function fib (n) result (f)
7    !$omp declare target
8    integer :: n
9    if (n <= 0) then
10      f = 0
11    else if (n == 1) then
12      f = 1
13    else
14      f = fib (n - 1) + fib (n - 2)
15    end if
16  end function
17
18  integer function fib_wrapper (n)
19    integer :: x
20    !$omp target map(to: n) map(from: x) if(n > THRESHOLD)
21      x = fib (n)
22    !$omp end target
23    fib_wrapper = x
24  end function
25end module
26
27program e_53_1
28  use e_53_1_mod, only : fib, fib_wrapper
29  if (fib (15) /= fib_wrapper (15)) stop 1
30  ! Reduced from 25 to 23, otherwise execution runs out of thread stack on
31  ! Nvidia Titan V.
32  if (fib (23) /= fib_wrapper (23)) stop 2
33end program
34