#!/bin/csh -f
#
# dobar-one - do a bar plot for the given set of data files.  
#	Either .avg or .data files can be used.
#	Probably, all files should be the same pattern
#		(perhaps mixing read and write of same pattern)
#
set usage='usage: dobar-one [-t title] configs/*/results/foo.avg...'
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              October 1996
#                          dfk@cs.dartmouth.edu

set P=`runbin`	# where to find awk scripts

set files=($*)

# extract optional title
if ($#argv > 0 && "$1" == -t) then
    if ($#argv > 1) then
    	   set title="$2"
	   set files=($argv[3-])
    else
	echo "$usage"
	exit 1
    endif
else
    if ($#argv == 0) then
	echo "$usage"
	exit 1
    endif
endif

set tmp=/tmp/dobar
onintr cleanup
mkdir $tmp

if ($?title) then
	echo "set title '$title'" > $tmp/plot
else
	echo > $tmp/plot
endif

# comment this out for interactive use
echo "set term postscript 10" >> $tmp/plot
echo "set time" >> $tmp/plot

# Assume that all files are the same type (avg, imp, or impavg)
set kind=$files[1]:e

cat $files | dsort 7 9 10 11 5 6 1 3 4 | nawk -f $P/dobar.awk "type=$kind"

lasergnu -f $tmp/plot
#echo 'pause -1 "press return"' >> $tmp/plot	# also comment out above
#gnuplot $tmp/plot

cleanup:
rm -rf $tmp

