mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
To solve NC_ELATEFILL error for NetCDF-4 files, mark all variables written at enddef.
This commit is contained in:
parent
d0d1a69826
commit
73ccb364a9
@ -47,7 +47,7 @@ EXTRA_DIST = attr.m4 ncx.m4 putget.m4 $(man_MANS) CMakeLists.txt XGetopt.c
|
||||
|
||||
# This tells make how to turn .m4 files into .c files.
|
||||
.m4.c:
|
||||
m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >${srcdir}/$@
|
||||
m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< > $@
|
||||
|
||||
# The C API man page.
|
||||
man_MANS = netcdf.3
|
||||
|
@ -2984,6 +2984,8 @@ static int NC4_enddef(int ncid)
|
||||
{
|
||||
NC *nc;
|
||||
NC_HDF5_FILE_INFO_T* nc4_info;
|
||||
NC_GRP_INFO_T *grp;
|
||||
int i;
|
||||
|
||||
LOG((1, "%s: ncid 0x%x", __func__, ncid));
|
||||
|
||||
@ -2991,6 +2993,14 @@ static int NC4_enddef(int ncid)
|
||||
return NC_EBADID;
|
||||
assert(nc4_info);
|
||||
|
||||
/* Find info for this file and group */
|
||||
if (!(grp = nc4_rec_find_grp(nc4_info->root_grp, (ncid & GRP_ID_MASK))))
|
||||
return NC_EBADGRPID;
|
||||
|
||||
/* when exiting define mode, mark all variable written */
|
||||
for (i=0; i<grp->vars.nelems; i++)
|
||||
grp->vars.value[i]->written_to = NC_TRUE;
|
||||
|
||||
return nc4_enddef_netcdf4_file(nc4_info);
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,17 @@ main(int argc, char **argv)
|
||||
|
||||
printf("**** testing simple fill value attribute creation...");
|
||||
{
|
||||
int status;
|
||||
/* Create a netcdf-4 file with one scalar var. Add fill
|
||||
* value. */
|
||||
if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_BYTE, 0, NULL, &varid)) ERR;
|
||||
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
|
||||
status = nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value);
|
||||
if (status != NC_ELATEFILL)
|
||||
printf("Error at line %d: expecting NC_ELATEFILL but got %s\n",__LINE__,nc_strerror(status));
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and check. */
|
||||
@ -94,8 +98,6 @@ main(int argc, char **argv)
|
||||
if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_BYTE, NUM_DIMS, dimids, &varid)) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user