79236186

Date: 2024-11-29 07:37:50
Score: 0.5
Natty:
Report link

Exceptions do not exist in Fortran so there is no Exception handling. But the external file handling statements can now take optional iostat and iomsg clauses.
iostat is an integer which returns a non-zero value if there is an error but the execution will not stop.

You can add them to the open command in the Fortran code:
integer :: my_iostat
character (256) :: my_iomsg
open (unit=1,status="unknown",file=filename,form="unformatted",iostat=my_iostat, iomsg=my_iomsg)
if (my_iostat/=0) then
! put some values in params that you could use to identify the error in Python
else
! read the file
end if

In the python code you must check if the returned values ​​match the ones you defined for error otherwise the file was read without problems.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Lewis