What is the gfortran flag equivalent for intel ifort's
-heap-arrays [size]
This is an old question, but the accepted answer is not fully correct and I would like to add context for future users like me who come across the post looking for answers.
I believe both intel's ifort
and gcc's gfortran
have some byte limit where arrays above said limit are not allocated on the stack, but instead are in static memory.
Intel's: -heap-arrays [size]
, will put any array bigger than [size]
kilobytes on the heap, instead of in static memory or on the stack depending on the size.
Gcc does not have this option and instead only has -fmax-stack-var-size=n
, where any variable above n
bytes is not placed on the stack. The documentation (https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html) says:
if the size is exceeded static memory is used (except in procedures marked as RECURSIVE).
The key difference here is that these large variables are NOT guaranteed to be placed on the heap.
Therefore the two options from intel and gcc are not identical, and more care needs to be taken to ensure large arrays in gfortran
are not shared in static memory.