
   clear all; close all;

%-------------------------------------------------------------------------------
   root_dir=['/loceanfs/pulsation/cholod'];

%%% exp, period
   exp_name1={'erai70c','erai72c','tr025_np12','erai73c'};
   config='peru12_nemo';
   yd='2000';
   yf='2007';

%%% field
%  field='mld_dt02'; title1='MLD_DT02 (m)';
   field='mldr10_3'; title1='MLDR10_3 (m)';

   view='peru12';
%  view='zoom1';

%-------------------------------------------------------------------------------

%  for num_exp=1:size(exp_name1,2)
   for num_exp=4:4
%  num_exp=3
      exp_name=char(exp_name1(num_exp));
      exp_name_title=regexprep(exp_name,'_','\\_');
      rep=[yd '0101_' yf '1231']; 
      ydur=[yd '-' yf];
      title2=regexprep(title1,'_','\\_');

      disp([exp_name ' - ' field ' (' ydur ')']);

      fs=[root_dir '/' config '/outputs/' exp_name '/' rep '/peru12_5d_' rep '_grid_T_2D.' exp_name '.nc'];

      fg=[root_dir '/peru12_nemo/inputs/grd/mesh_mask_peru12.L46_bathy_Stephane.nc'];
      ng=netcdf(fg,'r');
      lat=ng{'nav_lat'}(:);
      lon=ng{'nav_lon'}(:);
      close(ng);

      ns=netcdf(fs,'r');
%     float tos,zos,mld_dt02...(time_counter, lat, lon) ;
      field2=ns{field}(:,:,:);
      close(ns);

      mfield=squeeze(mean(field2,1));

      opengl neverselect % pour pb cartes graphiques
   
% plot
      figure(num_exp);
      pcolor(lon,lat,mfield);
      shading flat;
      %     shading interp;


      switch view
%%% vue zone peru12
         case 'peru12'
            file_name_view1='';
            axis1=[-100 -70 -30 10];
            PlotBoxAspectRatio1=[0.6 1 1];
            caxis1=[0 70]; % pour mld
%%% vue zoom equateur
         case 'zoom1'
            file_name_view1='_zoom1';
            axis1=[-100 -70 -5 5];
            PlotBoxAspectRatio1=[1 0.4 1];
            caxis1=[10 25]; % pour mld
      end

      axis(axis1);
      set(gca,'PlotBoxAspectRatio',PlotBoxAspectRatio1);
      set(gca,'FontS',12);
      caxis(caxis1);

      title([title2 ' - ' exp_name_title ' (' ydur ')'], 'FontSize',16);
	  hcc=colorbar; set(hcc,'FontS',12);

      switch view
      % Pour virer le white space inutile sur les figures générées par matlab en png, jpeg, tiff
      %          (pas le cas en eps mais pas la même qualité et images bcp + lourdes)
%%% vue zone peru12
         case 'peru12'
	    set(gca, 'Position', get(gca, 'OuterPosition') - get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
	    set(gcf, 'PaperUnits', 'inches');
	    set(gcf, 'PaperSize', [6.25 7.5]);
	    set(gcf, 'PaperPositionMode', 'manual');
	    set(gcf, 'PaperPosition', [0 0 6.25 7.5]);
%%% vue zoom equateur
         case 'zoom1'
	    set(gca, 'Position', get(gca, 'OuterPosition') - get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
      end

	  print ('-dpng',['ave_' field '_' exp_name '_' ydur file_name_view1 '.png'])
%         print ('-depsc2',['ave_' field '_' exp_name '_' ydur file_name_view1 '.eps'])
	  end  % for num_exp

quit
