Question

What is the gfortran flag equivalent for intel ifort's

-heap-arrays [size]
Was it helpful?

Solution 2

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.

OTHER TIPS

I've found this:

-fmax-stack-var-size=n This option specifies the size in bytes of the largest array that will be put on the stack; if the size is exceeded static memory is used (except in procedures marked as RECURSIVE). Use the option -frecursive to allow for recursive procedures which do not have a RECURSIVE attribute or for parallel programs. Use -fno-automatic to never use the stack. This option currently only affects local arrays declared with constant bounds, and may not apply to all character variables. Future versions of GNU Fortran may improve this behavior.

The default value for n is 32768.

from gfortran's website. I think it'll do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top