function netcdf_to_txt
all_dep_dir = '/hosts/tornado/ssdsdata/deployments/m0/ascii_all_dep/';
nc_directory = '/hosts/tornado/ssdsdata/deployments/m0/200607';
ascii_directory = '/hosts/tornado/ssdsdata/deployments/m0/200607/ascii_output/';
mat_directory = '/hosts/tornado/ssdsdata/deployments/m0/200607/ascii_output/mat_files/';
nc_filename = {'m0_adcp1267_20060731';'m0_ctd0000_20060731_original' ;...
    'm0_ts_20060731';'m0_gps1564_20060731'; 'm0_metsys_20061108_original';...
    'm0_ecoflntu_20061108'}; %; 


all_filename = {'m0_adcp';'m0_ctd'; 'm0_ts'; 'm0_gps'; 'm0_metsys'; 'm0_ecoflntu_20061108'}; %'m0_adcp'; 

ascii_wrapper (nc_directory, ascii_directory, mat_directory, ...
    all_dep_dir, all_filename, nc_filename)

%radiometers
nc_directory = '/hosts/tornado/ssdsdata/ocr3000cimt/netcdf/ssds_netcdf/';

nc_filename = {'CIMT_ocr3000_Eds_mean_ssds'; 'CIMT_ocr3000_Ed5_mean_ssds'; ...
    'CIMT_ocr3000_Ed10_mean_ssds'; 'CIMT_ocr3000_Lu5_mean_ssds'; ...
    'CIMT_ocr3000_Lu10_mean_ssds'; 'CIMT_ocr3000_Eds_median_ssds'; ...
    'CIMT_ocr3000_Ed5_median_ssds'; 'CIMT_ocr3000_Ed10_median_ssds'; ...
    'CIMT_ocr3000_Lu5_median_ssds'; 'CIMT_ocr3000_Lu10_median_ssds'};

ascii_wrapper (nc_directory, ascii_directory, mat_directory, ...
    all_dep_dir, nc_filename, nc_filename)

%co2 measurements - supplied by a scheduled excel macro to run on
%Phytoplankton
nc_directory = '/hosts/tornado/ssdsdata/deployments/m0/200607';
co2 (nc_directory, ascii_directory, mat_directory, all_dep_dir)


%M0 surface observations (hourly) for LOBOVIZ/ODV - in development
%nc_to_odv_surf
%nc_loaddap_odv_surf



disp(['M0 ASCII files written to ' nc_directory]);
%metsys
%nc_filename1 = 'm0_metsys_20060801_original';
%nc_filename2 = 'm0_metsys_20061108_original';
%netcdf_concat (nc_directory, mat_directory, nc_filename1, nc_filename2);

%ecflntu
%nc_filename1 = 'm0_ecoflntu_20060731';
%nc_filename2 = 'm0_ecoflntu_20061108';
%netcdf_concat (nc_directory, nc_filename1, nc_filename2);

end


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

[data1, meta_data1, header1, append, a ,b ,c] = nc_to_ascii (nc_directory, nc_filename1);
[data2, meta_data2, header2, append, data, meta_data, time_esecs] = nc_to_ascii (nc_directory, nc_filename2);
if (isempty(data2)==0),
    header = header1;
    data_all = [data1; data2];
    meta_data_all = [meta_data1; meta_data2];

    tblwrite_smb(data_all, header, meta_data_all, ...
        [nc_directory '/ascii_output/' nc_filename1 '.txt'],'\t',12,append)
    
    save ([mat_directory nc_filename2 '.mat'], 'data', 'meta_data', 'header', 'time_esecs');
end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function co2 (nc_directory, ascii_directory, mat_directory, all_dep_dir)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
filename = 'm0_co2';

    [new_data, new_meta_data, header, append, data, meta_data, time_esecs] ...
      = co2_read (nc_directory, ascii_directory, mat_directory, filename);
    if (isempty(new_data)==0),
        tblwrite_smb(new_data, header, new_meta_data, ...
            [ascii_directory filename '.txt'],'\t',12, append)
        %also appends to entire data set...
        tblwrite_smb(new_data, header, new_meta_data, ...
            [all_dep_dir filename '.txt'],'\t',12, 1)

        save ([mat_directory filename '.mat'], 'data', 'meta_data', 'header', 'time_esecs');

    end

end
