1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #include <mpi.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "mpitest.h"
10 
11 /*
12  * This test attempts communication between 2 running processes
13  * after another process has failed.
14  */
main(int argc,char ** argv)15 int main(int argc, char **argv)
16 {
17     int rank, err;
18     char buf[10];
19 
20     MPI_Init(&argc, &argv);
21     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22     MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
23 
24     if (rank == 1) {
25         exit(EXIT_FAILURE);
26     }
27 
28     if (rank == 0) {
29         err = MPI_Send("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
30         if (err) {
31             fprintf(stderr, "An error occurred during the send operation\n");
32         }
33     }
34 
35     if (rank == 2) {
36         err = MPI_Recv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
37         if (err) {
38             fprintf(stderr, "An error occurred during the recv operation\n");
39         } else {
40             printf(" %s\n", buf);
41             fflush(stdout);
42         }
43     }
44 
45     MPI_Finalize();
46 
47     return MTestReturnValue(err);
48 }
49