#!/bin/csh -f

set WORKDIR = `pwd`
set DATADIR = "/data2/kotsuki/JAXA_GPM/data/"

rm *~
set NORMDAY = (31 28 31 30 31 30 31 31 30 31 30 31)
set LEAPDAY = (31 29 31 30 31 30 31 31 30 31 30 31)

@ YEAR = 2013
while ($YEAR <= 2013)
@ MON = 1
while ($MON <= 12)

@ CHK = $YEAR % 4
if( $CHK == 0 ) then
  set DAYMAX = $LEAPDAY[$MON]
else
  set DAYMAX = $NORMDAY[$MON]
endif

#echo DAYS of Feb. ${YEAR},${DAYMAX}

@ DAY = 1
while ($DAY <= $DAYMAX)
#  echo ${YEAR}, ${MON}, ${DAY}
  if( $MON <= 9) then
    set CMON = "0${MON}"
  else
    set CMON = "${MON}"
  endif
  if( $DAY <= 9) then
    set CDAY = "0${DAY}"
  else
    set CDAY = "${DAY}"
  endif

  set DIR = "${DATADIR}/${YEAR}/${CMON}/${CDAY}"
#  echo ${DIR}
  cd ${DIR}
#    ls
    gunzip -v *.gz
  cd ${WORKDIR}
@ DAY ++
end
@ MON ++
end
@ YEAR ++
end



