- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am noticing different behaviour when I create a large array in two different ways.
If I use the allocatable method:
everything works fine.
If I define the function as:
and call it with
I get the following error at run time:
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
array_test.exe 00447897 Unknown Unknown Unknown
array_test.exe 0040116E Unknown Unknown Unknown
array_test.exe 004637C3 Unknown Unknown Unknown
array_test.exe 004527CE Unknown Unknown Unknown
kernel32.dll 7C816FD7 Unknown Unknown Unknown
I am using Intel Visual Fortran Compiler IA-32, Version 11.0, Build 20090318.
I am launching the compiler from a Cygwin terminal session, using the following command:
/usr/local/bin/ifort -c /QaxSSE4.1 /MT /fpp /Qvec-report0 /check:bounds /warn:all array_test.f90 -o
array_test.obj
Note that the file contains the function described above and a small test program to call the function.
If I use the allocatable method:
[cpp]subroutine array_function(array_size) implicit none integer :: array_size integer, allocatable :: array(:)and call this with
allocate(array(array_size))
...
end subroutine
[/cpp]
[cpp]array_function(300000)[/cpp]
everything works fine.
If I define the function as:
[cpp]subroutine array_function(array_size) implicit none integer :: array_size integer :: array(array_size) ... end subroutine[/cpp]
and call it with
[cpp]array_function(300000)[/cpp]
I get the following error at run time:
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
array_test.exe 00447897 Unknown Unknown Unknown
array_test.exe 0040116E Unknown Unknown Unknown
array_test.exe 004637C3 Unknown Unknown Unknown
array_test.exe 004527CE Unknown Unknown Unknown
kernel32.dll 7C816FD7 Unknown Unknown Unknown
I am using Intel Visual Fortran Compiler IA-32, Version 11.0, Build 20090318.
I am launching the compiler from a Cygwin terminal session, using the following command:
/usr/local/bin/ifort -c /QaxSSE4.1 /MT /fpp /Qvec-report0 /check:bounds /warn:all array_test.f90 -o
array_test.obj
Note that the file contains the function described above and a small test program to call the function.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - wayne.lewis
I am noticing different behaviour when I create a large array in two different ways.
If I use the allocatable method:
everything works fine.
If I define the function as:
and call it with
I get the following error at run time:
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
array_test.exe 00447897 Unknown Unknown Unknown
array_test.exe 0040116E Unknown Unknown Unknown
array_test.exe 004637C3 Unknown Unknown Unknown
array_test.exe 004527CE Unknown Unknown Unknown
kernel32.dll 7C816FD7 Unknown Unknown Unknown
I am using Intel Visual Fortran Compiler IA-32, Version 11.0, Build 20090318.
I am launching the compiler from a Cygwin terminal session, using the following command:
/usr/local/bin/ifort -c /QaxSSE4.1 /MT /fpp /Qvec-report0 /check:bounds /warn:all array_test.f90 -o
array_test.obj
Note that the file contains the function described above and a small test program to call the function.
If I use the allocatable method:
[cpp]subroutine array_function(array_size) implicit none integer :: array_size integer, allocatable :: array(:)and call this with
allocate(array(array_size))
...
end subroutine
[/cpp]
[cpp]array_function(300000)[/cpp]
everything works fine.
If I define the function as:
[cpp]subroutine array_function(array_size) implicit none integer :: array_size integer :: array(array_size) ... end subroutine[/cpp]
and call it with
[cpp]array_function(300000)[/cpp]
I get the following error at run time:
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
array_test.exe 00447897 Unknown Unknown Unknown
array_test.exe 0040116E Unknown Unknown Unknown
array_test.exe 004637C3 Unknown Unknown Unknown
array_test.exe 004527CE Unknown Unknown Unknown
kernel32.dll 7C816FD7 Unknown Unknown Unknown
I am using Intel Visual Fortran Compiler IA-32, Version 11.0, Build 20090318.
I am launching the compiler from a Cygwin terminal session, using the following command:
/usr/local/bin/ifort -c /QaxSSE4.1 /MT /fpp /Qvec-report0 /check:bounds /warn:all array_test.f90 -o
array_test.obj
Note that the file contains the function described above and a small test program to call the function.
By default, automatic arrays are allocated on the stack, whereas the one you explicitly allocate are not. The stack size is not large enough to hold your 300000 element array.
You could either increase your stack size (don't remember the setting right now), or you could tell the compiler to allocate large temporary arrays on the heap rather than on the stack. For that, set the option Fortran->Optimization->Heap Arrays.
Best regards,
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
in contrast to allocatable variables, which are allocated on the heap, automatic variables are taken from the stack. Apparently your default stack size is insufficient; to get around this problem, you can either use the /F option - in your case /F1200000 for 300000 * (size of integer) bytes - or specify /heap-arrays, which would enforce using the heap for automatic arrays as well.
Regards
Reinhold
in contrast to allocatable variables, which are allocated on the heap, automatic variables are taken from the stack. Apparently your default stack size is insufficient; to get around this problem, you can either use the /F option - in your case /F1200000 for 300000 * (size of integer) bytes - or specify /heap-arrays, which would enforce using the heap for automatic arrays as well.
Regards
Reinhold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - reinhold-bader
in contrast to allocatable variables, which are allocated on the heap, automatic variables are taken from the stack. Apparently your default stack size is insufficient; to get around this problem, you can either use the /F option - in your case /F1200000 for 300000 * (size of integer) bytes - or specify /heap-arrays, which would enforce using the heap for automatic arrays as well.

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