Blame test/mpi/ft/sendalive.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *
Packit 0848f5
 *  (C) 2003 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
#include <mpi.h>
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include <stdlib.h>
Packit 0848f5
Packit 0848f5
/*
Packit 0848f5
 * This test attempts communication between 2 running processes
Packit 0848f5
 * after another process has failed.
Packit 0848f5
 */
Packit 0848f5
int main(int argc, char **argv)
Packit 0848f5
{
Packit 0848f5
    int rank, err;
Packit 0848f5
    char buf[10];
Packit 0848f5
Packit 0848f5
    MPI_Init(&argc, &argv);
Packit 0848f5
    MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
Packit 0848f5
    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
Packit 0848f5
Packit 0848f5
    if (rank == 1) {
Packit 0848f5
        exit(EXIT_FAILURE);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    if (rank == 0) {
Packit 0848f5
        err = MPI_Send("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
Packit 0848f5
        if (err) {
Packit 0848f5
            fprintf(stderr, "An error occurred during the send operation\n");
Packit 0848f5
        }
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    if (rank == 2) {
Packit 0848f5
        err = MPI_Recv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
Packit 0848f5
        if (err) {
Packit 0848f5
            fprintf(stderr, "An error occurred during the recv operation\n");
Packit 0848f5
        }
Packit 0848f5
        else {
Packit 0848f5
            printf(" %s\n", buf);
Packit 0848f5
            fflush(stdout);
Packit 0848f5
        }
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}