1! Ensure that a non-scalar dummy arguments which are implicitly used inside
2! offloaded regions are properly mapped using present_or_copy, or (default)
3! present.
4
5! { dg-do run }
6
7program main
8  implicit none
9
10  integer,parameter :: size = 100
11  integer :: array(size), i, n
12
13  n = size
14
15  !$acc data copy(array)
16
17  call kernels(array, n)
18
19  !$acc update host(array)
20
21  do i = 1, n
22     if (array(i) .ne. i) STOP 1
23  end do
24
25  call kernels_default_present(array, n)
26
27  !$acc update host(array)
28
29  do i = 1, n
30     if (array(i) .ne. i+1) STOP 2
31  end do
32
33  call parallel(array, n)
34
35  !$acc update host(array)
36
37  do i = 1, n
38     if (array(i) .ne. i+i) STOP 3
39  end do
40
41  call parallel_default_present(array, n)
42
43  !$acc end data
44
45  do i = 1, n
46     if (array(i) .ne. i+i+1) STOP 4
47  end do
48end program main
49
50subroutine kernels (array, n)
51  integer, dimension (n) :: array
52  integer :: n, i
53
54  !$acc kernels
55  do i = 1, n
56     array(i) = i
57  end do
58  !$acc end kernels
59end subroutine kernels
60
61subroutine kernels_default_present (array, n)
62  integer, dimension (n) :: array
63  integer :: n, i
64
65  !$acc kernels default(present)
66  do i = 1, n
67     array(i) = i+1
68  end do
69  !$acc end kernels
70end subroutine kernels_default_present
71
72subroutine parallel (array, n)
73  integer, dimension (n) :: array
74  integer :: n, i
75
76  !$acc parallel
77  do i = 1, n
78     array(i) = i+i
79  end do
80  !$acc end parallel
81end subroutine parallel
82
83subroutine parallel_default_present (array, n)
84  integer, dimension (n) :: array
85  integer :: n, i
86
87  !$acc parallel default(present)
88  do i = 1, n
89     array(i) = i+i+1
90  end do
91  !$acc end parallel
92end subroutine parallel_default_present
93