- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have been using Fortran software written by a former associate of mine which was written and debugged on a Sun workstation; I am not sure which compiler, but it is likely to be rather old. I have now recompiled them in Linux using Ifort 9.0, and am experiencing some difficulties that seem to be related to system or compiler compatability.
The problem seems to be that upon exiting a subroutine, variables used in that subroutine are somehow "lost" from memory, or subsequently overwritten, and this causes problems when the variables are used again later in the main program. This was apparently not a problem on the Sun workstation, but only occurs when I attempt to compile in Linux using Ifort 9.0. (The code also compiles and runs properly in Windows using the Compaq compiler.) I have heard that in some cases, with the newer versions of Fortran, variables passed to subroutines which are not declared a certain way may be lost when a subroutine closes.
Thus my question: Is there a compiler option which will take care of this (as it was apparently not a problem in other versions of Fortran?), or a simple way of modifying the code to rectify the problem? I am not a programmer myself, merely a consumer of Fortran code, and the programs are enormous :)
Thanks for any advice,
Jeff
I have been using Fortran software written by a former associate of mine which was written and debugged on a Sun workstation; I am not sure which compiler, but it is likely to be rather old. I have now recompiled them in Linux using Ifort 9.0, and am experiencing some difficulties that seem to be related to system or compiler compatability.
The problem seems to be that upon exiting a subroutine, variables used in that subroutine are somehow "lost" from memory, or subsequently overwritten, and this causes problems when the variables are used again later in the main program. This was apparently not a problem on the Sun workstation, but only occurs when I attempt to compile in Linux using Ifort 9.0. (The code also compiles and runs properly in Windows using the Compaq compiler.) I have heard that in some cases, with the newer versions of Fortran, variables passed to subroutines which are not declared a certain way may be lost when a subroutine closes.
Thus my question: Is there a compiler option which will take care of this (as it was apparently not a problem in other versions of Fortran?), or a simple way of modifying the code to rectify the problem? I am not a programmer myself, merely a consumer of Fortran code, and the programs are enormous :)
Thanks for any advice,
Jeff
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jeff,
Tobias
The problem seems to be that upon exiting a subroutine, variables used in that subroutine are somehow "lost" from memory, or subsequently overwritten, and this causes problems when the variables are used again later in the main program.I'm not completely sure what you mean by that. If you mean that a local variable does not keep the value from the last call to that subroutine, you need to use the SAVE keyword as in
real, save :: myVariableYou could try whether the option -save works for you.
Tobias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tobias,
I tried compiling with the "-save" option, and it worked perfectly! Thanks so much for your help!
Jeff
I tried compiling with the "-save" option, and it worked perfectly! Thanks so much for your help!
Jeff

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