Skip to content

Commit 5cab3ef

Browse files
author
shanedsnyder
authored
Merge pull request #875 from wkliao/fix_start_ndx
fix index when ndims is large
2 parents 907750a + 4bb82cf commit 5cab3ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

darshan-runtime/lib/darshan-pnetcdf-api.m4

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ define(`CALC_VARA_ACCESS_INFO',
8787
if (ndims > PNETCDF_VAR_MAX_NDIMS)
8888
start_ndx = ndims - PNETCDF_VAR_MAX_NDIMS;
8989
for (i = start_ndx; i < ndims; i++) {
90-
common_access_vals[1+i] = count[i];
90+
common_access_vals[1+i-start_ndx] = count[i];
9191
}
9292
}
9393
else {
@@ -98,18 +98,19 @@ dnl
9898
define(`CALC_VARS_ACCESS_INFO',
9999
`int ndims = rec_ref->var_rec->counters[PNETCDF_VAR_NDIMS];
100100
if (ndims > 0) {
101-
int i, start_ndx = 0;
101+
int i, j, start_ndx = 0;
102102
$3 = count[0];
103103
for (i = 1; i < ndims; i++)
104104
$3 *= count[i];
105105
if (ndims > PNETCDF_VAR_MAX_NDIMS)
106106
start_ndx = ndims - PNETCDF_VAR_MAX_NDIMS;
107107
for (i = start_ndx; i < ndims; i++) {
108-
common_access_vals[1+i] = count[i];
108+
j = i - start_ndx;
109+
common_access_vals[1+j] = count[i];
109110
if (stride)
110-
common_access_vals[1+i+PNETCDF_VAR_MAX_NDIMS] = stride[i];
111+
common_access_vals[1+j+PNETCDF_VAR_MAX_NDIMS] = stride[i];
111112
else
112-
common_access_vals[1+i+PNETCDF_VAR_MAX_NDIMS] = 1;
113+
common_access_vals[1+j+PNETCDF_VAR_MAX_NDIMS] = 1;
113114
}
114115
}
115116
else {

0 commit comments

Comments
 (0)