#! /bin/csh

set D = /Net/elninoshare/abhardwaj/PR/CCSM4/RSM
set O = /Net/elninoshare/abhardwaj/PR/CCSM4/RSM/netcdf
set O1 = /Net/water/abhardwaj/CCSM4/RSM/RSM_netcdf/CCSM4

set yr = `cat list`
set n = `cat list |wc -l`

set cnt = 1
while ($cnt <= $n)

cd $D/$yr[$cnt]
set y1 = `cat $O/list6h`
set n1 = `cat $O/list6h |wc -l`
set nn = `cat $O/list6h | cut -c9-12`

set cnt2 = 1
while ($cnt2 <= $n1)
echo $n1 $nn[$cnt2]

if(-e $O/$yr[$cnt]/r_pgb$nn[$cnt2].nc) then
echo $O/$yr[$cnt]/r_pgb$nn[$cnt2].nc exists
else
rsync -a -v --ignore-existing /Net/elninoshare/abhardwaj/PR/CCSM4/RSM/netcdf/2043/r_pgb* .

#rm -f $O/$yr[$cnt]/r_pgb$nn[$cnt2].grb
#rm -f $O/$yr[$cnt]/r_pgb$nn[$cnt2].nc
#cp  $D/$yr[$cnt]/$y1[$cnt2] $O/$yr[$cnt]/r_pgb$nn[$cnt2].grb

cd $O/$yr[$cnt]
#ncl_convert2nc -u $O/$yr[$cnt]/r_pgb$nn[$cnt2].grb

#ncl_convert2nc $O/$yr[$cnt]/r_pgb$nn[$cnt2].grb
endif
#rm -f $O/$yr[$cnt]/r_pgb$nn[$cnt2].grb

@ cnt2 = $cnt2 + 1
end
@ cnt = $cnt + 1
end
