#!/bin/bash

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

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

source chunk_to_recipe

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

set +eu
source MODULES
set -eu

${singu_prefix} Rscript ${script} ${atomic_recipe}
