- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
is there an option in Intel Fortran that ensures that variables in a subroutine retain their value when the subroutine is exited? I have not been able to find it so far.
Best
Peter
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I think that Qsave will do the job https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2025-1/save-qsave.html
Beware that it's an atomic bomb that will apply to every variable everywhere in your program. It could be better to explicitly save only variables when required with the option save in declarations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or you can SAVE individual variables ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would strongly recommend using SAVE rather than an option. Figure out which variables need to be kept defined and give them the SAVE attribute. If you're asking this, make sure you are not also assuming that variables are preset to zero.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To make Steve's comment absolutely clear -- in Fortran, all variables are undefined unless initiailised -- so don't assume a variable that has not been initialised has a value of zero.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page