Skip to content

Commit

Permalink
set correct dimension when finding 3- or 4-D array
Browse files Browse the repository at this point in the history
While we correctly found a higher-dimensioned array than 2, we forgot to update ndims once selecting it.
Closes #6588.
  • Loading branch information
PaulWessel committed Apr 23, 2022
1 parent 526514a commit 5bc6137
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gmt_nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head
if (z_id < 0) { /* No 2-D grid found, check if we found a higher dimension cube */
if (ID == GMT_NOTSET) return (GMT_GRDIO_NO_2DVAR); /* No we didn't */
z_id = ID; /* Pick the higher dimensioned cube instead, get its name, and warn */
ndims = dim; /* Recall the dimensions of this ID */
nc_inq_varname (ncid, z_id, HH->varname);
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "No 2-D array in file %s. Selecting first 2-D slice in the %d-D array %s\n", HH->name, dim, HH->varname);
}
Expand Down Expand Up @@ -1557,6 +1558,7 @@ int gmtlib_is_nc_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header) {
if (z_id < 0) { /* No 2-D grid found, check if we found a higher dimension cube */
if (ID == GMT_NOTSET) return (GMT_GRDIO_NO_2DVAR); /* No we didn't */
z_id = ID; /* Pick the higher dimensioned cube instead, get its name, and warn */
ndims = dim; /* Recall the dimensions of this ID */
nc_inq_varname (ncid, z_id, varname);
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "No 2-D array in file %s. Selecting first 2-D slice in the %d-D array %s\n", HH->name, dim, varname);
}
Expand Down

0 comments on commit 5bc6137

Please sign in to comment.