function g = gravity(p, lat)
%  1.  NAME
%
%  gravity - Gravity as a function of latitude and pressure
%
%  2.  SYNOPSIS
%
%  g = gravity(p, lat)
%
%  3.  DESCRIPTION
%
%  Calculates the Earth gravity as a function of pressure and latitude.
%  Coding is inspired from the CODAS C-source file ocean/grav.c.
%
%  4.  PARAMETERS
%
%     p  Pressure in dbar.
%
%     lat
%        Latitude in degrees.
%
%  5.  RETURNS
%
%     p  Gravity in m/s^2.
%
%  6.  AUTHOR
%
%  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999.
%

x = sin(lat/57.29578);
x = x .* x;
g = 9.780318*(1.0+(5.2788E-3+2.36E-5*x) .* x) + 1.092E-6*p;

