- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page