This source file includes following definitions.
- ompi_type_create_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_CREATE_STRUCT = ompi_type_create_struct_f
31 #pragma weak pmpi_type_create_struct = ompi_type_create_struct_f
32 #pragma weak pmpi_type_create_struct_ = ompi_type_create_struct_f
33 #pragma weak pmpi_type_create_struct__ = ompi_type_create_struct_f
34
35 #pragma weak PMPI_Type_create_struct_f = ompi_type_create_struct_f
36 #pragma weak PMPI_Type_create_struct_f08 = ompi_type_create_struct_f
37 #else
38 OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_CREATE_STRUCT,
39 pmpi_type_create_struct,
40 pmpi_type_create_struct_,
41 pmpi_type_create_struct__,
42 pompi_type_create_struct_f,
43 (MPI_Fint *count, MPI_Fint *array_of_block_lengths, MPI_Aint *array_of_displacements, MPI_Fint *array_of_types, MPI_Fint *newtype, MPI_Fint *ierr),
44 (count, array_of_block_lengths, array_of_displacements, array_of_types, newtype, ierr) )
45 #endif
46 #endif
47
48 #if OPAL_HAVE_WEAK_SYMBOLS
49 #pragma weak MPI_TYPE_CREATE_STRUCT = ompi_type_create_struct_f
50 #pragma weak mpi_type_create_struct = ompi_type_create_struct_f
51 #pragma weak mpi_type_create_struct_ = ompi_type_create_struct_f
52 #pragma weak mpi_type_create_struct__ = ompi_type_create_struct_f
53
54 #pragma weak MPI_Type_create_struct_f = ompi_type_create_struct_f
55 #pragma weak MPI_Type_create_struct_f08 = ompi_type_create_struct_f
56 #else
57 #if ! OMPI_BUILD_MPI_PROFILING
58 OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_CREATE_STRUCT,
59 mpi_type_create_struct,
60 mpi_type_create_struct_,
61 mpi_type_create_struct__,
62 ompi_type_create_struct_f,
63 (MPI_Fint *count, MPI_Fint *array_of_block_lengths, MPI_Aint *array_of_displacements, MPI_Fint *array_of_types, MPI_Fint *newtype, MPI_Fint *ierr),
64 (count, array_of_block_lengths, array_of_displacements, array_of_types, newtype, ierr) )
65 #else
66 #define ompi_type_create_struct_f pompi_type_create_struct_f
67 #endif
68 #endif
69
70
71 static const char FUNC_NAME[] = "MPI_TYPE_CREATE_STRUCT";
72
73
74 void ompi_type_create_struct_f(MPI_Fint *count,
75 MPI_Fint *array_of_block_lengths,
76 MPI_Aint *array_of_displacements,
77 MPI_Fint *array_of_types, MPI_Fint *newtype,
78 MPI_Fint *ierr)
79 {
80 MPI_Datatype c_new;
81 MPI_Datatype *c_type_old_array;
82 int i, c_ierr;
83 OMPI_ARRAY_NAME_DECL(array_of_block_lengths);
84
85 c_type_old_array = (MPI_Datatype *) malloc(*count * sizeof(MPI_Datatype));
86 if (NULL == c_type_old_array) {
87 c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
88 FUNC_NAME);
89 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
90 return;
91 }
92
93 for (i = 0; i < *count; i++) {
94 c_type_old_array[i] = PMPI_Type_f2c(array_of_types[i]);
95 }
96
97 OMPI_ARRAY_FINT_2_INT(array_of_block_lengths, *count);
98
99 c_ierr = PMPI_Type_create_struct(OMPI_FINT_2_INT(*count),
100 OMPI_ARRAY_NAME_CONVERT(array_of_block_lengths),
101 array_of_displacements, c_type_old_array, &c_new);
102 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
103
104 OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_block_lengths);
105
106 if (MPI_SUCCESS == c_ierr) {
107 *newtype = PMPI_Type_c2f(c_new);
108 }
109
110 free(c_type_old_array);
111 }