function list()
%
% list is used to save all the editing to text files bottom.asc,
% badprf.asc, and badbin.asc, which are then applied to the database
% by running the dbupdate and badbin programs;
% anything that is currently marked as bottom (*), glitchy (o),
% or having a high error velocity (o) on the plots (except for 'x',
% which means it's already been flagged in the database) will be
% recorded in those files.
%

% The fprintf statements could be vectorized.  The array
% form is probably a holdover from Matlab 4.

% fixed Sat  98/08/01

global BOTTOM LGB NBINS IBLKPRF TIME DEPTH BADPRF BADBIN LISTED

ibot = find(abs(BOTTOM) <= NBINS);
if ~isempty(ibot)
   fid = fopen('bottom.asc', 'a');
   for i = ibot
     fprintf(fid, '  0 %3.0f %3.0f %2.0f/%02.0f/%02.0f  %02.0f:%02.0f:%02.0f', ...
       IBLKPRF(i,:), TIME(i,1:6));
     fprintf(fid, ' A    32767 %5.0f %3.0f\n', ...
       abs(BOTTOM(i)), DEPTH(NBINS*(i-1) + abs(BOTTOM(i))));
   end
   fclose(fid);
end

ibad = find(BADPRF & ~mod(BADPRF,2) );
if ~isempty(ibad)
   fid = fopen('badprf.asc', 'a');
   for i = ibad
     fprintf(fid, ' -1 %3.0f %3.0f %4.0f/%02.0f/%02.0f  %02.0f:%02.0f:%02.0f\n', ...
       IBLKPRF(i,:), TIME(i,1:6));
   end
   fclose(fid);
end

ibad = find(BADBIN & ~mod(BADBIN,2));
if ~isempty(ibad)
   fid = fopen('badbin.asc', 'a');
   ibinprf = ndx2subs(ibad, NBINS);
   iprf    = [0 find(diff([ibinprf(:,2)' -99]) ~= 0)];  % identifying unique profile entries
   for i = 2:length(iprf)
     fprintf(fid, '\n%4.0f/%02.0f/%02.0f  %02.0f:%02.0f:%02.0f %3.0f %3.0f', ...
       TIME(ibinprf(iprf(i),2),1:6), IBLKPRF(ibinprf(iprf(i),2),:));
     fprintf(fid, ' %3.0f %3.0f', iprf(i) - iprf(i-1), ibinprf(1+iprf(i-1):iprf(i),1));
   end
   fclose(fid);
end

LISTED = 1;
