#!/usr/bin/env bash
# run_check.sh — guarantees the same Python as your cron job
# Usage:
#   ./run_check.sh check_quick_day.py ARGUMENTS...
#   ./run_check.sh check_consistency_month.py --month 2025-09 ...
#   ./run_check.sh check_spectra_health.py --month 2025-09 ...

set -Eeuo pipefail

# 1) Load the shared toolchain (harmless if no-op)
if command -v module >/dev/null 2>&1; then
  module load python3/miniforge3 || true
fi

# 2) Use the same interpreter your cron uses
PY="/sca/compilers_and_tools/python/miniforge3/bin/python"

# 3) Ensure user-site packages are allowed and present (no conda init needed)
unset PYTHONNOUSERSITE PYTHONPATH
"$PY" -m pip install --user --quiet --upgrade netCDF4 cftime numpy

# 4) Run the target script with the same interpreter
exec "$PY" "$@"

