File: error.c

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (127 lines) | stat: -rw-r--r-- 5,101 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *
 *   Copyright (C) 1997 University of Chicago.
 *   See COPYRIGHT notice in top-level directory.
 */

#include "adio.h"
#include "adio_extern.h"

/* NOTE: THIS FUNCTION IS DEPRECATED AND ONLY EXISTS HERE BECAUSE
 * SOME DEPRECATED ADIO IMPLEMENTATIONS STILL CALL IT (SFS, HFS, PIOFS).
 */
int ADIOI_Error(ADIO_File fd, int error_code, char *string)
{
    char buf[MPI_MAX_ERROR_STRING];
    int myrank, result_len;
    MPI_Errhandler err_handler;

    if (fd == ADIO_FILE_NULL) err_handler = ADIOI_DFLT_ERR_HANDLER;
    else err_handler = fd->err_handler;

    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
    if (err_handler == MPI_ERRORS_ARE_FATAL) {
	MPI_Error_string(error_code, buf, &result_len);
	FPRINTF(stderr, "[%d] - %s : %s\n", myrank, string, buf);
	MPI_Abort(MPI_COMM_WORLD, 1);
    }
    else if (err_handler != MPI_ERRORS_RETURN) {
	/* MPI_File_call_errorhandler(fd, error_code); */

	FPRINTF(stderr, "Only MPI_ERRORS_RETURN and MPI_ERRORS_ARE_FATAL are currently supported as error handlers for files\n");
	MPI_Abort(MPI_COMM_WORLD, 1);
    }

    return error_code;
}
/* Check for special error codes for those MPI error
   classes that relate to particular problems.
   Returns an MPI error code corresponding to "my_errno", for function "myname"
 * and the given file, "filename".  */
int ADIOI_Err_create_code(const char *myname, const char *filename, int my_errno)
{
    int error_code = MPI_SUCCESS;
    if(!my_errno) return MPI_SUCCESS;

    /* --BEGIN ERROR HANDLING-- */
    switch(my_errno) {
        case EACCES:
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE, myname,
                                              __LINE__, MPI_ERR_ACCESS,
                                              "**fileaccess",
                                              "**fileaccess %s",
                                              filename );
            break;
        case ENAMETOOLONG:
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE, myname,
                                              __LINE__, MPI_ERR_BAD_FILE,
                                              "**filenamelong",
                                              "**filenamelong %s %d",
                                              filename,
                                              strlen(filename));
            break;
        case ENOENT:
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE, myname,
                                              __LINE__, MPI_ERR_NO_SUCH_FILE,
                                              "**filenoexist",
                                              "**filenoexist %s",
                                              filename);
            break;
        case EISDIR:
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE,
                                              myname, __LINE__,
                                              MPI_ERR_BAD_FILE,
                                              "**filenamedir",
                                              "**filenamedir %s",
                                              filename);
            break;
        case EROFS:
	    /* Read only file or file system and write access requested */
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE, myname,
                                              __LINE__, MPI_ERR_READ_ONLY,
                                              "**ioneedrd", 0 );
            break;
        case EEXIST:
            error_code = MPIO_Err_create_code(MPI_SUCCESS,
                                              MPIR_ERR_RECOVERABLE, myname,
                                              __LINE__, MPI_ERR_FILE_EXISTS,
                                              "**fileexist", 0);
            break;
	case ENOTDIR:
	case ELOOP:
	    error_code = MPIO_Err_create_code(MPI_SUCCESS,
					       MPIR_ERR_RECOVERABLE,
					       myname, __LINE__,
					       MPI_ERR_BAD_FILE,
					       "**filenamedir",
					       "**filenamedir %s",
					       filename);
            break;
	case ENOSPC:
	    error_code = MPIO_Err_create_code(MPI_SUCCESS,
		    MPIR_ERR_RECOVERABLE, myname, __LINE__,
		    MPI_ERR_NO_SPACE,
		    "**filenospace", 0);
	    break;
	case EDQUOT:
	    error_code = MPIO_Err_create_code(MPI_SUCCESS,
		    MPIR_ERR_RECOVERABLE, myname, __LINE__,
		    MPI_ERR_QUOTA,
		    "**filequota", 0);

        default:
            error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
                                              myname, __LINE__, MPI_ERR_IO, "**io",
                                              "**io %s", strerror(my_errno));
            break;
    }
    /* --END ERROR HANDLING-- */

    return error_code;
}