function [ctd_pr_idx, ctd_c1_idx, ctd_c2_idx, ctd_t1_idx, ctd_t2_idx, ctd_ox1_idx, ctd_ox2_idx, ctd_oxyv1_idx, ctd_oxyv2_idx, flag_conv1, flag_message1, flag_cond_Sm_to_mScm] = determine_column_names_of_btl_file (btl)
%
% Assume that each btl file has the same btl.names stings
%
% determine which column of data is each variable
% by extracting the indexes for the .btl files usin ghte names field.
%
% loop through each of the names and see what it matches.
%
% be flexible about what the pressure variable is called in "names"
% string.  Can appear as "pressure", "PrDM", etc.
flag_conv1 = 0;
flag_message1 = 0;
flag_cond_Sm_to_mScm = 0;

clear II
II = strmatch('pr',lower(btl(1).names));
if isempty(II)
    II = strmatch('de',lower(btl(1).names));
    if isempty(II)        
        fprintf(1,'WARNING:  Can''t find pressure or depth variable in btl files.\n');
    else
        fprintf(1,'WARNING:  Can''t find pressure variable in btl files. Using Depth.\n');
        ctd_pr_idx=min(II);
        names(1) = btl(1).names(min(II));
    end
else
    ctd_pr_idx=min(II);
    names(1) = btl(1).names(min(II));
end

% be flexible about what the conductivity variable is called in "names"
% string.  Can appear as "con_pri", "C0Sm", "C0cmSm" etc.
clear II
II = strmatch('con_pri',lower(btl(1).names));
if isempty(II)
    II = strmatch('c0',lower(btl(1).names));
    if isempty(II)        
        fprintf(1,'WARNING:  Can''t find primary conductivity variable in btl files.\n');
    else
        ctd_c1_idx=min(II);
        names(2) = btl(1).names(min(II));
        II = strmatch('c0mscm',lower(btl(1).names));
        if isempty(II)        
            flag_cond_Sm_to_mScm = 1;
        else
            flag_cond_Sm_to_mScm = 0;
        end
    end
else
    ctd_c1_idx=min(II);
    names(2) = btl(1).names(min(II));
end


% be flexible about what the conductivity variable is called in "names"
% string.  Can appear as "con_sec", "C1Sm", "C1cmSm" etc.
clear II
II = strmatch('con_sec',lower(btl(1).names));
if isempty(II)
    II = strmatch('c1',lower(btl(1).names));
    if isempty(II)        
        fprintf(1,'WARNING:  Can''t find secondary conductivity variable in btl files.\n');
    else
        ctd_c2_idx=min(II);
        names(3) = btl(1).names(min(II));
        II = strmatch('c1mscm',lower(btl(1).names));
        if isempty(II)        
            flag_cond_Sm_to_mScm = 1;
        else
            flag_cond_Sm_to_mScm = 0;
        end
    end
else
    ctd_c2_idx=min(II);
        names(3) = btl(1).names(min(II));
end


% be flexible about what the temperature variable is called in "names"
% string.  Can appear as "t90_pri", "t090c", etc.
clear II
II = strmatch('t90_pri',lower(btl(1).names));
if isempty(II)
    II = strmatch('t090c',lower(btl(1).names));
    if isempty(II) 
        II = strmatch('t68_pri',lower(btl(1).names));
        if isempty(II)
            II = strmatch('t068c',lower(btl(1).names));
            if isempty(II)
                fprintf(1,'WARNING:  Can''t find primary temperature variable in btl files.\n');
            else
                ctd_t1_idx=min(II);
                names(4) = btl(1).names(min(II));
           		flag_conv1=1;
                if flag_message1==0
                    fprintf(1,'Primary temperatures are given in T68.\nThis program will convert to T90 to make the necessary calculations\n')
                    flag_message1=1;
                end
            end
        else
            ctd_t1_idx=min(II);
            names(4) = btl(1).names(min(II));
            flag_conv1=1;
            if flag_message1==0
                fprintf(1,'Primary temperatures are given in T68.\nThis program will convert to T90 to make the necessary calculations\n')
                flag_message1=1;
            end
        end
    else
        ctd_t1_idx=min(II);
        names(4) = btl(1).names(min(II));
    end
else
    ctd_t1_idx=min(II);
    names(4) = btl(1).names(min(II));
end


% be flexible about what the temperature variable is called in "names"
% string.  Can appear as "t90_sec", "t190c", etc.
clear II
II = strmatch('t90_sec',lower(btl(1).names));
if isempty(II)
    II = strmatch('t190c',lower(btl(1).names));
    if isempty(II) 
        II = strmatch('t68_sec',lower(btl(1).names));
        if isempty(II)
            II = strmatch('t168c',lower(btl(1).names));
            if isempty(II)
                fprintf(1,'WARNING:  Can''t find secondary temperature variable in btl files.\n');
            else
                ctd_t2_idx=min(II);
                cond_match.names(4) = btl(1).names(min(II));
           		flag_conv1=1;
                if flag_message1==0
                    fprintf(1,'Secondary temperatures are given in T68.\nThis program will convert to T90 to make the necessary calculations\n')
                    flag_message1=1;
                end
            end
        else
            ctd_t2_idx=min(II);
            names(5) = btl(1).names(min(II));
            flag_conv1=1;
            if flag_message1==0
                fprintf(1,'Secondary temperatures are given in T68.\nThis program will convert to T90 to make the necessary calculations\n')
                flag_message1=1;
            end
        end
    else
        ctd_t2_idx=min(II);
        names(5) = btl(1).names(min(II));
    end
else
    ctd_t2_idx=min(II);
    names(5) = btl(1).names(min(II));
end

% read in primary oxygen mll
clear II
II = strmatch('sbeox0mll',lower(btl(1).names));
if isempty(II)
        fprintf(1,'WARNING:  Can''t find primary o variable in btl files.\n');
else
    ctd_ox1_idx=min(II);
    names(6) = btl(1).names(min(II));
end

% read in secondary oxygen mll
clear II
II = strmatch('sbeox1mll',lower(btl(1).names));
if isempty(II)
        fprintf(1,'WARNING:  Can''t find primary o variable in btl files.\n');
else
    ctd_ox2_idx=min(II);
    names(7) = btl(1).names(min(II));
end

% read in primary oxygen v
clear II
II = strmatch('sbeox0v',lower(btl(1).names));
if isempty(II)
        fprintf(1,'WARNING:  Can''t find primary ov variable in btl files.\n');
else
    ctd_oxyv1_idx=min(II);
    names(8) = btl(1).names(min(II));
end

% read in secondary oxygen v
clear II
II = strmatch('sbeox1v',lower(btl(1).names));
if isempty(II)
        fprintf(1,'WARNING:  Can''t find primary ov variable in btl files.\n');
else
    ctd_oxyv2_idx=min(II);
    names(9) = btl(1).names(min(II));
end

% read in btle time
% clear II
% II = strmatch('time',lower(btl(1).names));
% if isempty(II)
%     fprintf(1,'Warning: Can''t find time variable in btl files. \n');
% else
%     time_idx=min(II);
%     names(10) = btl(1).names(min(II));
% end;

%
% 1  'Bottle'
% 2   'Date'
% 3   'Potemp090C'
% 4   'Potemp190C'
% 5   'Sal00'
% 6   'Sal11'
% 7   'Sbeox0MLL'
% 8   'Sbeox1MLL'
% 9   'Scan'
% 10   'TimeS'
% 11   'DepSM'
% 12   'PrDM'
% 13   'T090C'
% 14   'T190C'
% 15   'C0Sm'
% 16   'C1Sm'
% 17   'Sbeox0V'
% 18   'Sbeox1V'
% 19   'AltM'
%
