- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Also, if I run the program as is... it exits without showing any stack overflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
If I build with optimization, then no stack overflow but also the optimizer removes the dead assignment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, the arrays are not implicitly SAVE. They are probably statically allocated, but that's not the same.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page