#!/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
# ------------------------------------------

# assuming you are in the ICON base directory (i.e. your git repo)
# Prepare environment on Balfrin
source /scratch/d1000/apps/buildbot/bb-venv/bin/activate

# create the experiment list
pushd scripts/buildbot_scripts
./create_list_merge2rc

# build ICON for balfrin_gpu_nvidia_mixed. This is an in-source build. Out-of-source mode is not supported at the moment.
./build balfrin_gpu_nvidia_mixed --list merge2rc
popd

# Some tests expect a BB_NAME so set it
export BB_NAME=balfrin_gpu_nvidia_mixed

# load necessary modules
module use $USER_ENV_ROOT/modules
module load cdo

# Run all experiment
./scripts/buildbot_scripts/runexp

# At the end of the script output, it should show only OK. Not like here:
#
# exit code for .../run/check.mch_icon-ch1_small.run: OK (jobID:302321) (code:0)
# exit code for .../run/check.mch_icon-ch2_small.run: OK (jobID:302322) (code:0)
# exit code for .../run/check.mch_kenda-ch1_small.run: FAILED (jobID:302327) (code:1)
