% a matlab plotting program to read successive matrices from disk files
% this version used for basin model, among others. 

clear all

      
load what.dat
nx = what(1);
ny = what(2);
nz = what(3);
dx = what(5);
dy = what(6);
x1 = what(7);
y1 = what(9); 


x1 = 0.
y1 = 0.

x = zeros(1,nx);
y = zeros(1,ny);

x(:) = 1:nx;
y(:) = 1:ny;
for i=1:nx;
x(i) = x1 + (i-1)*dx;
x(i) = x(i)/1000.;
end;
for i=1:ny;
y(i) = y1 + (i-1)*dy;
y(i) = y(i)/1000.;
end;
       

 load looktim.dat

[ntim, kkk] = size(looktim)


h1 = zeros(ny,nx); 
h2 = h1; h3 = h1; h4 = h1;


load basin1.dat
load basin2.dat
load basin3.dat        
load basin4.dat


 for i=2:ntim;

  
 n1 = (i-1)*ny + 1
 n2 = n1 + ny - 1


 h1(:,:) = basin1(n1:n2,:); 
 h2(:,:) = basin2(n1:n2,:); 
 h3(:,:) = basin3(n1:n2,:);
 h4(:,:) = basin4(n1:n2,:);

%  note that this use of figure saves everything; kind of cumbersome

 figure(1)
 
 clf reset

 subplot(2,2,1); 
 c = contour(x, y, h1); 
 clabel(c);
  
 xlabel('East, km');  ylabel('eta1');            
 
 subplot(2,2,2); 
 c = contour(h2,5); 
 clabel(c);
 ylabel('P1')
 
 % add the time
 tim = looktim(i)
 title(['Time (days) = ',num2str(tim)])


 subplot(2,2,3); 
 c = contour(h3,5); 
 clabel(c); 
 ylabel('eta2');

 subplot(2,2,4); 
 c = contour(h4,5); 
 clabel(c); 
 ylabel('P2');
                            
 pause;  

 end
