Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Handling of Errors

Ilie__Daniel
Beginner
669 Views

Hello!

Is there a way to catch runtime errors and exit the program gracefully?

For example:

The program calls subroutine SUB1. In SUB1, an array out of bound error occurs (Error 154). Can I catch the error and exit that subroutine gracefully, rather than have the program crash?

Thank you for your help.

Kind regards,

Daniel.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
669 Views
Unfortunately, not. An array bounds error does not result in any kind of exception signal you can handle. We have an open feature request to add some sort of user "hook" into the error processing. I'll comment, though, that the notion of "exiting the subroutine gracefully" is very difficult to do in the absence of structured exception handling.

I suggest that if you think array bounds errors may occur that you add code to check the bounds yourself. Fortran intrinsics such as SHAPE, UBOUND, LBOUND, etc. are available to help you with that.
0 Kudos
Reply