I am writing a fortran code with openMP (I’m not so sure if the openMP has anything to do with error). When I test it, the code is well compiled and run with a smaller size of array (=a smaller set of grid points). But as I increase the size of the arrays, it crashes with “Segmentation Fault” error.
Any suggestions would be appreciated. (Adding an additional RAM to my computer will do?)
Is the array fixed size, an allocablable or an automatic?
If fixed size or allocatable, most like the array is larger than 2GB in which case add the flag “-mcmodel=medium”. This will use the Medium Memory Model which uses 64-bit offsets, as opposed to the default 32-bit, thus allowing for single objects greater that 2GB.
For allocatables, you can also use “-Mlarge_arrays” which is implied by “-mcmodel=medium”.
If you’re using automatics, then it’s most likely a stack overflow. When using OpenMP, automatics are allocated on the stack, so if the arrays are large, you can use up all the stack space. To fix, set your shell’s stack size to unlimited. In bash, this would be “ulimit -s unlimited”, in csh “limit stacksize unlimited”. Alternatively, you can use the environment variable “OMP_STACKSIZE”.