Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

Capturing automatic array memory allocation failure

David_DiLaura1
New Contributor I
1,032 Views

Colleagues,

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.

David

0 Kudos
3 Replies
Casey
Beginner
1,032 Views

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.

0 Kudos
John_Campbell
New Contributor II
1,032 Views

David,

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.

John

0 Kudos
Steven_L_Intel1
Employee
1,032 Views

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.

0 Kudos
Reply