1! { dg-do run }
2
3  integer, dimension (128) :: a, b
4  integer :: i, j
5  logical :: k
6  a = -1
7  b = -1
8  do i = 1, 128
9    if (i .ge. 8 .and. i .le. 15) then
10      b(i) = 1 * 256 + i
11    else if (i .ge. 19 .and. i .le. 23) then
12      b(i) = 2 * 256 + i
13    else if (i .ge. 28 .and. i .le. 38) then
14      if (iand (i, 1) .eq. 0) b(i) = 3 * 256 + i
15    else if (i .ge. 59 .and. i .le. 79) then
16      if (iand (i - 59, 3) .eq. 0) b(i) = 4 * 256 + i
17    else if (i .ge. 101 .and. i .le. 125) then
18      if (mod (i - 101, 12) .eq. 0) b(i) = 5 * 256 + i
19    end if
20  end do
21
22  k = .false.
23  j = 8
24!$omp parallel num_threads (4)
25
26!$omp do ordered
27  do i = 8, 15
28    a(i) = 1 * 256 + i
29!$omp ordered
30    if (i .ne. j) k = .true.
31    j = j + 1
32!$omp end ordered
33  end do
34
35!$omp single
36  j = 23
37!$omp end single
38
39!$omp do ordered
40  do i = 23, 19, -1
41    a(i) = 2 * 256 + i
42!$omp ordered
43    if (i .ne. j) k = .true.
44    j = j - 1
45!$omp end ordered
46  end do
47
48!$omp single
49  j = 28
50!$omp end single
51
52!$omp do ordered
53  do i = 28, 39, 2
54    a(i) = 3 * 256 + i
55!$omp ordered
56    if (i .ne. j) k = .true.
57    j = j + 2
58!$omp end ordered
59  end do
60
61!$omp single
62  j = 79
63!$omp end single
64
65!$omp do ordered
66  do i = 79, 59, -4
67    a(i) = 4 * 256 + i
68!$omp ordered
69    if (i .ne. j) k = .true.
70    j = j - 4
71!$omp end ordered
72  end do
73
74!$omp single
75  j = 125
76!$omp end single
77
78!$omp do ordered
79  do i = 125, 90, -12
80    a(i) = 5 * 256 + i
81!$omp ordered
82    if (i .ne. j) k = .true.
83    j = j - 12
84!$omp end ordered
85  end do
86
87!$omp end parallel
88
89  if (any (a .ne. b) .or. k) call abort
90  a = -1
91  k = .false.
92  j = 8
93!$omp parallel num_threads (4)
94
95!$omp do ordered schedule (static)
96  do i = 8, 15
97    a(i) = 1 * 256 + i
98!$omp ordered
99    if (i .ne. j) k = .true.
100    j = j + 1
101!$omp end ordered
102  end do
103
104!$omp single
105  j = 23
106!$omp end single
107
108!$omp do ordered schedule (static, 1)
109  do i = 23, 19, -1
110    a(i) = 2 * 256 + i
111!$omp ordered
112    if (i .ne. j) k = .true.
113    j = j - 1
114!$omp end ordered
115  end do
116
117!$omp single
118  j = 28
119!$omp end single
120
121!$omp do ordered schedule (static, 3)
122  do i = 28, 39, 2
123    a(i) = 3 * 256 + i
124!$omp ordered
125    if (i .ne. j) k = .true.
126    j = j + 2
127!$omp end ordered
128  end do
129
130!$omp single
131  j = 79
132!$omp end single
133
134!$omp do ordered schedule (static, 6)
135  do i = 79, 59, -4
136    a(i) = 4 * 256 + i
137!$omp ordered
138    if (i .ne. j) k = .true.
139    j = j - 4
140!$omp end ordered
141  end do
142
143!$omp single
144  j = 125
145!$omp end single
146
147!$omp do ordered schedule (static, 2)
148  do i = 125, 90, -12
149    a(i) = 5 * 256 + i
150!$omp ordered
151    if (i .ne. j) k = .true.
152    j = j - 12
153!$omp end ordered
154  end do
155
156!$omp end parallel
157
158  if (any (a .ne. b) .or. k) call abort
159  a = -1
160  k = .false.
161  j = 8
162!$omp parallel num_threads (4)
163
164!$omp do ordered schedule (dynamic)
165  do i = 8, 15
166    a(i) = 1 * 256 + i
167!$omp ordered
168    if (i .ne. j) k = .true.
169    j = j + 1
170!$omp end ordered
171  end do
172
173!$omp single
174  j = 23
175!$omp end single
176
177!$omp do ordered schedule (dynamic, 4)
178  do i = 23, 19, -1
179    a(i) = 2 * 256 + i
180!$omp ordered
181    if (i .ne. j) k = .true.
182    j = j - 1
183!$omp end ordered
184  end do
185
186!$omp single
187  j = 28
188!$omp end single
189
190!$omp do ordered schedule (dynamic, 1)
191  do i = 28, 39, 2
192    a(i) = 3 * 256 + i
193!$omp ordered
194    if (i .ne. j) k = .true.
195    j = j + 2
196!$omp end ordered
197  end do
198
199!$omp single
200  j = 79
201!$omp end single
202
203!$omp do ordered schedule (dynamic, 2)
204  do i = 79, 59, -4
205    a(i) = 4 * 256 + i
206!$omp ordered
207    if (i .ne. j) k = .true.
208    j = j - 4
209!$omp end ordered
210  end do
211
212!$omp single
213  j = 125
214!$omp end single
215
216!$omp do ordered schedule (dynamic, 3)
217  do i = 125, 90, -12
218    a(i) = 5 * 256 + i
219!$omp ordered
220    if (i .ne. j) k = .true.
221    j = j - 12
222!$omp end ordered
223  end do
224
225!$omp end parallel
226
227  if (any (a .ne. b) .or. k) call abort
228  a = -1
229  k = .false.
230  j = 8
231!$omp parallel num_threads (4)
232
233!$omp do ordered schedule (guided)
234  do i = 8, 15
235    a(i) = 1 * 256 + i
236!$omp ordered
237    if (i .ne. j) k = .true.
238    j = j + 1
239!$omp end ordered
240  end do
241
242!$omp single
243  j = 23
244!$omp end single
245
246!$omp do ordered schedule (guided, 4)
247  do i = 23, 19, -1
248    a(i) = 2 * 256 + i
249!$omp ordered
250    if (i .ne. j) k = .true.
251    j = j - 1
252!$omp end ordered
253  end do
254
255!$omp single
256  j = 28
257!$omp end single
258
259!$omp do ordered schedule (guided, 1)
260  do i = 28, 39, 2
261    a(i) = 3 * 256 + i
262!$omp ordered
263    if (i .ne. j) k = .true.
264    j = j + 2
265!$omp end ordered
266  end do
267
268!$omp single
269  j = 79
270!$omp end single
271
272!$omp do ordered schedule (guided, 2)
273  do i = 79, 59, -4
274    a(i) = 4 * 256 + i
275!$omp ordered
276    if (i .ne. j) k = .true.
277    j = j - 4
278!$omp end ordered
279  end do
280
281!$omp single
282  j = 125
283!$omp end single
284
285!$omp do ordered schedule (guided, 3)
286  do i = 125, 90, -12
287    a(i) = 5 * 256 + i
288!$omp ordered
289    if (i .ne. j) k = .true.
290    j = j - 12
291!$omp end ordered
292  end do
293
294!$omp end parallel
295
296  if (any (a .ne. b) .or. k) call abort
297  a = -1
298  k = .false.
299  j = 8
300!$omp parallel num_threads (4)
301
302!$omp do ordered schedule (runtime)
303  do i = 8, 15
304    a(i) = 1 * 256 + i
305!$omp ordered
306    if (i .ne. j) k = .true.
307    j = j + 1
308!$omp end ordered
309  end do
310
311!$omp single
312  j = 23
313!$omp end single
314
315!$omp do ordered schedule (runtime)
316  do i = 23, 19, -1
317    a(i) = 2 * 256 + i
318!$omp ordered
319    if (i .ne. j) k = .true.
320    j = j - 1
321!$omp end ordered
322  end do
323
324!$omp single
325  j = 28
326!$omp end single
327
328!$omp do ordered schedule (runtime)
329  do i = 28, 39, 2
330    a(i) = 3 * 256 + i
331!$omp ordered
332    if (i .ne. j) k = .true.
333    j = j + 2
334!$omp end ordered
335  end do
336
337!$omp single
338  j = 79
339!$omp end single
340
341!$omp do ordered schedule (runtime)
342  do i = 79, 59, -4
343    a(i) = 4 * 256 + i
344!$omp ordered
345    if (i .ne. j) k = .true.
346    j = j - 4
347!$omp end ordered
348  end do
349
350!$omp single
351  j = 125
352!$omp end single
353
354!$omp do ordered schedule (runtime)
355  do i = 125, 90, -12
356    a(i) = 5 * 256 + i
357!$omp ordered
358    if (i .ne. j) k = .true.
359    j = j - 12
360!$omp end ordered
361  end do
362
363!$omp end parallel
364
365  if (any (a .ne. b) .or. k) call abort
366end
367