Skip to content

Commit 9018c41

Browse files
committed
Use "_FillValue" and avoid using C macro _FillValue or NC_FillValue
This is to conform with NetCDF4's header, netcdf.hs, changed in 4.9.3. See Unidata/netcdf-c#2911
1 parent c920993 commit 9018c41

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

src/dispatchers/attr_getput.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ sanity_check_put(PNC *pncp,
6464

6565
#ifdef NO_NC_GLOBAL_FILLVALUE
6666
/* See r3403 and RELEASE_NOTES 1.9.0 */
67-
if (varid == NC_GLOBAL && !strcmp(name, _FillValue))
68-
DEBUG_RETURN_ERROR(NC_EGLOBAL) /* global _FillValue is not allowed */
67+
if (varid == NC_GLOBAL && !strcmp(name, "_FillValue"))
68+
DEBUG_RETURN_ERROR(NC_EGLOBAL) /* global "_FillValue" is not allowed */
6969
#endif
7070

7171
if (strlen(name) > NC_MAX_NAME) /* name length */

src/dispatchers/variable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ ncmpi_def_var_fill(int ncid, /* IN: file ID */
256256
}
257257

258258
if (varid == NC_GLOBAL) {
259-
/* setting global _FillValue through this API is not allowed */
259+
/* setting global attribute _FillValue through this API is not allowed */
260260
DEBUG_ASSIGN_ERROR(err, NC_EGLOBAL)
261261
goto err_check;
262262
}

src/drivers/ncmpio/ncmpio_attr.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ ncmpio_put_att(void *ncdp,
983983
/* If this is attribute _FillValue, then let PnetCDF return the
984984
* same error codes as netCDF
985985
*/
986-
if (varid != NC_GLOBAL && !strcmp(name, NC_FillValue)) {
986+
if (varid != NC_GLOBAL && !strcmp(name, "_FillValue")) {
987987
/* Fill value must be of the same data type */
988988
if (xtype != ncp->vars.value[varid]->xtype) {
989989
DEBUG_ASSIGN_ERROR(err, NC_EBADTYPE)

src/drivers/ncmpio/ncmpio_fill.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fill_var_buf(const NC_var *varp,
9393
{
9494
int i, indx;
9595

96-
indx = ncmpio_NC_findattr(&varp->attrs, _FillValue);
96+
indx = ncmpio_NC_findattr(&varp->attrs, "_FillValue");
9797
if (indx >= 0) {
9898
/* User defined fill value */
9999
NC_attr *attrp = varp->attrs.value[indx];
@@ -280,12 +280,12 @@ fillerup(NC *ncp)
280280
* explicitly filled by calling ncmpi_fill_var_rec() */
281281
continue;
282282

283-
/* check if _FillValue attribute is defined */
284-
indx = ncmpio_NC_findattr(&ncp->vars.value[i]->attrs, _FillValue);
283+
/* check if attribute _FillValue is defined */
284+
indx = ncmpio_NC_findattr(&ncp->vars.value[i]->attrs, "_FillValue");
285285

286286
/* only if filling this variable is requested. Fill mode can be
287287
* enabled by 2 ways: explictly call to ncmpi_def_var_fill() or put
288-
* the attribute named _FillValue */
288+
* the attribute named "_FillValue" */
289289
if (ncp->vars.value[i]->no_fill && indx == -1) continue;
290290

291291
/* collectively fill the entire variable */
@@ -309,8 +309,8 @@ fill_added(NC *ncp, NC *old_ncp)
309309
/* skip record variables */
310310
continue;
311311

312-
/* check if _FillValue attribute is defined */
313-
indx = ncmpio_NC_findattr(&ncp->vars.value[varid]->attrs, _FillValue);
312+
/* check if attribute _FillValue is defined */
313+
indx = ncmpio_NC_findattr(&ncp->vars.value[varid]->attrs, "_FillValue");
314314

315315
/* only if filling this variable is requested */
316316
if (ncp->vars.value[varid]->no_fill && indx == -1) continue;
@@ -338,8 +338,8 @@ fill_added_recs(NC *ncp, NC *old_ncp)
338338
/* skip non-record variables */
339339
continue;
340340

341-
/* check if _FillValue attribute is defined */
342-
indx = ncmpio_NC_findattr(&ncp->vars.value[varid]->attrs, _FillValue);
341+
/* check if attribute _FillValue is defined */
342+
indx = ncmpio_NC_findattr(&ncp->vars.value[varid]->attrs, "_FillValue");
343343

344344
/* only if filling this variable is requested */
345345
if (ncp->vars.value[varid]->no_fill && indx == -1) continue;
@@ -725,8 +725,8 @@ ncmpio_fill_var_rec(void *ncdp,
725725
goto err_check;
726726
}
727727

728-
/* check if _FillValue attribute is defined */
729-
indx = ncmpio_NC_findattr(&varp->attrs, _FillValue);
728+
/* check if attribute _FillValue is defined */
729+
indx = ncmpio_NC_findattr(&varp->attrs, "_FillValue");
730730

731731
/* error if the fill mode of this variable is not on */
732732
if (varp->no_fill && indx == -1) {
@@ -891,7 +891,7 @@ ncmpio_def_var_fill(void *ncdp,
891891
if (fill_value != NULL && !varp->no_fill) {
892892

893893
/* create/overwrite attribute _FillValue */
894-
err = ncmpio_put_att(ncdp, varid, _FillValue, varp->xtype,
894+
err = ncmpio_put_att(ncdp, varid, "_FillValue", varp->xtype,
895895
1, fill_value, ncmpii_nc2mpitype(varp->xtype));
896896
if (err != NC_NOERR) return err;
897897
}
@@ -911,9 +911,9 @@ ncmpio_inq_var_fill(NC_var *varp,
911911

912912
assert(varp != NULL); /* NC_GLOBAL varid is illegal in this context */
913913

914-
/* Check if _FillValue is defined for this variable */
914+
/* Check if attribute _FillValue is defined for this variable */
915915
for (i=0; i<ncap->ndefined; i++) {
916-
if (strcmp(ncap->value[i]->name, _FillValue) == 0)
916+
if (strcmp(ncap->value[i]->name, "_FillValue") == 0)
917917
break;
918918
}
919919
if (i == ncap->ndefined) { /* attribute _FillValue is not set */

src/utils/ncmpidump/ncmpidump.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,18 @@ do_ncdump(const char *path, struct fspec* specp)
538538

539539
var.has_fillval = 1; /* by default, but turn off for bytes */
540540

541-
/* get _FillValue attribute */
542-
ncmpi_status = ncmpi_inq_att(ncid, varid, _FillValue,
541+
/* get attribute _FillValue */
542+
ncmpi_status = ncmpi_inq_att(ncid, varid, "_FillValue",
543543
&att.type, &att.len);
544544
if (ncmpi_status == NC_NOERR &&
545545
att.type == var.type && att.len == 1) {
546546
if (var.type == NC_CHAR) {
547547
char fillc;
548-
NC_CHECK(ncmpi_get_att_text(ncid, varid, _FillValue,
548+
NC_CHECK(ncmpi_get_att_text(ncid, varid, "_FillValue",
549549
&fillc));
550550
var.fillval = fillc;
551551
} else
552-
NC_CHECK(ncmpi_get_att_double(ncid, varid, _FillValue,
552+
NC_CHECK(ncmpi_get_att_double(ncid, varid, "_FillValue",
553553
&var.fillval));
554554
} else {
555555
switch (var.type) {

src/utils/ncmpigen/ncmpigen.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,13 +1221,13 @@ void equalatt(void)
12211221
/* shrink space down to what was really needed */
12221222
att_space = erealloc(att_space, valnum*nctypesize(valtype));
12231223
atts[natts].val = att_space;
1224-
if (STREQ(atts[natts].name, _FillValue) &&
1224+
if (STREQ(atts[natts].name, "_FillValue") &&
12251225
atts[natts].var != NC_GLOBAL) {
12261226
nc_putfill(atts[natts].type,atts[natts].val,
12271227
&vars[atts[natts].var].fill_value);
12281228
if(atts[natts].type != vars[atts[natts].var].type) {
12291229
derror("variable %s: %s type mismatch",
1230-
vars[atts[natts].var].name, _FillValue);
1230+
vars[atts[natts].var].name, "_FillValue");
12311231
}
12321232
}
12331233
natts++;

src/utils/ncmpigen/ncmpigentab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,13 @@ void equalatt(void)
483483
/* shrink space down to what was really needed */
484484
att_space = erealloc(att_space, valnum*nctypesize(valtype));
485485
atts[natts].val = att_space;
486-
if (STREQ(atts[natts].name, _FillValue) &&
486+
if (STREQ(atts[natts].name, "_FillValue") &&
487487
atts[natts].var != NC_GLOBAL) {
488488
nc_putfill(atts[natts].type,atts[natts].val,
489489
&vars[atts[natts].var].fill_value);
490490
if(atts[natts].type != vars[atts[natts].var].type) {
491491
derror("variable %s: %s type mismatch",
492-
vars[atts[natts].var].name, _FillValue);
492+
vars[atts[natts].var].name, "_FillValue");
493493
}
494494
}
495495
natts++;

test/nc_test/t_nc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static const char * const reqattr[] = {
151151
"SCALEMIN",
152152
"SCALEMAX",
153153
"FIELDNAM",
154-
_FillValue
154+
"_FillValue"
155155
};
156156
#define NUM_RATTRS 6
157157

@@ -359,8 +359,8 @@ int t_nc(char *filename, int cmode)
359359

360360
{
361361
int ifill = -1; double dfill = -9999;
362-
err = ncmpi_put_att_int(id, Long_id, _FillValue, NC_INT, 1, &ifill); ERR
363-
err = ncmpi_put_att_double(id, Double_id, _FillValue, NC_DOUBLE, 1, &dfill); ERR
362+
err = ncmpi_put_att_int(id, Long_id, "_FillValue", NC_INT, 1, &ifill); ERR
363+
err = ncmpi_put_att_double(id, Double_id, "_FillValue", NC_DOUBLE, 1, &dfill); ERR
364364
}
365365

366366
#ifdef REDEF

0 commit comments

Comments
 (0)