Fix Gfortran stack to static warning

GCC / Gfortran 10 brought new warnings for arrays too big for the current stack settings, that may cause unexpected behavior. The warnings are triggered like:

 integer :: ibig2(1000,1000)
      |                     1

Warning: Array ‘ibig2’ 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]


If the array is in a procedure (subroutine or function) one can workaround this warning by simply adding recursive to the front of the procedure statement. Recursive was meant to be the default for Fortran 2018 standard.

recursive subroutine foo()


As with the Intel Fortran heap-arrays command-line options, there could be a penalty in speed by having large arrays drive off the stack into heap memory.