

% 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(8); 
htot = what(9);
f0 = what(10);
%beta = what(11);
tau = what(12);
%decay = what(13);
%sno = what(14);
%ekno = what(15);
%rno = what(16);


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

g = 9.8;
dens = 1025.;

figure(2); clf reset;

 for i=1:ntim;

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

 h1(:,:) = basin1(n1:n2,:)/(htot*f0); 
 h2(:,:) = basin2(n1:n2,:); 
 h3(:,:) = basin3(n1:n2,:)/1.e6;
 h4(:,:) = basin4(n1:n2,:)/(g*htot);

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

  if i <= 6
  figure(2)
  subplot(3,2,i)
  ci = -40:2:40;
  c = contour(x,y,h3, ci); 
  clabel(c); 
  ylabel('Psi, M m^3 s^{-1}');
  tim = looktim(i)
% axis('square')
  end 


 if i == ntim

  figure(1) 
  clf reset
 
  subplot(2,2,3); 
  ci = -0.3:0.05:0.7;
  c = contour(x,y,h1,5); 
  clabel(c);
  ylabel('Vort/f') 
  xlabel('East, km');
              

  subplot(2,2,2); 
  ci = -2.:0.05:2.;
  c = contour(x,y,h2,ci); 
  clabel(c);
  ylabel('North speed, m s^{-1}')
 
 
  % add the time
  tim = looktim(i)
  title(['Time (days) = ',num2str(tim)])

 subplot(2,2,1); 
 ci = -40:2:40;
 c = contour(x,y,h3, ci); 
 clabel(c); 
 ylabel('Psi, M m^3 s^{-1}');
%  xlabel('East, km');


 subplot(2,2,4); 
 c = contour(x,y,h4,5); 
 clabel(c); 
 ylabel('Eta, m');
 xlabel('East, km');
 
 end   %   if on i = ntim
                          
 end

 
