function [XH,cspec]=fft_read1(FFT,jseq,jrec,jfreq);
%
% [XH,cspec]=fft_read1(FFT,jseq,jrec,jfreq);
%
% cspec     = cspec(1:nfreq,1:nrec,1:nseq)
%
%
% 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<4, jfreq=[]; end
%
if length(jfreq)==2,
	fax=(FFT.imap(:,1) - 1) * FFT.df;
	jfreq=find(fax>=jfreq(1) & fax<=jfreq(2));
end
%
if isempty(jrec), jrec=[1:FFT.nrec]; end
if isempty(jseq), jseq=[1:FFT.nseq]; end
if isempty(jfreq), jfreq=[1:FFT.nfreq]; end
nrec=length(jrec); nseq=length(jseq); nfreq=length(jfreq);
cspec=zeros(nfreq,nrec,nseq) + i*ones(nfreq,nrec,nseq);
xh=zeros(20,nrec,nseq);
%
if min(jseq)<1 | max(jseq)>FFT.nseq,
	jseq,FFT.nseq,
	error('USER ERROR: illegal sequence specification jseq') 
end
if min(jrec)<1 | max(jrec)>FFT.nrec,
	jrec,FFT.nrec,
	error('USER ERROR: illegal receiver specification jrec') 
end
if min(jfreq)<1 | max(jfreq)>FFT.nfreq,
	jfreq,FFT.nfreq,
	error('USER ERROR: illegal frequency specification jfreq') 
end
%
nf2=2*nfreq; data=zeros(nf2,1); 
ii1=1:2:nf2; ii2=ii1 + 1; jfreq(1);
off2=(jfreq(1)-1)*2*4;
for js=1:nseq,
	jseq_out=jseq(js);
	for jr=1:nrec,
		jrec_out=jrec(jr);
		offset=((jseq_out-1)*FFT.nrec + (jrec_out-1))*FFT.lenrec;
		stat=fseek(FFT.fft_fid,offset,'bof');
        if stat<0, error(['Error seeking in fft_read1 - file too large? ',int2str(offset)]); end
%		[data(1:FFT.nwords),count] = fread(FFT.fft_fid,FFT.nwords,'real*4');
		[xh(:,jr,js),count] = fread(FFT.fft_fid,20,'real*4');
		if count<20,
			count,FFT.nwords,
			disp('Error reading FFT file');
		end
		if jfreq(1) > 1, fseek(FFT.fft_fid,off2,'cof'); end
		[data(1:nf2),count] = fread(FFT.fft_fid,nf2,'real*4');
%
		if count<nf2,
			count,FFT.nwords,
			disp('Error reading FFT file');
		end
		cspec(1:nfreq,jr,js)=data(ii1) + i*data(ii2);
	end
end
XH.moy=squeeze(xh(1,1,:)); XH.t0=squeeze(xh(14,1,:));
XH.seqs=squeeze(xh(3,:,1));
XH.recs=squeeze(xh(4,:,1));
XH.rng=squeeze(xh(18,:,1)); XH.zr=squeeze(xh(19,:,1)); 
XH.h20=squeeze(xh(20,:,1));
moy=XH.moy + XH.t0/60;
[Jday,Jhour,Jmin]=moy2jday(moy);
XH.hod=(Jday - FFT.jday0)*24 + Jhour + Jmin/60;
%
if nrec>1 & all(diff(XH.recs)==0), XH.recs=jrec; end
