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

Issue with openMP commands in Fortran Composer XE 2011

theoryx
Beginner
436 Views
I am using Fortran Composer XE 2011 and I am using Visual Studio 2008 as the shell.

Here is a simple piece of code that I wrote that would not work:

=============================

PROGRAM Console3

IMPLICIT NONE

INTEGER, PARAMETER :: a1 = 30
INTEGER, PARAMETER :: a2 = 100
INTEGER, PARAMETER :: a3 = 100

REAL, DIMENSION(a1,a2,a3) :: abc

!$OMP PARALLEL
!$OMP END PARALLEL

abc(1,1,1) = 1.0

end program Console3

=============================

The assignment of abc(1,1,1) does not occur. Two ways I can "fix" this code is one to remove the OMP commands and second to make the array 2D. Can you help? Or guide me as to where to look or what other forum to post in?

0 Kudos
5 Replies
Steven_L_Intel1
Employee
436 Views
How do you know the assignment does not occur? The program never uses or displays the value of abc and the compiler may have decided to throw away the assignment.

I noticed that if I added a PRINT of some elements of abc I got a stack overflow that I could avoid by increasing the stack size.
0 Kudos
theoryx
Beginner
436 Views
I know because I am debugging the program and the debugger shows that the assignment did not happen? Are you suggesting I increase the stack size to fix the problem?

Also, if I run the program as is... it exits without showing any stack overflow?
0 Kudos
Steven_L_Intel1
Employee
436 Views
I looked at the generated code and the assignment is done. When I build this without optimization but with OpenMP and run it, I get a stack overflow. Are you building with optimization and debugging?

If I build with optimization, then no stack overflow but also the optimizer removes the dead assignment.
0 Kudos
jimdempseyatthecove
Honored Contributor III
436 Views
When you compile with -openmp the arrays are implicitly on stack. Without -openmp (and/or recursive function/subroutine) the arrays are implicitly SAVE... unless you add -heap-arrays. It is the programmers responsibility to assure stack requirements are met. You cannot specify unlimited stack without limiting heap (in some way or other).

Jim Dempsey
0 Kudos
Steven_L_Intel1
Employee
436 Views
No, the arrays are not implicitly SAVE. They are probably statically allocated, but that's not the same.
0 Kudos
Reply