"Fossies" - the Fresh Open Source Software Archive

Member "openmpi-4.1.2/orte/test/mpi/abort.c" (24 Nov 2021, 787 Bytes) of package /linux/misc/openmpi-4.1.2.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 
   12 #include "mpi.h"
   13 
   14 int main(int argc, char* argv[])
   15 {
   16     int rank, size;
   17     int errcode;
   18 
   19     if (1 < argc) {
   20         errcode = strtol(argv[1], NULL, 10);
   21     } else {
   22         errcode = 2;
   23     }
   24 
   25     MPI_Init(&argc, &argv);
   26     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   27     MPI_Comm_size(MPI_COMM_WORLD, &size);
   28 
   29     printf("Hello, World, I am %d of %d\n", rank, size);
   30 
   31     if (1 == size) {
   32             MPI_Abort(MPI_COMM_WORLD, errcode);
   33     } else {
   34         if (1 == rank) {
   35             MPI_Abort(MPI_COMM_WORLD, errcode);
   36         } else {
   37             errcode = 0;
   38             sleep(99999999);
   39         }
   40     }
   41 
   42     MPI_Finalize();
   43     return errcode;
   44 }