Automatic array allocation upon assignment in Fortran

前端 未结 2 2076
暖寄归人
暖寄归人 2020-11-27 21:35

We recently discovered we were making an assignment to an unallocated array in Fortran. The GNU gfortran compiler didn\'t catch the error, and the code runs under both OSX

2条回答
  •  独厮守ぢ
    2020-11-27 22:07

    It turns out that only GNU gfortran 4.6 and above allow for automatic reallocation of LHS arrays in F90. Using the compiler flag -fno-realloc-lhs disables this feature and triggers seg. faults in all cases I described above (OSX, Linux, PPC) Mystery solved! Thanks to mystery poster whose comment mysteriously disappeared.

    See GCC 4.6 Wiki

提交回复
热议问题