
REstarA = [2400 0  -1800];
nR = length(REstarA);
tstop = [1020.14 1020.97 1021.22];
%tbp0 = [1020.2 1020.55 1020.75 1020.95  1021.05 1021.0 1021.05 1021.3];
%j_index = [-6 -4 9 0 -7 -4 -6 -6];
Bo=4000;
scalarz='z';
scalarp='p';
scalarf='f';

[Xb,Zb] = return_patch_bathy();

for k=2:2,

REstar = REstarA(k);
%index0=return_basilisk_index(tbp0(k));
%index_stop=index0+j_index(k);
%t_stop = return_basilisk_time(index_stop) + 1001.0



figure(1),clf
 cmap = cbrewer('div','RdBu',80);
 colormap(flipud(cmap));
xSize = 20; ySize = 6;  %size of the figure to be generated
set(gcf,'PaperUnits','centimeters')
set(gcf,'PaperPosition',[0 0  xSize ySize])

index2=0; 
for index = 50:2:590,
    %for t=1011.0:1011.0, %0.5:1020.5,
    %  index=return_basilisk_index(t);
    [Z,x,y,t]  = read_binary_file(9,REstar,Bo,index,scalarz,'alldump');
    [F,x,y,t]  = read_binary_file(9,REstar,Bo,index,scalarf,'alldump');    
    %    [P,x,y,t]  = read_binary_file(9,REstar,Bo,index,scalarp,'alldump');  
    if (t>tstop(k)),
        break;
    end;
  minx = min(x)+1; maxx=max(x)-1;
  
    [Xs,Ys,Xraw,Yraw] = read_processed_surface_extract(9,REstar,Bo,t);

   ii=find(Xs>=minx & Xs<=maxx);
   Xsn = [Xs(ii(1)); Xs(ii); Xs(ii(end))];
   Ysn = [-1; Ys(ii); -1];

   clf
   sand_color = [194 178 128]/255;
   water_color = [100 208 216]/255;   

   hh=subplot('position',[0.06 0.17 0.925 0.8])
            pcolorcen(x,y,Z),shading interp
            axis xy
            axis([13  45 -1.1 4])
            caxis([-10 10])
            %            caxis([-0.005 0.005])            
            hold on
            plot(Xsn,Ysn,'k','linewidth',1.5)
            h1=patch(Xsn,Ysn,water_color);
            set(h1,'FaceAlpha',0.7)
            h2=patch(Xb,Zb,sand_color)
            colorbar('vert','position',[0.10 0.65 0.03 0.25])
            ylabel('$z/h_0$','interpreter','latex')
            xlabel('$x/h_0$','interpreter','latex')
            titlestr =sprintf('vorticity: $\\mathrm{Re}^*=%d$, $\\mathrm{Bo}=%d$: $t=%.2f$',REstar,Bo,t-1001);
            text(17,3.65,titlestr,'interpreter','latex')
            drawnow

           set(gcf,'PaperUnits','centimeters')
           set(gcf,'papersize',[xSize ySize],'paperposition',[ 0 0 xSize ySize]);    
           print('-dpng','-r300',sprintf('tmp/newalldump_REstar%d_Bo%04d_%03d.png',REstar,Bo,index2))
           index2 = index2+1;
    end;
end;
            return
               
%nn = length(Xn);
%Cn = [1:nn]'/nn;
    
% figure(1)
% hold on
%      scatter(Xs,Ys+(t-1002)/5,4,C,'d')
%     drawnow
%     pause(0.02)
%     %    plot(Spc.Location(:,1),Spc.Location(:,2),'kd')
% 
%     figure(2)
%     hold on
%     %for t=1011.0:1011.0, %0.5:1020.5,
% 
% nraw = length(Xraw);
% Cr = [1:nraw]'/nraw;
% %nn = length(Xn);
% %Cn = [1:nn]'/nn;
%     
% figure(2)
% hold on
%      scatter(Xraw,Yraw+(t-1002)/5,4,Cr,'d')
%     drawnow
%     pause(0.02)
%      
% end;
    
    
  %[F,x,y,t]  = read_binary_file(9,REstar,Bo,index,'f');
%[V,x,y,t]  = read_binary_file(9,REstar,Bo,index,'z')
%[P,x,y,t]  = read_binary_file(9,REstar,Bo,index,'p');
