From eb51bc90f73a3eae913a7b3f4c2a3f5ca211e9aa Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Thu, 10 Oct 2024 15:21:10 -0700 Subject: [PATCH] Add save_files_only option to the gnuplot command. The .plt and .data files are saved but gnuplot is not invoked. For example: gnuplot name save_files_only plotargs --- src/frontend/plotting/gnuplot.c | 7 ++++++- src/frontend/plotting/gnuplot.h | 2 +- src/frontend/plotting/plotit.c | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/frontend/plotting/gnuplot.c b/src/frontend/plotting/gnuplot.c index 27f727947..e24e14778 100644 --- a/src/frontend/plotting/gnuplot.c +++ b/src/frontend/plotting/gnuplot.c @@ -257,7 +257,7 @@ void ft_gnuplot(double *xlims, double *ylims, const char *filename, const char *title, const char *xlabel, const char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, - struct dvec *vecs, bool xycontour) + struct dvec *vecs, bool xycontour, bool save_files_only) { FILE *file, *file_data; struct dvec *v, *scale = NULL; @@ -645,6 +645,11 @@ void ft_gnuplot(double *xlims, double *ylims, (void) sprintf(buf, "gnuplot -persist %s &", filename_plt); } #endif + if (save_files_only) { + printf("Saving gnuplot plt file %s\n", filename_plt); + printf("Saving gnuplot data file %s\n", filename_data); + return; + } err = system(buf); /* delete the plt and data files */ diff --git a/src/frontend/plotting/gnuplot.h b/src/frontend/plotting/gnuplot.h index 0fe5194e6..44ad6e6e1 100644 --- a/src/frontend/plotting/gnuplot.h +++ b/src/frontend/plotting/gnuplot.h @@ -11,7 +11,7 @@ void ft_gnuplot(double *xlims, double *ylims, const char *filename, const char *title, const char *xlabel, const char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, - struct dvec *vecs, bool xycontour); + struct dvec *vecs, bool xycontour, bool save_files_only); void ft_writesimple(double *xlims, double *ylims, diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 449b0fec1..1a207c185 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -288,6 +288,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname) static PLOTTYPE ptype = PLOT_LIN; bool gfound = FALSE, pfound = FALSE, oneval = FALSE, contour2d = FALSE, digitop = FALSE; + bool save_files_only = FALSE; double ylims[2], xlims[2]; struct pnode *pn, *names = NULL; struct dvec *d = NULL, *vecs = NULL, *lv = NULL, *lastvs = NULL; @@ -364,6 +365,11 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname) /* See if contours for 2D Cider data can be plotted with gnuplot */ contour2d = getflag(wl, "xycontour"); + /* save_files_only to save gnuplot plt and data files without plotting */ + if (devname && eq(devname, "gnuplot")) { + save_files_only = getflag(wl, "save_files_only"); + } + /* Now extract all the parameters. */ digitop = getflag(wl, "digitop"); @@ -1208,7 +1214,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname) title ? title : vecs->v_plot->pl_title, xlabel ? xlabel : ft_typabbrev(vecs->v_scale->v_type), ylabel ? ylabel : ft_typabbrev(y_type), - gtype, ptype, vecs, contour2d); + gtype, ptype, vecs, contour2d, save_files_only); rtn = TRUE; goto quit; }