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

Last change on this file since 236 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
RevLine 
[2]1;+
[163]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;
[231]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;;
[142]34; @todo seb
35;
[2]36;-
[231]37;
[97]38FUNCTION rhon, sn, tn, INSITU = insitu, SIGMA_N = sigma_n
[114]39;
40  compile_opt idl2, strictarrsubs
41;
[97]42@common
43   tempsun = systime(1)         ; pour key_performance
[2]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
[231]55      END
[2]56      1:BEGIN                   ;z
57         zrhop=dblarr(taille[1])
58         jkmax = taille[1]
[231]59      END
[2]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]
[231]63      END
[2]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
[231]67      END
[2]68      4:BEGIN                   ;xyzt
69         zrhop=dblarr(taille[1],taille[2],taille[3],taille[4] )
70         jkmax = taille[3]
[231]71      END
[2]72   endcase
73
74
[231]75
[2]76   FOR jk = 0, jkmax-1 DO BEGIN
77
78      case taille[0] of
79         0:BEGIN                ;z
80            ztt = tn
81            zs = sn
[231]82         END
[2]83         1:BEGIN                ;z
84            ztt = tn[jk]
[231]85            zs = sn[jk]
86         END
[2]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, *]
[231]93               zs = sn[jk, *]
[2]94            ENDELSE
[231]95         END
[2]96         3:BEGIN                ;xyz (jpt=1) ou xyt
97            if jpt EQ 1 then begin
98               ztt = tn[*, *, jk]
[231]99               zs = sn[*, *,jk]
[2]100            endif ELSE BEGIN
101               ztt = tn
102               zs = sn
103            ENDELSE
[231]104         END
[2]105         4:BEGIN                ;xyzt
106            ztt = tn[*, *, jk, *]
[231]107            zs = sn[*, *,jk, *]
108         END
[2]109      endcase
[114]110      if n_elements(sigma_n) NE 0 then zh = 1000.*sigma_n ELSE zh = gdept[jk]
[2]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
[114]123         1: zrhop[jk]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
[231]124         2:BEGIN
[2]125            if jpt EQ 1 then zrhop = (zr4*zs + zr3*zsr + zr2)*zs + zr1 $
[114]126            ELSE zrhop[jk, *]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
[2]127         END
[231]128         3:BEGIN
[114]129            if jpt EQ 1 then zrhop[*, *,jk]= (zr4*zs + zr3*zsr + zr2)*zs + zr1 $
[2]130             ELSE zrhop = (zr4*zs + zr3*zsr + zr2)*zs + zr1
131         END
[114]132         4: zrhop[*, *,jk, *]= (zr4*zs + zr3*zsr + zr2)*zs + zr1
[2]133      endcase
134
[231]135      IF n_elements(insitu) EQ 1 THEN BEGIN
[2]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)))
[114]154            1: zrhop[jk] = zrhop[jk] / (1.0-zh/(zk0-zh*(za-zh*zb)))
[231]155            2:BEGIN
[2]156               if jpt EQ 1 then zrhop = zrhop / (1.0-zh/(zk0-zh*(za-zh*zb))) $
[114]157               ELSE zrhop[jk, *] = zrhop[jk, *] / (1.0-zh/(zk0-zh*(za-zh*zb)))
[2]158            END
[231]159            3:BEGIN
[114]160               if jpt EQ 1 then zrhop[*, *,jk] = zrhop[*, *,jk] / (1.0-zh/(zk0-zh*(za-zh*zb))) $
[2]161               ELSE zrhop = zrhop / (1.0-zh/(zk0-zh*(za-zh*zb)))
162            END
[114]163            4: zrhop[*, *,jk, *] = zrhop[*, *,jk, *] / (1.0-zh/(zk0-zh*(za-zh*zb)))
[2]164         endcase
[231]165
166      ENDIF
167   ENDFOR
168
[2]169   terre = where(tn GE 1e6)
170   if terre[0] NE -1 then zrhop[terre] = valmask
171
[231]172   if keyword_set(key_performance) THEN print, 'temps rhon', systime(1)-tempsun
[2]173
[231]174
[2]175   return, zrhop
[231]176END
Note: See TracBrowser for help on using the repository browser.