1! RUN: %python %S/../test_errors.py %s %flang -fopenacc
2
3! Check OpenACC clause validity for the following construct and directive:
4!   2.6.5 Data
5!   2.14.6 Enter Data
6!   2.14.7 Exit Data
7
8program openacc_data_validity
9
10  implicit none
11
12  type atype
13    real(8), dimension(10) :: arr
14    real(8) :: s
15  end type atype
16
17  integer :: i, j, b, gang_size, vector_size, worker_size
18  integer, parameter :: N = 256
19  integer, dimension(N) :: c
20  logical, dimension(N) :: d, e
21  integer :: async1
22  integer :: wait1, wait2
23  real :: reduction_r
24  logical :: reduction_l
25  real(8), dimension(N, N) :: aa, bb, cc
26  real(8), dimension(:), allocatable :: dd
27  real(8), pointer :: p
28  logical :: ifCondition = .TRUE.
29  type(atype) :: t
30  type(atype), dimension(10) :: ta
31
32  real(8), dimension(N) :: a, f, g, h
33
34  !ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive
35  !$acc enter data
36
37  !ERROR: Modifier is not allowed for the COPYIN clause on the ENTER DATA directive
38  !$acc enter data copyin(zero: i)
39
40  !ERROR: Only the ZERO modifier is allowed for the CREATE clause on the ENTER DATA directive
41  !$acc enter data create(readonly: i)
42
43  !ERROR: COPYOUT clause is not allowed on the ENTER DATA directive
44  !$acc enter data copyin(i) copyout(i)
45
46  !$acc enter data create(aa) if(.TRUE.)
47
48  !ERROR: At most one IF clause can appear on the ENTER DATA directive
49  !$acc enter data create(aa) if(.TRUE.) if(ifCondition)
50
51  !$acc enter data create(aa) if(ifCondition)
52
53  !$acc enter data create(aa) async
54
55  !ERROR: At most one ASYNC clause can appear on the ENTER DATA directive
56  !$acc enter data create(aa) async async
57
58  !$acc enter data create(aa) async(async1)
59
60  !$acc enter data create(aa) async(1)
61
62  !$acc enter data create(aa) wait(1)
63
64  !$acc enter data create(aa) wait(wait1)
65
66  !$acc enter data create(aa) wait(wait1, wait2)
67
68  !$acc enter data create(aa) wait(wait1) wait(wait2)
69
70  !ERROR: Argument `bb` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
71  !$acc enter data attach(bb)
72
73  !ERROR: At least one of COPYOUT, DELETE, DETACH clause must appear on the EXIT DATA directive
74  !$acc exit data
75
76  !ERROR: Modifier is not allowed for the COPYOUT clause on the EXIT DATA directive
77  !$acc exit data copyout(zero: i)
78
79  !$acc exit data delete(aa)
80
81  !$acc exit data delete(aa) finalize
82
83  !ERROR: At most one FINALIZE clause can appear on the EXIT DATA directive
84  !$acc exit data delete(aa) finalize finalize
85
86  !ERROR: Argument `cc` on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
87  !$acc exit data detach(cc)
88
89  !ERROR: Argument on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
90  !$acc exit data detach(/i/)
91
92  !$acc exit data copyout(bb)
93
94  !$acc exit data delete(aa) if(.TRUE.)
95
96  !$acc exit data delete(aa) if(ifCondition)
97
98  !ERROR: At most one IF clause can appear on the EXIT DATA directive
99  !$acc exit data delete(aa) if(ifCondition) if(.TRUE.)
100
101  !$acc exit data delete(aa) async
102
103  !ERROR: At most one ASYNC clause can appear on the EXIT DATA directive
104  !$acc exit data delete(aa) async async
105
106  !$acc exit data delete(aa) async(async1)
107
108  !$acc exit data delete(aa) async(1)
109
110  !$acc exit data delete(aa) wait(1)
111
112  !$acc exit data delete(aa) wait(wait1)
113
114  !$acc exit data delete(aa) wait(wait1, wait2)
115
116  !$acc exit data delete(aa) wait(wait1) wait(wait2)
117
118  !ERROR: Only the ZERO modifier is allowed for the COPYOUT clause on the DATA directive
119  !$acc data copyout(readonly: i)
120  !$acc end data
121
122  !ERROR: At most one IF clause can appear on the DATA directive
123  !$acc data copy(i) if(.true.) if(.true.)
124  !$acc end data
125
126  !ERROR: At least one of COPYOUT, DELETE, DETACH clause must appear on the EXIT DATA directive
127  !$acc exit data
128
129  !ERROR: At least one of ATTACH, COPY, COPYIN, COPYOUT, CREATE, DEFAULT, DEVICEPTR, NO_CREATE, PRESENT clause must appear on the DATA directive
130  !$acc data
131  !$acc end data
132
133  !$acc data copy(aa) if(.true.)
134  !$acc end data
135
136  !$acc data copy(aa) if(ifCondition)
137  !$acc end data
138
139  !$acc data copy(aa, bb, cc)
140  !$acc end data
141
142  !$acc data copyin(aa) copyin(readonly: bb) copyout(cc)
143  !$acc end data
144
145  !$acc data copyin(readonly: aa, bb) copyout(zero: cc)
146  !$acc end data
147
148  !$acc data create(aa, bb(:,:)) create(zero: cc(:,:))
149  !$acc end data
150
151  !$acc data no_create(aa) present(bb, cc)
152  !$acc end data
153
154  !$acc data deviceptr(aa) attach(dd, p)
155  !$acc end data
156
157  !$acc data copy(aa, bb) default(none)
158  !$acc end data
159
160  !$acc data copy(aa, bb) default(present)
161  !$acc end data
162
163  !ERROR: At most one DEFAULT clause can appear on the DATA directive
164  !$acc data copy(aa, bb) default(none) default(present)
165  !$acc end data
166
167  !ERROR: At most one IF clause can appear on the DATA directive
168  !$acc data copy(aa) if(.true.) if(ifCondition)
169  !$acc end data
170
171  !$acc data copyin(i)
172  !ERROR: Unmatched PARALLEL directive
173  !$acc end parallel
174
175end program openacc_data_validity
176