function ascii_wrapper
%nc_directory = 'c:/ocr3000/NC_ascii/netcdf';
nc_directory = '/hosts/tornado/ssdsdata/deployments/m0/200607';

%nc_filename = 'm0_adcp1267_20060731';
%[data, header, meta_data] = nc_to_ascii (nc_directory, nc_filename);
%delete ([nc_directory '/ascii_output/' nc_filename '.txt']);
%tblwrite_smb(data, header, meta_data, [nc_directory '/ascii_output/' nc_filename '.txt'],'\t',12)


%metsys
nc_filename1 = 'm0_metsys_20060801_original';
nc_filename2 = 'm0_metsys_20061108_original';
delete ([nc_directory '/ascii_output/' nc_filename1 '.txt']);
netcdf_concat (nc_directory, nc_filename1, nc_filename2);

nc_filename = {'m0_ctd0000_20060731_original'; 'm0_ts_20060731'};

for file = 1:length(nc_filename),
    [new_data, new_meta_data, header, append] ...
        = nc_to_ascii (nc_directory, char(nc_filename(file)));
    tblwrite_smb(new_data, header, new_meta_data, ...
        [nc_directory '/ascii_output/' char(nc_filename(file)) '.txt'],'\t',12, append)

end

%ctd
%nc_filename = 'm0_ctd0000_20060731_original';
%[data, header, meta_data] = nc_to_ascii (nc_directory, nc_filename);
%delete ([nc_directory '/ascii_output/' nc_filename '.txt']);
%tblwrite_smb(data, header, meta_data, [nc_directory '/ascii_output/' nc_filename '.txt'],'\t',12)

%ts
%nc_filename = 'm0_ts_20060731';
%[data, header, meta_data] = nc_to_ascii (nc_directory, nc_filename);
%delete ([nc_directory '/ascii_output/' nc_filename '.txt']);
%tblwrite_smb(data, header, meta_data, [nc_directory '/ascii_output/' nc_filename '.txt'],'\t',12)

disp(['M0 ASCII files written to ' nc_directory '/ascii_output/']);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function netcdf_concat (nc_directory, nc_filename1, nc_filename2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        

[data1, header1, meta_data1, append] = nc_to_ascii (nc_directory, nc_filename1);
[data2, header2, meta_data2, append] = nc_to_ascii (nc_directory, nc_filename2);

header = header1;
data = [data1; data2];
meta_data = [meta_data1; meta_data2];

tblwrite_smb(data, header, meta_data, ...
    [nc_directory '/ascii_output/' nc_filename1 '.txt'],'\t',12, append)

end