function o = o2sol_gg92(s,t,p)
%
% function o = o2sol_gg92(s,t,p); input is IN SITU temperature
%
% This function returns the solubility equilibrium 
% oxygen concentration in uM/kg (for seawater of a
% given salinity s, temperature t, and pressure p).
%
% follows Garcia, H. E., and L. I. Gordon (1992) Oxygen solubility in
% seawater:  Better fitting equations.  Limnol. Oceanogr., 37(6), 1307-1312
%

% Calculate potential temperature to get to atmospheric 
% pressure then convert to Kelvin for use in the formula

th = sw_ptmp(s,t,p,0*p);
%disp('WARNING: MODIFICATION O2SOL TO IN SITU TEMPERATURE')
%th=t;

% compute oxsol in umol/kg according to Garcia & Gordon (1992)
% check value is 274.610 at 10C and salinity 35 psu

a0=5.80871;
a1=3.20291;
a2=4.17887;
a3=5.10006;
a4=-9.86643e-2;
a5=3.80369;
b0=-7.01577e-3;
b1=-7.70028e-3;
b2=-1.13864e-2;
b3=-9.51519e-3;
c0=-2.75915e-7;

ts=log((298.15-th)./(273.15+th));
x=a0+a1*ts+a2*ts.^2+a3*ts.^3+a4*ts.^4+a5*ts.^5+s.*(b0+b1*ts+b2*ts.^2+b3*ts.^3)+c0*s.^2;
o=exp(x);

