% hf30_append
% VOCALS 2008 :: 2008-10-25 :: Simon de Szoeke
% Concatenates flux_30*.txt files into one datafile.
clear
read_parameters
disp(['hf30_append: ' cruise ' ' year])

fclose('all');
s=[way_proc_data_flux 'flux_30hf*.txt'];
dr=dir(s);			%lists all files in directory
[n m]=size(dr); %n=# of files in data directory (includes . and ..)

if true % you dislike slow programs
    % concatenate files outside matlab
    filecat(s,[way_proc_data_flux 'cat\flux_30hf_' cruise year '.txt']);
else
    %******************  setup read data loop  **********
    jamx=1;
    for ibg = start:n;% 			%major read loop
        nm=dr(ibg).name; disp(nm)
        if(strcmp(nm(1:9),'flux_30hf') && length(nm)<17)
            e=[way_proc_data_flux dr(ibg).name]; %gets names of files in directory
            stux=load(e);   		%loads all data from files into stux
            [nl ml]=size(stux);
            stux_alla(jamx:jamx+nl-1,1:ml)=stux;  % make data array
            jamx=jamx+nl;
        end;
    end; %  data line loop

    stux_all=sortrows(stux_alla,1);
    % save [way_proc_data, 'flux_30hf_' cruise year(3:4) '.txt'] stux_all -ascii -tabs
    save([way_proc_data_flux, 'flux_30hf_' cruise year(3:4) '.txt'],'stux_all','-ascii','-tabs')
end