how to set the stack size?

how to set the stack size?

Consider the code below

program Console2
    implicit none
    integer :: a(10000,10000)   # line1
    
    a=1
    print *, 'Hello World'
end program Console2

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?

6 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

As your results don't depend on the a array, the compile could have deleted it.

To set the stack size, set the Linker property System > Stack Reserve. An alternative is to enable Heap Arrays (Fortran > Optimization > Heap Arrays - set to 0.)

Steve - Intel Developer Support

Thank you for all your help.

1. TimP, if i write the array to the file, the program still goes well.

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

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!

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.

2.Steve, I find the two properties, but i cannot find the corresponding help page in the help file. i want to know the default number 0 means what.

3.what is the correct way to use a large array? should i use the "new" operator?

Thank you again.

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:

integer, allocatable :: a(:,:)
allocate (a(10000,10000))
...

Steve - Intel Developer Support

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!