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

set SCRIPDIR = $1

# scaling, squaring and compression programs
# Needed to change to AIX 
# used hp instead of sun

set hpsq = "$SCRIPDIR/squarize"
set hps6 = "$SCRIPDIR/scale6"
set hpcombo = "$SCRIPDIR/combo"
set hpqcombo = "$SCRIPDIR/qcombo"
set hprevsq = "$SCRIPDIR/revsquarize"

# non-draft options
set hpalterps = "$SCRIPDIR/alterps"
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

# Fix for improper xrange
    echo -n " set xrange " >> $plotfile
    echo -n "[0:" >> $plotfile
    echo -n 15000 >> $plotfile
    echo "]" >> $plotfile

  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 
    #else if ($HOSTTYPE == "RISC6000") then 
    else if ($HOSTTYPE == "i386-linux") then 
      echo $hps6 $datfile $tmpdatfile
      $hps6 $datfile $tmpdatfile
      if ($howtoplot != "p") then
        if ($howtoplot != "r") then
          echo $hpsq $tmpdatfile $datfile
          $hpsq $tmpdatfile $datfile
	else
          echo $hprevsq $tmpdatfile $datfile
          $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
  cat $plotfile
  gnuplot $plotfile
  mv ./tmp.ps $psfile
  if ($draft == 0) then
     echo Have not ported that yet
  endif
  @ ctr ++
end


  












