function iir=ekw_var_spec(rng_lims,ranges);
% Call iir=ekw_var_spec(rng_lims,ranges);
% rng_lims	= [r1,r2,nr], [r1,r2,-dr], [rmin,rmax], [r1;r2;...rn]
% ranges	= list of ranges available
% iir		= indices in ranges that are chosen by rng_lims specification;
%
nrange=length(ranges);
[nr,nc]=size(rng_lims);
if nr==1 & nc==3,
	if rng_lims(3)>0,
		rng_lims=linspace(rng_lims(1),rng_lims(2),rng_lims(3))'; 
	else
		rng_lims=[rng_lims(1):-rng_lims(3):rng_lims(2)]';
	end
	[nr,nc]=size(rng_lims);
end
if isempty(rng_lims),
	iir=1:nrange;
elseif nr==1 & nc==2,
	iir=find(ranges>=rng_lims(1) & ranges<=rng_lims(2));
elseif nc==1,
	for jr=1:nr,
		[dummy,iir(jr)]=min(abs(ranges-rng_lims(jr)));
	end
	iir=unique(iir);
else
	error('USER ERROR: rng_lims must be [rmin,rmax] or [r1;r2;..rn]');	
end
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
