clc;clear all;close all;

filename='/data3/yiwen/Timcom_exp/EXP_TIMCOM_renew/test01_control/ocn/DATA_034001.nc'
%=========================================
%!!EXP yr
%=========================================
pathi1='/data3/yiwen/Timcom_exp/EXP_TIMCOM/test01_control/ice/';                            %control run
pathi2='/data3/yiwen/Timcom_exp/EXP_TIMCOM_renew/change_wind_shr_45/GTJRAv2.10/ice/hist/';  %change wind 45
pathi3='/data3/yiwen/Timcom_exp/EXP_TIMCOM_renew/change_FWF_45/GTJRAv2.10/ice/hist/'        %change FWF 45 
% pathi3='/data3/yiwen/Timcom_exp/change_wind_shr_NS/GTJRAv2.10/ice/hist/'   %change wind NS 
% pathi5='/data3/yiwen/Timcom_exp/change_FWF_NS/GTJRAv2.10/ice/hist/'        %change FWF NS 

nyra_start = 346; nyra_end = 366;  
nx=320;ny=288;

AREA1=zeros([nx,ny,(nyra_end-nyra_start+1)*12]);AREA2=zeros([nx,ny,(nyra_end-nyra_start+1)*12]);
AREA3=zeros([nx,ny,(nyra_end-nyra_start+1)*12]);AREA4=zeros([nx,ny,(nyra_end-nyra_start+1)*12]);
AREA5=zeros([nx,ny,(nyra_end-nyra_start+1)*12]);

count=0
for iyr = nyra_start:nyra_end
for im = 1:12
count = count +1;
FNb1 = [pathi1 'GTJRAv2.10.cice.h.' num2str(iyr,'%04d') '-' num2str(im,'%02d') '.nc'];
FNb2 = [pathi2 'GTJRAv2.10.cice.h.' num2str(iyr,'%04d') '-' num2str(im,'%02d') '.nc'];
FNb3 = [pathi3 'GTJRAv2.10.cice.h.' num2str(iyr,'%04d') '-' num2str(im,'%02d') '.nc'];
% FNb4 = [pathi4 'GTJRAv2.10.cice.h.' num2str(iyr,'%04d') '-' num2str(im,'%02d') '.nc'];
% FNb5 = [pathi5 'GTJRAv2.10.cice.h.' num2str(iyr,'%04d') '-' num2str(im,'%02d') '.nc'];

area1 = ncread(FNb1,'aice'); %320*288
area2 = ncread(FNb2,'aice'); 
area3 = ncread(FNb3,'aice'); 
% area4 = ncread(FNb4,'aice');
% area5 = ncread(FNb5,'aice');

for i=1:nx
 for j=1:ny
   AREA1(i,j,count)=AREA1(i,j,count)+area1(i,j);
   AREA2(i,j,count)=AREA2(i,j,count)+area2(i,j);
   AREA3(i,j,count)=AREA3(i,j,count)+area3(i,j);
%    AREA4(i,j,count)=AREA4(i,j,count)+area4(i,j);
%    AREA5(i,j,count)=AREA5(i,j,count)+area5(i,j); 
 end
end


end
end


%=====================================
%mean time
%=====================================
AREA_control=squeeze(nanmean(AREA1,3));
AREA_45=squeeze(nanmean(AREA2,3));
AREA_FWF45=squeeze(nanmean(AREA3,3));
% AREA_NS=squeeze(nanmean(AREA3,3));
% AREA_FWFNS=squeeze(nanmean(AREA5,3));

%%

period = [nyra_start,nyra_end];
patho='/data3/yiwen/Timcom_exp/matlab_code/SIC_renew/';
fn2 = [patho 'SIC'];
save(fn2,'AREA_control','AREA_45','AREA_FWF45','period')
% save(fn2,'AREA_control','AREA_45','AREA_NS','AREA_FWF45','AREA_FWFNS','period')


