Fortran · File status code
What does IOSTAT 28 — CLOSE Error mean in Fortran?
The runtime detected an error while executing a CLOSE statement, for example an invalid STATUS= value, a unit that is already closed, or an underlying OS-level failure flushing/removing the file.
The runtime detected an error while executing a CLOSE statement, for example an invalid STATUS= value, a unit that is already closed, or an underlying OS-level failure flushing/removing the file.
Check that the unit is actually open and that STATUS= ('KEEP' or 'DELETE') is valid for that file type before closing, and inspect IOSTAT on the CLOSE rather than assuming it always succeeds.