#/!bin/bash
# This script launch R programs to test the difference between two experiments.

set -o nounset
set -o errexit

if [ $# -ne 5 ] ; then
   echo "Usage:   ./compare.sh EXP1 EXP2 YEARSTART YEAREND NMEMB"
   echo "Example: ./ensemble.sh e00x e00y 1990 2000 5"
   exit 1
fi

exp1=$1
exp2=$2
year1=$3
year2=$4
nmemb=$5

# Configuration
exp=$exp1
. ./config.sh
mkdir -p $OUTDIR
module load R
rep=$MAINDIR/EC-Earth_diags/
echo $rep

# Comparing Reichler & Kim indices
Rscript R_scripts/KS_index.R $rep $exp1 $exp2 $year1 $year2

# Mapping the differences between the two experiments
Rscript R_scripts/map_diff_experiments.R $rep $exp1 $exp2 $year1 $year2 $nmemb
