diff --git a/compare_results.sh b/compare_results.sh index cf93f120a..43644ef8e 100644 --- a/compare_results.sh +++ b/compare_results.sh @@ -61,50 +61,84 @@ if [ -n "$diff_files" ]; then file1=$( echo "${array_files[i]}" | awk '{print $1}' ) file2=$( echo "${array_files[i]}" | awk '{print $2}' ) - # Filter output files, ignore lines with words (probably not the results) - # Do not delete "e", since it can be used as exponent - # removes |<>() characters - num_filter='s/(\|)\||\|>\|\| DEBUG_TXT_DIFF + # paste <(echo "$file1_num") <(echo "$file2_num") > DEBUG_NUM_DIFF + # cat "$file1" | sed "$txt_filter" > DEBUG_F1 + # cat "$file2" | sed "$txt_filter" > DEBUG_F2 - # Pairwise compares files fields, that are produces from diffs and computes average and maximum - # relative differences - filename=$(basename $file1) # total file paths are pretty long, this keep info concise + + # Pairwise compare file fields and compute average/maximum relative difference + filename=$(basename $file1) # total file paths are long, this keeps info concise echo "Comparing values in '$filename'..." + + if [ -n "$num_diff" ]; then - rel_max_difference=$( export max_diff_limit; export avg_diff_limit; echo "$num_diff" | awk 'function abs(v) {return v < 0 ? -v : v} { radius=NF/2; - max_diff=0; - sum=0; - for(i = 1; i <= radius; i++) { - if ($i != 0) { - ind_diff= abs((($(i + radius)-$i)/$i )); - sum += ind_diff; - if (ind_diff > max_diff ) { max_diff = ind_diff } - } - } - } END { diff=2*sum/( NR*NF ); if (diff > ENVIRON["avg_diff_limit"] || max_diff > ENVIRON["max_diff_limit"]) { print diff, max_diff }}') + max_diff=0.0 + rel_max_difference=$( export max_diff_limit; export avg_diff_limit; echo "$num_diff" | awk 'function abs(v) {return v < 0 ? -v : v} + BEGIN { + max_diff=0.0; + sum=0; + total_entries=0; + } + { + radius=NF/2; + for(i = 1; i <= radius; i++) { + total_entries += 1; + if ($i != 0) { + ind_diff = abs((($(i + radius)-$i)/$i )); + sum += ind_diff; + if (ind_diff > max_diff ) { + max_diff = ind_diff; + # printf("DEBUG| NR: %d; max: %f; ind: %f; sum: %f | Out: %f; refOut: %f\n", NR, max_diff, ind_diff, sum, $(i + radius), $i) > "/dev/stderr"; + } + } + } + } + END { + if (total_entries == 0) { print "NO_ENTRIES" } + else { + diff=sum/total_entries; + if (diff > ENVIRON["avg_diff_limit"] || max_diff > ENVIRON["max_diff_limit"]) { + print diff, max_diff; + } + } + }' ) fi if [ -n "$rel_max_difference" ]; then # Split by space and transform into the array difference=( $rel_max_difference ) echo -e "> Numerical difference in $filename" - echo -e "$num_diff" + # echo -e "$num_diff" echo -e "Average: ${difference[0]} ; Maximum: ${difference[1]} ${NC}" ret=1 fi diff --git a/system_testing.py b/system_testing.py index 809d29cfe..d44c020df 100644 --- a/system_testing.py +++ b/system_testing.py @@ -198,7 +198,7 @@ def comparison(pathToRef, pathToOutput): else: print('SYSTEST SUCCEEDED - Differences to referenceOutput within tolerance.') else: - print('SYSTEST SUCCEEDED - No difference to referenceOutput found.') + print('SYSTEST SUCCEEDED - Result files and reference are identical.') def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all=False, verbose=False):