function yn = nc_iscoordvar ( ncfile, varname )
% NC_ISCOORDVAR:  yes if the given variable is also a coordinate variable.
%
% A coordinate variable is a variable with just one dimension.  That 
% dimension has the same name as the variable itself.
%
% USAGE:  yn = nc_iscoordvar ( ncfile, varname );
%
% PARAMETERS:
% Input:
%     ncfile:  
%        Input netcdf file name.
%     varname:  
%        variable to check
% Output:
%     yn:
%         1 if the variable is a coordinate variable
%         0 if the variable is not a coordinate variable
%
% Throws an exception in case of an error condition.
%
%
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Id: nc_iscoordvar.m 1741 2006-08-29 16:35:33Z johnevans007 $
% $LastChangedDate: 2006-08-29 12:35:33 -0400 (Tue, 29 Aug 2006) $
% $LastChangedRevision: 1741 $
% $LastChangedBy: johnevans007 $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Show usage if too few arguments.
%
if nargin~=2 
	error ( '%s:  must have two input arguments.\n', mfilename );
end

if ~ischar ( varname )
	error ( '%s:  varname input must be character.\n', mfilename );
end

%
% Assume that the answer is no until we know that it is yes.

yn = 0;

ncvar = nc_getvarinfo ( ncfile, varname );

%
% Check that it's not a singleton.  If it is, then the answer is no.
if isempty(ncvar.Dimension)
	yn = 0;
	return
end

%
% Check that the names are the same.
if strcmp ( ncvar.Dimension{1}, varname )
	yn = 1;
end


return;

