function [ yn, return_status ] = 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, status] = 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
%     status:
%         0 if the routine succeeded in making a valid determination.
%        -1 if the routine failed because of invalid inputs.

%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Name:  $
% $Id: nc_iscoordvar.m,v 1.1 2005/06/29 16:07:00 brian Exp $
% AUTHOR:  johnevans@acm.org
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




% assume false until we know otherwise
yn = 0;
return_status = -1;




% Show usage if too few arguments.
%
if nargin~=2 
   help nc_iscoordvar;
   return;
end


[ncvar, status] = nc_getvarinfo ( ncfile, varname );
if status < 0
	fprintf ( 2, '%s:  nc_getvarinfo failed on variable %s.\n', mfilename, varname );
	return
end

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

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


return;


