How can I avoid a stack overflow when Fortran produces a large, internal, temporary array?

前端 未结 1 1281
小鲜肉
小鲜肉 2020-12-12 00:39

I have some Fortran code that calls RESHAPE to reorder a matrix such that the dimension that I am now about to loop over becomes the first varying dimension (Co

相关标签:
1条回答
  • 2020-12-12 00:56

    The Fortran standard does not speak about stack and heap at all, that is an implementation detail. In which part of memory something is placed and whether there are any limits is implementation defined.

    Therefore it is impossible to control the stack or heap behaviour from the Fortran code itself. The compiler must be instructed by other means if you want to specify this and the compiler options are used for that. Intel Fortran uses stack by default and has the -heap-arrays n option (n is the limit in kB), gfortran is slightly different and has the opposite -fstack-arrays option (included in -Ofast, but can be disabled).

    This is valid for all kinds of temporaries and automatic arrays.

    0 讨论(0)
提交回复
热议问题