- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two verybasic questions:
How are local variables saved in memory for a subroutine with the Recursive keyword?
And , how is the SAVE attribute handled in a subroutine with the recursive keyword?
Thanks for any info!
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Variables that don't have the SAVE attribute are allocated on the stack. (Allocatable variables have their descriptors on the stack.) Variables with SAVE are statically allocated. Note that data initialization implies SAVE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the following correct:
When a subroutine is recursively called (indirectly) another stack is created for the subroutines local variables, and variables that have the SAVE attributemaybe changed during the recursive call. The final value of the SAVEd variable will be the valueafter the last recursive call.
Thanks for the reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Close enough.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
While searching this Forum for info on stacks, heaps, automatic, recursion, etc. I came across a link to a document that you wrote. Clicking on the link takes me to"Doctor Forum -- Don't Blow Your Stack."However, withinabout 10 secondsthe url is rerouted to an Hp web site, making it impossible to read the document--unless you are a very fast reader. Can you repost the link here?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Better - I'll repost all my Doctor Fortran articles. Stay tuned.
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