1 |
|
---|
2 |
function ADTG = sw_adtg(S,T,P) |
---|
3 |
|
---|
4 |
% SW_ADTG Adiabatic temperature gradient |
---|
5 |
%=========================================================================== |
---|
6 |
% SW_ADTG $Id: sw_adtg.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $ |
---|
7 |
% Copyright (C) CSIRO, Phil Morgan 1992. |
---|
8 |
% |
---|
9 |
% adtg = sw_adtg(S,T,P) |
---|
10 |
% |
---|
11 |
% DESCRIPTION: |
---|
12 |
% Calculates adiabatic temperature gradient as per UNESCO 1983 routines. |
---|
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 |
% ADTG = adiabatic temperature gradient [degree_C/db] |
---|
22 |
% |
---|
23 |
% AUTHOR: Phil Morgan, 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. Unesco Tech. Pap. in Mar. Sci., No. 44, 53 pp. Eqn.(31) p.39 |
---|
33 |
% |
---|
34 |
% Bryden, H. 1973. |
---|
35 |
% "New Polynomials for thermal expansion, adiabatic temperature gradient |
---|
36 |
% and potential temperature of sea water." |
---|
37 |
% DEEP-SEA RES., 1973, Vol20,401-408. |
---|
38 |
%========================================================================= |
---|
39 |
|
---|
40 |
% Modifications |
---|
41 |
% 99-06-25. Lindsay Pender, Fixed transpose of row vectors. |
---|
42 |
% 03-12-12. Lindsay Pender, Converted to ITS-90. |
---|
43 |
|
---|
44 |
%------------- |
---|
45 |
% CHECK INPUTS |
---|
46 |
%------------- |
---|
47 |
if nargin ~= 3 |
---|
48 |
error('sw_adtg.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 |
T68 = 1.00024 * T; |
---|
82 |
|
---|
83 |
a0 = 3.5803E-5; |
---|
84 |
a1 = +8.5258E-6; |
---|
85 |
a2 = -6.836E-8; |
---|
86 |
a3 = 6.6228E-10; |
---|
87 |
|
---|
88 |
b0 = +1.8932E-6; |
---|
89 |
b1 = -4.2393E-8; |
---|
90 |
|
---|
91 |
c0 = +1.8741E-8; |
---|
92 |
c1 = -6.7795E-10; |
---|
93 |
c2 = +8.733E-12; |
---|
94 |
c3 = -5.4481E-14; |
---|
95 |
|
---|
96 |
d0 = -1.1351E-10; |
---|
97 |
d1 = 2.7759E-12; |
---|
98 |
|
---|
99 |
e0 = -4.6206E-13; |
---|
100 |
e1 = +1.8676E-14; |
---|
101 |
e2 = -2.1687E-16; |
---|
102 |
|
---|
103 |
ADTG = a0 + (a1 + (a2 + a3.*T68).*T68).*T68 ... |
---|
104 |
+ (b0 + b1.*T68).*(S-35) ... |
---|
105 |
+ ( (c0 + (c1 + (c2 + c3.*T68).*T68).*T68) ... |
---|
106 |
+ (d0 + d1.*T68).*(S-35) ).*P ... |
---|
107 |
+ ( e0 + (e1 + e2.*T68).*T68 ).*P.*P; |
---|
108 |
|
---|
109 |
return |
---|
110 |
%========================================================================== |
---|
111 |
|
---|
112 |
|
---|