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
ind=find(coast(:,1)>370);
coast(ind,:)=[];
coast(1,:)=[];

cruise=cr;
eval(['load ' cruise ]);

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
idepth
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=['Salinity  section 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');
%varg1(98,60)=32.1;

%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',[.1 .1 .45 .8]);
colormap(jet(64));
if(iflip1),
  varg1=max(clev1)-varg1;
end
if(iflip2),
  varg2=max(clev2)-varg2;
end
cax=[min(clev1) max(clev1)];
itype=2;
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,'label','fill');...
  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==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
text(220,320,'DATA');
set(gca,'visible','off');
text(300,370,titl);
set(gca,'xticklabels','','yticklabels','');
axes('pos',[.5 .1 .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,'label','fill');...
  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==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(220,320,'MODEL');
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

%pclegend([0 150]',[.08 .65 .025 .2],gcf,'cells/l')



%writegif('/usr/www/foo.gif');
