#!/bin/csh -f

set datadir = '../../csv'

set FC = /usr/bin/gfortran

set nobs = 31
set ndat = 121		

set prname = P
set psname = .csv


$FC calcwind.f
mv a.out calcwind.out


@ n = 1
rm datafile
while ( $n <= $nobs )
  if ( $n < 10 ) then
      ln -s ${datadir}/${prname}0${n}${psname} datafile
    else
      ln -s ${datadir}/${prname}${n}${psname}  datafile
  endif

  ./calcwind.out > wind.dat

gnuplot <<EOF
set term png
set out "temp.png"
unset key
unset colorbox
set xlabel "degrees from north in a clockwise direction"
#set xrange [-22.5:337.5]
set ylabel "frequency"
set yrange [0:1.0]
set title "n = ${n}"
set palette rgbformulae 33,13,10
set style fill solid
plot n=${n}, "wind.dat" every ::1 using 0:3:xtic(1) with boxes palette frac (n-1)/(${nobs}-1.0)
EOF

  if ( $n < 10 ) then
      mv temp.png ${prname}0${n}.png
    else
      mv temp.png ${prname}${n}.png
  endif

  @ n = $n + 1
  rm datafile
end

convert -delay 50 ${prname}*.png wind.gif
rm ${prname}*.png
