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) 2006-2012 Cisco Systems, Inc.  All rights reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  */
19 
20 #include "ompi_config.h"
21 
22 #include "ompi/mpi/fortran/mpif-h/bindings.h"
23 #include "ompi/mpi/fortran/base/fint_2_int.h"
24 
25 #if OPAL_HAVE_WEAK_SYMBOLS
26 #pragma weak MPI_TYPE_NULL_COPY_FN   = ompi_type_null_copy_fn_f
27 #pragma weak mpi_type_null_copy_fn   = ompi_type_null_copy_fn_f
28 #pragma weak mpi_type_null_copy_fn_  = ompi_type_null_copy_fn_f
29 #pragma weak mpi_type_null_copy_fn__ = ompi_type_null_copy_fn_f
30 
31 #pragma weak MPI_TYPE_NULL_DELETE_FN   = ompi_type_null_delete_fn_f
32 #pragma weak mpi_type_null_delete_fn   = ompi_type_null_delete_fn_f
33 #pragma weak mpi_type_null_delete_fn_  = ompi_type_null_delete_fn_f
34 #pragma weak mpi_type_null_delete_fn__ = ompi_type_null_delete_fn_f
35 
36 #pragma weak MPI_TYPE_DUP_FN   = ompi_type_dup_fn_f
37 #pragma weak mpi_type_dup_fn   = ompi_type_dup_fn_f
38 #pragma weak mpi_type_dup_fn_  = ompi_type_dup_fn_f
39 #pragma weak mpi_type_dup_fn__ = ompi_type_dup_fn_f
40 
41 #pragma weak MPI_COMM_NULL_DELETE_FN   = ompi_comm_null_delete_fn_f
42 #pragma weak mpi_comm_null_delete_fn   = ompi_comm_null_delete_fn_f
43 #pragma weak mpi_comm_null_delete_fn_  = ompi_comm_null_delete_fn_f
44 #pragma weak mpi_comm_null_delete_fn__ = ompi_comm_null_delete_fn_f
45 
46 #pragma weak MPI_COMM_DUP_FN   = ompi_comm_dup_fn_f
47 #pragma weak mpi_comm_dup_fn   = ompi_comm_dup_fn_f
48 #pragma weak mpi_comm_dup_fn_  = ompi_comm_dup_fn_f
49 #pragma weak mpi_comm_dup_fn__ = ompi_comm_dup_fn_f
50 
51 #pragma weak MPI_COMM_NULL_COPY_FN   = ompi_comm_null_copy_fn_f
52 #pragma weak mpi_comm_null_copy_fn   = ompi_comm_null_copy_fn_f
53 #pragma weak mpi_comm_null_copy_fn_  = ompi_comm_null_copy_fn_f
54 #pragma weak mpi_comm_null_copy_fn__ = ompi_comm_null_copy_fn_f
55 
56 #pragma weak MPI_WIN_NULL_DELETE_FN   = ompi_win_null_delete_fn_f
57 #pragma weak mpi_win_null_delete_fn   = ompi_win_null_delete_fn_f
58 #pragma weak mpi_win_null_delete_fn_  = ompi_win_null_delete_fn_f
59 #pragma weak mpi_win_null_delete_fn__ = ompi_win_null_delete_fn_f
60 
61 #pragma weak MPI_WIN_NULL_COPY_FN   = ompi_win_null_copy_fn_f
62 #pragma weak mpi_win_null_copy_fn   = ompi_win_null_copy_fn_f
63 #pragma weak mpi_win_null_copy_fn_  = ompi_win_null_copy_fn_f
64 #pragma weak mpi_win_null_copy_fn__ = ompi_win_null_copy_fn_f
65 
66 #pragma weak MPI_WIN_DUP_FN   = ompi_win_dup_fn_f
67 #pragma weak mpi_win_dup_fn   = ompi_win_dup_fn_f
68 #pragma weak mpi_win_dup_fn_  = ompi_win_dup_fn_f
69 #pragma weak mpi_win_dup_fn__ = ompi_win_dup_fn_f
70 
71 #pragma weak MPI_NULL_COPY_FN   = ompi_null_copy_fn_f
72 #pragma weak mpi_null_copy_fn   = ompi_null_copy_fn_f
73 #pragma weak mpi_null_copy_fn_  = ompi_null_copy_fn_f
74 #pragma weak mpi_null_copy_fn__ = ompi_null_copy_fn_f
75 
76 #pragma weak MPI_NULL_DELETE_FN   = ompi_null_delete_fn_f
77 #pragma weak mpi_null_delete_fn   = ompi_null_delete_fn_f
78 #pragma weak mpi_null_delete_fn_  = ompi_null_delete_fn_f
79 #pragma weak mpi_null_delete_fn__ = ompi_null_delete_fn_f
80 
81 #pragma weak MPI_DUP_FN   = ompi_dup_fn_f
82 #pragma weak mpi_dup_fn   = ompi_dup_fn_f
83 #pragma weak mpi_dup_fn_  = ompi_dup_fn_f
84 #pragma weak mpi_dup_fn__ = ompi_dup_fn_f
85 
86 #else
87 OMPI_GENERATE_F77_BINDINGS( MPI_TYPE_NULL_DELETE_FN,
88                             mpi_type_null_delete_fn,
89                             mpi_type_null_delete_fn_,
90                             mpi_type_null_delete_fn__,
91                             ompi_type_null_delete_fn_f,
92                             (MPI_Fint* type, MPI_Fint* type_keyval, MPI_Aint* attribute_val_out, MPI_Aint* extra_state, MPI_Fint* ierr),
93                             (type, type_keyval, attribute_val_out, extra_state, ierr) )
94 OMPI_GENERATE_F77_BINDINGS( MPI_TYPE_NULL_COPY_FN,
95                             mpi_type_null_copy_fn,
96                             mpi_type_null_copy_fn_,
97                             mpi_type_null_copy_fn__,
98                             ompi_type_null_copy_fn_f,
99                             (MPI_Fint* type, MPI_Fint* type_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
100                             (type, type_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
101 OMPI_GENERATE_F77_BINDINGS( MPI_TYPE_DUP_FN,
102                             mpi_type_dup_fn,
103                             mpi_type_dup_fn_,
104                             mpi_type_dup_fn__,
105                             ompi_type_dup_fn_f,
106                             (MPI_Fint* type, MPI_Fint* type_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
107                             (type, type_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
108 OMPI_GENERATE_F77_BINDINGS( MPI_COMM_NULL_DELETE_FN,
109                             mpi_comm_null_delete_fn,
110                             mpi_comm_null_delete_fn_,
111                             mpi_comm_null_delete_fn__,
112                             ompi_comm_null_delete_fn_f,
113                             (MPI_Fint* comm, MPI_Fint* comm_keyval,MPI_Aint* attribute_val_out, MPI_Aint* extra_state, MPI_Fint* ierr ),
114                             (comm, comm_keyval, attribute_val_out, extra_state, ierr) )
115 OMPI_GENERATE_F77_BINDINGS( MPI_COMM_NULL_COPY_FN,
116                             mpi_comm_null_copy_fn,
117                             mpi_comm_null_copy_fn_,
118                             mpi_comm_null_copy_fn__,
119                             ompi_comm_null_copy_fn_f,
120                             (MPI_Fint* comm, MPI_Fint* comm_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
121                             (comm, comm_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
122 OMPI_GENERATE_F77_BINDINGS( MPI_COMM_DUP_FN,
123                             mpi_comm_dup_fn,
124                             mpi_comm_dup_fn_,
125                             mpi_comm_dup_fn__,
126                             ompi_comm_dup_fn_f,
127                             (MPI_Fint* comm, MPI_Fint* comm_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
128                             (comm, comm_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
129 OMPI_GENERATE_F77_BINDINGS( MPI_NULL_DELETE_FN,
130                             mpi_null_delete_fn,
131                             mpi_null_delete_fn_,
132                             mpi_null_delete_fn__,
133                             ompi_null_delete_fn_f,
134                             (MPI_Fint* comm, MPI_Fint* comm_keyval,MPI_Fint* attribute_val_out, MPI_Fint* extra_state, MPI_Fint* ierr ),
135                             (comm, comm_keyval, attribute_val_out, extra_state, ierr) )
136 OMPI_GENERATE_F77_BINDINGS( MPI_NULL_COPY_FN,
137                             mpi_null_copy_fn,
138                             mpi_null_copy_fn_,
139                             mpi_null_copy_fn__,
140                             ompi_null_copy_fn_f,
141                             (MPI_Fint* comm, MPI_Fint* comm_keyval, MPI_Fint* extra_state, MPI_Fint* attribute_val_in, MPI_Fint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
142                             (comm, comm_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
143 OMPI_GENERATE_F77_BINDINGS( MPI_DUP_FN,
144                             mpi_dup_fn,
145                             mpi_dup_fn_,
146                             mpi_dup_fn__,
147                             ompi_dup_fn_f,
148                             (MPI_Fint* comm, MPI_Fint* comm_keyval, MPI_Fint* extra_state, MPI_Fint* attribute_val_in, MPI_Fint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
149                             (comm, comm_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
150 
151 OMPI_GENERATE_F77_BINDINGS( MPI_WIN_NULL_DELETE_FN,
152                             mpi_win_null_delete_fn,
153                             mpi_win_null_delete_fn_,
154                             mpi_win_null_delete_fn__,
155                             ompi_win_null_delete_fn_f,
156                             (MPI_Fint* type, MPI_Fint* type_keyval,MPI_Aint* attribute_val_out, MPI_Aint* extra_state, MPI_Fint* ierr ),
157                             (type, type_keyval, attribute_val_out, extra_state, ierr) )
158 OMPI_GENERATE_F77_BINDINGS( MPI_WIN_NULL_COPY_FN,
159                             mpi_win_null_copy_fn,
160                             mpi_win_null_copy_fn_,
161                             mpi_win_null_copy_fn__,
162                             ompi_win_null_copy_fn_f,
163                             (MPI_Fint* window, MPI_Fint* win_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
164                             (window, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
165 OMPI_GENERATE_F77_BINDINGS( MPI_WIN_DUP_FN,
166                             mpi_win_dup_fn,
167                             mpi_win_dup_fn_,
168                             mpi_win_dup_fn__,
169                             ompi_win_dup_fn_f,
170                             (MPI_Fint* window, MPI_Fint* win_keyval, MPI_Aint* extra_state, MPI_Aint* attribute_val_in, MPI_Aint* attribute_val_out, ompi_fortran_logical_t* flag, MPI_Fint* ierr),
171                             (window, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
172 #endif
173 
174 /*
175  * Note that in this file, we invoke OMPI_C_<function> rather than
176  * <function>, where <function> is MPI_DUP_FN (and all the rest).
177  * Specifically:
178  *
179  *   MPI_NULL_DELETE_FN -> OMPI_C_MPI_NULL_DELETE_FN
180  *   MPI_NULL_COPY_FN -> OMPI_C_MPI_NULL_COPY_FN
181  *   MPI_DUP_FN -> OMPI_C_MPI_DUP_FN
182  *
183  *   MPI_TYPE_NULL_DELETE_FN -> OMPI_C_MPI_TYPE_NULL_DELETE_FN
184  *   MPI_TYPE_NULL_COPY_FN -> OMPI_C_MPI_TYPE_NULL_COPY_FN
185  *   MPI_TYPE_DUP_FN -> OMPI_C_MPI_TYPE_DUP_FN
186  *
187  *   MPI_COMM_NULL_DELETE_FN -> OMPI_C_MPI_COMM_NULL_DELETE_FN
188  *   MPI_COMM_NULL_COPY_FN -> OMPI_C_MPI_COMM_NULL_COPY_FN
189  *   MPI_COMM_DUP_FN -> OMPI_C_MPI_COMM_DUP_FN
190  *
191  *   MPI_WIN_NULL_DELETE_FN -> OMPI_C_MPI_WIN_NULL_DELETE_FN
192  *   MPI_WIN_NULL_COPY_FN -> OMPI_C_MPI_WIN_NULL_COPY_FN
193  *   MPI_WIN_DUP_FN -> OMPI_C_MPI_WIN_DUP_FN
194  *
195  * The reason why is discussed in a lengthy comment in mpi.h.
196  */
ompi_type_null_delete_fn_f(MPI_Fint * type,MPI_Fint * type_keyval,MPI_Aint * attribute_val_out,MPI_Aint * extra_state,MPI_Fint * ierr)197 void ompi_type_null_delete_fn_f(MPI_Fint* type, MPI_Fint* type_keyval,
198                                 MPI_Aint* attribute_val_out,
199                                 MPI_Aint* extra_state, MPI_Fint* ierr)
200 {
201     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
202 }
203 
ompi_type_null_copy_fn_f(MPI_Fint * type,MPI_Fint * type_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)204 void ompi_type_null_copy_fn_f(MPI_Fint* type, MPI_Fint* type_keyval,
205                               MPI_Aint* extra_state,
206                               MPI_Aint* attribute_val_in,
207                               MPI_Aint* attribute_val_out,
208                               ompi_fortran_logical_t* flag, MPI_Fint* ierr)
209 {
210     *flag = (ompi_fortran_logical_t) 0;
211     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
212 }
213 
ompi_type_dup_fn_f(MPI_Fint * type,MPI_Fint * type_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)214 void ompi_type_dup_fn_f(MPI_Fint* type, MPI_Fint* type_keyval,
215                         MPI_Aint* extra_state,
216                         MPI_Aint* attribute_val_in,
217                         MPI_Aint* attribute_val_out,
218                         ompi_fortran_logical_t* flag, MPI_Fint* ierr )
219 {
220     *flag = (ompi_fortran_logical_t) 1;
221     *attribute_val_out = *attribute_val_in;
222     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
223 }
224 
ompi_comm_null_delete_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Aint * attribute_val_out,MPI_Aint * extra_state,MPI_Fint * ierr)225 void ompi_comm_null_delete_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
226                                 MPI_Aint* attribute_val_out,
227                                 MPI_Aint* extra_state, MPI_Fint* ierr)
228 {
229     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
230 }
231 
ompi_comm_null_copy_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)232 void ompi_comm_null_copy_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
233                               MPI_Aint* extra_state,
234                               MPI_Aint* attribute_val_in,
235                               MPI_Aint* attribute_val_out,
236                               ompi_fortran_logical_t* flag, MPI_Fint* ierr)
237 {
238     *flag = (ompi_fortran_logical_t) 0;
239     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
240 }
241 
ompi_comm_dup_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)242 void ompi_comm_dup_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
243                         MPI_Aint* extra_state,
244                         MPI_Aint* attribute_val_in,
245                         MPI_Aint* attribute_val_out,
246                         ompi_fortran_logical_t* flag, MPI_Fint* ierr)
247 {
248     *flag = (ompi_fortran_logical_t) 1;
249     *attribute_val_out = *attribute_val_in;
250     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
251 }
252 
ompi_null_delete_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Fint * attribute_val_out,MPI_Fint * extra_state,MPI_Fint * ierr)253 void ompi_null_delete_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
254                            MPI_Fint* attribute_val_out,
255                            MPI_Fint* extra_state, MPI_Fint* ierr)
256 {
257     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
258 }
259 
ompi_null_copy_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Fint * extra_state,MPI_Fint * attribute_val_in,MPI_Fint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)260 void ompi_null_copy_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
261                          MPI_Fint* extra_state,
262                          MPI_Fint* attribute_val_in,
263                          MPI_Fint* attribute_val_out,
264                          ompi_fortran_logical_t* flag, MPI_Fint* ierr)
265 {
266     *flag = (ompi_fortran_logical_t) 0;
267     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
268 }
269 
270 
ompi_dup_fn_f(MPI_Fint * comm,MPI_Fint * comm_keyval,MPI_Fint * extra_state,MPI_Fint * attribute_val_in,MPI_Fint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)271 void ompi_dup_fn_f(MPI_Fint* comm, MPI_Fint* comm_keyval,
272                    MPI_Fint* extra_state,
273                    MPI_Fint* attribute_val_in,
274                    MPI_Fint* attribute_val_out,
275                    ompi_fortran_logical_t* flag, MPI_Fint* ierr)
276 {
277     *flag = (ompi_fortran_logical_t) 1;
278     *attribute_val_out = *attribute_val_in;
279     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
280 }
281 
ompi_win_null_delete_fn_f(MPI_Fint * window,MPI_Fint * win_keyval,MPI_Aint * attribute_val_out,MPI_Aint * extra_state,MPI_Fint * ierr)282 void ompi_win_null_delete_fn_f(MPI_Fint* window, MPI_Fint* win_keyval,
283                                MPI_Aint* attribute_val_out,
284                                MPI_Aint* extra_state, MPI_Fint* ierr)
285 {
286     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
287 }
288 
ompi_win_null_copy_fn_f(MPI_Fint * window,MPI_Fint * win_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)289 void ompi_win_null_copy_fn_f(MPI_Fint* window, MPI_Fint* win_keyval,
290                              MPI_Aint* extra_state,
291                              MPI_Aint* attribute_val_in,
292                              MPI_Aint* attribute_val_out,
293                              ompi_fortran_logical_t* flag, MPI_Fint* ierr)
294 {
295     *flag = (ompi_fortran_logical_t) 0;
296     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
297 }
298 
ompi_win_dup_fn_f(MPI_Fint * window,MPI_Fint * win_keyval,MPI_Aint * extra_state,MPI_Aint * attribute_val_in,MPI_Aint * attribute_val_out,ompi_fortran_logical_t * flag,MPI_Fint * ierr)299 void ompi_win_dup_fn_f(MPI_Fint* window, MPI_Fint* win_keyval,
300                        MPI_Aint* extra_state,
301                        MPI_Aint* attribute_val_in,
302                        MPI_Aint* attribute_val_out,
303                        ompi_fortran_logical_t* flag, MPI_Fint* ierr)
304 {
305     *flag = (ompi_fortran_logical_t) 1;
306     *attribute_val_out = *attribute_val_in;
307     *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
308 }
309