- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve:
I had another program blow up with stack overflow, after it gave me an outof bounds error. I read your Dr Fortran Blog on the Stack overflow issue, but I still have a question.
The routines do Fast Fourier transforms, so I have very large arrays, the array size is set by a variable FFTsize that is passed in the arguments to the subroutines, along with the file number details. When I call the main analysis program the stackoverflows if I set the FFTSize above 4092, it has to multiples of 2, so 8184 is the next size.
What is the best method to establish the arrays so I do not get a stack overflow? My guess is I have 10 arrays with 32678 elements and eight varialbe arrays of FFtSize. This is in Windows 7 32 bit.
Thanks
John
I had another program blow up with stack overflow, after it gave me an outof bounds error. I read your Dr Fortran Blog on the Stack overflow issue, but I still have a question.
The routines do Fast Fourier transforms, so I have very large arrays, the array size is set by a variable FFTsize that is passed in the arguments to the subroutines, along with the file number details. When I call the main analysis program the stackoverflows if I set the FFTSize above 4092, it has to multiples of 2, so 8184 is the next size.
What is the best method to establish the arrays so I do not get a stack overflow? My guess is I have 10 arrays with 32678 elements and eight varialbe arrays of FFtSize. This is in Windows 7 32 bit.
Thanks
John
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
Sorry about the double post, I thought I had lost the first one.
JMN
Sorry about the double post, I thought I had lost the first one.
JMN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can allocate the stack required using the /F option to the compiler or the /stack: option to the linker. If the arrays that you described above are of type double precision, you need about 4 MB of stack.
If, on the other hand, as your bounds overflow suggests, you have mismatched subprogram arguments, an incorrect integer argument could be used as the size of a local variable, and any reasonable allocation of stack would not help to remove the problem. In this case, you should investigate and remove the bounds error first.
If, on the other hand, as your bounds overflow suggests, you have mismatched subprogram arguments, an incorrect integer argument could be used as the size of a local variable, and any reasonable allocation of stack would not help to remove the problem. In this case, you should investigate and remove the bounds error first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The simplest solution is to set the project property Optimization > Heap Arrays to 0. This will allocate local automatic arrays and array temps on the heap rather than the stack.
An approach that doesn't require a special setting is to change the local arrays to ALLOCATABLE and to allocate them to the desired size. For example, instead of:
REAL A(FFTsize)
you'd have:
REAL A(:)
...
ALLOCATE (A(FFTsize))
These will get automatically deallocated on routine exit.
An approach that doesn't require a special setting is to change the local arrays to ALLOCATABLE and to allocate them to the desired size. For example, instead of:
REAL A(FFTsize)
you'd have:
REAL A(:)
...
ALLOCATE (A(FFTsize))
These will get automatically deallocated on routine exit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
Thank you for the responses.
CAn you tel me what format the numbers are required in the stack size allocation. The old Microsoft Fortran manual says hexadecimal, I could not find an answer in the Intel manuals, they said what to do but no example.
Regards
JMN
Thank you for the responses.
CAn you tel me what format the numbers are required in the stack size allocation. The old Microsoft Fortran manual says hexadecimal, I could not find an answer in the Intel manuals, they said what to do but no example.
Regards
JMN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
Worked it out at last, 4000000 worked a treat.
JMN
Worked it out at last, 4000000 worked a treat.
JMN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are using the linker property to set the stack reserve size, the value there is decimal. This may work for you now, but if the problem size increases it may fail again. This is why I generally recommend using heap allocation.
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