<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58091>58091</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Signal end of file rather than error if namelist is not found in file
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:runtime
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jpenix-quic
</td>
</tr>
</table>
<pre>
Example program below:
```
subroutine test
integer, parameter :: read_unit=10
integer :: a
namelist /my_namelist/ a
namelist /missing_namelist/ a
open(unit=read_unit, file="namelist.txt", form="FORMATTED", status="NEW")
write(unit=read_unit, nml=my_namelist, err=1)
close(unit=read_unit)
open(unit=read_unit, file="namelist.txt", form="FORMATTED", status="OLD")
read(unit=read_unit, nml=my_namelist, err=2, end=3)
print *, "Read of my_namelist succeeded, as expected!"
print *, "Trying to read non-present namelist..."
read(unit=read_unit, nml=missing_namelist, err=2, end=3)
return
1 print *, "Error while writing!"
return
2 print *, "Error while reading!"
return
3 print *, "End of file when reading!"
return
end
program p
call test
end
```
gfortran and ifort both print "End of file when reading!" (please see https://godbolt.org/z/eT8KTE89o) but flang prints "Error while reading!" for me.
Would it be ok to change the behavior in flang to match that of gfortran/ifort? From what I understand, I don't think there is a set requirement one way or another for this, but 521.wrf_r in SPEC2017 seems to rely on `end` being taken in this situation and it seems that this is what gfortran and ifort do (although I am not sure about other compilers' behavior here).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VduO2zgM_RrnRajhSy7Ogx_SSQIU3d0u2gB9HMg2HasjS64uzcx-_ZJKnGSamXb2ZQHnIpE8PEek6Eo3T-XmkfeDBDYYvTe8ZxVIfYjyVZSso2T8nienJyytr4z2TihgDqw7bjImlIM9mCi7YwNHKHBgGCHlK2aAN_deCRfl6zT5KWJ04uO-wmAprGNRtu2f7sclrl7xEdYKtX_JcXTXA6goK04ULnSQbCsk4F6UZWN87B7RkgW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