xref: /llvm-project/flang/test/Semantics/OpenMP/ordered01.f90 (revision b08b252a023eeead07b3e77ce799c3a7d783a0b3)
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
6program main
7  integer :: i, N = 10
8  real :: a, arrayA(10), arrayB(10), arrayC(10)
9  real, external :: foo, bar, baz
10
11  !$omp do ordered
12  do i = 1, N
13    !ERROR: At most one THREADS clause can appear on the ORDERED directive
14    !$omp ordered threads threads
15    arrayA(i) = i
16    !$omp end ordered
17  end do
18  !$omp end do
19
20  !$omp simd
21  do i = 1, N
22    !ERROR: At most one SIMD clause can appear on the ORDERED directive
23    !$omp ordered simd simd
24    arrayA(i) = i
25    !$omp end ordered
26  end do
27  !$omp end simd
28
29  !$omp do simd ordered
30  do i = 1, N
31    !ERROR: At most one SIMD clause can appear on the ORDERED directive
32    !$omp ordered simd simd
33    arrayA(i) = i
34    !$omp end ordered
35  end do
36  !$omp end do simd
37
38  !$omp do ordered(1)
39  do i = 2, N
40    !ERROR: Only SINK or SOURCE dependence types are allowed when ORDERED construct is a standalone construct with no ORDERED region
41    !ERROR: At most one SOURCE dependence type can appear on the ORDERED directive
42    !$omp ordered depend(source) depend(inout: arrayA) depend(source)
43    arrayA(i) = foo(i)
44    !ERROR: The SINK and SOURCE dependence types are mutually exclusive
45    !ERROR: At most one SOURCE dependence type can appear on the ORDERED directive
46    !$omp ordered depend(sink: i - 1) depend(source) depend(source)
47    arrayB(i) = bar(arrayA(i), arrayB(i-1))
48    !ERROR: Only SINK or SOURCE dependence types are allowed when ORDERED construct is a standalone construct with no ORDERED region
49    !ERROR: Only SINK or SOURCE dependence types are allowed when ORDERED construct is a standalone construct with no ORDERED region
50    !$omp ordered depend(out: arrayC) depend(in: arrayB)
51    arrayC(i) = baz(arrayB(i-1))
52  end do
53  !$omp end do
54
55  !$omp do ordered(1)
56  do i = 2, N
57    !ERROR: DEPEND clauses are not allowed when ORDERED construct is a block construct with an ORDERED region
58    !$omp ordered depend(source)
59    arrayA(i) = foo(i)
60    !$omp end ordered
61    !ERROR: DEPEND clauses are not allowed when ORDERED construct is a block construct with an ORDERED region
62    !$omp ordered depend(sink: i - 1)
63    arrayB(i) = bar(arrayA(i), arrayB(i-1))
64    !$omp end ordered
65  end do
66  !$omp end do
67
68contains
69  subroutine work1()
70    !ERROR: THREADS and SIMD clauses are not allowed when ORDERED construct is a standalone construct with no ORDERED region
71    !$omp ordered simd
72  end subroutine work1
73
74  subroutine work2()
75    !ERROR: THREADS and SIMD clauses are not allowed when ORDERED construct is a standalone construct with no ORDERED region
76    !$omp ordered threads
77  end subroutine work2
78
79end program main
80