- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider the code below
[fortran]
program Console2
implicit none
integer :: a(10000,10000) # line1
a=1
print *, 'Hello World'
end program Console2
[/fortran]
My compile enviroment is VS2010+intel Parallel Studio XE 2011+Win7.
the code line1 defined a variable “a" with size 4*10000*10000=400MB, and the program pass the compile and run. I remember i got an error "stack oveflow" when i define a big array before. Why it didn't pop the error this time?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As your results don't depend on the a array, the compile could have deleted it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for all your help.
1. TimP, if i write the array to the file, the program still goes well.
[fortran]
program Console2
implicit none
integer :: a(10000,10000)
a=1
Open( 12 , File = 'TestBinW.Bin', Access = 'SEQUENTIAL' , Form = 'Unformatted')
Write( 12) a
Close( 12 )
print *, 'Hello World'
end program Console2
[/fortran]
2. Steve, I cannot find the help page of the "heap:reserve" and "stack:reserve", set the two properties to 0 mean default? if so, what the default size of the heap and stack.
3. I want to know the correct way to use a large array. I think i should use "new" operator, not just define it. am i right?
thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for all your help.
1. TimP, if i write the variable to file, i can also run properly. So, I don't think the compiler delete it.
3.what is the correct way to use a large array? should i use the "new" operator?
Thank you again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A 0 for Heap Arrays means to put all array temporaries on the heap. A blank value means put them on the stack. While one can put in an integer value other than 0, that doesn't actually do anything useful so just use 0.
In Fortran, there is no "new operator". There is ALLOCATE that is used with arrays that have the ALLOCATABLE attribute. For example:
[fortran]
integer, allocatable :: a(:,:)
allocate (a(10000,10000))
...
[/fortran]
![](/skins/images/895D6060305DF45A57FACF854B5A8CD1/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page