#!/bin/csh

if ($#argv != 2) then
        echo "Usage: $0 mm yyyy"
        echo "   where"
        echo "     mm = month (ex. 01)"
        echo "     dd = day (ex. 12)"
        echo "     yyyy = year (ex. 2012)"
        exit
endif

 set month = $1
# set day = $2
 set year = $2
 set shortyear = `echo $2 | cut -c3-4`


foreach i  (15)

 set mday = $month$i
 set yymmdd = $shortyear$month$i


if(-e /gpmraid/raw/NPOL/OLYMPEX/ppi/$year/$mday)then
cd /gpmraid/raw/NPOL/OLYMPEX/ppi/$year/$mday/

foreach f (`ls np1$yymmdd*`)
 set cday = `echo $f | cut -c6-9 `
 mkdir -p /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$cday/ppi
 cp $f /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$cday/ppi
end
endif

if(-e /gpmraid/raw/NPOL/OLYMPEX/rhi_a/$year/$mday)then
cd /gpmraid/raw/NPOL/OLYMPEX/rhi_a/$year/$mday/

foreach g (`ls np1$yymmdd*`)
 set dday = `echo $g | cut -c6-9 `
 mkdir -p /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$dday/rhi_a
 cp $g /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$dday/rhi_a/
end
endif

if(-e /gpmraid/raw/NPOL/OLYMPEX/rhi_b/$year/$mday)then
cd /gpmraid/raw/NPOL/OLYMPEX/rhi_b/$year/$mday/

foreach h (`ls np1$yymmdd*`)
 set eday = `echo $h | cut -c6-9 `
 mkdir -p /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$eday/rhi_b
 cp $h /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$eday/rhi_b/
end
endif

if(-e /gpmraid/raw/NPOL/OLYMPEX/bb/$year/$mday)then
cd /gpmraid/raw/NPOL/OLYMPEX/bb/$year/$mday/

foreach s (`ls np1$yymmdd*`)
 set kday = `echo $s | cut -c6-9 `
 mkdir -p /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$kday/bb
 cp $s /gpmraid/gpmarchive/Radar/NPOL/OLYMPEX/RAW/$kday/bb/
end
endif

end
