#!/bin/bash

if [ $# -ne 1 ] 
then                    # affiche l'usage
    echo "Missing parameter" 
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
    exit 1
fi

if [ $1 == "help" ] || [ $1 == "--help" ] 
then 
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
    exit 1
fi

if [ $1 != "help" ] && [ $1 != "--help" ] && [ $1 != "compute" ] &&
 [ $1 != "diff" ]
then 
    echo "Wrong Parameter"
    echo "Use: $0 diff for comparing result" 
    echo "Use: $0 compute for computing result" 
    exit 1
fi

# compute and save result in _new
if [ $1 == "compute" ]
then 
soltracy Input_checkcode.prm

CMD='mv'

$CMD nudx.out nudx_new.out
$CMD nudz.out nudz_new.out
$CMD nudp.out nudp_new.out
$CMD flat_file_error.dat flat_file_error_new.dat
$CMD linlat.out linlat_new.out
$CMD chambre.out chambre_new.out
$CMD flat_file.dat flat_file_new.dat
fi

if [ $1 == "diff" ]
then 

CMD='diff'
$CMD nudx_ref.out nudx_new.out
$CMD nudz_ref.out nudz_new.out
$CMD nudp_ref.out nudp_new.out
$CMD flat_file_error_ref.dat flat_file_error_new.dat
$CMD linlat_ref.out linlat_new.out
$CMD chambre_ref.out chambre_new.out
$CMD flat_file_ref.dat flat_file_new.dat
fi