Using the latest gfortran compiler results in the following warnings in one? or a small number of subroutines:
| 1
Warning: Array 'i2' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider using '-frecursive', or increase the '-fmax-stack-var-size=' limit, or change the code to use an ALLOCATABLE array. [-Wsurprising]
The warning is clear and offers solutions. The following solutions can be implemented:
Move the arrays into a common block, which is global shared data that only gets allocated once. This is the approach that Erin took. The negatives are:
Data are being managed as global when they don't need to be. It is desirable that subroutine data is local and that the routine performs a unit of work that is easy to test.
Still using static large arrays.
Set the maximum array size with compiler option. The negatives are:
Any time compiler options are used, it is a bit of a large hammer. However, in this case, increasing the stack size might be relatively harmless.
Declare the array in the subroutine as ALLOCATABLE, which means the dimension is dynamic and controlled by the code that passes in the array. In simple situations, the array can be set to dimension *. This approach is recommended because it keeps the data local to the routine and is flexible.
Using the latest
gfortran
compiler results in the following warnings in one? or a small number of subroutines:The warning is clear and offers solutions. The following solutions can be implemented:
*
. This approach is recommended because it keeps the data local to the routine and is flexible.