#!/bin/csh -f
#
# groupfiles - group metric files from many test cases
#
#   We print out the logical contatenation of the given set of
# metrics files.  This means that each file is represented by 
# one line in the output,  with a column for the mean of each
# interesting parameter.  Columns are tab-separated and so are ready
# for import into Excel.
#
set usage='usage: groupfiles metriclistfile foo.metrics ...'
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              January 1996
#                          dfk@cs.dartmouth.edu

source environset

if ($#argv < 2) then
	echo "$usage"
	exit 1
endif

set metrics=`cat $1`
shift

set col=3	# we want column 3 which holds the mean values

set out=/tmp/group$$
onintr cleanup

set outlist=()
foreach metric ($metrics)
    grep ^$metric $* | colex $col | mapmetric $metric > $out.$metric
    set outlist=($outlist $out.$metric)
end

# header: metric names
echo $metrics | sed 's/ /	/g'
# now abut the files in the same order as specified in list
abut $outlist

cleanup:
rm -f $out*
