1

In my application, I have the following in my code. I am using mpi_f08 in that specific routine to use the function MPI_F_SYNC_REG for safe synchronisation. It seems using mpi_f08 is triggering the problem.

 use mpi_f08, only: MPI_F_SYNC_REG
 do I = 1, noblocks
 ncell = geom(I)% ncell
 allocate(buf(ncell,6))
 call MPI_IBCAST(buf,root,ncell*6, request, mpi_comm_world, mopier)
 call mpi_wait(request, mpier)
 ptr = buf(:,6)
 deallocate(buf)
 enddo

When running with openmpi and gfortran I get the following runtime error:

Fortran runtime error: Index '6' of dimension 2 of array 'buf' outside of expected range (0:5)

I am running with gcc 10.1.0 and openmpi 4.1.0. Recreating this problem is tough, I am seeking an advice or hints, if any of way might have came across such problem before. What could this be? Because clearly I am explicitly allocating 6 elements on the 2nd dimension, and I don't see why gfortran suddenly switches to a 0 based indexing

ATK
  • 1,296
  • 10
  • 26
  • Most likely you are writing in the memory you are not supposed to write to and you have a typical heap corruption.Enable all debugging flags in your compiler and check that you are calling all MPI procedures exactly as you should. – Vladimir F Героям слава Jun 28 '21 at 09:20
  • I have these: `-g -fbacktrace -fno-second-underscore -cpp -std=legacy -fbounds-check -fcheck-array-temporaries -fcheck=all -fno-range-check -Wno-tabs -Wsurprising -ffixed-line-length-none -ffree-line-length-512 -fdec -O0 -c` . Am I missing others? – ATK Jun 28 '21 at 09:23
  • 1
    Are you doing `Use mpi_f08`? There's a horrible bug in (I think) gfortran which can remap the indices causing havoc. But `Use mpi_f08` is definitely the thing that triggered it when I cam across it – Ian Bush Jun 28 '21 at 09:57
  • 2
    Is this relevant: https://stackoverflow.com/questions/63824065/lbound-of-an-array-changes-after-call-to-mpi-gatherv-when-using-mpi-f08-module – Ian Bush Jun 28 '21 at 10:03
  • YES I AM, Omg. Okay thanks I will try to workaround using that – ATK Jun 28 '21 at 10:09
  • 2
    OMG indeed. I'll mark as duplicate, but it would be good if you can edit your question to include the `Use mpi_f08` bit – Ian Bush Jun 28 '21 at 10:12
  • 1
    Can confirm now that by removing `use mpi_f08`, this problem is solved. – ATK Jun 28 '21 at 10:27

0 Answers0