Skip to content

Commit

Permalink
fix the previous commit that missed the case of re-open file
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei-keng Liao committed Mar 29, 2017
1 parent 73ccb36 commit 1508bd5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion libsrc4/nc4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
hid_t pid = 0;
unsigned crt_order_flags = 0;
H5_index_t iter_index;
int retval = NC_NOERR; /* everything worked! */
int i, retval = NC_NOERR; /* everything worked! */

assert(grp && grp->name);
LOG((3, "%s: grp->name %s", __func__, grp->name));
Expand Down Expand Up @@ -2217,6 +2217,10 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
if ((retval = read_grp_atts(grp)))
BAIL(retval);

/* when exiting define mode, mark all variable written */
for (i=0; i<grp->vars.nelems; i++)
grp->vars.value[i]->written_to = NC_TRUE;

exit:
/* Clean up local information on error, if anything remains */
if (retval)
Expand Down
13 changes: 10 additions & 3 deletions nc_test4/tst_fill_attr_vanish.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
int main()
{
int ncid, dimids[RANK_P], time_id, p_id, test_id;
int ncid, dimids[RANK_P], time_id, p_id, test_id, status;
int ndims, dimids_in[RANK_P];

int test_data[1] = {1};
Expand Down Expand Up @@ -95,8 +95,15 @@ int main()

}

printf("**** Adding _FillValue attribute.\n");
if (nc_put_att_int(ncid, test_id, "_FillValue", NC_INT, 1, test_fill_val)) ERR;
printf("**** Expecting NC_ELATEFILL when adding _FillValue attribute if variable exists.\n");
status = nc_put_att_int(ncid, test_id, "_FillValue", NC_INT, 1, test_fill_val);
if (status != NC_ELATEFILL) {
fflush(stdout); /* Make sure our stdout is synced with stderr. */
err++;
fprintf(stderr, "Sorry! Expecting NC_ELATEFILL but got %s, at file %s line: %d\n",
nc_strerror(status), __FILE__, __LINE__);
return 2;
}

/* Query existing attribute. */
{
Expand Down

0 comments on commit 1508bd5

Please sign in to comment.