#!/bin/csh -f
#
# nova - do an anova test on factors iopfs and sort
#
# run this after 'extract'
set usage='usage: nova {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

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
    
# rawdata fields:
#   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

rm -f data.*

# Pull out the data files that have correct # columns,
# sort them,
# and format with awk
awk NF==14 rawdata \
    | dsort 1 5 7 6 14 \
    | nawk -f $P/nova.awk

echo > nova.out
foreach i (data.*)
    echo $i -------------------- >> nova.out
    anova trial fs KBps < $i >>& nova.out
    echo "" >> nova.out
end

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 # data.*
