Memory issue/seg fault (Updated with code and seg fault msg)

I am compliling a program that uses a bunch of different modules (hence I won’t be able to post code). However, in the code, I am using a allocatable structure, where I only allocate the arrays for a grid cell if it has not already been allocated. I have compiled this program using both the PGF and ifort compilers (as the computer I have has both and we want to make the program compatible for multiple compilers). However, when running the version that has been compiled using the PGF compiler, I notice that I use on the order of 70% of my 2GB of memory. However, if I use the ifort compiler, I only use ~50% of the memory (same code for both). Also, when I use the version compiled with the PGF compiler, it seg faults (no other information) once it tries to allocate part of the structure once the memory usage reaches ~70% (based off of doing numerous print statements to determin where the code seg faults).

I tried to use the -C option to diagnose the problem, however, I ran into a situation similar to Technical Problem Report 3547, http://www.pgroup.com/support/tprs_35xx.htm#t3547. Thus, I was forced to compile all of by .o and .mod files without that option.

So, couple of questions. Why does the PGF compiler version use more memory than other compiler versions of the same code? Is there anyway to get around this issue?

Compile options: -g -Msave -O4 -mp
Machine: Linux 32-bit machine (x86)
Compiler: PGF 7.0

Thanks in advance for any help.

An update on this issue. I ran the PGDBG to gather more information. The error message was as follows:

Signalled SIGSEV at 0x8080c3b, function allocate_grid_cell, file, cell_routines.f90, line 342

The code for this subroutine is as follows (lines with !********** are the lines it fails at):

!------------------------------------------------------------------
! Subroutine to allocate memory for the GRID structure.
! also intializes the counts and mean data variables to 0
!------------------------------------------------------------------

!--- SEG TEMPORARY

subroutine ALLOCATE_GRID_CELL(icell, seg)
  integer (kind=int4), intent(in) :: icell, seg
  real(kind=real4) :: ilat, ilon, dummy_r4

  integer :: astatus, status
  integer :: i,j

  status = 0
if (seg .ge. 50) print *, "ALLOCATE GOOBER 1", status, astatus

  allocate(gridcell(icell)%d(1),stat=astatus) !**********
  status = status +abs(astatus)
  allocate(gridcell(icell)%d(1)%cnt(abichan,0:nmask-1),stat=astatus)
  gridcell(icell)%d(1)%cnt = 0.0
  status = status +abs(astatus)
  allocate(gridcell(icell)%d(1)%cnt_type(0:ntype-1),stat=astatus)
  gridcell(icell)%d(1)%cnt_type = 0.0
  status = status +abs(astatus)
  allocate(gridcell(icell)%d(1)%mean_data(abichan,0:nmask-1),stat=astatus)
  gridcell(icell)%d(1)%mean_data = 0.0
  status = status +abs(astatus)
if (seg .ge. 50) print *, "ALLOCATE GOOBER 2", status, astatus

  allocate(gridcell(icell)%d(1)%std_data(abichan,0:nmask-1),stat=astatus)
  gridcell(icell)%d(1)%std_data = 0.0
  status = status +abs(astatus)
if (seg .ge. 50) print *, "ALLOCATE GOOBER 3", status, astatus

  allocate(gridcell(icell)%d(1)%cld_test(24),stat=astatus)
  status = status +abs(astatus)
if (seg .ge. 50) print *, "ALLOCATE GOOBER 4", status, astatus
  allocate(gridcell(icell)%d(1)%cnt_test(24),stat=astatus)
  status = status +abs(astatus)
if (seg .ge. 50) print *, "ALLOCATE GOOBER 5", status, astatus
  allocate(gridcell(icell)%d(1)%insol_all(maxfpr, maxint),stat=astatus)
  gridcell(icell)%d(1)%insol_all(:,:) = 0.0
  status = status +abs(astatus)
if (seg .ge. 50) print *, "ALLOCATE GOOBER 6", status, astatus

  allocate(gridcell(icell)%d(1)%insol_clr(maxfpr, maxint),stat=astatus) !**********
  gridcell(icell)%d(1)%insol_clr(:,:) = 0.0
  status = status +abs(astatus)


  if (status /= 0) then
!    print "(a,'Not enough memory to allocate grid_params structure.')",EXE_PROMPT
    print "('Not enough memory to allocate grid_params structure.')"
    stop
  endif

  gridcell(icell)%flag = 1
  
  !--- get latitiude/longitude for the particular cell number and
  !--- place them in the lat/lon vars in structure
  
  call PLACE_EQUAL_ANGLE_CELL(icell, ilat, ilon, dummy_r4,dummy_r4)
  
  gridcell(icell)%d(1)%lat = ilat
 
  gridcell(icell)%d(1)%lon =  ilon
  
  num_cells_with_data = num_cells_with_data + 1

end subroutine ALLOCATE_GRID_CELL

As I mentioned, while this code compiles, it gives that same error. I did change the compile options, eliminating the -O4 option. Also, as mentioned above, the ifort compiler (which we also want to use, because some people have it rather than the pgf compiler), does not seg fault at all, and produces valid data.

Again, I appriciate your help.

Hi,

Is it possible for you to provide some small test(a program) case that cause the seg. fault? You can send to trs@pgroup.com or post it here. Can you try with 7.1-1? It is possible that the memory is not allocated and seg. fault when you try to write to it?

Hongyon

Hongyon

I sent you guys an email with the location of the test program. After untaring it, the the make file is in the code directory. Everything is there that you need.