#!/usr/bin/perl
#

  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "my_osc_1.ps";
  $term_options = "postscript color font 'Helvectica,18";

  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set nokey \n";
  printf CMDFILE "set ylabel 'position above center of Earth (meters)' \n";
  printf CMDFILE "set xlabel 'time (seconds)' \n";
  printf CMDFILE "set title 'Simulation of ball and Earth with timestep 0.0001 sec' \n", $aper;
  
  $cmd = "plot [][] 'tiny_earth_soft_rad1e5_t1e-4.dat' using 2:4 ";
  $cmd .= "  with lines lw 3 ";

  printf CMDFILE "$cmd \n";
  printf CMDFILE "set output \n";
  printf CMDFILE "quit \n";
  close(CMDFILE) ;
  
  $retval = `gnuplot < $cmdfile`;
  printf "retval is ..%s..\n", $retval;
  
  if ($term_options =~ /postscript/) {
    $psfile = $output_file;
    $giffile = $psfile;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

