#!/bin/csh -f
#
# dotrend-multi - do a trend plot of thruput vs some parameter for the given 
#   set of patterns and configs ---- ALL PATS ON ONE PLOT
#
set usage='usage: dotrend-multi [-t title] patfile Nio Ncomp xfield config...'
# where xfield is the field number (column) in avg files that
# specifies the independent variable
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 2.0
#                              January 1995
#                          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 patfile="$1"
set Nio="$2"
set Ncomp="$3"
set xfield="$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 -t "$title, pattern file $patfile" $xfield $files
else
    dotrend-one \
    	-t "Pattern file $patfile, field $xfield" $xfield $files
endif
