#!/bin/bash

#Make work for leap years

#startyear=1999
#endyear=2007
#totaldays=(31 28 31 30 31 30 31 31 30 31 30 31)

startyear=2003
endyear=2003

startmonth=12
endmonth=12

totaldays=(31 28 31 30 31 30 31 31 30 31 30 31)
totaldaysleap=(31 29 31 30 31 30 31 31 30 31 30 31)


#Satellite
count1=$startyear
while [ $count1 -le $endyear ]

do

#if [ $count1 -eq $startyear ]
#then
#startmonth=7
#lse
#startmonth=1
#fi 

#Month
count2=$startmonth
#while [ $count2 -le 12 ]
while [ $count2 -le $endmonth ]

do

if [ $count2 -lt 10 ]
then
monthstring=0${count2}
else
monthstring=$count2
fi

daytotal_index=`expr $count2 - 1`
tempdaytotal=${totaldays[daytotal_index]}
count3=1
while [ $count3 -le $tempdaytotal ]
#while [ $count3 -le $totaldays ]

do 

if [ $count3 -lt 10 ]
then
daystring=0${count3}
else
daystring=${count3}
fi


ftppath=ftp://ftp.ssmi.com/qscat/bmaps_v04/y${count1}/m${monthstring}/
file=qscat_${count1}${monthstring}${daystring}v4.gz
testget=${ftppath}${file}
#echo $testget


wget ${ftppath}${file}

count3=`expr $count3 + 1`

done

count2=`expr $count2 + 1`

done

count1=`expr $count1 + 1`

done
