This source file includes following definitions.
- ompi_type_struct_f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "ompi_config.h"
23
24 #include "ompi/mpi/fortran/mpif-h/bindings.h"
25 #include "ompi/errhandler/errhandler.h"
26 #include "ompi/communicator/communicator.h"
27
28 #if OMPI_BUILD_MPI_PROFILING
29 #if OPAL_HAVE_WEAK_SYMBOLS
30 #pragma weak PMPI_TYPE_STRUCT = ompi_type_struct_f
31 #pragma weak pmpi_type_struct = ompi_type_struct_f
32 #pragma weak pmpi_type_struct_ = ompi_type_struct_f
33 #pragma weak pmpi_type_struct__ = ompi_type_struct_f
34
35 #pragma weak PMPI_Type_struct_f = ompi_type_struct_f
36 #pragma weak PMPI_Type_struct_f08 = ompi_type_struct_f
37 #else
38 OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_STRUCT,
39 pmpi_type_struct,
40 pmpi_type_struct_,
41 pmpi_type_struct__,
42 pompi_type_struct_f,
43 (MPI_Fint *count, MPI_Fint *array_of_blocklengths, MPI_Fint *array_of_displacements, MPI_Fint *array_of_types, MPI_Fint *newtype, MPI_Fint *ierr),
44 (count, array_of_blocklengths, array_of_displacements, array_of_types, newtype, ierr) )
45 #endif
46 #endif
47
48 #if OPAL_HAVE_WEAK_SYMBOLS
49 #pragma weak MPI_TYPE_STRUCT = ompi_type_struct_f
50 #pragma weak mpi_type_struct = ompi_type_struct_f
51 #pragma weak mpi_type_struct_ = ompi_type_struct_f
52 #pragma weak mpi_type_struct__ = ompi_type_struct_f
53
54 #pragma weak MPI_Type_struct_f = ompi_type_struct_f
55 #pragma weak MPI_Type_struct_f08 = ompi_type_struct_f
56 #else
57 #if ! OMPI_BUILD_MPI_PROFILING
58 OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_STRUCT,
59 mpi_type_struct,
60 mpi_type_struct_,
61 mpi_type_struct__,
62 ompi_type_struct_f,
63 (MPI_Fint *count, MPI_Fint *array_of_blocklengths, MPI_Fint *array_of_displacements, MPI_Fint *array_of_types, MPI_Fint *newtype, MPI_Fint *ierr),
64 (count, array_of_blocklengths, array_of_displacements, array_of_types, newtype, ierr) )
65 #else
66 #define ompi_type_struct_f pompi_type_struct_f
67 #endif
68 #endif
69
70
71 static const char FUNC_NAME[] = "MPI_TYPE_STRUCT";
72
73
74 void ompi_type_struct_f(MPI_Fint *count, MPI_Fint *array_of_blocklengths,
75 MPI_Fint *array_of_displacements,
76 MPI_Fint *array_of_types, MPI_Fint *newtype,
77 MPI_Fint *ierr)
78 {
79 MPI_Aint *c_disp_array;
80 MPI_Datatype *c_type_old_array;
81 MPI_Datatype c_new;
82 int i, c_ierr;
83 OMPI_ARRAY_NAME_DECL(array_of_blocklengths);
84
85 c_type_old_array = (MPI_Datatype *) malloc(*count * (sizeof(MPI_Datatype) +
86 sizeof(MPI_Aint)));
87 if (NULL == c_type_old_array) {
88 c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
89 FUNC_NAME);
90 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
91 return;
92 }
93 c_disp_array = (MPI_Aint*) c_type_old_array + *count;
94
95 for (i = 0; i < *count; i++) {
96 c_disp_array[i] = (MPI_Aint) array_of_displacements[i];
97 c_type_old_array[i] = PMPI_Type_f2c(array_of_types[i]);
98 }
99
100 OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);
101
102 c_ierr = PMPI_Type_struct(OMPI_FINT_2_INT(*count),
103 OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths),
104 c_disp_array,
105 c_type_old_array, &c_new);
106 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
107
108 OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
109 free(c_type_old_array);
110
111 if (MPI_SUCCESS == c_ierr) {
112 *newtype = PMPI_Type_c2f(c_new);
113 }
114 }