00001 
00002 
00003 
00004 
00005 
00006 
00007 #include <stdarg.h>
00008 #include <stdio.h>
00009 
00010 #include "mpioimpl.h"
00011 #include "adio_extern.h"
00012 
00013 
00014 
00015 
00016 int MPIR_Err_create_code_valist(int, int, const char [], int, int, 
00017                 const char [], const char [], va_list );
00018 int MPIR_Err_is_fatal(int);
00019 
00020 void MPIR_Get_file_error_routine( MPI_Errhandler, 
00021                   void (**)(MPI_File *, int *, ...), 
00022                   int * );
00023 int MPIR_File_call_cxx_errhandler( MPI_File *, int *, 
00024                    void (*)(MPI_File *, int *, ... ) );
00025 
00026 int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
00027              int line, int error_class, const char generic_msg[],
00028              const char specific_msg[], ... )
00029 {
00030     va_list Argp;
00031     int error_code;
00032 
00033     va_start(Argp, specific_msg);
00034 
00035     error_code = MPIR_Err_create_code_valist(lastcode, fatal, fcname, line,
00036                          error_class, generic_msg,
00037                          specific_msg, Argp);
00038     
00039     va_end(Argp);
00040 
00041     return error_code;
00042 }
00043 
00044 int MPIO_Err_return_file(MPI_File mpi_fh, int error_code)
00045 {
00046     MPI_Errhandler e;
00047     void (*c_errhandler)(MPI_File *, int *, ... );
00048     int  kind;   
00049     char error_msg[4096];
00050     int len;
00051 
00052     
00053 
00054 
00055 
00056 
00057 
00058     
00059     if (mpi_fh == MPI_FILE_NULL) {
00060     e = ADIOI_DFLT_ERR_HANDLER;
00061     }
00062     else {
00063     ADIO_File fh;
00064 
00065     fh = MPIO_File_resolve(mpi_fh);
00066     e = fh->err_handler;
00067     }
00068 
00069     
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077     if (e == MPI_ERRORS_RETURN || e == MPIR_ERRORS_THROW_EXCEPTIONS || !e) {
00078     
00079     kind = 1;
00080     c_errhandler = 0;
00081     }
00082     else {
00083     MPIR_Get_file_error_routine( e, &c_errhandler, &kind );
00084     }
00085 
00086     
00087     if (MPIR_Err_is_fatal(error_code) || kind == 0) 
00088     {
00089     ADIOI_Snprintf(error_msg, 4096, "I/O error: ");
00090     len = (int)strlen(error_msg);
00091     MPIR_Err_get_string(error_code, &error_msg[len], 4096-len, NULL);
00092     MPID_Abort(NULL, MPI_SUCCESS, error_code, error_msg);
00093     }
00094     
00095     else if (kind == 2) {
00096     (*c_errhandler)( &mpi_fh, &error_code, 0 ); 
00097     }
00098     else if (kind == 3) {
00099     MPIR_File_call_cxx_errhandler( &mpi_fh, &error_code, c_errhandler );
00100     }
00101 
00102     
00103     return error_code;
00104 }
00105 
00106 int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code)
00107 {
00108     
00109 
00110 
00111     MPI_Comm_call_errhandler(mpi_comm, error_code);
00112     return error_code;
00113 }