function tu = delxs2TU(del,T,S,He4,flag)

% USAGE: he3 in TU = delxs2TU(dHe3,T,S,He4,flag)
% Convert dHe3% to He3 in TU. He4 is the measured 
% value. T, S are temp and salinity. All
% input arguments must be vectors of same length.
% del is the TRITUGENIC He3 in %.
% If a measured He4 value is not available (i.e. 
% He4 is NaN, there is the option to use the solubility equilibrium
% value by setting flag=1. If flag=0, and He4=NaN,
% a NaN is returned for that value of del.
% WARNING: make sure T or S are not NaN.

% Samar Khatiwala (spk@ldeo.columbia.edu)

Ra = 1.384e-6; % atmospheric 3/4 ratio
He4eq = HEsol(T,S); % solubility equilibrium conc. Weiss, 1971.

i = find(isnan(He4)); % if a He4 measurement is not available
if ((flag==1) & (length(i)>0)) % and flag = 1
  He4(i) = He4eq(i); % use solubility equilibrium value.
end

tu = 4.021e14*(Ra/100)*(del.*He4)./(1 - (S/1000));
