Skip to content

Commit f305dcf

Browse files
authored
Remove deprecated xy from grdimage's THIS_MODULE_OPTIONS and other fixes (#8257)
* Remove deprecated xy from grdimage's THIS_MODULE_OPTIONS That was the only plotting module that still had the old lower case xy in the MODULE OPTIONS list. We then added x for multicore, hence got 2 -x options to check and that yielded the trouble in #8256. This lead to more relevant fixes in grdfilter test scripts. * Handle -x in usage and synopsis * Update explain_core_full.rst_ * Restor GLIB check for windows
1 parent 24ae8e7 commit f305dcf

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

doc/rst/source/explain_core_full.rst_

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ The **-x** option
88

99
**Description**
1010

11-
The **-x** option limits the number of cores to be used in any OpenMP-enabled multi-threaded algorithms [default is to
12-
use all available cores]. Append *n* to only use *n* cores (if too large it will be truncated to the maximum cores
13-
available). Finally, give a negative *n* to select (all - *n*) cores (or at least 1 if *n* equals or exceeds all).
14-
The **-x** option is only available to GMT modules compiled with OpenMP support, with the exception of :doc:`/movie`
15-
and :doc:`/batch` which handle their own parallel execution.
11+
The **-x** option limits the number of cores to be used in any multi-threaded algorithms [default is to
12+
use all available cores]. Append *n* to only use *n* cores (if too large it will be truncated to the
13+
maximum cores available). Finally, give a negative *n* to select (all - *n*) cores (or at least 1 if *n*
14+
equals or exceeds all). **Note**: The **-x** option is only available to GMT modules compiled with OpenMP
15+
or Glib threads support, with the exception of :doc:`/movie` and :doc:`/batch` which handle their own
16+
parallel execution separately.

src/gmt_init.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -8137,10 +8137,12 @@ void gmtlib_explain_options (struct GMT_CTRL *GMT, char *options) {
81378137

81388138
#ifdef GMT_MP_ENABLED
81398139
case 'y': /* Number of threads (reassigned from -x in GMT_Option) */
8140-
cores = gmtlib_get_num_processors();
8141-
GMT_Usage (API, 1, "\n%s", GMT_x_OPT);
8142-
GMT_Usage (API, -2, "Limit the number of cores used in multi-threaded algorithms [Default uses all %d cores]. "
8143-
"If <n> is negative then we select (%d - <n>) cores (or at least 1).", cores, cores);
8140+
if (strlen (GMT_x_OPT) > 1) { /* Only print this if it is in fact available */
8141+
cores = gmtlib_get_num_processors();
8142+
GMT_Usage (API, 1, "\n%s", GMT_x_OPT);
8143+
GMT_Usage (API, -2, "Limit the number of cores used in multi-threaded algorithms [Default uses all %d cores]. "
8144+
"If <n> is negative then we select (%d - <n>) cores (or at least 1).", cores, cores);
8145+
}
81448146
break;
81458147
#endif
81468148
case 'Z': /* Vertical scaling for 3-D plots */

src/gmt_parse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,8 @@ int GMT_Parse_Common (void *V_API, const char *given_options, struct GMT_OPTION
11181118
if (strchr (critical_opt_order, given_options[i])) continue; /* Skip critical option */
11191119
list[0] = given_options[i]; /* Just look for this particular option */
11201120
for (opt = options; opt; opt = opt->next) {
1121-
n_errors += gmt_parse_common_options (API->GMT, list, opt->option, opt->arg);
11221121
if (opt->option != list[0]) continue;
1122+
n_errors += gmt_parse_common_options (API->GMT, list, opt->option, opt->arg);
11231123
}
11241124
}
11251125
if (GMT_Destroy_Options (API, &options)) {

src/gmt_synopsis.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
#define GMT_qo_OPT "-qo[~]<rows>|<limits>[,...][+c<col>][+a|t|s]"
5656
#define GMT_PAR_OPT "--PAR=<value>"
5757

58-
#ifdef GMT_MP_ENABLED
58+
#if defined(_OPENMP)
59+
/* Use these constants in modules only serviced by OpenMP; see gmt_glib.h for equivalent constants for Glib threads modules */
5960
#define GMT_x_OPT " [-x[[-]<n>]] " /* Must add spaces and brackets here and place via %s since it may be blank */
6061
#define GMT_ADD_x_OPT "x"
6162
#else /* No Open-MP support */

src/grdimage.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define THIS_MODULE_PURPOSE "Project and plot grids or images"
3535
#define THIS_MODULE_KEYS "<G{+,CC(,IG(,>X},>IA,<ID"
3636
#define THIS_MODULE_NEEDS "Jg"
37-
#define THIS_MODULE_OPTIONS "->BJKOPRUVXYfnptxy" GMT_OPT("Sc") GMT_ADD_x_OPT
37+
#define THIS_MODULE_OPTIONS "->BJKOPRUVXYfnpt" GMT_OPT("Sc") GMT_ADD_x_OPT
3838

3939
/* These are images that GDAL knows how to read for us. */
4040
#define N_IMG_EXTENSIONS 7

test/grdfilter/spikes.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ps=spikes.ps
66

77
if [[ ${HAVE_GLIB_GTHREAD} =~ TRUE|ON ]]; then
8-
_thread_opt=-x+a
8+
_thread_opt=-x+a
99
fi
1010

1111
filter () {

test/grdfilter/threads.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Testing gmt grdfilter if gthreads is enabled.
33
ps=threads.ps # Basically same as test openmp.sh but using GTHREAD
44

5-
if [ "X$(gmt-config --has-gthreads)" = "Xyes" ]; then
5+
if [[ ${HAVE_GLIB_GTHREAD} =~ TRUE|ON ]]; then
66
_thread_opt=-x+a
77
fi
88

0 commit comments

Comments
 (0)