segmentation faults with structure arrays


I am not sure where to start with debugging this problem. I have a fortran code that is using a structure such as below.

When I then declare an array of structure variables that has 3000 elements, I get segmentation fauls. If I limit the size to 2000, the program runs fine. The overall memory requirement of this code is not very large (a few MB) and there is plenty memory on the machine (5 GB).

Am I doing something obviously wrong?

Thanks, Jan

TYPE :: objstruc
      REAL(KIND=RP),DIMENSION(44)           :: par
      REAL(KIND=RP),DIMENSION(NLMX)         :: z 
      REAL(KIND=RP),DIMENSION(3)            :: g
      REAL(KIND=RP),DIMENSION(3)            :: gp 
      REAL(KIND=RP),DIMENSION(3,3)          :: Chat,Chati 
      REAL(KIND=RP)                         :: detChat
      INTEGER(KIND=IB)                    :: k         
      INTEGER(KIND=IB)                    :: NFP     
      REAL(KIND=RP)                         :: logL     
      REAL(KIND=RP)                         :: logPr    
      REAL(KIND=RP)                         :: lognorm  
   END TYPE objstruc

TYPE(objstruc),DIMENSION(3000)   :: particles

Hi Jan,

The first place to start is by compiling with “-g” and then running the code through the PGI debugger to determine the actual cause of the seg fault.

Unless “NLMX” was large, I doubt it’s a memory size issue. The one exception would be if it’s a stack overflow.

  • Mat