The executing program maintains a master stack for the initial (or primary) thread that executes the program, and maintains a different stack for each dependent thread. A stack is a temporary memory address space that retains parameters and automatic variables during a subroutine or function reference call. If the size of the thread stack is too small, a stack overflow may occur, resulting in a silent data corruption or segment failure.
Compiling a Fortran program with the f95 -stackvar option forces local variables and arrays to be allocated on the stack as if they were automatic variables. An explicit parallelization program implies the use of -stackvarfor OpenMP programs, because this option increases the ability of the optimizer to parallelize calls in the loop. (For a discussion of the -stackvar flag, see the Fortran User Guide .) However, if there is not enough memory allocated for the stack, the use causes a stack overflow.
Use the limit C-shell command or the ulimit Bourne or Korn shell command to display or set the stack size of the initial thread (or the main course). Typically, the default stack size for the initial thread is 8 MB.
Each subordinate thread of an OpenMP program has its own thread stack. This stack simulates the initial (or main) thread stack, but is unique to the thread. The PRIVATE array of threads and variables (for threads that are local) are allocated in the thread stack. On 32-bit SPARC V8 and x86 platforms, the default size is 4 MB, and on 64-bit SPARC V9 and x86 platforms, the default size is 8 MB. The size of the slave thread stack is set by the omp_stacksize environment variable.
Stack and stack size