This source file includes following definitions.
- MPIO_Err_create_code
- MPIO_Err_return_file
- MPIO_Err_return_comm
1
2
3
4
5
6
7 #include "mpioimpl.h"
8 #include "adio_extern.h"
9
10 #include <stdarg.h>
11 #include <stdio.h>
12
13
14
15
16
17
18
19 int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
20 int line, int error_class, const char generic_msg[],
21 const char specific_msg[], ... )
22 {
23 va_list Argp;
24 int idx = 0;
25 char *buf;
26
27 buf = (char *) ADIOI_Malloc(1024);
28 if (buf != NULL) {
29 idx += ADIOI_Snprintf(buf, 1023, "%s (line %d): ", fcname, line);
30 if (specific_msg == NULL) {
31 ADIOI_Snprintf(&buf[idx], 1023 - idx, "%s\n", generic_msg);
32 }
33 else {
34 va_start(Argp, specific_msg);
35 vsnprintf(&buf[idx], 1023 - idx, specific_msg, Argp);
36 va_end(Argp);
37 }
38 FPRINTF(stderr, "%s", buf);
39 ADIOI_Free(buf);
40 }
41
42 return error_class;
43 }
44
45 int MPIO_Err_return_file(MPI_File mpi_fh, int error_code)
46 {
47 ADIO_File adio_fh;
48
49 if (mpi_fh == MPI_FILE_NULL)
50 {
51 if (ADIOI_DFLT_ERR_HANDLER == MPI_ERRORS_ARE_FATAL ||
52 ADIOI_DFLT_ERR_HANDLER != MPI_ERRORS_RETURN)
53 {
54 MPI_Abort(MPI_COMM_WORLD, 1);
55 }
56 else
57 {
58 return error_code;
59 }
60 }
61
62 adio_fh = MPIO_File_resolve(mpi_fh);
63
64 if (adio_fh->err_handler == MPI_ERRORS_ARE_FATAL ||
65 adio_fh->err_handler != MPI_ERRORS_RETURN)
66 {
67 MPI_Abort(MPI_COMM_WORLD, 1);
68 }
69 else
70 {
71 return error_code;
72 }
73 }
74
75 int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code)
76 {
77 MPI_Errhandler errh;
78
79 MPI_Errhandler_get(mpi_comm, &errh);
80
81 if (errh == MPI_ERRORS_ARE_FATAL ||
82 errh != MPI_ERRORS_RETURN)
83 {
84 MPI_Abort(mpi_comm, 1);
85 }
86
87 return error_code;
88 }