Changeset 622
- Timestamp:
- 09/16/08 16:47:00 (5 months ago)
- Files:
-
- trunk/CDF3/src/lib/dim.c (modified) (1 diff)
- trunk/CDF3/src/lib/mpinetcdf.c (modified) (9 diffs)
- trunk/CDF3/src/lib/ncx.h (modified) (1 diff)
- trunk/CDF3/src/lib/var.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CDF3/src/lib/dim.c
r613 r622 332 332 return NC_EDIMSIZE; 333 333 } else if ((ncp->flags & NC_64BIT_DATA)) { 334 /* CDF 3format*/335 if (size > X_UINT_MAX - 3 || (size < 0))334 /* CDF5 format*/ 335 if (size < 0) 336 336 /* "-3" handles rounded-up size */ 337 337 return NC_EDIMSIZE; trunk/CDF3/src/lib/mpinetcdf.c
r613 r622 845 845 { 846 846 847 if(*coord > X_INT _MAX)847 if(*coord > X_INT64_T_MAX) 848 848 return NC_EINVALCOORDS; /* sanity check */ 849 849 if(NC_readonly(ncp) && *coord >= ncp->numrecs) … … 873 873 { 874 874 /* cast needed for braindead systems with signed int64_t */ 875 if( *ip >= (u nsigned long)*up )875 if( *ip >= (uint64_t)*up ) 876 876 return NC_EINVALCOORDS; 877 877 } … … 903 903 { 904 904 /* cast needed for braindead systems with signed int64_t */ 905 if( *edges > (u nsigned long)*shp || *start + *edges > (unsigned long)*shp)905 if( *edges > (uint64_t)*shp || *start + *edges > (uint64_t)*shp) 906 906 { 907 907 return(NC_EEDGE); … … 926 926 if(IS_RECVAR(varp)) 927 927 { 928 if ( *stride == 0 || *stride >= X_INT _MAX)928 if ( *stride == 0 || *stride >= X_INT64_T_MAX) 929 929 /* cast needed for braindead systems with signed int64_t */ 930 930 return NC_ESTRIDE; … … 939 939 { 940 940 /* cast needed for braindead systems with signed int64_t */ 941 if( (*edges > (u nsigned long)*shp) ||942 (*edges > 0 && *start+1 + (*edges-1) * *stride > (u nsigned long)*shp) ||943 (*edges == 0 && *start > (u nsigned long)*shp) )941 if( (*edges > (uint64_t)*shp) || 942 (*edges > 0 && *start+1 + (*edges-1) * *stride > (uint64_t)*shp) || 943 (*edges == 0 && *start > (uint64_t)*shp) ) 944 944 { 945 945 return(NC_EEDGE); 946 946 } 947 947 948 if ( *stride == 0 || *stride >= X_INT _MAX)948 if ( *stride == 0 || *stride >= X_INT64_T_MAX) 949 949 /* cast needed for braindead systems with signed int64_t */ 950 950 return NC_ESTRIDE; … … 1063 1063 int64_t dim, ndims; 1064 1064 int *shape = NULL, *subcount = NULL, *substart = NULL; /* all in bytes */ 1065 int64_t *shape64 = NULL, *subcount64 = NULL, *substart64 = NULL; 1065 1066 MPI_Datatype rectype; 1066 1067 MPI_Datatype filetype; 1067 1068 int mpireturn; 1069 MPI_Datatype types[3]; 1070 MPI_Datatype type1; 1071 int64_t size, disps[3]; 1072 int blklens[3]; 1073 int tag = 0; 1074 int i; 1075 1068 1076 1069 1077 offset = varp->begin; … … 1187 1195 1188 1196 } else { 1189 1197 1190 1198 /* non record variable */ 1191 1192 for (dim = 0; dim < ndims-1; dim++ ) { 1193 shape[dim] = varp->shape[dim]; 1194 subcount[dim] = count[dim]; 1195 substart[dim] = start[dim]; 1196 } 1197 1198 shape[dim] = varp->xsz * varp->shape[dim]; 1199 subcount[dim] = varp->xsz * count[dim]; 1200 substart[dim] = varp->xsz * start[dim]; 1201 1202 MPI_Type_create_subarray(ndims, shape, subcount, substart, 1203 MPI_ORDER_C, MPI_BYTE, &filetype); 1204 1205 MPI_Type_commit(&filetype); 1206 } 1199 tag = 0; 1200 for (dim=0; dim< ndims-1; dim++){ 1201 if (varp->shape[dim] > 2147483647){ /* if shape > 2^31-1 */ 1202 tag = 1; 1203 break; 1204 } 1205 } 1206 if ((varp->shape[dim]*varp->xsz) > 2147483647) 1207 tag = 1; 1208 if (tag == 0 ){ 1209 for (dim = 0; dim < ndims-1; dim++ ) { 1210 shape[dim] = varp->shape[dim]; 1211 subcount[dim] = count[dim]; 1212 substart[dim] = start[dim]; 1213 } 1214 1215 shape[dim] = varp->xsz * varp->shape[dim]; 1216 subcount[dim] = varp->xsz * count[dim]; 1217 substart[dim] = varp->xsz * start[dim]; 1218 1219 MPI_Type_create_subarray(ndims, shape, subcount, substart, 1220 MPI_ORDER_C, MPI_BYTE, &filetype); 1221 1222 MPI_Type_commit(&filetype); 1223 } else { 1224 shape64 = (int64_t *)malloc(sizeof(int64_t) * ndims); 1225 subcount64 = (int64_t *)malloc(sizeof(int64_t) * ndims); 1226 substart64 = (int64_t *)malloc(sizeof(int64_t) * ndims); 1227 1228 if (ndims == 1){ // for 64-bit support, added July 23, 2008 1229 shape64[0] = varp->shape[0]; 1230 subcount64[0] = count[0]; 1231 substart64[0] = start[0]; 1232 1233 offset += start[0]*varp->xsz; 1234 1235 MPI_Type_contiguous(subcount64[0]*varp->xsz, MPI_BYTE, &type1); 1236 MPI_Type_commit(&type1); 1237 1238 #if (MPI_VERSION < 2) 1239 MPI_Type_hvector(subcount64[0], varp->xsz, shape64[0]*varp->xsz, 1240 MPI_BYTE, &filetype); 1241 #else 1242 MPI_Type_create_hvector(1, 1, shape64[0]*varp->xsz, 1243 type1, &filetype); 1244 #endif 1245 MPI_Type_commit(&filetype); 1246 MPI_Type_free(&type1); 1247 1248 } else { 1249 for (dim = 0; dim < ndims-1; dim++ ) { 1250 shape64[dim] = varp->shape[dim]; 1251 subcount64[dim] = count[dim]; 1252 substart64[dim] = start[dim]; 1253 } 1254 1255 shape64[dim] = varp->xsz * varp->shape[dim]; 1256 subcount64[dim] = varp->xsz * count[dim]; 1257 substart64[dim] = varp->xsz * start[dim]; 1258 MPI_Type_hvector(subcount64[dim-1], 1259 subcount64[dim], 1260 varp->xsz * varp->shape[dim], 1261 MPI_BYTE, 1262 &type1); 1263 MPI_Type_commit(&type1); 1264 size = shape[dim]; 1265 for (i=dim-2; i>=0; i--) { 1266 size *= shape[i+1]; 1267 MPI_Type_hvector(subcount64[i], 1268 1, 1269 size, 1270 type1, 1271 &filetype); 1272 MPI_Type_commit(&filetype); 1273 1274 MPI_Type_free(&type1); 1275 type1 = filetype; 1276 } 1277 disps[1] = substart64[dim]; 1278 size = 1; 1279 for (i=dim-1; i>=0; i--) { 1280 size *= shape64[i+1]; 1281 disps[1] += size*substart64[i]; 1282 } 1283 disps[2] = 1; 1284 for (i=0; i<ndims; i++) disps[2] *= shape64[i]; 1285 1286 disps[0] = 0; 1287 blklens[0] = blklens[1] = blklens[2] = 1; 1288 types[0] = MPI_LB; 1289 types[1] = type1; 1290 types[2] = MPI_UB; 1291 1292 MPI_Type_struct(3, 1293 blklens, 1294 disps, 1295 types, 1296 &filetype); 1297 1298 MPI_Type_free(&type1); 1299 } 1300 1301 free(shape64); 1302 free(subcount64); 1303 free(substart64); 1304 } 1305 } 1306 1207 1307 } 1208 1308 } … … 1279 1379 { 1280 1380 if ( (stride != NULL && stride[dim] == 0) || 1281 stride[dim] >= X_ INT_MAX)1381 stride[dim] >= X_LONG_MAX) 1282 1382 { 1283 1383 return NC_ESTRIDE; … … 1293 1393 1294 1394 if(getnotput && IS_RECVAR(varp) && 1295 (u nsigned long)*start + (unsigned long)*count > NC_get_numrecs(ncp))1395 (uint64_t)*start + (uint64_t)*count > NC_get_numrecs(ncp)) 1296 1396 return NC_EEDGE; 1297 1397 */ trunk/CDF3/src/lib/ncx.h
r613 r622 109 109 #define X_OFF_MAX X_INT_MAX 110 110 111 #define X_INT64_T_MAX 9223372036854775808 112 #define X_UINT64_T_MAX 18446744073709551616U 111 113 112 114 /* Begin ncx_len */ trunk/CDF3/src/lib/var.c
r618 r622 360 360 * 'compile' the shape and len of a variable 361 361 * Formerly 362 ncmpii_NC_var_shape(var, dims)362 * ncmpii_NC_var_shape(var, dims) 363 363 */ 364 364 #include <stdio.h>