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

% USAGE: he3 in TU = del2TU(dHe3,T,S,He4,flag)
% Convert dHe3% to He3 in TU. dHe3 and He4 are the measured 
% values of those variables. T, S are temp and salinity. All
% input arguments must be vectors of same length.
% This function accounts for the solubility equilibrium
% and bubble entrainment components of He3. Thus it first
% computes excess (tritiugenic) He3 in ccSTP/g, and then
% converts to TU. 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. In this case NO buuble component can be 
% computed and this is then assumed absent. 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.

a = (deleq(T,S)/100)+1; % 3/4 fractionation factor. Benson and Krause
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
t1 = Ra*He4.*(del/100) + Ra*He4eq.*(1-a); % [He3]xs in ccSTP/g
tu = 4.021e14*t1./(1 - (S/1000)); % [He3]xs in TU

if (flag == 0)
	tu(i)=NaN;
end
% tu =  (Ra/(100*2.49e-15))*He4.*(del - deleq(T,S));
