function [bool, indexarray] = acompar(x,y,index)

%
% Format [bool, indexarray] = acompar(x,y,index)
%
% Comparing vectors, not for string vectors.
% Ruturns 1 if any of the elements in x is
% included in y, zero otherwise.
% Vectors are not necessary to be of the 
% same length.
%
% It now also returns the index number of 
% matching numbers in terms of y vector, it
% records in indexarray.
%

% $Log: acompar.m,v $
% Revision 1.2  2000/03/16 02:21:59  dbyrne
%
%
% Corrected logic in check for matrices and error message to use dodsmsg.
% dbyrne 00/03/14
%
% Revision 1.1  1999/11/23 18:12:15  kwoklin
% R. Signell's time-series and profile data files.   klee
%

% $Id: acompar.m,v 1.2 2000/03/16 02:21:59 dbyrne Exp $
% klee 08/12/99

bool = 0;
count = 0;
acount = [];  indexarray = [];
[xx,xy] = size(x);
[yx,yy] = size(y);
if (xx ~= 1) | (yx ~= 1) 
  dodsmsg('The input args to acompar should be vectors, not matrices!');
  return;
end
for i = 1:xy
  for j = 1:yy
    if (y(j) == x(i))
      count = count + 1;
      acount = [acount; j];
    end
  end
end 

%if count == min(xy,yy)
%  bool = 1;
%end
if count > 0 
  bool = 1;
end

if nargin == 2
  return;
elseif nargin == 3
  indexarray = acount;
  return;
end
