1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2015-2017 Research Organization for Information Science
14 * and Technology (RIST). All rights reserved.
15 * $COPYRIGHT$
16 *
17 * Additional copyrights may follow
18 *
19 * $HEADER$
20 */
21
22 #include "ompi_config.h"
23
24 #include "ompi/mpi/fortran/mpif-h/bindings.h"
25 #include "ompi/communicator/communicator.h"
26
27 #if OMPI_BUILD_MPI_PROFILING
28 #if OPAL_HAVE_WEAK_SYMBOLS
29 #pragma weak PMPI_KEYVAL_CREATE = ompi_keyval_create_f
30 #pragma weak pmpi_keyval_create = ompi_keyval_create_f
31 #pragma weak pmpi_keyval_create_ = ompi_keyval_create_f
32 #pragma weak pmpi_keyval_create__ = ompi_keyval_create_f
33
34 #pragma weak PMPI_Keyval_create_f = ompi_keyval_create_f
35 #pragma weak PMPI_Keyval_create_f08 = ompi_keyval_create_f
36 #else
37 OMPI_GENERATE_F77_BINDINGS (PMPI_KEYVAL_CREATE,
38 pmpi_keyval_create,
39 pmpi_keyval_create_,
40 pmpi_keyval_create__,
41 pompi_keyval_create_f,
42 (ompi_fint_copy_attr_function* copy_fn, ompi_fint_delete_attr_function* delete_fn, MPI_Fint *keyval, MPI_Fint *extra_state, MPI_Fint *ierr),
43 (copy_fn, delete_fn, keyval, extra_state, ierr) )
44 #endif
45 #endif
46
47 #if OPAL_HAVE_WEAK_SYMBOLS
48 #pragma weak MPI_KEYVAL_CREATE = ompi_keyval_create_f
49 #pragma weak mpi_keyval_create = ompi_keyval_create_f
50 #pragma weak mpi_keyval_create_ = ompi_keyval_create_f
51 #pragma weak mpi_keyval_create__ = ompi_keyval_create_f
52
53 #pragma weak MPI_Keyval_create_f = ompi_keyval_create_f
54 #pragma weak MPI_Keyval_create_f08 = ompi_keyval_create_f
55 #else
56 #if ! OMPI_BUILD_MPI_PROFILING
57 OMPI_GENERATE_F77_BINDINGS (MPI_KEYVAL_CREATE,
58 mpi_keyval_create,
59 mpi_keyval_create_,
60 mpi_keyval_create__,
61 ompi_keyval_create_f,
62 (ompi_fint_copy_attr_function* copy_fn, ompi_fint_delete_attr_function* delete_fn, MPI_Fint *keyval, MPI_Fint *extra_state, MPI_Fint *ierr),
63 (copy_fn, delete_fn, keyval, extra_state, ierr) )
64 #else
65 #define ompi_keyval_create_f pompi_keyval_create_f
66 #endif
67 #endif
68
69 static const char FUNC_NAME[] = "MPI_keyval_create_f";
70
ompi_keyval_create_f(ompi_fint_copy_attr_function * copy_attr_fn,ompi_fint_delete_attr_function * delete_attr_fn,MPI_Fint * keyval,MPI_Fint * extra_state,MPI_Fint * ierr)71 void ompi_keyval_create_f(ompi_fint_copy_attr_function* copy_attr_fn,
72 ompi_fint_delete_attr_function* delete_attr_fn,
73 MPI_Fint *keyval, MPI_Fint *extra_state,
74 MPI_Fint *ierr)
75 {
76 int ret, c_ierr;
77 OMPI_SINGLE_NAME_DECL(keyval);
78 ompi_attribute_fn_ptr_union_t copy_fn;
79 ompi_attribute_fn_ptr_union_t del_fn;
80
81 copy_fn.attr_fint_copy_fn = copy_attr_fn;
82 del_fn.attr_fint_delete_fn = delete_attr_fn;
83
84 /* Set the "F77_OLD" bit to denote that the callbacks should use
85 the old MPI-1 INTEGER-parameter functions (as opposed to the
86 new MPI-2 INTEGER(KIND=MPI_ADDRESS_KIND)-parameter
87 functions). */
88
89 ret = ompi_attr_create_keyval_fint(COMM_ATTR, copy_fn, del_fn,
90 OMPI_SINGLE_NAME_CONVERT(keyval), *extra_state,
91 OMPI_KEYVAL_F77,
92 NULL);
93
94 if (MPI_SUCCESS != ret) {
95 c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
96 MPI_ERR_OTHER,
97 FUNC_NAME);
98 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
99 } else {
100 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
101 OMPI_SINGLE_INT_2_FINT(keyval);
102 }
103 }
104