xref: /llvm-project/flang/test/Semantics/OpenMP/ordered02.f90 (revision 502bea25bdc07d1811b8bfea1c2e6bfa8617f72f)
1! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2! OpenMP Version 5.1
3! Check OpenMP construct validity for the following directives:
4! 2.19.9 Ordered Construct
5
6subroutine sub1()
7  integer :: i, j, N = 10
8  real :: arrayA(10), arrayB(10)
9  real, external :: foo, bar
10
11  !$omp ordered
12  arrayA(i) = foo(i)
13  !$omp end ordered
14
15  !$omp ordered threads
16  arrayA(i) = foo(i)
17  !$omp end ordered
18
19  !$omp ordered simd
20  arrayA(i) = foo(i)
21  !$omp end ordered
22
23  !$omp sections
24  do i = 1, N
25    !$omp ordered
26    arrayA(i) = foo(i)
27    !$omp end ordered
28  end do
29  !$omp end sections
30
31  !$omp do ordered
32  do i = 1, N
33    arrayB(i) = bar(i)
34    !$omp ordered
35    arrayA(i) = foo(i)
36    !$omp end ordered
37  end do
38  !$omp end do
39
40  !$omp sections
41  do i = 1, N
42    !ERROR: An ORDERED directive with SIMD clause must be closely nested in a SIMD or worksharing-loop SIMD region
43    !$omp ordered simd
44    arrayA(i) = foo(i)
45    !$omp end ordered
46  end do
47  !$omp end sections
48
49  !$omp do ordered
50  do i = 1, N
51    !$omp parallel
52    do j = 1, N
53      !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a SIMD, worksharing-loop, or worksharing-loop SIMD region
54      !$omp ordered
55      arrayA(i) = foo(i)
56      !$omp end ordered
57    end do
58    !$omp end parallel
59  end do
60  !$omp end do
61
62  !$omp do ordered
63  do i = 1, N
64    !$omp target parallel
65    do j = 1, N
66      !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a SIMD, worksharing-loop, or worksharing-loop SIMD region
67      !$omp ordered
68      arrayA(i) = foo(i)
69      !$omp end ordered
70    end do
71    !$omp end target parallel
72  end do
73  !$omp end do
74
75  !$omp do
76  do i = 1, N
77    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
78    !$omp ordered
79    arrayA(i) = foo(i)
80    !$omp end ordered
81  end do
82  !$omp end do
83
84  !$omp do
85  do i = 1, N
86    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
87    !$omp ordered threads
88    arrayA(i) = foo(i)
89    !$omp end ordered
90  end do
91  !$omp end do
92
93  !$omp do ordered(1)
94  do i = 1, N
95    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
96    !$omp ordered
97    arrayA(i) = foo(i)
98    !$omp end ordered
99  end do
100  !$omp end do
101
102  !$omp do ordered(1)
103  do i = 1, N
104    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
105    !$omp ordered threads
106    arrayA(i) = foo(i)
107    !$omp end ordered
108  end do
109  !$omp end do
110
111  !$omp parallel do ordered(1)
112  do i = 1, N
113    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
114    !$omp ordered
115    arrayA(i) = foo(i)
116    !$omp end ordered
117  end do
118  !$omp end parallel do
119
120  !$omp parallel do ordered(1)
121  do i = 1, N
122    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
123    !$omp ordered threads
124    arrayA(i) = foo(i)
125    !$omp end ordered
126  end do
127  !$omp end parallel do
128
129  !$omp target parallel do ordered(1)
130  do i = 1, N
131    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
132    !$omp ordered
133    arrayA(i) = foo(i)
134    !$omp end ordered
135  end do
136  !$omp end target parallel do
137
138  !$omp target parallel do ordered(1)
139  do i = 1, N
140    !ERROR: An ORDERED directive without the DEPEND clause must be closely nested in a worksharing-loop (or worksharing-loop SIMD) region with ORDERED clause without the parameter
141    !$omp ordered threads
142    arrayA(i) = foo(i)
143    !$omp end ordered
144  end do
145  !$omp end target parallel do
146end
147