function pressure_gnuplot ( header, n, x, y, u, v, p, s )

%*****************************************************************************80
%
%% pressure_gnuplot() writes the Navier-Stokes pressure field to files for GNUPLOT.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 July 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string HEADER, a header to be used to name the files.
%
%    integer N, the number of evaluation points.
%
%    real X(N), Y(N), the coordinates of the evaluation points.
%
%    real U(N), V(N), P(N), the flow field samples.
%
%    real S, a scale factor for the velocity vectors.
%

%
%  Write the data file.
%
  data_filename = strcat ( 'pressure_', header, '_data.txt' );

  data_unit = fopen ( data_filename, 'wt' );

  yold = 99
  for i = 1 : n
    if ( yold ~= y(i) )
      fprintf ( data_unit, '\n' );
    end
    fprintf ( data_unit, '  %g  %g  %g\n', ...
      x(i), y(i), p(i) );
    yold = y(i);
  end

  fclose ( data_unit );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Data written to "%s".\n', data_filename );
%
%  Write the command file.
%
  command_filename = strcat ( 'pressure_', header, '_commands.txt' );
  plot_filename = strcat ( 'pressure_', header, '.png' );

  command_unit = fopen ( command_filename, 'wt' );

  fprintf ( command_unit, '#  %s\n', command_filename );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, 'set term png\n' );
  fprintf ( command_unit, 'set output "%s"\n', plot_filename );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, '#  Add titles and labels.\n' );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, 'set xlabel "<--- X --->"\n' );
  fprintf ( command_unit, 'set ylabel "<--- Y --->"\n' );
  fprintf ( command_unit, 'set title "%s pressure field"\n', header );
  fprintf ( command_unit, 'unset key\n' );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, '#  Add grid lines.\n' );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, 'set grid\n' );
  fprintf ( command_unit, 'unset surface\n' );
  fprintf ( command_unit, 'set size ratio -1\n' );
  fprintf ( command_unit, 'set contour base\n' );
  fprintf ( command_unit, 'set view map\n' );
  fprintf ( command_unit, 'set pm3d\n' );
  fprintf ( command_unit, 'splot "%s" with pm3d\n', data_filename );
  fprintf ( command_unit, 'quit\n' );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, '#  Timestamp the plot.\n' );
  fprintf ( command_unit, '#\n' );
  fprintf ( command_unit, 'set timestamp\n' );
  fprintf ( command_unit, 'quit\n' );

  fclose ( command_unit );

  fprintf ( 1, '  Commands written to "%s".\n', command_filename );

  return
end

