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

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/q4_eqnstate2.m

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

Initial import of Stark code.

Line 
1 function R=eqnstate2(T,S)
2 %EQNSTATE2 - Matlab implementation of QUODDY's Equation of State.
3 %-----------------------------------------------------------------------
4 % purpose: This subroutine computes the perturbation density (R; in
5 %          sigmat units) as a function of two variables; temperature
6 %          (T; 0 to 40 degrees C) and salinity (S; 0 to 42 psu).
7 %
8 % reference: UNESCO equation of state as published in Gill(1982)
9 % Contributed by Douglas T. Morgan
10 %
11 % Vectorized version; BOB for FCAST work
12
13 if min(T)<0 | max(T)>40.
14    error('Temperature outside of allowable range: (0<T<40)')
15 end
16 if min(S)<0 | max(S)>42.
17    error('Salinity outside of allowable range: (0<S<42)')
18 end
19
20 [mT,nT]=size(T);
21 [mS,nS]=size(S);
22    
23 if (mS ~= mT) | (nS ~= nT)
24    if mT*nT~=1 & mS*nS~=1
25       disp('Size of Temp array and Sal array must be the same')
26       disp('or one must be 1x1.')
27       R=[];
28       return
29    end
30 end
31
32 %
33 %...Density of pure water
34 %
35 R=-0.157406 ... 
36   +6.793952E-2*T ...
37   -9.095290E-3*T.^2 ...
38   +1.001685E-4*T.^3 ...
39   -1.120083E-6*T.^4 ...
40   +6.536332E-9*T.^5;
41 %
42 %...Density at one standard atmosphere
43 F1=0.824493...
44         -4.0899E-3*T ...
45         +7.6438E-5*T.^2 ...
46         -8.2467E-7*T.^3 ...
47         +5.3875E-9*T.^4.0;
48 F2=-5.72466E-3 + 1.0227E-4*T - 1.6546E-6*T.^2;
49
50 R=R+S.*F1+(S.^1.5).*F2+4.8314E-4*S.^2;
Note: See TracBrowser for help on using the browser.