Blame src/mpi/romio/mpi-io/mpir-mpioinit.c

Packit Service c5cf8c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *  (C) 2009 UChicago/Argonne LLC
Packit Service c5cf8c
 *      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
 */
Packit Service c5cf8c
#include "mpioimpl.h"
Packit Service c5cf8c
#include <string.h>
Packit Service c5cf8c
Packit Service c5cf8c
#ifdef HAVE_WEAK_SYMBOLS
Packit Service c5cf8c
/* Include mapping from MPI->PMPI */
Packit Service c5cf8c
#define MPIO_BUILD_PROFILING
Packit Service c5cf8c
#include "mpioprof.h"
Packit Service c5cf8c
#endif
Packit Service c5cf8c
Packit Service c5cf8c
extern int ADIO_Init_keyval;
Packit Service c5cf8c
Packit Service c5cf8c
/* common code to stuff an attribute on a communicator for the purpose of
Packit Service c5cf8c
 * cleaning up in MPI_Finalize() */
Packit Service c5cf8c
Packit Service c5cf8c
void MPIR_MPIOInit(int *error_code)
Packit Service c5cf8c
{
Packit Service c5cf8c
Packit Service c5cf8c
    int flag;
Packit Service c5cf8c
    char myname[] = "MPIR_MPIOInit";
Packit Service c5cf8c
Packit Service c5cf8c
    /* first check if ADIO has been initialized. If not, initialize it */
Packit Service c5cf8c
    if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) {
Packit Service c5cf8c
        MPI_Initialized(&flag;;
Packit Service c5cf8c
Packit Service c5cf8c
        /* --BEGIN ERROR HANDLING-- */
Packit Service c5cf8c
        if (!flag) {
Packit Service c5cf8c
            *error_code = MPIO_Err_create_code(MPI_SUCCESS,
Packit Service c5cf8c
                                               MPIR_ERR_RECOVERABLE, myname, __LINE__,
Packit Service c5cf8c
                                               MPI_ERR_OTHER, "**initialized", 0);
Packit Service c5cf8c
            *error_code = MPIO_Err_return_file(MPI_FILE_NULL, *error_code);
Packit Service c5cf8c
            return;
Packit Service c5cf8c
        }
Packit Service c5cf8c
        /* --END ERROR HANDLING-- */
Packit Service c5cf8c
Packit Service c5cf8c
        MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval, (void *) 0);
Packit Service c5cf8c
Packit Service c5cf8c
        /* put a dummy attribute on MPI_COMM_SELF, because we want the delete
Packit Service c5cf8c
         * function to be called when MPI_COMM_SELF is freed. Clarified
Packit Service c5cf8c
         * in MPI-2 section 4.8, the standard mandates that attributes on
Packit Service c5cf8c
         * MPI_COMM_SELF get cleaned up early in MPI_Finalize */
Packit Service c5cf8c
Packit Service c5cf8c
        MPI_Attr_put(MPI_COMM_SELF, ADIO_Init_keyval, (void *) 0);
Packit Service c5cf8c
Packit Service c5cf8c
        /* initialize ADIO */
Packit Service c5cf8c
        ADIO_Init((int *) 0, (char ***) 0, error_code);
Packit Service c5cf8c
    }
Packit Service c5cf8c
    *error_code = MPI_SUCCESS;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
/*
Packit Service c5cf8c
 * vim: ts=8 sts=4 sw=4 noexpandtab
Packit Service c5cf8c
 */