Index: trunk/SRC/ToBeReviewed/CALCULS/grossemoyenne.pro
===================================================================
--- trunk/SRC/ToBeReviewed/CALCULS/grossemoyenne.pro	(revision 442)
+++ trunk/SRC/ToBeReviewed/CALCULS/grossemoyenne.pro	(revision 445)
@@ -399,10 +399,10 @@
     IF keyword_set(key_partialstep) THEN BEGIN
 ; the top of the ocean floor is
-      IF vargrid EQ 'T' OR vargrid EQ 'W' THEN bottom = total(mask, 3) $
-      ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3)
+      bottom = total(tmask[firstx:lastx, firsty:lasty, *], 3)
 ; we suppress columns with only ocean or land
-      good = where(bottom NE 0 AND bottom NE nz)
+      bottom = long(temporary(bottom)) - firstz - 1L
+      good = where(bottom GE 0 AND bottom LT nz)
 ; the bottom of the ocean in 3D index is:
-      bottom = lindgen(nx*ny)+(temporary(bottom)-1L)*nx*ny
+      bottom = lindgen(nx*ny)+nx*ny*temporary(bottom)
       IF good[0] NE -1 THEN bottom = bottom[good] $
       ELSE bottom = -1
@@ -470,12 +470,6 @@
         endif
       end
-      (dirx eq 0) and (diry eq 0) and (dirz eq 1) : begin
-        e33 = replicate(1, 1.*nx*ny)#e3
-        e33 = reform(e33, nx, ny, nz, /over)
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e33[bottom] = (e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e33[bottom] = (e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
+      (dirx eq 0) and (diry eq 0) and (dirz eq 1) : BEGIN
+        e33 = e3_3d()
         echelle = (temporary(e33)*temporary(mask))[*]#replicate(1, jpt)
         echelle = reform(echelle, nx, ny, nz, jpt, /over)
@@ -524,10 +518,5 @@
       end
       (dirx eq 1) and (diry eq 0) and (dirz eq 1) : begin
-        e133 = e1[*]#e3
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e133[bottom] = (e1*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e133[bottom] = (e1*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
+        e133 = e3_3d(/e1)
         echelle = (temporary(e133[*])*temporary(mask[*]))#replicate(1, jpt)
         echelle = reform(echelle, nx, ny, nz, jpt, /over)
@@ -546,10 +535,5 @@
       end
       (dirx eq 0) and (diry eq 1) and (dirz eq 1) : begin
-        e233 = e2[*]#e3
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e233[bottom] = (e2*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e233[bottom] = (e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
+        e233 = e3_3d(/e2)
         echelle = (temporary(e233[*])*temporary(mask[*]))#replicate(1, jpt)
         echelle = reform(echelle, nx, ny, nz, jpt, /over)
@@ -568,10 +552,5 @@
       end
       (dirx eq 1) and (diry eq 1) and (dirz eq 1) : begin
-        e1233 = (e1[*]*e2[*])#e3
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e1233[bottom] = (e1*e2*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e1233[bottom] = (e1*e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
+        e1233 = e3_3d(/e1, /e2)
         echelle = (temporary(e1233[*])*temporary(mask[*]))#replicate(1, jpt)
         echelle = reform(echelle, nx, ny, nz, jpt, /over)
Index: trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro
===================================================================
--- trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro	(revision 442)
+++ trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro	(revision 445)
@@ -376,10 +376,10 @@
     IF keyword_set(key_partialstep) THEN BEGIN
 ; the top of the ocean floor is
-      IF vargrid EQ 'T' OR vargrid EQ 'W' THEN bottom = total(mask, 3) $
-      ELSE bottom = total(tmask[firstx:lastx, firsty:lasty, firstz:lastz], 3)
+      bottom = total(tmask[firstx:lastx, firsty:lasty, *], 3)
 ; we suppress columns with only ocean or land
-      good = where(bottom NE 0 AND bottom NE nz)
+      bottom = long(temporary(bottom)) - firstz - 1L
+      good = where(bottom GE 0 AND bottom LT nz)
 ; the bottom of the ocean in 3D index is:
-      bottom = lindgen(nx*ny)+(temporary(bottom)-1L)*nx*ny
+      bottom = lindgen(nx*ny)+nx*ny*temporary(bottom)
       IF good[0] NE -1 THEN bottom = bottom[good] $
       ELSE bottom = -1
@@ -447,12 +447,6 @@
       end
       (dirx eq 0) and (diry eq 0) and (dirz eq 1) : begin
-        e33 = replicate(1, 1.*nx*ny)#e3
-        e33 = reform(e33, nx, ny, nz, /over)
+        e33 = e3_3d()
         IF keyword_set(sshh) THEN e33[*, *, 0] = e33[*, *, 0] + sshh
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e33[bottom] = (e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e33[bottom] = (e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
         if keyword_set(integration) then divi = 1 else begin
           divi = e33*mask
@@ -500,12 +494,6 @@
       end
       (dirx eq 1) and (diry eq 0) and (dirz eq 1) : begin
-        e133 = e1[*]#e3
-        e133 = reform(e133, nx, ny, nz, /over)
+        e133 = e3_3d(/e1)
         IF keyword_set(sshh) THEN e133[*, *, 0] = e133[*, *, 0] + sshh*e1
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e133[bottom] = (e1*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e133[bottom] = (e1*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
         if keyword_set(integration) then divi = 1 else BEGIN
           divi = e133*mask
@@ -525,12 +513,6 @@
       end
       (dirx eq 0) and (diry eq 1) and (dirz eq 1) : begin
-        e233 = e2[*]#e3
-        e233 = reform(e233, nx, ny, nz, /over)
+        e233 = e3_3d(/e2)
         IF keyword_set(sshh) THEN e233[*, *, 0] = e233[*, *, 0] + sshh*e2
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e233[bottom] = (e2*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e233[bottom] = (e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
         if keyword_set(integration) then divi = 1 else BEGIN
           divi = e233*mask
@@ -550,12 +532,6 @@
       end
       (dirx eq 1) and (diry eq 1) and (dirz eq 1) : begin
-        e1233 = (e1*e2)[*]#e3
-        e1233 = reform(e1233, nx, ny, nz, /over)
+        e1233 = e3_3d(/e1, /e2)
         IF keyword_set(sshh) THEN e1233[*, *, 0] = e1233[*, *, 0] + sshh*e1*e2
-        IF keyword_set(key_partialstep) AND bottom[0] NE -1 THEN BEGIN
-          IF keyword_set(wdepth) THEN $
-            e1233[bottom] = (e1*e2*e3w_ps[firstx:lastx, firsty:lasty])[temporary(good)] $
-          ELSE e1233[bottom] = (e1*e2*e3t_ps[firstx:lastx, firsty:lasty])[temporary(good)]
-        ENDIF
         if keyword_set(integration) then divi = 1 else BEGIN
           if msknan[0] NE -1 then divi = total(e1233*mask*msknan) $
