diff --git a/doc/rst/source/grdtrack.rst b/doc/rst/source/grdtrack.rst index aa1e6312a08..64fd6a8441d 100644 --- a/doc/rst/source/grdtrack.rst +++ b/doc/rst/source/grdtrack.rst @@ -87,6 +87,7 @@ Required Arguments |-G| as many times as you have grids you wish to sample. Alternatively, use **-G+l**\ *list* to pass a file whose first word in the trailing text record will be extracted as the file names. + Note, this means that file must have at least one numeric column before the text holding the grid names. The grids are sampled and results are output in the order given. (See :ref:`Grid File Formats `). **Note**: If *gridfile* is a remote global grid and no registration is specified then **grdtrack** diff --git a/src/grdtrack.c b/src/grdtrack.c index 4d7a59f9c36..934e746f1c0 100644 --- a/src/grdtrack.c +++ b/src/grdtrack.c @@ -389,18 +389,23 @@ static int parse (struct GMT_CTRL *GMT, struct GRDTRACK_CTRL *Ctrl, struct GMT_O n_errors++; break; } - if ((c = strstr (opt->arg, "+l"))) { /* Gave +l */ + if ((c = strstr(opt->arg, "+l"))) { /* Gave +l */ char file[PATH_MAX] = {""}; struct GMT_DATASET *L = NULL; struct GMT_DATASEGMENT *S = NULL; uint64_t row; if (c[2] == '\0') { /* No list file given */ - GMT_Report (API, GMT_MSG_ERROR, "Option -G: No listfile appended after modifier +l\n"); + GMT_Report(API, GMT_MSG_ERROR, "Option -G: No listfile appended after modifier +l\n"); n_errors++; break; } - if ((L = GMT_Read_Data (API, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, &c[2], NULL)) == NULL) { - GMT_Report (API, GMT_MSG_WARNING, "Error reading list file %s\n", &c[2]); + if ((L = GMT_Read_Data(API, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL, NULL, &c[2], NULL)) == NULL) { + GMT_Report(API, GMT_MSG_WARNING, "Error reading list file %s\n", &c[2]); + n_errors++; + break; + } + if (L->table[0]->n_segments == 0) { + GMT_Report(API, GMT_MSG_WARNING, "The list file, %s, must have at least one numeric column before the grid names.\n", &c[2]); n_errors++; break; }