|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* FIXME: This test program assumes that MPI_Error_string will work even
|
|
Packit Service |
c5cf8c |
if MPI is not initialized. That is not guaranteed. */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Normally, when checking for error returns from MPI calls, you must ensure
|
|
Packit Service |
c5cf8c |
that the error handler on the relevant object (communicator, file, or
|
|
Packit Service |
c5cf8c |
window) has been set to MPI_ERRORS_RETURN. The tests in this
|
|
Packit Service |
c5cf8c |
program are a special case, as either a failure or an abort will
|
|
Packit Service |
c5cf8c |
indicate a problem */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int error;
|
|
Packit Service |
c5cf8c |
int flag;
|
|
Packit Service |
c5cf8c |
char err_string[1024];
|
|
Packit Service |
c5cf8c |
int length = 1024;
|
|
Packit Service |
c5cf8c |
int rank;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
flag = 0;
|
|
Packit Service |
c5cf8c |
error = MPI_Finalized(&flag;;
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (flag) {
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized returned true before MPI_Init.\n");
|
|
Packit Service |
c5cf8c |
return -1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error = MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Init failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Comm_rank failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, error);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
flag = 0;
|
|
Packit Service |
c5cf8c |
error = MPI_Finalized(&flag;;
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, error);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (flag) {
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized returned true before MPI_Finalize.\n");
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, error);
|
|
Packit Service |
c5cf8c |
return -1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error = MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Barrier failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, error);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error = MPI_Finalize();
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalize failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
flag = 0;
|
|
Packit Service |
c5cf8c |
error = MPI_Finalized(&flag;;
|
|
Packit Service |
c5cf8c |
if (error != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
MPI_Error_string(error, err_string, &length);
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized failed: %s\n", err_string);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
return error;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (!flag) {
|
|
Packit Service |
c5cf8c |
printf("MPI_Finalized returned false after MPI_Finalize.\n");
|
|
Packit Service |
c5cf8c |
return -1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|