From db2a121526a27a4a1059f280f8e2ae650d8dc811 Mon Sep 17 00:00:00 2001 From: wkliao Date: Sun, 15 Sep 2024 18:26:10 -0500 Subject: [PATCH] Replace use of C macro _FillValue with string "_FillValue" --- src/cases/e3sm_io_case.hpp | 12 ++++++------ src/e3sm_io.h | 1 - tests/icase_def.c | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cases/e3sm_io_case.hpp b/src/cases/e3sm_io_case.hpp index adfe85f0..1d4d356a 100644 --- a/src/cases/e3sm_io_case.hpp +++ b/src/cases/e3sm_io_case.hpp @@ -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++; \ @@ -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) \ diff --git a/src/e3sm_io.h b/src/e3sm_io.h index 09b0ce4c..cd348247 100644 --- a/src/e3sm_io.h +++ b/src/e3sm_io.h @@ -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 diff --git a/tests/icase_def.c b/tests/icase_def.c index 1ef7db53..ac8a7d16 100644 --- a/tests/icase_def.c +++ b/tests/icase_def.c @@ -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 \ }