#!/bin/bash

# ICON
#
# ------------------------------------------
# Copyright (C) 2004-2026, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ------------------------------------------

# abort on error
set -euo pipefail

cd $(dirname "${BASH_SOURCE[0]}")
basedir=$(cd ../.. && pwd)

#############################################################################
##
## create mch-opr list
##
#############################################################################

listname=${1:-mch-opr}
./rmlist $listname

machine=balfrin
./addmachine $machine --list $listname
./addbuilder balfrin_gpu_nvidia_mixed --machine $machine --build_script="./config/buildbot/balfrin_gpu_nvidia_mixed" --builderflags="Active" --list $listname
# the alps_mch_test builders may be moved to different machines in the future
./addbuilder alps_mch_test_gpu --machine $machine --build_script="./config/buildbot/alps_mch_test_gpu" --builderflags="Active" --list $listname

# add bench experiments
./../experiments/addexp_from_yml --tag $listname

add_store_performance_exp () {
    exp=$1
    cp ${basedir}/run/performance/pp.store_performance ${basedir}/run/performance/pp.store_performance_${exp}
    ./addexp "performance/pp.store_performance_${exp}"  --builders "balfrin_gpu_nvidia_mixed alps_mch_test_gpu" --list $listname --runflags "cpu_time=00:10:00"
    ./adddep --from-experiment "performance/pp.store_performance_${exp}" --to-experiment "checksuite.icon-dev/check.${exp}" --builders "balfrin_gpu_nvidia_mixed alps_mch_test_gpu" --list $listname
}

# create a store script for each experiment and add the exp and dep
add_store_performance_exp "mch_icon-ch2"
add_store_performance_exp "mch_icon-ch1"
add_store_performance_exp "mch_kenda-ch1"

#lets see the list
./lslist $listname
#-----------------------------------------------------------
