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

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

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