#!/usr/bin/perl
#
# Make a nice graph showing efficiency as a function of redshift
#   for each of the 3 fields.
#
# MWR 3/4/2007

$debug = 1;

$title = "Forced harmonic oscillator with k = 30 N/m, m = 2 kg, b = 2.0 N*s/m, F_d = 10 N ";
$cmdfile = "./forced_plot_a.gnu";
$psfile = "./forced_plot_a.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n ";
printf CMDFILE "set term postscript enhanced color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top right \n";
printf CMDFILE "set xlabel 'Driving angular frequency {/Symbol w}_d (rad/sec)'  \n";
printf CMDFILE "set ylabel 'Amplitude of motion (m)' \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [0.0:10.0][] ";
printf CMDFILE "  'forced_amp_a.out' using (\$2):(\$4) ";
printf CMDFILE "            t '' with linespoints pt 3 ps 0.5 ";
printf CMDFILE " \n";
printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;




exit 0;


##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


