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

Fixes for #8677 #8678

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -12716,28 +12716,32 @@ int gmt_BC_init (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *h) {
}
else { /* Determine BC based on whether grid is geographic or not */
type = (gmt_M_x_is_lon (GMT, GMT_IN)) ? GMT_BC_IS_GEO : GMT_BC_IS_NATURAL;
for (i = 0; i < 4; i++) if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = type;
for (i = 0; i < 4; i++)
if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = type;
}

/* Check if geographic conditions can be used with this grid */
if (HH->gn && !gmt_grd_is_global (GMT, h)) {
/* User has requested geographical conditions, but grid is not global */
GMT_Report (GMT->parent, GMT_MSG_WARNING, "Longitude range too small; geographic boundary condition changed to natural.\n");
GMT_Report(GMT->parent, GMT_MSG_INFORMATION, "Longitude range too small; geographic boundary condition changed to natural.\n");
HH->nxp = HH->nyp = 0;
HH->gn = HH->gs = false;
for (i = 0; i < 4; i++) if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = GMT_BC_IS_NATURAL;
for (i = 0; i < 4; i++)
if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = GMT_BC_IS_NATURAL;
}
else if (gmt_grd_is_global (GMT, h)) { /* Grid is truly global */
double xtest = fmod (180.0, h->inc[GMT_X]) * HH->r_inc[GMT_X];
GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Grid is considered to have a 360-degree longitude range.\n");
if (GMT->parent->ignore_BC) xtest = 0.0; /* To bypass the checks below */
/* xtest should be within GMT_CONV4_LIMIT of zero or of one. */
if (xtest > GMT_CONV4_LIMIT && xtest < (1.0 - GMT_CONV4_LIMIT) && GMT->current.proj.projection_GMT == 0) {
/* Maybe error. We need it to divide into 180 so we can phase-shift at poles but not if we already projected the grid to Cartesian. */
/* Maybe error. We need it to divide into 180 so we can phase-shift at poles but not if we
already projected the grid to Cartesian. */
GMT_Report (GMT->parent, GMT_MSG_WARNING, "x_inc does not divide 180; geographic boundary condition changed to natural.\n");
HH->nxp = HH->nyp = 0;
HH->gn = HH->gs = false;
for (i = 0; i < 4; i++) if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = GMT_BC_IS_NATURAL;
for (i = 0; i < 4; i++)
if (HH->BC[i] == GMT_BC_IS_NOTSET) HH->BC[i] = GMT_BC_IS_NATURAL;
}
else {
HH->nxp = urint (360.0 * HH->r_inc[GMT_X]);
Expand Down
29 changes: 15 additions & 14 deletions src/seis/grdvs30.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static int parse (struct GMT_CTRL *GMT, struct VS30_CTRL *Ctrl, struct GMT_Z_IO

unsigned int n_errors = 0, n_files = 0;
char p[GMT_LEN16] = {""}, *pch;
float t;
struct GMT_OPTION *opt = NULL;
struct GMTAPI_CTRL *API = GMT->parent;

Expand All @@ -186,21 +187,19 @@ static int parse (struct GMT_CTRL *GMT, struct VS30_CTRL *Ctrl, struct GMT_Z_IO
if ((pch = strstr(opt->arg, "+g")) != NULL)
Ctrl->C.is_grid = true; /* Useless if Ctrl->C.file = NULL is set below */

if (!gmt_check_filearg (GMT, 'C', Ctrl->C.file, GMT_IN, GMT_IS_DATASET)) {
t = atof(opt->arg);
if (t >= 0 && t <= 1) {
Ctrl->C.val = t;
Ctrl->C.file = NULL;
Ctrl->C.val = atof (opt->arg);
if (Ctrl->C.val < 0 || Ctrl->C.val > 1) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Errorn in -C. Must provide either a file name or a value in the [0 1] interval.\n", p);
n_errors++;
}
}
else if (!gmt_check_filearg(GMT, 'C', Ctrl->C.file, GMT_IN, GMT_IS_DATASET)) {
GMT_Report(GMT->parent, GMT_MSG_NORMAL, "Errorn in -C. Must provide either a file name or a value in the [0 1] interval.\n", p);
n_errors++;
}
break;
case 'G': /* Output file */
n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active);
if (!gmt_check_filearg (GMT, 'G', opt->arg, GMT_OUT, GMT_IS_GRID))
Ctrl->G.file = strdup (opt->arg);
else
n_errors++;
n_errors += gmt_M_repeated_module_option(API, Ctrl->G.active);
n_errors += gmt_get_required_file(GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->G.file));
break;
case 'W':
Ctrl->W.water = (float)atof (opt->arg);
Expand All @@ -211,7 +210,7 @@ static int parse (struct GMT_CTRL *GMT, struct VS30_CTRL *Ctrl, struct GMT_Z_IO
}
}

n_errors += gmt_M_check_condition (GMT, !Ctrl->G.file, "Syntax error -G option: Must specify output grid file\n");
n_errors += gmt_M_check_condition (GMT, !Ctrl->G.active, "Syntax error -G option: Must specify output grid file\n");
n_errors += gmt_M_check_condition (GMT, !Ctrl->C.active, "Syntax error -C option: Must specify a value or a file name.\n");

return (n_errors ? GMT_PARSE_ERROR : GMT_NOERROR);
Expand Down Expand Up @@ -260,7 +259,9 @@ EXTERN_MSC int GMT_grdvs30 (void *V_API, int mode, void *args) {
uint64_t ij;
int error = 0;
char cmd[GMT_LEN256] = {""};
char crat_grd[GMT_LEN16] = {""}, mask_grd[GMT_LEN16] = {""}, grad_grd[GMT_LEN16] = {""};
char crat_grd[GMT_LEN32] = {""}, mask_grd[GMT_LEN32] = {""}, grad_grd[GMT_LEN32] = {""};
/*
*/
float crat, lg;
double (*table)[4], tvs[2], vv, wesn[4];

Expand Down Expand Up @@ -312,7 +313,7 @@ EXTERN_MSC int GMT_grdvs30 (void *V_API, int mode, void *args) {
Return (API->error);

/* Prepare the grdlandmask arguments */
sprintf (cmd, "-G%s -I%f/%f -Df -R%.16g/%.16g/%.16g/%.16g --GMT_HISTORY=false ",
sprintf (cmd, "-G%s -I%.16g/%.16g -Df -R%.16g/%.16g/%.16g/%.16g --GMT_HISTORY=false ",
mask_grd, G->header->inc[GMT_X], G->header->inc[GMT_Y], wesn[XLO], wesn[XHI], wesn[YLO], wesn[YHI]);

GMT_Report (API, GMT_MSG_LONG_VERBOSE, "Calling grdlandmask with args %s\n", cmd);
Expand Down
Loading