diff --git a/gdb.txt b/gdb.txt index b58856a532..d87ae846b1 100644 --- a/gdb.txt +++ b/gdb.txt @@ -1,5 +1,10 @@ break main break do_ncdump -break annotate -break vardata.c:310 if 'vp->name == "land_tile_fractions"' +break vardata.c:484quit +break vardata.c:308 +command +print cor[vrank-1]+iel+1 +end + + run -f f -v land_tile_fractions gh181_check_me_out.nc diff --git a/ncdump/vardata.c b/ncdump/vardata.c index 620554df9a..483fc291d7 100644 --- a/ncdump/vardata.c +++ b/ncdump/vardata.c @@ -46,11 +46,11 @@ set_max_len(int len) { } -/* +/* * Output a string that should not be split across lines. If it would * make current line too long, first output a newline and current * (nested group) indentation, then continuation indentation, then - * output string. If string ends with a newline to force short line, + * output string. If string ends with a newline to force short line, * reset indentation after output. */ void @@ -98,19 +98,19 @@ lput2( /* chars); saved between calls */ int len_prefix = strlen (CDL_COMMENT_PREFIX); bool_t make_newline; - + size_t len1 = strlen(cp); /* length of input string */ assert (len1 > 0); /* (1) Single space or newline/indent sequence, as needed. */ - + linep = linep + 1 + len1; /* new line position, without newline */ /* add 1 extra for preceding space */ - + make_newline = (wrap && (first_item || linep > max_line_len + 2)); /* NEVER new line in no-wrap mode */ - + if (make_newline) { /* start new line, if needed */ printf ("\n"); indent_out(); /* same exact indentation as pr_att */ @@ -164,8 +164,8 @@ print_any_val( const void *valp /* pointer to the value */ ) { - if (varp->has_fillval && - (*(varp->tinfo->val_equals))((const nctype_t *)varp->tinfo, + if (varp->has_fillval && + (*(varp->tinfo->val_equals))((const nctype_t *)varp->tinfo, (const void*)varp->fillvalp, valp) ) { sbuf_cpy(sb, FILL_STRING); } else { @@ -235,7 +235,7 @@ pr_any_att_vals( sbuf_free(sb); } -/* +/* * Prints brief annotation for a row of data values */ static void @@ -243,7 +243,7 @@ annotate_brief( const ncvar_t *vp, /* variable */ const size_t *cor, /* corner coordinates */ size_t vdims[] /* variable dimension sizes */ - ) + ) { int vrank = vp->ndims; int id; @@ -290,7 +290,7 @@ annotate( { int vrank = vp->ndims; int id; - + /* print indices according to data_lang */ /* printf(" // %s(", vp->name); */ printf(" // "); @@ -409,7 +409,7 @@ upcorner( return ret; } -/* Print data values for variable varid. +/* Print data values for variable varid. * * Recursive to handle possibility of variables with multiple * unlimited dimensions, for which the CDL syntax requires use of "{" @@ -417,7 +417,7 @@ upcorner( * in a simple linear list of values. */ static int -print_rows( +print_rows( int level, /* 0 at top-level, incremented for each recursive level */ int ncid, /* netcdf id */ int varid, /* variable id */ @@ -427,7 +427,7 @@ print_rows( size_t edg[], /* edges of hypercube */ void *vals, /* allocated buffer for ncols values in a row */ int marks_pending /* number of pending closing "}" record markers */ - ) + ) { int rank = vp->ndims; size_t ncols = rank > 0 ? vdims[rank - 1] : 1; /* number of values in a row */ @@ -455,11 +455,11 @@ print_rows( local_cor[level] = 0; local_edg[level] = 1; for(i = 0; i < d0 - 1; i++) { - print_rows(level + 1, ncid, varid, vp, vdims, + print_rows(level + 1, ncid, varid, vp, vdims, local_cor, local_edg, vals, 0); local_cor[level] += 1; } - print_rows(level + 1, ncid, varid, vp, vdims, + print_rows(level + 1, ncid, varid, vp, vdims, local_cor, local_edg, vals, marks_pending); free(local_edg); free(local_cor); @@ -492,25 +492,25 @@ print_rows( /* determine if this is the last row */ lastrow = true; for(j = 0; j < rank - 1; j++) { - if (cor[j] != vdims[j] - 1) { + if (cor[j] != vdims[j] - 1) { lastrow = false; break; - } + } } if (formatting_specs.full_data_cmnts) { - for (j = 0; j < marks_pending; j++) { + for (j = 0; j < marks_pending; j++) { sbuf_cat(sb, "}"); - } - printf("%s", sbuf_str(sb)); - lastdelim (0, lastrow); - annotate (vp, cor, d0); + } + printf("%s", sbuf_str(sb)); + lastdelim (0, lastrow); + annotate (vp, cor, d0-1); } else { - for (j = 0; j < marks_pending; j++) { + for (j = 0; j < marks_pending; j++) { sbuf_cat(sb, "}"); - } - lput(sbuf_str(sb)); - lastdelim2 (0, lastrow); - } + } + lput(sbuf_str(sb)); + lastdelim2 (0, lastrow); + } } sbuf_free(sb); return NC_NOERR; @@ -578,7 +578,7 @@ vardata( } nrows = nels/ncols; /* number of "rows" */ vals = emalloc(ncols * vp->tinfo->size); - + NC_CHECK(print_rows(level, ncid, varid, vp, vdims, cor, edg, vals, marks_pending)); free(vals); free(cor); @@ -753,7 +753,7 @@ vardatax( } nrows = nels/ncols; /* number of "rows" */ vals = emalloc(ncols * vp->tinfo->size); - + for (ir = 0; ir < nrows; ir++) { size_t corsav = 0; bool_t lastrow; @@ -767,16 +767,16 @@ vardatax( edg[vrank-1] = ncols; NC_CHECK(nc_get_vara(ncid, varid, cor, edg, vals) ); /* Test if we should treat array of chars as a string */ - if(vp->type == NC_CHAR && + if(vp->type == NC_CHAR && (vp->fmt == 0 || STREQ(vp->fmt,"%s") || STREQ(vp->fmt,""))) { pr_tvalsx(vp, ncols, 0, lastrow, (char *) vals); } else { pr_any_valsx(vp, ncols, 0, lastrow, vals); } - + if (vrank > 0) cor[vrank-1] += ncols; - + if (vrank > 0) cor[vrank-1] = corsav; if (ir < nrows-1)