root/ompi/mca/io/romio321/romio/mpi-io/glue/default/mpio_err.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPIO_Err_create_code
  2. MPIO_Err_return_file
  3. MPIO_Err_return_comm

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *   Copyright (C) 2004 University of Chicago. 
   4  *   See COPYRIGHT notice in top-level directory.
   5  */
   6 
   7 #include "mpioimpl.h"
   8 #include "adio_extern.h"
   9 
  10 #include <stdarg.h>
  11 #include <stdio.h>
  12 
  13 /* Default error handling implementation.
  14  *
  15  * Note that only MPI_ERRORS_ARE_FATAL and MPI_ERRORS_RETURN are
  16  * handled correctly; other handlers cause an abort.
  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 }

/* [<][>][^][v][top][bottom][index][help] */