NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/seawater/sw_svel.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1
2 function svel = sw_svel(S,T,P)
3
4 % SW_SVEL    Sound velocity of sea water
5 %=========================================================================
6 % SW_SVEL  $Id: sw_svel.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $
7 %          Copyright (C) CSIRO, Phil Morgan 1993.
8 %
9 % USAGE:  svel = sw_svel(S,T,P)
10 %
11 % DESCRIPTION:
12 %    Sound Velocity in sea water using UNESCO 1983 polynomial.
13 %
14 % INPUT:  (all must have same dimensions)
15 %   S = salinity    [psu      (PSS-78)]
16 %   T = temperature [degree C (ITS-90)]
17 %   P = pressure    [db]
18 %       (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) )
19 %
20 % OUTPUT:
21 %   svel = sound velocity  [m/s]
22 %
23 % AUTHOR:  Phil Morgan 93-04-20, Lindsay Pender (Lindsay.Pender@csiro.au)
24 %
25 % DISCLAIMER:
26 %   This software is provided "as is" without warranty of any kind.
27 %   See the file sw_copy.m for conditions of use and licence.
28 %
29 % REFERENCES:
30 %    Fofonoff, P. and Millard, R.C. Jr
31 %    Unesco 1983. Algorithms for computation of fundamental properties of
32 %    seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp.
33 %=========================================================================
34
35 % Modifications
36 % 99-06-25. Lindsay Pender, Fixed transpose of row vectors.
37 % 03-12-12. Lindsay Pender, Converted to ITS-90.
38
39 % CALLER: general purpose
40 % CALLEE: none
41
42 % UNESCO 1983. eqn.33  p.46
43
44 %----------------------
45 % CHECK INPUT ARGUMENTS
46 %----------------------
47 if nargin ~=3
48    error('sw_svel.m: Must pass 3 parameters')
49 end %if
50
51 % CHECK S,T,P dimensions and verify consistent
52 [ms,ns] = size(S);
53 [mt,nt] = size(T);
54 [mp,np] = size(P);
55
56
57 % CHECK THAT S & T HAVE SAME SHAPE
58 if (ms~=mt) | (ns~=nt)
59    error('check_stp: S & T must have same dimensions')
60 end %if
61
62 % CHECK OPTIONAL SHAPES FOR P
63 if     mp==1  & np==1      % P is a scalar.  Fill to size of S
64    P = P(1)*ones(ms,ns);
65 elseif np==ns & mp==1      % P is row vector with same cols as S
66    P = P( ones(1,ms), : ); %   Copy down each column.
67 elseif mp==ms & np==1      % P is column vector
68    P = P( :, ones(1,ns) ); %   Copy across each row
69 elseif mp==ms & np==ns     % PR is a matrix size(S)
70    % shape ok
71 else
72    error('check_stp: P has wrong dimensions')
73 end %if
74
75 %***check_stp
76
77 %---------
78 % BEGIN
79 %--------
80
81 P = P/10;  % convert db to bars as used in UNESCO routines
82 T68 = T * 1.00024;
83
84 %------------
85 % eqn 34 p.46
86 %------------
87 c00 = 1402.388;
88 c01 =    5.03711;
89 c02 =   -5.80852e-2;
90 c03 =    3.3420e-4;
91 c04 =   -1.47800e-6;
92 c05 =    3.1464e-9;
93
94 c10 =  0.153563;
95 c11 =  6.8982e-4;
96 c12 = -8.1788e-6;
97 c13 =  1.3621e-7;
98 c14 = -6.1185e-10;
99
100 c20 =  3.1260e-5;
101 c21 = -1.7107e-6;
102 c22 =  2.5974e-8;
103 c23 = -2.5335e-10;
104 c24 =  1.0405e-12;
105
106 c30 = -9.7729e-9;
107 c31 =  3.8504e-10;
108 c32 = -2.3643e-12;
109
110 Cw = ((((c32.*T68 + c31).*T68 + c30).*P + ...
111        ((((c24.*T68 + c23).*T68 + c22).*T68 + c21).*T68 + c20)).*P + ...
112        ((((c14.*T68 + c13).*T68 + c12).*T68 + c11).*T68 + c10)).*P + ...
113        ((((c05.*T68 + c04).*T68 + c03).*T68 + c02).*T68 + c01).*T68 + c00;
114
115 %-------------
116 % eqn 35. p.47
117 %-------------
118 a00 =  1.389;
119 a01 = -1.262e-2;
120 a02 =  7.164e-5;
121 a03 =  2.006e-6;
122 a04 = -3.21e-8;
123
124 a10 =  9.4742e-5;
125 a11 = -1.2580e-5;
126 a12 = -6.4885e-8;
127 a13 =  1.0507e-8;
128 a14 = -2.0122e-10;
129
130 a20 = -3.9064e-7;
131 a21 =  9.1041e-9;
132 a22 = -1.6002e-10;
133 a23 =  7.988e-12;
134
135 a30 =  1.100e-10;
136 a31 =  6.649e-12;
137 a32 = -3.389e-13;
138
139 A = ((((a32.*T68 + a31).*T68 + a30).*P + ...
140     (((a23.*T68 + a22).*T68 + a21).*T68 + a20)).*P + ...
141     ((((a14.*T68 + a13).*T68 + a12).*T68 + a11).*T68 + a10)).*P + ...
142     (((a04.*T68 + a03).*T68 + a02).*T68 + a01).*T68 + a00;
143
144 %------------
145 % eqn 36 p.47
146 %------------
147 b00 = -1.922e-2;
148 b01 = -4.42e-5;
149 b10 =  7.3637e-5;
150 b11 =  1.7945e-7;
151
152 B = b00 + b01.*T68 + (b10 + b11.*T68).*P;
153
154 %------------
155 % eqn 37 p.47
156 %------------
157 d00 =  1.727e-3;
158 d10 = -7.9836e-6;
159
160 D = d00 + d10.*P;
161
162 %------------
163 % eqn 33 p.46
164 %------------
165 svel = Cw + A.*S + B.*S.*sqrt(S) + D.*S.^2;
166
Note: See TracBrowser for help on using the browser.