#!/bin/bash

############ AUTOSUBMIT INPUTS ############
projdir=%PROJDIR%
outdir=%common.OUTDIR%
tmpdir=%common.TMPDIR%
script=%common.SCRIPT%
CHUNK=%CHUNK%
###############################

if [ -d $projdir ]; then
  cd $projdir
else
  cd ${tmpdir}/sunset/$(basename ${outdir})/
fi

source chunk_to_recipe

srcdir=${tmpdir}/$(basename ${outdir})

atomic_recipe=${srcdir}/logs/recipes/atomic_recipe_${recipe}.yml

set +eu
source MODULES
set -eu

Rscript ${script} ${atomic_recipe}
