function [d, GR] = depth(P,LAT)
%function [d, GR] = depth(P,LAT)
%
% ********************************************************************
% DEPTH IN METERS FROM PRESSURE IN DECIBARS USING
% SAUNDERS AND FOFONOFF'S METHOD.
% DEEP-SEA RES., 1976,23,109-111.
% FORMULA REFITTED FOR 1980 EQUATION OF STATE
% ***
% UNITS:      
%       PRESSURE        P        DECIBARS
%       LATITUDE        LAT      DEGREES
%       DEPTH           DEPTH    METERS
% ***
% CHECKVALUE: DEPTH = 9712.653 M FOR P=10000 DECIBARS, LATITUDE=30 DEG
%     ABOVE FOR STANDARD OCEAN: T=0 DEG. CELSUIS ; S=35 (IPSS-78)
% ***
%
      X = sin(LAT/57.29578);
      X = X.*X;
% GR= GRAVITY VARIATION WITH LATITUDE: ANON (1970) BULLETIN GEODESIQUE
      GR = 9.780318*(1.0+(5.2788E-3+2.36E-5*X).*X) + 1.092E-6*P;
      DEPTH = (((-1.82E-15*P+2.279E-10).*P-2.2512E-5).*P+9.72659).*P;
      d=DEPTH./GR;
