function out = readback_elemental_data(in,HTML)

% This just reports elemental data from the Cl-36 input structure for error
% checking. 


if nargin < 2
    HTML = 'no';
end

load Cl36_consts;

out = [];

if strcmp(HTML,'yes')
    % Write table header
    out = [out '<table class=standard>'];
end

for a = 1:length(in.n.wpe)
    thiswpe = in.n.wpe{a};
    thisdelwpe = in.n.delwpe{a};
    thiswpetarget = in.n.wpetarget{a};
    thisdelwpetarget = in.n.delwpetarget{a};
    if strcmp(HTML,'no')
        % case dump to command window
        disp(['Sample ' char(in.s.sample_name(in.n.index(a)))]);
        disp('Element, conc in WR, uncert, conc in target, uncert, unit');
        for b = 1:length(consts.elts)
            if thiswpe(b) < 0.0009
                s1 = [sprintf('%0.2f',thiswpe(b).*1e6) ', ' sprintf('%0.2f',thisdelwpe(b).*1e6) ', ' sprintf('%0.2f',thiswpetarget(b).*1e6) ', ' sprintf('%0.2f',thisdelwpetarget(b).*1e6) ', ppm'];
            else
                s1 = [sprintf('%0.2f',thiswpe(b)) ', ' sprintf('%0.2f',thisdelwpe(b)) ', ' sprintf('%0.2f',thiswpetarget(b)) ', ' sprintf('%0.2f',thisdelwpetarget(b)) ', pct'];
            end
            disp([consts.elts{b} ', ' s1]);
        end
    else
        % Case write HTML table
        out = [out '<tr><td align=center colspan=4>Element readback, sample ' char(in.s.sample_name(in.n.index(a))) '</td></tr>'];
        out = [out '<tr><td align=center>Element</td><td align=center>Concentration<br>(whole rock)</td><td align=center>Concentration<br>(target)</td><td align=center>Unit</td></tr>'];
        for b = 1:length(consts.elts)
            if thiswpe(b) < 0.0009
                out = [out '<tr><td>' consts.elts{b} '</td><td align=center>' sprintf('%0.2f',thiswpe(b).*1e6) ' +/- ' sprintf('%0.2f',thisdelwpe(b).*1e6) '</td><td align=center>' sprintf('%0.2f',thiswpetarget(b).*1e6) ' +/- ' sprintf('%0.2f',thisdelwpetarget(b).*1e6) '</td><td align=center>ppm</td><tr>'];
            else
                out = [out '<tr><td>' consts.elts{b} '</td><td align=center>' sprintf('%0.2f',thiswpe(b).*100) ' +/- ' sprintf('%0.2f',thisdelwpe(b).*100) '</td><td align=center>' sprintf('%0.2f',thiswpetarget(b).*100) ' +/- ' sprintf('%0.2f',thisdelwpetarget(b).*100) '</td><td align=center>wt pct</td><tr>'];
            end
        end
    end
end
       
if strcmp(HTML,'yes')
    % Close table
    out = [out '</table>'];
    
end
    