1 |
|
---|
2 |
function g = sw_g(LAT,z) |
---|
3 |
|
---|
4 |
% SW_G Gravitational acceleration |
---|
5 |
%=========================================================================== |
---|
6 |
% SW_G $Id: sw_g.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $ |
---|
7 |
% Copyright (C) CSIRO, Phil Morgan 1993. |
---|
8 |
% |
---|
9 |
% USAGE: g = sw_g(lat,z) |
---|
10 |
% |
---|
11 |
% DESCRIPTION: |
---|
12 |
% Calculates acceleration due to gravity as function of latitude. |
---|
13 |
% |
---|
14 |
% INPUT: (all must have same dimensions) |
---|
15 |
% lat = Latitude in decimal degress north [-90..+90] |
---|
16 |
% z = height in metres (+ve above sea surface, -ve below) |
---|
17 |
% |
---|
18 |
% OUTPUT: |
---|
19 |
% g = gravity [m/s^2] |
---|
20 |
% |
---|
21 |
% AUTHOR: Phil Morgan 93-04-20 (morgan@ml.csiro.au) |
---|
22 |
% |
---|
23 |
% DISCLAIMER: |
---|
24 |
% This software is provided "as is" without warranty of any kind. |
---|
25 |
% See the file sw_copy.m for conditions of use and licence. |
---|
26 |
% |
---|
27 |
% REFERENCES: |
---|
28 |
% Unesco 1983. Algorithms for computation of fundamental properties of |
---|
29 |
% seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp. |
---|
30 |
% |
---|
31 |
% A.E. Gill 1982. p.597 |
---|
32 |
% "Atmosphere-Ocean Dynamics" |
---|
33 |
% Academic Press: New York. ISBN: 0-12-283522-0 |
---|
34 |
%========================================================================= |
---|
35 |
|
---|
36 |
% CALLER: general purpose |
---|
37 |
% CALLEE: none |
---|
38 |
|
---|
39 |
%------------- |
---|
40 |
% CHECK INPUTS |
---|
41 |
%------------- |
---|
42 |
if ~(nargin==1 | nargin==2) |
---|
43 |
error('sw_g.m: Requires one or two input arguments') |
---|
44 |
end %if |
---|
45 |
if nargin == 1 |
---|
46 |
z = zeros(size(LAT)); |
---|
47 |
end %if |
---|
48 |
|
---|
49 |
[mL,nL] = size(LAT); |
---|
50 |
[mz,nz] = size(z); |
---|
51 |
if ~(mL==mz | nL==nz) |
---|
52 |
error('sw_g.m: Input arguments should have same dimensions') |
---|
53 |
end %if |
---|
54 |
|
---|
55 |
%------------- |
---|
56 |
% BEGIN |
---|
57 |
%------------- |
---|
58 |
% Eqn p27. Unesco 1983. |
---|
59 |
a = 6371000; % mean radius of earth A.E.Gill |
---|
60 |
DEG2RAD = pi/180; |
---|
61 |
LAT = abs(LAT); |
---|
62 |
X = sin(LAT*DEG2RAD); % convert to radians |
---|
63 |
sin2 = X.*X; |
---|
64 |
g = 9.780318*(1.0+(5.2788E-3+2.36E-5*sin2).*sin2); |
---|
65 |
if any(any(z)) |
---|
66 |
g = g./((1+z/a).^2); % from A.E.Gill p.597 |
---|
67 |
end %if |
---|
68 |
return |
---|
69 |
%=========================================================================== |
---|
70 |
|
---|
71 |
|
---|