function dvla_depth_read(array_no)
%
%
% 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 array_no==1,
    file_roots={'178','179','191','180'};
else
    file_roots={'192','193','194','195'};
end
%
for jfile=1:4,
    fid(jfile)=fopen([file_roots{jfile},'.txt']);
end
for jline=1:26,
    for jfile=1:4,
        tline = fgetl(fid(jfile));
    end
end
for jfile=1:4,
    tline2 = fgetl(fid(jfile));
end

year=str2num(tline2(12:15));
month=str2num(tline2(17:18));
day=str2num(tline2(20:21));
hour=str2num(tline2(23:24));
minute=str2num(tline2(26:27));
sec=str2num(tline2(29:30));
Jday=date_to_Jday(month,day,year),
Jhour=hour + minute/60 + sec/3600;

depth=str2num(tline2(35:49));

cts_root=['dvla_depth_',int2str(array_no)]; nrec=4; fs=1; f_bb=0; ii_type=0; val_type=0;
[fid_cts,cts_hdr]=cts_write_open(cts_root,Jday,Jhour,nrec,fs,f_bb,ii_type,val_type);
done=0; nline=2000; nblock=0;
while ~done,
    nblock=nblock + 1;
    depth=zeros(4,nline); nline_tot=nline;
    for jfile=1:4,
        for jline=1:nline,
            tline2=fgetl(fid(jfile)); 
            if ~ischar(tline2), 
                done=1; jfile,jline,tlinep,
                nline_tot=min([nline_tot,jline-1]),
                break, 
            end
            tlinep=tline2;
 %           jfile, jline, tline2(39:49)
            depth(jfile,jline)=str2num(tline2(39:49));
        end
    end
    stat=cts_write(fid_cts,depth(:,1:nline_tot),0);
    disp(['Finished block ',int2str(nblock)]);
end
fclose(fid_cts);
    
