Segfault when allocating large array in Fortran

2019-08-30 11:49发布

问题:

I have a very simple example of a strange segfault I am having and it is as follows:

program big_array_segfault

  integer :: nX = 13000
  integer :: nY = 100000
  real(kind = 8), allocatable :: bigarr(:,:)

  allocate(bigarr(nX, nY))

end program big_array_segfault

Note that I have 20 GB of RAM to work with and this does not even begin to approach that. Everything I have seen online suggests that this may be a problem with Stack space vs Heap space but I don't know how to control the memory in that way using Fortran.

For what it is worth, the I am compiling with gfortran -o big_arr.exe test.f90 so there is nothing special going on in the compilation.