source: trunk/SRC/Computation/e3t_3d.pro @ 495

Last change on this file since 495 was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

File size: 2.2 KB
Line 
1;+
2;
3; @file_comments
4; compute the 3D e3t from e3t and e3t_ps
5;
6; @categories
7; diagnostics
8;
9; @keyword e1 {default=0}{type=scalar: 0 or 1}
10; activate to compute e1t * e3t instead of e3t
11; note that of both keywords e1 and e2 are activated we compute e1t * e2t * e3t instead of e3t
12;
13; @keyword e2 {default=0}{type=scalar: 0 or 1}
14; activate to compute e2t * e3t instead of e3t
15; note that of both keywords e1 and e2 are activated we compute e1t * e2t * e3t instead of e3t
16;
17; @returns
18; e3t
19;
20; @uses
21; cm_4mesh.pro
22;
23; @history
24; Sebastien Masson, Jan 2011
25;
26; @version
27; $Id$
28;
29;-
30function e3t_3d, e1 = e1, e2 = e2, fstx = fstx, lstx = lstx, fsty = fsty, lsty = lsty
31;
32  compile_opt idl2, strictarrsubs
33;
34@cm_4mesh
35;
36  IF n_elements(fstx) EQ 0 THEN fstx = firstxt
37  IF n_elements(lstx) EQ 0 THEN lstx = lastxt
38  IF n_elements(fsty) EQ 0 THEN fsty = firstyt
39  IF n_elements(lsty) EQ 0 THEN lsty = lastyt
40  nx = lstx - fstx + 1
41  ny = lsty - fsty + 1
42;
43  CASE 1 OF
44    keyword_set(e1) AND keyword_set(e2):arr2d = e1t[fstx:lstx, fsty:lsty] * e2t[fstx:lstx, fsty:lsty]
45    keyword_set(e1)                    :arr2d = e1t[fstx:lstx, fsty:lsty]
46                        keyword_set(e2):arr2d =                             e2t[fstx:lstx, fsty:lsty]
47    ELSE:arr2d = replicate(1.d, nx*ny)
48  ENDCASE
49  e3t3d = arr2d[*] # e3t[firstzt:lastzt]
50  e3t3d = reform(e3t3d, nx, ny, nzt, /overwrite)
51;
52  IF keyword_set(key_partialstep) THEN BEGIN
53; Change bottom values with e3t_ps
54; level of the bottom of the ocean
55    bottom = total(tmask[fstx:lstx, fsty:lsty, *], 3)
56    sea = where(bottom NE 0)
57    bottom2 = long(temporary(bottom)) - firstzt
58    bottom  = bottom2 - 1L
59    ok  = inter(sea, where(bottom  GE 0 AND bottom  LT nzt))
60    ok2 = inter(sea, where(bottom2 GE 0 AND bottom2 LT nzt))
61; apply e3t_ps to e3t_3D at the bottom of the ocean
62    IF ok[0]  NE -1 THEN BEGIN
63; the bottom of the ocean in 3D index is:
64      bottom  = (lindgen(nx*ny))[ok ] + nx*ny*(temporary(bottom ))[ok ]
65      e3t3d[temporary(bottom )] = arr2d[ok ] * (e3t_ps[fstx:lstx, fsty:lsty])[ok ]
66    ENDIF
67    IF ok2[0] NE -1 THEN BEGIN
68      bottom2 = (lindgen(nx*ny))[ok2] + nx*ny*(temporary(bottom2))[ok2]
69      e3t3d[temporary(bottom2)] = arr2d[ok2] * (e3t_ps[fstx:lstx, fsty:lsty])[ok2]
70    ENDIF
71;
72  ENDIF
73;
74  return, e3t3d
75END
76
Note: See TracBrowser for help on using the repository browser.