source: trunk/CALCULS/rhon.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

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