source: trunk/tools/density_binning/binning_neutral_and_co/bn2.pro

Last change on this file was 170, checked in by pinsard, 15 years ago

fill uses paragraph in header with used commons

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1;+
2;
3; Compute the local Brunt-Vaisala frequency
4;       
5; Method :
6; -------
7;       neos = 0  : UNESCO sea water properties
8;          The brunt-vaisala frequency is computed using the polynomial
9;       polynomial expression of McDougall (1987):
10;               N^2 = g * beta * ( alpha/beta*dk[ tn ] - dk[ sn ] )/e3w
11;
12;       neos = 1  : linear equation of state (temperature only)
13;               N^2 = g * ralpha * dk[ tn ]/e3w
14;
15;       neos = 2  : linear equation of state (temperature & salinity)
16;               N^2 = g * (ralpha * dk[ tn ] - rbeta * dk[ sn ] ) / e3w
17;
18;       The use of potential density to compute N^2 introduces e r r o r
19;      in the sign of N^2 at great depths. We recommand the use of
20;      neos = 0, except for academical studies.
21;
22;      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
23;      and is never used at this level.
24;
25; References :
26; -----------
27; McDougall, T. J., J. Phys. Oceanogr., 17, 1950-1964, 1987.
28;
29; @param TN {in}
30; potential temperature
31;
32; @param SN {in}
33; salinity sn
34;
35; @returns
36; brunt-vaisala frequency
37;
38; @uses
39; <pro>common</pro>
40;
41; @history
42; Original  : 94-07 (G. Madec, M. Imbard)
43; Additions : 97-07 (G. Madec) introduction of statement functions
44; Idl version : 98-12 (M. Levy)
45;
46; @version
47; $Id$
48;
49;-
50FUNCTION bn2, tn, sn, neos
51;
52  compile_opt idl2, strictarrsubs
53;
54@common
55;
56   case n_params() of
57      0:begin
58         print, 'rentrer nom des champs de temperature et/ou salinite'
59         goto, sortie
60      end
61      1:begin
62         print, 'pas de salinite : valeur de neos imposee a 1'
63         neos = 1
64      end
65      2:begin
66         print, 'calcul Unesco par default'
67         neos = 0
68      END
69      3:
70   endcase
71domdef
72;  coordonnees z : on s'assure qu'on a autant de points W que de points
73;  T sur le domaine defini par domdef.
74;  on va se servir dans les calculs de e3w (e3) et gdepw (gdep)
75   IF (nzt NE nzw ) THEN BEGIN
76      print, 'le domaine doit etre choisi avec autant de points'
77      print, 'sur  niveaux T que sur les niveaux W pour calculer N2'
78      z = -1
79      GOTO, sortie
80   endif
81   IF (nzt LE 1 ) THEN BEGIN
82      print, 'il faut un minimum de deux points sur la verticale'
83      print, ' pour calculer N2'
84      z = -1
85      GOTO, sortie
86   endif
87   cdgrid = 'W'
88   g = 9.81
89   grille, mask, glam, gphi, gdep, nx, ny,nz, premierx, premiery, premierz, dernierx, derniery, dernierz ,e1,e2,e3, TRI=tri
90   zgde3w = reform( (fltarr(nx*ny)+1)#(g/e3), nx, ny, nz)
91;
92varname='Brunt-Vaisala frequency'
93varunit='s-1'
94;vargrid='W'
95;
96; mask tn and sn
97        tn=tn*tmask
98        sn=sn*tmask
99;
100;  Interior points ( 2=< jk =< jpkm1 )
101;  ----------------
102;
103   case 1 of
104      (neos EQ 0): begin
105; ... UNESCO seawater equation of state
106;   ... temperature, salinity anomalie
107         zzt = 0.5*( tn + shift( tn, 0, 0, 1 ))
108         zzs = 0.5*( sn + shift( sn, 0, 0, 1) ) - 35.0
109         zzp = reform( (fltarr(nx*ny)+1)#gdep, nx , ny, nz)
110;   ... ratio alpha/beta and beta
111         zalbet = fsalbt( zzt, zzs, zzp )
112         zbeta = fsbeta( zzt, zzs, zzp )
113;   ... N^2 = g/e3w * beta * ( alpha/beta * dk[tn] - dk[sn])
114         z = zgde3w * zbeta * mask $
115          * ( zalbet * ( shift(tn, 0, 0, 1) - tn ) $
116              - ( shift(sn, 0, 0, 1) - sn ) )
117      end
118      ( neos EQ 1 ): begin
119; ... First Linear density formulation (function of temperature only)
120;
121        ralpha = 1.176e-4
122        z = zgde3w * ralpha * mask* (shift(tn, 0, 0, 1) - tn)
123         
124      end
125      ( neos EQ 2 ): begin
126; ... Second linear density formulation (function of temp. and salinity)
127;
128         ralpha = 2.e-4
129         rbeta = 0.001     
130         z = zgde3w * mask $
131          * (  ralpha * (shift(tn, 0, 0, 1) - tn) $
132               - rbeta  * (shift(sn, 0, 0, 1) - sn)  )
133      end   
134      (neos NE 0) AND (neos NE 1) AND (neos NE 2): BEGIN
135         print, 'neos doit etre egal a 0, 1 ou 2'
136         GOTO, sortie
137      end
138   endcase
139;
140;
141;  first and last levels
142; ------------------------
143; bn^2=0. at first vertical point and jk=jpk
144   z[*, *, 0] = 0
145   IF (gdep[nz-1] eq gdepw[jpk-1]) THEN z[*, *, nz-1] = 0
146sortie:
147   return, z
148END
Note: See TracBrowser for help on using the repository browser.