how to set the stack size?

how to set the stack size?

Imagen de 史 建鑫

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?

publicaciones de 6 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de TimP (Intel)

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

Imagen de Steve Lionel (Intel)

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
Imagen de 史 建鑫

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!

Imagen de 史 建鑫

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.

Imagen de Steve Lionel (Intel)

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

Inicie sesión para dejar un comentario.