root/orte/test/mpi/accept.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* -*- C -*-
   2  *
   3  * $HEADER$
   4  *
   5  * Test of connect/accept - the accept (server) side
   6  */
   7 
   8 #include <stdio.h>
   9 #include "mpi.h"
  10 
  11 int main(int argc, char* argv[])
  12 {
  13     int rank, size;
  14     MPI_Info info;
  15     char port[MPI_MAX_PORT_NAME];
  16     MPI_Comm client;
  17 
  18     MPI_Init(&argc, &argv);
  19 
  20     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  21     MPI_Comm_size(MPI_COMM_WORLD, &size);
  22 
  23     printf("Hello, World, I am %d of %d\n", rank, size);
  24     fflush(stdout);
  25 
  26     MPI_Info_create(&info);
  27     MPI_Info_set(info, "ompi_global_scope", "true");
  28 
  29     if (0 == rank) {
  30         MPI_Open_port(MPI_INFO_NULL, port);
  31         MPI_Publish_name("test-pub", info, port);
  32         MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &client);
  33     }
  34 
  35     MPI_Barrier(client);
  36 
  37     if (0 == rank) {
  38         MPI_Unpublish_name("test-pub", info, port);
  39         MPI_Close_port(port);
  40     }
  41 
  42     MPI_Finalize();
  43     return 0;
  44 }

/* [<][>][^][v][top][bottom][index][help] */