1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
! { dg-do compile }
! { dg-options "-fmax-errors=1000 -fopenmp" }
module m
contains
function fn1 (x, y)
integer, intent(in) :: x, y
integer :: fn1
fn1 = x + 2 * y
end function
subroutine sub1 (x, y)
integer, intent(in) :: y
integer, intent(out) :: x
x = y
end subroutine
function fn2 (x)
integer, intent(in) :: x
integer :: fn2
fn2 = x
end function
subroutine sub2 (x, y)
integer, intent(in) :: y
integer, intent(inout) :: x
x = x + y
end subroutine
function fn3 (x, y)
integer, intent(in) :: x(:), y(:)
integer :: fn3(lbound(x, 1):ubound(x, 1))
fn3 = x + 2 * y
end function
subroutine sub3 (x, y)
integer, intent(in) :: y(:)
integer, intent(out) :: x(:)
x = y
end subroutine
function fn4 (x)
integer, intent(in) :: x(:)
integer :: fn4(lbound(x, 1):ubound(x, 1))
fn4 = x
end function
subroutine sub4 (x, y)
integer, intent(in) :: y(:)
integer, intent(inout) :: x(:)
x = x + y
end subroutine
function fn5 (x, y)
integer, intent(in) :: x(10), y(10)
integer :: fn5(10)
fn5 = x + 2 * y
end function
subroutine sub5 (x, y)
integer, intent(in) :: y(10)
integer, intent(out) :: x(10)
x = y
end subroutine
function fn6 (x)
integer, intent(in) :: x(10)
integer :: fn6(10)
fn6 = x
end function
subroutine sub6 (x, y)
integer, intent(in) :: y(10)
integer, intent(inout) :: x(10)
x = x + y
end subroutine
function fn7 (x, y)
integer, allocatable, intent(in) :: x(:), y(:)
integer, allocatable :: fn7(:)
fn7 = x + 2 * y
end function
subroutine sub7 (x, y)
integer, allocatable, intent(in) :: y(:)
integer, allocatable, intent(out) :: x(:)
x = y
end subroutine
function fn8 (x)
integer, allocatable, intent(in) :: x(:)
integer, allocatable :: fn8(:)
fn8 = x
end function
subroutine sub8 (x, y)
integer, allocatable, intent(in) :: y(:)
integer, allocatable, intent(inout) :: x(:)
x = x + y
end subroutine
end module
subroutine test1
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp & initializer (sub1 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp initializer (omp_priv = fn2 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
integer :: a(10)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test1
subroutine test2
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in)) &
!$omp & initializer (sub1 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn2 (omp_orig))
integer :: a
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test2
subroutine test3
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp & initializer (sub1 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
!$omp initializer (omp_priv = fn2 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*scalar and rank-1" }
integer, allocatable :: a(:)
allocate (a(10))
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test3
subroutine test4
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in)) &
!$omp & initializer (sub1 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn2 (omp_orig))
integer, allocatable :: a
allocate (a)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test4
subroutine test5
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn3 (omp_out, omp_in)) &
!$omp & initializer (sub3 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub4 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn4 (omp_orig))
integer :: a(10)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test5
subroutine test6
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn3 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub3 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub4 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn4 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer :: a
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test6
subroutine test7
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn3 (omp_out, omp_in)) &
!$omp & initializer (sub3 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub4 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn4 (omp_orig))
integer, allocatable :: a(:)
allocate (a(10))
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test7
subroutine test8
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn3 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub3 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub4 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn4 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer, allocatable :: a
allocate (a)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test8
subroutine test9
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn5 (omp_out, omp_in)) &
!$omp & initializer (sub5 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub6 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn6 (omp_orig))
integer :: a(10)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test9
subroutine test10
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn5 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub5 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub6 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn6 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer :: a
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test10
subroutine test11
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn5 (omp_out, omp_in)) &
!$omp & initializer (sub5 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub6 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn6 (omp_orig))
integer, allocatable :: a(:)
allocate (a(10))
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test11
subroutine test12
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn5 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub5 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub6 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn6 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer, allocatable :: a
allocate (a)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test12
subroutine test13
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = & ! { dg-error "Different shape for array assignment at \[^\n\r]* on dimension 1 .9 and 10" }
!$omp & fn5 (omp_out, omp_in)) & ! { dg-warning "Actual argument contains too few elements for dummy argument \[^\n\r]* .9/10" }
!$omp & initializer (sub5 (omp_priv, omp_orig)) ! { dg-warning "Actual argument contains too few elements for dummy argument \[^\n\r]* .9/10" }
!$omp declare reduction (baz : integer : sub6 (omp_out, omp_in)) & ! { dg-warning "Actual argument contains too few elements for dummy argument \[^\n\r]* .9/10" }
!$omp initializer (omp_priv = & ! { dg-error "Different shape for array assignment at \[^\n\r]* on dimension 1 .9 and 10" }
!$omp & fn6 (omp_orig)) ! { dg-warning "Actual argument contains too few elements for dummy argument \[^\n\r]* .9/10" }
integer :: a(9)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test13
subroutine test14
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn7 (omp_out, omp_in)) & ! { dg-error "Actual argument for \[^\n\r]* must be ALLOCATABLE" }
!$omp & initializer (sub7 (omp_priv, omp_orig)) ! { dg-error "Actual argument for \[^\n\r]* must be ALLOCATABLE" }
!$omp declare reduction (baz : integer : sub8 (omp_out, omp_in)) & ! { dg-error "Actual argument for \[^\n\r]* must be ALLOCATABLE" }
!$omp initializer (omp_priv = fn8 (omp_orig)) ! { dg-error "Actual argument for \[^\n\r]* must be ALLOCATABLE" }
integer :: a(10)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test14
subroutine test15
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn7 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub7 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub8 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn8 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer :: a
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test15
subroutine test16
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn7 (omp_out, omp_in)) &
!$omp & initializer (sub7 (omp_priv, omp_orig))
!$omp declare reduction (baz : integer : sub8 (omp_out, omp_in)) &
!$omp initializer (omp_priv = fn8 (omp_orig))
integer, allocatable :: a(:)
allocate (a(10))
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test16
subroutine test17
use m
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)
!$omp declare reduction (bar : integer : omp_out = fn7 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
!$omp & initializer (sub7 (omp_priv, omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp declare reduction (baz : integer : sub8 (omp_out, omp_in)) & ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar" }
!$omp initializer (omp_priv = fn8 (omp_orig)) ! { dg-error "Rank mismatch in argument\[^\n\r]*rank-1 and scalar|Incompatible ranks 0 and 1 in assignment" }
integer, allocatable :: a
allocate (a)
!$omp parallel reduction (foo : a)
!$omp end parallel
!$omp parallel reduction (bar : a)
!$omp end parallel
!$omp parallel reduction (baz : a)
!$omp end parallel
end subroutine test17
|