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 Sun Microsystems, Inc. All rights reserved.
13 * Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved.
14 * Copyright (c) 2015 Research Organization for Information Science
15 * and Technology (RIST). All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22
23 #include "ompi_config.h"
24
25 #include "mpi.h"
26 #include "ompi/mpi/fortran/base/fint_2_int.h"
27
28 /*
29 * This function implemented in this file is only called from Fortran,
30 * so we never bothered to put a prototype for it in any C header
31 * file. To avoid compiler warnings about no protoype, we prototype
32 * it here.
33 */
34 OMPI_DECLSPEC void ompi_buffer_detach_f08(char *buffer, MPI_Fint *size,
35 MPI_Fint *ierr);
36
37 OMPI_DECLSPEC void pompi_buffer_detach_f08(char *buffer, MPI_Fint *size,
38 MPI_Fint *ierr);
39
40 /* (this comment is repeated in ompi/mpi/fortran/mpif-h/buffer_detach_f.c)
41 *
42 * MPI-3.1 section 3.6, page 45, states that the mpif.h and mpi module
43 * interfaces for MPI_BUFFER_DETACH ignore the buffer argument.
44 * Therefore, for the mpif.h and mpi module interfaces, we use a dummy
45 * variable and leave the value handed in alone.
46 *
47 * The mpi_f08 implementation for MPI_BUFFER_DETACH therefore is a
48 * separate routine in the use-mpi-f08 directory (it's not built in
49 * the mpif-h directory because of all the different combinations of
50 * supporting weak symbols (or not), building the profiling layer (or
51 * not), etc.).
52 *
53 * Note that we only need to build this function once -- the F08
54 * interfaces for MPI_BUFFER_ATTACH and PMPI_BUFFER_ATTACH both
55 * bind(C) to the name ompi_buffer_detach_f08.
56 */
57 void ompi_buffer_detach_f08(char *buffer, MPI_Fint *size, MPI_Fint *ierr)
58 {
59 int c_ierr;
60 void *dummy;
61 OMPI_SINGLE_NAME_DECL(size);
62
63 c_ierr = PMPI_Buffer_detach(&dummy, OMPI_SINGLE_NAME_CONVERT(size));
64 if (NULL != ierr) {
65 *ierr = OMPI_INT_2_FINT(c_ierr);
66 }
67
68 if (MPI_SUCCESS == c_ierr) {
69 OMPI_SINGLE_INT_2_FINT(size);
70 *(void **)buffer = dummy;
71 }
72 }
73
74 void pompi_buffer_detach_f08(char *buffer, MPI_Fint *size, MPI_Fint *ierr)
75 {
76 ompi_buffer_detach_f08(buffer, size, ierr);
77 }