#!/bin/csh -f
#
# dotrend-all - do a trend plot of thruput vs some parameter for the given 
#   set of patterns and configs
#
set usage='usage: dotrend-all [-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

foreach pat (`cat $patfile`)
    set files=()
    foreach dir ($dirs)
	set files=($files $dir/results/$pat.$Nio.$Ncomp.avg)
    end
    if ($?title) then
	dotrend-one -t "$title, pattern $pat" $xfield $files
    else
	dotrend-one \
		-t "Pattern $pat, field $xfield" $xfield $files
    endif
end
