1! { dg-do run }
2! { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } }
3
4program update
5  use openacc
6  implicit none
7  integer, parameter :: N = 8
8  integer, parameter :: NDIV2 = N / 2
9  real :: a(N), b(N)
10  integer i
11
12  do i = 1, N
13    a(i) = 3.0
14    b(i) = 0.0
15  end do
16
17  !$acc enter data copyin (a, b)
18
19  !$acc parallel present (a, b)
20    do i = 1, N
21      b(i) = a(i)
22    end do
23  !$acc end parallel
24
25  !$acc update host (a, b)
26
27  do i = 1, N
28    if (a(i) .ne. 3.0) STOP 1
29    if (b(i) .ne. 3.0) STOP 2
30  end do
31
32  if (acc_is_present (a) .neqv. .TRUE.) STOP 3
33  if (acc_is_present (b) .neqv. .TRUE.) STOP 4
34
35  do i = 1, N
36    a(i) = 5.0
37    b(i) = 1.0
38  end do
39
40  !$acc update device (a, b)
41
42  !$acc parallel present (a, b)
43    do i = 1, N
44      b(i) = a(i)
45    end do
46  !$acc end parallel
47
48  !$acc update host (a, b)
49
50  do i = 1, N
51    if (a(i) .ne. 5.0) STOP 5
52    if (b(i) .ne. 5.0) STOP 6
53 end do
54
55  if (acc_is_present (a) .neqv. .TRUE.) STOP 7
56  if (acc_is_present (b) .neqv. .TRUE.) STOP 8
57
58  !$acc parallel present (a, b)
59  do i = 1, N
60    b(i) = a(i)
61  end do
62  !$acc end parallel
63
64  !$acc update host (a, b)
65
66  do i = 1, N
67    if (a(i) .ne. 5.0) STOP 9
68    if (b(i) .ne. 5.0) STOP 10
69  end do
70
71  if (acc_is_present (a) .neqv. .TRUE.) STOP 11
72  if (acc_is_present (b) .neqv. .TRUE.) STOP 12
73
74  do i = 1, N
75    a(i) = 6.0
76    b(i) = 0.0
77  end do
78
79  !$acc update device (a, b)
80
81  do i = 1, N
82    a(i) = 9.0
83  end do
84
85  !$acc parallel present (a, b)
86    do i = 1, N
87      b(i) = a(i)
88    end do
89  !$acc end parallel
90
91  !$acc update host (a, b)
92
93  do i = 1, N
94    if (a(i) .ne. 6.0) STOP 13
95    if (b(i) .ne. 6.0) STOP 14
96  end do
97
98  if (acc_is_present (a) .neqv. .TRUE.) STOP 15
99  if (acc_is_present (b) .neqv. .TRUE.) STOP 16
100
101  do i = 1, N
102    a(i) = 7.0
103    b(i) = 2.0
104  end do
105
106  !$acc update device (a, b)
107
108  do i = 1, N
109    a(i) = 9.0
110  end do
111
112  !$acc parallel present (a, b)
113    do i = 1, N
114      b(i) = a(i)
115    end do
116  !$acc end parallel
117
118  !$acc update host (a, b)
119
120  do i = 1, N
121    if (a(i) .ne. 7.0) STOP 17
122    if (b(i) .ne. 7.0) STOP 18
123  end do
124
125  do i = 1, N
126    a(i) = 9.0
127  end do
128
129  !$acc update device (a)
130
131  !$acc parallel present (a, b)
132    do i = 1, N
133      b(i) = a(i)
134    end do
135  !$acc end parallel
136
137  !$acc update host (a, b)
138
139  do i = 1, N
140    if (a(i) .ne. 9.0) STOP 19
141    if (b(i) .ne. 9.0) STOP 20
142  end do
143
144  if (acc_is_present (a) .neqv. .TRUE.) STOP 21
145  if (acc_is_present (b) .neqv. .TRUE.) STOP 22
146
147  do i = 1, N
148    a(i) = 5.0
149  end do
150
151  !$acc update device (a)
152
153  do i = 1, N
154    a(i) = 6.0
155  end do
156
157  !$acc update device (a(1:NDIV2))
158
159  !$acc parallel present (a, b)
160    do i = 1, N
161      b(i) = a(i)
162    end do
163  !$acc end parallel
164
165  !$acc update host (a, b)
166
167  do i = 1, NDIV2
168    if (a(i) .ne. 6.0) STOP 23
169    if (b(i) .ne. 6.0) STOP 24
170  end do
171
172  do i = NDIV2 + 1, N
173    if (a(i) .ne. 5.0) STOP 25
174    if (b(i) .ne. 5.0) STOP 26
175  end do
176
177  if (acc_is_present (a) .neqv. .TRUE.) STOP 27
178  if (acc_is_present (b) .neqv. .TRUE.) STOP 28
179
180  do i = 1, N
181    a(i) = 0.0
182  end do
183
184  !$acc update device (a(1:4))
185
186  !$acc parallel present (a)
187    do i = 1, N
188      a(i) = a(i) + 1.0
189    end do
190  !$acc end parallel
191
192  !$acc update host (a(5:N))
193
194  do i = 1, NDIV2
195    if (a(i) .ne. 0.0) STOP 29
196  end do
197
198  do i = NDIV2 + 1, N
199    if (a(i) .ne. 6.0) STOP 30
200  end do
201
202  !$acc update host (a(1:4))
203
204  do i = 1, NDIV2
205    if (a(i) .ne. 1.0) STOP 31
206  end do
207
208  do i = NDIV2 + 1, N
209    if (a(i) .ne. 6.0) STOP 32
210  end do
211
212  a(3) = 9
213  a(4) = 9
214  a(5) = 9
215  a(6) = 9
216
217  !$acc update device (a(3:6))
218
219  !$acc parallel present (a(1:N))
220    do i = 1, N
221      a(i) = a(i) + 1.0
222    end do
223  !$acc end parallel
224
225  !$acc update host (a(3:6))
226
227  do i = 1, 2
228    if (a(i) .ne. 1.0) STOP 33
229  end do
230
231  do i = 3, 6
232    if (a(i) .ne. 10.0) STOP 34
233  end do
234
235  do i = 7, N
236    if (a(i) .ne. 6.0) STOP 35
237  end do
238
239  !$acc exit data delete (a, b)
240
241end program
242
243