diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index 05d63fc77..08434c1ea 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -1374,8 +1374,13 @@ bool get_nc_data_ptr(NcVar *var, float *data) { // Note: missing data was checked here // int type_id = GET_NC_TYPE_ID_P(var); - // Handle the variable without dimension, for example, "float t ;" - int cell_count = (0 == get_dim_count(var)) ? 1 : get_data_size(var); + int cell_count = get_data_size(var); + if (cell_count <= 0) { + mlog << Warning << "\n\n" << method_name + << " Adjusted the data size to 1 (was " << cell_count << ") of the variable \"" + << GET_NC_NAME_P(var) << "\"\n\n"; + cell_count = 1; + } return_status = true; if (NcType::nc_FLOAT == type_id) { @@ -1570,8 +1575,13 @@ bool get_nc_data_ptr(NcVar *var, double *data) { // int unpacked_count = 0; int type_id = GET_NC_TYPE_ID_P(var); - // Handle the variable without dimension, for example, "double t ;" - const int cell_count = (0 == get_dim_count(var)) ? 1 : get_data_size(var); + int cell_count = get_data_size(var); + if (cell_count <= 0) { + mlog << Warning << "\n\n" << method_name + << " Adjusted the data size to 1 (was " << cell_count << ") of the variable \"" + << GET_NC_NAME_P(var) << "\"\n\n"; + cell_count = 1; + } return_status = true; if (NcType::nc_DOUBLE == type_id) { diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 500a6144f..1ec524cc9 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -2251,7 +2251,8 @@ static unixtime find_valid_time(NcVar time_var) { if( IS_VALID_NC(time_var) || get_dim_count(&time_var) < 2) { // Handle the variable without dimension - int time_count = (0 == get_dim_count(&time_var)) ? 1 : get_dim_size(&time_var, 0); + int time_count = get_dim_size(&time_var, 0); + if (time_count == 0) time_count = get_data_size(&time_var); vector time_values(time_count+1); if (get_nc_data(&time_var, time_values)) {