Debian Codegraph @

src/mpi/romio/mpi-io/glue/default/mpio_err.c

raw
1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpioimpl.h"
7 #include "adio_extern.h"
8
9 #include <stdarg.h>
10 #include <stdio.h>
11
12 /* Default error handling implementation.
13 *
14 * Note that only MPI_ERRORS_ARE_FATAL and MPI_ERRORS_RETURN are
15 * handled correctly; other handlers cause an abort.
16 */
17
18 int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
19 int line, int error_class, const char generic_msg[],
20 const char specific_msg[], ...)
21 {
22 va_list Argp;
23 int idx = 0;
24 char *buf;
25
26 buf = (char *) ADIOI_Malloc(1024);
27 if (buf != NULL) {
28 idx += snprintf(buf, 1023, "%s (line %d): ", fcname, line);
29 if (specific_msg == NULL) {
30 snprintf(&buf[idx], 1023 - idx, "%s\n", generic_msg);
31 } else {
32 va_start(Argp, specific_msg);
33 vsnprintf(&buf[idx], 1023 - idx, specific_msg, Argp);
34 va_end(Argp);
35 }
36 FPRINTF(stderr, "%s", buf);
37 ADIOI_Free(buf);
38 }
39
40 return error_class;
41 }
42
43 int MPIO_Err_return_file(MPI_File mpi_fh, int error_code)
44 {
45 ADIO_File adio_fh;
46
47 if (mpi_fh == MPI_FILE_NULL) {
48 if (ADIOI_DFLT_ERR_HANDLER != MPI_ERRORS_RETURN) {
49 MPI_Abort(MPI_COMM_WORLD, 1);
50 } else {
51 return error_code;
52 }
53 }
54
55 adio_fh = MPIO_File_resolve(mpi_fh);
56
57 if (adio_fh->err_handler != MPI_ERRORS_RETURN) {
58 MPI_Abort(MPI_COMM_WORLD, 1);
59 } else {
60 return error_code;
61 }
62 }
63
64 int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code)
65 {
66 MPI_Errhandler errh;
67
68 MPI_Comm_get_errhandler(mpi_comm, &errh);
69
70 if (errh != MPI_ERRORS_RETURN) {
71 MPI_Abort(mpi_comm, 1);
72 }
73
74 return error_code;
75 }