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

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

improvements/corrections of some *.pro headers

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