- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was wondering if when a recursive routine calls itself, what happens to statements AFTER the call.
Example:
subroutine SUB1(isq)
call sub1(isq+1)
print *,"Does it ever get here?"
print *,isq+1
end
Now if it has a condition such that it SKIPS the call to itself, it will reach the PRINT statement.
But I have seen situations where it got there anyway, and I can't figure out why that would happen.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I meant to say RECURSIVE - sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your example, no. You will eventually get a stack overflow. A correctly written recursive routine will return when it finds it doesn't need to recurse further.

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