Capturing automatic array memory allocation failure

Capturing automatic array memory allocation failure

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

4 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

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.

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

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.

Steve - Intel Developer Support

登陆并发表评论。