<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61201>61201</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP] Compilation error of multiple `PARALLEL DO` directives with the same `REDUCTION` clause
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang-new : 17.0.0(0303eafcb34647f7d5a4015aad266b5766f5dc5e)
```
Multiple `PARALLEL DO` directives with the same `REDUCTION` clause are a compile-time error.
The following are the test program, flang-new, gfortran and ifort compilation result.
omp_PARADO_036_2.f:
```fortran
program main
parameter (n=47)
real*8 yyy(n,n),zzz(n,n,n),aaa(n,n,n),tmp,s
do k=1,n
do j=1,n
do i=1,n
yyy(i,j)=float((j)*10+i)
zzz(i,j,k)=float((k)*100+(j)*10+i)
aaa(i,j,k)=0.0
enddo
enddo
enddo
s=0.0
!$omp parallel do private(tmp) reduction(+:s)
do k=1,n
!$omp parallel do private(tmp) reduction(+:s)
do j=1,n
do i=1,n
tmp = zzz(i,j,k)+yyy(i,j)
aaa(i,j,k) = sqrt(tmp**2)
s=s+aaa(i,j,k)
enddo
enddo
!$omp end parallel do
enddo
!$omp end parallel do
end
```
```
$ flang-new -flang-experimental-exec -fopenmp omp_PARADO_036_2.f
error: Semantic errors in omp_PARADO_036_2.f
./omp_PARADO_036_2.f:16:32: error: REDUCTION variable 's' is REDUCTION in outer context must be shared in the parallel region\
s to which any of the worksharing regions arising from the worksharing construct bind.
!$omp parallel do private(tmp) reduction(+:s)
^^^^^^^^^^^^^^
$
```
```
$ gfortran -fopenmp omp_PARADO_036_2.f
$
```
```
$ ifort -qopenmp omp_PARADO_036_2.f
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVltv4ygU_jXkBSXCGF_ykAcnbqSVO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