Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] MPI_Send and MPI_Recv not working
From: ankur pachauri (ankurpachauri_at_[hidden])
Date: 2009-10-10 04:39:05

i have openmpi 1.3.3 installed on my linux fedora 10 system, i have a
cluster of two nodes node0(ip and node1(ip among
them passwordless ssh is set and a directory is nfs mounted

when i run a simple test code without and MPI_Send or MPI_Recv it works for
any number of process with the command
mpirun -np 2 --hostfile host a.out
  #include "mpi.h"
   #include <stdio.h>

   int main(argc,argv)
   int argc;
   char *argv[]; {
   int numtasks, rank, rc;
   int x;
   rc = MPI_Init(&argc,&argv);
   if (rc != MPI_SUCCESS) {
     printf ("Error starting MPI program. Terminating.\n");
     MPI_Abort(MPI_COMM_WORLD, rc);

   printf ("\nNumber of tasks= %d \t My rank= %d", numtasks,rank);

   /******* do some work *******/

   if(rank == 0)
        printf("\t This is primary");
        x = 9;
        x = 1;
but when i run another code with MPI_Send or MPI_Recv
it give the follwing error

connect() to failed: No route to host (113)
^Cmpirun: killing job...

mpirun was unable to cleanly terminate the daemons on the nodes shown
below. Additional manual cleanup may be required - please refer to
the "orte-clean" tool for assistance.

#include "mpi.h"
#include "string.h"
#include "stdio.h"
main( argc, argv )
int argc;
char **argv;
    char message[20];
    int myrank;
    MPI_Status status;
    MPI_Init( &argc, &argv );
    MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
    if (myrank == 0) /* code for process zero */
        strcpy(message,"Hello, there");
        MPI_Send(message, strlen(message)+1, MPI_CHAR, 1, 99,
    else if (myrank == 1) /* code for process one */
        MPI_Recv(message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status);
        printf("received :%s:\n", message);

please help


Ankur Pachauri.
Research Scholar,
software engineering.
Department of Mathematics
Dayalbagh Educational Institute