#!/bin/bash

############ AUTOSUBMIT INPUTS ############
proj_dir=%PROJDIR%
outdir=%common.OUTDIR%
script=%common.SCRIPT%
CHUNK=%CHUNK%
###############################

cd $proj_dir

atomic_recipe_number=$(printf "%02d" $CHUNK)
atomic_recipe=${outdir}/logs/recipes/atomic_recipe_${atomic_recipe_number}.yml

## Workaround to avoid bug in conda activate/source activate when running
## inside bash script
set +eu
source /gpfs/projects/bsc32/software/suselinux/11/software/Miniconda3/4.7.10/etc/profile.d/conda.sh
conda activate /esarchive/scratch/vagudets/conda-cerise/conda/envs
set -eu

Rscript ${script} ${atomic_recipe}
