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

Stack size for loading a subroutine

merik
Beginner
406 Views
I am currently trying to load a subroutine contained in a library which is linked into a DLL which is dynamically loaded by an executable.

Is there any limit to the local variable stack size becuase we are always crashing in chkstk.asm. Also, does the number of subroutines containing a number of parameters beingcalled inside this subroutine affect the size. If there is a set limit, is there a way to increase it?

We are using Fortran 10.1.025.
0 Kudos
1 Reply
mecej4
Honored Contributor III
406 Views
Each time a subroutine (or function) is called/referenced, some of the arguments may be put on the stack, and space on the stack committed to them. Furtner, each subroutine or function will itself consume some stack for local variables. When the routine executes a RETURN or end statement, the stack is released and restored to the state prior to the call.

Thus, you can see that it is not the number of subroutines that are called that matters, but the length of the chain of calls. In other words, if your code calls 99 subroutine each of which needs 128 bytes of stack, one after the other, the stack needed is still 128 bytes. However, if you call A, and A calls B, ..., S calls T, then the stack size needed is 24 X 128 bytes. In a realistic case, you will need to add the individual stack needs of the routines in the call chain, since they will not all be the same.

A simple way of finding the stack needs is to compile with more than sufficient stack allocated, fire up the program in the debugger, and record the value of the stack pointer just before the call to A and just before the exit from T, take the difference and add an allowance for safety.
0 Kudos
Reply