1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2005 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2005 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2013 Los Alamos National Security, LLC. All rights
14 * reserved.
15 * Copyright (c) 2015 Research Organization for Information Science
16 * and Technology (RIST). All rights reserved.
17 * $COPYRIGHT$
18 *
19 * Additional copyrights may follow
20 *
21 * $HEADER$
22 */
23
24 #include "ompi_config.h"
25 #include <stdio.h>
26
27 #include "ompi/mpi/c/bindings.h"
28 #include "ompi/runtime/params.h"
29 #include "ompi/errhandler/errhandler.h"
30 #include "ompi/mca/io/base/base.h"
31 #include "ompi/file/file.h"
32
33 #if OMPI_BUILD_MPI_PROFILING
34 #if OPAL_HAVE_WEAK_SYMBOLS
35 #pragma weak MPI_Register_datarep = PMPI_Register_datarep
36 #endif
37 #define MPI_Register_datarep PMPI_Register_datarep
38 #endif
39
40 static const char FUNC_NAME[] = "MPI_Register_datarep";
41
42
MPI_Register_datarep(const char * datarep,MPI_Datarep_conversion_function * read_conversion_fn,MPI_Datarep_conversion_function * write_conversion_fn,MPI_Datarep_extent_function * dtype_file_extent_fn,void * extra_state)43 int MPI_Register_datarep(const char *datarep,
44 MPI_Datarep_conversion_function *read_conversion_fn,
45 MPI_Datarep_conversion_function *write_conversion_fn,
46 MPI_Datarep_extent_function *dtype_file_extent_fn,
47 void *extra_state)
48 {
49 int rc;
50
51 if (MPI_PARAM_CHECK) {
52 rc = MPI_SUCCESS;
53 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
54 if (NULL == datarep) {
55 rc = MPI_ERR_ARG;
56 }
57 OMPI_ERRHANDLER_CHECK(rc, MPI_FILE_NULL, rc, FUNC_NAME);
58 }
59
60 /* The io framework is only initialized lazily. If it hasn't
61 already been initialized, do so now (note that MPI_FILE_OPEN
62 and MPI_FILE_DELETE are the only two places that it will be
63 initialized). */
64
65 if (OMPI_SUCCESS != (rc = mca_base_framework_open(&ompi_io_base_framework, 0))) {
66 return OMPI_ERRHANDLER_INVOKE(MPI_FILE_NULL, rc, FUNC_NAME);
67 }
68
69 OPAL_CR_ENTER_LIBRARY();
70
71 /* Call the back-end io component function */
72 rc = mca_io_base_register_datarep(datarep, read_conversion_fn,
73 write_conversion_fn,
74 dtype_file_extent_fn,
75 extra_state);
76
77
78 /* All done */
79
80 OMPI_ERRHANDLER_RETURN(rc, MPI_FILE_NULL, rc, FUNC_NAME);
81 }
82