mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Eliminate a lot of 'result of operation is undefined or garbage' errors reported by static analysis. These errors appeared to be false positives as there was logic that should prevent their occurance, but it's possible that optimization would result in these error states occuring.
This commit is contained in:
parent
0451296574
commit
30621b38d3
@ -826,7 +826,7 @@ ifelse(`$1',`uchar',`ifdef(`PNETCDF',,``#'endif')')
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j]-index[j]-1) / (IntType)stride[j];
|
||||
count[j] = 1 + (edge[j]-index[j]-1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
}
|
||||
@ -1123,7 +1123,7 @@ ifelse(`$1',`uchar',`ifdef(`PNETCDF',,``#'endif')')
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j]-index[j]-1) / (IntType)stride[j];
|
||||
count[j] = 1 + (edge[j]-index[j]-1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ check_vars_$1(const char *filename, int numVars)
|
||||
error("var_name: %s, ", var_name[i]);
|
||||
error("var_type: %s, ", s_nc_type(var_type[i]));
|
||||
error("index:");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
error(" %d", index[d]);
|
||||
error(", expect: %g, ", expect);
|
||||
error("got: %g", (double) value);
|
||||
@ -428,9 +428,9 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS */
|
||||
for (j = 0; j < var_rank[i]; j++) index[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) index[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
index[j] = var_shape[i][j]; /* out of boundary check */
|
||||
err = PutVar1($1)(ncid, i, index, value);
|
||||
@ -664,6 +664,13 @@ TestFunc(vara)_$1(VarArgs)
|
||||
IntType mid[MAX_RANK], index[MAX_RANK];
|
||||
$1 value[MAX_NELS];
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
mid[j] = 0;
|
||||
index[j] = 0;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_CLOBBER);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -707,7 +714,7 @@ TestFunc(vara)_$1(VarArgs)
|
||||
|
||||
canConvert = (var_type[i] == NC_CHAR) CheckText($1);
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
}
|
||||
@ -741,7 +748,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVara($1)(ncid, i, start, edge, value);
|
||||
@ -765,9 +772,9 @@ ifdef(`PNETCDF',`dnl
|
||||
}
|
||||
|
||||
/* Check correct error returned when nothing to put, when edge[*]==0 */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVara($1)(ncid, i, start, edge, value);
|
||||
@ -788,19 +795,19 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* Put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
/* bits of k determine whether to put lower or upper part of dim */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -814,7 +821,7 @@ ifdef(`PNETCDF',`dnl
|
||||
for (allInExtRange = 1, j = 0; j < nels; j++) {
|
||||
err = toMixedBase(j, var_rank[i], edge, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index[d] += start[d];
|
||||
value[j]= hash_$1(cdf_format,var_type[i], var_rank[i], index,
|
||||
NCT_ITYPE($1));
|
||||
@ -883,6 +890,17 @@ TestFunc(vars)_$1(VarArgs)
|
||||
PTRDType stride[MAX_RANK];
|
||||
$1 value[MAX_NELS];
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
mid[j] = 0;
|
||||
index[j] = 0;
|
||||
index2[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
stride[j] = 1;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_CLOBBER);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -926,7 +944,7 @@ TestFunc(vars)_$1(VarArgs)
|
||||
|
||||
canConvert = (var_type[i] == NC_CHAR) CheckText($1);
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
@ -944,7 +962,7 @@ ifdef(`PNETCDF',`dnl
|
||||
EXPECT_ERR(NC_EINVALCOORDS, err)
|
||||
}
|
||||
ELSE_NOK
|
||||
|
||||
|
||||
/* for non-scalar variables, argument count cannot be NULL */
|
||||
err = PutVars($1)(ncid, i, start, NULL, NULL, value);
|
||||
if (!canConvert) {
|
||||
@ -960,7 +978,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j]; /* out of boundary check */
|
||||
err = PutVars($1)(ncid, i, start, edge, stride, value);
|
||||
@ -989,9 +1007,9 @@ ifdef(`PNETCDF',`dnl
|
||||
stride[j] = 1;
|
||||
}
|
||||
/* Check correct error returned even when nothing to put */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVars($1)(ncid, i, start, edge, stride, value);
|
||||
@ -1012,12 +1030,12 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* Put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1025,7 +1043,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* choose random stride from 1 to edge */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1041,15 +1059,15 @@ ifdef(`PNETCDF',`dnl
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = (1 + (edge[j] - index[j] - 1)) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
}
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
@ -1058,7 +1076,7 @@ ifdef(`PNETCDF',`dnl
|
||||
for (allInExtRange = 1, j = 0; j < nels; j++) {
|
||||
err = toMixedBase(j, var_rank[i], count, index2);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index2[d] = index[d] + index2[d] * (IntType)stride[d];
|
||||
value[j] = hash_$1(cdf_format,var_type[i], var_rank[i],
|
||||
index2, NCT_ITYPE($1));
|
||||
@ -1128,6 +1146,17 @@ TestFunc(varm)_$1(VarArgs)
|
||||
PTRDType stride[MAX_RANK], imap[MAX_RANK];
|
||||
$1 value[MAX_NELS];
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
mid[j] = 0;
|
||||
index[j] = 0;
|
||||
index2[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
stride[j] = 1;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_CLOBBER);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -1171,7 +1200,7 @@ TestFunc(varm)_$1(VarArgs)
|
||||
|
||||
canConvert = (var_type[i] == NC_CHAR) CheckText($1);
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
@ -1191,7 +1220,7 @@ ifdef(`PNETCDF',`dnl
|
||||
EXPECT_ERR(NC_EINVALCOORDS, err)
|
||||
}
|
||||
ELSE_NOK
|
||||
|
||||
|
||||
/* for non-scalar variables, argument count cannot be NULL */
|
||||
err = PutVarm($1)(ncid, i, start, NULL, NULL, NULL, value);
|
||||
if (!canConvert) {
|
||||
@ -1207,7 +1236,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j]; /* out of boundary check */
|
||||
err = PutVarm($1)(ncid, i, start, edge, stride, imap, value);
|
||||
@ -1236,9 +1265,9 @@ ifdef(`PNETCDF',`dnl
|
||||
stride[j] = 1;
|
||||
}
|
||||
/* Check correct error returned when nothing to put, i.e. edge[*]==0 */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i]&& j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVarm($1)(ncid, i, start, edge, stride, imap, value);
|
||||
@ -1259,12 +1288,12 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* Put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1272,7 +1301,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* choose random stride from 1 to edge */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1288,7 +1317,7 @@ ifdef(`PNETCDF',`dnl
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
@ -1296,7 +1325,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
@ -1311,7 +1340,7 @@ ifdef(`PNETCDF',`dnl
|
||||
for (allInExtRange = 1, j = 0; j < nels; j++) {
|
||||
err = toMixedBase(j, var_rank[i], count, index2);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index2[d] = index[d] + index2[d] * (IntType)stride[d];
|
||||
value[j] = hash_$1(cdf_format,var_type[i], var_rank[i],
|
||||
index2, NCT_ITYPE($1));
|
||||
@ -1533,4 +1562,3 @@ TEST_NC_PUT_ATT(ushort)
|
||||
TEST_NC_PUT_ATT(uint)
|
||||
TEST_NC_PUT_ATT(longlong)
|
||||
TEST_NC_PUT_ATT(ulonglong)
|
||||
|
||||
|
@ -1076,7 +1076,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] = var_shape[i][j];
|
||||
err = GetVar1(ncid, i, index, buf, 1, datatype);
|
||||
IF (err != NC_EINVALCOORDS)
|
||||
@ -1135,6 +1135,13 @@ TestFunc(get_vara)(VarArgs)
|
||||
double buf[MAX_NELS] = {0}; /* (void *) buffer */
|
||||
double expect = 0;
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
index[j] = 0;
|
||||
mid[j] = 0;
|
||||
}
|
||||
|
||||
err = FileOpen(testfile, NC_NOWRITE, &ncid);
|
||||
IF (err != NC_NOERR)
|
||||
error("open: %s", APIFunc(strerror)(err));
|
||||
@ -1159,7 +1166,7 @@ TestFunc(get_vara)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
}
|
||||
@ -1184,7 +1191,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS, first when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] = var_shape[i][j];
|
||||
err = GetVara(ncid, i, index, edge, buf, 1, datatype);
|
||||
IF (err != NC_EINVALCOORDS)
|
||||
@ -1201,9 +1208,9 @@ ifdef(`PNETCDF',`dnl
|
||||
|
||||
/* Check non-scalars for correct error returned even when there is
|
||||
* nothing to get (edge[j]==0) */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = GetVara(ncid, i, start, edge, buf, 0, datatype);
|
||||
@ -1217,7 +1224,7 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
err = GetVara(ncid, i, start, edge, buf, 1, datatype);
|
||||
IF (err != NC_NOERR)
|
||||
@ -1227,14 +1234,14 @@ ifdef(`PNETCDF',`dnl
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* get 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
/* bits of k determine whether to get lower or upper part of dim */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1257,7 +1264,7 @@ ifdef(`PNETCDF',`dnl
|
||||
IF (err) error("error in nc2dbl");
|
||||
err = toMixedBase(j, var_rank[i], edge, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index[d] += start[d];
|
||||
expect = hash(var_type[i], var_rank[i], index);
|
||||
if (inRange(expect,var_type[i])) {
|
||||
@ -1316,6 +1323,17 @@ TestFunc(get_vars)(VarArgs)
|
||||
double expect;
|
||||
double got;
|
||||
|
||||
for (j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
mid[j] = 1;
|
||||
index[j] = 0;
|
||||
index2[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
}
|
||||
|
||||
err = FileOpen(testfile, NC_NOWRITE, &ncid);
|
||||
IF (err != NC_NOERR)
|
||||
error("open: %s", APIFunc(strerror)(err));
|
||||
@ -1340,10 +1358,15 @@ TestFunc(get_vars)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
mid[j] = 1;
|
||||
index[j] = 0;
|
||||
index2[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
}
|
||||
|
||||
ifdef(`PNETCDF',`dnl
|
||||
@ -1366,7 +1389,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS, first when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = var_shape[i][j];
|
||||
err = GetVars(ncid, i, start, edge, stride, buf, 1, datatype);
|
||||
IF (err != NC_EINVALCOORDS)
|
||||
@ -1388,9 +1411,9 @@ ifdef(`PNETCDF',`dnl
|
||||
}
|
||||
/* Check non-scalars for correct error returned even when there is
|
||||
* nothing to get (edge[j]==0) */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = GetVars(ncid, i, start, edge, stride, buf, 0, datatype);
|
||||
@ -1404,7 +1427,7 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
err = GetVars(ncid, i, start, edge, stride, buf, 1, datatype);
|
||||
IF (err != NC_NOERR)
|
||||
@ -1414,7 +1437,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* get 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1423,7 +1446,7 @@ ifdef(`PNETCDF',`dnl
|
||||
n = 0;
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1439,15 +1462,15 @@ ifdef(`PNETCDF',`dnl
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
}
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
@ -1466,7 +1489,7 @@ ifdef(`PNETCDF',`dnl
|
||||
error("error in nc2dbl");
|
||||
err = toMixedBase(j, var_rank[i], count, index2);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index2[d] = index[d] + index2[d] * (IntType)stride[d];
|
||||
expect = hash(var_type[i], var_rank[i], index2);
|
||||
if (inRange(expect,var_type[i])) {
|
||||
@ -1539,6 +1562,18 @@ TestFunc(get_varm)(VarArgs)
|
||||
double expect;
|
||||
double got;
|
||||
|
||||
for (j = 0; j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
mid[j] = 1;
|
||||
index[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
imap[j] = 0;
|
||||
imap2[j] = 0;
|
||||
}
|
||||
|
||||
err = FileOpen(testfile, NC_NOWRITE, &ncid);
|
||||
IF (err != NC_NOERR)
|
||||
error("open: %s", APIFunc(strerror)(err));
|
||||
@ -1563,7 +1598,7 @@ TestFunc(get_varm)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
@ -1590,7 +1625,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS, first when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK ; j++) {
|
||||
start[j] = var_shape[i][j];
|
||||
err = GetVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
|
||||
IF (err != NC_EINVALCOORDS)
|
||||
@ -1612,9 +1647,9 @@ ifdef(`PNETCDF',`dnl
|
||||
}
|
||||
/* Check non-scalars for correct error returned even when there is
|
||||
* nothing to get (edge[j]==0) */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = GetVarm(ncid, i, start, edge, stride, imap, buf, 0, datatype);
|
||||
@ -1628,7 +1663,7 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
err = GetVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
|
||||
IF (err != NC_NOERR)
|
||||
@ -1646,7 +1681,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* get 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1654,7 +1689,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* choose random stride from 1 to edge */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1674,15 +1709,15 @@ ifdef(`PNETCDF',`dnl
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
index[j] += start[j];
|
||||
nels *= count[j];
|
||||
}
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
|
@ -892,9 +892,9 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* test NC_EINVALCOORDS */
|
||||
for (j = 0; j < var_rank[i]; j++) index[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) index[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
index[j] = var_shape[i][j]; /* out of boundary check */
|
||||
err = PutVar1(ncid, i, index, value, 1, datatype);
|
||||
@ -951,9 +951,16 @@ TestFunc(put_vara)(VarArgs)
|
||||
IntType mid[MAX_RANK];
|
||||
double buf[MAX_NELS]; /* (void *) buffer */
|
||||
char *p; /* (void *) pointer */
|
||||
double value;
|
||||
double value = 0;
|
||||
ifdef(`PNETCDF', `MPI_Datatype datatype;')
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++ ) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
index[j] = 0;
|
||||
mid[j] = 0;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -993,7 +1000,7 @@ TestFunc(put_vara)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
}
|
||||
@ -1021,7 +1028,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVara(ncid, i, start, edge, buf, 1, datatype);
|
||||
@ -1037,9 +1044,9 @@ ifdef(`PNETCDF',`dnl
|
||||
edge[j] = 1;
|
||||
}
|
||||
/* Check correct error returned when nothing to put, when edge[*]==0 */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVara(ncid, i, start, edge, buf, 0, datatype);
|
||||
@ -1053,19 +1060,19 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
/* bits of k determine whether to put lower or upper part of dim */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1079,7 +1086,7 @@ ifdef(`PNETCDF',`dnl
|
||||
for (j = 0; j < nels; j++) {
|
||||
err = toMixedBase(j, var_rank[i], edge, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index[d] += start[d];
|
||||
value = hash(var_type[i], var_rank[i], index);
|
||||
if (!inRange(value, var_type[i]))
|
||||
@ -1135,6 +1142,17 @@ TestFunc(put_vars)(VarArgs)
|
||||
double value;
|
||||
ifdef(`PNETCDF', `MPI_Datatype datatype;')
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++ ) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
index[j] = 0;
|
||||
mid[j] = 0;
|
||||
index2[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
stride[j] = 1;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -1174,7 +1192,7 @@ TestFunc(put_vars)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
@ -1203,7 +1221,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == 0) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
|
||||
@ -1225,9 +1243,9 @@ ifdef(`PNETCDF',`dnl
|
||||
stride[j] = 1;
|
||||
}
|
||||
/* Check correct error returned even when nothing to put */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == 0) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVars(ncid, i, start, edge, stride, buf, 0, datatype);
|
||||
@ -1241,12 +1259,12 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1254,7 +1272,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* choose random stride from 1 to edge */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1270,15 +1288,15 @@ ifdef(`PNETCDF',`dnl
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
nels = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
nels *= count[j];
|
||||
index[j] += start[j];
|
||||
}
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
@ -1288,7 +1306,7 @@ ifdef(`PNETCDF',`dnl
|
||||
for (j = 0; j < nels; j++) {
|
||||
err = toMixedBase(j, var_rank[i], count, index2);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (d = 0; d < var_rank[i]; d++)
|
||||
for (d = 0; d < var_rank[i] && d < MAX_RANK; d++)
|
||||
index2[d] = index[d] + index2[d] * (IntType)stride[d];
|
||||
value = hash(var_type[i], var_rank[i], index2);
|
||||
if (!inRange(value, var_type[i]))
|
||||
@ -1352,6 +1370,18 @@ TestFunc(put_varm)(VarArgs)
|
||||
double value;
|
||||
ifdef(`PNETCDF', `MPI_Datatype datatype;')
|
||||
|
||||
for(j = 0; j < MAX_RANK; j++ ) {
|
||||
start[j] = 0;
|
||||
edge[j] = 0;
|
||||
index[j] = 0;
|
||||
mid[j] = 0;
|
||||
count[j] = 0;
|
||||
sstride[j] = 1;
|
||||
stride[j] = 1;
|
||||
imap[j] = 0;
|
||||
imap2[j] = 0;
|
||||
}
|
||||
|
||||
err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
|
||||
IF (err != NC_NOERR) {
|
||||
error("create: %s", APIFunc(strerror)(err));
|
||||
@ -1391,11 +1421,12 @@ TestFunc(put_varm)(VarArgs)
|
||||
|
||||
ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
start[j] = 0;
|
||||
edge[j] = 1;
|
||||
stride[j] = 1;
|
||||
imap[j] = 1;
|
||||
mid[j] = 1;
|
||||
}
|
||||
|
||||
ifdef(`PNETCDF',`dnl
|
||||
@ -1421,7 +1452,7 @@ ifdef(`PNETCDF',`dnl
|
||||
')dnl
|
||||
|
||||
/* first test when edge[*] > 0 */
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == 0) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
|
||||
@ -1443,9 +1474,9 @@ ifdef(`PNETCDF',`dnl
|
||||
stride[j] = 1;
|
||||
}
|
||||
/* Check correct error returned even when nothing to put */
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 0;
|
||||
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if (var_dimid[i][j] == 0) continue; /* skip record dim */
|
||||
start[j] = var_shape[i][j];
|
||||
err = PutVarm(ncid, i, start, edge, stride, imap, buf, 0, datatype);
|
||||
@ -1459,7 +1490,7 @@ ifdef(`PNETCDF',`dnl
|
||||
ELSE_NOK
|
||||
start[j] = 0;
|
||||
}
|
||||
for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) edge[j] = 1;
|
||||
|
||||
if (var_rank[i] > 0) {
|
||||
int jj = var_rank[i] - 1;
|
||||
@ -1484,7 +1515,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* Choose a random point dividing each dim into 2 parts */
|
||||
/* put 2^rank (nslabs) slabs so defined */
|
||||
nslabs = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
mid[j] = roll( var_shape[i][j] );
|
||||
nslabs *= 2;
|
||||
}
|
||||
@ -1492,7 +1523,7 @@ ifdef(`PNETCDF',`dnl
|
||||
/* choose random stride from 1 to edge */
|
||||
for (k = 0; k < nslabs; k++) {
|
||||
nstarts = 1;
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
if ((k >> j) & 1) {
|
||||
start[j] = 0;
|
||||
edge[j] = mid[j];
|
||||
@ -1511,14 +1542,14 @@ ifdef(`PNETCDF',`dnl
|
||||
} else {
|
||||
err = toMixedBase(m, var_rank[i], sstride, index);
|
||||
IF (err != 0) error("error in toMixedBase");
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
count[j] = 1 + (edge[j] - index[j] - 1) / ( (IntType)stride[j] == 0 ? 1 : (IntType)stride[j]);
|
||||
index[j] += start[j];
|
||||
}
|
||||
/* Random choice of forward or backward */
|
||||
/* TODO
|
||||
if ( roll(2) ) {
|
||||
for (j = 0; j < var_rank[i]; j++) {
|
||||
for (j = 0; j < var_rank[i] && j < MAX_RANK; j++) {
|
||||
index[j] += (count[j] - 1) * (IntType)stride[j];
|
||||
stride[j] = -stride[j];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user