From 929b5bd60b9a9eb7a70137d8ffa471f301c72342 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Sun, 17 Nov 2024 15:54:28 +0000 Subject: [PATCH] Fix the problem with -o and remote files. (#8621) Fixes #8620 --- src/gmt_init.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index eb64ab08142..0ada172ea07 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -16663,22 +16663,24 @@ void gmt_end_module (struct GMT_CTRL *GMT, struct GMT_CTRL *Ccopy) { without calling gmt_begin() again. This is need in externals that want to keep using the API contents between diferent module calls. */ - /* Reset default input column order */ - for (i = 0; i < GMT_MAX_COLUMNS; i++) - GMT->current.io.col[GMT_IN][i].col = GMT->current.io.col[GMT_IN][i].order = i; /* Default order */ - for (i = 0; i < GMT_MAX_COLUMNS; i++) GMT->current.io.col_skip[i] = false; /* Consider all input columns */ - /* Reset default output column order */ - for (i = 0; i < GMT_MAX_COLUMNS; i++) - GMT->current.io.col[GMT_OUT][i].col = GMT->current.io.col[GMT_OUT][i].order = i; /* Default order */ + /* Reset default input column order, but not too soon (#8620) */ + if (func_level_bak <= GMT_TOP_MODULE) { + for (i = 0; i < GMT_MAX_COLUMNS; i++) + GMT->current.io.col[GMT_IN][i].col = GMT->current.io.col[GMT_IN][i].order = i; /* Default order */ + for (i = 0; i < GMT_MAX_COLUMNS; i++) GMT->current.io.col_skip[i] = false; /* Consider all input columns */ + /* Reset default output column order */ + for (i = 0; i < GMT_MAX_COLUMNS; i++) + GMT->current.io.col[GMT_OUT][i].col = GMT->current.io.col[GMT_OUT][i].order = i; /* Default order */ + } for (i = 0; i < 2; i++) GMT->current.io.skip_if_NaN[i] = true; /* x/y must be non-NaN */ if (GMT->hidden.func_level == 0) /* Only when top-level module ends. Doesn't affect CLI but useful for externals */ - for (i = 0; i < 2; i++) gmt_set_column_type (GMT, GMT_IO, i, GMT_IS_UNKNOWN); /* Must be told [or find out] what x/y are */ - for (i = 2; i < GMT_MAX_COLUMNS; i++) gmt_set_column_type (GMT, GMT_IO, i, GMT_IS_FLOAT); /* Other columns default to floats */ - gmt_M_memset (GMT->current.io.col_set[GMT_X], GMT_MAX_COLUMNS, char); /* This is the initial state of input columns - all available to be changed by modules */ - gmt_M_memset (GMT->current.io.col_set[GMT_Y], GMT_MAX_COLUMNS, char); /* This is the initial state of output columns - all available to be changed by modules */ - gmt_M_memset (GMT->current.io.curr_rec, GMT_MAX_COLUMNS, double); /* Initialize current and previous records to zero */ - gmt_M_memset (GMT->current.io.prev_rec, GMT_MAX_COLUMNS, double); + for (i = 0; i < 2; i++) gmt_set_column_type(GMT, GMT_IO, i, GMT_IS_UNKNOWN); /* Must be told [or find out] what x/y are */ + for (i = 2; i < GMT_MAX_COLUMNS; i++) gmt_set_column_type(GMT, GMT_IO, i, GMT_IS_FLOAT); /* Other columns default to floats */ + gmt_M_memset(GMT->current.io.col_set[GMT_X], GMT_MAX_COLUMNS, char); /* This is the initial state of input columns - all available to be changed by modules */ + gmt_M_memset(GMT->current.io.col_set[GMT_Y], GMT_MAX_COLUMNS, char); /* This is the initial state of output columns - all available to be changed by modules */ + gmt_M_memset(GMT->current.io.curr_rec, GMT_MAX_COLUMNS, double); /* Initialize current and previous records to zero */ + gmt_M_memset(GMT->current.io.prev_rec, GMT_MAX_COLUMNS, double); GMT->current.io.record.data = GMT->current.io.curr_rec; /* Time periodicity column */ GMT->current.io.cycle_col = GMT_NOTSET;