;+ ; ; @file_comments ; compute the 3D e3w from e3w and e3w_ps ; ; @categories ; diagnostics ; ; @keyword e1 {default=0}{type=scalar: 0 or 1} ; activate to compute e1t * e3w instead of e3w ; note that of both keywords e1 and e2 are activated we compute e1t * e2t * e3w instead of e3w ; ; @keyword e2 {default=0}{type=scalar: 0 or 1} ; activate to compute e2t * e3w instead of e3w ; note that of both keywords e1 and e2 are activated we compute e1t * e2t * e3w instead of e3w ; ; @returns ; e3w ; ; @uses ; cm_4mesh.pro ; ; @history ; Sebastien Masson, Jan 2011 ; ; @version ; $Id$ ; ;- function e3w_3d, e1 = e1, e2 = e2 ; compile_opt idl2, strictarrsubs ; @cm_4mesh ; CASE 1 OF keyword_set(e1) AND keyword_set(e2):arr2d = e1t[firstxt:lastxt, firstyt:lastyt] $ * e2t[firstxt:lastxt, firstyt:lastyt] keyword_set(e1):arr2d = e1t[firstxt:lastxt, firstyt:lastyt] keyword_set(e2):arr2d = e2t[firstxt:lastxt, firstyt:lastyt] ELSE:arr2d = replicate(1.d, nxt*nyt) ENDCASE e3w_3d = arr2d[*] # e3w[firstzw:lastzw] e3w_3d = reform(e3w_3d, nxt, nyt, nzw, /overwrite) ; IF keyword_set(key_partialstep) THEN BEGIN ; Change bottom values with e3t_ps ; level of the bottom of the ocean bottom = total(tmask[firstxt:lastxt, firstyt:lastyt, *], 3) sea = where(bottom NE 0) bottom2 = long(temporary(bottom)) - firstzw bottom = bottom2 - 1L ok = inter(sea, where(bottom GE 0 AND bottom LT nzw)) ok2 = inter(sea, where(bottom2 GE 0 AND bottom2 LT nzw)) ; apply e3w_ps to e3w_3D at the bottom of the ocean IF ok[0] NE -1 THEN BEGIN ; the bottom of the ocean in 3D index is: bottom = (lindgen(nxt*nyt))[ok ] + nxt*nyt*(temporary(bottom ))[ok ] e3w_3d[bottom ] = arr2d[ok ] * (e3w_ps[firstxt:lastxt, firstyt:lastyt])[ok ] ENDIF IF ok2[0] NE -1 THEN BEGIN bottom2 = (lindgen(nxt*nyt))[ok2] + nxt*nyt*(temporary(bottom2))[ok2] e3w_3d[bottom2] = arr2d[ok2] * (e3t_ps[firstxt:lastxt, firstyt:lastyt])[ok2] ; use e3t_ps and not e3w_ps ENDIF ENDIF ; return, e3w_3d END