#!/bin/bash

function cmd_create()
{
    export ESM_ROOT="$PWD/../../"
    export ARCH=X64_CURIE
    STORE_ROOT="$STOREDIR/aquaplanet"
    STORE0L="$STORE_ROOT/ce0l"
    for DIR in ce0l year01 year02 ; do
	rm -rf $DIR $STORE_ROOT/$DIR
    done
    ./prepare.sh ce0l                                ce0l   "$STORE0L"
    ./prepare.sh first $STORE0L                      year01 "$STORE_ROOT/year01"
    ./prepare.sh next  $STORE0L "$STORE_ROOT/year01" year02 "$STORE_ROOT/year02"
}

function submit_X64_CURIE()
{
    EXP=$1 ; shift
    CMD="ccc_msub $* $EXP/job.sh"
    MSG=$($CMD)
    echo "$CMD : $MSG"
    JOBID=$( echo "$MSG" | awk '{print $NF}' )
    DEP="-a $JOBID"
}

function cmd_submit()
{
    DEP=""
    submit_$ARCH ce0l
    submit_$ARCH year01 $DEP
    submit_$ARCH year02 $DEP
}

function cmd_()
{
echo
}

echo "Your command : $0 $*"
echo "Usage : $0 [create|submit]"
ARCH=X64_CURIE
cmd_$1
