# ============================================================================
#  SHARED SETTINGS OF THE ROUND 5 RUNS.
#
#  Runs from the v7 gdirs (../lmr_gdirs_v7_202610): per-glacier dynamic
#  melt_f calibration of every sensitivity config. The long run of the
#  calibration itself (DYN_YS -> 2025, with the final melt_f) is kept: it is
#  the HIST run we compare with the LIA. Sourced by submit.sh and
#  run_dyn_slurm.sh. The OGGM version, container and sample data come from
#  the v7 config, so that the runs use exactly the OGGM which built the gdirs.
# ============================================================================

source /home/www/fmaussion/runs/lmr_2025/lmr_gdirs_v7_202610/common.sh

R5_DIR=/home/www/fmaussion/runs/lmr_2025/round5

# Per-glacier dynamic melt_f calibration, as round4a: OGGM's
# run_dynamic_melt_f_calibration with the plain dynamic_melt_f_run (no
# dynamic spinup, so no temp_bias loop). Each iteration runs DYN_YS -> end of
# the forcing and must match Hugonnet 2000-2020 within DYN_ERR_FACTOR x its
# error. OGGM's default minimum step (the max step uses the farther melt_f
# bound since #2005).
# Can be overridden by a run name <exp>_ys<year> (submit.sh exports it)
DYN_YS=${DYN_YS:-1000}
DYN_ERR_FACTOR=0.2
# Calibration method: oggm (run_dynamic_melt_f_calibration; its local search
# gets trapped by the non-monotonic response, see CLAUDE.md) or scan
# (scan_calib.py: melt_f 2-10 by 1 + bisection). A run name ending in _scan
# selects scan (submit.sh exports it).
CALIB=${CALIB:-oggm}
# scan: how to choose between several roots: volume (V/V_inv closest to 1) or static
SELECT=${SELECT:-volume}
DYN_MAXITER=40
DYN_STEP_MIN=0.1
# The calibration run, merged to output/<run>/<DYN_ID>_reg11.nc
DYN_ID=hist_dyn_calib

# Hugonnet ±1 sigma runs (<exp>_hugp / <exp>_hugm): every glacier's target is
# shifted by the same amount, the regional 2000-2020 uncertainty of RGI 11
# (hugonnet_2021_regional_avg.csv: -0.864 ± 0.108 m w.e. yr-1). hugp = less
# mass loss (target + HUG_SIGMA), hugm = more loss. The glacier's own error
# (the tolerance) is unchanged.
HUG_SIGMA=108

# Optional second run with the calibrated melt_f, from RUN_YS (e.g. 1 for the
# attribution ensemble). Empty: no second run, the calibration run is enough.
RUN_YS=
RUN_ID=lmr_mira_hist

RUN_CHUNK_SIZE=100
RUN_N_CHUNKS=40
RUN_CPUS=8 ; DYN_RUN_TIME=12:00:00

# The oggm_env python, for the merge job (outside the container)
LOCAL_PY=/home/users/fmaussion/.miniforge3/envs/oggm_env/bin/python
