# ============================================================================
#  SHARED SETTINGS OF THE ROUND 4 RUNS.
#
#  Sourced by submit.sh and run_slurm.sh. The OGGM version, patch, container
#  and sample data come from the v5 gdirs config, so that the runs always
#  use exactly the OGGM which built the gdirs they start from.
# ============================================================================

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

R4_DIR=/home/www/fmaussion/runs/lmr_2025/round4

# The v5 experiments: one gdir set each, in $V5_DIR/exps/<exp>
V5_EXPS_DIR=$V5_DIR/exps
V5_EXPS_URL=https://cluster.klima.uni-bremen.de/~fmaussion/runs/lmr_2025/lmr_gdirs_v5_202610/exps

# The run: from the model flowlines at the RGI date, starting in year 1 of the
# forcing (year 0 is dropped in data/unstacked). The first centuries are a
# spinup and get discarded later anyway.
RUN_YS=1
RUN_ID=lmr_mira_hist

# 2024 years per glacier is slow, and the big glaciers dominate, so many small
# chunks are better than few big ones. Region 11 has 40 chunks of 100. A
# round3 hist run was ~16 min on 64 cpus for the whole region.
RUN_CHUNK_SIZE=100
RUN_CPUS=8 ; RUN_TIME=04:00:00

# Per-glacier dynamic melt_f calibration (DYN_CALIB=1 ./submit.sh ...): the
# calibration runs start in DYN_YS, and must match Hugonnet within
# DYN_ERR_FACTOR x its error (0.2, as oggm_prepro). Up to 20 iterations of a
# DYN_YS -> 2025 run per glacier, hence the longer time limit.
DYN_YS=1000
DYN_ERR_FACTOR=0.2
# max calibration iterations per glacier (OGGM default 20: with 20, 420 of
# 3892 glaciers stopped at the limit in lam8_ib_dyn20)
DYN_MAXITER=40
# Minimum max-step of melt_f between two calibration iterations
# (melt_f_max_step_length_minimum). OGGM's own step formula has a bug: it
# uses |melt_f_min - melt_f_initial| / maxiter instead of the distance to the
# farther bound, so on its own melt_f can only move ~+-3.5 from 5. We don't
# patch OGGM for this: the step is max(that formula, this minimum), so 0.3
# reproduces the intended step for melt_f_initial ~5 and maxiter 40 (12/40).
# It acts as a prior on how far melt_f may move from its static value:
# 0.1 = OGGM's current behaviour (the *_dynbug runs), 0.3 = the *_dyn runs.
DYN_STEP_MIN=0.3
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
