#!/bin/csh -f
#
# extract-check:  check the results directories to see that extract succeeded
#
# usage:  extract-check [dir]...
# if no dirs, then it does all dirs.
#
# 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

    pushd $dir/results >& /dev/null

    # try to make a list of *.data
    set files=(`ls | grep '\.data$'`)
    if ($#files == 0) continue

    wc -w *.data | awk '$1 != 14 && $2 != "total" {print "'$dir/results'/" $2}'
    awk '$13==0 || $12 == 0 {print FILENAME}' *.data

    set prev=""
    foreach file (*sim*)
	# set base to be base file name
	if ($file:e == gz || $file:e == Z || $file:e == z) then
		set temp = $file:r	# strip .gz
		set base = $temp:r	# strip .sim
	else
		set base = $file:r	# strip .sim
	endif
	set data=$base.data
	if (! -r $data) echo missing $dir/results/$data	
	set base=$base:r	# strip .trial
	if ($base != $prev) then
		set avg=$base.avg
		if (! -r $avg) echo missing $dir/results/$avg
		set imp=$base.imp
		if ($dir =~ *general* && ! -r $imp) echo missing $dir/results/$imp
		set prev=$base
	endif
    end

    popd >& /dev/null
end
