From 6f7cc94da20f2843cbd1d313d6652c2d8fdf5c48 Mon Sep 17 00:00:00 2001 From: Lisa Julia Nebel Date: Tue, 2 Apr 2024 16:10:18 +0200 Subject: [PATCH] Add script to compare the summary files of two different simulator runs --- tests/run-comparison.sh | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 tests/run-comparison.sh diff --git a/tests/run-comparison.sh b/tests/run-comparison.sh new file mode 100755 index 000000000..7e2241740 --- /dev/null +++ b/tests/run-comparison.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# This does two simulator runs and compares the summary files against each other. + +if test $# -eq 0 +then + echo -e "Usage:\t$0 -- [additional simulator options]" + echo -e "\tMandatory options:" + echo -e "\t\t -i Path to read first deck from" + echo -e "\t\t -j Path to read second deck from" + echo -e "\t\t -f First deck file name" + echo -e "\t\t -g value Second deck file name" + echo -e "\t\t -y value Ignore extra keywords in the run. For -y 'BOTH', extra keywords in both runs will be ignored. For -y 'SECOND', extra keywords in the second deck will be ignored." + echo -e "\t\t -r Path to store results in" + echo -e "\t\t -b Path to simulator binary" + echo -e "\t\t -a Absolute tolerance in comparison" + echo -e "\t\t -t Relative tolerance in comparison" + echo -e "\t\t -c Path to comparison tool" + echo -e "\t\t -e Simulator binary to use" + exit 1 +fi + +RESTART_STEP="" +OPTIND=1 +while getopts "i:j:f:g:r:b:a:t:c:e:y:" OPT +do + case "${OPT}" in + i) INPUT_DATA_PATH1=${OPTARG} ;; + j) INPUT_DATA_PATH2=${OPTARG} ;; + f) FILENAME1=${OPTARG} ;; + g) FILENAME2=${OPTARG} ;; + r) RESULT_PATH=${OPTARG} ;; + b) BINPATH=${OPTARG} ;; + a) ABS_TOL=${OPTARG} ;; + t) REL_TOL=${OPTARG} ;; + c) COMPARE_ECL_COMMAND=${OPTARG} ;; + e) EXE_NAME=${OPTARG} ;; + y) IGNORE_EXTRA_KW=${OPTARG} ;; + esac +done +shift $(($OPTIND-1)) +TEST_ARGS="$@" + +mkdir -p ${RESULT_PATH} +cd ${RESULT_PATH} +${BINPATH}/${EXE_NAME} ${INPUT_DATA_PATH1}/${FILENAME1} ${TEST_ARGS} --output-dir=${RESULT_PATH} +test $? -eq 0 || exit 1 +${BINPATH}/${EXE_NAME} ${INPUT_DATA_PATH2}/${FILENAME2} ${TEST_ARGS} --output-dir=${RESULT_PATH} +test $? -eq 0 || exit 1 +cd .. + + +ecode=0 + +ignore_extra_kw="" +if grep -q "SECOND" <<< $IGNORE_EXTRA_KW +then + ignore_extra_kw="-x" +fi + +if grep -q "BOTH" <<< $IGNORE_EXTRA_KW +then + ignore_extra_kw="-y" +fi + +echo "=== Executing comparison for EGRID, INIT, UNRST and RFT files if these exists in reference folder ===" +${COMPARE_ECL_COMMAND} -t SMRY ${ignore_extra_kw} ${RESULT_PATH}/${FILENAME1} ${RESULT_PATH}/${FILENAME2} ${ABS_TOL} ${REL_TOL} +if [ $? -ne 0 ] +then + ecode=1 + ${COMPARE_ECL_COMMAND} -t SMRY ${ignore_extra_kw} -a ${RESULT_PATH}/${FILENAME1} ${RESULT_PATH}/${FILENAME2} ${ABS_TOL} ${REL_TOL} +fi + +exit $ecode