


 namerun='erai51c';
%namerun='erai61c';

k=0;

 yy=[1990:1:1994];
%yy=[1990:1:1994];
%yy=1990;

%rep='<REP>';
%rep='19940101_19941231';

gridfile=['/net/adonis/usr/adonis/phybiocar/cholod/peru12_nemo/mesh_mask_PERU12.nc'];
ng=netcdf(gridfile,'r');
umask=squeeze(ng{'umaskutil'}(1,:,:));
vmask=squeeze(ng{'vmaskutil'}(1,:,:));
smu=sum(sum(umask));  % nombre de pooints d'ocean (1)
smv=sum(sum(vmask));
close(ng);

ke=[];    % declare que vecteur vide
time=[];

for y=1:length(yy)
  rep=[num2str(yy(y)) '0101_' num2str(yy(y)) '1231']

  dirfile=['/net/adonis/usr/adonis/phybiocar/cholod/peru12_nemo/' namerun '/' rep '/'];
  fileu=[dirfile 'peru12_5d_' rep '_grid_U_2D.' namerun '.nc'] 
  filev=[dirfile 'peru12_5d_' rep '_grid_V_2D.' namerun '.nc'] 
  nu=netcdf(fileu,'r');
  nv=netcdf(filev,'r');

  lt=size(nu{'uos'}(:),1);  % extrait la size temps (premier)

  for i=1:lt
    k=k+1;
    u=squeeze(nu{'uos'}(i,:,:));
    v=squeeze(nv{'vos'}(i,:,:));
    u=u.*umask;     %  . pour tout calcul matriciel
    v=v.*umask;
    u=u.*u;
    v=v.*v;
    ke(k)=0.5*(sum(sum(u))./smu + sum(sum(v))./smv);
    time(k)=2.5+(k-1)*5;
  end

  close(nu);
  close(nv);

end

figure;
plot(time,ke);
grid on;
axis([0 2000 0 0.06]);
xlabel('jours')
year_dur=[num2str(yy(1)) '-' num2str(yy(length(yy)))]
title([namerun ' - ' year_dur ' - ke time serie'], 'FontSize',18);
figname1=['ke_time_serie_' namerun '_' year_dur ]
 print ('-dpng',['outputs/' figname1]) 
%print ('-dpng',figname1) 

quit


