#!/bin/csh -f
#
# run-lu: run exactly one LU test case, in current directory
#
set usage='usage: run-lu [-v] Nio Ncomp [seed]'
# where -v is used when we want to verify the results
#
# 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 < 2 || $#argv > 4) then
    echo "$usage"
    exit 1
endif

limit core 0k
# limit file 200k

if ("$1" == "-v") then
    set do_verify
    set Nio=$2
    set Ncomp=$3
    if ($#argv == 4) then
        set seed=$4
    else
        set seed=1
    endif
else
    unset do_verify
    set Nio=$1
    set Ncomp=$2
    if ($#argv == 3) then
        set seed=$3
    else
        set seed=1
    endif
endif

set pat=lu

set f=results/$pat.$Nio.$Ncomp.$seed

rm -f $f.sim $f.sim.gz $f.out $f.out.gz input

if ($?do_verify) then
       proteus             -abort           -v luinit 1 1        >& $f.out \
    && unstripe > input \
    && proteus -seed $seed -abort -o $f.sim -v $pat $Nio $Ncomp >>& $f.out \
    && unstripe | lutest input >>& $f.out
	rm -f input
else
       proteus             -abort           -v luinit 1 1        >& $f.out \
    && proteus -seed $seed -abort -o $f.sim -v $pat $Nio $Ncomp >>& $f.out
endif

rm -f DISK??

gzip $f.sim 
rm -f events.sim

exit 0
