File: mpio_err.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (76 lines) | stat: -rw-r--r-- 1,956 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

#include "mpioimpl.h"
#include "adio_extern.h"

#include <stdarg.h>
#include <stdio.h>

/* Default error handling implementation.
 *
 * Note that only MPI_ERRORS_ARE_FATAL and MPI_ERRORS_RETURN are
 * handled correctly; other handlers cause an abort.
 */

int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
                         int line, int error_class, const char generic_msg[],
                         const char specific_msg[], ...)
{
    va_list Argp;
    int idx = 0;
    char *buf;

    buf = (char *) ADIOI_Malloc(1024);
    if (buf != NULL) {
        idx += MPL_snprintf(buf, 1023, "%s (line %d): ", fcname, line);
        if (specific_msg == NULL) {
            MPL_snprintf(&buf[idx], 1023 - idx, "%s\n", generic_msg);
        } else {
            va_start(Argp, specific_msg);
            vsnprintf(&buf[idx], 1023 - idx, specific_msg, Argp);
            va_end(Argp);
        }
        FPRINTF(stderr, "%s", buf);
        ADIOI_Free(buf);
    }

    return error_class;
}

int MPIO_Err_return_file(MPI_File mpi_fh, int error_code)
{
    ADIO_File adio_fh;

    if (mpi_fh == MPI_FILE_NULL) {
        if (ADIOI_DFLT_ERR_HANDLER == MPI_ERRORS_ARE_FATAL ||
            ADIOI_DFLT_ERR_HANDLER != MPI_ERRORS_RETURN) {
            MPI_Abort(MPI_COMM_WORLD, 1);
        } else {
            return error_code;
        }
    }

    adio_fh = MPIO_File_resolve(mpi_fh);

    if (adio_fh->err_handler == MPI_ERRORS_ARE_FATAL || adio_fh->err_handler != MPI_ERRORS_RETURN) {
        MPI_Abort(MPI_COMM_WORLD, 1);
    } else {
        return error_code;
    }
}

int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code)
{
    MPI_Errhandler errh;

    MPI_Comm_get_errhandler(mpi_comm, &errh);

    if (errh == MPI_ERRORS_ARE_FATAL || errh != MPI_ERRORS_RETURN) {
        MPI_Abort(mpi_comm, 1);
    }

    return error_code;
}