root/orte/test/mpi/early_abort.c

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

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* -*- C -*-
   2  *
   3  * $HEADER$
   4  *
   5  * The most basic of MPI applications
   6  */
   7 
   8 #include <stdio.h>
   9 #include <stdlib.h>
  10 #include <unistd.h>
  11 #include <string.h>
  12 #include "mpi.h"
  13 
  14 int main(int argc, char* argv[])
  15 {
  16     int rank, size;
  17     char *rk;
  18 
  19     /* get the MPI rank from the environ */
  20     if (NULL == (rk = getenv("OMPI_COMM_WORLD_RANK"))) {
  21         fprintf(stderr, "FAILED TO GET RANK\n");
  22         exit(1);
  23     }
  24     if (1 < argc) {
  25         /* rank 0 exits first */
  26         if (0 == strcmp(rk, "0")) {
  27             exit(1);
  28         } else {
  29             sleep(1);
  30         }
  31     } else {
  32         if (0 == strcmp(rk, "0")) {
  33             sleep(1);
  34             exit(1);
  35         }
  36     }
  37 
  38     MPI_Init(&argc, &argv);
  39     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  40     MPI_Comm_size(MPI_COMM_WORLD, &size);
  41 
  42     printf("Hello, World, I am %d of %d\n", rank, size);
  43 
  44     MPI_Finalize();
  45     return 0;
  46 }

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