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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Incorrect execution result of writing and reading namelist-group-name as described in the `NAMELIST` statement
        </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(5a50ba03e9adb1614189530f8a5ef06d90dfd670)
```

The execution result of writing and reading namelist-group-name as described in the `NAMELIST` statement is incorrect.
The `Write` statement on line 26 in subroutine yy does not seem to work correctly.

The following are the test program, results of flang-new, gfortran and ifort compilation and execution.

snggf688_5.f90:
```fortran
program main
  call s1
  print *,'pass'
end program main

module m1
  namelist /a/ i
end module m1

subroutine s1
  namelist /a/i
  call xx
 call yy
  write(6,*) "before read : i = ", i
  rewind 1
 read(1,a)
  write(6,*) "after  read : i = ", i
  if (i/=2)write(6,*) "NG i = ", i
contains
  subroutine xx
    use m1
    i=2
 end subroutine xx
  subroutine yy
    use m1
    write(1,a)
 i=3
  end subroutine yy
end subroutine s1
```

```
$ flang-new -flang-experimental-exec snggf688_3.f90; ./a.out
 before read : i =  3
 after  read : i =  0
 NG i =  0
 pass
$
$ cat fort.1
&A I= 0/
$
```

```
$ gfortran snggf688_3.f90; ./a.out
 before read : i =            0
 after  read : i = 2
 pass
$
$ cat fort.1
&A
 I=2          ,
 /
$
```

```
$ ifort snggf688_3.f90; ./a.out
 before read : i =            0
 after  read : i =            2
 pass
$
$ cat fort.1
 &A
 I       =           2
 /
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VluvozYQ_jXmZRRkhkvggYfspqmO1O5LV-1jZWAg3oId2aY5-feVuSQnaU67u1IbHXHw2PPNfHMzwlrZKaKSpR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