#!/bin/sh
cd "${0%/*}" || exit 1    # Run from this directory

#
# FUNCTIONS
#
usage()
{
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done

    cat<<USAGE
Usage: ${0##*/} [OPTION]

options:
  -l         -latestTime option for sample
  -h         help

Runs a set of samples across the cone face and concatenates output files
USAGE
    exit 1
}

#------------------------------------------------------------------------------

unset timeOpt

# parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
    -h | -help)
        usage
        ;;
    -l | -latestTime)
        timeOpt="-latestTime"
        shift
        ;;
    *)
        usage "unknown option/argument: '$*'"
        ;;
    esac
done

sampleDir=postProcessing/sample
ext="$(find $sampleDir -mindepth 2 | head -1 | xargs basename | cut -d_ -f2-)"

for d in $sampleDir/*
do
    cat "${d}/cone25_${ext}" "${d}/cone55_${ext}" "${d}/base_${ext}"\
        > "${d}/biconic_${ext}"
done

#------------------------------------------------------------------------------
