1 /*
2 * Copyright (c) 2011-2013 The University of Tennessee and The University
3 * of Tennessee Research Foundation. All rights
4 * reserved.
5 * Copyright (c) 2011-2013 Inria. All rights reserved.
6 * Copyright (c) 2011-2013 Université Bordeaux 1
7 * Copyright (c) 2015-2019 Research Organization for Information Science
8 * and Technology (RIST). All rights reserved.
9 * $COPYRIGHT$
10 *
11 * Additional copyrights may follow
12 *
13 * $HEADER$
14 */
15
16 #include "ompi_config.h"
17
18 #include "ompi/mpi/fortran/mpif-h/bindings.h"
19 #include "ompi/mpi/fortran/base/constants.h"
20
21 #if OMPI_BUILD_MPI_PROFILING
22 #if OPAL_HAVE_WEAK_SYMBOLS
23 #pragma weak PMPI_DIST_GRAPH_NEIGHBORS = ompi_dist_graph_neighbors_f
24 #pragma weak pmpi_dist_graph_neighbors = ompi_dist_graph_neighbors_f
25 #pragma weak pmpi_dist_graph_neighbors_ = ompi_dist_graph_neighbors_f
26 #pragma weak pmpi_dist_graph_neighbors__ = ompi_dist_graph_neighbors_f
27
28 #pragma weak PMPI_Dist_graph_neighbors_f = ompi_dist_graph_neighbors_f
29 #pragma weak PMPI_Dist_graph_neighbors_f08 = ompi_dist_graph_neighbors_f
30 #else
31 OMPI_GENERATE_F77_BINDINGS (PMPI_DIST_GRAPH_NEIGHBORS,
32 pmpi_dist_graph_neighbors,
33 pmpi_dist_graph_neighbors_,
34 pmpi_dist_graph_neighbors__,
35 pompi_dist_graph_neighbors_f,
36 (MPI_Fint* comm, MPI_Fint* maxindegree, MPI_Fint* sources, MPI_Fint* sourceweights, MPI_Fint* maxoutdegree, MPI_Fint* destinations, MPI_Fint* destweights, MPI_Fint *ierr),
37 (comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights, ierr) )
38 #endif
39 #endif
40
41 #if OPAL_HAVE_WEAK_SYMBOLS
42 #pragma weak MPI_DIST_GRAPH_NEIGHBORS = ompi_dist_graph_neighbors_f
43 #pragma weak mpi_dist_graph_neighbors = ompi_dist_graph_neighbors_f
44 #pragma weak mpi_dist_graph_neighbors_ = ompi_dist_graph_neighbors_f
45 #pragma weak mpi_dist_graph_neighbors__ = ompi_dist_graph_neighbors_f
46
47 #pragma weak MPI_Dist_graph_neighbors_f = ompi_dist_graph_neighbors_f
48 #pragma weak MPI_Dist_graph_neighbors_f08 = ompi_dist_graph_neighbors_f
49 #else
50 #if ! OMPI_BUILD_MPI_PROFILING
51 OMPI_GENERATE_F77_BINDINGS (MPI_DIST_GRAPH_NEIGHBORS,
52 mpi_dist_graph_neighbors,
53 mpi_dist_graph_neighbors_,
54 mpi_dist_graph_neighbors__,
55 ompi_dist_graph_neighbors_f,
56 (MPI_Fint* comm, MPI_Fint* maxindegree, MPI_Fint* sources, MPI_Fint* sourceweights, MPI_Fint* maxoutdegree, MPI_Fint* destinations, MPI_Fint* destweights, MPI_Fint *ierr),
57 (comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights, ierr) )
58 #endif
59
60 #if OMPI_BUILD_MPI_PROFILING && ! OPAL_HAVE_WEAK_SYMBOLS
61 #define ompi_dist_graph_neighbors_f pompi_dist_graph_neighbors_f
62 #endif
63 #endif
64
65
ompi_dist_graph_neighbors_f(MPI_Fint * comm,MPI_Fint * maxindegree,MPI_Fint * sources,MPI_Fint * sourceweights,MPI_Fint * maxoutdegree,MPI_Fint * destinations,MPI_Fint * destweights,MPI_Fint * ierr)66 void ompi_dist_graph_neighbors_f(MPI_Fint* comm, MPI_Fint* maxindegree,
67 MPI_Fint* sources, MPI_Fint* sourceweights,
68 MPI_Fint* maxoutdegree, MPI_Fint* destinations,
69 MPI_Fint* destweights,
70 MPI_Fint *ierr)
71 {
72 MPI_Comm c_comm;
73 OMPI_ARRAY_NAME_DECL(sources);
74 OMPI_ARRAY_NAME_DECL(sourceweights);
75 OMPI_ARRAY_NAME_DECL(destinations);
76 OMPI_ARRAY_NAME_DECL(destweights);
77 int c_ierr;
78
79 c_comm = PMPI_Comm_f2c(*comm);
80
81 OMPI_ARRAY_FINT_2_INT_ALLOC(sources, *maxindegree);
82 if( !OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ) {
83 OMPI_ARRAY_FINT_2_INT_ALLOC(sourceweights, *maxindegree);
84 }
85 OMPI_ARRAY_FINT_2_INT_ALLOC(destinations, *maxoutdegree);
86 if( !OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ) {
87 OMPI_ARRAY_FINT_2_INT_ALLOC(destweights, *maxoutdegree);
88 }
89
90 c_ierr = PMPI_Dist_graph_neighbors(c_comm, OMPI_FINT_2_INT(*maxindegree),
91 OMPI_ARRAY_NAME_CONVERT(sources),
92 OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(sourceweights),
93 OMPI_FINT_2_INT(*maxoutdegree), OMPI_ARRAY_NAME_CONVERT(destinations),
94 OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ? MPI_UNWEIGHTED : OMPI_ARRAY_NAME_CONVERT(destweights));
95 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
96
97 if (OMPI_SUCCESS == c_ierr) {
98 OMPI_ARRAY_INT_2_FINT(sources, *maxindegree);
99 if( !OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ) {
100 OMPI_ARRAY_INT_2_FINT(sourceweights, *maxindegree);
101 }
102 OMPI_ARRAY_INT_2_FINT(destinations, *maxoutdegree);
103 if( !OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ) {
104 OMPI_ARRAY_INT_2_FINT(destweights, *maxoutdegree);
105 }
106 } else {
107 OMPI_ARRAY_FINT_2_INT_CLEANUP(sources);
108 if( !OMPI_IS_FORTRAN_UNWEIGHTED(sourceweights) ) {
109 OMPI_ARRAY_FINT_2_INT_CLEANUP(sourceweights);
110 }
111 OMPI_ARRAY_FINT_2_INT_CLEANUP(destinations);
112 if( !OMPI_IS_FORTRAN_UNWEIGHTED(destweights) ) {
113 OMPI_ARRAY_FINT_2_INT_CLEANUP(destweights);
114 }
115 }
116 }
117
118