function oct_plot_nestclim(clim_file,grid_file,tracer,l)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Test the climatology and initial files.
%
%  Further Information:  
%  http://www.croco-ocean.org
%  
%  This file is part of CROCOTOOLS
%
%  CROCOTOOLS is free software; you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published
%  by the Free Software Foundation; either version 2 of the License,
%  or (at your option) any later version.
%
%  CROCOTOOLS is distributed in the hope that it will be useful, but
%  WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
%  MA  02111-1307  USA
%
%  Copyright (c) 2004-2006 by Pierrick Penven 
%  e-mail:Pierrick.Penven@ird.fr  
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ncid = netcdf.open(clim_file, 'NC_NOWRITE');
var=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, tracer)));
[N M L]=size(var);
u=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'u')));
v=squeeze(netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'v')));
theta_s=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'theta_s'));
vtransform=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'Vtransform'));
if isempty(theta_s)
  theta_s=ncid.theta_s(:);
  theta_b=ncid.theta_b(:);
  hc=ncid.hc(:);
else
  theta_b=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'theta_b'));
  hc=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'hc'));
end
if  ~exist('vtransform') | isempty(vtransform)
    vtransform=1; %Old Vtransform
    disp([' NO VTRANSFORM parameter found'])
    disp([' USE TRANSFORM default value vtransform = 1'])
end
netcdf.close(ncid);
ncid = netcdf.open(grid_file, 'NC_NOWRITE');

lat=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lat_rho'));
lon=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'lon_rho'));
pm=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'pm'));
h=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'h'));
angle=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'angle'));
mask=netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'mask_rho'));
warning off
mask=mask./mask;
warning on

jstep=round((M/3)-1);
image=0;
z = oct_zlevs(h,0*h,theta_s,theta_b,hc,N,'r',vtransform);
for j=1:jstep:M
  index=j;
  image=image+1;
  subplot(2,2,image)
  field=squeeze(var(:,j,:));
  topo=squeeze(h(j,:));
  mask_vert=squeeze(mask(j,:));
  dx=1./squeeze(pm(j,:));
  xrad(1)=0;
  for i=2:L
    xrad(i)=xrad(i-1)+0.5*(dx(i)+dx(i-1));
  end
  x=zeros(N,L);
  masksection=zeros(N,L);
  for i=1:L
    for k=1:N
      x(k,i)=xrad(i);
      masksection(k,i)=mask_vert(i);
    end
  end
  xrad=xrad/1000;
  x=x/1000;
  field=masksection.*field;
  pcolor(x,squeeze(z(:,j,:)),field) 
  colorbar
  shading interp
  hold on
  plot(xrad,-topo,'k')
  hold off
  title(num2str(j))
end


figure
sst=squeeze(var(N,:,:));
[u,v,lonred,latred,maskred]=oct_uv_vec2rho(u,v,lon,lat,angle,mask,3,[0 0 0 0]);
spd=sqrt(u.^2+v.^2);
pcolor(lon,lat,mask.*sst)
shading flat
hold on
quiver(lonred,latred,u,v,'k')
hold off
axis image
colorbar
title(['max speed : ',num2str(100*max(max(spd))),' cm/s'])


return



