This source file includes following definitions.
- MPI_Type_create_f90_real
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include "ompi_config.h"
30
31 #include <float.h>
32
33 #include "opal/util/printf.h"
34
35 #include "ompi/mpi/c/bindings.h"
36 #include "ompi/runtime/params.h"
37 #include "ompi/communicator/communicator.h"
38 #include "ompi/errhandler/errhandler.h"
39
40 #if OMPI_BUILD_MPI_PROFILING
41 #if OPAL_HAVE_WEAK_SYMBOLS
42 #pragma weak MPI_Type_create_f90_real = PMPI_Type_create_f90_real
43 #endif
44 #define MPI_Type_create_f90_real PMPI_Type_create_f90_real
45 #endif
46
47 static const char FUNC_NAME[] = "MPI_Type_create_f90_real";
48
49
50 int MPI_Type_create_f90_real(int p, int r, MPI_Datatype *newtype)
51 {
52 uint64_t key;
53 int p_key, r_key;
54 int sflt_dig = 3, sflt_max_10_exp = +5, sflt_min_10_exp = -4;
55
56 OPAL_CR_NOOP_PROGRESS();
57
58 if (MPI_PARAM_CHECK) {
59 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
60
61
62
63
64
65
66 if ((MPI_UNDEFINED == p && MPI_UNDEFINED == r)) {
67 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
68 }
69 }
70
71
72
73
74 p_key = p;
75 r_key = r;
76 if( MPI_UNDEFINED == p ) p_key = 0;
77 if( MPI_UNDEFINED == r ) r_key = 0;
78
79
80
81
82
83
84
85
86
87
88 if ( (LDBL_DIG < p) || (LDBL_MAX_10_EXP < r) || (-LDBL_MIN_10_EXP < r) ) *newtype = &ompi_mpi_datatype_null.dt;
89 else if( (DBL_DIG < p) || (DBL_MAX_10_EXP < r) || (-DBL_MIN_10_EXP < r) ) *newtype = &ompi_mpi_long_double.dt;
90 else if( (FLT_DIG < p) || (FLT_MAX_10_EXP < r) || (-FLT_MIN_10_EXP < r) ) *newtype = &ompi_mpi_double.dt;
91 else if( ! OMPI_HAVE_FORTRAN_REAL2 ||
92 (sflt_dig < p) || (sflt_max_10_exp < r) || (-sflt_min_10_exp < r) ) *newtype = &ompi_mpi_float.dt;
93 else *newtype = &ompi_mpi_real2.dt;
94
95 if( *newtype != &ompi_mpi_datatype_null.dt ) {
96 ompi_datatype_t* datatype;
97 const int* a_i[2] = {&p, &r};
98 int rc;
99
100 key = (((uint64_t)p_key) << 32) | ((uint64_t)r_key);
101 if( OPAL_SUCCESS == opal_hash_table_get_value_uint64( &ompi_mpi_f90_real_hashtable,
102 key, (void**)newtype ) ) {
103 return MPI_SUCCESS;
104 }
105
106
107
108 if (OMPI_SUCCESS != ompi_datatype_duplicate( *newtype, &datatype)) {
109 OMPI_ERRHANDLER_RETURN (MPI_ERR_INTERN, MPI_COMM_WORLD,
110 MPI_ERR_INTERN, FUNC_NAME );
111 }
112
113
114
115 datatype->super.flags |= OMPI_DATATYPE_FLAG_PREDEFINED;
116
117
118
119
120
121 opal_snprintf(datatype->name, sizeof(datatype->name),
122 "COMBINER %s", (*newtype)->name);
123
124 ompi_datatype_set_args( datatype, 2, a_i, 0, NULL, 0, NULL, MPI_COMBINER_F90_REAL );
125
126 rc = opal_hash_table_set_value_uint64( &ompi_mpi_f90_real_hashtable, key, datatype );
127 if (OMPI_SUCCESS != rc) {
128 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
129 }
130 *newtype = datatype;
131 return MPI_SUCCESS;
132 }
133
134 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
135 }