[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / Semantics / OpenMP / loop-association.f90
blob9fac508e6128a7dfe589e1d8c7ab40955c7d309c
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! Check the association between OpenMPLoopConstruct and DoConstruct
5 integer :: b = 128
6 integer :: c = 32
7 integer, parameter :: num = 16
8 N = 1024
10 ! Different DO loops
12 !$omp parallel
13 !$omp do
14 do 10 i=1, N
15 a = 3.14
16 10 print *, a
17 !$omp end parallel
19 !$omp parallel do
20 DO CONCURRENT (i = 1:N)
21 a = 3.14
22 END DO
24 !$omp parallel do simd
25 outer: DO WHILE (c > 1)
26 inner: do while (b > 100)
27 a = 3.14
28 b = b - 1
29 enddo inner
30 c = c - 1
31 END DO outer
33 ! Accept directives between parallel do and actual loop.
34 !$OMP PARALLEL DO
35 !DIR$ VECTOR ALIGNED
36 DO 20 i=1,N
37 a = a + 0.5
38 20 CONTINUE
39 !$OMP END PARALLEL DO
41 c = 16
42 !ERROR: DO loop after the PARALLEL DO directive must have loop control
43 !$omp parallel do
45 a = 3.14
46 c = c - 1
47 if (c < 1) exit
48 enddo
50 ! Loop association check
52 ! If an end do directive follows a do-construct in which several DO
53 ! statements share a DO termination statement, then a do directive
54 ! can only be specified for the outermost of these DO statements.
55 do 100 i=1, N
56 !$omp do
57 do 100 j=1, N
58 a = 3.14
59 100 continue
60 !ERROR: The ENDDO directive must follow the DO loop associated with the loop construct
61 !$omp enddo
63 !$omp parallel do copyin(a)
64 do i = 1, N
65 !$omp parallel do
66 do j = 1, i
67 enddo
68 !$omp end parallel do
69 a = 3.
70 enddo
71 !$omp end parallel do
73 !$omp parallel do
74 do i = 1, N
75 enddo
76 !$omp end parallel do
77 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
78 !$omp end parallel do
80 !$omp parallel
81 a = 3.0
82 !$omp do simd
83 do i = 1, N
84 enddo
85 !$omp end do simd
87 !$omp parallel do copyin(a)
88 do i = 1, N
89 enddo
90 !$omp end parallel
92 a = 0.0
93 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
94 !$omp end parallel do
95 !$omp parallel do private(c)
96 do i = 1, N
97 do j = 1, N
98 !ERROR: A DO loop must follow the PARALLEL DO directive
99 !$omp parallel do shared(b)
100 a = 3.14
101 enddo
102 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
103 !$omp end parallel do
104 enddo
105 a = 1.414
106 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
107 !$omp end parallel do
109 do i = 1, N
110 !$omp parallel do
111 do j = 2*i*N, (2*i+1)*N
112 a = 3.14
113 enddo
114 enddo
115 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
116 !$omp end parallel do
118 !ERROR: A DO loop must follow the PARALLEL DO directive
119 !$omp parallel do private(c)
120 5 FORMAT (1PE12.4, I10)
121 do i=1, N
122 a = 3.14
123 enddo
124 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
125 !$omp end parallel do
127 !$omp parallel do simd
128 do i = 1, N
129 a = 3.14
130 enddo
131 !$omp end parallel do simd
132 !ERROR: The END PARALLEL DO SIMD directive must follow the DO loop associated with the loop construct
133 !$omp end parallel do simd
135 !ERROR: A DO loop must follow the SIMD directive
136 !$omp simd
137 a = i + 1
138 !ERROR: The END SIMD directive must follow the DO loop associated with the loop construct
139 !$omp end simd