Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 80 additions & 33 deletions tests/rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ die() { echo "$@" >&2; exit 1; }
usage() {
set +x
echo
echo "Usage: $0 -a <account> | -c | -e | -h | -k | -w | -d | -l <file> | -m | -n <name> | -r "
echo "Usage: $0 -a <account> | -b <file> | -c | -d | -e | -h | -k | -l <file> | -m | -n <name> | -r | -w"
echo
echo " -a <account> to use on for HPC queue"
echo " -b create new baselines only for tests listed in <file>"
echo " -c create new baseline results"
echo " -d delete run direcotries that are not used by other tests"
echo " -e use ecFlow workflow manager"
echo " -h display this help"
echo " -k keep run directory after rt.sh is completed"
Expand All @@ -21,7 +23,6 @@ usage() {
echo " -n run single test <name>"
echo " -r use Rocoto workflow manager"
echo " -w for weekly_test, skip comparing baseline results"
echo " -d delete run direcotries that are not used by other tests"
echo
set -x
exit 1
Expand Down Expand Up @@ -75,6 +76,37 @@ rt_single() {
fi
}

create_or_run_compile_task() {

cat << EOF > ${RUNDIR_ROOT}/compile_${COMPILE_NR}.env
export JOB_NR=${JOB_NR}
export COMPILE_NR=${COMPILE_NR}
export MACHINE_ID=${MACHINE_ID}
export RT_COMPILER=${RT_COMPILER}
export PATHRT=${PATHRT}
export PATHTR=${PATHTR}
export SCHEDULER=${SCHEDULER}
export ACCNR=${ACCNR}
export QUEUE=${COMPILE_QUEUE}
export PARTITION=${PARTITION}
export ROCOTO=${ROCOTO}
export ECFLOW=${ECFLOW}
export REGRESSIONTEST_LOG=${REGRESSIONTEST_LOG}
export LOG_DIR=${LOG_DIR}
EOF

if [[ $ROCOTO == true ]]; then
rocoto_create_compile_task
elif [[ $ECFLOW == true ]]; then
ecflow_create_compile_task
else
./run_compile.sh ${PATHRT} ${RUNDIR_ROOT} "${MAKE_OPT}" ${COMPILE_NR} > ${LOG_DIR}/compile_${COMPILE_NR}.log 2>&1
fi

RT_SUFFIX=""
BL_SUFFIX=""
}

rt_35d() {
if [[ $TEST_NAME =~ '35d' ]] ; then
local sy=$(echo ${DATE_35D} | cut -c 1-4)
Expand Down Expand Up @@ -142,13 +174,17 @@ export delete_rundir=false
SKIP_ORDER=false
RTPWD_NEW_BASELINE=false
TESTS_FILE='rt.conf'
NEW_BASELINES_FILE=''
ACCNR=${ACCNR:-""}

while getopts ":a:cl:mn:dwkreh" opt; do
while getopts ":a:b:cl:mn:dwkreh" opt; do
case $opt in
a)
ACCNR=$OPTARG
;;
b)
NEW_BASELINES_FILE=$OPTARG
;;
c)
CREATE_BASELINE=true
;;
Expand All @@ -171,9 +207,9 @@ while getopts ":a:cl:mn:dwkreh" opt; do
echo "The -n option needs <testname> AND <compiler>, i.e. -n control_p8 intel"
exit 1
fi
SINGLE_NAME=${SINGLE_OPTS[0],,}
export RT_COMPILER=${SINGLE_OPTS[1],,}
SINGLE_NAME=${SINGLE_OPTS[0]}
export RT_COMPILER=${SINGLE_OPTS[1]}

if [[ "$RT_COMPILER" == "intel" ]] || [[ "$RT_COMPILER" == "gnu" ]]; then
echo "COMPILER set to ${RT_COMPILER}"
else
Expand Down Expand Up @@ -471,6 +507,7 @@ NEW_BASELINE=${STMP}/${USER}/FV3_RT/REGRESSION_TEST
# Overwrite default RUNDIR_ROOT if environment variable RUNDIR_ROOT is set
RUNDIR_ROOT=${RUNDIR_ROOT:-${PTMP}/${USER}/FV3_RT}/rt_$$
mkdir -p ${RUNDIR_ROOT}
echo "Run regression test in: ${RUNDIR_ROOT}"

if [[ $SINGLE_NAME != '' ]]; then
rt_single
Expand Down Expand Up @@ -503,6 +540,16 @@ if [[ $CREATE_BASELINE == true ]]; then
#
rm -rf "${NEW_BASELINE}"
mkdir -p "${NEW_BASELINE}"

NEW_BASELINES_TESTS=()
if [[ $NEW_BASELINES_FILE != '' ]]; then
readarray -t NEW_BASELINES_TESTS < $NEW_BASELINES_FILE
echo "New baselines will be created for:"
for test_name in "${NEW_BASELINES_TESTS[@]}"
do
echo " $test_name"
done
fi
fi

if [[ $skip_check_results == true ]]; then
Expand Down Expand Up @@ -653,6 +700,7 @@ in_metatask=false
[[ -f $TESTS_FILE ]] || die "$TESTS_FILE does not exist"

LAST_COMPILER_NR=-9999
COMPILE_PREV==''

declare -A compiles

Expand All @@ -665,13 +713,14 @@ while read -r line || [ "$line" ]; do
JOB_NR=$( printf '%03d' $(( 10#$JOB_NR + 1 )) )

if [[ $line == COMPILE* ]]; then

COMPILE_NAME=$( echo $line | cut -d'|' -f2 | sed -e 's/^ *//' -e 's/ *$//')
RT_COMPILER=$(echo $line | cut -d'|' -f3 | sed -e 's/^ *//' -e 's/ *$//')
MAKE_OPT=$( echo $line | cut -d'|' -f4 | sed -e 's/^ *//' -e 's/ *$//')
MACHINES=$( echo $line | cut -d'|' -f5 | sed -e 's/^ *//' -e 's/ *$//')
CB=$( echo $line | cut -d'|' -f6)
COMPILE_NR=${COMPILE_NAME}_${RT_COMPILER}
COMPILE_PREV=${COMPILE_NR}

set +u
if [[ ! -z ${compiles[$COMPILE_NR]} ]] ; then
Expand All @@ -695,33 +744,11 @@ while read -r line || [ "$line" ]; do
fi
fi

cat << EOF > ${RUNDIR_ROOT}/compile_${COMPILE_NR}.env
export JOB_NR=${JOB_NR}
export COMPILE_NR=${COMPILE_NR}
export MACHINE_ID=${MACHINE_ID}
export RT_COMPILER=${RT_COMPILER}
export PATHRT=${PATHRT}
export PATHTR=${PATHTR}
export SCHEDULER=${SCHEDULER}
export ACCNR=${ACCNR}
export QUEUE=${COMPILE_QUEUE}
export PARTITION=${PARTITION}
export ROCOTO=${ROCOTO}
export ECFLOW=${ECFLOW}
export REGRESSIONTEST_LOG=${REGRESSIONTEST_LOG}
export LOG_DIR=${LOG_DIR}
EOF

if [[ $ROCOTO == true ]]; then
rocoto_create_compile_task
elif [[ $ECFLOW == true ]]; then
ecflow_create_compile_task
else
./run_compile.sh ${PATHRT} ${RUNDIR_ROOT} "${MAKE_OPT}" ${COMPILE_NR} > ${LOG_DIR}/compile_${COMPILE_NR}.log 2>&1
if [[ $CREATE_BASELINE == true && $NEW_BASELINES_FILE != '' ]]; then
continue
fi

RT_SUFFIX=""
BL_SUFFIX=""
create_or_run_compile_task

continue

Expand Down Expand Up @@ -751,6 +778,26 @@ EOF
fi
fi

COMPILE_METATASK_NAME=${COMPILE_NR}
if [[ $CREATE_BASELINE == true && $NEW_BASELINES_FILE != '' ]]; then
if [[ ! " ${NEW_BASELINES_TESTS[*]} " =~ " ${TEST_NAME} " ]]; then
echo "Link current baselines for test ${TEST_NAME}_${RT_COMPILER}"
(
source ${PATHRT}/tests/$TEST_NAME
ln -s ${RTPWD}/${CNTL_DIR}_${RT_COMPILER} ${NEW_BASELINE}
)
continue
else
echo "Create new baselines for test ${TEST_NAME}_${RT_COMPILER}"
# look at COMPILE_PREV, and if it's not an empty string run compile step
# and reset it to empty so that we do not run compile more than once
if [[ ${COMPILE_PREV} != '' ]]; then
create_or_run_compile_task
[[ $ROCOTO == true || $ECFLOW == true ]] && COMPILE_PREV=''
fi
fi
fi

# 35 day tests
[[ $TEST_35D == true ]] && rt_35d

Expand All @@ -762,7 +809,7 @@ EOF
new_compile=false
in_metatask=true
cat << EOF >> $ROCOTO_XML
<metatask name="compile_${COMPILE_NR}_tasks"><var name="zero">0</var>
<metatask name="compile_${COMPILE_METATASK_NAME}_tasks"><var name="zero">0</var>
EOF
fi

Expand Down