#!/bin/bash
#SBATCH --job-name=DrSFC_BC_Hist
#SBATCH --array=0-66%12
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --time=03:00:00
#SBATCH --output=/home/tanpv/Progs/CLI/Dr/logs/ope_bc_hist_%A_%a.out
#SBATCH --error=/home/tanpv/Progs/CLI/Dr/logs/ope_bc_hist_%A_%a.err
set -euo pipefail
cd /home/tanpv/Progs/CLI/Dr
export OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
idx=$SLURM_ARRAY_TASK_ID
year=$((2021 + idx / 12))
month=$((idx % 12 + 1))
for cycle in 1 2 3 4 5 6; do
  f=/home/tanpv/Data/562_VNU/0.25_VN/For_BC_Ope/$(printf "%04d/%02d" "$year" "$month")/RegCM_$(printf "%02d" "$cycle").nc
  [[ -f "$f" ]] || continue
  /home/hapt/miniconda3/bin/python3 operational_forecast.py --year "$year" --month "$month" --cycle "$cycle" --bc-only || { echo "SKIP invalid cycle $year-$month-$cycle"; continue; }
done
