catching exceptions from fortran

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Sep 16 00:56:41 EDT 2008


En Mon, 15 Sep 2008 10:04:27 -0300, john <john.m.roach at gmail.com> escribió:

[trying to catch exceptions when reading a file in Fortran code using f2py]

> i agree with everything you write, but unless i misunderstood
> something, this still doesn't address the main problem of the try-
> except construct not preventing the program from aborting when the
> wrapped fortran code encounters an error.  i tried hard-coding all of
> the passed variables to the fortran code and ran that code alone--
> works.  however, when an incorrect fortran read is attempted (ex.
> formatted read on unformatted file), the python except still fails to
> catch the error and the code aborts with a runtime error...

Looks like the error isn't mapped onto a Python exception, and is handled  
directly in the Fortran code;  better to find a f2py group to ask then.
Perhaps you have to catch those errors on the Fortran side. I barely  
remember doing things like READ(..., IOSTAT=IO)...

-- 
Gabriel Genellina




More information about the Python-list mailing list