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

OpenMP with latest standard fortran in MS Visual

deeppow
Beginner
708 Views
Embarassingly new at this, i.e. the combo I'm employing.

Have a fortran code that runs fine till I try to turn on OpenMP. Put a few OpenMP directives into the code, e.g. "!$omp parallel do private(i)", and then turned on OpenMP. I believe I'm turned it on correctly. Sequence is as follows:
Project > Project filename properties > Fortran > Language where I set "Process OpenMP Directives" to "General Parallel Code (/Qopenmp)"

It builds fine noting the loops with directives were parallelized.

But when I try to run I get a stack error "forrt1: severe (170): Program Exception - stack overflow"

Suggestions and help greatly appreciated!
0 Kudos
3 Replies
TimP
Honored Contributor III
708 Views
At least in the absence of the /heap-arrays switch, switching on /Qopenmp is likely to consume more run-time stack. The run-time stack limit can be increased in the usual ways, by options such as /link /stack:9999999 or by using editbin to modify the .exe.
http://msdn2.microsoft.com/en-us/library/8cxs58a6(VS.80).aspx

0 Kudos
Steven_L_Intel1
Employee
708 Views
If you're using Visual Studio, you can set the stack size in the property Linker..System..Stack Reserve.

When you enable OpenMP, that has the side-effect of defaulting local variables to "automatic" (stack) storage, so if you have large arrays, they will be stack-allocated. /heap-arrays is one option. Note also that when using OpenMP each thread has its own stack whose size can be set with an environment variable (KMP_STACKSIZE, I think.)
0 Kudos
deeppow
Beginner
708 Views
Thanks folks. Just kept increasing the stack reserve size till it ran.
0 Kudos
Reply