
 namerun='erai40c';
 rep='19910101_19941231';
 year_dur='1991-1994';

% pour test 
%namerun='erai51c';
%rep='19910101_19941231';
%year_dur='1991-1994';

dirfile=['/net/adonis/usr/adonis/phybiocar/cholod/peru12_nemo/' namerun '/' rep '/'];
filewo=[dirfile 'peru12_5d_' rep '_grid_W.' namerun '.nc']
nw=netcdf(filewo,'r');
depthw=nw{'depthw'}(:);
 wo=nw{'wo'}(:,:,100:300,50:200);
%wo=nw{'wo'}(100:101,:,100:300,50:200);     % pour test

close(nw);

rms_wo=squeeze(mean(sqrt(mean(mean(wo.^2,3),4)),1));

%mod_wo=wo.^2;
%mean_mod_wo=squeeze(mean(mean(mod_wo,3),4));
%rms_wo=sqrt(mean_mod_wo);
%mean_time_rms_wo=squeeze(mean(rms_wo,1));


%  1 m/s  =  86400 m/j
%plot (86400*squeeze(rms_wo(100,:)),-depthw,'-k','LineWidth',2)
%hold on
plot (86400*rms_wo,-depthw,'-r','LineWidth',2)
axis([0 1.0 -250 0]);
hx=xlabel('rms(W) [m/jour]'); set(hx,'FontS',14);
hy=ylabel('Depth [m]'); set(hy,'FontS',14);
set(gca,'FontS',14);
set(gca,'PlotBoxAspectRatio',[0.7 1 1]);
grid on
title(['rms (W) [m/jour]- ' namerun ' (' year_dur ')'], 'FontSize',18);
print ('-dpng','figure1.png')
save('save1.mat','depthw','rms_wo');

quit

