plot '<(sed "" $PUGS_SOURCE_DIR/doc/writer-example2.gnu)' u 1:2 lw 2 t "f" w l, '<(sed "" $PUGS_SOURCE_DIR/doc/writer-example2.gnu)' u 1:3 lw 2 t "g" w l, '<(sed "" $PUGS_SOURCE_DIR/doc/writer-example2.gnu)' u 1:4 lw 2 t "sin(pi*f)" w l
#+END_SRC
#+CAPTION: Illustration of the life time of variables. The output for ~fh~ corresponds to its value when ~output_list~ is created: the interpolation of $x -> x$.
plot '<(sed "" $PUGS_SOURCE_DIR/doc/writer-example2-2.gnu)' u 1:2 lw 2 t "f" w l, '<(sed "" $PUGS_SOURCE_DIR/doc/writer-example2-2.gnu)' u 1:3 lw 2 t "g" w l
#+END_SRC
#+CAPTION: Illustration of the life time of variables. ~output_list~ is updated after ~fh~ has been updated.
#+NAME: fig:writer-example2-2
#+ATTR_LATEX: :width 0.38\textwidth
#+ATTR_HTML: :width 300px;
#+RESULTS: writer-example2-2-img
***** ~gnuplot~ writers <<gnuplot-writers>>
There is two ~gnuplot~ writers. One is dedicated to output of dimension
1 results (~gnuplot_1d_writer~) and the other allows post processing in
dimension 1 and 2 (~gnuplot_writer~).
Both of these writers can be used for single output or time series
output. In the case of single output, the filename is completed by
adding the extension ~.gnu~, in the case of time series, the filename is
extending by adding ~.abcd.gnu~, where ~abcd~ is the number of the output
in the series.
#+BEGIN_note
The ~gnuplot~ writers are implemented in parallel.
The ~gnuplot~ post processing of produced files is the same whichever is
the number of processors (as soon as the saved data is also the same,
which is warrantied by ~pugs~ for explicit methods).
#+END_note
For an obvious practical reason, each ~gnuplot~ file starts with a
preamble that indicates running information.
This information contains, the production date of the file. The ~pugs~
version (including the hash key of the last commit) and a summary of
the output data to easy its use. For ~gnuplot~ files, this is the
location where the provided name (to the discrete function) is used.
In the case of time series the "physical" time of output is also
stored as a comment before the variable list.
Here is an example of preamble of a produced ~gnuplot~ file.
plot '<(sed "" $PUGS_SOURCE_DIR/doc/gp_1d_sin.gnu)' lw 2 w lp
#+END_SRC
#+CAPTION: Example of produced gnuplot results from the ~gnuplot_1d_writer~. Since data are stored by growing abscissa, one can use the ~w lp~ plotting option in ~gnuplot~.
plot '<(sed "" $PUGS_SOURCE_DIR/doc/gp_sin.gnu)' lw 2 w lp
#+END_SRC
#+CAPTION: Example of produced gnuplot results from the ~gnuplot_writer~. One can compare ths produced result to the one of the ~gnuplot_1d_writer~ given on Figure [[fig:writer-gp-1d-sin]]
#+NAME: fig:writer-gp-sin
#+ATTR_LATEX: :width 0.38\textwidth
#+ATTR_HTML: :width 300px;
#+RESULTS: writer-gp-sin-img
Let use give a 2d example.
#+BEGIN_SRC pugs :exports both :results none
import mesh;
import scheme;
import writer;
import math;
let m:mesh, m = cartesianMesh(-[1,1], [1,1], (40,40));
let pi:R, pi = acos(-1);
let f:R^2 -> R, x -> cos(pi*x[0])*sin(pi*x[1]);
write(gnuplot_writer("gp_2d_cos_sin"),
name_output(interpolate(m,P0(), f), "f"));
#+END_SRC
The gnuplot result is displayed on Figure [[fig:writer-gp-2d-cos-sin]].