Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Segmentation Fault on Fortran

dnewsome
Beginner
1,531 Views
I am developing a new program that involves an array of size 450^3 elements of Real(8) values, but I may have to go even higher to say 600^3 depending on how many points I need in my grid.

I am unable to get the program to run, getting the below error -

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
DCV_GCMD_TwinZeol 081069FE Unknown Unknown Unknown
DCV_GCMD_TwinZeol 0810292C Unknown Unknown Unknown
DCV_GCMD_TwinZeol 080E9FB1 Unknown Unknown Unknown
DCV_GCMD_TwinZeol 080E998B Unknown Unknown Unknown
DCV_GCMD_TwinZeol 08053C35 initializezeolpot 65 Initialize.f90
DCV_GCMD_TwinZeol 0804BED2 MAIN__.H 34 DCV_GCMC.f90
DCV_GCMD_TwinZeol 0804A3B8 Unknown Unknown Unknown
libc.so.6 75FE2E33 Unknown Unknown Unknown
DCV_GCMD_TwinZeol 0804A271 Unknown Unknown Unknown


This is a classic segmentation fault problem, where I am using a super large array. I am running my code in a beowulf cluster, where I request 1500 mb. I am questioning if this is purely a memory problem, but a stack problem.

A google search nor did a search through "man ifort" (fortran manual) show me how to modify the stack size for my program. I assume that if I can enlarge my stack or switch my program over to the "heap" I can get the code to run. Does anyone know how to modify Fortran for Linux to modify the stack size? Or any other pointers/experience here?

Thanks in advance, David
0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,531 Views
The Linux command to change the stacklimit depends on your shell. It can be:

ulimit -s

or

limit stacksize unlimited

Unfortunately, "unlimited" doesn't really mean that and sometimes setting an explicit but large value works better.

What is the statement at line 65 of initializezeolpot?
0 Kudos
dnewsome
Beginner
1,531 Views
The initializezeolpot means "initialize zeolite potential" - it is a simple subroutine to read in energy parameters from a linux script (my works involves physical chemistry) so that I can change my variables without having to hardwire the values in my code. It has worked before in previous editions, but is where the actual segmentation fault occurs. I suspect the stack deficiency for the large arrays interferes with this subroutine working. Also, this subroutine is the first task done in my program.

I did find the command ulimit -s in my search, but not in the fortran manual. Would I place this command in the fortran flags in my makefile when I recompile my code?

How could I specify an explicit stack size, and how would I know how much memory to specify?

Thanks, David
0 Kudos
Steven_L_Intel1
Employee
1,531 Views
This command does not go in your makefile. It something you use to affect the environment in which you run the program.

Is the line identified the beginning of the subroutine itself and not an executable line? If so, that suggests that the routine declares large "automatic arrays" - local arrays whose bounds depend on an argument. These can be replaced by allocatable arrays easy enough. So if you have:

subroutine sub (n)
real bigarray(n)

replace this with:

subroutine sub (n)
real, allocatable :: bigarray(:)

and then add as the first line of executable code:

allocate (bigarray(n))

the rest of the routine can remain unchanged.
0 Kudos
dnewsome
Beginner
1,531 Views
I tested my code by starting with a small array size, and for any array smaller than 250^3 Real(8) elements, I get the code to run. For anything 300^3 or larger I get the segmentation fault. (The exact critical size N^3 is not exactly known, but with 250300).

My network admin told me that he set the stack and other relevant terms to be unlimited.

(**paste**)

beowulf (~)% limit
cputime unlimited
filesize unlimited
datasize unlimited
stacksize unlimited
coredumpsize unlimited
memoryuse unlimited
vmemoryuse unlimited

(**/paste**)

He also indicates he knows that fortran has a limit on what a given variable memory size can be.

Are you aware of the exact limitations on intel fortran. Would using the Allocate attribute solve this error.

For my problem, the 8 arrays I am using are not declared locally in any subroutine, but are in a module and used in various points in my code. How can I dynamically allocate memory for them in this case. In your example, it was for a local array in the subroutine.

Thanks again, David
0 Kudos
dnewsome
Beginner
1,531 Views
A followup to my last message since it got botched somehow in the top when I refer to "250300".

N is between 250 and 300 is what I meant.
0 Kudos
Reply