0
$\begingroup$

I'm putting together a very simple integration program in FORTRAN using MPI. I have done this with C and all was well.

However, in my "MAP_REDUCE" call, the comm argument seems problematic. I have tried several different values and have gotten several error messages when the program runs.

Note: the program does compile, but does not run.

Here is the program itself (FORTRAN 90):

  c Fortran example                                                      
  program intega
  implicit none
  include '/opt/apps/intel15/mvapich2/2.1/include/mpif.h'

  integer rank,size,ierror,tag,status(MPI_STATUS_SIZE),i
  real :: integral = 0.00, x = 0.00, total_t = 0.00
  real :: analy,numres,edif


  real, PARAMETER :: x_lower_bound = 0,x_upper_bound = 1
  real, PARAMETER :: nsteps = 10000000
  real, PARAMETER :: dx = (x_upper_bound - x_lower_bound)/nSteps


  integer :: iMin,iMax,ierr=0,comm=0


  call MPI_INIT(ierror)
  call MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierror)
  call MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierror)
  do i = 0,(iMax-1)
      x = x_lower_bound + dx*(i+0.5)
      integral = integral + x*x*dx
   end do

   call MPI_REDUCE(integral,total_t,1,MPI_REAL,MPI_SUM,0,rank,ierr)
   analy = ((x_upper_bound**3)-(x_lower_bound**3))/3
   numres = total_t

   if (rank == 0) then
      edif = analy-numres
      print *, numres,analy,edif
   end if


  call MPI_FINALIZE(ierror)
  end

Now the error file looks like this: (not the whole thing, just a sample)

[cli_0]: [cli_1]: aborting job:
Fatal error in PMPI_Reduce:
Invalid communicator, error stack:
PMPI_Reduce(1288): MPI_Reduce(sbuf=0x6ac4a8, rbuf=0x6ac4b4, count=1, MPI_REAL, \
MPI_SUM, root=0, comm=0x1) failed
PMPI_Reduce(1163): Invalid communicator

aborting job:
Fatal error in PMPI_Reduce:
Invalid communicator, error stack:
PMPI_Reduce(1288): MPI_Reduce(sbuf=0x6ac4a8, rbuf=0x6ac4b4, count=1, MPI_REAL, \
MPI_SUM, root=0, comm=0x0) failed
PMPI_Reduce(1163): Invalid communicator

[cli_2]: aborting job:
Fatal error in PMPI_Reduce:
Invalid communicator, error stack:

So the communicator is the troublemaker. But not sure what I should be putting in there instead.

Thank you in advance for any suggestions.

$\endgroup$
2
$\begingroup$

Your MPI_Reduce call doesn't have a valid communicator specified. I think you left it out entirely. The place where you have rank should be the same value everywhere you call it, and it should be a communicator. From the look of your code, it should be MPI_COMM_WORLD since every rank is doing the operation.

$\endgroup$
  • 1
    $\begingroup$ When using MPI from Fortran, it is highly recommended to use the mpi_f08 module which will catch this sort of thing. $\endgroup$ – Victor Eijkhout Jun 13 '18 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.