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

Last change on this file since 327 was 327, checked in by pinsard, 17 years ago

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

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