array dimensioning

array dimensioning

In the following piece of code we tried four ways of dimensioning a simple integer-array. The first two methods (dimensioning by a common-block or a subroutine-argument) cause the error-message:

forrtl: severe (170): Program Exception - stack overflow

..., while the third and fourth way of declaring the bounds of the array work properly - all four ways allocate an array of the same size!
Is there an answer to this mystery??

Code (methods 2-4 not active)

program test 
implicit double precision (a-h,o-z) 
common /mtest/ msize 
msize = 259931 
isize = msize 
call subtest(isize) 
subroutine subtest(i) 
implicit double precision (a-h,o-z) 
parameter (lsize = 259931) 
common /mtest/ msize 
! the following two lines fail during run-time: 
 dimension itestarray(i) 
! dimension itestarray(msize) 
! the following two lines don't fail during run-time: 
! dimension itestarray(lsize) 
! dimension itestarray(259931) 

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The third and fourth methods allocate the array at fixed addresses at link time, whereas the first and second are "automatic arrays" which get allocated on the stack at run-time.


Retired 12/31/2016

I have the same problem. It seems that the only way to go around this problem is to expand the stack size. I tried with limit and it is not enough. How can I do this?




What operating system are you using? You may want to consider using ALLOCATABLE arrays rather than automatic arrays.


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today