1! { dg-do run }
2
3  call dep ()
4  call dep2 ()
5  call dep3 ()
6  call firstpriv ()
7  call antidep ()
8  call antidep2 ()
9  call antidep3 ()
10  call outdep ()
11  call concurrent ()
12  call concurrent2 ()
13  call concurrent3 ()
14contains
15  subroutine dep
16    integer :: x
17    x = 1
18    !$omp parallel
19      !$omp single
20        !$omp task shared (x) depend(out: x)
21          x = 2
22        !$omp end task
23        !$omp task shared (x) depend(in: x)
24          if (x.ne.2) call abort
25        !$omp end task
26      !$omp end single
27    !$omp end parallel
28  end subroutine dep
29
30  subroutine dep2
31    integer :: x
32    !$omp parallel
33      !$omp single private (x)
34        x = 1
35        !$omp task shared (x) depend(out: x)
36          x = 2
37        !$omp end task
38        !$omp task shared (x) depend(in: x)
39          if (x.ne.2) call abort
40        !$omp end task
41        !$omp taskwait
42      !$omp end single
43    !$omp end parallel
44  end subroutine dep2
45
46  subroutine dep3
47    integer :: x
48    !$omp parallel private (x)
49      x = 1
50      !$omp single
51        !$omp task shared (x) depend(out: x)
52          x = 2
53        !$omp endtask
54        !$omp task shared (x) depend(in: x)
55          if (x.ne.2) call abort
56        !$omp endtask
57      !$omp endsingle
58    !$omp endparallel
59  end subroutine dep3
60
61  subroutine firstpriv
62    integer :: x
63    !$omp parallel private (x)
64      !$omp single
65        x = 1
66        !$omp task depend(out: x)
67          x = 2
68        !$omp end task
69        !$omp task depend(in: x)
70          if (x.ne.1) call abort
71        !$omp end task
72      !$omp end single
73    !$omp end parallel
74  end subroutine firstpriv
75
76  subroutine antidep
77    integer :: x
78    x = 1
79    !$omp parallel
80      !$omp single
81        !$omp task shared(x) depend(in: x)
82          if (x.ne.1) call abort
83        !$omp end task
84        !$omp task shared(x) depend(out: x)
85          x = 2
86        !$omp end task
87      !$omp end single
88    !$omp end parallel
89  end subroutine antidep
90
91  subroutine antidep2
92    integer :: x
93    !$omp parallel private (x)
94      !$omp single
95        x = 1
96        !$omp taskgroup
97          !$omp task shared(x) depend(in: x)
98            if (x.ne.1) call abort
99          !$omp end task
100          !$omp task shared(x) depend(out: x)
101            x = 2
102          !$omp end task
103        !$omp end taskgroup
104      !$omp end single
105    !$omp end parallel
106  end subroutine antidep2
107
108  subroutine antidep3
109    integer :: x
110    !$omp parallel
111      x = 1
112      !$omp single
113        !$omp task shared(x) depend(in: x)
114          if (x.ne.1) call abort
115        !$omp end task
116        !$omp task shared(x) depend(out: x)
117          x = 2
118        !$omp end task
119      !$omp end single
120    !$omp end parallel
121  end subroutine antidep3
122
123  subroutine outdep
124    integer :: x
125    !$omp parallel private (x)
126      !$omp single
127        x = 0
128        !$omp task shared(x) depend(out: x)
129          x = 1
130        !$omp end task
131        !$omp task shared(x) depend(out: x)
132          x = 2
133        !$omp end task
134        !$omp taskwait
135        if (x.ne.2) call abort
136      !$omp end single
137    !$omp end parallel
138  end subroutine outdep
139
140  subroutine concurrent
141    integer :: x
142    x = 1
143    !$omp parallel
144      !$omp single
145        !$omp task shared (x) depend(out: x)
146          x = 2
147        !$omp end task
148        !$omp task shared (x) depend(in: x)
149          if (x.ne.2) call abort
150        !$omp end task
151        !$omp task shared (x) depend(in: x)
152          if (x.ne.2) call abort
153        !$omp end task
154        !$omp task shared (x) depend(in: x)
155          if (x.ne.2) call abort
156        !$omp end task
157      !$omp end single
158    !$omp end parallel
159  end subroutine concurrent
160
161  subroutine concurrent2
162    integer :: x
163    !$omp parallel private (x)
164      !$omp single
165        x = 1
166        !$omp task shared (x) depend(out: x)
167          x = 2;
168        !$omp end task
169        !$omp task shared (x) depend(in: x)
170          if (x.ne.2) call abort
171        !$omp end task
172        !$omp task shared (x) depend(in: x)
173          if (x.ne.2) call abort
174        !$omp end task
175        !$omp task shared (x) depend(in: x)
176          if (x.ne.2) call abort
177        !$omp end task
178        !$omp taskwait
179      !$omp end single
180    !$omp end parallel
181  end subroutine concurrent2
182
183  subroutine concurrent3
184    integer :: x
185    !$omp parallel private (x)
186      x = 1
187      !$omp single
188        !$omp task shared (x) depend(out: x)
189          x = 2
190        !$omp end task
191        !$omp task shared (x) depend(in: x)
192          if (x.ne.2) call abort
193        !$omp end task
194        !$omp task shared (x) depend(in: x)
195          if (x.ne.2) call abort
196        !$omp end task
197        !$omp task shared (x) depend(in: x)
198          if (x.ne.2) call abort
199        !$omp end task
200      !$omp end single
201    !$omp end parallel
202  end subroutine concurrent3
203end
204