#!/bin/tcsh -f
##set echo
setenv S /Net/elninost4/amishra/RSM/libs/etc
##setenv D /Net/water/amishra/RSM_ROMS/MONSOON15km/R2-SODA/theta_S/Atmosphere
##setenv O /Net/water/amishra/RSM_ROMS/MONSOON15km/R2-SODA/theta_S/Atmosphere/mon
##setenv O /Net/water/amishra/RSM_ROMS/MONSOON10km/RCM-CLD2/STAMPEDE/A/mon
##setenv D /Net/water/amishra/RSM_ROMS/MONSOON10km/RCM-CLD2/STAMPEDE/A
setenv O /Net/water/amishra/RSM_ROMS/FL-DWN/HIS/CLD2/A/mon
setenv D /Net/water/amishra/RSM_ROMS/FL-DWN/HIS/CLD2/A
@ yr = 2004
#echo `date `>> ${yr}.log
while ($yr <= 2005)
echo `date `>> ${yr}.log

@ ynxt = $yr + 1

echo "$yr / 4" >> tmp
echo "quit" >> tmp
set leap = `bc -l < tmp`
rm -f tmp
set leaptrue = `echo $leap | cut -c5`
if ($leaptrue == 0) then
   echo 'yes, '$yr' is a leap year'
endif
cd ${D}/$yr

###################################################################################
#     List of files for January
###################################################################################
${S}/monftmean $yr 3 01 
wait
${S}/force_grib_date_mon r_pgb.${yr}01.avrg.grib ${yr}010100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 02
wait
${S}/force_grib_date_mon r_pgb.${yr}02.avrg.grib ${yr}020100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 03
wait
${S}/force_grib_date_mon r_pgb.${yr}03.avrg.grib ${yr}030100
rm -rf grmean.*
***********
${S}/monftmean $yr 3 04
wait
${S}/force_grib_date_mon r_pgb.${yr}04.avrg.grib ${yr}040100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 05
wait
${S}/force_grib_date_mon r_pgb.${yr}05.avrg.grib ${yr}050100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 06
wait
${S}/force_grib_date_mon r_pgb.${yr}06.avrg.grib ${yr}060100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 07
wait
${S}/force_grib_date_mon r_pgb.${yr}07.avrg.grib ${yr}070100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 08
wait
${S}/force_grib_date_mon r_pgb.${yr}08.avrg.grib ${yr}080100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 09
wait
${S}/force_grib_date_mon r_pgb.${yr}09.avrg.grib ${yr}090100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 10
wait
${S}/force_grib_date_mon r_pgb.${yr}10.avrg.grib ${yr}100100
rm -rf grmean.*
**********
${S}/monftmean $yr 3 11
wait
${S}/force_grib_date_mon r_pgb.${yr}11.avrg.grib ${yr}110100
rm -rf grmean.*
#***********
${S}/monftmean $yr 3 12
wait
${S}/force_grib_date_mon r_pgb.${yr}12.avrg.grib ${yr}120100
rm -rf grmean.*
##################################################################################
mv ${D}/${yr}/r_pgb.${yr}??.avrg.grib ${O}/.
###################################################################################
echo `date `>> ${yr}.log
@ yr = ${yr} + 1
end
exit
