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) 2011-2012 Cisco Systems, Inc.  All rights reserved.
13  * Copyright (c) 2015      Research Organization for Information Science
14  *                         and Technology (RIST). All rights reserved.
15  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
16  * $COPYRIGHT$
17  *
18  * Additional copyrights may follow
19  *
20  * $HEADER$
21  */
22 
23 #include "ompi_config.h"
24 
25 #include "ompi/mpi/fortran/mpif-h/bindings.h"
26 #include "ompi/mpi/fortran/base/constants.h"
27 
28 #if OMPI_BUILD_MPI_PROFILING
29 #if OPAL_HAVE_WEAK_SYMBOLS
30 #pragma weak PMPI_ISCATTER = ompi_iscatter_f
31 #pragma weak pmpi_iscatter = ompi_iscatter_f
32 #pragma weak pmpi_iscatter_ = ompi_iscatter_f
33 #pragma weak pmpi_iscatter__ = ompi_iscatter_f
34 
35 #pragma weak PMPI_Iscatter_f = ompi_iscatter_f
36 #pragma weak PMPI_Iscatter_f08 = ompi_iscatter_f
37 #else
38 OMPI_GENERATE_F77_BINDINGS (PMPI_ISCATTER,
39                             pmpi_iscatter,
40                             pmpi_iscatter_,
41                             pmpi_iscatter__,
42                             pompi_iscatter_f,
43                             (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
44                             (sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr) )
45 #endif
46 #endif
47 
48 #if OPAL_HAVE_WEAK_SYMBOLS
49 #pragma weak MPI_ISCATTER = ompi_iscatter_f
50 #pragma weak mpi_iscatter = ompi_iscatter_f
51 #pragma weak mpi_iscatter_ = ompi_iscatter_f
52 #pragma weak mpi_iscatter__ = ompi_iscatter_f
53 
54 #pragma weak MPI_Iscatter_f = ompi_iscatter_f
55 #pragma weak MPI_Iscatter_f08 = ompi_iscatter_f
56 #else
57 #if ! OMPI_BUILD_MPI_PROFILING
58 OMPI_GENERATE_F77_BINDINGS (MPI_ISCATTER,
59                             mpi_iscatter,
60                             mpi_iscatter_,
61                             mpi_iscatter__,
62                             ompi_iscatter_f,
63                             (char *sendbuf, MPI_Fint *sendcount, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
64                             (sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request, ierr) )
65 #else
66 #define ompi_iscatter_f pompi_iscatter_f
67 #endif
68 #endif
69 
70 
ompi_iscatter_f(char * sendbuf,MPI_Fint * sendcount,MPI_Fint * sendtype,char * recvbuf,MPI_Fint * recvcount,MPI_Fint * recvtype,MPI_Fint * root,MPI_Fint * comm,MPI_Fint * request,MPI_Fint * ierr)71 void ompi_iscatter_f(char *sendbuf, MPI_Fint *sendcount,
72                      MPI_Fint *sendtype, char *recvbuf,
73                      MPI_Fint *recvcount, MPI_Fint *recvtype,
74                      MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request,
75                      MPI_Fint *ierr)
76 {
77     int c_ierr;
78     MPI_Datatype c_sendtype, c_recvtype;
79     MPI_Request c_request;
80     MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
81 
82     c_sendtype = PMPI_Type_f2c(*sendtype);
83     c_recvtype = PMPI_Type_f2c(*recvtype);
84 
85     sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
86     recvbuf = (char *) OMPI_F2C_IN_PLACE(recvbuf);
87     recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
88 
89     c_ierr = PMPI_Iscatter(sendbuf,OMPI_FINT_2_INT(*sendcount),
90                           c_sendtype, recvbuf,
91                           OMPI_FINT_2_INT(*recvcount),
92                           c_recvtype,
93                           OMPI_FINT_2_INT(*root), c_comm, &c_request);
94     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
95     if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);
96 }
97