#!/bin/csh -f
#
# suite-ndisk: spit out a suite for an ndisk variation where I want
#    Nio to be variable, but less than or equal to Ndisk
#
set usage='usage: suite-disk patfile Nio Ncomp config...  > suitefile'
#
# the patfile should contain a list of patterns to be used
# the config... is a list of configs/* directory names
#
# 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 <= 3) then
    echo "$usage"
    exit 1
endif

set patfile=$1
set Nio=$2
set Ncomp=$3
set dirs=($argv[4-])

if (! -f "$patfile") then
    echo Can not access pattern file "$patfile"
    exit 1
endif

set top=`echo $cwd | sed -e 's|.*dfk|/u/dfk|' -e 's|/u/dfk/.*run|/u/dfk/run|'`

foreach dir ($dirs)
    if (! -d $dir) continue
#    if (! -x $dir/proteus && ! -x $dir/proteus.gz) continue

    echo ""
    echo "# ------ $dir -------"

#    echo "gunzip $dir/proteus.gz" 
    echo "mkdir $dir/results" 

    foreach pat (`cat $patfile`)
#    	echo "cd $top/$dir; run-proteus $pat $Nio $Ncomp"

    	if ($dir =~ */8.* \
    	&& ($pat =~ w[rw]n || $pat == wrlw || $pat =~ w[rw]lw1)) continue

	set x=$dir:r
	set ndisk=$x:e
	if ($ndisk < $Nio) then
		set nio=$ndisk
	else
		set nio=$Nio
	endif

#        foreach trial (2 3 4 5)
       foreach trial (1)
#       foreach trial (1 2 3 4 5)
    	    echo "cd $top/$dir; run-proteus $pat $nio $Ncomp $trial"
   	end
    end

#    echo "gzip $dir/proteus"

#    echo "update $dir"
end

echo "mail -s 'suite finished' $user < /dev/null" 
