% Plot various mitgcm model output fields
% from the 4 by 4 integrations

% initilaize
clear all, close all
path('/dm1/dimitri/mitgcm/matlab/readmeta',path);
lat=(-78:4:78)'; lon=2:4:358;         % coarse gird
delZ=[50 50 55 60 65 70 80 95 120 155 200 260 320 400 480 ...
      570 655 725 775 815]';
dpt=cumsum(delZ)-delZ/2; clear delZ

% load data
cd ~/mitgcm/KPP-noGM_highKZ/exe      % path name
fileid=467;                          % time stamp of output files
eval(['U=rdmeta(''U.00000' sprintf('%05u',fileid) ''',''b'');'])
eval(['V=rdmeta(''V.00000' sprintf('%05u',fileid) ''',''b'');'])
eval(['T=rdmeta(''T.00000' sprintf('%05u',fileid) ''',''b'');'])
eval(['S=rdmeta(''S.00000' sprintf('%05u',fileid) ''',''b'');'])

for layer=1:20, disp(dpt(layer))
  u=U(:,:,layer)'; u(find(u==0))=nan;
  v=V(:,:,layer)'; v(find(v==0))=nan;
  t=T(:,:,layer)'; t(find(t==0))=nan;
  s=S(:,:,layer)'; s(find(s==0))=nan;
  clf
  subplot(2,2,1), pcolor(lon,lat,u), title('u'), shading flat, colorbar
  subplot(2,2,2), pcolor(lon,lat,v), title('v'), shading flat, colorbar
  subplot(2,2,3), pcolor(lon,lat,t), title('t'), shading flat, colorbar
  subplot(2,2,4), pcolor(lon,lat,s), title('s'), shading flat, colorbar
  pause
end

