Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: [OMPI users] MPI send recv confusion
From: Pradeep Jha (pradeep_at_[hidden])
Date: 2013-02-18 11:06:40

I have attached a sample of the MPI program I am trying to write. When I
run this program using "mpirun -np 4 a.out", my output is:

 Sender: 1
 Data received from 1
 Sender: 2
 Data received from 1
 Sender: 2

And the run hangs there. I dont understand why does the "sender" variable
change its value after MPI_recv? Any ideas?

Thank you,


 program mpi_test

  include 'mpif.h'

!----------------( Initialize variables )--------------------
  integer, dimension(3) :: recv, send

  integer :: sender, np, rank, ierror

  call mpi_init( ierror )
  call mpi_comm_rank( mpi_comm_world, rank, ierror )
  call mpi_comm_size( mpi_comm_world, np, ierror )

!----------------( Main program )--------------------

! receive the data from the other processors
  if (rank.eq.0) then
     do sender = 1, np-1
        print *, "Sender: ", sender
        call mpi_recv(recv, 3, mpi_int, sender, 1,
 & mpi_comm_world, status, ierror)
        print *, "Data received from ",sender
     end do
  end if

! send the data to the main processor
  if ( then
     send(1) = 3
     send(2) = 4
     send(3) = 4
     call mpi_send(send, 3, mpi_int, 0, 1, mpi_comm_world, ierr)
  end if

!----------------( clean up )--------------------
  call mpi_finalize(ierror)

  end program mpi_test`