#%Module1.0

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

source [file join [file dirname $ModulesCurrentModulefile] .pkg]

set ICON_DIR [file dirname [file dirname [file dirname $ModulesCurrentModulefile]]]

prepend-path PATH $ICON_DIR/utils/mkexp
prepend-path PYTHONPATH $ICON_DIR/utils/mkexp
prepend-path MANPATH $ICON_DIR/utils/mkexp/doc

prepend-path PATH $ICON_DIR/utils/plotems
prepend-path MANPATH $ICON_DIR/utils/plotems/man

set build_dir $ICON_DIR/build
if [info exists env(ICON_BUILD_DIR)] {
    if [string equal [file pathtype $env(ICON_BUILD_DIR)] relative] {
        set build_dir $ICON_DIR/$env(ICON_BUILD_DIR)
    } {
        set build_dir $env(ICON_BUILD_DIR)
    }
}

prepend-path MKEXP_PATH $ICON_DIR/run
prepend-path MKEXP_PATH $build_dir/run
prepend-path MKEXP_PATH .

prepend-path PATH $ICON_DIR/bin
prepend-path PATH $build_dir/bin

catch {
    set python_dir [exec python3 -c {import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase':'.'}))}]
    prepend-path PYTHONPATH $ICON_DIR/$python_dir
    prepend-path PYTHONPATH $build_dir/$python_dir
}
