Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde_crs.F90	(revision 5601)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde_crs.F90	(revision 6772)
@@ -96,6 +96,4 @@
       INTEGER  ::   iku, ikv, ikum1, ikvm1   ! partial step level (ocean bottom level) at u- and v-points
       REAL(wp) ::  ze3wu, ze3wv, zmaxu, zmaxv  ! temporary scalars
-  !cc    REAL(wp), POINTER, DIMENSION(:,:  ) ::  zri, zrj, zhi, zhj
-  !cc    REAL(wp), POINTER, DIMENSION(:,:,:) ::  zti, zte    ! interpolated value of tracer
       REAL(wp), ALLOCATABLE, DIMENSION(:,:  ) ::  zri, zrj, zhi, zhj
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::  zti, zte    ! interpolated value of tracer
@@ -105,6 +103,4 @@
       IF( nn_timing == 1 )  CALL timing_start( 'zps_hde_crs')
       !
-!!      CALL wrk_alloc( jpi, jpj,       zri, zrj, zhi, zhj ) 
-!!      CALL wrk_alloc( jpi, jpj, kjpt, zti, zte           ) 
       ALLOCATE( zri(jpi_crs,jpj_crs) , zrj(jpi_crs,jpj_crs), zte(jpi_crs ,jpj_crs ,kjpt), &
          &      zhi(jpi_crs,jpj_crs) , zhj(jpi_crs,jpj_crs), zti(jpi_crs ,jpj_crs ,kjpt))
@@ -112,22 +108,19 @@
       DO jn = 1, kjpt      !==   Interpolation of tracers at the last ocean level   ==!
          !
-# if defined key_vectopt_loop
-         jj = 1
-         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
-# else
          DO jj = 1, jpjm1
             DO ji = 1, jpim1
-# endif
+
                iku = mbku_crs(ji,jj)   ;   ikum1 = MAX( iku - 1 , 1 )    ! last and before last ocean level at u- & v-points
                ikv = mbkv_crs(ji,jj)   ;   ikvm1 = MAX( ikv - 1 , 1 )    ! if level first is a p-step, ik.m1=1
-          !     ze3wu = e3w_crs(ji+1,jj  ,iku) - e3w_crs(ji,jj,iku)
-          !     ze3wv = e3w_crs(ji  ,jj+1,ikv) - e3w_crs(ji,jj,ikv)
-               ze3wu = e3w_max_crs(ji+1,jj  ,iku) - e3w_max_crs(ji,jj,iku)
-               ze3wv = e3w_max_crs(ji  ,jj+1,ikv) - e3w_max_crs(ji,jj,ikv)
+               ze3wu = e3w_max_0_crs(ji+1,jj  ,iku) - e3w_max_0_crs(ji,jj,iku)
+               ze3wv = e3w_max_0_crs(ji  ,jj+1,ikv) - e3w_max_0_crs(ji,jj,ikv)
                !
                ! i- direction
                IF( ze3wu >= 0._wp ) THEN      ! case 1
-                  zmaxu =  ze3wu / e3w_max_crs(ji+1,jj,iku)  
-                 !    zmaxu =  ze3wu / e3w_crs(ji+1,jj,iku)
+#if defined key_vvl
+                  zmaxu =  ze3wu / e3w_max_n_crs(ji+1,jj,iku)  
+#else
+                  zmaxu =  ze3wu / e3w_max_0_crs(ji+1,jj,iku)  
+#endif
                   ! interpolated values of tracers
                   zti(ji,jj,jn) = pta(ji+1,jj,iku,jn) + zmaxu * ( pta(ji+1,jj,ikum1,jn) - pta(ji+1,jj,iku,jn) )
@@ -135,6 +128,9 @@
                   pgtu(ji,jj,jn) = umask_crs(ji,jj,1) * ( zti(ji,jj,jn) - pta(ji,jj,iku,jn) )
                ELSE                           ! case 2
-                  zmaxu = -ze3wu / e3w_max_crs(ji,jj,iku)
-                 !    zmaxu = -ze3wu / e3w_crs(ji,jj,iku)
+#if defined key_vvl
+                  zmaxu = -ze3wu / e3w_max_n_crs(ji,jj,iku)
+#else
+                  zmaxu = -ze3wu / e3w_max_0_crs(ji,jj,iku)
+#endif
                   ! interpolated values of tracers
                   zti(ji,jj,jn) = pta(ji,jj,iku,jn) + zmaxu * ( pta(ji,jj,ikum1,jn) - pta(ji,jj,iku,jn) )
@@ -145,6 +141,9 @@
                ! j- direction
                IF( ze3wv >= 0._wp ) THEN      ! case 1
-                  zmaxv =  ze3wv / e3w_max_crs(ji,jj+1,ikv)
-               !      zmaxv =  ze3wv / e3w_crs(ji,jj+1,ikv)
+#if defined key_vvl
+                  zmaxv =  ze3wv / e3w_max_n_crs(ji,jj+1,ikv)
+#else
+                  zmaxv =  ze3wv / e3w_max_0_crs(ji,jj+1,ikv)
+#endif
                   ! interpolated values of tracers
                   zte(ji,jj,jn) = pta(ji,jj+1,ikv,jn) + zmaxv * ( pta(ji,jj+1,ikvm1,jn) - pta(ji,jj+1,ikv,jn) )
@@ -152,6 +151,9 @@
                   pgtv(ji,jj,jn) = vmask_crs(ji,jj,1) * ( zte(ji,jj,jn) - pta(ji,jj,ikv,jn) )
                ELSE                           ! case 2
-                  zmaxv =  -ze3wv / e3w_max_crs(ji,jj,ikv)
-                !     zmaxv = -ze3wv / e3w_crs(ji,jj,ikv)
+#if defined key_vvl
+                  zmaxv =  -ze3wv / e3w_max_n_crs(ji,jj,ikv)
+#else
+                  zmaxv =  -ze3wv / e3w_max_0_crs(ji,jj,ikv)
+#endif
                   ! interpolated values of tracers
                   zte(ji,jj,jn) = pta(ji,jj,ikv,jn) + zmaxv * ( pta(ji,jj,ikvm1,jn) - pta(ji,jj,ikv,jn) )
@@ -160,53 +162,38 @@
                ENDIF
 
-# if ! defined key_vectopt_loop
             END DO
-# endif
          END DO
          CALL crs_lbc_lnk( pgtu(:,:,jn), 'U', -1. )   ;   CALL crs_lbc_lnk( pgtv(:,:,jn), 'V', -1. )   ! Lateral boundary cond.
          !
       END DO
-!WRITE(numout,*) ' test24 ', e3w_max_crs
+
       ! horizontal derivative of density anomalies (rd)
       IF( PRESENT( prd ) ) THEN         ! depth of the partial step level
-# if defined key_vectopt_loop
-         jj = 1
-         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
-# else
          DO jj = 1, jpjm1
             DO ji = 1, jpim1
-# endif
+
                iku = mbku_crs(ji,jj)
                ikv = mbkv_crs(ji,jj)
-   !cc             ze3wu  = e3w_max_crs(ji+1,jj  ,iku) - e3w_max_crs(ji,jj,iku)   !gradiant horizontal pas de max
-               ze3wu  = e3w_crs(ji+1,jj  ,iku) - e3w_crs(ji,jj,iku)
-       !cc        ze3wv  = e3w_max_crs(ji  ,jj+1,ikv) - e3w_max_crs(ji,jj,ikv)
-               ze3wv  = e3w_crs(ji  ,jj+1,ikv) - e3w_crs(ji,jj,ikv)
-               IF( ze3wu >= 0._wp ) THEN   ;   zhi(ji,jj) = gdept_crs(ji  ,jj,iku)     ! i-direction: case 1
-               ELSE                        ;   zhi(ji,jj) = gdept_crs(ji+1,jj,iku)     ! -     -      case 2
-               ENDIF
-               IF( ze3wv >= 0._wp ) THEN   ;   zhj(ji,jj) = gdept_crs(ji,jj  ,ikv)     ! j-direction: case 1
-               ELSE                        ;   zhj(ji,jj) = gdept_crs(ji,jj+1,ikv)     ! -     -      case 2
-               ENDIF
-# if ! defined key_vectopt_loop
+               ze3wu  = e3w_0_crs(ji+1,jj  ,iku) - e3w_0_crs(ji,jj,iku)
+               ze3wv  = e3w_0_crs(ji  ,jj+1,ikv) - e3w_0_crs(ji,jj,ikv)
+               IF( ze3wu >= 0._wp ) THEN   ;   zhi(ji,jj) = fsdept_crs(ji  ,jj,iku)     ! i-direction: case 1
+               ELSE                        ;   zhi(ji,jj) = fsdept_crs(ji+1,jj,iku)     ! -     -      case 2
+               ENDIF
+               IF( ze3wv >= 0._wp ) THEN   ;   zhj(ji,jj) = fsdept_crs(ji,jj  ,ikv)     ! j-direction: case 1
+               ELSE                        ;   zhj(ji,jj) = fsdept_crs(ji,jj+1,ikv)     ! -     -      case 2
+               ENDIF
+
             END DO
-# endif
          END DO
          CALL eos_crs( zti, zhi, zri )  
          CALL eos_crs( zte, zhj, zrj )
+
          ! Gradient of density at the last level 
-# if defined key_vectopt_loop
-         jj = 1
-         DO ji = 1, jpij-jpi   ! vector opt. (forced unrolled)
-# else
          DO jj = 1, jpjm1
             DO ji = 1, jpim1
-# endif
                iku = mbku_crs(ji,jj)
                ikv = mbkv_crs(ji,jj)
-      !         ze3wu  = e3w_max_crs(ji+1,jj  ,iku) - e3w_max_crs(ji,jj,iku)         gradient horizontal
-                ze3wu  = e3w_crs(ji+1,jj  ,iku) - e3w_crs(ji,jj,iku)
-      !         ze3wv  = e3w_max_crs(ji  ,jj+1,ikv) - e3w_max_crs(ji,jj,ikv)         gradient horizontal
-                ze3wv  = e3w_crs(ji  ,jj+1,ikv) - e3w_crs(ji,jj,ikv)
+                ze3wu  = e3w_0_crs(ji+1,jj  ,iku) - e3w_0_crs(ji,jj,iku)
+                ze3wv  = e3w_0_crs(ji  ,jj+1,ikv) - e3w_0_crs(ji,jj,ikv)
                IF( ze3wu >= 0._wp ) THEN   ;   pgru(ji,jj) = umask_crs(ji,jj,1) * ( zri(ji  ,jj) - prd(ji,jj,iku) )   ! i: 1
                ELSE                        ;   pgru(ji,jj) = umask_crs(ji,jj,1) * ( prd(ji+1,jj,iku) - zri(ji,jj) )   ! i: 2
@@ -215,9 +202,7 @@
                ELSE                        ;   pgrv(ji,jj) = vmask_crs(ji,jj,1) * ( prd(ji,jj+1,ikv) - zrj(ji,jj) )   ! j: 2
                ENDIF
-# if ! defined key_vectopt_loop
+
             END DO
-# endif
          END DO
-
 
          CALL crs_lbc_lnk( pgru , 'U', -1. )   ;   CALL crs_lbc_lnk( pgrv , 'V', -1. )   ! Lateral boundary conditions
@@ -225,6 +210,4 @@
       END IF
       !
-      !!ccCALL wrk_dealloc( jpi, jpj,       zri, zrj, zhi, zhj ) 
-      !!ccCALL wrk_dealloc( jpi, jpj, kjpt, zti, zte           ) 
       DEALLOCATE( zri , zrj, zte, zhi, zhj, zti)
       !
