#!/bin/bash

# run this script first 

# adapt the line below as needed
RUN_DIR=/glade/scratch/yannm/DCMIP2016/RUNS/

# the runs must be organized as : $RUN_DIR/TESTCASE/VARIANT
# with TESTCASE = SUPERCELL ...
# and VARIANT = dry ...
# this structure will be reflected in the form tescase/TESTCASE/variant/VARIANT
# data/TESTCASE/ contains NCL scripts for each test case

ROOT=$(pwd)

cd $RUN_DIR
TESTS=$(ls)
echo "Test cases : " $TESTS
for CASE in $TESTS ; do
    cd $RUN_DIR/$CASE
    VARIANTS=$(ls)
    for VARIANT in $VARIANTS ; do
	DIR=$ROOT/testcase/$CASE/variant/$VARIANT
	mkdir -p $DIR
	cd $DIR
	for x in $RUN_DIR/$CASE/$VARIANT/*.nc ; do
	    echo $x
	    ln -sf $x .
	done
    done
done
