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

ask for help!!!

jing-qian
Beginner
534 Views
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
0 Kudos
2 Replies
Steven_L_Intel1
Employee
534 Views
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))
0 Kudos
jing-qian
Beginner
534 Views
Steve:
Thanks a lot!!! The code works very well by following your instruction. You are great.
Jing
0 Kudos
Reply