In one sense one can already do this, but in another there is a fundamental limitation of Fortran that I don't see a way around.
Currently the @assert macros issue a RETURN statement if the assertion fails. This acts as a poor-man's version of throwing an exception, but ... it can only go up one level. There needs to be logic inserted into the calling procedure that checks for the exception and also returns. On can do this manually by testing to see if the calld procedure created an exception:
call foo() ! procedure that throws an exception
if (anyExceptions()) return
And additional care must be applied for the MPI case. If you see a clever way to avodi the need for the extra RETURN line, I'm quite interested.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The original requestor has suggested a package she created called fexception which might be very useful in pFUnit 4.0. If I determine that it is portable (and robust), I'll be happy to go that direction.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The original requestor has suggested a package she created called
fexception which might be very useful in pFUnit 4.0. If I determine that it
is portable (and robust), I'll be happy to go that direction.
Status: open Group: Version > 4 (Future Release) Created: Fri Jun 24, 2016 10:50 PM UTC by Elizabeth F Last Updated: Sun Jun 26, 2016 08:26 PM UTC Owner: nobody
I want to make a subroutine, called by a test, that uses @assertEqual().
I see no obvious solutions to this issue, other than using FException. I would be personally happy with that in the short term, but uncomfortable with going beyond the F2003 standard. That's just asking for trouble.
Any thoughts? I'd suggest we close this issue and live with the limitations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In one sense one can already do this, but in another there is a fundamental limitation of Fortran that I don't see a way around.
Currently the @assert macros issue a RETURN statement if the assertion fails. This acts as a poor-man's version of throwing an exception, but ... it can only go up one level. There needs to be logic inserted into the calling procedure that checks for the exception and also returns. On can do this manually by testing to see if the calld procedure created an exception:
call foo() ! procedure that throws an exception
if (anyExceptions()) return
And additional care must be applied for the MPI case. If you see a clever way to avodi the need for the extra RETURN line, I'm quite interested.
The original requestor has suggested a package she created called fexception which might be very useful in pFUnit 4.0. If I determine that it is portable (and robust), I'll be happy to go that direction.
It doesn't conform to F-2003 standard :(. There might be other ways to get
a similar effect.
On Sun, Jun 26, 2016 at 5:08 PM, Tom Clune tom_clune@users.sf.net wrote:
Related
Feature Requests: #55
I see no obvious solutions to this issue, other than using FException. I would be personally happy with that in the short term, but uncomfortable with going beyond the F2003 standard. That's just asking for trouble.
Any thoughts? I'd suggest we close this issue and live with the limitations.