#!/bin/bash -ue

# Usage: ece2evt-master.sh <expname> <conf_file.txt>

# launch ece2evt jobs

# set experiment name
expname=$1

# configuration
conf_file=$2

# set path to programs (if necessary)
CDO_PATH=
NCO_PATH=

[ -n "$CDO_PATH" ] && PATH=${CDO_PATH}:$PATH
[ -n "$NCO_PATH" ] && PATH=${NCO_PATH}:$PATH


if [ ! -f $conf_file ]
then
    echo "$conf_file doesn't exist - stopping"
    exit -1
fi

. $conf_file

# process ifs output
(( nprocs_ifs > 0 )) && \
    sbatch -N 1-1 -n $nprocs_ifs -t 1:00:00 ece2evt-ifs.sh $expname $conf_file

# process nemo output
(( nprocs_nemo > 0 )) && \
    sbatch -N 1-1 -n $nprocs_nemo -t 1:00:00 ece2evt-nemo.sh $expname $conf_file

exit 0
