0

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.

Community
  • 1
  • 1
drjrm3
  • 4,474
  • 10
  • 53
  • 91
  • You probably need to increase the stack size. See http://stackoverflow.com/questions/13264274/why-segmentation-fault-is-happening-in-this-openmp-code – M. S. B. Dec 09 '13 at 20:04
  • With allocatables that would be quite strange. – Vladimir F Героям слава Dec 09 '13 at 20:25
  • That alone asks for 10 GB, doesn't any other part of the program use the other 10 GB? – Vladimir F Героям слава Dec 09 '13 at 20:28
  • I tried a few versions of gfortran and stack sizes, and this code ran fine on linux. It may have something to do with cygwin, but I don't have Windows atm and cannot test. Did you try to use MinGW instead? – Xiaolei Zhu Dec 09 '13 at 21:35
  • why is this a new question? Couldn't you update the previous one you're referring to? – steabert Dec 09 '13 at 21:55
  • I thought about it, but the tags, title and general idea of the last question was quite different than this simplified version about stack/heap, so I made a new one. I think the problem may be Windows 8. I am running it on our cluster (256 GB RAM Linux) and it is working fine. I have a VM but I have access to less RAM but the file needed for this computation is ~100+ GB and the VM is only 250 GB large. – drjrm3 Dec 09 '13 at 22:22
  • @Laurbert515 If it is a bug in Cygwin, very little can be done but to download a new version. The alternative, MinGW, tends to have less bug in my experience, but that was a while ago. Maybe you can give that a try. – Xiaolei Zhu Dec 10 '13 at 06:39
  • Could you add the `status=` statement to `allocate`? The resulting error code might give further hints! – Alexander Vogt Dec 10 '13 at 08:57
  • does not segfault for me on 64bin Ubuntu Precise w/ 16gb RAM with stock gfortran. Cygwin / Windows issue? – ev-br Dec 10 '13 at 14:26

0 Answers0