I have some Fortran code that calls RESHAPE
to reorder a matrix such that the dimension that I am now about to loop over becomes the first varying dimension (Co
The Fortran standard does not speak about stack and heap at all, that is an implementation detail. In which part of memory something is placed and whether there are any limits is implementation defined.
Therefore it is impossible to control the stack or heap behaviour from the Fortran code itself. The compiler must be instructed by other means if you want to specify this and the compiler options are used for that. Intel Fortran uses stack by default and has the -heap-arrays n
option (n is the limit in kB), gfortran is slightly different and has the opposite -fstack-arrays
option (included in -Ofast
, but can be disabled).
This is valid for all kinds of temporaries and automatic arrays.