1! { dg-do run }
2
3program firstprivate
4  integer, parameter :: Nupper=100
5  integer :: a, b(Nupper), c, d, n
6  include "openacc_lib.h"
7
8  if (acc_get_device_type () .eq. acc_device_nvidia) then
9     n = Nupper
10  else
11     n = 1
12  end if
13
14  b(:) = -1
15  a = 5
16
17  !$acc parallel firstprivate (a) num_gangs (n)
18  !$acc loop gang
19  do i = 1, n
20     a = a + i
21     b(i) = a
22  end do
23  !$acc end parallel
24
25  do i = 1, n
26     if (b(i) .ne. i + a) call abort ()
27  end do
28
29  !$acc data copy (a)
30  !$acc parallel firstprivate (a) copyout (c)
31  a = 10
32  c = a
33  !$acc end parallel
34
35  !$acc parallel copyout (d) present (a)
36  d = a
37  !$acc end parallel
38  !$acc end data
39
40  if (c .ne. 10) call abort ()
41  if (d .ne. 5) call abort ()
42end program firstprivate
43