#!/bin/csh -f
#
# average - average all trials of an experiment into a *.avg file
#
set usage='usage: average [configdir]...'
#
# 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

if ($#argv == 0) then
	set dirs=(configs/*)
else
	set dirs=($*)
endif

foreach dir ($dirs)
    if (! -d $dir/results) continue

    # collect a list of file base names
    set files=`ls $dir/results/*.data | sed 's/.[1-5].data$//' | uniq`

    foreach file ($files)
	average-one $file.avg $file.*.data
	if ($dir =~ *general*) average-one $file.avgimp $file.*.imp
    end	
end
