#!/usr/local/bin/perl
#
# $Id: noptreport,v 1.1 1993/08/31 20:42:39 johans Exp $
#
# noptreport [-v] [-n name] [-i start [stop]] weightbase vectorfile
#
#

$Verbose = 0;

$StartIter;
$EndIter;

@WeightFiles;
$WeightBase;
$TestFile;
$ReportName = "report";

sub PrintUsage {
	print STDERR "usage: noptreport [-v] [-n name] [-i start [stop]] weightbase vectorfile\n";
}

while( @ARGV ) {

	if( $ARGV[0] !~ /^-/ ) {
		last;
	}

	$arg = shift( @ARGV );

	if( $arg eq "-i" ) {

		$StartIter = shift( @ARGV );

		if( $ARGV[0] =~ /^\d+$/ ) {
			$EndIter = shift( @ARGV );
		}

	} elsif( $arg eq "-n" ) {

		$ReportName = shift( @ARGV );

	} elsif( $arg eq "-v" ) {

		$Verbose = 1;

	} else {
		print STDERR "noptreport: bad arugment \'$arg\'\n";
		do PrintUsage();
		exit( 1 );
	}

}

if( $#ARGV != 1 ) {
	do PrintUsage();
	exit( 1 );
}

$WeightBase = $ARGV[0];
$TestFile = $ARGV[1];

#
# Find all of the weightfiles
#
@WeightFiles = <$WeightBase.*>;
@WeightFiles = grep( /$WeightBase\.\d+$/, @WeightFiles );

if( $Verbose ) {
	print "Found the following weight files:\n";
	print "\t @WeightFiles\n\n";
}

foreach $w ( @WeightFiles ) {

	$iter = $w;
	$iter =~ s/$WeightBase\.//;

	if( defined( $StartIter ) ) {
		if( $iter < $StartIter ) {
			next;
		}
	}

	if( defined( $EndIter ) ) {
		if( $iter > $EndIter ) {
			next;
		}
	}

	print "noptest $w $TestFile $ReportName.$iter\n" if( $Verbose );
	system( "noptest $w $TestFile $ReportName.$iter" );

}

