function overlay(colr);

% function overlay(colr);
%
% superimpose land masses (in green) on maps.
%
% colr=1 for color (green-grey), 0 for grey.

if ~exist('colr')
    colr=1;
end;
if (colr==0)
	col=[.5 .7 .5];		% green-grey
elseif (colr==1)
	col=[.6 .6 .6];		% grey
else
    col=colr;
end;

if (exist('minlon')==0)
  minlon=-100;
end;
if (exist('maxlon')==0)
  %maxlon=10;
  maxlon=60;
end;
if (exist('minlat')==0);
  %minlat=-20;
  minlat=-90;
end;
if (exist('maxlat')==0)
  maxlat=90;
end;

load coastlines
x=coast_x;
y=coast_y;
%q=find((x>=minlon & x<=maxlon & ...
	%y>=minlat & y<=maxlat) | ...
	%isnan(x+y));
%x=x(q);y=y(q);

q=find(isnan(x)); 
q=[0;q];
if (isnan(last(x))==0)
  q=[q;length(x)];
end;
for i=2:length(q);
  a=q(i-1)+1; b=q(i)-1;
  if (i==2)	% antarctica: add points at 90S
    x2=[x(a(1));x(a:b);x(b)];
    y2=[-90;y(a:b);-90];
  elseif (i==98) % asia: unwrap across 180
    a=[a:b,a];
    x2=x(a);y2=y(a);
    qa=find(x2<-100);
    x2(qa)=x2(qa)+360;
  else 
    a=[a:b,a];
    x2=x(a);y2=y(a);
  end;
  if (length(x2)>1)
    patch(x2,y2,col,'edgecolor','none');
    %plot(x2,y2,'color',col);
  end;
end;

