#!/bin/csh -x

set sumdir = /home/disk/margaret/mauger/met_data/caor_16d/monthly_summaries/
set maxswe = /home/disk/margaret/mauger/met_data/caor_16d/swe_stats/max_swe.xyz

echo >! pcptmp

foreach mon (oct nov dec jan feb mar)
 if ($mon == oct) then
  awk '{print $0;}' ${sumdir}precip_monthly_tot_${mon}.xyz >! pcptmp
 else
  awk '{print $3;}' ${sumdir}precip_monthly_tot_${mon}.xyz >! tmp 
  paste pcptmp tmp >! tmp2
  mv -f tmp2 pcptmp
#  rm -rf tmp
 endif
end

awk '{print ($3+$4+$5+$6+$7+$8);}' pcptmp >! tmpp
paste $maxswe tmpp >! tmp2
awk '{printf "%5.5f %5.5f %5.3f\n", $1,$2,$3/$4;}' tmp2 >! hist_swe_prcp_ratio_oct-mar
#rm -rf pcptmp tmpp tmp tpm2 swetmp
