1 |
gforget |
1.1 |
function ADTG = sw_adtg(S,T,P) |
2 |
|
|
|
3 |
|
|
% SW_ADTG Adiabatic temperature gradient |
4 |
|
|
%=========================================================================== |
5 |
|
|
% SW_ADTG $Revision: 1.4 $ $Date: 1994/10/10 04:16:37 $ |
6 |
|
|
% Copyright (C) CSIRO, Phil Morgan 1992. |
7 |
|
|
% |
8 |
|
|
% adtg = sw_adtg(S,T,P) |
9 |
|
|
% |
10 |
|
|
% DESCRIPTION: |
11 |
|
|
% Calculates adiabatic temperature gradient as per UNESCO 1983 routines. |
12 |
|
|
% |
13 |
|
|
% INPUT: (all must have same dimensions) |
14 |
|
|
% S = salinity [psu (PSS-78) ] |
15 |
|
|
% T = temperature [degree C (IPTS-68)] |
16 |
|
|
% P = pressure [db] |
17 |
|
|
% (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) ) |
18 |
|
|
% |
19 |
|
|
% OUTPUT: |
20 |
|
|
% ADTG = adiabatic temperature gradient [degree_C/db] |
21 |
|
|
% |
22 |
|
|
% AUTHOR: Phil Morgan 92-04-03 (morgan@ml.csiro.au) |
23 |
|
|
% |
24 |
|
|
% DISCLAIMER: |
25 |
|
|
% This software is provided "as is" without warranty of any kind. |
26 |
|
|
% See the file sw_copy.m for conditions of use and licence. |
27 |
|
|
% |
28 |
|
|
% REFERENCES: |
29 |
|
|
% Fofonoff, P. and Millard, R.C. Jr |
30 |
|
|
% Unesco 1983. Algorithms for computation of fundamental properties of |
31 |
|
|
% seawater. Unesco Tech. Pap. in Mar. Sci., No. 44, 53 pp. Eqn.(31) p.39 |
32 |
|
|
% |
33 |
|
|
% Bryden, H. 1973. |
34 |
|
|
% "New Polynomials for thermal expansion, adiabatic temperature gradient |
35 |
|
|
% and potential temperature of sea water." |
36 |
|
|
% DEEP-SEA RES., 1973, Vol20,401-408. |
37 |
|
|
%========================================================================= |
38 |
|
|
|
39 |
|
|
%------------- |
40 |
|
|
% CHECK INPUTS |
41 |
|
|
%------------- |
42 |
|
|
if nargin ~= 3 |
43 |
|
|
error('sw_adtg.m: Must pass 3 parameters ') |
44 |
|
|
end %if |
45 |
|
|
|
46 |
|
|
% CHECK S,T,P dimensions and verify consistent |
47 |
|
|
[ms,ns] = size(S); |
48 |
|
|
[mt,nt] = size(T); |
49 |
|
|
[mp,np] = size(P); |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
% CHECK THAT S & T HAVE SAME SHAPE |
53 |
|
|
if (ms~=mt) | (ns~=nt) |
54 |
|
|
error('check_stp: S & T must have same dimensions') |
55 |
|
|
end %if |
56 |
|
|
|
57 |
|
|
% CHECK OPTIONAL SHAPES FOR P |
58 |
|
|
if mp==1 & np==1 % P is a scalar. Fill to size of S |
59 |
|
|
P = P(1)*ones(ms,ns); |
60 |
|
|
elseif np==ns & mp==1 % P is row vector with same cols as S |
61 |
|
|
P = P( ones(1,ms), : ); % Copy down each column. |
62 |
|
|
elseif mp==ms & np==1 % P is column vector |
63 |
|
|
P = P( :, ones(1,ns) ); % Copy across each row |
64 |
|
|
elseif mp==ms & np==ns % PR is a matrix size(S) |
65 |
|
|
% shape ok |
66 |
|
|
else |
67 |
|
|
error('check_stp: P has wrong dimensions') |
68 |
|
|
end %if |
69 |
|
|
[mp,np] = size(P); |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
% IF ALL ROW VECTORS ARE PASSED THEN LET US PRESERVE SHAPE ON RETURN. |
74 |
|
|
Transpose = 0; |
75 |
|
|
if mp == 1 % row vector |
76 |
|
|
P = P(:); |
77 |
|
|
T = T(:); |
78 |
|
|
S = S(:); |
79 |
|
|
|
80 |
|
|
Transpose = 1; |
81 |
|
|
end %if |
82 |
|
|
%***check_stp |
83 |
|
|
|
84 |
|
|
%------------- |
85 |
|
|
% BEGIN |
86 |
|
|
%------------- |
87 |
|
|
a0 = 3.5803E-5; |
88 |
|
|
a1 = +8.5258E-6; |
89 |
|
|
a2 = -6.836E-8; |
90 |
|
|
a3 = 6.6228E-10; |
91 |
|
|
|
92 |
|
|
b0 = +1.8932E-6; |
93 |
|
|
b1 = -4.2393E-8; |
94 |
|
|
|
95 |
|
|
c0 = +1.8741E-8; |
96 |
|
|
c1 = -6.7795E-10; |
97 |
|
|
c2 = +8.733E-12; |
98 |
|
|
c3 = -5.4481E-14; |
99 |
|
|
|
100 |
|
|
d0 = -1.1351E-10; |
101 |
|
|
d1 = 2.7759E-12; |
102 |
|
|
|
103 |
|
|
e0 = -4.6206E-13; |
104 |
|
|
e1 = +1.8676E-14; |
105 |
|
|
e2 = -2.1687E-16; |
106 |
|
|
|
107 |
|
|
ADTG = a0 + (a1 + (a2 + a3.*T).*T).*T ... |
108 |
|
|
+ (b0 + b1.*T).*(S-35) ... |
109 |
|
|
+ ( (c0 + (c1 + (c2 + c3.*T).*T).*T) + (d0 + d1.*T).*(S-35) ).*P ... |
110 |
|
|
+ ( e0 + (e1 + e2.*T).*T ).*P.*P; |
111 |
|
|
|
112 |
|
|
if Transpose |
113 |
|
|
ADTG = ADTG'; |
114 |
|
|
end %if |
115 |
|
|
|
116 |
|
|
return |
117 |
|
|
%========================================================================== |