Skip to content

Commit

Permalink
per #2547, support reading variable that corresponds to dimension wit…
Browse files Browse the repository at this point in the history
…h different name as dimension and includes a time dimension, e.g. P_PL(Time, num_press_levels_stag)
  • Loading branch information
georgemccabe committed Jan 10, 2024
1 parent ff1acd9 commit a0a53a8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/libcode/vx_nc_util/nc_var_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,18 @@ NcVarInfo *find_var_info_by_dim_name(NcVarInfo *vars, const string dim_name,
}
}

// if dimension variable is not found, find variable that has only dim_name or dim_name and time
int dim_offset = 0;
if (!var) {
//StringArray dim_names;
for (int i=0; i<nvars; i++) {
if (1 == vars[i].Ndims) {
//dim_names.clear();
//get_dim_names(vars[i].var, &dim_names);
NcDim dim = get_nc_dim(vars[i].var, 0);
if (IS_VALID_NC(dim) && GET_NC_NAME(dim) == dim_name) {
var = &vars[i];
break;
}
if (vars[i].Ndims > 2) continue;
dim_offset = vars[i].Ndims == 2 ? 1 : 0;
NcDim dim = get_nc_dim(vars[i].var, dim_offset);
if (IS_VALID_NC(dim) && GET_NC_NAME(dim) == dim_name) {
var = &vars[i];
break;
}

}
}

Expand Down

0 comments on commit a0a53a8

Please sign in to comment.