Skip to content

Commit

Permalink
#2763 Handle a variable without dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Oct 8, 2024
1 parent 693ad84 commit b22381e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/libcode/vx_nc_util/nc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,8 @@ bool get_nc_data_ptr(NcVar *var, float *data) {
// Note: missing data was checked here
//
int type_id = GET_NC_TYPE_ID_P(var);
int cell_count = get_data_size(var);
if (cell_count== 0) cell_count = 1; // in case of a variable without dimension, for example, "float t ;"
// Handle the variable without dimension, for example, "float t ;"
int cell_count = (0 == get_dim_count(var)) ? 1 : get_data_size(var);

return_status = true;
if (NcType::nc_FLOAT == type_id) {
Expand Down Expand Up @@ -1570,8 +1570,8 @@ bool get_nc_data_ptr(NcVar *var, double *data) {
//
int unpacked_count = 0;
int type_id = GET_NC_TYPE_ID_P(var);
int tmp_count = get_data_size(var);
const int cell_count = (tmp_count==0) ? 1 : tmp_count; // in case of a variable without dimension, for example, "double t ;"
// Handle the variable without dimension, for example, "double t ;"
const int cell_count = (0 == get_dim_count(var)) ? 1 : get_data_size(var);

return_status = true;
if (NcType::nc_DOUBLE == type_id) {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/other/point2grid/point2grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,8 @@ static unixtime find_valid_time(NcVar time_var) {
static const char *method_name = "find_valid_time() -> ";

if( IS_VALID_NC(time_var) || get_dim_count(&time_var) < 2) {
int time_count = get_dim_size(&time_var, 0);
// Handle the variable without dimension
int time_count = (0 == get_dim_count(&time_var)) ? 1 : get_dim_size(&time_var, 0);

vector<double> time_values(time_count+1);
if (get_nc_data(&time_var, time_values)) {
Expand Down

0 comments on commit b22381e

Please sign in to comment.