source: trunk/SRC/ToBeReviewed/CALCULS/rhon.pro @ 442

Last change on this file since 442 was 430, checked in by pinsard, 14 years ago

indent shell scripts

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1;+
2;
3; Calcul de la fonction d'etat (issue de eos.F)
4;
5; @categories
6;
7; @param SN
8;
9; @param TN
10;
11; @keyword INSITU
12;
13; @keyword SIGMA_N
14;
15; @returns
16;
17; @uses
18;
19; @restrictions
20;
21; @examples
22;
23; @history
24;
25; - Creation : 1997 / G. Roullet
26;
27; - adaptation pour les tableaux z,zt,xyz,xyzt  par seb.
28;
29; @version
30; $Id$
31;
32; @todo seb
33;
34;-
35FUNCTION rhon, sn, tn, INSITU=insitu, SIGMA_N=sigma_n
36;
37  compile_opt idl2, strictarrsubs
38;
39@common
40   tempsun = systime(1)         ; pour key_performance
41      sn = -1e5 > double(sn) < 1e5
42      tn = -1e5 > double(tn) < 1e5
43
44
45      IF keyword_set(sigma_n) then insitu = 1
46
47   taille = size(sn)
48   case taille[0] of
49      0:BEGIN                   ;z
50         zrhop=0d
51         jkmax = 1
52      END
53      1:BEGIN                   ;z
54         zrhop=dblarr(taille[1])
55         jkmax = taille[1]
56      END
57      2:BEGIN                   ;xy (jpt=1) ou zt
58         zrhop=dblarr(taille[1],taille[2])
59         if jpt EQ 1 then jkmax = 1 ELSE jkmax = taille[1]
60      END
61      3:BEGIN                   ;xyz (jpt=1) ou xyt
62         zrhop=dblarr(taille[1],taille[2],taille[3])
63         if jpt EQ 1 then jkmax = taille[3] ELSE jkmax = 1
64      END
65      4:BEGIN                   ;xyzt
66         zrhop=dblarr(taille[1],taille[2],taille[3],taille[4] )
67         jkmax = taille[3]
68      END
69   endcase
70
71
72
73   FOR jk = 0, jkmax-1 DO BEGIN
74
75      case taille[0] of
76         0:BEGIN                ;z
77            ztt = tn
78            zs = sn
79         END
80         1:BEGIN                ;z
81            ztt = tn[jk]
82            zs = sn[jk]
83         END
84         2:BEGIN                ;xy (jpt=1) ou zt
85            if jpt EQ 1 then begin
86               ztt = tn
87               zs = sn
88            ENDIF ELSE BEGIN
89               ztt = tn[jk, *]
90               zs = sn[jk, *]
91            ENDELSE
92         END
93         3:BEGIN                ;xyz (jpt=1) ou xyt
94            if jpt EQ 1 then begin
95               ztt = tn[*, *, jk]
96               zs = sn[*, *,jk]
97            endif ELSE BEGIN
98               ztt = tn
99               zs = sn
100            ENDELSE
101         END
102         4:BEGIN                ;xyzt
103            ztt = tn[*, *, jk, *]
104            zs = sn[*, *,jk, *]
105         END
106      endcase
107      if n_elements(sigma_n) NE 0 then zh = 1000.*sigma_n ELSE zh = gdept[jk]
108; ...   square root salinity
109      zsr= sqrt(abs(zs))
110; ...   compute density pure water at atm pressure
111      zr1=((((6.536332e-9*ztt-1.120083e-6)*ztt+1.001685e-4)*ztt-9.095290e-3)*ztt+6.793952e-2)*ztt+999.842594
112; ...   seawater density atm pressure
113      zr2= (((5.3875e-9*ztt-8.2467e-7)*ztt+7.6438e-5)*ztt-4.0899e-3)*ztt+0.824493
114      zr3= (-1.6546e-6*ztt+1.0227e-4)*ztt-5.72466e-3
115      zr4= 4.8314e-4
116;
117; ...   potential density (reference to the surface)
118      case taille[0] of
119         0: zrhop    = (zr4*zs + zr3*zsr + zr2)*zs + zr1
120         1: zrhop[jk]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
121         2:BEGIN
122            if jpt EQ 1 then zrhop = (zr4*zs + zr3*zsr + zr2)*zs + zr1 $
123            ELSE zrhop[jk, *]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
124         END
125         3:BEGIN
126            if jpt EQ 1 then zrhop[*, *,jk]= (zr4*zs + zr3*zsr + zr2)*zs + zr1 $
127             ELSE zrhop = (zr4*zs + zr3*zsr + zr2)*zs + zr1
128         END
129         4: zrhop[*, *,jk, *]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
130      endcase
131
132      IF n_elements(insitu) EQ 1 THEN BEGIN
133; ...   add the compression terms
134         ze = (-3.508914e-8*ztt-1.248266e-8)*ztt-2.595994e-6
135         zbw= ( 1.296821e-6*ztt-5.782165e-9)*ztt+1.045941e-4
136         zb = zbw + ze * zs
137;
138         zd = -2.042967e-2
139         zc = (-7.267926e-5*ztt+2.598241e-3)*ztt+0.1571896
140         zaw = ((5.939910e-6*ztt+2.512549e-3)*ztt-0.1028859)*ztt -4.721788
141         za = ( zd*zsr + zc)*zs + zaw
142;
143         zb1= (-0.1909078*ztt+7.390729)*ztt-55.87545
144         za1= ((2.326469e-3*ztt+1.553190)*ztt-65.00517)*ztt+1044.077
145         zkw= (((-1.361629e-4*ztt-1.852732e-2)*ztt-30.41638)*ztt+2098.925)*ztt+190925.6
146         zk0= (zb1*zsr + za1)*zs + zkw
147;
148; ...   masked in situ density
149         case taille[0] of
150            0: zrhop = zrhop / (1.0-zh/(zk0-zh*(za-zh*zb)))
151            1: zrhop[jk] = zrhop[jk] / (1.0-zh/(zk0-zh*(za-zh*zb)))
152            2:BEGIN
153               if jpt EQ 1 then zrhop = zrhop / (1.0-zh/(zk0-zh*(za-zh*zb))) $
154               ELSE zrhop[jk, *] = zrhop[jk, *] / (1.0-zh/(zk0-zh*(za-zh*zb)))
155            END
156            3:BEGIN
157               if jpt EQ 1 then zrhop[*, *,jk] = zrhop[*, *,jk] / (1.0-zh/(zk0-zh*(za-zh*zb))) $
158               ELSE zrhop = zrhop / (1.0-zh/(zk0-zh*(za-zh*zb)))
159            END
160            4: zrhop[*, *,jk, *] = zrhop[*, *,jk, *] / (1.0-zh/(zk0-zh*(za-zh*zb)))
161         endcase
162
163      ENDIF
164   ENDFOR
165
166   terre = where(tn GE 1e6)
167   if terre[0] NE -1 then zrhop[terre] = valmask
168
169   if keyword_set(key_performance) THEN print, 'temps rhon', systime(1)-tempsun
170
171
172   return, zrhop
173END
Note: See TracBrowser for help on using the repository browser.