Capturing automatic array memory allocation failure

Capturing automatic array memory allocation failure

Imagen de David DiLaura


I gave a subroutine that uses automatic arrays. In some (rare) occasions, there isn't enough memory and the call to the routine generates a "stack overflow" error. The automatic arrays are too large.  Is there a way to trap the memoray allocation failure within the routine, so that I can set a error flag and do a graceful return? I being careful here to say "automatic arrays", not "allocatable arrays." I don't want to use allocatable arrays in this routine.


publicaciones de 4 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Casey

The options to fix the stack overflow are to either increase your stacksize or to tell the compiler to allocate automatic arrays on the heap rather than the stack.  Unfortunately, I'm not familiar with exactly where these options are in the VC shell, though I would expect someone will follow up and let you know where to find those.

Imagen de John Campbell


Making the array allocatable would solve the problem. I'm not sure why you don't want to use ALLOCATE. It is a more robust solution, compared to using the stack.


Imagen de Steve Lionel (Intel)

The heap allocation option is Fortran > Optimization > Heap Arrays - set this to zero. Your problem will likely be solved. There is no way to trap stack overflow and do anything graceful with it.


Inicie sesión para dejar un comentario.