The temporary array at the call site can be made at the stack or at the heap, it is implementation dependent. Compilers usually have options to control the behavior.
With Intel Fortran it the option -heap-arrays n
(n
cannot be ommited or too low, because performance would be bad).
Gfortran would put them on the heap automatically if it doesn't know the size beforehand. It is good to use -fstack-arrays
for better performance (it is included in -Ofast
).
You will find similar options in other compiler's documentation.
I would not fear and avoid the temporary arrays at all cost. The possibility of much shorter (and more readable!) code is sometimes more important. Many codes have portions that are done only once during initialization or final output where the performance penalty is often irrelevant. I personally use it to make my code cleaner in these parts (not in the computational core).