#!/usr/bin/perl
# Wrapper script for running the NRG code
# First argument is the filename of the executable (relative path).
# A file "FILES" is a list (one per line) of files that are compared
# against target files with the same name and suffix ".test" (see script
# "compare" in this directory).
# Part of "NRG Ljubljana"
# Rok Zitko, rok.zitko@ijs.si, Dec 2006

use warnings;
use strict;

if (@ARGV != 1) {
    die ("Synthax: calc <executable>\n");
}

open(FILES, "<FILES") or die "Can't open FILES\n";

# Delete old results
while (<FILES>) {
    chomp;
    my $f = $_;
    system("rm -f $f");
}

my $path = "../../src/";
my $prg = $ARGV[0];
my $exe = "$path$prg";

if( ! -e $exe) {
    die ("OOPS: Can't find the executable $exe.\n");
}

system("$exe -d -s ../../sneg.m -i ../../initial.m >log.d");
# Check for errors?

system("$exe >log.nrg");
