#!/usr/bin/env bash
set -Eeuo pipefail

LOG="/station/instruments/disdrodb/cron_parsivel.log"
mkdir -p "$(dirname "$LOG")"
exec >>"$LOG" 2>&1
echo "=== $(date -Is) START ==="

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

# Use the exact interpreter that has the user-site netCDF4 wheel
PY="/sca/compilers_and_tools/python/miniforge3/bin/python"

# Ensure user-site packages are allowed (some clusters set this var)
unset PYTHONNOUSERSITE PYTHONPATH

"$PY" -c 'import netCDF4, sys; print("[ok] netCDF4:", netCDF4.__version__, "python:", sys.executable)'

"$PY" /station/instruments/disdrodb/parsivel_daily_with_fill_value.py \
  --out-dir /station/instruments/disdrodb/PAR001_UQAM_PK \
  --fast-skip

echo "=== $(date -Is) END ==="

