Skip to content

Commit

Permalink
Replace use of C macro _FillValue with string "_FillValue"
Browse files Browse the repository at this point in the history
  • Loading branch information
wkliao committed Sep 15, 2024
1 parent dd3f54a commit db2a121
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/cases/e3sm_io_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,15 @@ int scorpio_write_var(e3sm_io_driver &driver,
#define PUT_ATTR_FILL(val) { \
if (varp->xType == NC_FLOAT) { \
float buf = (float)val; \
err = driver.put_att(ncid,varp->vid,_FillValue,varp->xType, 1, &buf); \
err = driver.put_att(ncid,varp->vid,"_FillValue",varp->xType,1,&buf); \
} \
else if (varp->xType == NC_INT) { \
int buf = (int)val; \
err = driver.put_att(ncid,varp->vid,_FillValue,varp->xType, 1, &buf); \
err = driver.put_att(ncid,varp->vid,"_FillValue",varp->xType,1,&buf); \
} \
else if (varp->xType == NC_DOUBLE) { \
double buf = (double)val; \
err = driver.put_att(ncid,varp->vid,_FillValue,varp->xType, 1, &buf); \
err = driver.put_att(ncid,varp->vid,"_FillValue",varp->xType,1,&buf); \
} \
CHECK_VAR_ERR(varp->_name) \
cmeta->num_attrs++; \
Expand Down Expand Up @@ -487,16 +487,16 @@ int scorpio_write_var(e3sm_io_driver &driver,
}
#define GET_ATTR_FILL(val) { \
if (varp->xType == NC_FLOAT) { \
err = driver.get_att(ncid,varp->vid,_FillValue,&val); \
err = driver.get_att(ncid,varp->vid,"_FillValue",&val); \
} \
else if (varp->xType == NC_INT) { \
int buf; \
err = driver.get_att(ncid,varp->vid,_FillValue,&buf); \
err = driver.get_att(ncid,varp->vid,"_FillValue",&buf); \
val = (float)buf; \
} \
else if (varp->xType == NC_DOUBLE) { \
double buf; \
err = driver.get_att(ncid,varp->vid,_FillValue,&buf); \
err = driver.get_att(ncid,varp->vid,"_FillValue",&buf); \
val = (float)buf; \
} \
CHECK_VAR_ERR(varp->_name) \
Expand Down
1 change: 0 additions & 1 deletion src/e3sm_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#define NC_NOERR 0 /**< No Error */
#define NC_GLOBAL -1
#define NC_UNLIMITED 0L
#define _FillValue "_FillValue"

typedef int nc_type;
#endif
Expand Down
6 changes: 3 additions & 3 deletions tests/icase_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ int main(int argc, char *argv[])
ERR \
if (xtype == NC_FLOAT) { \
float buf = (float)val; \
err = nc_put_att_float(ncid, varid, _FillValue, xtype, 1, &buf); \
err = nc_put_att_float(ncid, varid, "_FillValue", xtype, 1, &buf);\
} \
else if (xtype == NC_INT) { \
int buf = (int)val; \
err = nc_put_att_int(ncid, varid, _FillValue, xtype, 1, &buf); \
err = nc_put_att_int(ncid, varid, "_FillValue", xtype, 1, &buf); \
} \
else if (xtype == NC_DOUBLE) { \
double buf = (double)val; \
err = nc_put_att_double(ncid, varid, _FillValue, xtype, 1, &buf); \
err = nc_put_att_double(ncid, varid,"_FillValue", xtype, 1, &buf);\
} \
ERR \
}
Expand Down

0 comments on commit db2a121

Please sign in to comment.