function [Jday,Jhour]=mcs_get_time(data_root,cback_fig)
%
%
% 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.
if nargin<1, data_root=[]; end
if nargin<2, cback_fig=[]; end
%
fid_time=fopen('start_time.txt','r');
if ~isempty(cback_fig), 
    h1=findobj(cback_fig,'Tag','Init Jday,Jhour'); 
    set(h1,'Visible','Off');
end
if fid_time>0,
    [vals,count]=fscanf(fid_time,'%f',[2,1]);
    if length(vals)<2, 
        disp(vals), disp(count),
        error('File start_time.txt must contain Jday,Jhour'); 
    end
    Jday=vals(1); Jhour=vals(2);
    fclose(fid_time);
else
    disp('Did not find file start_time.txt, looking for .sum file');
	jday_file=[data_root,'.sum'],
	fid_time=fopen(jday_file);
    if fid_time<0, jday_file=[data_root(1:end-1),'.sum']; fid_time=fopen(jday_file), end
    if fid_time>0,
		tline=fgetl(fid_time);
		day=str2num(tline(9:10)); 
        if day>=10, joff=0; else, joff=-1; end
        month=tline(joff+[12:14]); year=str2num(tline(joff+[17:20]));
	    hour=str2num(tline(joff+[24:25])); minute=str2num(tline(joff+[27:28])); 
        second=str2num(tline(joff+[30:35]));
		Jday=date_to_Jday(month,day,year);
		Jhour=hour + minute/60 + second/3600;
		fclose(fid_time);
    else
		disp('Could not open .SUM file either.  Will rely on input Jday,Jhour.');
        if ~isempty(cback_fig),
            set(h1,'Visible','On');     % Get values also??
            vals=str2num(get(h1,'String')); Jday=vals(1); Jhour=vals(2); return;
        else
            Jday=0; Jhour=0;
        end
    end
end
