AMPI #952: update ROMIO to MPICH2-1.4.1p1
[charm.git] / src / libs / ck-libs / ampi / romio / mpi-io / get_errh.c
blobd26f7816dc8f502e4b47406ff97385b8554c71b2
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
4 * Copyright (C) 1997 University of Chicago.
5 * See COPYRIGHT notice in top-level directory.
6 */
8 #include "mpioimpl.h"
9 #include "adio_extern.h"
11 #ifdef HAVE_WEAK_SYMBOLS
13 #if defined(HAVE_PRAGMA_WEAK)
14 #pragma weak MPI_File_get_errhandler = PMPI_File_get_errhandler
15 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
16 #pragma _HP_SECONDARY_DEF PMPI_File_get_errhandler MPI_File_get_errhandler
17 #elif defined(HAVE_PRAGMA_CRI_DUP)
18 #pragma _CRI duplicate MPI_File_get_errhandler as PMPI_File_get_errhandler
19 /* end of weak pragmas */
20 #endif
22 /* Include mapping from MPI->PMPI */
23 #define MPIO_BUILD_PROFILING
24 #include "mpioprof.h"
25 #endif
27 /*@
28 MPI_File_get_errhandler - Returns the error handler for a file
30 Input Parameters:
31 . fh - file handle (handle)
33 Output Parameters:
34 . errhandler - error handler (handle)
36 .N fortran
37 @*/
38 int MPI_File_get_errhandler(MPI_File mpi_fh, MPI_Errhandler *errhandler)
40 int error_code = MPI_SUCCESS;
41 ADIO_File fh;
42 static char myname[] = "MPI_FILE_GET_ERRHANDLER";
43 MPIU_THREADPRIV_DECL;
45 MPIU_THREAD_CS_ENTER(ALLFUNC,);
47 if (mpi_fh == MPI_FILE_NULL) {
48 *errhandler = CtvAccess(ADIOI_DFLT_ERR_HANDLER);
50 else {
51 fh = MPIO_File_resolve(mpi_fh);
52 /* --BEGIN ERROR HANDLING-- */
53 if ((fh <= (MPI_File) 0) || ((fh)->cookie != ADIOI_FILE_COOKIE))
55 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
56 myname, __LINE__, MPI_ERR_ARG,
57 "**iobadfh", 0);
58 error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);
59 goto fn_exit;
61 /* --END ERROR HANDLING-- */
63 *errhandler = fh->err_handler;
66 fn_exit:
67 MPIU_THREAD_CS_EXIT(ALLFUNC,);
68 return MPI_SUCCESS;