function y=uvprofplot(u,v,d,mid,flu,flv);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function routine to try and get around an
% annoying bug in the batch processing of
% plots from a scripts.  The xaxis keeps
% changing from plot to plot.  Try to 
% isolate things in this file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fpath=['/data/span9/bahr/perlprogs/'];
velmin=-75; velmax=75;
	ylab=['Depth (m)'];
	lu=size(u,1);
	wu=size(u,2);
	cla reset;
	figure('Visible','off','Position',[200 200 300 600]);
	set(gcf,'Units','inches');
	set(gcf,'PaperPosition',[1.5 1.5 7 9]);
	clear ll;
	if isempty(u)==1,
		xfil=[0 1 1 0];
		yfil=[0 0 1 1];
		plot(xfil,yfil);
		axis([0 1 0 1]);
		text(0.4,0.5,'NO DATA','FontWeight','bold','FontSize',20);
	else,
% Add code to plot gaps as gaps
	nu=flu==3;
	nv=flv==3;
% First set missing data values to NaN's
	u(nu)=NaN;
	v(nv)=NaN;
% Temperoary set up on flags....
	tu=u==-3276.8;
	tv=v==-3276.8;
	flu(tu)=1;
	flv(tv)=1;
	ugood=u;
	vgood=v;
	ubad=u;
	vbad=v;
	uoff=u;
	voff=v;
% set good values 
	gu=flu==0;
	ugood(~gu)=NaN;
	ubad(gu)=NaN;
	uoff(gu)=NaN;
	gv=flv==0;
	vgood(~gv)=NaN;
	vbad(gv)=NaN;
	voff(gv)=NaN;
% Find values that plot outside of plotting bounds
	ou=((ubad > velmax)|(ubad < velmin));
	ov=((vbad > velmax)|(vbad < velmin));
	ubad(ou)=NaN;
	uoff(~ou)=NaN;
	vbad(ov)=NaN;
	voff(~ov)=NaN;
% Now set off plot values to plot as symbols at edge of plot
	voff(ov)=velmin+2;
	uoff(ou)=velmax-2;
% Now to actually plot the profile
	plot(ugood,d,'g');
	hold on;
	plot(ubad,d,'k');
	plot(uoff,d,'b^');
	plot(vgood,d,'r');
	plot(vbad,d,'k');
	plot(voff,d,'bv');
	vertical0('k');
	axis('ij');
	grid on;
	end
	xlabel(['Velocity (cm/s)'],'FontWeight','bold','FontSize',20);
	ylabel(ylab(1,:),'FontWeight','bold','FontSize',20);
	set(gca,'FontWeight','bold','FontSize',20);
	set(gca,'Xlim',[velmin velmax]);
	pltnm=[fpath,'m',num2str(mid),'_uvprof.ppm'];
	eval(['print -dppm ',pltnm,';']);
	close;
	clf;
