changed: improve reference data update script

- separate code and data
- no prt files for any tests
This commit is contained in:
Arne Morten Kvarving 2018-07-03 13:03:13 +02:00
parent a154d89197
commit 35d10a61b8

View File

@ -9,248 +9,82 @@ OPM_TESTS_ROOT=$1
# $4...$@ = file types to copy
copyToReferenceDir () {
SRC_DIR=$1
DST_DIR=$2;
STEM=$3;
FILETYPES=${@:4};
DST_DIR=$2
STEM=$3
FILETYPES=${@:4}
mkdir -p $DST_DIR
for filetype in $FILETYPES; do
cp "$WORKSPACE/$SRC_DIR$STEM.$filetype" $DST_DIR
DIFF=1
for filetype in $FILETYPES
do
diff -q "$WORKSPACE/$SRC_DIR$STEM.$filetype" "$DST_DIR/$STEM.$filetype"
if test $? -ne 0
then
cp "$WORKSPACE/$SRC_DIR$STEM.$filetype" $DST_DIR
DIFF=0
fi
done
return $DIFF
}
tests=${@:2}
test -z "$tests" && tests="spe11 spe12 spe12p spe1oilgas spe1nowells spe1thermal ctaquifer_2d_oilwater spe3 spe5 spe9 norne_init msw_2d_h msw_3d_hfa polymer2d spe9group polymer_oilwater wecon_wtest"
if grep -q -i "norne " <<< $ghprbCommentBody
then
if test -d $WORKSPACE/deps/opm-tests/norne/flow
then
tests="$tests norne_full"
fi
fi
declare -A tests
# binary dirname casename [testname]
# you only have to specify testname if it differs from dirname
tests[spe11_seq]="flow_sequential spe1 SPE1CASE1"
tests[spe12]="flow spe1 SPE1CASE2"
tests[spe12_legacy]="flow_legacy spe1 SPE1CASE2"
tests[spe12p]="flow spe1 SPE1CASE2_2P spe1_2p"
tests[spe12p_legacy]="flow_legacy spe1 SPE1CASE2_2P spe1_2p"
tests[spe1oilgas]="flow spe1 SPE1CASE2_OILGAS spe1_oilgas"
tests[spe1nowells]="flow spe1 SPE1CASE2_NOWELLS spe1_nowells"
tests[spe1thermal]="flow spe1 SPE1CASE2_THERMAL spe1_thermal"
tests[ctaquifer_2d_oilwater]="flow aquifer-oilwater 2D_OW_CTAQUIFER ctaquifer_2d_oilwater"
tests[msw_2d_h]="flow msw_2d_h 2D_H__"
tests[msw_3d_hfa]="flow msw_3d_hfa 3D_MSW"
tests[polymer_oilwater]="flow polymer_oilwater 2D_OILWATER_POLYMER"
tests[polymer2d]="flow polymer_simple2D 2D_THREEPHASE_POLY_HETER"
tests[spe3]="flow spe3 SPE3CASE1"
tests[spe3_legacy]="flow_legacy spe3 SPE3CASE1"
tests[spe5]="flow spe5 SPE5CASE1"
tests[spe9group]="flow spe9group SPE9_CP_GROUP"
tests[spe9]="flow spe9 SPE9_CP_SHORT"
tests[spe9_legacy]="flow_legacy spe9 SPE9_CP_SHORT"
tests[wecon_wtest]="flow wecon_wtest 3D_WECON"
echo $tests
for test_name in ${tests}; do
if grep -q "spe11" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow_sequential+spe1/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow_sequential \
SPE1CASE1 \
changed_tests=""
for test_name in ${!tests[*]}
do
binary=`echo ${tests[$test_name]} | awk -F ' ' '{print $1}'`
dirname=`echo ${tests[$test_name]} | awk -F ' ' '{print $2}'`
casename=`echo ${tests[$test_name]} | awk -F ' ' '{print $3}'`
tname=`echo ${tests[$test_name]} | awk -F ' ' '{print $4}'`
test -z "$tname" && tname=$dirname
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/$binary+$tname/ \
$OPM_TESTS_ROOT/$dirname/opm-simulation-reference/$binary \
$casename \
EGRID INIT SMSPEC UNRST UNSMRY
fi
test $? -eq 0 && changed_tests="$changed_tests $test_name"
done
if grep -q "spe12" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow_legacy+spe1/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow_legacy \
SPE1CASE2 \
EGRID INIT SMSPEC UNRST UNSMRY
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe1/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow \
SPE1CASE2 \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe12p" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe1_2p/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow \
SPE1CASE2_2P \
EGRID INIT SMSPEC UNRST UNSMRY
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow_legacy+spe1_2p/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow_legacy \
SPE1CASE2_2P \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe1oilgas" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe1_oilgas/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow \
SPE1CASE2_OILGAS \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe1nowells" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe1_nowells/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow \
SPE1CASE2_NOWELLS \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe1thermal" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe1_thermal/ \
$OPM_TESTS_ROOT/spe1/opm-simulation-reference/flow \
SPE1CASE2_THERMAL \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "ctaquifer_2d_oilwater" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+ctaquifer_2d_oilwater/ \
$OPM_TESTS_ROOT/aquifer-oilwater/opm-simulation-reference/flow \
2D_OW_CTAQUIFER \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "msw_2d_h" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+msw_2d_h/ \
$OPM_TESTS_ROOT/msw_2d_h/opm-simulation-reference/flow \
2D_H__ \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "msw_3d_hfa" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+msw_3d_hfa/ \
$OPM_TESTS_ROOT/msw_3d_hfa/opm-simulation-reference/flow \
3D_MSW \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "polymer_oilwater" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+polymer_oilwater/ \
$OPM_TESTS_ROOT/polymer_oilwater/opm-simulation-reference/flow \
2D_OILWATER_POLYMER \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "polymer2d" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+polymer_simple2D/ \
$OPM_TESTS_ROOT/polymer_simple2D/opm-simulation-reference/flow \
2D_THREEPHASE_POLY_HETER \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe3" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow_legacy+spe3/ \
$OPM_TESTS_ROOT/spe3/opm-simulation-reference/flow_legacy \
SPE3CASE1 \
EGRID INIT PRT SMSPEC UNRST UNSMRY
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe3/ \
$OPM_TESTS_ROOT/spe3/opm-simulation-reference/flow \
SPE3CASE1 \
EGRID INIT PRT SMSPEC UNRST UNSMRY
fi
if grep -q "spe5" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe5/ \
$OPM_TESTS_ROOT/spe5/opm-simulation-reference/flow \
SPE5CASE1 \
EGRID INIT SMSPEC UNRST UNSMRY
fi
if grep -q "spe9group" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe9group/ \
$OPM_TESTS_ROOT/spe9group/opm-simulation-reference/flow \
SPE9_CP_GROUP \
EGRID INIT PRT SMSPEC UNRST UNSMRY
elif grep -q "spe9" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+spe9/ \
$OPM_TESTS_ROOT/spe9/opm-simulation-reference/flow \
SPE9_CP_SHORT \
EGRID INIT PRT SMSPEC UNRST UNSMRY
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow_legacy+spe9/ \
$OPM_TESTS_ROOT/spe9/opm-simulation-reference/flow_legacy \
SPE9_CP_SHORT \
EGRID INIT PRT SMSPEC UNRST UNSMRY
fi
if grep -q "norne_init" <<< $test_name
then
copyToReferenceDir \
# special tests
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/init/flow+norne/ \
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow \
NORNE_ATW2013 \
EGRID INIT
test $? -eq 0 && changed_tests="$changed_tests norne_init"
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/init/flow_legacy+norne/ \
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow_legacy \
NORNE_ATW2013 \
EGRID INIT
fi
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/init/flow_legacy+norne/ \
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow_legacy \
NORNE_ATW2013 \
EGRID INIT
test $? -eq 0 && changed_tests="$changed_tests norne_init_legacy"
if grep -q "norne_full" <<< $test_name
then
copyToReferenceDir \
deps/opm-tests/norne/flow/ \
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow \
NORNE_ATW2013 \
UNSMRY
copyToReferenceDir \
deps/opm-tests/norne/flow_legacy/ \
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow_legacy \
NORNE_ATW2013 \
UNSMRY
fi
if grep -q "wecon_wtest" <<< $test_name
then
copyToReferenceDir \
$configuration/build-opm-simulators/tests/results/flow+wecon_wtest/ \
$OPM_TESTS_ROOT/wecon_wtest/opm-simulation-reference/flow \
3D_WECON \
EGRID INIT SMSPEC UNRST UNSMRY
fi
done
if [ -z "${@:2}" ]
then
# User did not specify tests to update, probe
pushd $OPM_TESTS_ROOT > /dev/null
tests=""
git status | grep "SPE1CASE1" && tests="spe11"
git status | grep "SPE1CASE2" && tests="$tests spe12"
git status | grep "SPE3CASE1" && tests="$tests spe3"
git status | grep "SPE1CASE2_2P" && tests="$tests spe1-2p"
git status | grep "SPE1CASE2_OILGAS" && tests="$tests spe1oilgas"
git status | grep "SPE5CASE1" && tests="$tests spe5"
git status | grep "SPE9_CP" && tests="$tests spe9"
git status | grep "SPE9_CP_GROUP" && tests="$tests spe9group"
git status | grep "2D_H__" && tests="$tests msw_2d_h"
git status | grep "3D_MSW" && tests="$tests msw_3d_hfa"
git status | grep "2D_THREEPHASE_POLY_HETER" && tests="$tests simple2d"
git status | grep "NORNE_ATW2013.INIT" && tests="$tests norne_init"
git status | grep "NORNE_ATW2013.UNSMRY" && tests="$tests norne_full"
popd > /dev/null
fi
echo -e "update reference data for $tests\n" > /tmp/cmsg
changed_tests=`echo $changed_tests | xargs`
echo -e "update reference data for $changed_tests\n" > /tmp/cmsg
if [ -z "$REASON" ]
then
echo -e "Reason: fill in this\n" >> /tmp/cmsg