source: trunk/SRC/ToBeReviewed/CALCULS/hdyn.pro @ 285

Last change on this file since 285 was 238, 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: 6.0 KB
Line 
1;+
2;
3; @file_comments
4; Calculate the height by rapport to a reference state for a depth reference.
5; See keywords for different possibilities. By default, the state reference
6; is rho=1020 and the depth reference is gdepw[ka] with ka the first W level
7; directly above 1000 m.
8;
9; @categories
10; Calculation
11;
12; @param TABSN {in}{required}
13; array representing the salinity
14;
15; @param TABTN {in}{required}
16; array representing the temperature. Has the same size than SN.
17;
18; @keyword GILL
19; We activate this key if we want to calculate the dynamic height
20; like in the GILL page 215, which means by rapport to a reference state which
21; vary in depth and which is determined by a reference temperature tref at 0°C
22; and a reference salinity sref at 35 psu.
23;
24; @keyword LEVEL
25; It is the same reference level to take. This level is defined like
26; that gdepw[level] is the reference depth
27;
28; @keyword SREF
29; Give a value to this keyword to change the reference salinity used in the
30; calculation when GILL is activated.
31;
32; @keyword TREF
33; Give a value to this keyword to change the reference temperature used in the
34; calculation when GILL is activated.
35;
36; @keyword PROFREF
37; Give a depth to this keyword which will be considered as the reference depth
38; (in this case, LEVEL has not any effect). the calculation will be effectuated
39; until this depth effecting an interpolation between the last W level above
40; PROFREF and PROFREF.
41;
42; @keyword SURFACE_LEVEL {default=0}
43; It is the level where we wan to calculate the dynamic height.
44;
45; @returns
46; An array of the same size of sn and tn representing the dynamic height calculated
47; from a reference depth nd by rapport to a reference state.
48;
49; @uses
50; common.pro
51;
52; @restrictions
53; Points for which we can not calculate the dynamic height (whose the batymetry
54; is less deep than the reference depth) are put at the value !values.f_nan
55;
56; @restrictions
57; approximation: The pressure in decibars is equal to the depth in meters
58; (the pressure increase of 1 bar every 10 m)
59;
60; @history
61; Sebastien Masson (smasson\@lodyc.jussieu.fr)
62;
63; @version
64; $Id$
65;
66;-
67;
68FUNCTION hdyn, tabsn, tabtn, TREF = tref, SREF = sref, PROFREF = profref, LEVEL = level, GILL = gill, SURFACE_LEVEL = surface_level
69;
70  compile_opt idl2, strictarrsubs
71;
72   tempsun = systime(1)         ; for key_performance
73@common
74
75   if NOT keyword_set(surface_level) then surface_level = 0
76; useful if GILL is activated
77   if NOT keyword_set(tref) then tref = 0.
78   if NOT keyword_set(sref) then sref = 35.
79; If needed, we determinate the reference depth and the W level situated directly above.
80   if keyword_set(profref) then begin
81      rien = where(gdepw LE profref, level)
82      level = level-1
83      za = gdepw[level]
84   ENDIF ELSE BEGIN
85      if NOT keyword_set(level) then BEGIN
86         rien = where(gdepw LE 1000., level)
87         level = level-1
88      ENDIF
89      profref = gdepw[level]
90      za = profref
91   ENDELSE
92   tailles = size(tabsn)
93   taillet = size(tabtn)
94   if total(tailles[0:tailles[0]] NE taillet[0:taillet[0]]) NE 0 then $
95    return,  report('arrays sn and tn must have the same size')
96   if tailles[3] NE jpk then return, report('vertical dimension of sn and tn arrays must be equal to jpk')
97   nx = nxt
98   ny = nyt
99   case (size(tabsn))[0] OF
100      3:BEGIN
101         case 1 of
102            tailles[1] eq jpi and tailles[2] eq jpj: BEGIN
103               sn = tabsn[firstxt:lastxt, firstyt:lastyt, *]
104               tn = tabtn[firstxt:lastxt, firstyt:lastyt, *]
105            end
106            tailles[1] eq  nx and tailles[2] eq  ny:BEGIN
107               sn = tabsn
108               tn = tabtn
109            end
110            else:return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
111         ENDCASE
112         if keyword_set(gill) then $
113          rhonref = rhon(replicate(sref,nx, ny, jpk),replicate(tref,nx, ny, jpk), /insitu) $
114         ELSE rhonref = 1020.
115         vol=(rhonref-rhon(sn,tn, /insitu))/rhonref
116         e33d = replicate(1, nx*ny)#e3t
117         e33d = reform(e33d, nx, ny, jpk, /over)
118         terre = where(tmask[firstxt:lastxt, firstyt:lastyt, *] EQ 0)
119         if terre[0] NE -1 then vol[terre] = !values.f_nan
120         case level of
121            0:hdyn =100.*(profref-gdepw[0])*vol[*, *, 0]
122            1:hdyn =100.*(vol*e33d)[*, *, 0]+(profref-gdepw[1])*vol[*, *, 1]
123            ELSE:hdyn =100.*total( (vol*e33d)[*, *, surface_level: level-1], 3) $
124             +(profref-gdepw[level])*vol[*, *, level]
125         endcase
126      END
127      4:BEGIN
128         case 1 of
129            tailles[1] eq jpi and tailles[2] eq jpj AND tailles[4] EQ jpt: BEGIN
130               sn = tabsn[firstxt:lastxt, firstyt:lastyt, *, *]
131               tn = tabtn[firstxt:lastxt, firstyt:lastyt, *, *]
132            end
133            tailles[1] eq  nx and tailles[2] eq  ny AND tailles[4] EQ jpt:BEGIN
134               sn = tabsn
135               tn = tabtn
136            end
137            else:return, report('Probleme d''adequation entre les tailles du domaine et de la boite.')
138         endcase
139         if keyword_set(gill) then $
140          rhonref = rhon(replicate(sref,nx, ny, jpk, jpt),replicate(tref,nx, ny, jpk, jpt), /insitu) $
141         ELSE rhonref = 1020.
142         vol=(rhonref-rhon(sn,tn, /insitu))/rhonref
143         e33d = replicate(1, nx*ny)#e3t
144         e33d = e33d[*]#replicate(1, jpt)
145         e33d = reform(e33d, nx, ny, jpk, jpt, /over)
146         mask = tmask[firstxt:lastxt, firstyt:lastyt, *]
147         mask = mask[*]#replicate(1, jpt)
148         terre = where(mask EQ 0)
149         if terre[0] NE -1 then vol[terre] = !values.f_nan
150         case level of
151            0:hdyn =100.*(profref-gdepw[0])*vol[*, *, 0, *]
152            1:hdyn =100.*(vol*e33d)[*, *, 0, *]+(profref-gdepw[1])*vol[*, *, 1, *]
153            ELSE:hdyn =100.*total( (vol*e33d)[*, *, surface_level: level-1, *], 3) $
154             +(profref-gdepw[level])*vol[*, *, level, *]
155         endcase
156      END
157      ELSE: return,  report('not implemented')
158   ENDCASE
159   varunit = 'cm'
160   varname = 'Dynamic Height (href='+strtrim(round(profref), 1)+'m)'
161   IF keyword_set(key_performance) THEN print, 'temps hdyn', systime(1)-tempsun
162
163   return, hdyn
164end
Note: See TracBrowser for help on using the repository browser.