- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a very simpleprogram like the following. When I run this code under Visual Studio 2008 with IntelFortran11, it reports error of stack overflow.If I define array m as "integer m(512, 512)" but not "integer m(k(1),k(2))", the code works well. My system is Windows XP 32, and RAM is 1GB. It should not be the problem of memory. Can someone help me? In addition, I had tried to changek(1) andk(2) to 500 but not 512 in main program. And the code works well too. I am so confused!
program test
IMPLICIT REAL(A-H, O-Z)
integer k(2)
common /index/ k
k(1) = 512
k(2) = 512
call dary
end program test
subroutine dary
IMPLICIT REAL(A-H, O-Z)
integer k(2)
common /index/ k
integer m(k(1),k(2))
m(1,1) = 2
write(*,*) m(1,1)
end subroutine dary
program test
IMPLICIT REAL(A-H, O-Z)
integer k(2)
common /index/ k
k(1) = 512
k(2) = 512
call dary
end program test
subroutine dary
IMPLICIT REAL(A-H, O-Z)
integer k(2)
common /index/ k
integer m(k(1),k(2))
m(1,1) = 2
write(*,*) m(1,1)
end subroutine dary
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may have 1GB of RAM, but the Microsoft linker defaults the stack size to 1MB. You have several choices:
1. In the Linker > System property pages, change the Stack Reserve Size to a larger value. 100000000 (100 million) should be enough
2. Change the Fortran > Optimization > Heap Arrays property to 0, which causes such arrays to be allocated on the heap rather than on the stack
3. Change the code to:
integer, allocatable :: m(:.:)
allocate (m(k(1),k(2))
1. In the Linker > System property pages, change the Stack Reserve Size to a larger value. 100000000 (100 million) should be enough
2. Change the Fortran > Optimization > Heap Arrays property to 0, which causes such arrays to be allocated on the heap rather than on the stack
3. Change the code to:
integer, allocatable :: m(:.:)
allocate (m(k(1),k(2))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
Thanks a lot!!! The code works very well by following your instruction. You are great.
Jing

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