- From: Klaus Wacker <wacker@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jun 2007 15:45:24 +0000 (UTC)
Ganesh <ganesh.iitm@xxxxxxxxx> wrote:
I have a subroutine where I am currently allocating 3 arrays at
every function call.. ! I learnt of this SAVE statement just now...!
However it's not quite what I want.. it's much more than what I want..
I can't have array lengths defined at compile time.. but each time
the subroutine is called it's going to be same length.... that is once
the execution has started.. it's going to be the same..
These arrays are used only internally and are not needed outside the
And i don't need the variables saved across the function calls.. i
just need to avoid allocation on every call...
Any idea what will be the best thing to do here..? To avoid
allocating on every call.. or does the compiler detect this
automatically and does something on it's own..I'm using IFORT 9.0..
but I need this to work on Sun Studio 8 (gfortran also if possible)
I have had the idea of declaring these arrays once in the main program
itself and passing them everytime.. that way it will be declared only
once..But that would put something totally out of place in the main
program...Hence i would like to know of some other way if it's
I would recommend automatic arrays for the internal workspace. The
condition for this to work is that the array bounds can be calculated
in a specification expression on entry. One of the easiest ways is to
pass the lengths as arguments in the call.
These arrays usually are actually allocated on every call, but this is
done on the stack and takes very little or no additional execution
time. It happens automatically, there is no allocate statement or
Klaus Wacker klaus.wacker@xxxxxxx
Experimentelle Physik V http://www.physik.uni-dortmund.de/~wacker
Universitaet Dortmund Tel.: +49 231 755 3587
D-44221 Dortmund Fax: +49 231 755 4547
- Re: SAVE
- From: alexei . matveev
- Re: SAVE
- From: Ganesh
- Prev by Date: Re: SAVE
- Next by Date: Re: SAVE
- Previous by thread: Re: SAVE
- Next by thread: Re: SAVE