#!/bin/bash

# Run a set of blocks of UTEP stations, concatenating output into one
# file

OUTPUT=UTEP.my_tc

function run_tc() {
  NORTH=$1 ; SOUTH=$2 ; EAST=$3 ; WEST=$4
  STNFILE="teststns_$NORTH-${SOUTH}_$EAST-$WEST"
  OUT=${STNFILE}.tc
  echo "# current block: $NORTH to $SOUTH, $EAST to $WEST" > $OUT
  ./grab_stns $NORTH $SOUTH $EAST $WEST > $STNFILE
  time ../terrain $STNFILE >> $OUT 2>>tc_out
  }

# cleanup from last run
rm teststns_*
echo `date` > tc_out

echo "# Automated run of blocks of UTEP stations for TC testing." > $OUTPUT
# start 2 runs in the background, then another, than wait for last
# before concatenating all output files into one giant one...
# 	North	South	East	West
#run_tc  44	43	-112	-113 &
run_tc  38	35	-112	-115 &
run_tc  47	45	-116	-120 &
wait # let RAM drain
run_tc  45	44	-101	-106 &
run_tc  35	32	-109	-112 &
wait # let RAM drain
run_tc  45	42	-109	-112 &
# wait for all terrain corrections to finish, then cat em together
wait
cat teststns_*tc >> $OUTPUT
