function [xyz,cavg,nph,geom_file,iif]=adi_array_find(geom_root);
%
% Call [xyz,cavg,nph,geom_file,iif]=adi_array_find(geom_root);
%
% Searches in NAV or ../NAV directory if available.
%
% Routines that work with array geometry files include:
% adi_array_make, adi_array_plot, adi_array_rot, adi_array_find, adi_array_geom;
%
geom_file=[geom_root,'_array']; path_back=[];
xyz=[]; cavg=[]; nph=[]; iif=1;
%
if isunix, dx='/'; elseif isppc, dx=':'; else, dx='\'; end
%
if exist(geom_file,'file')~=2,
    dd=which('adi_array_find'); home=dd(1:end-35);
    inp_file=[home,'inp/arrays',dx,geom_file];
    if exist(inp_file,'file'),
        disp(['Found array in ~/inp/arrays: ',inp_file]);
        geom_file=inp_file;
    elseif exist('NAV','dir'), 
% Search in NAV directory if available:
		path_back=pwd; eval('cd NAV'); 
	else
		work_dir=pwd; cc=findstr(work_dir,dx);
		lwd=length(work_dir); lcc=length(cc);
		if cc(lcc)==lwd, lcc=lcc-1; end
		up_dir=[work_dir(1:cc(max(1,lcc))),'NAV',dx];
		if exist(up_dir,'dir'),
% Search in ../NAV directory if available:
			path_back=pwd; cd(up_dir);
			disp(['Looking for geometry file ',geom_file,' in: ',up_dir,' ...'])
		end
	end
end
%
if exist(geom_file,'file')~=2,
	disp([geom_file,' not found.']);
	[geom_file,path_name]=uigetfile('*_array', ...
		'Please Choose _array File');
	if geom_file==0, iif=0; return; end
% Only change path_back if it hadn't already been changed:
	if isempty(path_back), path_back=pwd; end
	eval(['cd ''',path_name,'''']);
end		
%
[xyz,cavg,nph]=arr_geom(geom_file);
%
if ~isempty(path_back); eval(['cd ''',path_back,'''']); 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.
