Index: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 3284)
+++ branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 3285)
@@ -66,10 +66,12 @@
       !!----------------------------------------------------------------------
 
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwd, zws, zavmu, zavmv
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwd, zws
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  zavmu, zavmv
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('dyn_zdf_imp')
       !
-      CALL wrk_alloc( jpi,jpj,jpk, zwi, zwd, zws, zavmu, zavmv ) 
+      CALL wrk_alloc( jpi,jpj,jpk, zwi, zwd, zws ) 
+      CALL wrk_alloc( jpi,jpj, zavmu, zavmv ) 
       !
       IF( kt == nit000 ) THEN
@@ -89,12 +91,4 @@
       ! column vector of the tri-diagonal matrix equation
       !
-     DO jk = 1, jpk
-        DO jj = 1, jpj
-           DO ji =1, jpi
-              zavmu(ji,jj,jk) = avmu(ji,jj,jk)
-              zavmv(ji,jj,jk) = avmv(ji,jj,jk)
-           END DO
-        END DO
-      END DO
 
       IF( ln_bfrimp ) THEN
@@ -108,6 +102,8 @@
             ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points 
             ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
-            zavmu(ji,jj,ikbu+1) = -bfrua(ji,jj) * fse3uw(ji,jj,ikbu+1) 
-            zavmv(ji,jj,ikbv+1) = -bfrva(ji,jj) * fse3vw(ji,jj,ikbv+1)
+            zavmu(ji,jj) = avmu(ji,jj,ikbu+1)
+            zavmv(ji,jj) = avmv(ji,jj,ikbv+1)
+            avmu(ji,jj,ikbu+1) = -bfrua(ji,jj) * fse3uw(ji,jj,ikbu+1) 
+            avmv(ji,jj,ikbv+1) = -bfrva(ji,jj) * fse3vw(ji,jj,ikbv+1)
          END DO
       END DO
@@ -124,7 +120,7 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zcoef = - p2dt / fse3u(ji,jj,jk)
-               zzwi          = zcoef * zavmu (ji,jj,jk  ) / fse3uw(ji,jj,jk  )
+               zzwi          = zcoef * avmu (ji,jj,jk  ) / fse3uw(ji,jj,jk  )
                zwi(ji,jj,jk) = zzwi  * umask(ji,jj,jk)
-               zzws          = zcoef * zavmu (ji,jj,jk+1) / fse3uw(ji,jj,jk+1)
+               zzws          = zcoef * avmu (ji,jj,jk+1) / fse3uw(ji,jj,jk+1)
                zws(ji,jj,jk) = zzws  * umask(ji,jj,jk+1)
                zwd(ji,jj,jk) = 1._wp - zwi(ji,jj,jk) - zzws
@@ -210,7 +206,7 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zcoef = -p2dt / fse3v(ji,jj,jk)
-               zzwi          = zcoef * zavmv (ji,jj,jk  ) / fse3vw(ji,jj,jk  )
+               zzwi          = zcoef * avmv (ji,jj,jk  ) / fse3vw(ji,jj,jk  )
                zwi(ji,jj,jk) =  zzwi * vmask(ji,jj,jk)
-               zzws          = zcoef * zavmv (ji,jj,jk+1) / fse3vw(ji,jj,jk+1)
+               zzws          = zcoef * avmv (ji,jj,jk+1) / fse3vw(ji,jj,jk+1)
                zws(ji,jj,jk) =  zzws * vmask(ji,jj,jk+1)
                zwd(ji,jj,jk) = 1._wp - zwi(ji,jj,jk) - zzws
@@ -284,6 +280,24 @@
          END DO
       END DO
-      !
-      CALL wrk_dealloc( jpi,jpj,jpk, zwi, zwd, zws, zavmu, zavmv ) 
+
+      !! restore bottom layer avmu(v) 
+      IF( ln_bfrimp ) THEN
+# if defined key_vectopt_loop
+      DO jj = 1, 1
+         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
+# else
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+# endif
+            ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points 
+            ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
+            avmu(ji,jj,ikbu+1) = zavmu(ji,jj)
+            avmv(ji,jj,ikbv+1) = zavmv(ji,jj)
+         END DO
+      END DO
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk, zwi, zwd, zws) 
+      CALL wrk_dealloc( jpi,jpj, zavmu, zavmv) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_zdf_imp')
