Fortran 90 - “Segmentation fault - invalid memory reference” with scalable 3D array

那年仲夏 提交于 2019-12-05 02:25:41

The checks which many compilers have can assist you in debugging. For example with gfortran:

gfortran -g -fcheck=all -Wall segf.f90
segf.f90:5.17:

  INTEGER :: i, j, k
                 1
Warning: Unused variable 'j' declared at (1)
~/f/testy/stackoverflow> ./a.out 
At line 50 of file segf.f90
Fortran runtime error: Index '199' of dimension 3 of array 'phantom' outside of expected range (1:198)

Other compilers have similar options.

Your loops runs on such values of l that you are accessing the arrayphantom out of bounds.

Make sure l has the correct values, 1:m, or that the dimensions of the array phantom are specified correctly to be this range (1:m).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!