<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/113107>113107</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] [OpenMP] do-variable of io-implied-do-control in write statement in parallel construct is not private
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:openmp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 20.0.0(7f65377880ce6a0e5eaa4cb2591b86b8c8a24ee6)/AArch64
```

`do-variable` of `io-implied-do-control` in `write` statement in `parallel` construct is not private.  
The above program is `sngg318f_221.f90`.  
`do-variable` becomes `private` when `io-implied-do-control` is changed to `DO Loop`. 
The above program is `sngg318f_222.f90`.

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

sngg318f_221.f90:
```fortran
subroutine s2
  implicit none
  integer::a(0:1)
  integer::ip
  a=[1,2]
  ip=100
 write(6,*) "1 : ip = ", ip
!$omp parallel  shared(a)
  write(1,*) (a(ip),ip = 0,1)
  if (ip/=2) print *,2001,ip
!$omp end parallel
 write(6,*) "2 : ip = ", ip
  if (ip/=100) print *,1001,ip
end subroutine s2

program main
  integer::n1(2)
  call omp_set_num_threads(2)
  call s2
end program main
```

```
$ flang-new -fopenmp sngg318f_221.f90; ./a.out
 1 : ip =  100
 2 : ip =  2
 1001 2
$
```

```
$ gfortran -fopenmp sngg318f_221.f90; ./a.out
 1 : ip =          100
 2 : ip = 100
$
```

```
$ ifx -qopenmp sngg318f_221.f90; ./a.out
 1 : ip =          100
 2 : ip =            2
        1001 2
$
```

sngg318f_222.f90:
```fortran
subroutine s2
  implicit none
  integer::a(0:1)
  integer::ip
  a=[1,2]
 ip=100
  write(6,*) "1 : ip = ", ip
!$omp parallel  shared(a)
  do ip = 0,1
     write(1,*) a(ip)
  end do
  if (ip/=2) print *,2001,ip
!$omp end parallel
  write(6,*) "2 : ip = ", ip
  if (ip/=100) print *,1001,ip
end subroutine s2

program main
 integer::n1(2)
  call omp_set_num_threads(2)
  call s2
end program main
```

```
$ flang-new -fopenmp sngg318f_222.f90; ./a.out
 1 : ip =  100
 2 : ip =  100
$
```

```
$ gfortran -fopenmp sngg318f_222.f90; ./a.out
 1 : ip =          100
 2 : ip = 100
$
```

```
$ ifx -qopenmp sngg318f_222.f90; ./a.out
 1 : ip =          100
 2 : ip =          100
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV8uO47YS_Rp6Q9ggS--FFm4bvpsbTBZBtg1KKkkcSKRCUu7J3weUJbdf3elk0sFEMGyzWI9TxeJBSVgrG4WYk-iJRPuVGF2rTa5bpdf111Whq99zErP5w_aEbX9FY6VWVNe07oRq1gpfKAm2FNiGbRiBNKnjKEiSNGUlxoJhhEKEZQFRxos0LtIyFRAixgQyAoft1pRtHJ6c38Q6Cyu9PgojRdEhiZmPTWIm9Vr2QyexWld6XWrljO78tlR--8VIN2lbJxz2qNy8MQgjug4n1VIr68xYOiotVdrRwcijcLih9BT8lxapKPQR6WB0Y0TvFUnMrGqagKf1MwDf1JnHfLa5B1xgqXucDOcAXvrSono_EUvLVqgGK-q019x_of_XepiCfRgfLPgui-rtat11-kWqhgqD1LVIHVq3OCKwo4flhP3if7U2zghFhaqorL_RUveD7ISTWhE44DcsR_-fGrRj567C3ZUr2N6c-Ox8Vh8Lo0cnFVILJxGlU41K6ajSCs9C5bBB4_0FW0Eg9a65b61HCnJYxIIEexI9cQI7INH-rD2QYM_Z3H_01EOQxgR2BLYEMkoA-NTvcqAk2Pu1L87imQAnEOp-oEubUWpbYbAikIoLXItrfunaa6RymG7Gbg7ACOyuEqrprHQgwR684WCkcnTysgPG-GR8iwdVdcb0bnrwTnq34X2pbgDwawA-7IPjPH0vPdsLqR4emOIEUrjIvhRdR3U_PFt0z2rsn11rUFT2kdoSa8r8LtJbXH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