#! /bin/csh -f

set start_time = `date +%s`

source /aca1/nb965428/.cshrc

set mm = `date -u +%m`
set dd = `date -u +%d`
set hh = `date -u +%k`
set yy = `date -u +%y`
echo The Current Date Is $yy$mm$dd

cd /aca1/nb965428/wrf2gem/mesonet/climate/daily

set currentdate = 20${yy}${mm}${dd}
set startday = -480
set endday   = -2
while ( $startday <= $endday)

set dd = `date +%d -d "$currentdate UTC + $startday day"`
set mm = `date +%m -d "$currentdate UTC + $startday day"`
set yy = `date +%y -d "$currentdate UTC + $startday day"`

set ddtwo = `date +%d -d "$currentdate UTC - 1 day + $startday day"`
set mmtwo = `date +%m -d "$currentdate UTC - 1 day + $startday day"`
set yytwo = `date +%y -d "$currentdate UTC - 1 day + $startday day"`

set date = $yy$mm$dd
mkdir $date
cd $date


convert monthly.png -resize 750x750 -quality 100 +repage "outputm.png"

convert outputm.png -font helvetica -gravity north -stroke black -strokewidth 1.2 -pointsize 30 -annotate -180+50 20$yytwo-$mmtwo-$ddtwo output2m.png

#convert output.png -gravity north -fill '#0008' -draw 'rectangle 5,128,114,145' \
#          -fill white   -annotate +10+141 'Faerie Dragon'  output2.png

# convert -delay 20 -loop 0 */output2.png year.gif
# cp /home/nb965428/public_html/live/
cd ..

@ startday ++
end

set end_time   = `date  +%s`
@ length_time  = $end_time - $start_time
echo "It took this long to run getdaily.csh: $length_time seconds"
