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

Last change on this file since 142 was 142, checked in by navarro, 18 years ago

english and nicer header (2a)

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