function [fid,fmt,nchan,iirec_all,nrec_all,Jday,Jhour,Jhour_end,nbyte_file]= ...
	swami_header(data_file,fs);
%
% Call [fid,fmt,nchan,iirec_all,nrec_all,Jday,Jhour,Jhour_end]= ...
%	swami_header(data_file,fs);
%
%
% 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.
fmt='int16';
%
little_first=0;
if little_first,
	fid=fopen(data_file,'r','ieee-le');		% Try ieee-le first
else
	fid=fopen(data_file,'r','ieee-be');		% Try ieee-be first
end
if fid<0, error(['Data file ',data_file ' could not be opened.']); end
%
[header,count]=fread(fid,14,fmt);
status=fseek(fid,0,'eof');				% Go to end of file
nbyte_file=ftell(fid);					% # bytes in file
status=fseek(fid,0,'bof');				% Rewind,fmt);
%
if fid<0, disp(['Data file ',data_file 'could not be opened.']); end
blocksize=header(3)*2,
nchan=header(13);
nsamp=((blocksize/2)-14)/nchan;
%
houryear = header(10);
sechour = header(11);
msec = header(12);
Jday = floor(houryear/24);
hour=houryear-Jday*24;
minutes=floor(sechour/60);
%%sec=sechour - minutes*60;
Jhour = hour + sechour/3600 + msec/3600000;
iirec_all=[1:nchan]; 
nrec_all=length(iirec_all); 
%

nblock_file = fix(nbyte_file/blocksize);
if rem(nbyte_file,blocksize) ~= 0
    disp('Warning:  SWAMI data file size is not an integer multiple of blocksize')
end
nsamp_file=nblock_file*nsamp;
Thour_file=nsamp_file/fs/3600;
Jhour_end=Jhour + Thour_file,
keyboard
%
% NEW 6-19-00: Must rewind:
status=fseek(fid,0,'bof');				% Rewind
