- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have spent a few days trying to find a bug in my code, but later I realised that ifort comes up with segmentation fault beyond certain level of recursion in recursive subroutines.
Can you please let me know the maximum allowed number? What does that depend on?
The following code does not help me, since the extent to which it will run before it gives 'segmentation fault' will change every time I run it! :O
Test code:
I have spent a few days trying to find a bug in my code, but later I realised that ifort comes up with segmentation fault beyond certain level of recursion in recursive subroutines.
Can you please let me know the maximum allowed number? What does that depend on?
The following code does not help me, since the extent to which it will run before it gives 'segmentation fault' will change every time I run it! :O
Test code:
! RECURS.F90
!
i = 0
CALL Inc (i)
END
RECURSIVE SUBROUTINE Inc (i)
i = i + 1
CALL Out (i)
IF (i.LT.157500) CALL Inc (i) ! This also works in OUT
END SUBROUTINE Inc
SUBROUTINE Out (i)
WRITE (*,*) i
END SUBROUTINE Out
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Recursion pushes a stack frame and arguments for each invocation. So the limit is the limit of your current stacksize. Try the following commands from your system prompt:
ulimit a [to see the current limit]
ulimit s [to set the stack size as unlimited to make it as big as supported on your system]
The limit will vary a little by Linux type and version.
Procedure calls always use the stack to save the return information. The return address is stored along with return results (RESULT) values. The arguments are, by default, also passed on stack.
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