#!/bin/csh -x

# This script computes combined flow timeseries for each basin in station list


set stalist = station.list
set run = 1
set fluxdir = ../output/fluxes/
set outdir = ../output/combined_flow/

foreach sta (`cat $stalist`)

set llist = ../nat_flow/llists/{$sta}_ll.txt 
set areas = ../nat_flow/bas_areas_vic/{$sta}_areas.txt #km^3
set obs = ../nat_flow/{$sta}_obs_mon_af.txt.cfs
set sim = {$outdir}{$sta}.month
set outf = {$outdir}{$sta}.month.ps

./sum_ro_bf.scr $sta $run $llist $fluxdir $outdir $areas 

./plot_month.ALL.csh $sta $obs $run $sim $outf
#convert "/raid7/marketa/NPR/Sacramento/2d_calibration/BENDB_"$run".month.ps" "/raid7/marketa/NPR/Sacramento/2d_calibration/BENDB_"$run".month.png"

set rslt_stat = {$outdir}resultsfile.{$sta}
set stats =  {$outdir}stats.{$sta}
./sflow_opti_stats_monthly.pl $sim $obs $rslt_stat 195010 201009 -9999 $stats

end # basin loop
