function S= SALINITY (C, T, D);
%function S= SALINITY (C, T, D);
%                 this thing came from the S4 program,
%                 but it seems ok.  can check against Van Holiday's
	R = C / 42.914;
	T2 = T .* T;
	RP = 1+ (D .* (.0000207 - 6.37E-10 * D + 3.989E-15 * D .* D) )./..
	(1 + .03426 * T + .0004464 * T2 + .4215 * R - .003107 * R .* T);
	RT = .6766097 + .0200564 * T + 1.104259E-04 * T2 - 6.9698E-07 * T .* T2 + 1.0031E-09 * T2 .* T2;
	RTP = R ./ (RP .* RT);
	S = .008 - .1692 * sqrt(RTP) + 25.3851 * RTP + 14.0941 * RTP.*sqrt(RTP) - 7.0261 * RTP.*RTP + 2.7081 * RTP.^2.5;
	S = S+ ( (T - 15) .* (.0005 - .0056 * sqrt(RTP) - .0066 * RTP - .0375 * RTP.*sqrt(RTP) + .0636 * RTP.*RTP - .0144 * RTP.^2.5) )/..
   (1 + .0162 .* (T - 15));

