<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108065>108065</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][I/O] SNbone outputs data to stderr instead to a file
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pawosm-arm
</td>
</tr>
</table>
<pre>
I was trying to observe how SNbone behaves when compiled with flang-new, and sadly, it exposed a seriously weird behavior. What I'm seeing is that this code https://github.com/ANL-CESAR/SNbone/blob/dc2c25d51af12933070fd559d933431dd146a035/src_makemesh/Export_Mesh.F90#L32
```
200 FORMAT(10I8)
210 FORMAT(1P,6(E13.6,1X))
OPEN(UNIT=File_Unit,IOSTAT=IOS,FILE='grid_tet_mesh.ascii')
WRITE(File_Unit,'("# Version 1.0 file format for CFE SN miniapp")') ! Generic junk about the file type
WRITE(File_Unit,200) NumVertices,NumElements,NumVacuum
DO Vertex = 1,NumVertices
WRITE(File_Unit,210) GlobalXYZ(Vertex,1),GlobalXYZ(Vertex,2),GlobalXYZ(Vertex,3)
END DO
DO Element = 1,NumElements
WRITE(File_Unit,200) Conn(1,Element),Conn(2,Element),Conn(3,Element),Conn(4,Element)
END DO
DO Element = 1,NumVacuum
WRITE(File_Unit,200) ElementsWithVacuumBCs(Element),LocalSurfaceIndex(Element)
END DO
CLOSE(File_Unit)
```
...does not result in data outputed into the `grid_tet_mesh.ascii` file, everything is dumped to `stderr` (and there is a lot of it!).
To reproduce:
```
$ ./src_makemesh/makemesh.x 30 30 30 0
```
A workaround to have actual data file:
```
$ ./src_makemesh/makemesh.x 30 30 30 0 2>grid_tet_mesh.ascii
```
To make use of the outputed file:
```
$ ln -s grid_tet_mesh.ascii inputmesh.ascii
$ ./src_processmesh/processmesh.x 1 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV1zozoP_jXOjaYMy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