Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set correct dimension when finding 3- or 4-D array #6615

Merged
merged 2 commits into from
Apr 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 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 Expand Up @@ -1982,6 +1984,7 @@ int gmt_nc_read_cube_info (struct GMT_CTRL *GMT, char *file, double *w_range, ui
return GMT_GRDIO_NO_2DVAR;
}
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_WARNING, "No 3-D array in file %s. Selecting first 3-D slice in the %d-D array %s\n", file, dim, varname);
}
Expand Down