Re: Stack or Heap



On 19 nov, 21:58, PGK <graham.k...@xxxxxxxxx> wrote:
Hi all,

I find I'm guessing at this quite a lot, and wondered if you could
help me. When are arrays allocated on the heap, and when on the stack?
Is this specified by the standard or is the implementation free to
choose? Is a Fortran stack typically larger than a C stack?

Graham

Usually, automatic arrays, as well as local non saved scalar
variables, are allocated on the stack whereas allocated variables
(declared allocatable or pointer) are allocated on the heap.

But this is implementation free and the stack, as far as I know, is
not a FORTRAN or C concept by an operating system concept. On UNIX
computers, I generally declare the stack size as follows :

ulimit -s unlimited

In addition, a compiler usually does not (cannot ?) check the
remaining free stack length : so I tends to avoid the use of large
automatic arrays. Notice that the strategy of the compiler may be
often modified by specific options.
.