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: Re: [OMPI users] sending message to the source(0) from other processors
From: Eugene Loh (Eugene.Loh_at_[hidden])
Date: 2008-12-23 13:23:39

Win Than Aung wrote:

> MPI_Recv(....) << is it possible to receive the message sent from
> other sources? I tried MPI_ANY_SOURCE in place of source but it
> doesn't work out

Yes of course. Can you send a short example of what doesn't work? The
example should presumably be less than about 20 lines. Here is an
example that works:

% cat a.c
#include <stdio.h>
#include <mpi.h>

int main(int argc, char **argv) {
  int np, me, sbuf = -1, rbuf = -2;

  if ( np < 2 ) MPI_Abort(MPI_COMM_WORLD,-1);

  if ( me == 1 ) MPI_Send(&sbuf,1,MPI_INT,0,344,MPI_COMM_WORLD);
  if ( me == 0 ) {
    if ( rbuf == sbuf ) printf("Send/Recv self passed\n");
    else printf("Send/Recv self FAILED\n");


  return 0;
% mpicc a.c
% mpirun -np 2 a.out
Send/Recv self passed