function [xg,yg,varg1,varg2]=slicecomp2(cr,var1,clev1,var2,clev2,depth,itype);
% function [xg,yg,varg1,varg2]=slicecomp2(cr,var1,clev1,var2,clev2,depth,itype);
load /usr/users/rps/gom/dino/wgom_half
load /usr/users/rps/gom/dino/gom2.dig.sp
cruise=cr;
coast=[coast; nan nan; gom2(:,[1 2])/1000];
set(gcf,'pos',[10 10 620 480]);
eval(['load ' cruise ]);

deepmean1=gmean(gmean(salt(60:280,:))') 
deepmean2=gmean(gmean(smod(60:280,:))') 
iflip1=0;
if(length(var1)>4)
  if (var1(1:5)=='alex0')
    idepth=1;iflip1=1;
  elseif (var1(1:6)=='alex10'),
    idepth=1;iflip1=1;
  else
    idepth=depth*2;   %half meter depth intervals
  end
else
  idepth=depth*2;   %half meter depth intervals
end
% rps hack
iflip1=0
eval(['v = ' var1 '(idepth,:)']);
data=[x(:)*1000 y(:)*1000 v(:)];
ind=find(isnan(v(:)));
data(ind,:)=[];
start=greg2str(gregorian(min(jd(:))));
stop=greg2str(gregorian(max(jd(:))));
titl=['Horizontal section of Salinity at ' int2str(depth) ' m : '];
titl=[titl start(1:10) '-' stop(1:10)];


save lev.dat depth /ascii
save temp.dat data /ascii
!/usr/users/rps/gom/dino/dogridgen
[varg1,xg,yg]=readgrid('temp.cdf');

%rpshack
iflip2=0;
if(length(var2)>4)
  if (var2(1:5)=='alex0')
    idepth=1;iflip2=1;
  elseif (var2(1:6)=='alex10'),
    idepth=1;iflip2=1;
  else
    idepth=depth*2;   %half meter depth intervals
  end
else
  idepth=depth*2;   %half meter depth intervals
end
iflip2=0
eval(['v = ' var2 '(idepth,:)']);
data=[x(:)*1000 y(:)*1000 v(:)];
ind=find(isnan(v(:)));
data(ind,:)=[];
save temp.dat data /ascii
!/usr/users/rps/gom/dino/dogridgen
[varg2,xg,yg]=readgrid('temp.cdf');

%         itype :  1= fill, label 
%                  2= fill, no label
%                  3= nofill, label
%
clf
if(exist('itype')~=1),
 itype=1;
end
axes('pos',[.05 .12 .45 .8]);
colormap(jet(64));
if(iflip1),
  varg1=max(clev1)-varg1;
end
if(iflip2),
  varg2=max(clev2)-varg2;
end
cax=[min(clev1) max(clev1)];
if(itype==1),
  pslice2(xg/1000,yg/1000,varg1,[min(clev1) max(clev1)]);...
  line(coast(:,1),coast(:,2),'color','white');...
  line(data(:,1)/1000,data(:,2)/1000,'color','white','linestyle','x');...
  set(gca,'asp',[nan 1]);
elseif(itype==2),
  extcontour(xg/1000,yg/1000,varg1,clev1,'fill');...
  line(coast(:,1),coast(:,2),'color','white');...
  set(gca,'asp',[nan 1]);
elseif(itype==3),
  extcontour(xg/1000,yg/1000,varg1,clev1,'label');...
  line(coast(:,1),coast(:,2),'color','white');...
  set(gca,'asp',[nan 1]);
else
  disp('invalid itype');
  return
end

varg2=varg2+deepmean1-deepmean2;

text(250,340,'DATA','fontweight','bold');
set(gca,'visible','off');
text(250,375,titl,'fontweight','bold');
set(gca,'xticklabels','','yticklabels','');
axes('pos',[.4 .12 .45 .8]);
colormap(jet(64));
if(itype==1),
  pslice2(xg/1000,yg/1000,varg2,[min(clev2) max(clev2)]);...
  line(data(:,1)/1000,data(:,2)/1000,'color','white','linestyle','x');...
  line(coast(:,1),coast(:,2),'color','white');...
  set(gca,'asp',[nan 1]);
elseif(itype==2),
  extcontour(xg/1000,yg/1000,varg2,clev2,'fill');...
  line(coast(:,1),coast(:,2),'color','white');...
  set(gca,'asp',[nan 1]);
elseif(itype==3),
  extcontour(xg/1000,yg/1000,varg2,clev2,'label');
  line(coast(:,1),coast(:,2),'color','white');...
  set(gca,'asp',[nan 1]);
else
  disp('invalid itype');
  return
end
text(250,340,'MODEL','fontweight','bold');
set(gca,'visible','off');
%set(gca,'xticklabels','','yticklabels','');
%  hh=gca;
%  diff=max(cax)-min(cax);
%  mid=floor(diff/20);
%  inc=floor(diff/20)/5;
%  hb=cbar(hh,'h',inc,mid,'fontsize',9);
%  axes(hh);
% colorbar

%axes('pos',[.1 .06 .8 .03])
%pcolor([28:33; 28:33]);shading('flat');
%pcolor([0:100; 0:100]);shading('flat');
%set(gca,'yticklabels','','xticklabels','');
pclegend([28:33]',[.8 .3 .03 .3]);
%writegif('/usr/www/foo.gif');
