function sal=salin(temp,cond,depth);
%function sal=salin(temp,cond,[depth]);
%                  12/18/89
% This program reads several parameters from the keyboard.
% The parameters are depth, temperature and conductivity.
% The conductivity and temperature are used to calculate 
% salinity.  The salinity and temperature are used to
% calculate sigma-t.
disp('This program needs to be checked.  Looks a little too depth-sensitive')
% Set constants for salinity calculation
r0 = .008;
r1 = -.1692;
r2 = 25.3851;
r3 = 14.0941;
r4 = -7.0261;
r5 = 2.7081;
r6 = .6766097;
r7 = 2.00564e-2;
r8 = 1.104259e-4;
r9 = -6.9698e-7;
r10 = 1.0031e-9;
r11 = 3.426e-2;
r12 = 4.464e-4;
r13 = .4215;
r14 = -3.107e-3;
r15 = 2.07e-4;
r16 = -6.37e-8;
r17 = 3.989e-12;
r18 = 42.909;
r19 = .0005;
r20 = -.0056;
r21 = -.0066;
r22 = -.0375;
r23 = .0636;
r24 = -.0144;
r25 = .0162;

if nargin==2
        depth = 10*ones(temp);
end

depth = .1*depth;
onev = ones(temp);

% Calculate salinity
a = r6*onev + r7*temp + r8*temp.^2 + r9*temp.^3 + r10*temp.^4;
disp('1')
r = cond / r18;
b = onev + depth.*(r15*onev + r16*depth + r17*depth.^2) ./ ...
     (onev + r11*temp + r12*temp.^2 + r.*(r13*onev + r14*temp));
disp('2')
c = r ./ (b .* a);
s = r0*onev + r1*c.^0.5 + r2*c + r3*c.^1.5 + r4*c.^2 + r5*c.^2.5;
disp('3')
u = (temp-15*onev) ./ (onev + r25*(temp - 15*onev));
u = (r19*onev + r20*c.^.5 + r21*c + r22*c.^1.5 + r23*c.^2 + ...
      r24*c.^2.5) .* u;
sal = s + u;
