#!/bin/bash

#set -x 
mkdir -p results-mumps-charge
cp -a output_mumpsbench output_*log in_200Nodes* mumps_bench results-mumps-charge/

K=1
envtest="in_200Nodes_K=${K}_Test1_32x6.txt"
file="output_${envtest}.log"
max_allowed_diff=0.1
operations_in_node_elimination_good=63980000000000

operations_in_node_elimination=$(printf -- "%.25g" `grep 'Operations in node elimination' $file  | sort -u |  awk '{print $7}' | tr 'D' 'E'`)

echo $operations_in_node_elimination_good $operations_in_node_elimination $max_allowed_diff| awk '{if (sqrt(($1 - $2)^2) > $3) print "ERROR Operations in node elimination differs more than "$3; else print "OK accurate Operations in node elimination"}'

max_allowed_diff=0.0
flops_difference_good=0.0
flops_difference=$(printf -- "%.25g" `grep "FLOPS_REFERENCE DIFFERENCE" output_in_200Nodes_K\=1_Test1_32x6.txt.log  | awk '{print $4}' | sort -u | sort -n -k1 | tail -n 1`)
echo $flops_difference_good $flops_difference $max_allowed_diff| awk '{if (sqrt(($1 - $2)^2) > $3) print "ERROR flops differs more than "$3; else print "OK accurate flops"}'

grep "BENCH: TIME" $file  | grep "simultaneous instances" | awk -F= '{print $2" instances time"$3}'
