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

Stack overflow

bcartolos
Beginner
1,224 Views
Hi all,

I am coding a little fea solver. I use imsl to solve the stiffness matrix but I get a stack overflow error when I refine my solution (The program works well with a limited number of nodes, when I attempt to solve more exact solution the error appears)

The error I get is this:

Unhandled exception at 0x000000014023e1b7 in Problema1.exe: 0xC00000FD: Stack overflow.


The line that is causing the problem is located in a subroutine called from the main program

[fortran]Desp(DI) = Rigidez(DI, DI) .ix. F(DI)[/fortran]


Rigidez, Desp and F are variables declared in a module called Globals

[fortran]real(8), allocatable:: Rigidez(:,:)

real(8), allocatable:: Desp(:)

real(8), allocatable:: F(:)
[/fortran]


DI is a vector declared inside the subroutine and the values are set by another subroutine


[fortran]integer,allocatable:: DI(:)

call DIncognitas(DI, NDI)[/fortran]


Best Regards
0 Kudos
6 Replies
Les_Neilson
Valued Contributor II
1,224 Views
You can, if you wish, increase the stack size in the project settings :

Project->Properties->Linker->System-> Stack Reserve Size

You can also force temporary arrays to be allocated on the heap instead of the stack

Project->Properties->Fortran->Optimization->Heap Arrays 0 (zero)

Les
0 Kudos
bcartolos
Beginner
1,224 Views
Thank Les for your reply

How large should the stack reserve be?

and also Changing the stack size will not affect performance?

Best Regards
0 Kudos
Les_Neilson
Valued Contributor II
1,224 Views
I just took a quick look at one of our (smaller) projects and it is set to 4,000,000
(another, mixed language project, sets the stack at 8Gb!)

I doubt you will notice any performance issues unless you profile the code.

Les
0 Kudos
bcartolos
Beginner
1,224 Views
Thank you very much for your answer

Best Regards
0 Kudos
bcartolos
Beginner
1,224 Views
It's me again

I try to keep refining my solution but another error appeared:

[bash]forrtl: severe (41): insufficient virtual memory[/bash]


Can that restriction be circumvented?


Best Regards
0 Kudos
Steven_L_Intel1
Employee
1,224 Views
The stack is limited to 1GB in Windows. You may be bumping into the 2GB addressable limit in 32-bit Windows. How much data are you trying to allocate? Are you building a 64-bit application? The exception address in the first post suggests you are.
0 Kudos
Reply