#!/bin/csh
## plot+ < graphinfo
## Last modified: January 31st, 1996

set SCRIPDIR = "/n/park/0/cise/Repository/Developing/TCP/scripts"

# scaling, squaring and compression programs
set sq = "$SCRIPDIR/squarize"
set s6 = "$SCRIPDIR/scale6"
set hpsq = "$SCRIPDIR/hpsquarize"
set hps6 = "$SCRIPDIR/hpscale6"
set hpcombo = "$SCRIPDIR/hpcombo"
set hpqcombo = "$SCRIPDIR/hpqcombo"
set suncombo = "$SCRIPDIR/suncombo"
set hprevsq = "$SCRIPDIR/hprevsquarize"

# non-draft options
set alterps = "$SCRIPDIR/alterps"
set hpalterps = "$SCRIPDIR/hpalterps"
set count = 0
set uparrow = 3
set downarrow = 4
set noarrow = 5

# plot file headers
set headerlines = "$SCRIPDIR/.gnu.header"
set headerpoints = "$SCRIPDIR/.gnu.header1"
set headerdots = "$SCRIPDIR/.gnu.header2"

set tmpdatfile = "./dat.file"

set numgraphs = $<
set ctr = 0
while ($ctr < $numgraphs)
  set title  = $<
  set filename = $<
  set psfile = $filename".ps"
  set plotfile = $filename".plot"
  set xlabel = $<
  set ylabel = $<
  set linesorpoints = $<
  set draft = $<
  set yrange = $<
  if ($linesorpoints == "l") then
    cp $headerlines $plotfile
  else if ($linesorpoints == "p") then
    cp $headerpoints $plotfile
  else cp $headerdots $plotfile
  endif
  echo "" >> $plotfile
  echo -n " set title " >> $plotfile
  echo -n \" >> $plotfile
  echo -n $title >> $plotfile
  echo  \" >> $plotfile
  echo -n " set xlabel " >> $plotfile
  echo -n \" >> $plotfile
  echo -n $xlabel >> $plotfile
  echo \" >> $plotfile
  echo -n " set ylabel " >> $plotfile
  echo -n \" >> $plotfile
  echo -n $ylabel >> $plotfile
  echo \" >> $plotfile
  if ( $yrange != 0 ) then
    echo -n " set yrange " >> $plotfile
    echo -n "[0:" >> $plotfile
    echo -n $yrange >> $plotfile
    echo "]" >> $plotfile
  endif
  echo -n "plot" >> $plotfile

  set numcurves = $<
  set curve = 0
  while ($curve < $numcurves) 
    set curvetitle = $<
    set nondraftparams = $<
    set datfilenumber = $<
    set datfile = $datfilenumber".dat"
    set howtoplot = $<
    set compression = $<
    if ($HOSTTYPE == "sun4") then 
      echo Have not ported that yet
    else if ($HOSTTYPE == "hp700") then 
      $hps6 $datfile $tmpdatfile
      if ($howtoplot != "p") then
        if ($howtoplot != "r") then
          $hpsq $tmpdatfile $datfile
	else
          $hprevsq $tmpdatfile $datfile
	endif
      else
	mv $tmpdatfile $datfile
      endif
    endif
    if ($curve == 0) then 
      echo -n \"$datfile\" title \"$curvetitle \" >> $plotfile
    else
      echo -n ","\"$datfile\" title \"$curvetitle \" >> $plotfile
    endif
    @ curve++
  end
  gnuplot $plotfile
  mv ./tmp.ps $psfile
  if ($draft == 0) then
     echo Have not ported that yet
  endif
  @ ctr ++
end


  












