#!/bin/csh -f
#
# signtable - tabulate all data files in a sign table a la Raj Jain
#
# run this after 'extract'
set usage='usage: signtable {datafile | configdirectory}...'
#
# 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

if ($#argv == 0) then 
	echo "$usage"
	exit 1
endif

onintr cleanup
echo > rawdata

foreach i ($*)
    if (-d $i) then
        cat $i/results/*.data >> rawdata
    else
        cat $i >> rawdata
    endif
end
    
# Pull out the data files that have correct # columns,
# sort them,
# and format with awk
awk NF==13 rawdata \
    | dsort -n 1 2 3 4 5 6 7 9 10 11 \
    | nawk -f $P/signtable1.awk \
    > table

echo number of good data files:
awk 'NF==13' rawdata | wc -l 

echo number of broken data files:
awk 'NF!=13' rawdata | wc -l

cleanup:
rm -f rawdata
