#!/bin/csh -f
#
# maketable - tabulate all data files by variable in sorted format
#
# run this after 'extract'
set usage='usage: maketable {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
#        cat $i/results/{wr[nbc],wrlw}.*.data >> rawdata
    else
        cat $i >> rawdata
    endif
end
    
#   1      2     3       4        5             6
# Pattern CPFS IOPFS DISK_SORT RECORD_SIZE DISK_LAYOUT 
#  7              8      9    10     11         12     13
# FILE_BLOCKS BLOCK_SIZE Nio Ncomp NO_OF_DISKS total tthruput
#    14
#  trial

# Pull out the data files that have correct # columns,
# sort them,
# and format with awk
awk NF==14 rawdata \
    | dsort -e 1 5 7 6 8 3 4 14 \
    | awk -f $P/maketable.awk \
    > table

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

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

cleanup:
rm -f rawdata
