#!/bin/csh -f
#
# dotrend-multi-max -  MAX_OUTSTANDING version
#   do a trend plot of thruput vs max-outstanding for the given 
#   set of patterns and configs ---- ALL PATS ON ONE PLOT
#
set usage='usage: dotrend-multi-max [-t title] name patfile Nio Ncomp configs-max/...'
# where name is a word used in naming the output files
#
# 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

#   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

# extract optional title
unset title
if ($#argv > 0 && "$1" == -t) then
    if ($#argv > 1) then
    	   set title="$2"
           shift; shift
    else
	echo "$usage"
	exit 1
    endif
else
    if ($#argv == 0) then
	echo "$usage"
	exit 1
    endif
endif

if ($#argv <= 4) then
    echo "$usage"
    exit 1
endif

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

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

set files=()
foreach pat (`cat $patfile`)
    foreach dir ($dirs)
    	echo pat $pat, dir $dir
	set files=($files $dir/results/$pat.$Nio.$Ncomp.avg)
    end
end

if ($?title) then
    dotrend-one-max -t "$title, pattern file $patfile" $files
else
    dotrend-one-max \
    	-t "Pattern file $patfile, max-outstanding variation" $files
endif

if (-d dotrend.data) then
    if (! -d dotrend) mkdir dotrend
    mv dotrend.data dotrend/$name
    echo renaming dotrend.data to dotrend/$name
endif
