0

I am attempting to debug a 3D particle in cell code originally written in F77 but now written in F90. Myself and my supervisor believe that the context for this is a memory leakage coming about at some point when the code gets busy (post physics interaction - when there are a lot of particles moving about). Valgrind pumps out the following with the openMPI suppression file.

==8057== Invalid read of size 8
==8057==    at 0x424300: send_b_bd_ (rpp3dsubs.f90:4521)
==8057==    by 0x43C23A: mymain_ (rpp3dmain.f90:1651)
==8057==    by 0x40221F: MAIN__ (rpp3d.f90:386)
==8057==    by 0x401BAC: main (rpp3d.f90:199)
==8057==  Address 0x16f81100 is 0 bytes inside a block of size 38,528 alloc'd
==8057==    at 0x4C2AC3D: malloc (vg_replace_malloc.c:299)
==8057==    by 0x438329: mymain_ (rpp3dmain.f90:120)
==8057==    by 0x40221F: MAIN__ (rpp3d.f90:386)
==8057==    by 0x401BAC: main (rpp3d.f90:199)

There's about thirty or so of these errors. One of the subroutines pointed to is this one.

SUBROUTINE send_B_bd(myid)

  USE B_bd_arrays
  USE grid_parameter

  IMPLICIT NONE

  INCLUDE 'mpif.h'

  INTEGER idown,iup,inorth,isouth,tag,ierr,mpi_status,myid

  ! to +x and from -x
  IF (up >= 0) THEN
     tag = 0
     CALL MPI_SEND(B_bd_up(1,1),2*Grid_y*Grid_z,MPI_DOUBLE_PRECISION, &
          up,tag,MPI_COMM_WORLD,ierr)
  END IF

  IF (down >= 0) THEN
     tag = 0
     CALL MPI_RECV(B_bd_up(1,1),2*Grid_y*Grid_z,MPI_DOUBLE_PRECISION, &
          down,tag,MPI_COMM_WORLD,mpi_status,ierr)
     B_bd_down=B_bd_up
  ELSE
     B_bd_down=0.0d0
  END IF

  B_bd_up=0.0d0

  ! to +y and from -y
  IF (north >= 0) THEN
     tag = 0
     CALL MPI_SEND(B_bd_north(1,1),2*Grid_x*Grid_z,MPI_DOUBLE_PRECISION, &
          north,tag,MPI_COMM_WORLD,ierr)
  END IF

  IF (south >= 0) THEN
     tag = 0
     CALL MPI_RECV(B_bd_north(1,1),2*Grid_x*Grid_z,MPI_DOUBLE_PRECISION, &
          south,tag,MPI_COMM_WORLD,mpi_status,ierr)

     B_bd_south=B_bd_north
  ELSE
     B_bd_south=0.0d0
  END IF

  B_bd_north=0.0d0

END SUBROUTINE send_B_bd

The lines causing the issue appear to be

B_bd_up=0.0d0
B_bd_down=0.0d0

and other similar assignment statements. These are declared elsewhere in the code (in the underlying file rpp3d) with the declaration statements being:

module B_bd_arrays
  DOUBLE PRECISION, ALLOCATABLE,save, DIMENSION (:,:) :: &
       B_bd_north,B_bd_south,B_bd_down, B_bd_up
end module B_bd_arrays

Is it safe to assume that these are suppression worthy statements or is there something more fundamental going on here? I reiterate that something is causing unphysical results for high resolution runs in this code and as such I am trying to kill off all basic errors before considering anything more fundamental wrong with the code.

I realize this is possibly a very simple question, but I would prefer an answer from someone more knowledgable than myself. As I understand it,

fortranArray = 0.0d0

is a perfectly valid way of zeroing an array and is unlikely to produce the code to attempt to access memory which is not available to it.

Further, similar issues appear to arise for assignment statements such as

E_bd_down(iy,iz)=Ex(ix,iy,iz)
E_bd_down(Grid_y+iy,iz)=Ey(ix,iy,iz)
E_bd_down(2*Grid_y+iy,iz)=Ez(ix,iy,iz)

This cannot be a co-incidence. I cannot for the life of me figure out what could be wrong.

0 Answers0