#!/bin/csh

if($#argv != 5)then
    echo
    echo "Usage: $0 {network} {site} {month} {day} {year}"
    echo "  where"
    echo "     nnnn = Network (GPMVN, GCOMW1, KWAJ, NPOL)"
    echo "     site = ssss (NPOL, KWAJ)"
    echo "     month = mm (ex. 07)"
    echo "     day = dd (ex. 23)"
    echo "     year = yyyy (ex. 2008)"
    echo
    exit
endif

set network = $1
set site = $2
set month = $3
set day = $4
set year = $5
set mday = $3$4
set syear = `echo $year | cut -c3-4`
set yymmdd = $syear$month$day
set myear = $month'-'$year



cd ./cal_uf/

#if (site == 'Reunion') then
#   if (-e /gvs2/gpmgv_data/gpmgv/Piton_Villers/1CUF/$year/$mday/) then
#    idl<<EOF
#      cal_uf_mod,'$network','$site','$month','$day','$year'
#     cal_uf_mod2,'$network','$site','$month','$day','$year'
#    EOF
#   endif
#endif

if ($network == 'GPMVN') then

if (-e /gvs2/gpmgv_data/gpmgv/$site/1CUF/$year/$mday/) then

idl<<EOF
   cal_uf_mod,'$network','$site','$month','$day','$year'
#   cal_uf_mod2,'$network','$site','$month','$day','$year'
EOF

else
 
echo " "
echo "**************************************"
echo "No data for "$network" "$site" "$month"/"$day"/"$year
echo "**************************************"
echo " "

endif

endif

if ($network == 'GCOMW1') then

if (-e /gvs2/gpmgv_data/gcomw1/$site/1CUF/$year/$mday/) then

idl<<EOF
   cal_uf_mod,'$network','$site','$month','$day','$year'
EOF

else
 
echo " "
echo "**************************************"
echo "No data for "$network" "$site" "$month"/"$day"/"$year
echo "**************************************"
echo " "

endif

endif

if ($network == 'F16') then

if (-e /gvs2/gpmgv_data/f16/$site/1CUF/$year/$mday/) then

idl<<EOF
   cal_uf_mod,'$network','$site','$month','$day','$year'
EOF

else

echo " "
echo "**************************************"
echo "No data for "$network" "$site" "$month"/"$day"/"$year
echo "**************************************"
echo " "

endif

endif

if ($network == 'KWAJ') then

if (-e /gvs2/trmmgv/KWAJ/uf/not_calibrated/$myear/$yymmdd/) then

idl<<EOF
#   cal_uf_mod,'$network','$site','$month','$day','$year'
   cal_uf_mod2,'$network','$site','$month','$day','$year'
EOF

else

echo " "
echo "**************************************"
echo "No data for "$site" "$month"/"$day"/"$year
echo "**************************************"
echo " "

endif

endif

if ($network == 'NPOL') then
foreach l (ppi pps rhi qvp surv) 
#foreach l (rhi)
if (-e /gpmgv1/NPOL/UF/not_calibrated/$year/$mday/$l/) then

idl<<EOF
   cal_uf_mod2,'$network','$site','$month','$day','$year',stype='$l'
   #cal_uf_mod3,'$network','$site','$month','$day','$year',stype='$l'
EOF

else

echo " "
echo "**************************************"
echo "No data for "$network" "$l" "$month"/"$day"/"$year
echo "**************************************"
echo " "

endif
end
endif
