function cctwplt(vgrr,nn,mm,ng,as)

%  Plot coastal-trapped wave eigenfunctions as contours	8/28/97
%  Uses output from bigload3
%  	but the flat file version (mm,nn stripped off at beginning)
%  Call as
%	 cctwplt(vgrr,nn,mm,ng,as)
%  Where
%	nn,mm = # of x,z grid points in computed field
%		mm must be as in bigload3, nn can be less than in bigload3
%	ng = number of vertical grid points to interpolate to
%	vgrr= Bigload3 output
%	as = 0 for no autoscale, as ~= 0 for autoscale max
%
%  For Matlab for Windows 4.0 or better

nc = 10;
%	nc = number of positive and/or negative contours
grzz = NaN*ones(ng,nn);

vgrr(:,1) = vgrr(:,1)/1e5;
vgrr(:,2) = vgrr(:,2)/100;

yy = min(vgrr(:,2));
xl = 0;
xh = max(vgrr(:,1));

dz = abs(yy)/(ng-1);
yi = (yy:dz:0)';
yi(ng) = 0;
gryy = yi;

for i = 1:nn
	il = 1 + (i-1)*mm;
	ih = mm*i;
	grbt(i,1) = vgrr(il,1);
	zq = vgrr(il:ih,3);
	yq = vgrr(il:ih,2);
	yq(mm) = 0;
	yqm = min(yq);
	ii = find(yi >= yqm);
	yyi = yi(ii);
	zzi = interp1(yq,zq,yyi);
	grzz(ii,i) = zzi;
	grbt(i,2) = min(yq);
end
	
grxx = grbt(:,1);
xx = xh;

ax = [xl  xx  yy 0];

cc = max(abs(vgrr(:,3)));

if as ~= 0
	grzz = as*grzz/cc;
	cc =as;	
end	


ci = cc/nc;
cp = (1:nc)*ci;
cm = -cp;
cz = (ci/10000)*ones(2,1);
['Contour interval = ' num2str(ci)]

C= contour(grxx,gryy,grzz,cp);

axis(ax)
hold on

CC = contour(grxx,gryy,grzz,cm,'-.');
CCC = contour(grxx,gryy,grzz,cz,'--');

if as ~= 0
	clabel(C)
	clabel(CC)
end

plot(grbt(:,1),grbt(:,2))
xlabel('Distance Offshore (km)')
ylabel('Depth (m)')

hold off