@@ -24,11 +24,11 @@ int ADIO_Type_create_darray(int size, int rank, int ndims,
2424 int order , MPI_Datatype oldtype ,
2525 MPI_Datatype * newtype )
2626{
27- MPI_Datatype type_old , type_new = MPI_DATATYPE_NULL , types [3 ];
27+ MPI_Datatype type_old , type_new = MPI_DATATYPE_NULL , types [3 ], inttype ;
2828 int procs , tmp_rank , i , tmp_size , blklens [3 ], * coords ;
29- MPI_Aint * st_offsets , orig_extent , disps [3 ];
29+ MPI_Aint * st_offsets , orig_extent , disps [3 ], lb ;
3030
31- MPI_Type_extent (oldtype , & orig_extent );
31+ MPI_Type_get_extent (oldtype , & lb , & orig_extent );
3232
3333/* calculate position in Cartesian grid as MPI would (row-major
3434 ordering) */
@@ -129,12 +129,12 @@ int ADIO_Type_create_darray(int size, int rank, int ndims,
129129 for (i = 0 ; i < ndims ; i ++ ) disps [2 ] *= (MPI_Aint )array_of_gsizes [i ];
130130
131131 disps [0 ] = 0 ;
132- blklens [0 ] = blklens [1 ] = blklens [2 ] = 1 ;
133- types [0 ] = MPI_LB ;
134- types [1 ] = type_new ;
135- types [2 ] = MPI_UB ;
132+ blklens [0 ] = 1 ;
133+ types [0 ] = type_new ;
136134
137- MPI_Type_struct (3 , blklens , disps , types , newtype );
135+ MPI_Type_create_struct (1 , blklens , disps + 1 , types , & inttype );
136+ MPI_Type_create_resized (inttype , disps [0 ], disps [2 ], newtype );
137+ MPI_Type_free (& inttype );
138138
139139 MPI_Type_free (& type_new );
140140 ADIOI_Free (st_offsets );
@@ -184,15 +184,15 @@ static int MPIOI_Type_block(int *array_of_gsizes, int dim, int ndims, int nprocs
184184 MPI_Type_contiguous (mysize , type_old , type_new );
185185 else {
186186 for (i = 0 ; i < dim ; i ++ ) stride *= (MPI_Aint )array_of_gsizes [i ];
187- MPI_Type_hvector (mysize , 1 , stride , type_old , type_new );
187+ MPI_Type_create_hvector (mysize , 1 , stride , type_old , type_new );
188188 }
189189 }
190190 else {
191191 if (dim == ndims - 1 )
192192 MPI_Type_contiguous (mysize , type_old , type_new );
193193 else {
194194 for (i = ndims - 1 ; i > dim ; i -- ) stride *= (MPI_Aint )array_of_gsizes [i ];
195- MPI_Type_hvector (mysize , 1 , stride , type_old , type_new );
195+ MPI_Type_create_hvector (mysize , 1 , stride , type_old , type_new );
196196 }
197197
198198 }
@@ -217,7 +217,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
217217 rank = coordinate of this process in dimension dim */
218218 int blksize , i , blklens [3 ], st_index , end_index , local_size , rem , count ;
219219 MPI_Aint stride , disps [3 ];
220- MPI_Datatype type_tmp , types [3 ];
220+ MPI_Datatype type_tmp , type_tmp1 , types [3 ];
221221
222222 if (darg == MPI_DISTRIBUTE_DFLT_DARG ) blksize = 1 ;
223223 else blksize = darg ;
@@ -246,7 +246,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
246246 for (i = 0 ; i < dim ; i ++ ) stride *= (MPI_Aint )array_of_gsizes [i ];
247247 else for (i = ndims - 1 ; i > dim ; i -- ) stride *= (MPI_Aint )array_of_gsizes [i ];
248248
249- MPI_Type_hvector (count , blksize , stride , type_old , type_new );
249+ MPI_Type_create_hvector (count , blksize , stride , type_old , type_new );
250250
251251 if (rem ) {
252252 /* if the last block is of size less than blksize, include
@@ -259,7 +259,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
259259 blklens [0 ] = 1 ;
260260 blklens [1 ] = rem ;
261261
262- MPI_Type_struct (2 , blklens , disps , types , & type_tmp );
262+ MPI_Type_create_struct (2 , blklens , disps , types , & type_tmp );
263263
264264 MPI_Type_free (type_new );
265265 * type_new = type_tmp ;
@@ -269,14 +269,12 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
269269 dimension correctly. */
270270 if ( ((order == MPI_ORDER_FORTRAN ) && (dim == 0 )) ||
271271 ((order == MPI_ORDER_C ) && (dim == ndims - 1 )) ) {
272- types [0 ] = MPI_LB ;
273- disps [0 ] = 0 ;
274- types [1 ] = * type_new ;
275- disps [1 ] = (MPI_Aint )rank * (MPI_Aint )blksize * orig_extent ;
276- types [2 ] = MPI_UB ;
277- disps [2 ] = orig_extent * (MPI_Aint )array_of_gsizes [dim ];
278- blklens [0 ] = blklens [1 ] = blklens [2 ] = 1 ;
279- MPI_Type_struct (3 , blklens , disps , types , & type_tmp );
272+ types [0 ] = * type_new ;
273+ disps [0 ] = (MPI_Aint )rank * (MPI_Aint )blksize * orig_extent ;
274+ blklens [0 ] = 1 ;
275+ MPI_Type_create_struct (1 , blklens , disps , types , & type_tmp1 );
276+ MPI_Type_create_resized (type_tmp1 , 0 , orig_extent * (MPI_Aint )array_of_gsizes [dim ], & type_tmp );
277+ MPI_Type_free (& type_tmp1 );
280278 MPI_Type_free (type_new );
281279 * type_new = type_tmp ;
282280
0 commit comments