#!/bin/csh -f
#
# dotrend-one-max - do a trend plot for the given set of data files.  
#	Either .avg or .data files can be used.
#	All files should be the same pattern
#
# THIS VERSION OF dotrend-one IS FOR TREND OVER MAX_OUTSTANDING ONLY.
#
set usage='usage: dotrend-one-max [-t title] configs-max/*/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

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

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

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

# make a list of the MAX_OUTSTANDING field for each file
echo $files | tr ' ' '\012' | sed  -e 's|.*\.\([0-9][0-9]*\)/.*|\1|' > $tmp/maxout

# abut the data with the MAX-OUTSTANDING field, which will be field 16
#           dsort 16 1 7 9 10 11 5 6 3 4 
cat $files | abut - $tmp/maxout | dsort 16 1 | nawk -f $P/dotrend.awk xfield=16

lasergnu -f $tmp/plot

if (-d dotrend.data) rm -rf dotrend.data
cpdir $tmp dotrend.data

cleanup:
rm -rf $tmp

