
   clear all; close all;

   ys_fich=2003;
   ye_fich=2007;         

   dir_root='/loceanfs/pulsation/cholod/';

   exp(1).config='peru12_nemo';
   exp(1).names={'p12n_bdy_tr12n_quik' 'p12n_bdy_soda2' 'p12n_bdy_soda2_B' 'erai70b' 'erai74c' 'p12n_bdy_tr12n_quik_ND' 'p12n_bdy_tr12n_quik_blp1' 'p12n_bdy_soda2_B_steps' 'p12n_bdy_soda2_B_rfact'};

   exp(2).config='trop12_nemo/peru';
   exp(2).names={'tr12_quik' 'tr12_erainocrt'};

   exp(3).config='trop025peru12_nemo/peru';
   exp(3).names={'tr025p12_quik'};

   exp(4).config='/loceanfs/pulsation/cholod/data/TMI-AMSR-E/';
   exp(4).names={'TMI-AMSR-E_PERU12'};

   config_ref=exp(4).config;
   name_ref=exp(4).names{1};

   mini=-2;
   maxi=2;

   exp_dim=size(exp);
%  for ii = 1:exp_dim(2)
   for ii = 1:1                    % config
      config1=exp(ii).config;
      config2=config_ref;
      names=exp(ii).names;
      names_dim=size(names);

      %     for jj = 1:names_dim(2);     % names
      for jj = 8:9
         name1=names{jj};
         name2=name_ref;
         name1_title=regexprep(name1,'_','\\_');
         name2_title=regexprep(name2,'_','\\_');
         disp([num2str(jj) ' : ' config1 ' : ' name1]);
         rep_fich=[num2str(ys_fich) '0101_' num2str(ye_fich) '1231'];
         dur_plot=[num2str(ys_fich) '-' num2str(ye_fich)];
         maskfile='/loceanfs/pulsation/cholod/peru12_nemo/inputs/grd/mesh_mask_peru12.L75_from_trop12.nc';

         if strcmp(name1,'TMI-AMSR-E_PERU12')
            dir_in1=config1;
            filetos1=[dir_in1 name1 '_' dur_plot '_mean.nc']
         else
            dir_in1=['/loceanfs/pulsation/cholod/' config1 '/outputs/' name1 '/' rep_fich '/'];
            filetos1=[dir_in1 name1 '_1s_' rep_fich '_grid_T_2D.nc']
         end

         if strcmp(name2,'TMI-AMSR-E_PERU12')
            dir_in2=config2;
            filetos2=[dir_in2 name2 '_' dur_plot '_mean.nc']
         else
            dir_in2=['/loceanfs/pulsation/cholod/' config2 '/outputs/' name2 '/' rep_fich '/'];
            filetos2=[dir_in2 name2 '_1s_' rep_fich '_grid_T_2D.nc']
         end

%%% coord et mask  de la grille
         ng=netcdf(maskfile,'r');
         lon=ng{'glamt'}(:);
         lat=ng{'gphit'}(:);
	 mask=squeeze(ng{'tmask'}(:,1,:,:));
         mask(mask==0)=NaN;
         close(ng);

%%% Lecture tos
         nc1=netcdf(filetos1,'r'); 
         if strcmp(name1,'TMI-AMSR-E_PERU12')
            tos1=nc1{'sst'}(:,:);
         else
            tos1=nc1{'tos'}(5,:,:);
         end
         close(nc1);

         nc2=netcdf(filetos2,'r'); 
         if strcmp(name2,'TMI-AMSR-E_PERU12')
            tos2=nc2{'sst'}(:,:);
         else
            tos2=nc2{'tos'}(5,:,:);
         end
         close(nc2);

%%%  Plot 1
         figure;
         pcolor(lon(:,1:361),lat(:,1:361),mask(:,1:361).*(tos1(:,1:361)-tos2(:,1:361))); shading flat;
  lon1 = -79.67;
  lat1 = -7.065;
  lon2 = -76.33;
  lat2 = -13.05;
  lon1b = -82.42;
  lon2b = -79.08;
% line([lon1b lon1],[lat1 lat1],'color','k','LineWidth',1)
% line([lon2b lon2],[lat2 lat2],'color','k','LineWidth',1)
% line([lon1b lon2b],[lat1 lat2],'color','k','LineWidth',1)
         set(gca,'FontS',14); set(gca,'PlotBoxAspectRatio',[0.7 1 1]); box on;
         caxis ([mini maxi]); colormap([cold;flipud(hot)]); hcc=colorbar; set(hcc,'FontS',14);
         title(['sst mean (C) - ' name1_title ' - ' name2_title ' (' dur_plot ')'],'FontSize',12);
         fignameA=['map_sst_mean_' name1 '-' name2 '_' dur_plot];
         print ('-dpng',fignameA)

      end
   end
      


