#!/bin/csh -f
set ipath='/glade/work/leishanj/CESM1_2_2/sst_flow/sst'
set opath='/glade/work/leishanj/CESM1_2_2/sst_flow/sst/year'
set tyear1  = 1980 #1950 #1978
set tyear2  = 2010 #2016
@ tyear10 = $tyear1 - 1
@ tyear20 = $tyear2 + 1
echo $tyear10
cdo seldate,$tyear10-01-01,$tyear20-12-31 HadISST_ssta_1970_2018.nc HadISST_test1.nc
cdo inttime,$tyear1-01-01,12:00:00,1day HadISST_test1.nc HadISST_test_day.nc
cdo delete,month=2,day=29 HadISST_test_day.nc HadISST_test_day_365.nc
cdo seldate,$tyear1-01-01,$tyear2-12-31 HadISST_test_day_365.nc HadISST_test_day_365_${tyear1}to${tyear2}.nc
cdo ydayavg HadISST_test_day_365_${tyear1}to${tyear2}.nc HadISST_clim_day_${tyear1}to${tyear2}.nc
cdo splityear HadISST_test_day_365_${tyear1}to${tyear2}.nc $opath/year.
#rm HadISST_test1.nc HadISST_test_day.nc HadISST_test_day_365.nc HadISST_test_day_365_${tyear1}to${tyear2}.nc


