@@ -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 ] ;
28- int procs , tmp_rank , i , tmp_size , blklens [ 3 ] , * coords ;
29- MPI_Aint * st_offsets , orig_extent , disps [ 3 ] ;
27+ MPI_Datatype type_old , type_new = MPI_DATATYPE_NULL , inttype ;
28+ int procs , tmp_rank , i , tmp_size , blklen , * coords ;
29+ MPI_Aint * st_offsets , orig_extent , disp , ub , 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) */
@@ -77,11 +77,11 @@ int ADIO_Type_create_darray(int size, int rank, int ndims,
7777 }
7878
7979 /* add displacement and UB */
80- disps [ 1 ] = st_offsets [0 ];
80+ disp = st_offsets [0 ];
8181 tmp_size = 1 ;
8282 for (i = 1 ; i < ndims ; i ++ ) {
8383 tmp_size *= array_of_gsizes [i - 1 ];
84- disps [ 1 ] += (MPI_Aint )tmp_size * st_offsets [i ];
84+ disp += (MPI_Aint )tmp_size * st_offsets [i ];
8585 }
8686 /* rest done below for both Fortran and C order */
8787 }
@@ -115,26 +115,24 @@ int ADIO_Type_create_darray(int size, int rank, int ndims,
115115 }
116116
117117 /* add displacement and UB */
118- disps [ 1 ] = st_offsets [ndims - 1 ];
118+ disp = st_offsets [ndims - 1 ];
119119 tmp_size = 1 ;
120120 for (i = ndims - 2 ; i >=0 ; i -- ) {
121121 tmp_size *= array_of_gsizes [i + 1 ];
122- disps [ 1 ] += (MPI_Aint )tmp_size * st_offsets [i ];
122+ disp += (MPI_Aint )tmp_size * st_offsets [i ];
123123 }
124124 }
125125
126- disps [ 1 ] *= orig_extent ;
126+ disp *= orig_extent ;
127127
128- disps [ 2 ] = orig_extent ;
129- for (i = 0 ; i < ndims ; i ++ ) disps [ 2 ] *= (MPI_Aint )array_of_gsizes [i ];
128+ ub = orig_extent ;
129+ for (i = 0 ; i < ndims ; i ++ ) ub *= (MPI_Aint )array_of_gsizes [i ];
130130
131- 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 ;
131+ blklen = 1 ;
136132
137- MPI_Type_struct (3 , blklens , disps , types , newtype );
133+ MPI_Type_create_struct (1 , & blklen , & disp , & type_new , & inttype );
134+ MPI_Type_create_resized (inttype , 0 , ub , newtype );
135+ MPI_Type_free (& inttype );
138136
139137 MPI_Type_free (& type_new );
140138 ADIOI_Free (st_offsets );
@@ -184,15 +182,15 @@ static int MPIOI_Type_block(int *array_of_gsizes, int dim, int ndims, int nprocs
184182 MPI_Type_contiguous (mysize , type_old , type_new );
185183 else {
186184 for (i = 0 ; i < dim ; i ++ ) stride *= (MPI_Aint )array_of_gsizes [i ];
187- MPI_Type_hvector (mysize , 1 , stride , type_old , type_new );
185+ MPI_Type_create_hvector (mysize , 1 , stride , type_old , type_new );
188186 }
189187 }
190188 else {
191189 if (dim == ndims - 1 )
192190 MPI_Type_contiguous (mysize , type_old , type_new );
193191 else {
194192 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 );
193+ MPI_Type_create_hvector (mysize , 1 , stride , type_old , type_new );
196194 }
197195
198196 }
@@ -217,7 +215,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
217215 rank = coordinate of this process in dimension dim */
218216 int blksize , i , blklens [3 ], st_index , end_index , local_size , rem , count ;
219217 MPI_Aint stride , disps [3 ];
220- MPI_Datatype type_tmp , types [3 ];
218+ MPI_Datatype type_tmp , type_tmp1 , types [3 ];
221219
222220 if (darg == MPI_DISTRIBUTE_DFLT_DARG ) blksize = 1 ;
223221 else blksize = darg ;
@@ -246,7 +244,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
246244 for (i = 0 ; i < dim ; i ++ ) stride *= (MPI_Aint )array_of_gsizes [i ];
247245 else for (i = ndims - 1 ; i > dim ; i -- ) stride *= (MPI_Aint )array_of_gsizes [i ];
248246
249- MPI_Type_hvector (count , blksize , stride , type_old , type_new );
247+ MPI_Type_create_hvector (count , blksize , stride , type_old , type_new );
250248
251249 if (rem ) {
252250 /* if the last block is of size less than blksize, include
@@ -259,7 +257,7 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
259257 blklens [0 ] = 1 ;
260258 blklens [1 ] = rem ;
261259
262- MPI_Type_struct (2 , blklens , disps , types , & type_tmp );
260+ MPI_Type_create_struct (2 , blklens , disps , types , & type_tmp );
263261
264262 MPI_Type_free (type_new );
265263 * type_new = type_tmp ;
@@ -269,14 +267,12 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
269267 dimension correctly. */
270268 if ( ((order == MPI_ORDER_FORTRAN ) && (dim == 0 )) ||
271269 ((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 );
270+ types [0 ] = * type_new ;
271+ disps [0 ] = (MPI_Aint )rank * (MPI_Aint )blksize * orig_extent ;
272+ blklens [0 ] = 1 ;
273+ MPI_Type_create_struct (1 , blklens , disps , types , & type_tmp1 );
274+ MPI_Type_create_resized (type_tmp1 , 0 , orig_extent * (MPI_Aint )array_of_gsizes [dim ], & type_tmp );
275+ MPI_Type_free (& type_tmp1 );
280276 MPI_Type_free (type_new );
281277 * type_new = type_tmp ;
282278
0 commit comments