2016-07-06 04:30:10 -05:00
#!/bin/bash
2017-02-16 09:00:42 -06:00
# This runs a simulator, then compares the summary, restart and init
# files against a reference.
2021-10-13 03:47:23 -05:00
if test $# -eq 0
then
echo -e " Usage:\t $0 <options> -- [additional simulator options] "
echo -e "\tMandatory options:"
echo -e "\t\t -i <path> Path to read deck from"
echo -e "\t\t -r <path> Path to store results in"
echo -e "\t\t -b <path> Path to simulator binary"
echo -e "\t\t -f <filename> Deck file name"
echo -e "\t\t -a <tol> Absolute tolerance in comparison"
echo -e "\t\t -t <tol> Relative tolerance in comparison"
echo -e "\t\t -c <path> Path to comparison tool"
echo -e "\t\t -d <path> Path to restart deck tool"
echo -e "\t\t -e <filename> Simulator binary to use"
echo -e "\tOptional options:"
echo -e "\t\t -s <step> Step to do restart testing from"
echo -e "\t\t -h value sched_restart value to use in restart test"
exit 1
fi
2021-12-05 05:09:19 -06:00
RESTART_STEP = ""
2021-10-13 03:47:23 -05:00
OPTIND = 1
while getopts "i:r:b:f:a:t:c:d:s:e:h:" OPT
do
case " ${ OPT } " in
i) INPUT_DATA_PATH = ${ OPTARG } ; ;
r) RESULT_PATH = ${ OPTARG } ; ;
b) BINPATH = ${ OPTARG } ; ;
f) FILENAME = ${ OPTARG } ; ;
a) ABS_TOL = ${ OPTARG } ; ;
t) REL_TOL = ${ OPTARG } ; ;
c) COMPARE_ECL_COMMAND = ${ OPTARG } ; ;
d) RST_DECK_COMMAND = ${ OPTARG } ; ;
s) RESTART_STEP = ${ OPTARG } ; ;
e) EXE_NAME = ${ OPTARG } ; ;
h) RESTART_SCHED = ${ OPTARG } ; ;
esac
done
shift $(( $OPTIND - 1 ))
2016-07-06 04:30:10 -05:00
TEST_ARGS = " $@ "
mkdir -p ${ RESULT_PATH }
cd ${ RESULT_PATH }
2021-08-17 06:14:49 -05:00
${ BINPATH } /${ EXE_NAME } ${ INPUT_DATA_PATH } /${ FILENAME } ${ TEST_ARGS } --output-dir= ${ RESULT_PATH }
2018-08-09 01:11:36 -05:00
test $? -eq 0 || exit 1
2016-07-06 04:30:10 -05:00
cd ..
2018-09-13 03:04:23 -05:00
2019-05-10 08:25:14 -05:00
ecode = 0
2019-06-03 04:17:32 -05:00
ignore_extra_kw = ""
if grep -q "ignore_extra" <<< $ghprbCommentBody
then
ignore_extra_kw = "-x"
fi
2020-10-23 05:34:03 -05:00
echo "=== Executing comparison for EGRID, INIT, UNRST and RFT files if these exists in reference folder ==="
2019-06-03 04:17:32 -05:00
${ COMPARE_ECL_COMMAND } ${ ignore_extra_kw } ${ INPUT_DATA_PATH } /opm-simulation-reference/${ EXE_NAME } /${ FILENAME } ${ RESULT_PATH } /${ FILENAME } ${ ABS_TOL } ${ REL_TOL }
2017-02-16 09:00:42 -06:00
if [ $? -ne 0 ]
then
ecode = 1
2019-06-03 04:17:32 -05:00
${ COMPARE_ECL_COMMAND } ${ ignore_extra_kw } -a ${ INPUT_DATA_PATH } /opm-simulation-reference/${ EXE_NAME } /${ FILENAME } ${ RESULT_PATH } /${ FILENAME } ${ ABS_TOL } ${ REL_TOL }
2017-02-16 09:00:42 -06:00
fi
2017-02-02 07:58:23 -06:00
2021-12-05 05:09:19 -06:00
RSTEPS = ( ${ RESTART_STEP //,/ } )
for STEP in " ${ RSTEPS [@] } "
do
echo " === Executing restart run from step: ${ STEP } === "
2021-08-17 06:14:49 -05:00
mkdir -p ${ RESULT_PATH } /restart
cp -f ${ RESULT_PATH } /${ FILENAME } .UNRST ${ RESULT_PATH } /restart
2021-12-05 05:09:19 -06:00
${ RST_DECK_COMMAND } ${ INPUT_DATA_PATH } /${ FILENAME } .DATA ${ FILENAME } :${ STEP } -m inline -s > ${ RESULT_PATH } /restart/${ FILENAME } _RESTART_${ STEP } .DATA
2021-08-17 06:14:49 -05:00
cd ${ RESULT_PATH } /restart
2021-10-13 03:47:23 -05:00
if test -n " $RESTART_SCHED "
then
sched_rst = " --sched-restart= ${ RESTART_SCHED } "
fi
2021-12-05 05:09:19 -06:00
${ BINPATH } /${ EXE_NAME } ${ TEST_ARGS } ${ sched_rst } --output-dir= ${ RESULT_PATH } /restart ${ FILENAME } _RESTART_${ STEP }
2021-08-17 06:14:49 -05:00
test $? -eq 0 || exit 1
echo "=== Executing comparison for EGRID, INIT, UNRST and RFT files for restarted run ==="
2021-12-05 05:09:19 -06:00
${ COMPARE_ECL_COMMAND } ${ ignore_extra_kw } ${ INPUT_DATA_PATH } /opm-simulation-reference/${ EXE_NAME } /restart/${ FILENAME } _RESTART_${ STEP } ${ RESULT_PATH } /restart/${ FILENAME } _RESTART_${ STEP } ${ ABS_TOL } ${ REL_TOL }
2021-08-17 06:14:49 -05:00
if [ $? -ne 0 ]
then
ecode = 1
2021-12-05 05:09:19 -06:00
${ COMPARE_ECL_COMMAND } ${ ignore_extra_kw } -a ${ INPUT_DATA_PATH } /opm-simulation-reference/${ EXE_NAME } /restart/${ FILENAME } _RESTART_${ STEP } ${ RESULT_PATH } /restart/${ FILENAME } _RESTART_${ STEP } ${ ABS_TOL } ${ REL_TOL }
2021-08-17 06:14:49 -05:00
fi
2021-12-05 05:09:19 -06:00
done
2021-08-17 06:14:49 -05:00
2017-02-02 07:58:23 -06:00
exit $ecode