Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crs.F90	(revision 5601)
@@ -147,5 +147,5 @@
 
       ! Physical and dynamical ocean fields for output or passing to TOP, time-mean fields
-      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE      :: tsb_crs,tsn_crs
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE      :: tsb_crs,tsn_crs,rab_crs_n
       REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: un_crs, vn_crs, wn_crs, rke_crs
       REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: ub_crs, vb_crs
@@ -163,4 +163,18 @@
       REAL(wp), PUBLIC, DIMENSION(:,:)  , ALLOCATABLE :: rnf_crs
 
+      REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   uslp_crs, wslpi_crs          !: i_slope at U- and W-points
+      REAL(wp), PUBLIC, DIMENSION(:,:,:) , ALLOCATABLE ::   vslp_crs, wslpj_crs          !: j-slope at V- and W-points
+
+      ! Horizontal diffusion
+#if defined key_traldf_c3d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: ** 3D coefficients ** at T-,U-,V-,W-points
+#elif defined key_traldf_c2d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: ** 2D coefficients ** at T-,U-,V-,W-points
+#elif defined key_traldf_c1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)     ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: ** 1D coefficients ** at T-,U-,V-,W-points
+#else
+   REAL(wp), PUBLIC                                      ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: ** 0D coefficients ** at T-,U-,V-,W-points
+#endif
+
       ! Vertical diffusion
       REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)  ::  avt_crs           !: vert. diffusivity coef. [m2/s] at w-point for temp  
@@ -184,5 +198,5 @@
       !!-------------------------------------------------------------------
       !! Local variables
-      INTEGER, DIMENSION(14) :: ierr
+      INTEGER, DIMENSION(15) :: ierr
 
       ierr(:) = 0
@@ -246,6 +260,6 @@
          &      hdivb_crs(jpi_crs,jpj_crs,jpk) , hdivn_crs(jpi_crs,jpj_crs,jpk) , &
          &      rke_crs(jpi_crs,jpj_crs,jpk), rhop_crs(jpi_crs,jpj_crs,jpk)  , &
-         &      rb2_crs(jpi_crs,jpj_crs,jpk) ,rhd_crs(jpi_crs,jpj_crs,jpk)   , &
-         &      gtsu_crs(jpi_crs,jpj_crs,jpk) ,gtsv_crs(jpi_crs,jpj_crs,jpk) , &
+         &      rb2_crs(jpi_crs,jpj_crs,jpk) ,rhd_crs(jpi_crs,jpj_crs,jpk)   , rab_crs_n(jpi_crs,jpj_crs,jpk,jpts) , &
+         &      gtsu_crs(jpi_crs,jpj_crs,jpts) ,gtsv_crs(jpi_crs,jpj_crs,jpts) , &
                 gru_crs(jpi_crs,jpj_crs) ,grv_crs(jpi_crs,jpj_crs) , STAT=ierr(11))
 
@@ -256,12 +270,20 @@
          &     fr_i_crs(jpi_crs,jpj_crs), sfx_crs(jpi_crs ,jpj_crs), fmmflx_crs(jpi_crs ,jpj_crs),  STAT=ierr(12)  )
 
+#if defined key_traldf_c3d
+      ALLOCATE( ahtt_crs(jpi_crs,jpj_crs,jpk) , ahtu_crs(jpi_crs,jpj_crs,jpk) , ahtv_crs(jpi_crs,jpj_crs,jpk) , ahtw_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(13) )
+#elif defined key_traldf_c2d
+      ALLOCATE( ahtt_crs(jpi_crs,jpj_crs    ) , ahtu_crs(jpi_crs,jpj_crs    ) , ahtv_crs(jpi_crs,jpj_crs    ) , ahtw_crs(jpi_crs,jpj_crs    ) , STAT=ierr(13) )
+#elif defined key_traldf_c1d
+      ALLOCATE( ahtt_crs(        jpk) , ahtu_crs(        jpk) , ahtv_crs(        jpk) , ahtw_crs(        jpk) , STAT=ierr(13) )
+#endif
+
      ALLOCATE( tsn_crs(jpi_crs,jpj_crs,jpk,jpts), tsb_crs(jpi_crs,jpj_crs,jpk,jpts), avt_crs(jpi_crs,jpj_crs,jpk),    &
 # if defined key_zdfddm
          &      avs_crs(jpi_crs,jpj_crs,jpk),    &
 # endif
-         &      STAT=ierr(13) )
+         &      STAT=ierr(14) )
 
       ALLOCATE( nmln_crs(jpi_crs,jpj_crs) , hmld_crs(jpi_crs,jpj_crs) , &
-         &      hmlp_crs(jpi_crs,jpj_crs) , hmlpt_crs(jpi_crs,jpj_crs) , STAT=ierr(14) )
+         &      hmlp_crs(jpi_crs,jpj_crs) , hmlpt_crs(jpi_crs,jpj_crs) , STAT=ierr(15) )
 
       crs_dom_alloc1 = MAXVAL(ierr)
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdom.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdom.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdom.F90	(revision 5601)
@@ -1633,4 +1633,6 @@
                       ENDIF
                    ELSE
+                      DO ji = nistr, niend, nn_factx
+                      ii   = ( ji - mis_crs(2) ) * rfactx_r + 2     
                       je_2 = mjs_crs(2) 
                       zflcrs =  &
@@ -1646,4 +1648,5 @@
                       !
                       p_fld_crs(ii,2) = zflcrs
+                      ENDDO
                    ENDIF
 
@@ -2070,4 +2073,7 @@
                ENDDO
             ENDDO
+
+
+            !first level
             DO ji = nistr, niend, nn_factx
                ii   = ( ji - mis_crs(2) ) * rfactx_r + 2
@@ -2219,5 +2225,5 @@
       END SELECT
 
-      WRITE(narea+200,*)"TOTO",nldj_crs,mjs_crs(1), mje_crs(1),mjs_crs(2), mje_crs(2),mjs_crs(3), mje_crs(3),mjs_crs(4), mje_crs(4) ; CALL FLUSH(narea+200)
+      !WRITE(narea+200,*)"TOTO",nldj_crs,mjs_crs(1), mje_crs(1),mjs_crs(2), mje_crs(2),mjs_crs(3), mje_crs(3),mjs_crs(4), mje_crs(4) ; CALL FLUSH(narea+200)
 
       SELECT CASE ( cd_type )
@@ -2270,18 +2276,4 @@
                     &                    + zsurfmsk(ji,jj+2,jk) + zsurfmsk(ji+1,jj+2,jk) + zsurfmsk(ji+2,jj+2,jk)  
 
-               !cbr
-               iji=117 ; ijj=211
-               iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
-               IF( ii==iji .AND. ij==ijj .AND. jk==74 )THEN
-               WRITE(narea+5000,*)"SFC W =======> "
-               WRITE(narea+5000,*)ii,ij,jk
-               WRITE(narea+5000,*)ji,jj
-               WRITE(narea+5000,*)zsurfmsk(ji,jj  ,jk) , zsurfmsk(ji+1,jj  ,jk) , zsurfmsk(ji+2,jj  ,jk)
-               WRITE(narea+5000,*)zsurfmsk(ji,jj+1,jk) , zsurfmsk(ji+1,jj+1,jk) , zsurfmsk(ji+2,jj+1,jk)
-               WRITE(narea+5000,*)zsurfmsk(ji,jj+2,jk) , zsurfmsk(ji+1,jj+2,jk) , zsurfmsk(ji+2,jj+2,jk)
-               WRITE(narea+5000,*) p_surf_crs    (ii,ij,jk), p_surf_crs_msk(ii,ij,jk) 
-               ENDIF
-
-
             ENDDO      
          ENDDO
@@ -2333,26 +2325,4 @@
                     &                    + zsurfmsk(ji+2,jj+1,jk)  &
                     &                    + zsurfmsk(ji+2,jj+2,jk)
-               !cbr
-               !iji=117 ; ijj=211
-               !iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
-               !IF( ii==iji .AND. ij==ijj .AND. jk==74 )THEN
-               !WRITE(narea+5000,*)"SFC U =======> "
-               !WRITE(narea+5000,*)ii,ij,jk
-               !WRITE(narea+5000,*)ji,jj
-               !WRITE(narea+5000,*)mis_crs(2),rfactx_r , ( ji - 1 - mis_crs(2) ) * rfactx_r 
-               !WRITE(narea+5000,*)zsurf(ji+2,jj  ,jk),zsurf(ji+2,jj+1,jk),zsurf(ji+2,jj+2,jk)
-               !WRITE(narea+5000,*)zsurfmsk(ji+2,jj  ,jk),zsurfmsk(ji+2,jj+1,jk),zsurfmsk(ji+2,jj+2,jk)
-               !WRITE(narea+5000,*)p_surf_crs    (ii,ij,jk),p_surf_crs_msk(ii,ij,jk)
-               !ENDIF
-               !iji=116 ; ijj=211
-               !iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
-               !IF( ii==iji .AND. ij==ijj .AND. jk==74 )THEN
-               !WRITE(narea+5000,*)"SFC U =======> "
-               !WRITE(narea+5000,*)ii,ij,jk
-               !WRITE(narea+5000,*)ji,jj
-               !WRITE(narea+5000,*)zsurf(ji+2,jj  ,jk),zsurf(ji+2,jj+1,jk),zsurf(ji+2,jj+2,jk)
-               !WRITE(narea+5000,*)zsurfmsk(ji+2,jj  ,jk),zsurfmsk(ji+2,jj+1,jk),zsurfmsk(ji+2,jj+2,jk)
-               !WRITE(narea+5000,*)p_surf_crs    (ii,ij,jk),p_surf_crs_msk(ii,ij,jk)
-               !ENDIF
             ENDDO
          ENDDO
@@ -2395,13 +2365,13 @@
                p_surf_crs    (ii,ij,jk) =  zsurf(ji,jj+2,jk) + zsurf(ji+1,jj+2,jk) + zsurf(ji+2,jj+2,jk)
                p_surf_crs_msk(ii,ij,jk) =  zsurfmsk(ji,jj+2,jk) + zsurfmsk(ji+1,jj+2,jk) + zsurfmsk(ji+2,jj+2,jk)
-               iji=117 ; ijj=210
-               iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
-               IF( ii==iji .AND. ij==ijj .AND. jk==74 )THEN
-               WRITE(narea+5000,*)"SFC V =======> "
-               WRITE(narea+5000,*)ii,ij,jk
-               WRITE(narea+5000,*)ji,jj
-               WRITE(narea+5000,*)zsurfmsk(ji,jj+2,jk),zsurfmsk(ji+1,jj+2,jk),zsurfmsk(ji+2,jj+2,jk)
-               WRITE(narea+5000,*)p_surf_crs    (ii,ij,jk),p_surf_crs_msk(ii,ij,jk)
-               ENDIF
+               !iji=117 ; ijj=210
+               !iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
+               !IF( ii==iji .AND. ij==ijj .AND. jk==74 )THEN
+               !WRITE(narea+5000,*)"SFC V =======> "
+               !WRITE(narea+5000,*)ii,ij,jk
+               !WRITE(narea+5000,*)ji,jj
+               !WRITE(narea+5000,*)zsurfmsk(ji,jj+2,jk),zsurfmsk(ji+1,jj+2,jk),zsurfmsk(ji+2,jj+2,jk)
+               !WRITE(narea+5000,*)p_surf_crs    (ii,ij,jk),p_surf_crs_msk(ii,ij,jk)
+               !ENDIF
             ENDDO
          ENDDO
@@ -2409,11 +2379,11 @@
 
      END SELECT
-      DO jk=1,jpk
-      DO ji=1,jpi_crs
-      DO jj=1,jpj_crs
-         IF( p_surf_crs_msk(ji,jj,jk) .NE. p_surf_crs_msk(ji,jj,jk) )WRITE(narea+200,*)"SFC 4 ",ji,jj,jk,p_surf_crs_msk(ji,jj,jk)  ; call flush(narea+200)
-      ENDDO
-      ENDDO
-      ENDDO
+      !DO jk=1,jpk
+      !DO ji=1,jpi_crs
+      !DO jj=1,jpj_crs
+      !   IF( p_surf_crs_msk(ji,jj,jk) .NE. p_surf_crs_msk(ji,jj,jk) )WRITE(narea+200,*)"SFC 4 ",ji,jj,jk,p_surf_crs_msk(ji,jj,jk)  ; call flush(narea+200)
+      !ENDDO
+      !ENDDO
+      !ENDDO
       CALL crs_lbc_lnk( p_surf_crs    , cd_type, 1.0, pval=1.0 )
       CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pval=1.0 )
@@ -2449,7 +2419,7 @@
       jpi_crs = ( jpiglo_crs   - 2 * jpreci + (jpni-1) ) / jpni + 2 * jpreci
       jpj_crs = ( jpjglo_crsm1 - 2 * jprecj + (jpnj-1) ) / jpnj + 2 * jprecj   
-      WRITE(narea+200,*)"jpj_crs noso = ", jpj_crs , noso        
+      !WRITE(narea+200,*)"jpj_crs noso = ", jpj_crs , noso        
       IF( noso < 0 ) jpj_crs = jpj_crs + 1    ! add a local band on southern processors   ! celle qui est faite de zeros
-      WRITE(narea+200,*)"jpj_crs = ", jpj_crs
+      !WRITE(narea+200,*)"jpj_crs = ", jpj_crs
        
       jpi_crsm1   = jpi_crs - 1
@@ -2487,5 +2457,5 @@
         !cbr
         DO jn = 1, jpnij
-           WRITE(narea+200,*)"=====> jn",jn  ; call flush(narea+200)
+           !WRITE(narea+200,*)"=====> jn",jn  ; call flush(narea+200)
 
            !proc jn
@@ -2506,11 +2476,11 @@
            ENDIF
  
-           WRITE(narea+200,*)ii,ij  ; call flush(narea+200)
-           WRITE(narea+200,*)"iproc iprocso ",iproc,iprocso
-           WRITE(narea+200,*)"jpiglo jpjglo ",jpiglo,jpjglo
-           WRITE(narea+200,*)"ibonit(jn) ibonjt(jn) ",ibonit(jn),ibonjt(jn) ; call flush(narea+200)
-           WRITE(narea+200,*)"nimppt(jn) njmppt(jn) ",nimppt(jn),njmppt(jn) ; call flush(narea+200)
-           WRITE(narea+200,*)"loc jpj nldjt(jn),nlejt(jn),nlcjt(jn) ",jpj, nldjt(jn),nlejt(jn),nlcjt(jn) ; call flush(narea+200)
-           WRITE(narea+200,*)"glo jpj nldjt(jn),nlejt(jn),nlcjt(jn) ",jpj, nldjt(jn)+njmppt(jn)-1,nlejt(jn)+njmppt(jn)-1,nlcjt(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)ii,ij  ; call flush(narea+200)
+           !WRITE(narea+200,*)"iproc iprocso ",iproc,iprocso
+           !WRITE(narea+200,*)"jpiglo jpjglo ",jpiglo,jpjglo
+           !WRITE(narea+200,*)"ibonit(jn) ibonjt(jn) ",ibonit(jn),ibonjt(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"nimppt(jn) njmppt(jn) ",nimppt(jn),njmppt(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"loc jpj nldjt(jn),nlejt(jn),nlcjt(jn) ",jpj, nldjt(jn),nlejt(jn),nlcjt(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"glo jpj nldjt(jn),nlejt(jn),nlcjt(jn) ",jpj, nldjt(jn)+njmppt(jn)-1,nlejt(jn)+njmppt(jn)-1,nlcjt(jn) ; call flush(narea+200)
 
            !dimension selon j
@@ -2519,10 +2489,10 @@
               !iprocno=nfipproc(ii,ij+1) 
                  !iprocno=iprocno+1
-                 WRITE(narea+200,*)"ii,ij+1 ",ii,ij+1; call flush(narea+200)
-                 WRITE(narea+200,*)"njmppt  jn njmpptno(jn) ",njmppt(jn),njmpptno(jn); call flush(narea+200)
-                 WRITE(narea+200,*)"jpjglo",jpjglo ; call flush(narea+200)
-
-                 WRITE(narea+200,*)REAL( ( jpjglo - (njmppt  (jn) - 1) ) / nn_facty, wp ),REAL( ( jpjglo - (njmpptno(jn) - 1) ) / nn_facty, wp ); call flush(narea+200)
-                 WRITE(narea+200,*)AINT( REAL( ( jpjglo - (njmppt  (jn) - 1) ) / nn_facty, wp ) ),AINT( REAL( ( jpjglo - (njmpptno(jn) - 1) ) / nn_facty, wp ) ); call flush(narea+200)
+                 !WRITE(narea+200,*)"ii,ij+1 ",ii,ij+1; call flush(narea+200)
+                 !WRITE(narea+200,*)"njmppt  jn njmpptno(jn) ",njmppt(jn),njmpptno(jn); call flush(narea+200)
+                 !WRITE(narea+200,*)"jpjglo",jpjglo ; call flush(narea+200)
+
+                 !WRITE(narea+200,*)REAL( ( jpjglo - (njmppt  (jn) - 1) ) / nn_facty, wp ),REAL( ( jpjglo - (njmpptno(jn) - 1) ) / nn_facty, wp ); call flush(narea+200)
+                 !WRITE(narea+200,*)AINT( REAL( ( jpjglo - (njmppt  (jn) - 1) ) / nn_facty, wp ) ),AINT( REAL( ( jpjglo - (njmpptno(jn) - 1) ) / nn_facty, wp ) ); call flush(narea+200)
 
                  nlejt_crs(jn) = AINT( REAL( ( jpjglo - (njmppt  (jn) - 1) ) / nn_facty, wp ) ) &
@@ -2532,10 +2502,10 @@
            ENDIF
            !==> nbondj = -1 au sud, 0 au milieu, 1 au nord, 2 si jpnj=1
-           WRITE(narea+200,*)"nlejt_crs(jn) ",nlejt_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"nlejt_crs(jn) ",nlejt_crs(jn) ; call flush(narea+200)
            !!!noso== nbre de proc sud du proc sur lequel on tourne !!!! ; dangeureux car on est ds une boucle sur jn
            IF( iprocso < 0 .AND. ibonjt(jn) == -1 ) nlejt_crs(jn) = nlejt_crs(jn) + 1
            SELECT CASE( ibonjt(jn) )
               CASE ( -1 )
-                WRITE(narea+200,*)"MOD( jpjglo - njmppt(jn), nn_facty)",MOD( jpjglo - njmppt(jn), nn_facty) ; call flush(narea+200)
+                !WRITE(narea+200,*)"MOD( jpjglo - njmppt(jn), nn_facty)",MOD( jpjglo - njmppt(jn), nn_facty) ; call flush(narea+200)
                 IF( MOD( jpjglo - njmppt(jn), nn_facty) > 0 )  nlejt_crs(jn) = nlejt_crs(jn) + 1  ! au cas où il reste des lignes en bas
                 IF( nldjt(jn) == 1 )  nlejt_crs(jn) = nlejt_crs(jn) + 1
@@ -2558,6 +2528,6 @@
                  STOP
            END SELECT
-           WRITE(narea+200,*)"jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) " ; call flush(narea+200)
-           WRITE(narea+200,*) jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) " ; call flush(narea+200)
+           !WRITE(narea+200,*) jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) ; call flush(narea+200)
            IF( nlcjt_crs(jn) > jpj_crs )THEN
               jpj_crs = jpj_crs + 1
@@ -2572,6 +2542,6 @@
               njmppt_crs(jn) = 2 + ANINT(REAL((njmppt(jn) + 1 - MOD( jpjglo , nn_facty )) / nn_facty, wp ) )
            ENDIF
-           WRITE(narea+200,*)"tutu loc ",jn,jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) ; call flush(narea+200)
-           WRITE(narea+200,*)"tutu glo ",jn,jpj_crs, nldjt_crs(jn)+njmppt_crs(jn)-1,nlejt_crs(jn)+njmppt_crs(jn)-1,nlcjt_crs(jn)+njmppt_crs(jn)-1 ; call flush(narea+200)
+           !WRITE(narea+200,*)"tutu loc ",jn,jpj_crs, nldjt_crs(jn),nlejt_crs(jn),nlcjt_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"tutu glo ",jn,jpj_crs, nldjt_crs(jn)+njmppt_crs(jn)-1,nlejt_crs(jn)+njmppt_crs(jn)-1,nlcjt_crs(jn)+njmppt_crs(jn)-1 ; call flush(narea+200)
 
 
@@ -2583,10 +2553,10 @@
               nleit_crs(jn) = AINT( REAL( ( nimppt(jn  ) - 1 + nlcit(jn  ) )  / nn_factx, wp) )
            ELSE
-              WRITE(narea+200,*)"njmppt  jn njmpptea(jn) ",nimppt(jn),nimpptea(jn); call flush(narea+200)
-              WRITE(narea+200,*)"nlcit  (jn) nlcitea(jn) ) ",nlcit  (jn),nlcitea(jn); call flush(narea+200)
+              !WRITE(narea+200,*)"njmppt  jn njmpptea(jn) ",nimppt(jn),nimpptea(jn); call flush(narea+200)
+              !WRITE(narea+200,*)"nlcit  (jn) nlcitea(jn) ) ",nlcit  (jn),nlcitea(jn); call flush(narea+200)
               nleit_crs(jn) = AINT( REAL( ( nimppt  (jn) - 1 + nlcit  (jn) )  / nn_factx, wp) ) &
                  &          - AINT( REAL( ( nimpptea(jn) - 1 + nlcitea(jn) )  / nn_factx, wp) )
            ENDIF
-           WRITE(narea+200,*)"nleji_crs(jn),noso ",nleit_crs(jn); call flush(narea+200)
+           !WRITE(narea+200,*)"nleji_crs(jn),noso ",nleit_crs(jn); call flush(narea+200)
 
 
@@ -2611,12 +2581,12 @@
                  STOP
            END SELECT
-           WRITE(narea+200,*)"jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ",jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ",jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ; call flush(narea+200)
            nimppt_crs(jn) = ANINT( REAL( (nimppt(jn) + 1 ) / nn_factx, wp ) ) + 1
 
-           WRITE(narea+200,*)"tutu loc ",jn,jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ; call flush(narea+200)
-           WRITE(narea+200,*)"tutu glo ",jn,jpi_crs, nldit_crs(jn)+nimppt_crs(jn)-1,nleit_crs(jn)+nimppt_crs(jn)-1,nlcit_crs(jn)+nimppt_crs(jn)-1 ; call flush(narea+200)
+           !WRITE(narea+200,*)"tutu loc ",jn,jpi_crs, nldit_crs(jn),nleit_crs(jn),nlcit_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"tutu glo ",jn,jpi_crs, nldit_crs(jn)+nimppt_crs(jn)-1,nleit_crs(jn)+nimppt_crs(jn)-1,nlcit_crs(jn)+nimppt_crs(jn)-1 ; call flush(narea+200)
 
            nfiimpp_crs(ii,ij) = nimppt_crs(jn)
-           WRITE(narea+200,*)"tutu nimppt_crs(jn) ",ii,ij,nimppt_crs(jn) ; call flush(narea+200)
+           !WRITE(narea+200,*)"tutu nimppt_crs(jn) ",ii,ij,nimppt_crs(jn) ; call flush(narea+200)
           
         ENDDO
@@ -2628,5 +2598,5 @@
               nfiimpp_crs(ji,jj) = iimppt_crs
               IF( jn .GE. 1 )nimppt_crs(jn) = iimppt_crs
-              PRINT*," nfiimpp_crs(ji,jj) ",ji,jj,jn,nfiimpp(ji,jj),nfiimpp_crs(ji,jj)
+              !PRINT*," nfiimpp_crs(ji,jj) ",ji,jj,jn,nfiimpp(ji,jj),nfiimpp_crs(ji,jj)
            ENDDO
         ENDDO
@@ -2657,9 +2627,9 @@
 
         !==============================================================================================
-         write(narea+200,*)"jpi_crs,nldi_crs,nlei_crs,nlci_crs,nimpp_crs,nldi_crs+nimpp_crs-1,nlei_crs+nimpp_crs-1" ; call flush(narea+200)
-         write(narea+200,*)jpi_crs,nldi_crs,nlei_crs,nlci_crs,nimpp_crs,nldi_crs+nimpp_crs-1,nlei_crs+nimpp_crs-1 ; call flush(narea+200)
-         write(narea+200,*)"jpj_crs,nldj_crs,nlej_crs,nlcj_crs,njmpp_crs,nldj_crs+njmpp_crs-1,nlej_crs+njmpp_crs-1" ; call flush(narea+200)
-         write(narea+200,*)jpj_crs,nldj_crs,nlej_crs,nlcj_crs,njmpp_crs,nldj_crs+njmpp_crs-1,nlej_crs+njmpp_crs-1 ; call flush(narea+200)
-         write(narea+200,*)"nfsloop_crs nfeloop_crs ",nfsloop_crs,nfeloop_crs ; call flush(narea+200)
+         !write(narea+200,*)"jpi_crs,nldi_crs,nlei_crs,nlci_crs,nimpp_crs,nldi_crs+nimpp_crs-1,nlei_crs+nimpp_crs-1" ; call flush(narea+200)
+         !write(narea+200,*)jpi_crs,nldi_crs,nlei_crs,nlci_crs,nimpp_crs,nldi_crs+nimpp_crs-1,nlei_crs+nimpp_crs-1 ; call flush(narea+200)
+         !write(narea+200,*)"jpj_crs,nldj_crs,nlej_crs,nlcj_crs,njmpp_crs,nldj_crs+njmpp_crs-1,nlej_crs+njmpp_crs-1" ; call flush(narea+200)
+         !write(narea+200,*)jpj_crs,nldj_crs,nlej_crs,nlcj_crs,njmpp_crs,nldj_crs+njmpp_crs-1,nlej_crs+njmpp_crs-1 ; call flush(narea+200)
+         !write(narea+200,*)"nfsloop_crs nfeloop_crs ",nfsloop_crs,nfeloop_crs ; call flush(narea+200)
 
          ! No coarsening with zoom
@@ -2671,9 +2641,9 @@
          DO ji = 1, jpi_crs
             mig_crs(ji) = ji + nimpp_crs - 1
-            WRITE(narea+200,*)"fifi ",ji,mig_crs(ji)  ; call flush(narea+200)
+            !WRITE(narea+200,*)"fifi ",ji,mig_crs(ji)  ; call flush(narea+200)
          ENDDO
          DO jj = 1, jpj_crs
             mjg_crs(jj) = jj + njmpp_crs - 1!
-            WRITE(narea+200,*)"fufu ",jj,mjg_crs(jj)  ; call flush(narea+200)
+            !WRITE(narea+200,*)"fufu ",jj,mjg_crs(jj)  ; call flush(narea+200)
          ENDDO
        
@@ -2681,5 +2651,5 @@
             mi0_crs(ji) = MAX( 1, MIN( ji - nimpp_crs + 1 , jpi_crs + 1 ) )
             mi1_crs(ji) = MAX( 0, MIN( ji - nimpp_crs + 1 , jpi_crs     ) )
-            WRITE(narea+200,*)"mi ",ji,mi0_crs(ji),mi1_crs(ji)  ; call flush(narea+200)
+            !WRITE(narea+200,*)"mi ",ji,mi0_crs(ji),mi1_crs(ji)  ; call flush(narea+200)
          ENDDO
          
@@ -2687,5 +2657,5 @@
             mj0_crs(jj) = MAX( 1, MIN( jj - njmpp_crs + 1 , jpj_crs + 1 ) )
             mj1_crs(jj) = MAX( 0, MIN( jj - njmpp_crs + 1 , jpj_crs     ) )
-            WRITE(narea+200,*)"mj ",jj, mj0_crs(jj),mj1_crs(jj) ; call flush(narea+200)
+            !WRITE(narea+200,*)"mj ",jj, mj0_crs(jj),mj1_crs(jj) ; call flush(narea+200)
          ENDDO
 
@@ -2810,5 +2780,5 @@
                 mjs2_crs(jpjglo_crs-jj+2) = ijjs
                 mje2_crs(jpjglo_crs-jj+2) = ijje
-               WRITE(narea+200,*)"jpjglo_crs-jj+2,ijje,ijjs ",jpjglo_crs-jj+2,ijjs,ijje ; call flush(narea+200)
+               !WRITE(narea+200,*)"jpjglo_crs-jj+2,ijje,ijjs ",jpjglo_crs-jj+2,ijjs,ijje ; call flush(narea+200)
             ENDDO
 
@@ -2871,21 +2841,21 @@
         mje_crs(:) = mje2_crs(:) 
       ELSE
-       write(narea+200,*)"njmpp ",njmpp
+       !write(narea+200,*)"njmpp ",njmpp
         DO jj = 1, nlej_crs
-           write(narea+200,*)jj,"mjs2_crs mje2_crs ",mjg_crs(jj),mjs2_crs(mjg_crs(jj)),mje2_crs(mjg_crs(jj)) ; call flush(narea+200)
+           !write(narea+200,*)jj,"mjs2_crs mje2_crs ",mjg_crs(jj),mjs2_crs(mjg_crs(jj)),mje2_crs(mjg_crs(jj)) ; call flush(narea+200)
            mjs_crs(jj) = mjs2_crs(mjg_crs(jj)) - njmpp + 1
            mje_crs(jj) = mje2_crs(mjg_crs(jj)) - njmpp + 1
-           write(narea+200,*)"mjs_crs mje_crs ",mjs_crs(jj),mje_crs(jj) ; call flush(narea+200)
+           !write(narea+200,*)"mjs_crs mje_crs ",mjs_crs(jj),mje_crs(jj) ; call flush(narea+200)
         ENDDO
-        write(narea+200,*)"nimpp ",nimpp
+        !write(narea+200,*)"nimpp ",nimpp
         DO ji = 1, nlei_crs
-           write(narea+200,*)ji,"mis2_crs mie2_crs ",mig_crs(ji),mis2_crs(mig_crs(ji)),mie2_crs(mig_crs(ji)) ; call flush(narea+200)
+           !write(narea+200,*)ji,"mis2_crs mie2_crs ",mig_crs(ji),mis2_crs(mig_crs(ji)),mie2_crs(mig_crs(ji)) ; call flush(narea+200)
            mis_crs(ji) = mis2_crs(mig_crs(ji)) - nimpp + 1
            mie_crs(ji) = mie2_crs(mig_crs(ji)) - nimpp + 1
-           write(narea+200,*)"mis_crs mie_crs ",mis_crs(jj),mie_crs(jj) ; call flush(narea+200)
+           !write(narea+200,*)"mis_crs mie_crs ",mis_crs(jj),mie_crs(jj) ; call flush(narea+200)
         ENDDO
       ENDIF
       !
-      IF( nlcj_crs -1 .GT. nlej_crs )WRITE(narea+200,*)"tutututu",nlcj_crs,nlej_crs ; call flush(narea+200)
+      !IF( nlcj_crs -1 .GT. nlej_crs )WRITE(narea+200,*)"tutututu",nlcj_crs,nlej_crs ; call flush(narea+200)
       nistr = mis_crs(2)  ;   niend = mis_crs(nlci_crs - 1)
       njstr = mjs_crs(3)  ;   njend = mjs_crs(nlcj_crs - 1)
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsdomwri.F90	(revision 5601)
@@ -205,4 +205,6 @@
             CALL iom_rstput( 0, 0, inum4, 'e3u', e3u_crs )      
             CALL iom_rstput( 0, 0, inum4, 'e3v', e3v_crs )      
+            CALL iom_rstput( 0, 0, inum4, 'e3t_max_crs', e3t_max_crs )      
+            CALL iom_rstput( 0, 0, inum4, 'e3w_max_crs', e3w_max_crs )      
          ELSE
             DO jj = 1,jpj_crs   
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 5601)
@@ -17,4 +17,5 @@
    USE zdf_oce         ! vertical  physics: ocean fields
    USE zdfddm          ! vertical  physics: double diffusion
+   USe zdfmxl
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE in_out_manager  ! I/O manager
@@ -25,4 +26,5 @@
    USE crslbclnk
    USE iom
+   USE zdfmxl_crs
 
    IMPLICIT NONE
@@ -64,4 +66,5 @@
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zfse3t, zfse3u, zfse3v, zfse3w ! 3D workspace for e3
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zt, zs 
+      REAL(wp), POINTER, DIMENSION(:,:)   :: z2d,z2d_crs
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_crs, zs_crs !
       REAL(wp)       :: z2dcrsu, z2dcrsv
@@ -71,7 +74,5 @@
       INTEGER ::  iji,ijj
       !!
-       !!----------------------------------------------------------------------
-      ! 
-      !IF(narea==267)WRITE(narea+5000,*)"========================================> crsfldt ",kt
+      !!----------------------------------------------------------------------
 
       IF( nn_timing == 1 )   CALL timing_start('crs_fld')
@@ -80,7 +81,9 @@
       CALL wrk_alloc( jpi, jpj, jpk, zfse3t, zfse3w )
       CALL wrk_alloc( jpi, jpj, jpk, zfse3u, zfse3v )
-      CALL wrk_alloc( jpi, jpj, jpk, zt, zs       )
+      CALL wrk_alloc( jpi, jpj, jpk, zt, zs         )
+      CALL wrk_alloc( jpi, jpj,      z2d            )
       !
       CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
+      CALL wrk_alloc( jpi_crs, jpj_crs, z2d_crs     )
 
       ! Depth work arrrays
@@ -130,8 +133,8 @@
       zs(:,:,:) = tsb(:,:,:,jp_sal)  ;      zs_crs(:,:,:) = 0._wp
       CALL crs_dom_ope( zs, 'VOL', 'T', tmask, zs_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
-      tsb_crs(:,:,:,jp_sal) = zt_crs(:,:,:)
+      tsb_crs(:,:,:,jp_sal) = zs_crs(:,:,:)
       zs(:,:,:) = tsn(:,:,:,jp_sal)  ;      zs_crs(:,:,:) = 0._wp
       CALL crs_dom_ope( zs, 'VOL', 'T', tmask, zs_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
-      tsn_crs(:,:,:,jp_sal) = zt_crs(:,:,:)
+      tsn_crs(:,:,:,jp_sal) = zs_crs(:,:,:)
 
       CALL iom_put( "soce" , tsn_crs(:,:,:,jp_sal) )    ! sal
@@ -162,12 +165,8 @@
 
       !  V-velocity
-      !IF(narea==267)WRITE(narea+5000,*)"deg vb_crs"
       CALL crs_dom_ope( vb, 'SUM', 'V', vmask, vb_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
-      !IF(narea==267)WRITE(narea+5000,*)"deg vn_crs"
       CALL crs_dom_ope( vn, 'SUM', 'V', vmask, vn_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
-      !IF(narea==267)WRITE(narea+5000,*)"1 vn_crs(17,5,74) = ",vn_crs(17,5,74),vmask_crs(17,5,74),vn(46,13,74),vn(47,13,74),vn(48,13,74)
       vb_crs(:,:,:) = vb_crs(:,:,:)*vmask_crs(:,:,:)
       vn_crs(:,:,:) = vn_crs(:,:,:)*vmask_crs(:,:,:)
-      !IF(narea==267)WRITE(narea+5000,*)"2 vn_crs(17,5,74) = ",vn_crs(17,5,74),vmask_crs(17,5,74),vn(46,13,74),vn(47,13,74),vn(48,13,74)
       !                                                                                 
       zt(:,:,:) = 0._wp     ;    zs(:,:,:) = 0._wp  ;   zt_crs(:,:,:) = 0._wp   ;    zs_crs(:,:,:) = 0._wp
@@ -209,5 +208,4 @@
                   !
                   !cbr
-                  !
                   !bug1: il manquait le facvol_t(ji,jj,jk) ds la division ; ca creait des grosses erreurs de Wcrs ( vu en recalculant la divergence 3D )
                   !bug2: mm test que bug1: on n'obtient tjs pas zero
@@ -215,25 +213,6 @@
                   !exp (117,211,74) : e1*e2*e3=235206030060.005 / ocean_volume_crs_t * facvol = 235205585307.810
                   !                   e1*e2*e3-cean_volume_crs_t * facvol/(cean_volume_crs_t * facvol) ~1.e-6)  
-                  !IF( ocean_volume_crs_t(ji,jj,jk) .NE. 0._wp ) hdivn_crs(ji,jj,jk) = ( z2dcrsu + z2dcrsv ) / (facvol_t(ji,jj,jk)*ocean_volume_crs_t(ji,jj,jk))
-                  !IF( ocean_volume_crs_t(ji,jj,jk) .NE. 0._wp ) hdivn_crs(ji,jj,jk) = ( z2dcrsu + z2dcrsv ) / (e1t_crs(ji,jj)*e2t_crs(ji,jj)*e3t_crs(ji,jj,jk))
                   IF( ocean_volume_crs_t(ji,jj,jk) .NE. 0._wp ) hdivn_crs(ji,jj,jk) = ( z2dcrsu + z2dcrsv )
 
-               !iji=117 ; ijj=211
-               !iji=iji-nimpp_crs+1 ; ijj=ijj-njmpp_crs+1
-               !IF( ji==iji .AND. jj==ijj )THEN
-               !WRITE(narea+5000,*)"hdivn_crs =======> "
-               !WRITE(narea+5000,*) "u"  ,jk,un_crs(ji  ,jj  ,jk) ,e2e3u_msk(ji  ,jj  ,jk),un_crs(ji  ,jj  ,jk)*e2e3u_msk(ji  ,jj  ,jk)
-               !WRITE(narea+5000,*) "um1",jk,un_crs(ji-1,jj  ,jk) , e2e3u_msk(ji-1,jj  ,jk),un_crs(ji-1,jj  ,jk) * e2e3u_msk(ji-1,jj  ,jk)
-               !WRITE(narea+5000,*) "v",jk,vn_crs(ji  ,jj  ,jk) , e1e3v_msk(ji  ,jj  ,jk),vn_crs(ji  ,jj  ,jk) * e1e3v_msk(ji  ,jj  ,jk)
-               !WRITE(narea+5000,*) "vm1",jk,vn_crs(ji  ,jj-1,jk) , e1e3v_msk(ji  ,jj-1,jk),vn_crs(ji  ,jj-1,jk) * e1e3v_msk(ji  ,jj-1,jk)
-               !WRITE(narea+5000,*) "t1 ",jk,z2dcrsu,z2dcrsv, z2dcrsu + z2dcrsv,hdivn_crs(ji,jj,jk)
-               !WRITE(narea+5000,*) "t2 ",jk,e1t_crs(ji,jj),e2t_crs(ji,jj),e3t_crs(ji,jj,jk),e1t_crs(ji,jj)*e2t_crs(ji,jj)*e3t_crs(ji,jj,jk)
-               !WRITE(narea+5000,*) "t3 ",jk,ocean_volume_crs_t(ji,jj,jk),facvol_t(ji,jj,jk),facvol_t(ji,jj,jk)*ocean_volume_crs_t(ji,jj,jk)
-               !WRITE(narea+5000,*) "t4 ",jk, ( z2dcrsu + z2dcrsv ) / (facvol_t(ji,jj,jk)*ocean_volume_crs_t(ji,jj,jk))
-               !WRITE(narea+5000,*) "t5 ",jk, ( z2dcrsu + z2dcrsv ) / (e1t_crs(ji,jj)*e2t_crs(ji,jj)*e3t_crs(ji,jj,jk))
-               !ENDIF
-
-
-                  !IF( crs_volt_wgt(ji,jj,jk) .NE. 0._wp ) hdivn_crs(ji,jj,jk) = ( z2dcrsu + z2dcrsv ) / crs_volt_wgt(ji,jj,jk)
                   z2dcrsu =  ( ub_crs(ji  ,jj  ,jk) * e2e3u_msk(ji  ,jj  ,jk) ) &
                      &     - ( ub_crs(ji-1,jj  ,jk) * e2e3u_msk(ji-1,jj  ,jk) )
@@ -251,13 +230,4 @@
 
 
-      ! DO jk = 1, jpkm1          ! Interior value
-      !      DO jj = 1, jpj_crs
-      !         DO ji = 1, jpi_crs
-      !            IF( e3t_crs(ji,jj,jk) .NE. e3t_crs(ji,jj,jk) )WRITE(narea+200,*)"e3t_crs",e3t_crs(ji,jj,jk) ; call flush(narea+200)
-      !            IF( hdivn_crs(ji,jj,jk) .NE. hdivn_crs(ji,jj,jk) )WRITE(narea+200,*)"hdivn_crs",hdivn_crs(ji,jj,jk) ; call flush(narea+200)
-      !         END DO
-      !      END DO
-      !   END DO
-
       !  W-velocity
       IF( ln_crs_wn ) THEN
@@ -266,5 +236,4 @@
         wn_crs(:,:,jpk) = 0._wp
         DO jk = jpkm1, 1, -1
-           !cbr wn_crs(:,:,jk) = wn_crs(:,:,jk+1) - e3t_crs(:,:,jk) * hdivn_crs(:,:,jk)
            wn_crs(:,:,jk) = e1e2w_msk(:,:,jk+1)*wn_crs(:,:,jk+1) - hdivn_crs(:,:,jk)
            WHERE( e1e2w_msk(:,:,jk) .NE. 0._wp )  wn_crs(:,:,jk) =  wn_crs(:,:,jk) /e1e2w_msk(:,:,jk) 
@@ -286,5 +255,8 @@
       !
       CALL iom_put( "avt", avt_crs )   !  Kz
-      
+     
+      !deja dasn step CALL zdf_mxl_crs(kt)
+
+ 
       !  sbc fields  
 
@@ -303,4 +275,9 @@
       CALL crs_dom_ope( fr_i , 'SUM', 'T', tmask, fr_i_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
 
+      z2d=REAL(nmln,wp)
+      CALL crs_dom_ope( z2d , 'MAX', 'T', tmask, z2d_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
+      nmln_crs=INT(z2d_crs) 
+      nmln_crs=MAX(nlb10,nmln_crs)    
+
       CALL iom_put( "ssh"      , sshn_crs )   ! ssh output 
       CALL iom_put( "utau"     , utau_crs )   ! i-tau output 
@@ -313,120 +290,11 @@
       CALL iom_put( "ice_cover", fr_i_crs )   ! ice cover output 
 
-      !cbr
-      !IF(narea==267)WRITE(narea+5000,*)"vn_crs(17,5,74) = ",vn_crs(17,5,74)
-      !ji=117 ; jj=211 ; jk=74
-      !ji=ji-nimpp_crs+1 ; jj=jj-njmpp_crs+1
-      !IF( ji .GE. 2 .AND. ji .LE. jpi_crs-1 .AND. jj .GE. 2 .AND. jj .LE. jpj_crs-1 )THEN
-      !WRITE(narea+5000,*)"=======> kt ",kt
-      !WRITE(narea+5000,*)ji,jj,glamt(ji,jj),gphit(ji,jj)
-      !WRITE(narea+5000,*)"um1  crs ",umask_crs(ji-1,jj,jk),e2e3u_msk(ji-1,jj,jk),un_crs(ji-1,jj,jk),umask_crs(ji-1,jj,jk)*e2e3u_msk(ji-1,jj,jk)*un_crs(ji-1,jj,jk)
-      !WRITE(narea+5000,*)"u    crs ",umask_crs(ji,jj,jk),e2e3u_msk(ji,jj,jk),un_crs(ji,jj,jk),umask_crs(ji,jj,jk)*e2e3u_msk(ji,jj,jk)*un_crs(ji,jj,jk)
-      !WRITE(narea+5000,*)"vm1  crs ",vmask_crs(ji,jj-1,jk),e1e3v_msk(ji,jj-1,jk),vn_crs(ji,jj-1,jk),vmask_crs(ji,jj-1,jk)*e1e3v_msk(ji,jj-1,jk)*vn_crs(ji,jj-1,jk)
-      !WRITE(narea+5000,*)"v    crs ",vmask_crs(ji,jj,jk),e1e3v_msk(ji,jj,jk),vn_crs(ji,jj,jk),vmask_crs(ji,jj,jk)*e1e3v_msk(ji,jj,jk)*vn_crs(ji,jj,jk)
-      !WRITE(narea+5000,*)"wp1  crs ",tmask_crs(ji,jj,jk+1),e1e2w_msk(ji,jj,jk+1),wn_crs(ji,jj,jk+1),tmask_crs(ji,jj,jk+1)*e1e2w_msk(ji,jj,jk+1)*wn_crs(ji,jj,jk+1)
-      !WRITE(narea+5000,*)"w    crs ",tmask_crs(ji,jj,jk),e1e2w_msk(ji,jj,jk),wn_crs(ji,jj,jk),tmask_crs(ji,jj,jk)*e1e2w_msk(ji,jj,jk)*wn_crs(ji,jj,jk)
-      !z = umask_crs(ji,jj,jk)*e2e3u_msk(ji,jj,jk)*un_crs(ji,jj,jk) - umask_crs(ji-1,jj,jk)*e2e3u_msk(ji-1,jj,jk)*un_crs(ji-1,jj,jk) + &
-      !    vmask_crs(ji,jj,jk)*e1e3v_msk(ji,jj,jk)*vn_crs(ji,jj,jk) - vmask_crs(ji,jj-1,jk)*e1e3v_msk(ji,jj-1,jk)*vn_crs(ji,jj-1,jk) + &
-      !    tmask_crs(ji,jj,jk)*e1e2w_msk(ji,jj,jk)*wn_crs(ji,jj,jk) - tmask_crs(ji,jj,jk+1)*e1e2w_msk(ji,jj,jk+1)*wn_crs(ji,jj,jk+1)
-      !WRITE(narea+5000,*)"sum ",z
-      !ijie = mie_crs(ji)
-      !ijis = mis_crs(ji)
-      !ijje = mje_crs(jj)
-      !ijjs = mjs_crs(jj)
-      !DO i=ijis,ijie
-      !   DO j=ijjs,ijje
-      !       WRITE(narea+5000,*)"tmask",i,j,tmask(i,j,jk)
-      !   ENDDO           
-      !ENDDO           
-
-      !z=0._wp
-      !zsm=0._wp
-      !DO i=ijis,ijie
-      !   DO j=ijjs,ijje
-      !       WRITE(narea+5000,*)"w",i,j,tmask(i,j,jk),e1t(i,j),e2t(i,j),e1t(i,j)*e2t(i,j),wn(i,j,jk)
-      !       z=z+tmask(i,j,jk)*e1t(i,j)*e2t(i,j)*wn(i,j,jk)
-      !       zsm=zsm+tmask(i,j,jk)*e1t(i,j)*e2t(i,j)
-      !   ENDDO           
-      !ENDDO   
-        
-      !zw=z
-      !WRITE(narea+5000,*)"w sum ",zsm,zw           
-      !z=0._wp
-      !zsm=0._wp
-      !DO i=ijis,ijie
-      !   DO j=ijjs,ijje
-      !       WRITE(narea+5000,*)"wp1 ",i,j,tmask(i,j,jk+1),e1t(i,j),e2t(i,j),e1t(i,j)*e2t(i,j),wn(i,j,jk+1)
-      !       z=z+tmask(i,j,jk+1)*e1t(i,j)*e2t(i,j)*wn(i,j,jk+1)
-      !       zsm=zsm+tmask(i,j,jk+1)*e1t(i,j)*e2t(i,j)
-      !   ENDDO
-      !ENDDO
-      !zwp1=z
-      !WRITE(narea+5000,*)"wp1 sum ",zsm,zwp1  
-      !z=0._wp
-      !zsm=0._wp
-      !i=ijis-1
-      !DO j=ijjs,ijje
-      !    WRITE(narea+5000,*)"um1",i,j,umask(i,j,jk),e2u(i,j),e3u_0(i,j,jk),e2u(i,j)*e3u_0(i,j,jk),un(i,j,jk)
-      !    z=z+e2u(i,j)*e3u_0(i,j,jk)*un(i,j,jk)
-      !    zsm=zsm+e2u(i,j)*e3u_0(i,j,jk)*umask(i,j,jk)
-      !ENDDO
-      !zum1=z
-      !WRITE(narea+5000,*)"um1 sum ",zsm,zum1          
-      !z=0._wp
-      !zsm=0._wp
-      !i=ijie
-      !DO j=ijjs,ijje
-      !    WRITE(narea+5000,*)"u",i,j,umask(i,j,jk),e2u(i,j),e3u_0(i,j,jk),e2u(i,j)*e3u_0(i,j,jk),un(i,j,jk)
-      !    z=z+e2u(i,j)*e3u_0(i,j,jk)*un(i,j,jk)
-      !    zsm=zsm+e2u(i,j)*e3u_0(i,j,jk)*umask(i,j,jk)
-      !ENDDO           
-      !zu=z
-      !WRITE(narea+5000,*)"u   sum ",zsm,zu          
-      !z=0._wp
-      !zsm=0._wp
-      !j=ijjs-1
-      !DO i=ijis,ijie
-      !    WRITE(narea+5000,*)"vm1",i,j,vmask(i,j,jk),e1v(i,j),e3v_0(i,j,jk),e1v(i,j)*e3v_0(i,j,jk),vn(i,j,jk)
-      !    z=z+e1v(i,j)*e3v_0(i,j,jk)*vn(i,j,jk)
-      !    zsm=zsm+e1v(i,j)*e3v_0(i,j,jk)*vmask(i,j,jk)
-      !ENDDO           
-      !zvm1=z
-      !WRITE(narea+5000,*)"vm1 sum ",zsm,zvm1           
-      !z=0._wp
-      !zsm=0._wp
-      !j=ijje
-      !DO i=ijis,ijie
-      !    WRITE(narea+5000,*)"v",i,j,vmask(i,j,jk),e1v(i,j),e3v_0(i,j,jk),e1v(i,j)*e3v_0(i,j,jk),vn(i,j,jk)
-      !    z=z+e1v(i,j)*e3v_0(i,j,jk)*vn(i,j,jk)
-      !    zsm=zsm+e1v(i,j)*e3v_0(i,j,jk)*vmask(i,j,jk)
-      !ENDDO           
-      !zv=z
-      !WRITE(narea+5000,*)"v   sum ",zv           
-      !WRITE(narea+5000,*)"sum ",zw+zwp1+zum1+zu+zvm1+zv
-      !DO i=ijis,ijie
-      !   DO j=ijjs,ijje
-      !       WRITE(narea+5000,*)"msk",i,j,tmask(i,j,jk),umask(i,j,jk),vmask(i,j,jk)
-      !       WRITE(narea+5000,*)"vel",i,j,un(i,j,jk),vn(i,j,jk),wn(i,j,jk)
-      !   ENDDO
-      !ENDDO
-
-      !DO i=ijis,ijie
-      !   DO j=ijjs,ijje
-      !      z = un(i,j,jk)*e2u(i,j)*e3u_0(i,j,jk)*umask(i,j,jk) - un(i-1,j,jk)*e2u(i-1,j)*e3u_0(i-1,j,jk)*umask(i-1,j,jk) + &
-      !          vn(i,j,jk)*e1v(i,j)*e3v_0(i,j,jk)*vmask(i,j,jk) - vn(i,j-1,jk)*e1v(i,j-1)*e3v_0(i,j-1,jk)*vmask(i,j-1,jk) + &
-      !          wn(i,j,jk)*e2t(i,j)*e1t(i,j)*tmask(i,j,jk)     - wn(i,j,jk+1)*e2t(i,j)*e1t(i,j)*tmask(i,j,jk+1)
-      !       WRITE(narea+5000,*)"div ",i,j,jk,z
-      !   ENDDO
-      !ENDDO
-
-      !ENDIF
-      
-  
-
       !  free memory
       CALL wrk_dealloc( jpi, jpj, jpk, zfse3t, zfse3w )
       CALL wrk_dealloc( jpi, jpj, jpk, zfse3u, zfse3v )
-      CALL wrk_dealloc( jpi, jpj, jpk, zt, zs       )
+      CALL wrk_dealloc( jpi, jpj, jpk, zt, zs         )
+      CALL wrk_dealloc( jpi, jpj, z2d                 )
       CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
+      CALL wrk_dealloc( jpi_crs, jpj_crs, z2d_crs     )
       !
       CALL iom_swap( "nemo" )     ! return back on high-resolution grid
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90	(revision 5601)
@@ -20,4 +20,5 @@
    USE crslbclnk
    USE lib_mpp
+   USE ldftra_crs
 
    IMPLICIT NONE
@@ -179,5 +180,4 @@
       CASE ( 0, 1, 4 )           ! mesh on the sphere
 
-         zmin=MINVAL(ABS(gphif_crs(:,:)));zmax=MAXVAL(ABS(gphif_crs(:,:)));CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"gphif_crs",zmin,zmax
          ff_crs(:,:) = 2. * omega * SIN( rad * gphif_crs(:,:) )
 
@@ -206,5 +206,4 @@
      e1e3v_msk(:,:,:)=0._wp
      CALL crs_dom_sfc( tmask, 'W', e1e2w_crs, e1e2w_msk, p_e1=e1t, p_e2=e2t    )
-     WRITE(narea+200,*)"e1e2w_crs(2,18,1) ",e1e2w_crs(2,18,1)
      CALL crs_dom_sfc( umask, 'U', e2e3u_crs, e2e3u_msk, p_e2=e2u, p_e3=zfse3u )
      CALL crs_dom_sfc( vmask, 'V', e1e3v_crs, e1e3v_msk, p_e1=e1v, p_e3=zfse3v )
@@ -212,9 +211,4 @@
      !cbr facsurfu(:,:,:) = umask_crs(:,:,:) * e2e3u_msk(:,:,:) / e2e3u_crs(:,:,:)
      !cbr facsurfv(:,:,:) = vmask_crs(:,:,:) * e1e3v_msk(:,:,:) / e1e3v_crs(:,:,:)
-     WRITE(narea+200,*)'umask_crs ',SHAPE(umask_crs)
-     WRITE(narea+200,*)jpi,jpj,jpk
-     WRITE(narea+200,*)"e1e2w_crs(2,18,1) ",e1e2w_crs(2,18,1)
-     CALL flush(narea+200)
-
      DO jk=1,jpk
         DO ji=1,jpi_crs
@@ -222,12 +216,5 @@
 
               facsurfu(ji,jj,jk) = umask_crs(ji,jj,jk) * e2e3u_msk(ji,jj,jk)  
-
-              IF( facsurfu(ji,jj,jk) .NE. facsurfu(ji,jj,jk) )WRITE(narea+200,*)'BUG1',facsurfu(ji,jj,jk);call flush(narea+200)
-              IF( e2e3u_crs(ji,jj,jk) .NE. e2e3u_crs(ji,jj,jk) ) WRITE(narea+200,*)'BUG2',e2e3u_crs(ji,jj,jk);call flush(narea+200)
-              IF( e2e3u_msk(ji,jj,jk) .NE. e2e3u_msk(ji,jj,jk) ) WRITE(narea+200,*)'BUG3',e2e3u_msk(ji,jj,jk) ;call flush(narea+200)
-              IF( e1e2w_msk(ji,jj,jk) .NE. e1e2w_msk(ji,jj,jk) ) WRITE(narea+200,*)'BUG4',ji,jj,jk,e1e2w_msk(ji,jj,jk) ;call flush(narea+200)
-              IF( tmask(ji,jj,jk) .NE. tmask(ji,jj,jk) ) WRITE(narea+200,*)'BUG4',tmask(ji,jj,jk) ;call flush(narea+200)
-              IF( e1t(ji,jj) .NE. e1t(ji,jj) ) WRITE(narea+200,*)'BUG5',e1t(ji,jj) ;call flush(narea+200)
-              IF( e1t(ji,jj) .NE. e2t(ji,jj) ) WRITE(narea+200,*)'BUG6',e2t(ji,jj) ;call flush(narea+200)
+              IF( e2e3u_crs(ji,jj,jk) .NE. 0._wp ) facsurfu(ji,jj,jk) = facsurfu(ji,jj,jk) / e2e3u_crs(ji,jj,jk)
 
               facsurfv(ji,jj,jk) = vmask_crs(ji,jj,jk) * e1e3v_msk(ji,jj,jk)  
@@ -264,4 +251,5 @@
 
      !    3.d.3   Vertical depth (meters)
+     !cbr: il semblerait que p_e3=... ne soit pas utile ici !!!!!!!!!
      CALL crs_dom_ope( gdept_0, 'MAX', 'T', tmask, gdept_crs, p_e3=zfse3t, psgn=1.0 ) 
      CALL crs_dom_ope( gdepw_0, 'MAX', 'W', tmask, gdepw_crs, p_e3=zfse3w, psgn=1.0 )
@@ -271,5 +259,4 @@
      ! 4.  Coarse grid ocean volume and averaging weights
      !---------------------------------------------------------
-     ! 4.a. Ocean volume or area unmasked and masked
      CALL crs_dom_facvol( tmask, 'T', e1t, e2t, zfse3t, ocean_volume_crs_t, facvol_t )
      !
@@ -280,7 +267,17 @@
 
      CALL crs_dom_facvol( tmask, 'W', e1t, e2t, zfse3w, ocean_volume_crs_w, facvol_w )
-     !
-     !---------------------------------------------------------
-     ! 5.  Write out coarse meshmask  (see OPA_SRC/DOM/domwri.F90 for ideas later)
+
+
+     !---------------------------------------------------------
+     ! 5.  Coarse grid ocean volume and averaging weights
+     !---------------------------------------------------------
+     !CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
+     !CALL ldf_tra_crs_init
+     !CALL dom_grid_glo   ! Return to parent grid domain
+
+
+     !
+     !---------------------------------------------------------
+     ! 6.  Write out coarse meshmask  (see OPA_SRC/DOM/domwri.F90 for ideas later)
      !---------------------------------------------------------
 
@@ -300,4 +297,5 @@
      CALL wrk_dealloc(jpi, jpj, jpk, zfse3t, zfse3u, zfse3v, zfse3w )
 
+      IF( nn_timing == 1 )  CALL timing_stop('crs_init')
 
    END SUBROUTINE crs_init
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 5601)
@@ -438,5 +438,5 @@
       ENDIF
 
-      IF( nn_timing == 1 )   CALL timing_start('dia_fwb')
+      IF( nn_timing == 1 )   CALL timing_stop('dia_fwb')
 
  9005 FORMAT(1X,A,ES24.16)
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 5601)
@@ -143,5 +143,5 @@
 
       IF( lk_vvl ) THEN
-         z3d(:,:,:) = tsn(:,:,:,jp_tem) * fse3t_n(:,:,:)
+         z3d(:,:,:) = tsn(:,:,:,jp_tem) !cbr * fse3t_n(:,:,:)
          CALL iom_put( "toce" , z3d                        )   ! heat content
          DO jj = 1, jpj
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5601)
@@ -525,5 +525,5 @@
             !
          ENDIF
-         IF( ln_zps .OR. ln_sco )   THEN              ! zps or sco : read meter bathymetry
+         IF( ln_zps .OR. ln_sco .OR. ln_zco )   THEN              ! zps or sco : read meter bathymetry
             CALL iom_open ( 'bathy_meter.nc', inum ) 
             CALL iom_get  ( inum, jpdom_data, 'Bathymetry', bathy )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 5601)
@@ -629,8 +629,8 @@
             SELECT CASE ( cd_type)
             CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
-               pt3dl(:, 1  ,jk) = 0.e0
-               pt3dl(:,ijpj,jk) = 0.e0
+               pt3dl(:, 1  ,:) = 0.e0
+               pt3dl(:,ijpj,:) = 0.e0
             CASE ( 'F' )                               ! F-point
-               pt3dl(:,ijpj,jk) = 0.e0
+               pt3dl(:,ijpj,:) = 0.e0
             END SELECT
             !
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90	(revision 5601)
@@ -253,6 +253,4 @@
             DO ji = 2, jpni
                iimppt(ji,jj) = iimppt(ji-1,jj) + ilcit(ji-1,jj) - nreci
-               !cbr 
-               WRITE(narea+200,*)"iimppt",ji,jj,ilcit(ji-1,jj),nreci,iimppt(ji-1,jj),iimppt(ji,jj)
             END DO
          END DO
@@ -367,8 +365,4 @@
       nimpp  = nimppt(narea)  
       njmpp  = njmppt(narea)  
-      WRITE(narea+200,*)"jpi,jpj,nlci,nlcj,nldi,nldj,nlei,nlej"
-      WRITE(narea+200,*)jpi,jpj,nlci,nlcj,nldi,nldj,nlei,nlej ; call flush(narea+200) !cbr 
-      WRITE(narea+200,*)"nldi+nimpp-1,nldj+njmpp-1,nlei+nimpp-1,nlej+njmpp-1" ; call flush(narea+200) !cbr
-      WRITE(narea+200,*)nldi+nimpp-1,nldj+njmpp-1,nlei+nimpp-1,nlej+njmpp-1 ; call flush(narea+200) !cbr
 
      ! Save processor layout in layout.dat file 
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 5601)
@@ -196,5 +196,4 @@
          ii = 1 + MOD(jarea-1,jpni)
          ij = 1 +    (jarea-1)/jpni
-         write(narea+200,*)"mppini_2  ====== > ",jarea,ii,ij
          ili = ilci(ii,ij)
          ilj = ilcj(ii,ij)
@@ -207,10 +206,8 @@
          IF( MOD(jarea,jpni) == 0 )   ibondi(ii,ij) =  1
          IF( jpni            == 1 )   ibondi(ii,ij) =  2
-         write(narea+200,*)"titi",jarea,ii,ij,MOD(jarea,jpni),ibondi(ii,ij) ; call flush(narea+200)
          ! 2.4 Subdomain neighbors
 
          iproc = jarea - 1
          ioso(ii,ij) = iproc - jpni
-         write(narea+200,*)"mppini_2 0: ",ii,ij,iproc,jpni,ioso(ii,ij) ; call flush(narea+200)
          iowe(ii,ij) = iproc - 1
          ioea(ii,ij) = iproc + 1
@@ -281,5 +278,4 @@
             ENDIF
          ENDIF
-         write(narea+200,*)"titi",jarea,ibondi(ii,ij) ; call flush(narea+200)
          ipolj(ii,ij) = 0
          IF( jperio == 3 .OR. jperio == 4 ) THEN
@@ -311,5 +307,4 @@
             ibonit(icont+1) = ibondi(ii,ij)
             ibonjt(icont+1) = ibondj(ii,ij)
-            write(narea+200,*)"titi 1 ",icont+1,ibonit(icont+1) ; call flush(narea+200)
          ENDIF
       END DO
@@ -424,10 +419,8 @@
       ii = iin(narea)
       ij = ijn(narea)
-      write(narea+200,*)"mppini_2 a ",noso,ii,ij,ioso(ii,ij),jpni*jpnj-1 ; call flush(narea+200)
       IF( ioso(ii,ij) >= 0 .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN 
          iiso = 1 + MOD(ioso(ii,ij),jpni)
          ijso = 1 +    (ioso(ii,ij))/jpni
          noso = ipproc(iiso,ijso)
-         write(narea+200,*)"mppini_2 b ",iiso,ijso,noso  ; call flush(narea+200)
       ELSE
          noso = -1
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 5601)
@@ -35,4 +35,5 @@
    USE timing         ! Timing
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
+   USE iom
 
    IMPLICIT NONE
@@ -230,4 +231,5 @@
          END DO
          CALL lbc_lnk( zwz, 'U', -1. )   ;   CALL lbc_lnk( zww, 'V', -1. )      ! lateral boundary conditions
+
          !
          !                                            !* horizontal Shapiro filter
@@ -445,4 +447,12 @@
 
       ENDIF
+
+      CALL iom_put("zgru",zgru)
+      CALL iom_put("zgrv",zgrv)
+      CALL iom_put("zdzr",zdzr)
+      CALL iom_put("zwz",zwz)
+      CALL iom_put("zww",zww)
+      CALL iom_put("uslp",uslp)
+      CALL iom_put("vslp",vslp)
       
       CALL wrk_dealloc( jpi,jpj,jpk, zwz, zww, zdzr, zgru, zgrv )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp_crs.F90	(revision 5601)
@@ -21,6 +21,6 @@
    !!   ldf_slp_init : initialization of the slopes computation
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
- !  USE dom_oce         ! ocean space and time domain
+   !USE oce             ! ocean dynamics and tracers
+   !USE dom_oce         ! ocean space and time domain
    USE ldftra_oce      ! lateral diffusion: traceur
    USE ldfdyn_oce      ! lateral diffusion: dynamics
@@ -34,4 +34,5 @@
    USE timing          ! Timing
    USE crs
+   USE iom
 
    IMPLICIT NONE
@@ -45,6 +46,4 @@
    !                                                                             !! Madec operator
    !  Arrays allocated in ldf_slp_init() routine once we know whether we're using the Griffies or Madec operator
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   uslp_crs, wslpi_crs          !: i_slope at U- and W-points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   vslp_crs, wslpj_crs          !: j-slope at V- and W-points
    !                                                                !! Griffies operator
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   wslp2                !: wslp**2 from Griffies quarter cells
@@ -113,5 +112,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('ldf_slp')
+      IF( nn_timing == 1 )  CALL timing_start('ldf_slp_crs')
       !
       CALL wrk_alloc( jpi_crs,jpj_crs,jpk, zwz, zww, zdzr, zgru, zgrv )
@@ -126,6 +125,6 @@
       !
       DO jk = 1, jpk             !==   i- & j-gradient of density   ==!
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1   ! vector opt.
                zgru(ji,jj,jk) = umask_crs(ji,jj,jk) * ( prd(ji+1,jj  ,jk) - prd(ji,jj,jk) )
                zgrv(ji,jj,jk) = vmask_crs(ji,jj,jk) * ( prd(ji  ,jj+1,jk) - prd(ji,jj,jk) )
@@ -134,11 +133,6 @@
       END DO
       IF( ln_zps ) THEN                           ! partial steps correction at the bottom ocean level
-# if defined key_vectopt_loop
-         DO jj = 1, 1
-            DO ji = 1, jpij-jpi   ! vector opt. (forced unrolling)
-# else
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-# endif
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1
                zgru(ji,jj,mbku_crs(ji,jj)) = gru_crs(ji,jj)
                zgrv(ji,jj,mbkv_crs(ji,jj)) = grv_crs(ji,jj)
@@ -146,14 +140,12 @@
          END DO
       ENDIF
-!WRITE(numout,*) ' zgrv (ji,jj,jk-1)' , zgrv (:,:,:)
-!WRITE(numout,*) ' grv_crs (ji,jj,jk-1)'  ,grv_crs (:,:)
       !
       zdzr(:,:,1) = 0._wp        !==   Local vertical density gradient at T-point   == !   (evaluated from N^2)
       DO jk = 2, jpkm1
          !                               !   trick: tmask(ik  )  = 0   =>   all pn2   = 0   =>   zdzr = 0
-         !                                !    else  tmask(ik+1)  = 0   =>   pn2(ik+1) = 0   =>   zdzr divides by 1
-         !                                    ! zdzr = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
-         !                             !          umask(ik+1) /= 0   =>   all pn2  /= 0   =>   zdzr divides by 2
-         !                                ! NB: 1/(tmask+1) = (1-.5*tmask)  substitute a / by a *  ==> faster
+         !                               !    else  tmask(ik+1)  = 0   =>   pn2(ik+1) = 0   =>   zdzr divides by 1
+         !                               ! zdzr = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+         !                               !          umask(ik+1) /= 0   =>   all pn2  /= 0   =>   zdzr divides by 2
+         !                               ! NB: 1/(tmask+1) = (1-.5*tmask)  substitute a / by a *  ==> faster
          zdzr(:,:,jk) = zm1_g * ( prd(:,:,jk) + 1._wp )              &
             &                 * ( pn2(:,:,jk) + pn2(:,:,jk+1) ) * ( 1._wp - 0.5_wp * tmask_crs(:,:,jk+1) )
@@ -163,11 +155,10 @@
       CALL ldf_slp_mxl_crs( prd, pn2, zgru, zgrv, zdzr )        ! output: uslpml, vslpml, wslpiml, wslpjml
 
-
       ! I.  slopes at u and v point      | uslp = d/di( prd ) / d/dz( prd )
       ! ===========================      | vslp = d/dj( prd ) / d/dz( prd )
       !
       DO jk = 2, jpkm1                            !* Slopes at u and v points
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 2, jpj_crsm1
+            DO ji = 2, jpi_crsm1   ! vector opt.
                !                                      ! horizontal and vertical density gradient at u- and v-points
                zau = zgru(ji,jj,jk) / e1u_crs(ji,jj)
@@ -177,13 +168,8 @@
                !                                      ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
                !                                      ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
-     !IF( umask_crs(ji,jj,jk) .NE. 0._wp .AND. e3u_max_crs(ji,jj,jk)==0._wp )WRITE(narea+3000,*)"bug zbu ",umask_crs(ji,jj,jk),e3u_max_crs(ji,jj,jk) ; CALL flush(narea+3000)
-     !IF( e3u_max_crs(ji,jj,jk)==0._wp )WRITE(narea+3000,*)"bug zbu1 ",ji,jj,jk,umask_crs(ji,jj,jk),e3u_max_crs(ji,jj,jk) ; CALL flush(narea+3000)
                zbu = MIN(  zbu, -100._wp* ABS( zau ) , -7.e+3_wp/e3u_max_crs(ji,jj,jk)* ABS( zau )  )
                zbv = MIN(  zbv, -100._wp* ABS( zav ) , -7.e+3_wp/e3v_max_crs(ji,jj,jk)* ABS( zav )  )
-                  
-!cc               zbu = MIN(  zbu, -100._wp* ABS( zau ) , -7.e+3_wp/e3u_crs(ji,jj,jk)* ABS( zau )  )
-!cc               zbv = MIN(  zbv, -100._wp* ABS( zav ) , -7.e+3_wp/e3v_crs(ji,jj,jk)* ABS( zav )  )
-
-
+               !cc zbu = MIN(  zbu, -100._wp* ABS( zau ) , -7.e+3_wp/e3u_crs(ji,jj,jk)* ABS( zau )  )
+               !cc zbv = MIN(  zbv, -100._wp* ABS( zav ) , -7.e+3_wp/e3v_crs(ji,jj,jk)* ABS( zav )  )
                !                                      ! uslp and vslp output in zwz and zww, resp.
                zfi = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj,jk) )
@@ -210,9 +196,11 @@
       END DO
       CALL crs_lbc_lnk( zwz, 'U', -1. )   ;   CALL crs_lbc_lnk( zww, 'V', -1. )      ! lateral boundary conditions
+      CALL iom_put("zwz_crs",zwz)
+      CALL iom_put("zww_crs",zww)
       !
       !                                            !* horizontal Shapiro filter
       DO jk = 2, jpkm1
-         DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
-            DO ji = 2, jpim1
+         DO jj = 2, jpj_crsm1, MAX(1, jpj_crs-3)                        ! rows jj=2 and =jpjm1 only
+            DO ji = 2, jpi_crsm1
                uslp_crs(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
                   &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
@@ -227,6 +215,6 @@
             END DO
          END DO
-         DO jj = 3, jpj-2                               ! other rows
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 3, jpj_crs-2                               ! other rows
+            DO ji = 2, jpi_crsm1   ! vector opt.
                uslp_crs(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
                   &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
@@ -242,6 +230,6 @@
          END DO
          !                                        !* decrease along coastal boundaries
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 2, jpj_crsm1
+            DO ji = 2, jpi_crsm1   ! vector opt.
                uslp_crs(ji,jj,jk) = uslp_crs(ji,jj,jk) * ( umask_crs(ji,jj+1,jk) + umask_crs(ji,jj-1,jk  ) ) * 0.5_wp   &
                   &                            * ( umask_crs(ji,jj  ,jk) + umask_crs(ji,jj  ,jk+1) ) * 0.5_wp
@@ -257,6 +245,6 @@
       !
       DO jk = 2, jpkm1
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 2, jpj_crsm1
+            DO ji = 2, jpi_crsm1   ! vector opt.
                !                                  !* Local vertical density gradient evaluated from N^2
                zbw = zm1_2g * pn2 (ji,jj,jk) * ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. )
@@ -281,10 +269,4 @@
                zwz(ji,jj,jk) = (  zai / ( zbi - zeps ) * ( 1._wp - zfk ) + zck * wslpiml(ji,jj) * zfk  ) * tmask_crs(ji,jj,jk)
                zww(ji,jj,jk) = (  zaj / ( zbj - zeps ) * ( 1._wp - zfk ) + zck * wslpjml(ji,jj) * zfk  ) * tmask_crs(ji,jj,jk)
-!WRITE(numout,*) ' wslpiml(ji,jj)' , wslpiml(ji,jj)
-!WRITE(numout,*) ' zbj' , zbj
-!WRITE(numout,*) ' zeps' , zeps
-!WRITE(numout,*) ' zaj' , zaj
-
-
 !!gm  modif to suppress omlmask....  (as in Griffies operator)
 !               !                                         ! jk must be >= ML level for zfk=1. otherwise  zfk=0.
@@ -301,6 +283,6 @@
       !                                           !* horizontal Shapiro filter
       DO jk = 2, jpkm1
-         DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
-            DO ji = 2, jpim1
+         DO jj = 2, jpj_crsm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
+            DO ji = 2, jpi_crsm1
                zcofw = tmask_crs(ji,jj,jk) * z1_16
                wslpi_crs(ji,jj,jk) = (      zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
@@ -317,6 +299,6 @@
             END DO
          END DO
-         DO jj = 3, jpj-2                               ! other rows
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 3, jpj_crs-2                               ! other rows
+            DO ji = 2, jpi_crsm1   ! vector opt.
                zcofw = tmask_crs(ji,jj,jk) * z1_16
                wslpi_crs(ji,jj,jk) = (      zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
@@ -334,6 +316,6 @@
          END DO
          !                                        !* decrease along coastal boundaries
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
+         DO jj = 2, jpj_crsm1
+            DO ji = 2, jpi_crsm1   ! vector opt.
                zck =   ( umask_crs(ji,jj,jk) + umask_crs(ji-1,jj,jk) )   &
                   &  * ( vmask_crs(ji,jj,jk) + vmask_crs(ji,jj-1,jk) ) * 0.25
@@ -344,281 +326,25 @@
       END DO
 
-      ! III.  Specific grid points
-      ! ===========================
- !! cc     !
- !     IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN     !  ORCA_R4 configuration: horizontal diffusion in specific area
- !        !                                                    ! Gibraltar Strait
- !        ij0 =  50   ;   ij1 =  53
- !        ii0 =  69   ;   ii1 =  71   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ij0 =  51   ;   ij1 =  53
- !        ii0 =  68   ;   ii1 =  71   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ii0 =  69   ;   ii1 =  71   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ii0 =  69   ;   ii1 =  71   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        !
- !        !                                                    ! Mediterrannean Sea
- !        ij0 =  49   ;   ij1 =  56
- !        ii0 =  71   ;   ii1 =  90   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ij0 =  50   ;   ij1 =  56
- !        ii0 =  70   ;   ii1 =  90   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ii0 =  71   ;   ii1 =  90   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !        ii0 =  71   ;   ii1 =  90   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
- !     ENDIF
-!! cc
-
       ! IV. Lateral boundary conditions
       ! ===============================
-      CALL crs_lbc_lnk( uslp_crs , 'U', -1. )      ;      CALL crs_lbc_lnk( vslp_crs , 'V', -1. )
+      CALL crs_lbc_lnk( uslp_crs , 'U', -1. )      
+      CALL crs_lbc_lnk( vslp_crs , 'V', -1. )
       CALL crs_lbc_lnk( wslpi_crs, 'W', -1. )      ;      CALL crs_lbc_lnk( wslpj_crs, 'W', -1. )
-!WRITE(numout,*) ' zww' , zww(:,:,:)
-!WRITE(numout,*) ' wslpj_crs' , wslpj_crs(:,:,:)
-  !    IF(ln_ctl) THEN
-  !       CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk)
-  !      CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk)
-  !    ENDIF
-      !
-      CALL wrk_dealloc( jpi,jpj,jpk, zwz, zww, zdzr, zgru, zgrv )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldf_slp')
+      !
+      CALL iom_swap( "nemo_crs" )    ! swap on the coarse grid
+      CALL iom_put("zgru_crs",zgru)
+      CALL iom_put("zgrv_crs",zgrv)
+      CALL iom_put("zdzr_crs",zdzr)
+      CALL iom_put("zwz_crs",zwz)
+      CALL iom_put("zww_crs",zww)
+      CALL iom_put("uslp_crs",uslp_crs)
+      CALL iom_put("vslp_crs",vslp_crs)
+      CALL iom_swap( "nemo" )    ! swap on the coarse grid
+      !
+      CALL wrk_dealloc( jpi_crs,jpj_crs,jpk, zwz, zww, zdzr, zgru, zgrv )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_crs')
       !
    END SUBROUTINE ldf_slp_crs
-
-
-   SUBROUTINE ldf_slp_grif_crs ( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldf_slp_grif  ***
-      !!
-      !! ** Purpose :   Compute the squared slopes of neutral surfaces (slope
-      !!      of iso-pycnal surfaces referenced locally) (ln_traldf_grif=T)
-      !!      at W-points using the Griffies quarter-cells.
-      !!
-      !! ** Method  :   calculates alpha and beta at T-points
-      !!
-      !! ** Action : - triadi_g, triadj_g   T-pts i- and j-slope triads relative to geopot. (used for eiv)
-      !!             - triadi , triadj    T-pts i- and j-slope triads relative to model-coordinate
-      !!             - wslp2              squared slope of neutral surfaces at w-points.
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt             ! ocean time-step index
-      !!
-      INTEGER  ::   ji, jj, jk, jl, ip, jp, kp  ! dummy loop indices
-      INTEGER  ::   iku, ikv                    ! local integer
-      REAL(wp) ::   zfacti, zfactj              ! local scalars
-      REAL(wp) ::   znot_thru_surface           ! local scalars
-      REAL(wp) ::   zdit, zdis, zdjt, zdjs, zdkt, zdks, zbu, zbv, zbti, zbtj
-      REAL(wp) ::   zdxrho_raw, zti_coord, zti_raw, zti_lim, zti_g_raw, zti_g_lim
-      REAL(wp) ::   zdyrho_raw, ztj_coord, ztj_raw, ztj_lim, ztj_g_raw, ztj_g_lim
-      REAL(wp) ::   zdzrho_raw
-      REAL(wp) ::   zbeta0
-      REAL(wp), POINTER, DIMENSION(:,:)     ::   z1_mlbw
-      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalbet
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zdxrho , zdyrho, zdzrho     ! Horizontal and vertical density gradients
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zti_mlb, ztj_mlb            ! for Griffies operator only
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ldf_slp_grif')
-      !
-      CALL wrk_alloc( jpi,jpj, z1_mlbw )
-      CALL wrk_alloc( jpi,jpj,jpk, zalbet )
-      CALL wrk_alloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
-      CALL wrk_alloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
-      !
-      !--------------------------------!
-      !  Some preliminary calculation  !
-      !--------------------------------!
-      !
-      CALL eos_alpbet_crs( tsb_crs, zalbet, zbeta0 )  !==  before local thermal/haline expension ratio at T-points  ==!
-      !
-      DO jl = 0, 1                            !==  unmasked before density i- j-, k-gradients  ==!
-         !
-         ip = jl   ;   jp = jl                ! guaranteed nonzero gradients ( absolute value larger than repsln)
-         DO jk = 1, jpkm1                     ! done each pair of triad
-            DO jj = 1, jpjm1                  ! NB: not masked ==>  a minimum value is set
-               DO ji = 1, fs_jpim1            ! vector opt.
-                  zdit = ( tsb(ji+1,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )    ! i-gradient of T & S at u-point
-                  zdis = ( tsb(ji+1,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  zdjt = ( tsb(ji,jj+1,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )    ! j-gradient of T & S at v-point
-                  zdjs = ( tsb(ji,jj+1,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  zdxrho_raw = ( - zalbet(ji+ip,jj   ,jk) * zdit + zbeta0*zdis ) / e1u(ji,jj)
-                  zdyrho_raw = ( - zalbet(ji   ,jj+jp,jk) * zdjt + zbeta0*zdjs ) / e2v(ji,jj)
-                  zdxrho(ji+ip,jj   ,jk,1-ip) = SIGN( MAX(   repsln, ABS( zdxrho_raw ) ), zdxrho_raw )   ! keep the sign
-                  zdyrho(ji   ,jj+jp,jk,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw )
-               END DO
-            END DO
-         END DO
-         !
-         IF( ln_zps.and.l_grad_zps ) THEN     ! partial steps: correction of i- & j-grad on bottom
-# if defined key_vectopt_loop
-            DO jj = 1, 1
-               DO ji = 1, jpij-jpi            ! vector opt. (forced unrolling)
-# else
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-# endif
-                  iku  = mbku_crs(ji,jj)          ;   ikv  = mbkv_crs(ji,jj)             ! last ocean level (u- & v-points)
-                  zdit = gtsu_crs(ji,jj,jp_tem)   ;   zdjt = gtsv_crs(ji,jj,jp_tem)      ! i- & j-gradient of Temperature
-                  zdis = gtsu_crs(ji,jj,jp_sal)   ;   zdjs = gtsv_crs(ji,jj,jp_sal)      ! i- & j-gradient of Salinity
-                  zdxrho_raw = ( - zalbet(ji+ip,jj   ,iku) * zdit + zbeta0*zdis ) / e1u(ji,jj)
-                  zdyrho_raw = ( - zalbet(ji   ,jj+jp,ikv) * zdjt + zbeta0*zdjs ) / e2v(ji,jj)
-                  zdxrho(ji+ip,jj   ,iku,1-ip) = SIGN( MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw )   ! keep the sign
-                  zdyrho(ji   ,jj+jp,ikv,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw )
-               END DO
-            END DO
-         ENDIF
-         !
-      END DO
-
-      DO kp = 0, 1                            !==  unmasked before density i- j-, k-gradients  ==!
-         DO jk = 1, jpkm1                     ! done each pair of triad
-            DO jj = 1, jpj                    ! NB: not masked ==>  a minimum value is set
-               DO ji = 1, jpi                 ! vector opt.
-                  IF( jk+kp > 1 ) THEN        ! k-gradient of T & S a jk+kp
-                     zdkt = ( tsb(ji,jj,jk+kp-1,jp_tem) - tsb(ji,jj,jk+kp,jp_tem) )
-                     zdks = ( tsb(ji,jj,jk+kp-1,jp_sal) - tsb(ji,jj,jk+kp,jp_sal) )
-                  ELSE
-                     zdkt = 0._wp                                             ! 1st level gradient set to zero
-                     zdks = 0._wp
-                  ENDIF
-                  zdzrho_raw = ( - zalbet(ji   ,jj   ,jk) * zdkt + zbeta0*zdks ) / fse3w(ji,jj,jk+kp)
-                  zdzrho(ji   ,jj   ,jk,  kp) =     - MIN( - repsln,      zdzrho_raw )    ! force zdzrho >= repsln
-                 END DO
-            END DO
-         END DO
-      END DO
-      !
-      DO jj = 1, jpj                          !==  Reciprocal depth of the w-point below ML base  ==!
-         DO ji = 1, jpi
-            jk = MIN( nmln_crs(ji,jj), mbkt_crs(ji,jj) ) + 1     ! MIN in case ML depth is the ocean depth
-            z1_mlbw(ji,jj) = 1._wp / gdepw_crs(ji,jj,jk)
-         END DO
-      END DO
-      !
-      !                                       !==  intialisations to zero  ==!
-      !
-      wslp2  (:,:,:)     = 0._wp              ! wslp2 will be cumulated 3D field set to zero
-      triadi_g(:,:,1,:,:) = 0._wp   ;   triadi_g(:,:,jpk,:,:) = 0._wp   ! set surface and bottom slope to zero
-      triadj_g(:,:,1,:,:) = 0._wp   ;   triadj_g(:,:,jpk,:,:) = 0._wp
-      !!gm _iso set to zero missing
-      triadi  (:,:,1,:,:) = 0._wp   ;   triadj  (:,:,jpk,:,:) = 0._wp   ! set surface and bottom slope to zero
-      triadj  (:,:,1,:,:) = 0._wp   ;   triadj  (:,:,jpk,:,:) = 0._wp
-
-      !-------------------------------------!
-      !  Triads just below the Mixed Layer  !
-      !-------------------------------------!
-      !
-      DO jl = 0, 1                            ! calculate slope of the 4 triads immediately ONE level below mixed-layer base
-         DO kp = 0, 1                         ! with only the slope-max limit   and   MASKED
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  ip = jl   ;   jp = jl
-                  jk = MIN( nmln_crs(ji+ip,jj) , mbkt_crs(ji+ip,jj) ) + 1         ! ML level+1 (MIN in case ML depth is the ocean depth)
-                  ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
-                  zti_g_raw = (  zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp)      &
-                     &      - ( gdept_crs(ji+1,jj,jk-kp) - gdept_crs(ji,jj,jk-kp) ) / e1u_crs(ji,jj)  ) * umask_crs(ji,jj,jk)
-                  jk = MIN( nmln_crs(ji,jj+jp) , mbkt_crs(ji,jj+jp) ) + 1
-                  ztj_g_raw = (  zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp)      &
-                     &      - ( gdept_crs(ji,jj+1,jk-kp) - gdept_crs(ji,jj,jk-kp) ) / e2v_crs(ji,jj)  ) * vmask_crs(ji,jj,jk)
-                  zti_mlb(ji+ip,jj   ,1-ip,kp) = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
-                  ztj_mlb(ji   ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
-               END DO
-            END DO
-         END DO
-      END DO
-
-      !-------------------------------------!
-      !  Triads with surface limits         !
-      !-------------------------------------!
-      !
-      DO kp = 0, 1                            ! k-index of triads
-         DO jl = 0, 1
-            ip = jl   ;   jp = jl             ! i- and j-indices of triads (i-k and j-k planes)
-            DO jk = 1, jpkm1
-               ! Must mask contribution to slope from dz/dx at constant s for triads jk=1,kp=0 that poke up though ocean surface
-               znot_thru_surface = REAL( 1-1/(jk+kp), wp )  !jk+kp=1,=0.; otherwise=1.0
-               DO jj = 1, jpjm1
-                  DO ji = 1, fs_jpim1         ! vector opt.
-                     !
-                     ! Calculate slope relative to geopotentials used for GM skew fluxes
-                     ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
-                     ! Limit by slope *relative to geopotentials* by rn_slpmax, and mask by psi-point
-                     ! masked by umask taken at the level of dz(rho)
-                     !
-                     ! raw slopes: unmasked unbounded slopes (relative to geopotential (zti_g) and model surface (zti)
-                     !
-                     zti_raw   = zdxrho(ji+ip,jj   ,jk,1-ip) / zdzrho(ji+ip,jj   ,jk,kp)                   ! unmasked
-                     ztj_raw   = zdyrho(ji   ,jj+jp,jk,1-jp) / zdzrho(ji   ,jj+jp,jk,kp)
-
-                     ! Must mask contribution to slope for triad jk=1,kp=0 that poke up though ocean surface
-                     zti_coord = znot_thru_surface * ( gdept_crs(ji+1,jj  ,jk) - gdept_crs(ji,jj,jk) ) / e1u_crs(ji,jj)
-                     ztj_coord = znot_thru_surface * ( gdept_crs(ji  ,jj+1,jk) - gdept_crs(ji,jj,jk) ) / e2v_crs(ji,jj)                  ! unmasked
-                     zti_g_raw = zti_raw - zti_coord      ! ref to geopot surfaces
-                     ztj_g_raw = ztj_raw - ztj_coord
-                     zti_g_lim = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
-                     ztj_g_lim = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
-                     !
-                     ! Below  ML use limited zti_g as is & mask
-                     ! Inside ML replace by linearly reducing sx_mlb towards surface & mask
-                     !
-                     zfacti = REAL( 1 - 1/(1 + (jk+kp-1)/nmln_crs(ji+ip,jj)), wp )  ! k index of uppermost point(s) of triad is jk+kp-1
-                     zfactj = REAL( 1 - 1/(1 + (jk+kp-1)/nmln_crs(ji,jj+jp)), wp )  ! must be .ge. nmln(ji,jj) for zfact=1
-                     !                                                          !                   otherwise  zfact=0
-                     zti_g_lim =          ( zfacti   * zti_g_lim                       &
-                        &      + ( 1._wp - zfacti ) * zti_mlb(ji+ip,jj,1-ip,kp)   &
-                        &                           * fsdepw(ji+ip,jj,jk+kp) * z1_mlbw(ji+ip,jj) ) * umask_crs(ji,jj,jk+kp)
-                     ztj_g_lim =          ( zfactj   * ztj_g_lim                       &
-                        &      + ( 1._wp - zfactj ) * ztj_mlb(ji,jj+jp,1-jp,kp)   &
-                        &                           * fsdepw(ji,jj+jp,jk+kp) * z1_mlbw(ji,jj+jp) ) * vmask_crs(ji,jj,jk+kp)
-                     !
-                     triadi_g(ji+ip,jj   ,jk,1-ip,kp) = zti_g_lim
-                     triadj_g(ji   ,jj+jp,jk,1-jp,kp) = ztj_g_lim
-                     !
-                     ! Get coefficients of isoneutral diffusion tensor
-                     ! 1. Utilise gradients *relative* to s-coordinate, so add t-point slopes (*subtract* depth gradients)
-                     ! 2. We require that isoneutral diffusion  gives no vertical buoyancy flux
-                     !     i.e. 33 term = (real slope* 31, 13 terms)
-                     ! To do this, retain limited sx**2  in vertical flux, but divide by real slope for 13/31 terms
-                     ! Equivalent to tapering A_iso = sx_limited**2/(real slope)**2
-                     !
-                     zti_lim  = ( zti_g_lim + zti_coord ) * umask_crs(ji,jj,jk+kp)    ! remove coordinate slope => relative to coordinate surfaces
-                     ztj_lim  = ( ztj_g_lim + ztj_coord ) * vmask_crs(ji,jj,jk+kp)
-                     !
-                     IF( ln_triad_iso ) THEN
-                        zti_raw = zti_lim**2 / zti_raw
-                        ztj_raw = ztj_lim**2 / ztj_raw
-                        zti_raw = SIGN( MIN( ABS(zti_lim), ABS( zti_raw ) ), zti_raw )
-                        ztj_raw = SIGN( MIN( ABS(ztj_lim), ABS( ztj_raw ) ), ztj_raw )
-                        zti_lim =           zfacti   * zti_lim                       &
-                        &      + ( 1._wp - zfacti ) * zti_raw
-                        ztj_lim =           zfactj   * ztj_lim                       &
-                        &      + ( 1._wp - zfactj ) * ztj_raw
-                     ENDIF
-                     triadi(ji+ip,jj   ,jk,1-ip,kp) = zti_lim
-                     triadj(ji   ,jj+jp,jk,1-jp,kp) = ztj_lim
-                    !
-                     zbu = e1u(ji    ,jj) * e2u(ji   ,jj) * fse3u(ji   ,jj,jk   )
-                     zbv = e1v(ji    ,jj) * e2v(ji   ,jj) * fse3v(ji   ,jj,jk   )
-                     zbti = e1t(ji+ip,jj) * e2t(ji+ip,jj) * fse3w(ji+ip,jj,jk+kp)
-                     zbtj = e1t(ji,jj+jp) * e2t(ji,jj+jp) * fse3w(ji,jj+jp,jk+kp)
-                     !
-                     !!gm this may inhibit vectorization on Vect Computers, and even on scalar computers....  ==> to be checked
-                     wslp2 (ji+ip,jj,jk+kp) = wslp2(ji+ip,jj,jk+kp) + 0.25_wp * zbu / zbti * zti_g_lim**2      ! masked
-                     wslp2 (ji,jj+jp,jk+kp) = wslp2(ji,jj+jp,jk+kp) + 0.25_wp * zbv / zbtj * ztj_g_lim**2
-                  END DO
-               END DO
-            END DO
-         END DO
-      END DO
-      !
-      wslp2(:,:,1) = 0._wp                ! force the surface wslp to zero
-
-      CALL crs_lbc_lnk( wslp2, 'W', 1. )      ! lateral boundary confition on wslp2 only   ==>>> gm : necessary ? to be checked
-      !
-      CALL wrk_dealloc( jpi,jpj, z1_mlbw )
-      CALL wrk_dealloc( jpi,jpj,jpk, zalbet )
-      CALL wrk_dealloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
-      CALL wrk_dealloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_grif')
-      !
-   END SUBROUTINE ldf_slp_grif_crs
-
 
    SUBROUTINE ldf_slp_mxl_crs( prd, pn2, p_gru, p_grv, p_dzr )
@@ -657,18 +383,13 @@
       zm1_2g = -0.5_wp / grav
       !
-      uslpml (1,:) = 0._wp      ;      uslpml (jpi,:) = 0._wp
-      vslpml (1,:) = 0._wp      ;      vslpml (jpi,:) = 0._wp
-      wslpiml(1,:) = 0._wp      ;      wslpiml(jpi,:) = 0._wp
-      wslpjml(1,:) = 0._wp      ;      wslpjml(jpi,:) = 0._wp
+      uslpml (1,:) = 0._wp      ;      uslpml (jpi_crs,:) = 0._wp
+      vslpml (1,:) = 0._wp      ;      vslpml (jpi_crs,:) = 0._wp
+      wslpiml(1,:) = 0._wp      ;      wslpiml(jpi_crs,:) = 0._wp
+      wslpjml(1,:) = 0._wp      ;      wslpjml(jpi_crs,:) = 0._wp
       !
       !                                            !==   surface mixed layer mask   !
       DO jk = 1, jpk                               ! =1 inside the mixed layer, =0 otherwise
-# if defined key_vectopt_loop
-         DO jj = 1, 1
-            DO ji = 1, jpij                        ! vector opt. (forced unrolling)
-# else
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-# endif
+         DO jj = 1, jpj_crs
+            DO ji = 1, jpi_crs
                ik = nmln_crs(ji,jj) - 1
                IF( jk <= ik ) THEN   ;   omlmask(ji,jj,jk) = 1._wp
@@ -690,11 +411,6 @@
       !-----------------------------------------------------------------------
       !
-# 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
+      DO jj = 2, jpj_crsm1
+         DO ji = 2, jpi_crsm1
             !                        !==   Slope at u- & v-points just below the Mixed Layer   ==!
             !
@@ -744,13 +460,4 @@
       !
       IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_mxl')
- !     WRITE(numout,*) ' uslp_crs' , MAXVAL(uslp_crs(:,:,:)) , MINVAL(uslp_crs(:,:,:))
- !     WRITE(numout,*) ' vslp_crs' , vslp_crs
- !     WRITE(numout,*) ' uslpml' , uslpml
- !     WRITE(numout,*) ' vslpml' , vslpml
- !     WRITE(numout,*) ' wslpiml' , wslpiml
- !     WRITE(numout,*) ' wslpjml' , wslpjml
-  !    WRITE(numout,*) ' wslpi_crs' , wslpi_crs(:,:,2)
-  !    WRITE(numout,*) ' wslpj_crs_mxl' , wslpj_crs(:,:,:)
-      
       !
    END SUBROUTINE ldf_slp_mxl_crs
@@ -774,11 +481,11 @@
       IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*) 'ldf_slp_init : direction of lateral mixing'
+         WRITE(numout,*) 'ldf_slp_init_crs : direction of lateral mixing'
          WRITE(numout,*) '~~~~~~~~~~~~'
       ENDIF
 
       IF( ln_traldf_grif ) THEN        ! Griffies operator : triad of slopes
-         ALLOCATE( triadi_g(jpi,jpj,jpk,0:1,0:1) , triadj_g(jpi,jpj,jpk,0:1,0:1) , wslp2(jpi,jpj,jpk) , STAT=ierr )
-         ALLOCATE( triadi  (jpi,jpj,jpk,0:1,0:1) , triadj  (jpi,jpj,jpk,0:1,0:1)                      , STAT=ierr )
+         ALLOCATE( triadi_g(jpi_crs,jpj_crs,jpk,0:1,0:1) , triadj_g(jpi_crs,jpj_crs,jpk,0:1,0:1) , wslp2(jpi_crs,jpj_crs,jpk) , STAT=ierr )
+         ALLOCATE( triadi  (jpi_crs,jpj_crs,jpk,0:1,0:1) , triadj  (jpi_crs,jpj_crs,jpk,0:1,0:1)                      , STAT=ierr )
          IF( ierr > 0             )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Griffies operator slope' )
          !
@@ -786,6 +493,6 @@
          !
       ELSE                             ! Madec operator : slopes at u-, v-, and w-points
-         ALLOCATE( uslp_crs(jpi,jpj,jpk) , vslp_crs(jpi,jpj,jpk) , wslpi_crs(jpi,jpj,jpk) , wslpj_crs(jpi,jpj,jpk) ,  &
-            &   omlmask(jpi,jpj,jpk) , uslpml(jpi,jpj)   , vslpml(jpi,jpj)    , wslpiml(jpi,jpj)   , wslpjml(jpi,jpj) , STAT=ierr )
+         ALLOCATE( uslp_crs(jpi_crs,jpj_crs,jpk) , vslp_crs(jpi_crs,jpj_crs,jpk) , wslpi_crs(jpi_crs,jpj_crs,jpk) , wslpj_crs(jpi_crs,jpj_crs,jpk) ,  &
+            &   omlmask(jpi_crs,jpj_crs,jpk) , uslpml(jpi_crs,jpj_crs)   , vslpml(jpi_crs,jpj_crs)    , wslpiml(jpi_crs,jpj_crs)   , wslpjml(jpi_crs,jpj_crs) , STAT=ierr )
          IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Madec operator slope ' )
 
@@ -807,10 +514,7 @@
             ! set the slope of diffusion to the slope of s-surfaces
             !      ( c a u t i o n : minus sign as fsdep has positive value )
-            !WRITE(narea+3000,*)"ldfslp ",MINVAL(gdept_crs),MAXVAL(gdept_crs)  ; call flush(narea+3000)
-            !WRITE(narea+3000,*)"ldfslp ",MINVAL(vmask_crs),MAXVAL(vmask_crs)  ; call flush(narea+3000)
-            !WRITE(narea+3000,*)"ldfslp ",MINVAL(e2v_crs),MAXVAL(e2v_crs) ; call flush(narea+3000)
             DO jk = 1, jpk
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
+               DO jj = 2, jpj_crsm1
+                  DO ji = 2, jpi_crsm1   ! vector opt.
                   !cbr uslp_crs (ji,jj,jk) = -1./e1u_crs(ji,jj) * ( gdept_crs(ji+1,jj,jk) - gdept_crs(ji ,jj ,jk) ) * umask_crs(ji,jj,jk)
                   !vslp_crs (ji,jj,jk) = -1./e2v_crs(ji,jj) * ( gdept_crs(ji,jj+1,jk) - gdept_crs(ji ,jj ,jk) ) * vmask_crs(ji,jj,jk)
@@ -832,5 +536,4 @@
          ENDIF
       ENDIF
-  !    WRITE(numout,*) ' wslpi_crs' , wslpi_crs
       !
       IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_init')
@@ -849,11 +552,12 @@
       WRITE(*,*) 'ldf_slp: You should not have seen this print! error?', kt, prd(1,1,1), pn2(1,1,1)
    END SUBROUTINE ldf_slp_crs
+   SUBROUTINE ldf_slp_init_crs              ! Dummy routine
+   END SUBROUTINE ldf_slp_init_crs
+#endif
+
    SUBROUTINE ldf_slp_grif_crs( kt )        ! Dummy routine
       INTEGER, INTENT(in) :: kt
       WRITE(*,*) 'ldf_slp_grif: You should not have seen this print! error?', kt
    END SUBROUTINE ldf_slp_grif_crs
-   SUBROUTINE ldf_slp_init_crs              ! Dummy routine
-   END SUBROUTINE ldf_slp_init_crs
-#endif
 
    !!======================================================================
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2_crs.F90	(revision 5601)
@@ -15,7 +15,11 @@
    !!             -   ! 2002-11  (G. Madec, A. Bozec)  partial step, eos_insitu_2d
    !!             -   ! 2003-08  (G. Madec)  F90, free form
-   !!            3.0  ! 2006-08  (G. Madec)  add tfreez function
+   !!            3.0  ! 2006-08  (G. Madec)  add tfreez function (now eos_fzp function)
    !!            3.3  ! 2010-05  (C. Ethe, G. Madec)  merge TRC-TRA
-   !!             -   ! 2010-10  (G. Nurser, G. Madec)  add eos_alpbet used in ldfslp
+   !!             -   ! 2010-10  (G. Nurser, G. Madec)  add alpha/beta used in ldfslp
+   !!            3.7  ! 2012-03  (F. Roquet, G. Madec)  add primitive of alpha and beta used in PE computation
+   !!             -   ! 2012-05  (F. Roquet)  add Vallis and original JM95 equation of state
+   !!             -   ! 2013-04  (F. Roquet, G. Madec)  add eos_rab, change bn2 computation and reorganize the module
+   !!             -   ! 2014-09  (F. Roquet)  add TEOS-10, S-EOS, and modify EOS-80
    !!----------------------------------------------------------------------
 
@@ -23,21 +27,24 @@
    !!   eos            : generic interface of the equation of state
    !!   eos_insitu     : Compute the in situ density
-   !!   eos_insitu_pot : Compute the insitu and surface referenced potential
-   !!                    volumic mass
+   !!   eos_insitu_pot : Compute the insitu and surface referenced potential volumic mass
    !!   eos_insitu_2d  : Compute the in situ density for 2d fields
-   !!   eos_bn2        : Compute the Brunt-Vaisala frequency
-   !!   eos_alpbet     : calculates the in situ thermal/haline expansion ratio
-   !!   tfreez         : Compute the surface freezing temperature
+   !!   bn2            : Compute the Brunt-Vaisala frequency
+   !!   eos_rab        : generic interface of in situ thermal/haline expansion ratio 
+   !!   eos_rab_3d     : compute in situ thermal/haline expansion ratio
+   !!   eos_rab_2d     : compute in situ thermal/haline expansion ratio for 2d fields
+   !!   eos_fzp_2d     : freezing temperature for 2d fields
+   !!   eos_fzp_0d     : freezing temperature for scalar
    !!   eos_init       : set eos parameters (namelist)
    !!----------------------------------------------------------------------
-   USE dom_oce         ! ocean space and time domain
+   USE crs         ! ocean space and time domain
    USE phycst          ! physical constants
-   USE zdfddm          ! vertical physics: double diffusion
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
+   !
+   !USE in_out_manager  ! I/O manager
+   !USE lib_mpp         ! MPP library
+   !USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
    USE prtctl          ! Print control
    USE wrk_nemo        ! Memory Allocation
+   USE crslbclnk         ! ocean lateral boundary conditions
    USE timing          ! Timing
-   USE crs
 
    IMPLICIT NONE
@@ -46,22 +53,111 @@
    !                   !! * Interface
    INTERFACE eos_crs
-      MODULE PROCEDURE eos_insitu_crs, eos_insitu_pot_crs, eos_insitu_2d_crs
+      MODULE PROCEDURE eos_insitu_pot , eos_insitu_2d
    END INTERFACE
-   INTERFACE bn2_crs
-      MODULE PROCEDURE eos_bn2_crs
+   !
+   INTERFACE eos_rab_crs
+      MODULE PROCEDURE rab_crs_3d, rab_crs_2d, rab_crs_0d
    END INTERFACE
-
+   !
    PUBLIC   eos_crs        ! called by step, istate, tranpc and zpsgrd modules
+   PUBLIC   bn2_crs        ! called by step module
+   PUBLIC   eos_rab_crs    ! called by ldfslp, zdfddm, trabbl
    PUBLIC   eos_init_crs   ! called by istate module
-   PUBLIC   bn2_crs        ! called by step module
-   PUBLIC   eos_alpbet_crs ! called by ldfslp module
-   PUBLIC   tfreez_crs     ! called by sbcice_... modules
 
    !                                          !!* Namelist (nameos) *
    INTEGER , PUBLIC ::   nn_eos   = 0         !: = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
-   REAL(wp), PUBLIC ::   rn_alpha = 2.0e-4_wp !: thermal expension coeff. (linear equation of state)
-   REAL(wp), PUBLIC ::   rn_beta  = 7.7e-4_wp !: saline  expension coeff. (linear equation of state)
-
-   REAL(wp), PUBLIC ::   ralpbet_crs              !: alpha / beta ratio
+   LOGICAL , PUBLIC ::   ln_useCT  = .FALSE.  ! determine if eos_pt_from_ct is used to compute sst_m
+
+   !                                   !!!  simplified eos coefficients
+   ! default value: Vallis 2006
+   REAL(wp) ::   rn_a0      = 1.6550e-1_wp     ! thermal expansion coeff. 
+   REAL(wp) ::   rn_b0      = 7.6554e-1_wp     ! saline  expansion coeff. 
+   REAL(wp) ::   rn_lambda1 = 5.9520e-2_wp     ! cabbeling coeff. in T^2        
+   REAL(wp) ::   rn_lambda2 = 5.4914e-4_wp     ! cabbeling coeff. in S^2        
+   REAL(wp) ::   rn_mu1     = 1.4970e-4_wp     ! thermobaric coeff. in T  
+   REAL(wp) ::   rn_mu2     = 1.1090e-5_wp     ! thermobaric coeff. in S  
+   REAL(wp) ::   rn_nu      = 2.4341e-3_wp     ! cabbeling coeff. in theta*salt  
+   
+   ! TEOS10/EOS80 parameters
+   REAL(wp) ::   r1_S0, r1_T0, r1_Z0, rdeltaS
+   
+   ! EOS parameters
+   REAL(wp) ::   EOS000 , EOS100 , EOS200 , EOS300 , EOS400 , EOS500 , EOS600
+   REAL(wp) ::   EOS010 , EOS110 , EOS210 , EOS310 , EOS410 , EOS510
+   REAL(wp) ::   EOS020 , EOS120 , EOS220 , EOS320 , EOS420
+   REAL(wp) ::   EOS030 , EOS130 , EOS230 , EOS330
+   REAL(wp) ::   EOS040 , EOS140 , EOS240
+   REAL(wp) ::   EOS050 , EOS150
+   REAL(wp) ::   EOS060
+   REAL(wp) ::   EOS001 , EOS101 , EOS201 , EOS301 , EOS401
+   REAL(wp) ::   EOS011 , EOS111 , EOS211 , EOS311
+   REAL(wp) ::   EOS021 , EOS121 , EOS221
+   REAL(wp) ::   EOS031 , EOS131
+   REAL(wp) ::   EOS041
+   REAL(wp) ::   EOS002 , EOS102 , EOS202
+   REAL(wp) ::   EOS012 , EOS112
+   REAL(wp) ::   EOS022
+   REAL(wp) ::   EOS003 , EOS103
+   REAL(wp) ::   EOS013 
+   
+   ! ALPHA parameters
+   REAL(wp) ::   ALP000 , ALP100 , ALP200 , ALP300 , ALP400 , ALP500
+   REAL(wp) ::   ALP010 , ALP110 , ALP210 , ALP310 , ALP410
+   REAL(wp) ::   ALP020 , ALP120 , ALP220 , ALP320
+   REAL(wp) ::   ALP030 , ALP130 , ALP230
+   REAL(wp) ::   ALP040 , ALP140
+   REAL(wp) ::   ALP050
+   REAL(wp) ::   ALP001 , ALP101 , ALP201 , ALP301
+   REAL(wp) ::   ALP011 , ALP111 , ALP211
+   REAL(wp) ::   ALP021 , ALP121
+   REAL(wp) ::   ALP031
+   REAL(wp) ::   ALP002 , ALP102
+   REAL(wp) ::   ALP012
+   REAL(wp) ::   ALP003
+   
+   ! BETA parameters
+   REAL(wp) ::   BET000 , BET100 , BET200 , BET300 , BET400 , BET500
+   REAL(wp) ::   BET010 , BET110 , BET210 , BET310 , BET410
+   REAL(wp) ::   BET020 , BET120 , BET220 , BET320
+   REAL(wp) ::   BET030 , BET130 , BET230
+   REAL(wp) ::   BET040 , BET140
+   REAL(wp) ::   BET050
+   REAL(wp) ::   BET001 , BET101 , BET201 , BET301
+   REAL(wp) ::   BET011 , BET111 , BET211
+   REAL(wp) ::   BET021 , BET121
+   REAL(wp) ::   BET031
+   REAL(wp) ::   BET002 , BET102
+   REAL(wp) ::   BET012
+   REAL(wp) ::   BET003
+
+   ! PEN parameters
+   REAL(wp) ::   PEN000 , PEN100 , PEN200 , PEN300 , PEN400
+   REAL(wp) ::   PEN010 , PEN110 , PEN210 , PEN310
+   REAL(wp) ::   PEN020 , PEN120 , PEN220
+   REAL(wp) ::   PEN030 , PEN130
+   REAL(wp) ::   PEN040
+   REAL(wp) ::   PEN001 , PEN101 , PEN201
+   REAL(wp) ::   PEN011 , PEN111
+   REAL(wp) ::   PEN021
+   REAL(wp) ::   PEN002 , PEN102
+   REAL(wp) ::   PEN012
+   
+   ! ALPHA_PEN parameters
+   REAL(wp) ::   APE000 , APE100 , APE200 , APE300
+   REAL(wp) ::   APE010 , APE110 , APE210
+   REAL(wp) ::   APE020 , APE120
+   REAL(wp) ::   APE030
+   REAL(wp) ::   APE001 , APE101
+   REAL(wp) ::   APE011
+   REAL(wp) ::   APE002
+
+   ! BETA_PEN parameters
+   REAL(wp) ::   BPE000 , BPE100 , BPE200 , BPE300
+   REAL(wp) ::   BPE010 , BPE110 , BPE210
+   REAL(wp) ::   BPE020 , BPE120
+   REAL(wp) ::   BPE030
+   REAL(wp) ::   BPE001 , BPE101
+   REAL(wp) ::   BPE011
+   REAL(wp) ::   BPE002
 
    !! * Substitutions
@@ -69,137 +165,11 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id: eosbn2.F90 3294 2012-01-28 16:44:18Z rblod $
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id: eosbn2.F90 4990 2014-12-15 16:42:49Z timgraham $
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
 
-   SUBROUTINE eos_insitu_crs( pts, prd )
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE eos_insitu  ***
-      !!
-      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from
-      !!       potential temperature and salinity using an equation of state
-      !!       defined through the namelist parameter nn_eos.
-      !!
-      !! ** Method  :   3 cases:
-      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
-      !!         the in situ density is computed directly as a function of
-      !!         potential temperature relative to the surface (the opa t
-      !!         variable), salt and pressure (assuming no pressure variation
-      !!         along geopotential surfaces, i.e. the pressure p in decibars
-      !!         is approximated by the depth in meters.
-      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
-      !!         with pressure                      p        decibars
-      !!              potential temperature         t        deg celsius
-      !!              salinity                      s        psu
-      !!              reference volumic mass        rau0     kg/m**3
-      !!              in situ volumic mass          rho      kg/m**3
-      !!              in situ density anomalie      prd      no units
-      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
-      !!          t = 40 deg celcius, s=40 psu
-      !!      nn_eos = 1 : linear equation of state function of temperature only
-      !!              prd(t) = 0.0285 - rn_alpha * t
-      !!      nn_eos = 2 : linear equation of state function of temperature and
-      !!               salinity
-      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
-      !!      Note that no boundary condition problem occurs in this routine
-      !!      as pts are defined over the whole domain.
-      !!
-      !! ** Action  :   compute prd , the in situ density (no units)
-      !!
-      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
-      !!----------------------------------------------------------------------
-      !!
-      REAL(wp), DIMENSION(:,:,:,:), INTENT(in   ) ::   pts   ! 1 : potential temperature  [Celcius]
-      !                                                      ! 2 : salinity               [psu]
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   prd   ! in situ density            [-]
-      !!
-      INTEGER  ::   ji, jj, jk           ! dummy loop indices
-      REAL(wp) ::   zt , zs , zh , zsr   ! local scalars
-      REAL(wp) ::   zr1, zr2, zr3, zr4   !   -      -
-      REAL(wp) ::   zrhop, ze, zbw, zb   !   -      -
-      REAL(wp) ::   zd , zc , zaw, za    !   -      -
-      REAL(wp) ::   zb1, za1, zkw, zk0   !   -      -
-      REAL(wp) ::   zrau0r               !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zws
-      !!----------------------------------------------------------------------
-
-      !
-      IF( nn_timing == 1 ) CALL timing_start('eos')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zws )
-      !
-      SELECT CASE( nn_eos )
-      !
-      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
-         zrau0r = 1.e0 / rau0
-!CDIR NOVERRCHK
-         zws(:,:,:) = SQRT( ABS( pts(:,:,:,jp_sal) ) )
-         !
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zt = pts   (ji,jj,jk,jp_tem)
-                  zs = pts   (ji,jj,jk,jp_sal)
-                  zh = gdept_crs(ji,jj,jk)        ! depth
-                  zsr= zws   (ji,jj,jk)        ! square root salinity
-                  !
-                  ! compute volumic mass pure water at atm pressure
-                  zr1= ( ( ( ( 6.536332e-9_wp  *zt - 1.120083e-6_wp )*zt + 1.001685e-4_wp )*zt   &
-                     &        -9.095290e-3_wp )*zt + 6.793952e-2_wp )*zt +  999.842594_wp
-                  ! seawater volumic mass atm pressure
-                  zr2= ( ( ( 5.3875e-9_wp*zt-8.2467e-7_wp ) *zt+7.6438e-5_wp ) *zt        &
-                     &                      -4.0899e-3_wp ) *zt+0.824493_wp
-                  zr3= ( -1.6546e-6_wp*zt+1.0227e-4_wp )    *zt-5.72466e-3_wp
-                  zr4= 4.8314e-4_wp
-                  !
-                  ! potential volumic mass (reference to the surface)
-                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
-                  !
-                  ! add the compression terms
-                  ze = ( -3.508914e-8_wp*zt-1.248266e-8_wp ) *zt-2.595994e-6_wp
-                  zbw= (  1.296821e-6_wp*zt-5.782165e-9_wp ) *zt+1.045941e-4_wp
-                  zb = zbw + ze * zs
-                  !
-                  zd = -2.042967e-2_wp
-                  zc =   (-7.267926e-5_wp*zt+2.598241e-3_wp ) *zt+0.1571896_wp
-                  zaw= ( ( 5.939910e-6_wp*zt+2.512549e-3_wp ) *zt-0.1028859_wp ) *zt - 4.721788_wp
-                  za = ( zd*zsr + zc ) *zs + zaw
-                  !
-                  zb1=   (-0.1909078_wp*zt+7.390729_wp )        *zt-55.87545_wp
-                  za1= ( ( 2.326469e-3_wp*zt+1.553190_wp)       *zt-65.00517_wp ) *zt+1044.077_wp
-                  zkw= ( ( (-1.361629e-4_wp*zt-1.852732e-2_wp ) *zt-30.41638_wp ) *zt + 2098.925_wp ) *zt+190925.6_wp
-                  zk0= ( zb1*zsr + za1 )*zs + zkw
-                  !
-                  ! masked in situ density anomaly
-                  prd(ji,jj,jk) = (  zrhop / (  1.0_wp - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
-                     &             - rau0  ) * zrau0r * tmask_crs(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !
-      CASE( 1 )                !==  Linear formulation function of temperature only  ==!
-         DO jk = 1, jpkm1
-            prd(:,:,jk) = ( 0.0285_wp - rn_alpha * pts(:,:,jk,jp_tem) ) * tmask_crs(:,:,jk)
-         END DO
-         !
-      CASE( 2 )                !==  Linear formulation function of temperature and salinity  ==!
-         DO jk = 1, jpkm1
-            prd(:,:,jk) = ( rn_beta  * pts(:,:,jk,jp_sal) - rn_alpha * pts(:,:,jk,jp_tem) ) * tmask_crs(:,:,jk)
-         END DO
-         !
-      END SELECT
-      !
-    !  IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos  : ', ovlap=1, kdim=jpk )
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zws )
-      !
-      IF( nn_timing == 1 ) CALL timing_stop('eos')
-      !
-   END SUBROUTINE eos_insitu_crs
-
-
-   SUBROUTINE eos_insitu_pot_crs( pts, prd, prhop )
+   SUBROUTINE eos_insitu_pot( pts, prd, prhop, pdep )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE eos_insitu_pot  ***
@@ -210,133 +180,95 @@
       !!     namelist parameter nn_eos.
       !!
-      !! ** Method  :
-      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
-      !!         the in situ density is computed directly as a function of
-      !!         potential temperature relative to the surface (the opa t
-      !!         variable), salt and pressure (assuming no pressure variation
-      !!         along geopotential surfaces, i.e. the pressure p in decibars
-      !!         is approximated by the depth in meters.
-      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
-      !!              rhop(t,s)  = rho(t,s,0)
-      !!         with pressure                      p        decibars
-      !!              potential temperature         t        deg celsius
-      !!              salinity                      s        psu
-      !!              reference volumic mass        rau0     kg/m**3
-      !!              in situ volumic mass          rho      kg/m**3
-      !!              in situ density anomalie      prd      no units
-      !!
-      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
-      !!          t = 40 deg celcius, s=40 psu
-      !!
-      !!      nn_eos = 1 : linear equation of state function of temperature only
-      !!              prd(t) = ( rho(t) - rau0 ) / rau0 = 0.028 - rn_alpha * t
-      !!              rhop(t,s)  = rho(t,s)
-      !!
-      !!      nn_eos = 2 : linear equation of state function of temperature and
-      !!               salinity
-      !!              prd(t,s) = ( rho(t,s) - rau0 ) / rau0
-      !!                       = rn_beta * s - rn_alpha * tn - 1.
-      !!              rhop(t,s)  = rho(t,s)
-      !!      Note that no boundary condition problem occurs in this routine
-      !!      as (tn,sn) or (ta,sa) are defined over the whole domain.
-      !!
       !! ** Action  : - prd  , the in situ density (no units)
       !!              - prhop, the potential volumic mass (Kg/m3)
       !!
-      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
-      !!                Brown and Campana, Mon. Weather Rev., 1978
-      !!----------------------------------------------------------------------
-      !!
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::   pts    ! 1 : potential temperature  [Celcius]
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk,jpts), INTENT(in   ) ::   pts    ! 1 : potential temperature  [Celcius]
       !                                                                ! 2 : salinity               [psu]
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(  out) ::   prd    ! in situ density            [-]
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(  out) ::   prhop  ! potential density (surface referenced)
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! local scalars
-      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zrau0r       !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zws
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 ) CALL timing_start('eos-p')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zws )
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk     ), INTENT(  out) ::   prd    ! in situ density            [-]
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk     ), INTENT(  out) ::   prhop  ! potential density (surface referenced)
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk     ), INTENT(in   ) ::   pdep   ! depth                      [m]
+      !
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zt , zh , zs , ztm        ! local scalars
+      REAL(wp) ::   zn , zn0, zn1, zn2, zn3   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('eos-pot_crs')
       !
       SELECT CASE ( nn_eos )
       !
-      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
-         zrau0r = 1.e0 / rau0
-!CDIR NOVERRCHK
-         zws(:,:,:) = SQRT( ABS( pts(:,:,:,jp_sal) ) )
+      CASE( -1, 0 )                !==  polynomial TEOS-10 / EOS-80 ==!
          !
          DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zt = pts   (ji,jj,jk,jp_tem)
-                  zs = pts   (ji,jj,jk,jp_sal)
-                  zh = gdept_crs(ji,jj,jk)        ! depth
-                  zsr= zws   (ji,jj,jk)        ! square root salinity
-                  !
-                  ! compute volumic mass pure water at atm pressure
-                  zr1= ( ( ( ( 6.536332e-9_wp*zt-1.120083e-6_wp )*zt+1.001685e-4_wp )*zt   &
-                     &                          -9.095290e-3_wp )*zt+6.793952e-2_wp )*zt+999.842594_wp
-                  ! seawater volumic mass atm pressure
-                  zr2= ( ( ( 5.3875e-9_wp*zt-8.2467e-7_wp ) *zt+7.6438e-5_wp ) *zt   &
-                     &                                         -4.0899e-3_wp ) *zt+0.824493_wp
-                  zr3= ( -1.6546e-6_wp*zt+1.0227e-4_wp )    *zt-5.72466e-3_wp
-                  zr4= 4.8314e-4_wp
-                  !
-                  ! potential volumic mass (reference to the surface)
-                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
-                  !
-                  ! save potential volumic mass
-                  prhop(ji,jj,jk) = zrhop * tmask_crs(ji,jj,jk)
-                  !
-                  ! add the compression terms
-                  ze = ( -3.508914e-8_wp*zt-1.248266e-8_wp ) *zt-2.595994e-6_wp
-                  zbw= (  1.296821e-6_wp*zt-5.782165e-9_wp ) *zt+1.045941e-4_wp
-                  zb = zbw + ze * zs
-                  !
-                  zd = -2.042967e-2_wp
-                  zc =   (-7.267926e-5_wp*zt+2.598241e-3_wp ) *zt+0.1571896_wp
-                  zaw= ( ( 5.939910e-6_wp*zt+2.512549e-3_wp ) *zt-0.1028859_wp ) *zt - 4.721788_wp
-                  za = ( zd*zsr + zc ) *zs + zaw
-                  !
-                  zb1=   (  -0.1909078_wp  *zt+7.390729_wp    ) *zt-55.87545_wp
-                  za1= ( (   2.326469e-3_wp*zt+1.553190_wp    ) *zt-65.00517_wp ) *zt + 1044.077_wp
-                  zkw= ( ( (-1.361629e-4_wp*zt-1.852732e-2_wp ) *zt-30.41638_wp ) *zt + 2098.925_wp ) *zt+190925.6_wp
-                  zk0= ( zb1*zsr + za1 )*zs + zkw
-                  !
-                  ! masked in situ density anomaly
-                  prd(ji,jj,jk) = (  zrhop / (  1.0_wp - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
-                     &             - rau0  ) * zrau0r * tmask_crs(ji,jj,jk)
+            DO jj = 1, jpj_crs
+               DO ji = 1, jpi_crs
+                  !
+                  zh  = pdep(ji,jj,jk) * r1_Z0                                  ! depth
+                  zt  = pts (ji,jj,jk,jp_tem) * r1_T0                           ! temperature
+                  zs  = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 )   ! square root salinity
+                  ztm = tmask_crs(ji,jj,jk)                                     ! tmask
+                  !
+                  zn3 = EOS013*zt   &
+                     &   + EOS103*zs+EOS003
+                     !
+                  zn2 = (EOS022*zt   &
+                     &   + EOS112*zs+EOS012)*zt   &
+                     &   + (EOS202*zs+EOS102)*zs+EOS002
+                     !
+                  zn1 = (((EOS041*zt   &
+                     &   + EOS131*zs+EOS031)*zt   &
+                     &   + (EOS221*zs+EOS121)*zs+EOS021)*zt   &
+                     &   + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt   &
+                     &   + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
+                     !
+                  zn0 = (((((EOS060*zt   &
+                     &   + EOS150*zs+EOS050)*zt   &
+                     &   + (EOS240*zs+EOS140)*zs+EOS040)*zt   &
+                     &   + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt   &
+                     &   + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt   &
+                     &   + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt   &
+                     &   + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
+                     !
+                  zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+                  !
+                  prhop(ji,jj,jk) = zn0 * ztm                           ! potential density referenced at the surface
+                  !
+                  prd(ji,jj,jk) = (  zn * r1_rau0 - 1._wp  ) * ztm      ! density anomaly (masked)
                END DO
             END DO
          END DO
          !
-      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
+      CASE( 1 )                !==  simplified EOS  ==!
+         !
          DO jk = 1, jpkm1
-            prd  (:,:,jk) = ( 0.0285_wp - rn_alpha * pts(:,:,jk,jp_tem) )        * tmask_crs(:,:,jk)
-            prhop(:,:,jk) = ( 1.e0_wp   +            prd (:,:,jk)       ) * rau0 * tmask_crs(:,:,jk)
+            DO jj = 1, jpj_crs
+               DO ji = 1, jpi_crs
+                  zt  = pts  (ji,jj,jk,jp_tem) - 10._wp
+                  zs  = pts  (ji,jj,jk,jp_sal) - 35._wp
+                  zh  = pdep (ji,jj,jk)
+                  ztm = tmask_crs(ji,jj,jk)
+                  !                                                     ! potential density referenced at the surface
+                  zn =  - rn_a0 * ( 1._wp + 0.5_wp*rn_lambda1*zt ) * zt   &
+                     &  + rn_b0 * ( 1._wp - 0.5_wp*rn_lambda2*zs ) * zs   &
+                     &  - rn_nu * zt * zs
+                  prhop(ji,jj,jk) = ( rau0 + zn ) * ztm
+                  !                                                     ! density anomaly (masked)
+                  zn = zn - ( rn_a0 * rn_mu1 * zt + rn_b0 * rn_mu2 * zs ) * zh
+                  prd(ji,jj,jk) = zn * r1_rau0 * ztm
+                  !
+               END DO
+            END DO
          END DO
          !
-      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
-         DO jk = 1, jpkm1
-            prd  (:,:,jk) = ( rn_beta  * pts(:,:,jk,jp_sal) - rn_alpha * pts(:,:,jk,jp_tem) )        * tmask_crs(:,:,jk)
-            prhop(:,:,jk) = ( 1.e0_wp  + prd (:,:,jk) )                                       * rau0 * tmask_crs(:,:,jk)
-         END DO
-         !
       END SELECT
       !
-   !   IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-p: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zws )
-      !
-      IF( nn_timing == 1 ) CALL timing_stop('eos-p')
-      !
-   END SUBROUTINE eos_insitu_pot_crs
-
-
-   SUBROUTINE eos_insitu_2d_crs( pts, pdep, prd )
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-pot: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('eos-pot_crs')
+      !
+   END SUBROUTINE eos_insitu_pot
+
+   SUBROUTINE eos_insitu_2d( pts, pdep, prd )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE eos_insitu_2d  ***
@@ -346,349 +278,188 @@
       !!      defined through the namelist parameter nn_eos. * 2D field case
       !!
-      !! ** Method :
-      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
-      !!         the in situ density is computed directly as a function of
-      !!         potential temperature relative to the surface (the opa t
-      !!         variable), salt and pressure (assuming no pressure variation
-      !!         along geopotential surfaces, i.e. the pressure p in decibars
-      !!         is approximated by the depth in meters.
-      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
-      !!         with pressure                      p        decibars
-      !!              potential temperature         t        deg celsius
-      !!              salinity                      s        psu
-      !!              reference volumic mass        rau0     kg/m**3
-      !!              in situ volumic mass          rho      kg/m**3
-      !!              in situ density anomalie      prd      no units
-      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
-      !!          t = 40 deg celcius, s=40 psu
-      !!      nn_eos = 1 : linear equation of state function of temperature only
-      !!              prd(t) = 0.0285 - rn_alpha * t
-      !!      nn_eos = 2 : linear equation of state function of temperature and
-      !!               salinity
-      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
-      !!      Note that no boundary condition problem occurs in this routine
-      !!      as pts are defined over the whole domain.
-      !!
-      !! ** Action  : - prd , the in situ density (no units)
-      !!
-      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
-      !!----------------------------------------------------------------------
-      !!
-      REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in   ) ::   pts   ! 1 : potential temperature  [Celcius]
+      !! ** Action  : - prd , the in situ density (no units) (unmasked)
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpts), INTENT(in   ) ::   pts   ! 1 : potential temperature  [Celcius]
       !                                                           ! 2 : salinity               [psu]
-      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(in   ) ::   pdep  ! depth                  [m]
-      REAL(wp), DIMENSION(jpi,jpj)     , INTENT(  out) ::   prd   ! in situ density
-      !!
-      INTEGER  ::   ji, jj                    ! dummy loop indices
-      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! temporary scalars
-      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zmask        !    -         -
-      REAL(wp), POINTER, DIMENSION(:,:) :: zws
-      !!----------------------------------------------------------------------
-      !
-!WRITE(numout,*) ' pts1 ' ,  pts(:,:,1)
-!WRITE(numout,*) ' pts2 ' ,  pts(:,:,2)
-!WRITE(numout,*) ' jpi ' ,  jpi
-!WRITE(numout,*) ' fs_jpim1 ' ,  fs_jpim1
-!WRITE(numout,*) ' dim ' ,  size(pts,1)
-      IF( nn_timing == 1 ) CALL timing_start('eos2d')
-      !
-      CALL wrk_alloc( jpi, jpj, zws )
-      !
-
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs)     , INTENT(in   ) ::   pdep  ! depth                      [m]
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs)     , INTENT(  out) ::   prd   ! in situ density
+      !
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zt , zh , zs              ! local scalars
+      REAL(wp) ::   zn , zn0, zn1, zn2, zn3   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('eos2d')
+      !
       prd(:,:) = 0._wp
-
+      !
       SELECT CASE( nn_eos )
       !
-      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
-      !
-!CDIR NOVERRCHK
-         DO jj = 1, jpjm1
-!CDIR NOVERRCHK
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zws(ji,jj) = SQRT( ABS( pts(ji,jj,jp_sal) ) )
+      CASE( -1, 0 )                !==  polynomial TEOS-10 / EOS-80 ==!
+         !
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1   ! vector opt.
+               !
+               zh  = pdep(ji,jj) * r1_Z0                                  ! depth
+               zt  = pts (ji,jj,jp_tem) * r1_T0                           ! temperature
+               zs  = SQRT( ABS( pts(ji,jj,jp_sal) + rdeltaS ) * r1_S0 )   ! square root salinity
+               !
+               zn3 = EOS013*zt   &
+                  &   + EOS103*zs+EOS003
+                  !
+               zn2 = (EOS022*zt   &
+                  &   + EOS112*zs+EOS012)*zt   &
+                  &   + (EOS202*zs+EOS102)*zs+EOS002
+                  !
+               zn1 = (((EOS041*zt   &
+                  &   + EOS131*zs+EOS031)*zt   &
+                  &   + (EOS221*zs+EOS121)*zs+EOS021)*zt   &
+                  &   + ((EOS311*zs+EOS211)*zs+EOS111)*zs+EOS011)*zt   &
+                  &   + (((EOS401*zs+EOS301)*zs+EOS201)*zs+EOS101)*zs+EOS001
+                  !
+               zn0 = (((((EOS060*zt   &
+                  &   + EOS150*zs+EOS050)*zt   &
+                  &   + (EOS240*zs+EOS140)*zs+EOS040)*zt   &
+                  &   + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt   &
+                  &   + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt   &
+                  &   + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt   &
+                  &   + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000
+                  !
+               zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+               !
+               prd(ji,jj) = zn * r1_rau0 - 1._wp               ! unmasked in situ density anomaly
+               !
             END DO
          END DO
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zmask = tmask_crs(ji,jj,1)          ! land/sea bottom mask = surf. mask
-               zt    = pts  (ji,jj,jp_tem)            ! interpolated T
-               zs    = pts  (ji,jj,jp_sal)            ! interpolated S
-               zsr   = zws  (ji,jj)            ! square root of interpolated S
-               zh    = pdep (ji,jj)            ! depth at the partial step level
-               !
-               ! compute volumic mass pure water at atm pressure
-               zr1 = ( ( ( ( 6.536332e-9_wp*zt-1.120083e-6_wp )*zt+1.001685e-4_wp )*zt   &
-                  &                        -9.095290e-3_wp )*zt+6.793952e-2_wp )*zt+999.842594_wp
-               ! seawater volumic mass atm pressure
-               zr2 = ( ( ( 5.3875e-9_wp*zt-8.2467e-7_wp )*zt+7.6438e-5_wp ) *zt   &
-                  &                                   -4.0899e-3_wp ) *zt+0.824493_wp
-               zr3 = ( -1.6546e-6_wp*zt+1.0227e-4_wp ) *zt-5.72466e-3_wp
-               zr4 = 4.8314e-4_wp
-               !
-               ! potential volumic mass (reference to the surface)
-               zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
-               !
-               ! add the compression terms
-               ze = ( -3.508914e-8_wp*zt-1.248266e-8_wp ) *zt-2.595994e-6_wp
-               zbw= (  1.296821e-6_wp*zt-5.782165e-9_wp ) *zt+1.045941e-4_wp
-               zb = zbw + ze * zs
-               !
-               zd =    -2.042967e-2_wp
-               zc =   (-7.267926e-5_wp*zt+2.598241e-3_wp ) *zt+0.1571896_wp
-               zaw= ( ( 5.939910e-6_wp*zt+2.512549e-3_wp ) *zt-0.1028859_wp ) *zt -4.721788_wp
-               za = ( zd*zsr + zc ) *zs + zaw
-               !
-               zb1=     (-0.1909078_wp  *zt+7.390729_wp      ) *zt-55.87545_wp
-               za1=   ( ( 2.326469e-3_wp*zt+1.553190_wp      ) *zt-65.00517_wp ) *zt+1044.077_wp
-               zkw= ( ( (-1.361629e-4_wp*zt-1.852732e-2_wp   ) *zt-30.41638_wp ) *zt   &
-                  &                             +2098.925_wp ) *zt+190925.6_wp
-               zk0= ( zb1*zsr + za1 )*zs + zkw
-               !
-               ! masked in situ density anomaly
-               prd(ji,jj) = ( zrhop / (  1.0_wp - zh / ( zk0 - zh * ( za - zh * zb ) )  ) - rau0 ) / rau0 * zmask
+         !
+         CALL crs_lbc_lnk( prd, 'T', 1. )                    ! Lateral boundary conditions
+         !
+      CASE( 1 )                !==  simplified EOS  ==!
+         !
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1   ! vector opt.
+               !
+               zt    = pts  (ji,jj,jp_tem)  - 10._wp
+               zs    = pts  (ji,jj,jp_sal)  - 35._wp
+               zh    = pdep (ji,jj)                         ! depth at the partial step level
+               !
+               zn =  - rn_a0 * ( 1._wp + 0.5_wp*rn_lambda1*zt + rn_mu1*zh ) * zt   &
+                  &  + rn_b0 * ( 1._wp - 0.5_wp*rn_lambda2*zs - rn_mu2*zh ) * zs   &
+                  &  - rn_nu * zt * zs
+                  !
+               prd(ji,jj) = zn * r1_rau0               ! unmasked in situ density anomaly
+               !
             END DO
          END DO
          !
-      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               prd(ji,jj) = ( 0.0285_wp - rn_alpha * pts(ji,jj,jp_tem) ) * tmask_crs(ji,jj,1)
-            END DO
-         END DO
-         !
-      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               prd(ji,jj) = ( rn_beta * pts(ji,jj,jp_sal) - rn_alpha * pts(ji,jj,jp_tem) ) * tmask_crs(ji,jj,1)
-            END DO
-         END DO
+         CALL crs_lbc_lnk( prd, 'T', 1. )                    ! Lateral boundary conditions
          !
       END SELECT
-!WRITE(numout,*) ' prd ' ,  prd(:,:)
-!WRITE(numout,*) ' zws ' ,  zws(:,:)
-!WRITE(numout,*) ' pdep ' ,  pdep(:,:)
-
-
-
-!     IF(ln_ctl)   CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
-      !
-      CALL wrk_dealloc( jpi, jpj, zws )
-      !
-      IF( nn_timing == 1 ) CALL timing_stop('eos2d')
-      !
-   END SUBROUTINE eos_insitu_2d_crs
-
-
-   SUBROUTINE eos_bn2_crs( pts, pn2 )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE eos_bn2  ***
-      !!
-      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the time-
-      !!      step of the input arguments
-      !!
-      !! ** Method :
-      !!       * nn_eos = 0  : UNESCO sea water properties
-      !!         The brunt-vaisala frequency is computed using the polynomial
-      !!      polynomial expression of McDougall (1987):
-      !!            N^2 = grav * beta * ( alpha/beta*dk[ t ] - dk[ s ] )/e3w
-      !!      If lk_zdfddm=T, the heat/salt buoyancy flux ratio Rrau is
-      !!      computed and used in zdfddm module :
-      !!              Rrau = alpha/beta * ( dk[ t ] / dk[ s ] )
-      !!       * nn_eos = 1  : linear equation of state (temperature only)
-      !!            N^2 = grav * rn_alpha * dk[ t ]/e3w
-      !!       * nn_eos = 2  : linear equation of state (temperature & salinity)
-      !!            N^2 = grav * (rn_alpha * dk[ t ] - rn_beta * dk[ s ] ) / e3w
-      !!      The use of potential density to compute N^2 introduces e r r o r
-      !!      in the sign of N^2 at great depths. We recommand the use of
-      !!      nn_eos = 0, except for academical studies.
-      !!        Macro-tasked on horizontal slab (jk-loop)
-      !!      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
-      !!      and is never used at this level.
-      !!
-      !! ** Action  : - pn2 : the brunt-vaisala frequency
-      !!
-      !! References :   McDougall, J. Phys. Oceanogr., 17, 1950-1964, 1987.
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::   pts   ! 1 : potential temperature  [Celcius]
-      !                                                               ! 2 : salinity               [psu]
-      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pn2   ! Brunt-Vaisala frequency    [s-1]
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zgde3w, zt, zs, zh, zalbet, zbeta   ! local scalars
-#if defined key_zdfddm
-      REAL(wp) ::   zds   ! local scalars
-#endif
-      !!----------------------------------------------------------------------
-
-      !
-      IF( nn_timing == 1 ) CALL timing_start('bn2')
-      !
-      ! pn2 : interior points only (2=< jk =< jpkm1 )
-      ! --------------------------
-      !
-      SELECT CASE( nn_eos )
-      !
-      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zgde3w = grav / e3w_max_crs(ji,jj,jk)
-                  zt = 0.5 * ( pts(ji,jj,jk,jp_tem) + pts(ji,jj,jk-1,jp_tem) )         ! potential temperature at w-pt
-                  zs = 0.5 * ( pts(ji,jj,jk,jp_sal) + pts(ji,jj,jk-1,jp_sal) ) - 35.0  ! salinity anomaly (s-35) at w-pt
-                  zh = gdepw_crs(ji,jj,jk)                                                ! depth in meters  at w-point
-                  !
-                  zalbet = ( ( ( - 0.255019e-07_wp * zt + 0.298357e-05_wp ) * zt   &   ! ratio alpha/beta
-                     &                                  - 0.203814e-03_wp ) * zt   &
-                     &                                  + 0.170907e-01_wp ) * zt   &
-                     &   +         0.665157e-01_wp                                 &
-                     &   +     ( - 0.678662e-05_wp * zs                            &
-                     &           - 0.846960e-04_wp * zt + 0.378110e-02_wp ) * zs   &
-                     &   +   ( ( - 0.302285e-13_wp * zh                            &
-                     &           - 0.251520e-11_wp * zs                            &
-                     &           + 0.512857e-12_wp * zt * zt              ) * zh   &
-                     &           - 0.164759e-06_wp * zs                            &
-                     &        +(   0.791325e-08_wp * zt - 0.933746e-06_wp ) * zt   &
-                     &                                  + 0.380374e-04_wp ) * zh
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('eos2d')
+      !
+   END SUBROUTINE eos_insitu_2d
+
+   SUBROUTINE rab_crs_3d( pts, pab )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE rab_3d  ***
+      !!
+      !! ** Purpose :   Calculates thermal/haline expansion ratio at T-points
+      !!
+      !! ** Method  :   calculates alpha / beta at T-points
+      !!
+      !! ** Action  : - pab     : thermal/haline expansion ratio at T-points
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk,jpts), INTENT(in   ) ::   pts   ! pot. temperature & salinity
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk,jpts), INTENT(  out) ::   pab   ! thermal/haline expansion ratio
+      !
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zt , zh , zs , ztm        ! local scalars
+      REAL(wp) ::   zn , zn0, zn1, zn2, zn3   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('rab_3d')
+      !
+      SELECT CASE ( nn_eos )
+      !
+      CASE( -1, 0 )                !==  polynomial TEOS-10 / EOS-80 ==!
+         !
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj_crs
+               DO ji = 1, jpi_crs
+                  !
+                  zh  = gdept_crs(ji,jj,jk) * r1_Z0                                ! depth
+                  zt  = pts (ji,jj,jk,jp_tem) * r1_T0                           ! temperature
+                  zs  = SQRT( ABS( pts(ji,jj,jk,jp_sal) + rdeltaS ) * r1_S0 )   ! square root salinity
+                  ztm = tmask_crs(ji,jj,jk)                                         ! tmask
+                  !
+                  ! alpha
+                  zn3 = ALP003
+                  !
+                  zn2 = ALP012*zt + ALP102*zs+ALP002
+                  !
+                  zn1 = ((ALP031*zt   &
+                     &   + ALP121*zs+ALP021)*zt   &
+                     &   + (ALP211*zs+ALP111)*zs+ALP011)*zt   &
+                     &   + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
                      !
-                  zbeta  = ( ( -0.415613e-09_wp * zt + 0.555579e-07_wp ) * zt      &   ! beta
-                     &                               - 0.301985e-05_wp ) * zt      &
-                     &   +       0.785567e-03_wp                                   &
-                     &   + (     0.515032e-08_wp * zs                              &
-                     &         + 0.788212e-08_wp * zt - 0.356603e-06_wp ) * zs     &
-                     &   + ( (   0.121551e-17_wp * zh                              &
-                     &         - 0.602281e-15_wp * zs                              &
-                     &         - 0.175379e-14_wp * zt + 0.176621e-12_wp ) * zh     &
-                     &                                + 0.408195e-10_wp   * zs     &
-                     &     + ( - 0.213127e-11_wp * zt + 0.192867e-09_wp ) * zt     &
-                     &                                - 0.121555e-07_wp ) * zh
+                  zn0 = ((((ALP050*zt   &
+                     &   + ALP140*zs+ALP040)*zt   &
+                     &   + (ALP230*zs+ALP130)*zs+ALP030)*zt   &
+                     &   + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt   &
+                     &   + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt   &
+                     &   + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
                      !
-                  !cbr zgde3w: divide by 0
-                  !pn2(ji,jj,jk) = zgde3w * zbeta * tmask_crs(ji,jj,jk)           &   ! N^2
-                  !   &          * ( zalbet * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) )   &
-                  !   &                     - ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) ) )
-                  pn2(ji,jj,jk) = zbeta * tmask_crs(ji,jj,jk)           &   ! N^2
-                     &          * ( zalbet * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) )   &
-                     &                     - ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) ) )
-                  IF( e3w_max_crs(ji,jj,jk) .NE. 0._wp ) pn2(ji,jj,jk) = zgde3w * e3w_max_crs(ji,jj,jk)
-
-#if defined key_zdfddm
-                  !                                                         !!bug **** caution a traiter zds=dk[S]= 0 !!!!
-                  zds = ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) )                    ! Rrau = (alpha / beta) (dk[t] / dk[s])
-                  IF ( ABS( zds) <= 1.e-20_wp ) zds = 1.e-20_wp
-                  rrau(ji,jj,jk) = zalbet * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) ) / zds
-#endif
+                  zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+                  !
+                  pab(ji,jj,jk,jp_tem) = zn * r1_rau0 * ztm
+                  !
+                  ! beta
+                  zn3 = BET003
+                  !
+                  zn2 = BET012*zt + BET102*zs+BET002
+                  !
+                  zn1 = ((BET031*zt   &
+                     &   + BET121*zs+BET021)*zt   &
+                     &   + (BET211*zs+BET111)*zs+BET011)*zt   &
+                     &   + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
+                     !
+                  zn0 = ((((BET050*zt   &
+                     &   + BET140*zs+BET040)*zt   &
+                     &   + (BET230*zs+BET130)*zs+BET030)*zt   &
+                     &   + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt   &
+                     &   + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt   &
+                     &   + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
+                     !
+                  zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+                  !
+                  pab(ji,jj,jk,jp_sal) = zn / zs * r1_rau0 * ztm
+                  !
                END DO
             END DO
          END DO
          !
-      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
-         DO jk = 2, jpkm1
-            pn2(:,:,jk) = grav * rn_alpha * ( pts(:,:,jk-1,jp_tem) - pts(:,:,jk,jp_tem) ) / e3w_max_crs(:,:,jk) * tmask_crs(:,:,jk)
-         END DO
-         !
-      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
-         DO jk = 2, jpkm1
-            !cbr: bug divide by 0.
-            !pn2(:,:,jk) = grav * (  rn_alpha * ( pts(:,:,jk-1,jp_tem) - pts(:,:,jk,jp_tem) )      &
-            !   &                  - rn_beta  * ( pts(:,:,jk-1,jp_sal) - pts(:,:,jk,jp_sal) )  )   &
-            !   &               / e3w_max_crs(:,:,jk) * tmask_crs(:,:,jk)
-            pn2(:,:,jk) = grav * (  rn_alpha * ( pts(:,:,jk-1,jp_tem) - pts(:,:,jk,jp_tem) )      &
-               &                  - rn_beta  * ( pts(:,:,jk-1,jp_sal) - pts(:,:,jk,jp_sal) )  )   &
-               &               * tmask_crs(:,:,jk)
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  IF( e3w_max_crs(ji,jj,jk) .NE. 0._wp ) pn2(ji,jj,jk) = pn2(ji,jj,jk) / e3w_max_crs(ji,jj,jk)
-               ENDDO
-            ENDDO
-         END DO
-#if defined key_zdfddm
-         DO jk = 2, jpkm1                                 ! Rrau = (alpha / beta) (dk[t] / dk[s])
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zds = ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) )
-                  IF ( ABS( zds ) <= 1.e-20_wp ) zds = 1.e-20_wp
-                  rrau(ji,jj,jk) = ralpbet_crs * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) ) / zds
+      CASE( 1 )                  !==  simplified EOS  ==!
+         !
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj_crs
+               DO ji = 1, jpi_crs
+                  zt  = pts (ji,jj,jk,jp_tem) - 10._wp   ! pot. temperature anomaly (t-T0)
+                  zs  = pts (ji,jj,jk,jp_sal) - 35._wp   ! abs. salinity anomaly (s-S0)
+                  zh  = gdept_crs(ji,jj,jk)                 ! depth in meters at t-point
+                  ztm = tmask_crs(ji,jj,jk)                  ! land/sea bottom mask = surf. mask
+                  !
+                  zn  = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
+                  pab(ji,jj,jk,jp_tem) = zn * r1_rau0 * ztm   ! alpha
+                  !
+                  zn  = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
+                  pab(ji,jj,jk,jp_sal) = zn * r1_rau0 * ztm   ! beta
+                  !
                END DO
             END DO
          END DO
-#endif
-      END SELECT
-
-  !    IF(ln_ctl)   CALL prt_ctl( tab3d_1=pn2, clinfo1=' bn2  : ', ovlap=1, kdim=jpk )
-#if defined key_zdfddm
-  !    IF(ln_ctl)   CALL prt_ctl( tab3d_1=rrau, clinfo1=' rrau : ', ovlap=1, kdim=jpk )
-#endif
-      !
-      IF( nn_timing == 1 ) CALL timing_stop('bn2')
-      !
-   END SUBROUTINE eos_bn2_crs
-
-
-   SUBROUTINE eos_alpbet_crs( pts, palpbet, beta0 )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE eos_alpbet  ***
-      !!
-      !! ** Purpose :   Calculates the in situ thermal/haline expansion ratio at T-points
-      !!
-      !! ** Method  :   calculates alpha / beta ratio at T-points
-      !!       * nn_eos = 0  : UNESCO sea water properties
-      !!                       The alpha/beta ratio is returned as 3-D array palpbet using the polynomial
-      !!                       polynomial expression of McDougall (1987).
-      !!                       Scalar beta0 is returned = 1.
-      !!       * nn_eos = 1  : linear equation of state (temperature only)
-      !!                       The ratio is undefined, so we return alpha as palpbet
-      !!                       Scalar beta0 is returned = 0.
-      !!       * nn_eos = 2  : linear equation of state (temperature & salinity)
-      !!                       The alpha/beta ratio is returned as ralpbet
-      !!                       Scalar beta0 is returned = 1.
-      !!
-      !! ** Action  : - palpbet : thermal/haline expansion ratio at T-points
-      !!            :   beta0   : 1. or 0.
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(in   ) ::   pts       ! pot. temperature & salinity
-      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   palpbet   ! thermal/haline expansion ratio
-      REAL(wp),                              INTENT(  out) ::   beta0     ! set = 1 except with case 1 eos, rho=rho(T)
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zt, zs, zh   ! local scalars
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 ) CALL timing_start('eos_alpbet')
-      !
-      SELECT CASE ( nn_eos )
-      !
-      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
-         DO jk = 1, jpk
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zt = pts(ji,jj,jk,jp_tem)           ! potential temperature
-                  zs = pts(ji,jj,jk,jp_sal) - 35._wp  ! salinity anomaly (s-35)
-                  zh = fsdept(ji,jj,jk)               ! depth in meters
-                  !
-                  palpbet(ji,jj,jk) =                                              &
-                     &     ( ( ( - 0.255019e-07_wp * zt + 0.298357e-05_wp ) * zt   &
-                     &                                  - 0.203814e-03_wp ) * zt   &
-                     &                                  + 0.170907e-01_wp ) * zt   &
-                     &   + 0.665157e-01_wp                                         &
-                     &   +     ( - 0.678662e-05_wp * zs                            &
-                     &           - 0.846960e-04_wp * zt + 0.378110e-02_wp ) * zs   &
-                     &   +   ( ( - 0.302285e-13_wp * zh                            &
-                     &           - 0.251520e-11_wp * zs                            &
-                     &           + 0.512857e-12_wp * zt * zt              ) * zh   &
-                     &           - 0.164759e-06_wp * zs                            &
-                     &        +(   0.791325e-08_wp * zt - 0.933746e-06_wp ) * zt   &
-                     &                                  + 0.380374e-04_wp ) * zh
-               END DO
-            END DO
-         END DO
-         beta0 = 1._wp
-         !
-      CASE ( 1 )              !==  Linear formulation = F( temperature )  ==!
-         palpbet(:,:,:) = rn_alpha
-         beta0 = 0._wp
-         !
-      CASE ( 2 )              !==  Linear formulation = F( temperature , salinity )  ==!
-         palpbet(:,:,:) = ralpbet_crs
-         beta0 = 1._wp
          !
       CASE DEFAULT
@@ -699,54 +470,305 @@
       END SELECT
       !
-      IF( nn_timing == 1 ) CALL timing_stop('eos_alpbet')
-      !
-   END SUBROUTINE eos_alpbet_crs
-
-
-   FUNCTION tfreez_crs( psal ) RESULT( ptf )
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=pab(:,:,:,jp_tem), clinfo1=' rab_3d_t: ', &
+         &                       tab3d_2=pab(:,:,:,jp_sal), clinfo2=' rab_3d_s : ', ovlap=1, kdim=jpk )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('rab_3d')
+      !
+   END SUBROUTINE rab_crs_3d
+
+   SUBROUTINE rab_crs_2d( pts, pdep, pab )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE rab_2d  ***
+      !!
+      !! ** Purpose :   Calculates thermal/haline expansion ratio for a 2d field (unmasked)
+      !!
+      !! ** Action  : - pab     : thermal/haline expansion ratio at T-points
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpts)    , INTENT(in   ) ::   pts    ! pot. temperature & salinity
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs)         , INTENT(in   ) ::   pdep   ! depth                  [m]
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpts)    , INTENT(  out) ::   pab    ! thermal/haline expansion ratio
+      !
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zt , zh , zs              ! local scalars
+      REAL(wp) ::   zn , zn0, zn1, zn2, zn3   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 ) CALL timing_start('rab_2d')
+      !
+      pab(:,:,:) = 0._wp
+      !
+      SELECT CASE ( nn_eos )
+      !
+      CASE( -1, 0 )                !==  polynomial TEOS-10 / EOS-80 ==!
+         !
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1   ! vector opt.
+               !
+               zh  = pdep(ji,jj) * r1_Z0                                  ! depth
+               zt  = pts (ji,jj,jp_tem) * r1_T0                           ! temperature
+               zs  = SQRT( ABS( pts(ji,jj,jp_sal) + rdeltaS ) * r1_S0 )   ! square root salinity
+               !
+               ! alpha
+               zn3 = ALP003
+               !
+               zn2 = ALP012*zt + ALP102*zs+ALP002
+               !
+               zn1 = ((ALP031*zt   &
+                  &   + ALP121*zs+ALP021)*zt   &
+                  &   + (ALP211*zs+ALP111)*zs+ALP011)*zt   &
+                  &   + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
+                  !
+               zn0 = ((((ALP050*zt   &
+                  &   + ALP140*zs+ALP040)*zt   &
+                  &   + (ALP230*zs+ALP130)*zs+ALP030)*zt   &
+                  &   + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt   &
+                  &   + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt   &
+                  &   + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
+                  !
+               zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+               !
+               pab(ji,jj,jp_tem) = zn * r1_rau0
+               !
+               ! beta
+               zn3 = BET003
+               !
+               zn2 = BET012*zt + BET102*zs+BET002
+               !
+               zn1 = ((BET031*zt   &
+                  &   + BET121*zs+BET021)*zt   &
+                  &   + (BET211*zs+BET111)*zs+BET011)*zt   &
+                  &   + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
+                  !
+               zn0 = ((((BET050*zt   &
+                  &   + BET140*zs+BET040)*zt   &
+                  &   + (BET230*zs+BET130)*zs+BET030)*zt   &
+                  &   + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt   &
+                  &   + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt   &
+                  &   + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
+                  !
+               zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+               !
+               pab(ji,jj,jp_sal) = zn / zs * r1_rau0
+               !
+               !
+            END DO
+         END DO
+         !
+         CALL crs_lbc_lnk( pab(:,:,jp_tem), 'T', 1. )                    ! Lateral boundary conditions
+         CALL crs_lbc_lnk( pab(:,:,jp_sal), 'T', 1. )                    
+         !
+      CASE( 1 )                  !==  simplified EOS  ==!
+         !
+         DO jj = 1, jpj_crsm1
+            DO ji = 1, jpi_crsm1   ! vector opt.
+               !
+               zt    = pts  (ji,jj,jp_tem) - 10._wp   ! pot. temperature anomaly (t-T0)
+               zs    = pts  (ji,jj,jp_sal) - 35._wp   ! abs. salinity anomaly (s-S0)
+               zh    = pdep (ji,jj)                   ! depth at the partial step level
+               !
+               zn  = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
+               pab(ji,jj,jp_tem) = zn * r1_rau0   ! alpha
+               !
+               zn  = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
+               pab(ji,jj,jp_sal) = zn * r1_rau0   ! beta
+               !
+            END DO
+         END DO
+         !
+         CALL crs_lbc_lnk( pab(:,:,jp_tem), 'T', 1. )                    ! Lateral boundary conditions
+         CALL crs_lbc_lnk( pab(:,:,jp_sal), 'T', 1. )                    
+         !
+      CASE DEFAULT
+         IF(lwp) WRITE(numout,cform_err)
+         IF(lwp) WRITE(numout,*) '          bad flag value for nn_eos = ', nn_eos
+         nstop = nstop + 1
+         !
+      END SELECT
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab2d_1=pab(:,:,jp_tem), clinfo1=' rab_2d_t: ', &
+         &                       tab2d_2=pab(:,:,jp_sal), clinfo2=' rab_2d_s : ' )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('rab_2d')
+      !
+   END SUBROUTINE rab_crs_2d
+
+
+   SUBROUTINE rab_crs_0d( pts, pdep, pab )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE rab_0d  ***
+      !!
+      !! ** Purpose :   Calculates thermal/haline expansion ratio for a 2d field (unmasked)
+      !!
+      !! ** Action  : - pab     : thermal/haline expansion ratio at T-points
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpts)    , INTENT(in   ) ::   pts    ! pot. temperature & salinity
+      REAL(wp),                      INTENT(in   ) ::   pdep   ! depth                  [m]
+      REAL(wp), DIMENSION(jpts)    , INTENT(  out) ::   pab    ! thermal/haline expansion ratio
+      !
+      REAL(wp) ::   zt , zh , zs              ! local scalars
+      REAL(wp) ::   zn , zn0, zn1, zn2, zn3   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 ) CALL timing_start('rab_2d')
+      !
+      pab(:) = 0._wp
+      !
+      SELECT CASE ( nn_eos )
+      !
+      CASE( -1, 0 )                !==  polynomial TEOS-10 / EOS-80 ==!
+         !
+         !
+         zh  = pdep * r1_Z0                                  ! depth
+         zt  = pts (jp_tem) * r1_T0                           ! temperature
+         zs  = SQRT( ABS( pts(jp_sal) + rdeltaS ) * r1_S0 )   ! square root salinity
+         !
+         ! alpha
+         zn3 = ALP003
+         !
+         zn2 = ALP012*zt + ALP102*zs+ALP002
+         !
+         zn1 = ((ALP031*zt   &
+            &   + ALP121*zs+ALP021)*zt   &
+            &   + (ALP211*zs+ALP111)*zs+ALP011)*zt   &
+            &   + ((ALP301*zs+ALP201)*zs+ALP101)*zs+ALP001
+            !
+         zn0 = ((((ALP050*zt   &
+            &   + ALP140*zs+ALP040)*zt   &
+            &   + (ALP230*zs+ALP130)*zs+ALP030)*zt   &
+            &   + ((ALP320*zs+ALP220)*zs+ALP120)*zs+ALP020)*zt   &
+            &   + (((ALP410*zs+ALP310)*zs+ALP210)*zs+ALP110)*zs+ALP010)*zt   &
+            &   + ((((ALP500*zs+ALP400)*zs+ALP300)*zs+ALP200)*zs+ALP100)*zs+ALP000
+            !
+         zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+         !
+         pab(jp_tem) = zn * r1_rau0
+         !
+         ! beta
+         zn3 = BET003
+         !
+         zn2 = BET012*zt + BET102*zs+BET002
+         !
+         zn1 = ((BET031*zt   &
+            &   + BET121*zs+BET021)*zt   &
+            &   + (BET211*zs+BET111)*zs+BET011)*zt   &
+            &   + ((BET301*zs+BET201)*zs+BET101)*zs+BET001
+            !
+         zn0 = ((((BET050*zt   &
+            &   + BET140*zs+BET040)*zt   &
+            &   + (BET230*zs+BET130)*zs+BET030)*zt   &
+            &   + ((BET320*zs+BET220)*zs+BET120)*zs+BET020)*zt   &
+            &   + (((BET410*zs+BET310)*zs+BET210)*zs+BET110)*zs+BET010)*zt   &
+            &   + ((((BET500*zs+BET400)*zs+BET300)*zs+BET200)*zs+BET100)*zs+BET000
+            !
+         zn  = ( ( zn3 * zh + zn2 ) * zh + zn1 ) * zh + zn0
+         !
+         pab(jp_sal) = zn / zs * r1_rau0
+         !
+         !
+         !
+      CASE( 1 )                  !==  simplified EOS  ==!
+         !
+         zt    = pts(jp_tem) - 10._wp   ! pot. temperature anomaly (t-T0)
+         zs    = pts(jp_sal) - 35._wp   ! abs. salinity anomaly (s-S0)
+         zh    = pdep                    ! depth at the partial step level
+         !
+         zn  = rn_a0 * ( 1._wp + rn_lambda1*zt + rn_mu1*zh ) + rn_nu*zs
+         pab(jp_tem) = zn * r1_rau0   ! alpha
+         !
+         zn  = rn_b0 * ( 1._wp - rn_lambda2*zs - rn_mu2*zh ) - rn_nu*zt
+         pab(jp_sal) = zn * r1_rau0   ! beta
+         !
+      CASE DEFAULT
+         IF(lwp) WRITE(numout,cform_err)
+         IF(lwp) WRITE(numout,*) '          bad flag value for nn_eos = ', nn_eos
+         nstop = nstop + 1
+         !
+      END SELECT
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('rab_2d')
+      !
+   END SUBROUTINE rab_crs_0d
+
+
+   SUBROUTINE bn2_crs( pts, pab, pn2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE bn2  ***
+      !!
+      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the 
+      !!                time-step of the input arguments
+      !!
+      !! ** Method  :   pn2 = grav * (alpha dk[T] + beta dk[S] ) / e3w
+      !!      where alpha and beta are given in pab, and computed on T-points.
+      !!      N.B. N^2 is set one for all to zero at jk=1 in istate module.
+      !!
+      !! ** Action  :   pn2 : square of the brunt-vaisala frequency at w-point 
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk,jpts), INTENT(in   ) ::  pts   ! pot. temperature and salinity   [Celcius,psu]
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk,jpts), INTENT(in   ) ::  pab   ! thermal/haline expansion coef.  [Celcius-1,psu-1]
+      REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk     ), INTENT(  out) ::  pn2   ! Brunt-Vaisala frequency squared [1/s^2]
+      !
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   zaw, zbw, zrw   ! local scalars
+      !!----------------------------------------------------------------------
+      !
+      pn2(:,:,:)=0._wp
+
+      IF( nn_timing == 1 ) CALL timing_start('bn2')
+      !
+      DO jk = 2, jpkm1           ! interior points only (2=< jk =< jpkm1 )
+         DO jj = 1, jpj_crs          ! surface and bottom value set to zero one for all in istate.F90
+            DO ji = 1, jpi_crs
+               !zrw =   ( gdepw_crs(ji,jj,jk  ) - gdept_crs(ji,jj,jk) )   &
+               !   &  / ( gdept_crs(ji,jj,jk-1) - gdept_crs(ji,jj,jk) ) 
+               zrw =   gdepw_crs(ji,jj,jk  ) - gdept_crs(ji,jj,jk)    
+               !?IF( gdept_crs(ji,jj,jk-1) - gdept_crs(ji,jj,jk) .NE. 0._wp )THEN
+               IF( gdept_crs(ji,jj,jk-1) - gdept_crs(ji,jj,jk) .LT. 0._wp )THEN
+                  zrw = zrw  / ( gdept_crs(ji,jj,jk-1) - gdept_crs(ji,jj,jk) ) 
+               ELSE
+                  zrw = 0._wp
+               ENDIF
+               !
+               zaw = pab(ji,jj,jk,jp_tem) * (1._wp - zrw) + pab(ji,jj,jk-1,jp_tem) * zrw 
+               zbw = pab(ji,jj,jk,jp_sal) * (1._wp - zrw) + pab(ji,jj,jk-1,jp_sal) * zrw
+               !
+               IF( e3w_max_crs(ji,jj,jk) .NE. 0._wp ) THEN
+                  pn2(ji,jj,jk) = grav * (  zaw * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) )     &
+                     &                    - zbw * ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) )  )  &
+                  &                    * tmask_crs(ji,jj,jk)  / e3w_max_crs(ji,jj,jk)
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('bn2')
+      !
+   END SUBROUTINE bn2_crs
+
+   SUBROUTINE eos_init_crs
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE eos_init  ***
       !!
-      !! ** Purpose :   Compute the sea surface freezing temperature [Celcius]
-      !!
-      !! ** Method  :   UNESCO freezing point at the surface (pressure = 0???)
-      !!       freezing point [Celcius]=(-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s-7.53e-4*p
-      !!       checkvalue: tf= -2.588567 Celsius for s=40.0psu, p=500. decibars
-      !!
-      !! Reference  :   UNESCO tech. papers in the marine science no. 28. 1978
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity             [psu]
-      ! Leave result array automatic rather than making explicitly allocated
-      REAL(wp), DIMENSION(jpi,jpj)                ::   ptf    ! freezing temperature [Celcius]
-      !!----------------------------------------------------------------------
-      !
-      ptf(:,:) = ( - 0.0575_wp + 1.710523e-3_wp * SQRT( psal(:,:) )   &
-         &                     - 2.154996e-4_wp *       psal(:,:)   ) * psal(:,:)
-      !
-   END FUNCTION tfreez_crs
-
-
-   SUBROUTINE eos_init_crs
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE eos_init  ***
-      !!
       !! ** Purpose :   initializations for the equation of state
       !!
       !! ** Method  :   Read the namelist nameos and control the parameters
       !!----------------------------------------------------------------------
-      INTEGER ::   ios   ! Local integer output status for namelist read
-      !!
-      NAMELIST/nameos/ nn_eos, rn_alpha, rn_beta
-      !!----------------------------------------------------------------------
-      !
-      REWIND( numnam_ref )            
-      READ  ( numnam_ref, nameos, IOSTAT = ios, ERR = 901)
+      INTEGER  ::   ios   ! local integer
+      !!
+      NAMELIST/nameos/ nn_eos, ln_useCT, rn_a0, rn_b0, rn_lambda1, rn_mu1,   &
+         &                                             rn_lambda2, rn_mu2, rn_nu
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist nameos in reference namelist : equation of state
+      READ  ( numnam_ref, nameos, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nameos in reference namelist', lwp )
-
-      REWIND( numnam_cfg )    
+      !
+      REWIND( numnam_cfg )              ! Namelist nameos in configuration namelist : equation of state
       READ  ( numnam_cfg, nameos, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nameos in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, nameos )
-
+      IF(lwm) WRITE( numond, nameos )
+      !
+      rau0        = 1026._wp                 !: volumic mass of reference     [kg/m3]
+      rcp         = 3991.86795711963_wp      !: heat capacity     [J/K]
       !
       IF(lwp) THEN                ! Control print
@@ -756,25 +778,406 @@
          WRITE(numout,*) '          Namelist nameos : set eos parameters'
          WRITE(numout,*) '             flag for eq. of state and N^2  nn_eos   = ', nn_eos
-         WRITE(numout,*) '             thermal exp. coef. (linear)    rn_alpha = ', rn_alpha
-         WRITE(numout,*) '             saline  exp. coef. (linear)    rn_beta  = ', rn_beta
+         IF( ln_useCT )   THEN
+            WRITE(numout,*) '             model uses Conservative Temperature'
+            WRITE(numout,*) '             Important: model must be initialized with CT and SA fields'
+         ENDIF
       ENDIF
       !
       SELECT CASE( nn_eos )         ! check option
       !
-      CASE( 0 )                        !==  Jackett and McDougall (1994) formulation  ==!
+      CASE( -1 )                       !==  polynomial TEOS-10  ==!
          IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '          use of Jackett & McDougall (1994) equation of state and'
-         IF(lwp) WRITE(numout,*) '                 McDougall (1987) Brunt-Vaisala frequency'
-         !
-      CASE( 1 )                        !==  Linear formulation = F( temperature )  ==!
+         IF(lwp) WRITE(numout,*) '          use of TEOS-10 equation of state (cons. temp. and abs. salinity)'
+         !
+         rdeltaS = 32._wp
+         r1_S0  = 0.875_wp/35.16504_wp
+         r1_T0  = 1._wp/40._wp
+         r1_Z0  = 1.e-4_wp
+         !
+         EOS000 = 8.0189615746e+02_wp
+         EOS100 = 8.6672408165e+02_wp
+         EOS200 = -1.7864682637e+03_wp
+         EOS300 = 2.0375295546e+03_wp
+         EOS400 = -1.2849161071e+03_wp
+         EOS500 = 4.3227585684e+02_wp
+         EOS600 = -6.0579916612e+01_wp
+         EOS010 = 2.6010145068e+01_wp
+         EOS110 = -6.5281885265e+01_wp
+         EOS210 = 8.1770425108e+01_wp
+         EOS310 = -5.6888046321e+01_wp
+         EOS410 = 1.7681814114e+01_wp
+         EOS510 = -1.9193502195_wp
+         EOS020 = -3.7074170417e+01_wp
+         EOS120 = 6.1548258127e+01_wp
+         EOS220 = -6.0362551501e+01_wp
+         EOS320 = 2.9130021253e+01_wp
+         EOS420 = -5.4723692739_wp
+         EOS030 = 2.1661789529e+01_wp
+         EOS130 = -3.3449108469e+01_wp
+         EOS230 = 1.9717078466e+01_wp
+         EOS330 = -3.1742946532_wp
+         EOS040 = -8.3627885467_wp
+         EOS140 = 1.1311538584e+01_wp
+         EOS240 = -5.3563304045_wp
+         EOS050 = 5.4048723791e-01_wp
+         EOS150 = 4.8169980163e-01_wp
+         EOS060 = -1.9083568888e-01_wp
+         EOS001 = 1.9681925209e+01_wp
+         EOS101 = -4.2549998214e+01_wp
+         EOS201 = 5.0774768218e+01_wp
+         EOS301 = -3.0938076334e+01_wp
+         EOS401 = 6.6051753097_wp
+         EOS011 = -1.3336301113e+01_wp
+         EOS111 = -4.4870114575_wp
+         EOS211 = 5.0042598061_wp
+         EOS311 = -6.5399043664e-01_wp
+         EOS021 = 6.7080479603_wp
+         EOS121 = 3.5063081279_wp
+         EOS221 = -1.8795372996_wp
+         EOS031 = -2.4649669534_wp
+         EOS131 = -5.5077101279e-01_wp
+         EOS041 = 5.5927935970e-01_wp
+         EOS002 = 2.0660924175_wp
+         EOS102 = -4.9527603989_wp
+         EOS202 = 2.5019633244_wp
+         EOS012 = 2.0564311499_wp
+         EOS112 = -2.1311365518e-01_wp
+         EOS022 = -1.2419983026_wp
+         EOS003 = -2.3342758797e-02_wp
+         EOS103 = -1.8507636718e-02_wp
+         EOS013 = 3.7969820455e-01_wp
+         !
+         ALP000 = -6.5025362670e-01_wp
+         ALP100 = 1.6320471316_wp
+         ALP200 = -2.0442606277_wp
+         ALP300 = 1.4222011580_wp
+         ALP400 = -4.4204535284e-01_wp
+         ALP500 = 4.7983755487e-02_wp
+         ALP010 = 1.8537085209_wp
+         ALP110 = -3.0774129064_wp
+         ALP210 = 3.0181275751_wp
+         ALP310 = -1.4565010626_wp
+         ALP410 = 2.7361846370e-01_wp
+         ALP020 = -1.6246342147_wp
+         ALP120 = 2.5086831352_wp
+         ALP220 = -1.4787808849_wp
+         ALP320 = 2.3807209899e-01_wp
+         ALP030 = 8.3627885467e-01_wp
+         ALP130 = -1.1311538584_wp
+         ALP230 = 5.3563304045e-01_wp
+         ALP040 = -6.7560904739e-02_wp
+         ALP140 = -6.0212475204e-02_wp
+         ALP050 = 2.8625353333e-02_wp
+         ALP001 = 3.3340752782e-01_wp
+         ALP101 = 1.1217528644e-01_wp
+         ALP201 = -1.2510649515e-01_wp
+         ALP301 = 1.6349760916e-02_wp
+         ALP011 = -3.3540239802e-01_wp
+         ALP111 = -1.7531540640e-01_wp
+         ALP211 = 9.3976864981e-02_wp
+         ALP021 = 1.8487252150e-01_wp
+         ALP121 = 4.1307825959e-02_wp
+         ALP031 = -5.5927935970e-02_wp
+         ALP002 = -5.1410778748e-02_wp
+         ALP102 = 5.3278413794e-03_wp
+         ALP012 = 6.2099915132e-02_wp
+         ALP003 = -9.4924551138e-03_wp
+         !
+         BET000 = 1.0783203594e+01_wp
+         BET100 = -4.4452095908e+01_wp
+         BET200 = 7.6048755820e+01_wp
+         BET300 = -6.3944280668e+01_wp
+         BET400 = 2.6890441098e+01_wp
+         BET500 = -4.5221697773_wp
+         BET010 = -8.1219372432e-01_wp
+         BET110 = 2.0346663041_wp
+         BET210 = -2.1232895170_wp
+         BET310 = 8.7994140485e-01_wp
+         BET410 = -1.1939638360e-01_wp
+         BET020 = 7.6574242289e-01_wp
+         BET120 = -1.5019813020_wp
+         BET220 = 1.0872489522_wp
+         BET320 = -2.7233429080e-01_wp
+         BET030 = -4.1615152308e-01_wp
+         BET130 = 4.9061350869e-01_wp
+         BET230 = -1.1847737788e-01_wp
+         BET040 = 1.4073062708e-01_wp
+         BET140 = -1.3327978879e-01_wp
+         BET050 = 5.9929880134e-03_wp
+         BET001 = -5.2937873009e-01_wp
+         BET101 = 1.2634116779_wp
+         BET201 = -1.1547328025_wp
+         BET301 = 3.2870876279e-01_wp
+         BET011 = -5.5824407214e-02_wp
+         BET111 = 1.2451933313e-01_wp
+         BET211 = -2.4409539932e-02_wp
+         BET021 = 4.3623149752e-02_wp
+         BET121 = -4.6767901790e-02_wp
+         BET031 = -6.8523260060e-03_wp
+         BET002 = -6.1618945251e-02_wp
+         BET102 = 6.2255521644e-02_wp
+         BET012 = -2.6514181169e-03_wp
+         BET003 = -2.3025968587e-04_wp
+         !
+         PEN000 = -9.8409626043_wp
+         PEN100 = 2.1274999107e+01_wp
+         PEN200 = -2.5387384109e+01_wp
+         PEN300 = 1.5469038167e+01_wp
+         PEN400 = -3.3025876549_wp
+         PEN010 = 6.6681505563_wp
+         PEN110 = 2.2435057288_wp
+         PEN210 = -2.5021299030_wp
+         PEN310 = 3.2699521832e-01_wp
+         PEN020 = -3.3540239802_wp
+         PEN120 = -1.7531540640_wp
+         PEN220 = 9.3976864981e-01_wp
+         PEN030 = 1.2324834767_wp
+         PEN130 = 2.7538550639e-01_wp
+         PEN040 = -2.7963967985e-01_wp
+         PEN001 = -1.3773949450_wp
+         PEN101 = 3.3018402659_wp
+         PEN201 = -1.6679755496_wp
+         PEN011 = -1.3709540999_wp
+         PEN111 = 1.4207577012e-01_wp
+         PEN021 = 8.2799886843e-01_wp
+         PEN002 = 1.7507069098e-02_wp
+         PEN102 = 1.3880727538e-02_wp
+         PEN012 = -2.8477365341e-01_wp
+         !
+         APE000 = -1.6670376391e-01_wp
+         APE100 = -5.6087643219e-02_wp
+         APE200 = 6.2553247576e-02_wp
+         APE300 = -8.1748804580e-03_wp
+         APE010 = 1.6770119901e-01_wp
+         APE110 = 8.7657703198e-02_wp
+         APE210 = -4.6988432490e-02_wp
+         APE020 = -9.2436260751e-02_wp
+         APE120 = -2.0653912979e-02_wp
+         APE030 = 2.7963967985e-02_wp
+         APE001 = 3.4273852498e-02_wp
+         APE101 = -3.5518942529e-03_wp
+         APE011 = -4.1399943421e-02_wp
+         APE002 = 7.1193413354e-03_wp
+         !
+         BPE000 = 2.6468936504e-01_wp
+         BPE100 = -6.3170583896e-01_wp
+         BPE200 = 5.7736640125e-01_wp
+         BPE300 = -1.6435438140e-01_wp
+         BPE010 = 2.7912203607e-02_wp
+         BPE110 = -6.2259666565e-02_wp
+         BPE210 = 1.2204769966e-02_wp
+         BPE020 = -2.1811574876e-02_wp
+         BPE120 = 2.3383950895e-02_wp
+         BPE030 = 3.4261630030e-03_wp
+         BPE001 = 4.1079296834e-02_wp
+         BPE101 = -4.1503681096e-02_wp
+         BPE011 = 1.7676120780e-03_wp
+         BPE002 = 1.7269476440e-04_wp
+         !
+      CASE( 0 )                        !==  polynomial EOS-80 formulation  ==!
+         !
          IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T) = rau0 * ( 1.0285 - rn_alpha * T )'
-         IF( lk_zdfddm ) CALL ctl_stop( '          double diffusive mixing parameterization requires',   &
-              &                         ' that T and S are used as state variables' )
-         !
-      CASE( 2 )                        !==  Linear formulation = F( temperature , salinity )  ==!
-         ralpbet_crs = rn_alpha / rn_beta
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T,S) = rau0 * ( rn_beta * S - rn_alpha * T )'
+         IF(lwp) WRITE(numout,*) '          use of EOS-80 equation of state (pot. temp. and pract. salinity)'
+         !
+         rdeltaS = 20._wp
+         r1_S0  = 1._wp/40._wp
+         r1_T0  = 1._wp/40._wp
+         r1_Z0  = 1.e-4_wp
+         !
+         EOS000 = 9.5356891948e+02_wp
+         EOS100 = 1.7136499189e+02_wp
+         EOS200 = -3.7501039454e+02_wp
+         EOS300 = 5.1856810420e+02_wp
+         EOS400 = -3.7264470465e+02_wp
+         EOS500 = 1.4302533998e+02_wp
+         EOS600 = -2.2856621162e+01_wp
+         EOS010 = 1.0087518651e+01_wp
+         EOS110 = -1.3647741861e+01_wp
+         EOS210 = 8.8478359933_wp
+         EOS310 = -7.2329388377_wp
+         EOS410 = 1.4774410611_wp
+         EOS510 = 2.0036720553e-01_wp
+         EOS020 = -2.5579830599e+01_wp
+         EOS120 = 2.4043512327e+01_wp
+         EOS220 = -1.6807503990e+01_wp
+         EOS320 = 8.3811577084_wp
+         EOS420 = -1.9771060192_wp
+         EOS030 = 1.6846451198e+01_wp
+         EOS130 = -2.1482926901e+01_wp
+         EOS230 = 1.0108954054e+01_wp
+         EOS330 = -6.2675951440e-01_wp
+         EOS040 = -8.0812310102_wp
+         EOS140 = 1.0102374985e+01_wp
+         EOS240 = -4.8340368631_wp
+         EOS050 = 1.2079167803_wp
+         EOS150 = 1.1515380987e-01_wp
+         EOS060 = -2.4520288837e-01_wp
+         EOS001 = 1.0748601068e+01_wp
+         EOS101 = -1.7817043500e+01_wp
+         EOS201 = 2.2181366768e+01_wp
+         EOS301 = -1.6750916338e+01_wp
+         EOS401 = 4.1202230403_wp
+         EOS011 = -1.5852644587e+01_wp
+         EOS111 = -7.6639383522e-01_wp
+         EOS211 = 4.1144627302_wp
+         EOS311 = -6.6955877448e-01_wp
+         EOS021 = 9.9994861860_wp
+         EOS121 = -1.9467067787e-01_wp
+         EOS221 = -1.2177554330_wp
+         EOS031 = -3.4866102017_wp
+         EOS131 = 2.2229155620e-01_wp
+         EOS041 = 5.9503008642e-01_wp
+         EOS002 = 1.0375676547_wp
+         EOS102 = -3.4249470629_wp
+         EOS202 = 2.0542026429_wp
+         EOS012 = 2.1836324814_wp
+         EOS112 = -3.4453674320e-01_wp
+         EOS022 = -1.2548163097_wp
+         EOS003 = 1.8729078427e-02_wp
+         EOS103 = -5.7238495240e-02_wp
+         EOS013 = 3.8306136687e-01_wp
+         !
+         ALP000 = -2.5218796628e-01_wp
+         ALP100 = 3.4119354654e-01_wp
+         ALP200 = -2.2119589983e-01_wp
+         ALP300 = 1.8082347094e-01_wp
+         ALP400 = -3.6936026529e-02_wp
+         ALP500 = -5.0091801383e-03_wp
+         ALP010 = 1.2789915300_wp
+         ALP110 = -1.2021756164_wp
+         ALP210 = 8.4037519952e-01_wp
+         ALP310 = -4.1905788542e-01_wp
+         ALP410 = 9.8855300959e-02_wp
+         ALP020 = -1.2634838399_wp
+         ALP120 = 1.6112195176_wp
+         ALP220 = -7.5817155402e-01_wp
+         ALP320 = 4.7006963580e-02_wp
+         ALP030 = 8.0812310102e-01_wp
+         ALP130 = -1.0102374985_wp
+         ALP230 = 4.8340368631e-01_wp
+         ALP040 = -1.5098959754e-01_wp
+         ALP140 = -1.4394226233e-02_wp
+         ALP050 = 3.6780433255e-02_wp
+         ALP001 = 3.9631611467e-01_wp
+         ALP101 = 1.9159845880e-02_wp
+         ALP201 = -1.0286156825e-01_wp
+         ALP301 = 1.6738969362e-02_wp
+         ALP011 = -4.9997430930e-01_wp
+         ALP111 = 9.7335338937e-03_wp
+         ALP211 = 6.0887771651e-02_wp
+         ALP021 = 2.6149576513e-01_wp
+         ALP121 = -1.6671866715e-02_wp
+         ALP031 = -5.9503008642e-02_wp
+         ALP002 = -5.4590812035e-02_wp
+         ALP102 = 8.6134185799e-03_wp
+         ALP012 = 6.2740815484e-02_wp
+         ALP003 = -9.5765341718e-03_wp
+         !
+         BET000 = 2.1420623987_wp
+         BET100 = -9.3752598635_wp
+         BET200 = 1.9446303907e+01_wp
+         BET300 = -1.8632235232e+01_wp
+         BET400 = 8.9390837485_wp
+         BET500 = -1.7142465871_wp
+         BET010 = -1.7059677327e-01_wp
+         BET110 = 2.2119589983e-01_wp
+         BET210 = -2.7123520642e-01_wp
+         BET310 = 7.3872053057e-02_wp
+         BET410 = 1.2522950346e-02_wp
+         BET020 = 3.0054390409e-01_wp
+         BET120 = -4.2018759976e-01_wp
+         BET220 = 3.1429341406e-01_wp
+         BET320 = -9.8855300959e-02_wp
+         BET030 = -2.6853658626e-01_wp
+         BET130 = 2.5272385134e-01_wp
+         BET230 = -2.3503481790e-02_wp
+         BET040 = 1.2627968731e-01_wp
+         BET140 = -1.2085092158e-01_wp
+         BET050 = 1.4394226233e-03_wp
+         BET001 = -2.2271304375e-01_wp
+         BET101 = 5.5453416919e-01_wp
+         BET201 = -6.2815936268e-01_wp
+         BET301 = 2.0601115202e-01_wp
+         BET011 = -9.5799229402e-03_wp
+         BET111 = 1.0286156825e-01_wp
+         BET211 = -2.5108454043e-02_wp
+         BET021 = -2.4333834734e-03_wp
+         BET121 = -3.0443885826e-02_wp
+         BET031 = 2.7786444526e-03_wp
+         BET002 = -4.2811838287e-02_wp
+         BET102 = 5.1355066072e-02_wp
+         BET012 = -4.3067092900e-03_wp
+         BET003 = -7.1548119050e-04_wp
+         !
+         PEN000 = -5.3743005340_wp
+         PEN100 = 8.9085217499_wp
+         PEN200 = -1.1090683384e+01_wp
+         PEN300 = 8.3754581690_wp
+         PEN400 = -2.0601115202_wp
+         PEN010 = 7.9263222935_wp
+         PEN110 = 3.8319691761e-01_wp
+         PEN210 = -2.0572313651_wp
+         PEN310 = 3.3477938724e-01_wp
+         PEN020 = -4.9997430930_wp
+         PEN120 = 9.7335338937e-02_wp
+         PEN220 = 6.0887771651e-01_wp
+         PEN030 = 1.7433051009_wp
+         PEN130 = -1.1114577810e-01_wp
+         PEN040 = -2.9751504321e-01_wp
+         PEN001 = -6.9171176978e-01_wp
+         PEN101 = 2.2832980419_wp
+         PEN201 = -1.3694684286_wp
+         PEN011 = -1.4557549876_wp
+         PEN111 = 2.2969116213e-01_wp
+         PEN021 = 8.3654420645e-01_wp
+         PEN002 = -1.4046808820e-02_wp
+         PEN102 = 4.2928871430e-02_wp
+         PEN012 = -2.8729602515e-01_wp
+         !
+         APE000 = -1.9815805734e-01_wp
+         APE100 = -9.5799229402e-03_wp
+         APE200 = 5.1430784127e-02_wp
+         APE300 = -8.3694846809e-03_wp
+         APE010 = 2.4998715465e-01_wp
+         APE110 = -4.8667669469e-03_wp
+         APE210 = -3.0443885826e-02_wp
+         APE020 = -1.3074788257e-01_wp
+         APE120 = 8.3359333577e-03_wp
+         APE030 = 2.9751504321e-02_wp
+         APE001 = 3.6393874690e-02_wp
+         APE101 = -5.7422790533e-03_wp
+         APE011 = -4.1827210323e-02_wp
+         APE002 = 7.1824006288e-03_wp
+         !
+         BPE000 = 1.1135652187e-01_wp
+         BPE100 = -2.7726708459e-01_wp
+         BPE200 = 3.1407968134e-01_wp
+         BPE300 = -1.0300557601e-01_wp
+         BPE010 = 4.7899614701e-03_wp
+         BPE110 = -5.1430784127e-02_wp
+         BPE210 = 1.2554227021e-02_wp
+         BPE020 = 1.2166917367e-03_wp
+         BPE120 = 1.5221942913e-02_wp
+         BPE030 = -1.3893222263e-03_wp
+         BPE001 = 2.8541225524e-02_wp
+         BPE101 = -3.4236710714e-02_wp
+         BPE011 = 2.8711395266e-03_wp
+         BPE002 = 5.3661089288e-04_wp
+         !
+      CASE( 1 )                        !==  Simplified EOS     ==!
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) '          use of simplified eos:    rhd(dT=T-10,dS=S-35,Z) = '
+            WRITE(numout,*) '             [-a0*(1+lambda1/2*dT+mu1*Z)*dT + b0*(1+lambda2/2*dT+mu2*Z)*dS - nu*dT*dS]/rau0'
+            WRITE(numout,*)
+            WRITE(numout,*) '             thermal exp. coef.    rn_a0      = ', rn_a0
+            WRITE(numout,*) '             saline  cont. coef.   rn_b0      = ', rn_b0
+            WRITE(numout,*) '             cabbeling coef.       rn_lambda1 = ', rn_lambda1
+            WRITE(numout,*) '             cabbeling coef.       rn_lambda2 = ', rn_lambda2
+            WRITE(numout,*) '             thermobar. coef.      rn_mu1     = ', rn_mu1
+            WRITE(numout,*) '             thermobar. coef.      rn_mu2     = ', rn_mu2
+            WRITE(numout,*) '             2nd cabbel. coef.     rn_nu      = ', rn_nu
+            WRITE(numout,*) '               Caution: rn_beta0=0 incompatible with ddm parameterization '
+         ENDIF
          !
       CASE DEFAULT                     !==  ERROR in nn_eos  ==!
@@ -784,4 +1187,14 @@
       END SELECT
       !
+      r1_rau0     = 1._wp / rau0
+      r1_rcp      = 1._wp / rcp
+      r1_rau0_rcp = 1._wp / ( rau0 * rcp )
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          volumic mass of reference           rau0  = ', rau0   , ' kg/m^3'
+      IF(lwp) WRITE(numout,*) '          1. / rau0                        r1_rau0  = ', r1_rau0, ' m^3/kg'
+      IF(lwp) WRITE(numout,*) '          ocean specific heat                 rcp   = ', rcp    , ' J/Kelvin'
+      IF(lwp) WRITE(numout,*) '          1. / ( rau0 * rcp )           r1_rau0_rcp = ', r1_rau0_rcp
+      !
    END SUBROUTINE eos_init_crs
 
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd_crs.F90	(revision 5601)
@@ -24,5 +24,5 @@
    USE oce             ! ocean dynamics and active tracers
    USE dom_oce , ONLY : lk_vvl
-   USE trdmod_oce      ! tracers trends
+   USE trd_oce         ! tracers trends
    USE trdtra          ! tracers trends
    USE in_out_manager  ! I/O manager
@@ -123,24 +123,4 @@
          ! 2. upstream advection with initial mass fluxes & intermediate update
          ! --------------------------------------------------------------------
-        !DO jk = 2, jpkm1          ! Interior value
-        !    DO jj = 1, jpj
-        !       DO ji = 1, jpi
-        !          IF( ptb(ji,jj,jk,jn) .NE. ptb(ji,jj,jk,jn) )WRITE(narea+200,*)"ADVtb",ptb(ji,jj,jk,jn) ; call flush(narea+200)
-        !          IF( ptn(ji,jj,jk,jn) .NE. ptn(ji,jj,jk,jn) )WRITE(narea+200,*)"ADVtn",ptb(ji,jj,jk,jn) ; call flush(narea+200)
-        !          IF( pun(ji,jj,jk) .NE. pun(ji,jj,jk) )WRITE(narea+200,*)"ADVun",pun(ji,jj,jk) ; call flush(narea+200)
-        !          IF( pvn(ji,jj,jk) .NE. pvn(ji,jj,jk) )WRITE(narea+200,*)"ADVvn",pvn(ji,jj,jk) ; call flush(narea+200)
-        !          IF( pwn(ji,jj,jk) .NE. pwn(ji,jj,jk) )WRITE(narea+200,*)"ADVwn",pwn(ji,jj,jk) ; call flush(narea+200)
-        !       END DO
-        !    END DO
-        ! END DO
-        ! ji=117 ; jj=211 ; jk=74
-        ! ji=ji-nimpp_crs+1 ; jj=jj-njmpp_crs+1
-        ! IF( ji .GE. 2 .AND. ji .LE. jpi_crs-1 .AND. jj .GE. 2 .AND. jj .LE. jpj_crs-1 )THEN
-        ! WRITE(narea+5000,*)"tvd =======> kt ",kt
-        ! WRITE(narea+5000,*)ptb(ji,jj,jk,jn),ptn(ji,jj,jk,jn)
-        ! WRITE(narea+5000,*)pun(ji-1,jj,jk),pun(ji,jj,jk)
-        ! WRITE(narea+5000,*)pvn(ji,jj-1,jk),pun(ji,jj,jk)
-        ! WRITE(narea+5000,*)pwn(ji,jj,jk),pwn(ji,jj,jk+1)
-        ! ENDIF
 
          ! upstream tracer flux in the i and j direction
@@ -173,6 +153,4 @@
             END DO
          END DO
-!WRITE(numout,*) 'test_tra', maxval(pta(:,:,:,1)) , kt
-!WRITE(numout,*) 'test_tra', minval(pta(:,:,:,1)) , kt
          ! total advective trend
          DO jk = 1, jpkm1
@@ -188,22 +166,7 @@
                   pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra
                   zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask_crs(ji,jj,jk)
-                  !iji=117 ; ijj=211 ; ijk=74
-                  !iji=iji-nimpp+1 ; ijj=ijj-njmpp+1
-                  !IF( ji==iji .AND. jj==ijj )THEN
-                  !WRITE(narea+5000,*)"test ",jk,zwx(ji,jj,jk) , zwx(ji-1,jj  ,jk  ), & 
-                  !              zwy(ji,jj,jk) , zwy(ji  ,jj-1,jk  ),zwz(ji,jj,jk),zwz(ji  ,jj  ,jk+1)
-                  !ENDIF
-                  !IF( ztra .NE. 0._wp )WRITE(narea+6000,*)"buga ",kt,ji,jj,jk,mbathy_crs(ji,jj), &
-                  !    zwx(ji,jj,jk) , zwx(ji-1,jj  ,jk  ),zwy(ji,jj,jk) , zwy(ji  ,jj-1,jk  ),zwz(ji,jj,jk),zwz(ji  ,jj  ,jk+1)
-               END DO
-            END DO
-         END DO
-         !IF(narea==267)WRITE(narea+5000,*)"1 pta(17,6,74,1) = ",pta(17,6,74,1)
-         !zmin=MINVAL( pta(2:jpi-1,2:jpj-1,2:jpk,1),mask=(tmask(2:jpi-1,2:jpj-1,2:jpk)==1)) ; CALL mpp_min(zmin)
-         !zmax=MAXVAL( pta(2:jpi-1,2:jpj-1,2:jpk,1),mask=(tmask(2:jpi-1,2:jpj-1,2:jpk)==1)) ; CALL mpp_max(zmax)
-         !IF(lwp)WRITE(numout,*)"trcadvtvdcrs a ",kt,zmin,zmax
-
-!WRITE(numout,*) 'test_tra', maxval(pta(:,:,:,jk)) , kt
-!WRITE(numout,*) 'test_tra', minval(pta(:,:,:,jk)) , kt
+               END DO
+            END DO
+         END DO
          !                             ! Lateral boundary conditions on zwi  (unchanged sign)
          CALL crs_lbc_lnk( zwi, 'T', 1. )  
@@ -226,21 +189,9 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  !iji=117 ; ijj=211 ; ijk=74
-                  !iji=iji-nimpp+1 ; ijj=ijj-njmpp+1
-                  !IF( ji==iji .AND. jj==ijj )THEN
-                  !WRITE(narea+5000,*)"antidiffxy ",jk,pun(ji,jj,jk),ptn(ji,jj,jk,jn),ptn(ji+1,jj,jk,jn),zwx(ji,jj,jk)
-                  !WRITE(narea+5000,*)"antidiffxy ",jk,pvn(ji,jj,jk),ptn(ji,jj,jk,jn),ptn(ji,jj+1,jk,jn),zwy(ji,jj,jk)
-                  !ENDIF
                   zwx(ji,jj,jk) = 0.5 * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj,jk,jn) ) - zwx(ji,jj,jk)
                   zwy(ji,jj,jk) = 0.5 * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj+1,jk,jn) ) - zwy(ji,jj,jk)
-                  !iji=117 ; ijj=211 ; ijk=74
-                  !iji=iji-nimpp+1 ; ijj=ijj-njmpp+1
-                  !IF( ji==iji .AND. jj==ijj )THEN
-                  !WRITE(narea+5000,*)"antidiffxy ",jk,zwx(ji,jj,jk),zwy(ji,jj,jk) 
-                  !ENDIF
-               END DO
-            END DO
-         END DO
-  !    WRITE(numout,*) 'test6456_trb_sbc', pta(10,10,1,1), kt
+               END DO
+            END DO
+         END DO
          ! antidiffusive flux on k
          zwz(:,:,1) = 0.e0         ! Surface value
@@ -250,9 +201,4 @@
                DO ji = 1, jpi
                   zwz(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) ) - zwz(ji,jj,jk)
-                  !iji=117 ; ijj=211 ; ijk=74
-                  !iji=iji-nimpp+1 ; ijj=ijj-njmpp+1
-                  !IF( ji==iji .AND. jj==ijj )THEN
-                  !WRITE(narea+5000,*)"antidiffz ",jk,zwz(ji,jj,jk)
-                  !ENDIF
                END DO
             END DO
@@ -263,24 +209,5 @@
          ! 4. monotonicity algorithm
          ! -------------------------
-         !DO jk = 2, jpkm1          ! Interior value
-         !   DO jj = 1, jpj
-         !      DO ji = 1, jpi
-         !         IF( ptb(ji,jj,jk,jn) .NE. ptb(ji,jj,jk,jn) )WRITE(narea+200,*)"ADV1",ptb(ji,jj,jk,jn) ; call flush(narea+200)
-         !         IF( zwx(ji,jj,jk) .NE. zwx(ji,jj,jk) )WRITE(narea+200,*)"ADV2",zwx(ji,jj,jk) ; call flush(narea+200)
-         !         IF( zwy(ji,jj,jk) .NE. zwy(ji,jj,jk) )WRITE(narea+200,*)"ADV3",zwy(ji,jj,jk) ; call flush(narea+200)
-         !         IF( zwz(ji,jj,jk) .NE. zwz(ji,jj,jk) )WRITE(narea+200,*)"ADV4",zwz(ji,jj,jk) ; call flush(narea+200)
-         !         IF( zwi(ji,jj,jk) .NE. zwi(ji,jj,jk) )WRITE(narea+200,*)"ADV5",zwi(ji,jj,jk) ; call flush(narea+200)
-         !         IF( tmask_crs(ji,jj,jk) .NE. tmask_crs(ji,jj,jk) )WRITE(narea+200,*)"ADV6",tmask_crs(ji,jj,jk) ; call flush(narea+200)
-         !      END DO
-         !   END DO
-         !END DO
-  
          CALL nonosc_crs( ptb(:,:,:,jn), zwx, zwy, zwz, zwi, p2dt )
-
-         !IF( narea==267 )THEN
-         !DO jk=1,jpk-1
-         !WRITE(narea+5000,*)"toto",jk,zwx(16,6,jk),zwx(17,6,jk),zwy(17,5,jk),zwy(17,6,jk),zwz(17,6,jk),zwz(17,6,jk+1)
-         !ENDDO
-         !ENDIF
 
          ! 5. final trend with corrected fluxes
@@ -298,23 +225,8 @@
 
 
-                  !IF( narea==267 .AND. ji==17 .AND. jj==6 )THEN 
-                  !WRITE(narea+5000,*)"correc ",jk,ptb(ji,jj,jk,1),pta(ji,jj,jk,1),zwx(ji,jj,jk) , zwx(ji-1,jj  ,jk  ), &
-                  !              zwy(ji,jj,jk) , zwy(ji  ,jj-1,jk  ),zwz(ji,jj,jk),zwz(ji  ,jj  ,jk+1)
-                  !ENDIF
-
-
-                  !IF( ztra .NE. 0._wp )WRITE(narea+6000,*)"bugb ",kt,ji,jj,jk,mbathy_crs(ji,jj), &
-                  !    zwx(ji,jj,jk) , zwx(ji-1,jj  ,jk  ),zwy(ji,jj,jk) , zwy(ji  ,jj-1,jk  ),zwz(ji,jj,jk),zwz(ji  ,jj  ,jk+1)
-               END DO
-            END DO
-         END DO
-         !IF(narea==267)WRITE(narea+5000,*)"2 pta(17,6,74,1) = ",pta(17,6,74,1)
-         !zmin=MINVAL( pta(2:jpi-1,2:jpj-1,2:jpk,1),mask=(tmask(2:jpi-1,2:jpj-1,2:jpk)==1)) ; CALL mpp_min(zmin)
-         !zmax=MAXVAL( pta(2:jpi-1,2:jpj-1,2:jpk,1),mask=(tmask(2:jpi-1,2:jpj-1,2:jpk)==1)) ; CALL mpp_max(zmax)
-         !IF(lwp)WRITE(numout,*)"trcadvtvdcrs b ",kt,zmin,zmax
-
-!WRITE(numout,*) 'test_tra', maxval(pta(:,:,:,jk)) , kt
-!WRITE(numout,*) 'test_tra', minval(pta(:,:,:,jk)) , kt
-!WRITE(numout,*) 'test6456_trb_sbc', pta(10,10,1,1), kt
+               END DO
+            END DO
+         END DO
+
          !                                 ! trend diagnostics (contribution of upstream fluxes)
          IF( l_trd )  THEN 
@@ -323,7 +235,7 @@
             ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
             
-            CALL trd_tra( kt, cdtype, jn, jptra_trd_xad, ztrdx, pun, ptn(:,:,:,jn) )   
-            CALL trd_tra( kt, cdtype, jn, jptra_trd_yad, ztrdy, pvn, ptn(:,:,:,jn) )  
-            CALL trd_tra( kt, cdtype, jn, jptra_trd_zad, ztrdz, pwn, ptn(:,:,:,jn) ) 
+            CALL trd_tra( kt, cdtype, jn, jptra_xad, ztrdx, pun, ptn(:,:,:,jn) )   
+            CALL trd_tra( kt, cdtype, jn, jptra_yad, ztrdy, pvn, ptn(:,:,:,jn) )  
+            CALL trd_tra( kt, cdtype, jn, jptra_zad, ztrdz, pwn, ptn(:,:,:,jn) ) 
          END IF
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
@@ -339,6 +251,4 @@
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_adv_tvd')
-  !    IF(lwp) WRITE(numout,*) 'TEST2', pta
-!WRITE(numout,*) 'test6456_trb_sbc', pta(10,10,1,1), kt
       !
    END SUBROUTINE tra_adv_tvd_crs
@@ -434,21 +344,10 @@
                zbu = MIN( 1.e0, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
                zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )THEN 
-               !   WRITE(narea+5000,*)"nonosc ",jk
-               !   WRITE(narea+5000,*)"paa",zbetdo(ji,jj,jk),zbetup(ji+1,jj,jk),zbetup(ji,jj,jk),zbetdo(ji+1,jj,jk)
-               !   WRITE(narea+5000,*)"paa",zau,zbu,zcu, paa(ji,jj,jk)
-               !ENDIF
                paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1.e0 - zcu) * zbu )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )WRITE(narea+5000,*)"paa",paa(ji,jj,jk)
 
                zav = MIN( 1.e0, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
                zbv = MIN( 1.e0, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
                zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )THEN 
-               !   WRITE(narea+5000,*)"pbb",zbetdo(ji,jj,jk),zbetup(ji,jj+1,jk),zbetup(ji,jj,jk),zbetdo(ji,jj+1,jk)
-               !   WRITE(narea+5000,*)"pbb",zav,zbv,zcv, pbb(ji,jj,jk)
-               !ENDIF
                pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1.e0 - zcv) * zbv )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )WRITE(narea+5000,*)"pbb",pbb(ji,jj,jk)
 
       ! monotonic flux in the k direction, i.e. pcc
@@ -457,26 +356,10 @@
                zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
                zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )THEN 
-               !   WRITE(narea+5000,*)"pcc",zbetdo(ji,jj,jk+1),zbetup(ji,jj,jk),zbetup(ji,jj,jk+1),zbetdo(ji,jj,jk)
-               !   WRITE(narea+5000,*)"pcc",za,zb,zc, pcc(ji,jj,jk+1)
-               !ENDIF
                pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1.e0 - zc) * zb )
-               !IF( narea==267 .AND. ji==17 .AND. jj==6 )WRITE(narea+5000,*)"pcc",pcc(ji,jj,jk+1)
             END DO
          END DO
       END DO
 
-         !IF( narea==267 )THEN
-         !DO jk=1,jpk-1
-         !WRITE(narea+5000,*)"nono",jk,paa(16,6,jk),paa(17,6,jk),pbb(17,5,jk),pbb(17,6,jk),pcc(17,6,jk),pcc(17,6,jk+1)
-         !ENDDO
-         !ENDIF
-
       CALL crs_lbc_lnk( paa, 'U', -1. )   ;   CALL crs_lbc_lnk( pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
-         !IF( narea==267 )THEN
-         !DO jk=1,jpk-1
-         !WRITE(narea+5000,*)"nono1",jk,paa(16,6,jk),paa(17,6,jk),pbb(17,5,jk),pbb(17,6,jk),pcc(17,6,jk),pcc(17,6,jk+1)
-         !!ENDDO
-         !ENDIF
       !
       CALL wrk_dealloc( jpi, jpj, jpk, zbetup, zbetdo, zbup, zbdo )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl_crs.F90	(revision 5601)
@@ -28,5 +28,5 @@
    USE phycst         ! physical constant
    USE eosbn2_crs     ! equation of state
-   USE trdmod_oce     ! trends: ocean variables
+   USE trd_oce        ! trends: ocean variables
    USE trdtra         ! trends: active tracers
    USE iom            ! IOM server               
@@ -38,5 +38,5 @@
    USE crs
    USE crslbclnk
-   USE crsiom
+   USE crsfld
 
 
@@ -154,6 +154,6 @@
          ztrdt(:,:,:) = tsa_crs(:,:,:,jp_tem) - ztrdt(:,:,:)
          ztrds(:,:,:) = tsa_crs(:,:,:,jp_sal) - ztrds(:,:,:)
-         CALL trd_tra( kt, 'TRA', jp_tem, jptra_trd_bbl, ztrdt )
-         CALL trd_tra( kt, 'TRA', jp_sal, jptra_trd_bbl, ztrds )
+         CALL trd_tra( kt, 'TRA', jp_tem, jptra_bbl, ztrdt )
+         CALL trd_tra( kt, 'TRA', jp_sal, jptra_bbl, ztrds )
          CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds ) 
       ENDIF
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_crs.F90	(revision 5601)
@@ -19,10 +19,10 @@
    !!                  the isopycnal or geopotential s-coord. operator 
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE dom_oce         ! ocean space and time domain
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE zdf_oce         ! ocean vertical physics
-   USE ldftra_oce      ! ocean active tracers: lateral physics
- !  USE ldfslp          ! iso-neutral slopes
+!   USE oce             ! ocean dynamics and active tracers
+!   USE dom_oce         ! ocean space and time domain
+!   USE trc_oce         ! share passive tracers/Ocean variables
+!   USE zdf_oce         ! ocean vertical physics
+!   USE ldftra_oce      ! ocean active tracers: lateral physics
+!   USE ldfslp          ! iso-neutral slopes
    USE ldfslp_crs          ! iso-neutral slopes
    USE diaptr          ! poleward transport diagnostics
@@ -35,5 +35,7 @@
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
-   USE crs
+!   USE crs
+   USE oce_trc
+   USE iom, ONLY : iom_put,iom_swap
 
    IMPLICIT NONE
@@ -94,5 +96,4 @@
       !! ** Action :   Update pta arrays with the before rotated diffusion
       !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zftu => ua       , zftv  => va         ! (ua,va) used as workspace
       !
       INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
@@ -113,5 +114,5 @@
 #endif
       REAL(wp), POINTER, DIMENSION(:,:  ) ::  zdkt, zdk1t, z2d
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zdit, zdjt, ztfw 
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zdit, zdjt, ztfw , zftu,  zftv 
       !!----------------------------------------------------------------------
       !
@@ -119,5 +120,5 @@
       !
       CALL wrk_alloc( jpi, jpj,      zdkt, zdk1t, z2d ) 
-      CALL wrk_alloc( jpi, jpj, jpk, zdit, zdjt, ztfw  ) 
+      CALL wrk_alloc( jpi, jpj, jpk, zdit, zdjt, ztfw , zftu, zftv ) 
       !
 
@@ -149,7 +150,4 @@
             END DO
          END DO
-    !    WRITE(numout,*) ' test1 ', zdit
-!cc commenté pour le test concluant de TMP16 --> pgu mauvais, correction dans
-!zpshde_crs ( probleme de signe lorsque ze3wu negatif, de mem pour pgv)
          IF( ln_zps ) THEN      ! partial steps correction at the last ocean level 
             DO jj = 1, jpjm1
@@ -160,6 +158,4 @@
             END DO
          ENDIF
-!cc
-     !   WRITE(numout,*) ' test2 ', zdit
 
          !!----------------------------------------------------------------------
@@ -183,8 +179,6 @@
             DO jj = 1 , jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-   !               zabe1 = ( fsahtu(ji,jj,jk) + pahtb0 ) * e2e3u_msk(ji,jj,jk) / e1u_crs(ji,jj)
-  zabe1 = ( fsahtu(ji,jj,jk) + pahtb0 ) * e2e3u_msk(ji,jj,jk) / e1u_crs(ji,jj)
- !               zabe2 = ( fsahtv(ji,jj,jk) + pahtb0 ) * e1e3v_msk(ji,jj,jk) / e2v_crs(ji,jj)
-zabe2 = ( fsahtv(ji,jj,jk) + pahtb0 ) * e1e3v_msk(ji,jj,jk) / e2v_crs(ji,jj)
+                  zabe1 = ( fsahtu(ji,jj,jk) + pahtb0 ) * e2e3u_msk(ji,jj,jk) / e1u_crs(ji,jj)
+                  zabe2 = ( fsahtv(ji,jj,jk) + pahtb0 ) * e1e3v_msk(ji,jj,jk) / e2v_crs(ji,jj)
 
                   zmsku = 1. / MAX(  tmask_crs(ji+1,jj,jk  ) + tmask_crs(ji,jj,jk+1)   &
@@ -194,10 +188,6 @@
                      &             + tmask_crs(ji,jj+1,jk+1) + tmask_crs(ji,jj,jk  ), 1. )
                   !
-    !              zcof1 = - fsahtu(ji,jj,jk) * e2e3u_msk(ji,jj,jk) * uslp_crs(ji,jj,jk) * zmsku / MAX( 1._wp , e3u_max_crs(ji,jj,jk)) vue avec Gurvan OK
-                zcof1 = - fsahtu(ji,jj,jk) * e2e3u_msk(ji,jj,jk) * uslp_crs(ji,jj,jk) * zmsku / MAX( 1._wp , e3u_max_crs(ji,jj,jk))
-  !                zcof2 = - fsahtv(ji,jj,jk) * e1e3v_msk(ji,jj,jk) * vslp_crs(ji,jj,jk) * zmskv / MAX( 1._wp , e3v_max_crs(ji,jj,jk))  vue avec Gurvan OK
-                zcof2 = - fsahtv(ji,jj,jk) * e1e3v_msk(ji,jj,jk) * vslp_crs(ji,jj,jk) * zmskv / MAX( 1._wp , e3v_max_crs(ji,jj,jk))
-           !        zcof1 = - fsahtu(ji,jj,jk) * e2u_crs(ji,jj) * uslp(ji,jj,jk) * zmsku
-           !        zcof2 = - fsahtv(ji,jj,jk) * e1v_crs(ji,jj) * vslp(ji,jj,jk) * zmskv  
+                  zcof1 = - fsahtu(ji,jj,jk) * e2e3u_msk(ji,jj,jk) * uslp_crs(ji,jj,jk) * zmsku / MAX( 1._wp , e3u_max_crs(ji,jj,jk))
+                  zcof2 = - fsahtv(ji,jj,jk) * e1e3v_msk(ji,jj,jk) * vslp_crs(ji,jj,jk) * zmskv / MAX( 1._wp , e3v_max_crs(ji,jj,jk))
                   !
                   zftu(ji,jj,jk ) = ( zabe1 * zdit(ji,jj,jk)   &
@@ -209,4 +199,8 @@
                END DO
             END DO
+            CALL iom_swap( "nemo_crs"  )
+            CALL iom_put( "zftu" , zftu )
+            CALL iom_put( "zftv" , zftv )
+            CALL iom_swap( "nemo" )
 
             ! II.4 Second derivative (divergence) and add to the general trend
@@ -285,6 +279,4 @@
                   zcoef3 = zcoef0 * e1e2w_crs(ji,jj,jk) * zmsku * wslpi_crs(ji,jj,jk) / e1t_crs(ji,jj)
                   zcoef4 = zcoef0 * e1e2w_crs(ji,jj,jk) * zmskv * wslpj_crs(ji,jj,jk) / e2t_crs(ji,jj)
-           !       zcoef3 = zcoef0 * e2t_crs(ji,jj) * zmsku * wslpi (ji,jj,jk)
-           !       zcoef4 = zcoef0 * e1t_crs(ji,jj) * zmskv * wslpj (ji,jj,jk)
                   ztfw(ji,jj,jk) = zcoef3 * (   zdit(ji  ,jj  ,jk-1) + zdit(ji-1,jj  ,jk)      &
                      &                        + zdit(ji-1,jj  ,jk-1) + zdit(ji  ,jj  ,jk)  )   &
@@ -312,5 +304,5 @@
       !
       CALL wrk_dealloc( jpi, jpj,      zdkt, zdk1t, z2d ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, zdit, zdjt, ztfw  ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, zdit, zdjt, ztfw , zftu, zftv ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_iso')
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 5601)
@@ -290,5 +290,5 @@
          ll_traqsr  = ln_traqsr        ! active  tracers case  and  solar penetration
       ELSE                          
-         ll_tra     = .FALSE.          ! passive tracers case
+         ll_tra     = .FALSE.           ! passive tracers case
          ll_tra_hpg = .FALSE.          ! passive tracers case or NO semi-implicit hpg
          ll_traqsr  = .FALSE.          ! active  tracers case and NO solar penetration
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp_crs.F90	(revision 5601)
@@ -78,5 +78,4 @@
       !! ** Action  : - pta  becomes the after tracer
       !!---------------------------------------------------------------------
-      USE oce     , ONLY:   zwd => ua       , zws => va         ! (ua,va) used as 3D workspace
       !
       INTEGER                              , INTENT(in   ) ::   kt       ! ocean time-step index
@@ -90,11 +89,10 @@
       INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
       REAL(wp) ::  zrhs, ze3tb, ze3tn, ze3ta   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwt
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwt,zwd,zws
       !!---------------------------------------------------------------------
       !
-!WRITE(numout,*) 'test6456_trb_sbc1', pta(:,:,:,1), kt
-      IF( nn_timing == 1 )  CALL timing_start('tra_zdf_imp')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zwi, zwt ) 
+      IF( nn_timing == 1 )  CALL timing_start('tra_zdf_imp_crs')
+      !
+      CALL wrk_alloc( jpi, jpj, jpk, zwi, zwt, zwd, zws ) 
       !
       IF( kt == kit000 )  THEN
@@ -121,7 +119,5 @@
             ! vertical mixing coef.: avt for temperature, avs for salinity and passive tracers
             IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN   ;   zwt(:,:,2:jpk) = avt  (:,:,2:jpk)
-#if defined key_zdfddm
-            ELSE                                            ;   zwt(:,:,2:jpk) = avs_crs(:,:,2:jpk)
-#endif
+            ELSE                                            ;   zwt(:,:,2:jpk) = avt_crs(:,:,2:jpk)
             ENDIF
             zwt(:,:,1) = 0._wp
@@ -135,5 +131,4 @@
                      DO ji = fs_2, fs_jpim1   ! vector opt.
                         zwt(ji,jj,jk) = zwt(ji,jj,jk) + ah_wslp2(ji,jj,jk) 
-    !                    WRITE(numout,*) 'ah_wslp2', ah_wslp2(ji,jj,jk)      
                      END DO
                   END DO
@@ -152,32 +147,17 @@
 
 #endif
-!WRITE(numout,*) 'test6456_trb_sbc2', pta(:,:,:,1), kt
-            ! Diagonal, lower (i), upper (s)  (including the bottom boundary condition since avt is masked)
-! WRITE(numout,*) 'wslpi_crs', wslpi_crs(:,:,:)
-! WRITE(numout,*) 'wslpj_crs(ji,jj,jk-1)',wslpj_crs(:,:,:)
-! WRITE(numout,*) ' fsahtw',  fsahtw(:,:,:)
- !WRITE(numout,*) 'ah_wslp2', ah_wslp2(:,:,:) 
-! WRITE(numout,*) 'zwt2(ji,jj,jk-1)', zwt(:,:,:) 
-
             DO jk = 1, jpkm1
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1   ! vector opt.
-              !        ze3ta =  ( 1. - r_vvl ) +        r_vvl   * ocean_volume_crs_t(ji,jj,jk)   ! after scale factor at T-point
-             !         ze3tn =         r_vvl   + ( 1. - r_vvl ) * ocean_volume_crs_t(ji,jj,jk)   ! now   scale factor at T-point
                      ze3ta =  ( 1. - r_vvl ) +        r_vvl   * e3t_crs(ji,jj,jk)   ! after scale factor at T-point
                      ze3tn =         r_vvl   + ( 1. - r_vvl ) * e3t_crs(ji,jj,jk)   ! now   scale factor at T-point
-                     zwi(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk  ) / ( ze3tn * e3w_1d(jk  ) )  !cc
-                     zws(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk+1) / ( ze3tn * e3w_1d(jk+1) )  !cc
+                     !cbr zwi(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk  ) / ( ze3tn * e3w_1d(jk  ) )  !cc
+                     !cbr zws(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk+1) / ( ze3tn * e3w_1d(jk+1) )  !cc
+                     zwi(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk  ) / ( ze3tn * e3w_max_crs(ji,jj,jk) )
+                     zws(ji,jj,jk) = - p2dt(jk) * zwt(ji,jj,jk+1) / ( ze3tn * e3w_max_crs(ji,jj,jk+1) )
                      zwd(ji,jj,jk) = ze3ta - zwi(ji,jj,jk) - zws(ji,jj,jk)
-      !               WRITE(numout,*) 'ze3tn', ze3tn
-      !               WRITE(numout,*) 'e3w_0', e3w_0(jk)
-      !               WRITE(numout,*) 'ze3ta', ze3ta
-      !               WRITE(numout,*) 'zwt3(ji,jj,jk-1)', zwt(ji,jj,jk)
                  END DO
                END DO
             END DO
-  ! WRITE(numout,*) 'zwi(ji,jj,jk-1)', zwi(:,:,:)
-  ! WRITE(numout,*) 'zws(ji,jj,jk-1)', zws(:,:,:)
-  ! WRITE(numout,*) 'zwd(ji,jj,jk-1)', zwd(:,:,:) 
             !
             !! Matrix inversion from the first level
@@ -216,25 +196,17 @@
             !
          END IF
-! WRITE(numout,*) 'zwt4(ji,jj,jk-1)', zwt(:,:,:) 
          !    
-!WRITE(numout,*) 'test6456_trb_sbc4', pta(:,:,:,1), kt     
          ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1
-           !     ze3tb = ( 1. - r_vvl ) + r_vvl * ocean_volume_crs_t(ji,jj,1)
-           !     ze3tn = ( 1. - r_vvl ) + r_vvl * ocean_volume_crs_t(ji,jj,1)
                ze3tb = ( 1. - r_vvl ) + r_vvl * e3t_crs(ji,jj,1)
                ze3tn = ( 1. - r_vvl ) + r_vvl * e3t_crs(ji,jj,1)
                pta(ji,jj,1,jn) = ze3tb * ptb(ji,jj,1,jn) + p2dt(1) * ze3tn * pta(ji,jj,1,jn)
-!WRITE(numout,*) 'test6456_trb_sbc4', pta(:,:,:,1), kt 
-            END DO
-         END DO
-
-!WRITE(numout,*) 'kt', kt 
+            END DO
+         END DO
+
          DO jk = 2, jpkm1
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1
-           !        ze3tb = ( 1. - r_vvl ) + r_vvl * ocean_volume_crs_t(ji,jj,jk)
-           !        ze3tn = ( 1. - r_vvl ) + r_vvl * ocean_volume_crs_t(ji,jj,jk)
                   ze3tb = ( 1. - r_vvl ) + r_vvl * e3t_crs(ji,jj,jk)
                   ze3tn = ( 1. - r_vvl ) + r_vvl * e3t_crs(ji,jj,jk)
@@ -246,5 +218,4 @@
          END DO
 
-!WRITE(numout,*) 'test6456_trb_sbc5', pta(:,:,:,1), kt
          ! third recurrence:    Xk = (Zk - Sk Xk+1 ) / Tk   (result is the after tracer)
          DO jj = 2, jpjm1
@@ -267,6 +238,5 @@
       !                                               ! ================= !
       !
-!WRITE(numout,*) 'test6456_trb_sbc6', pta(:,:,:,1), kt
-      CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwt ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwt, zwd, zws ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_zdf_imp_crs')
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 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde_crs.F90	(revision 5601)
@@ -103,5 +103,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start( 'zps_hde')
+      IF( nn_timing == 1 )  CALL timing_start( 'zps_hde_crs')
       !
 !!      CALL wrk_alloc( jpi, jpj,       zri, zrj, zhi, zhj ) 
@@ -128,7 +128,5 @@
                ! i- direction
                IF( ze3wu >= 0._wp ) THEN      ! case 1
-                  !cbr zmaxu =  ze3wu / e3w_max_crs(ji+1,jj,iku)  
-                  zmaxu =  ze3wu
-                  IF( e3w_max_crs(ji+1,jj,iku) .NE. 0._wp ) zmaxu = zmaxu / e3w_max_crs(ji+1,jj,iku)
+                  zmaxu =  ze3wu / e3w_max_crs(ji+1,jj,iku)  
                  !    zmaxu =  ze3wu / e3w_crs(ji+1,jj,iku)
                   ! interpolated values of tracers
@@ -137,7 +135,5 @@
                   pgtu(ji,jj,jn) = umask_crs(ji,jj,1) * ( zti(ji,jj,jn) - pta(ji,jj,iku,jn) )
                ELSE                           ! case 2
-                  !cbr zmaxu = -ze3wu / e3w_max_crs(ji,jj,iku)
-                  zmaxu =  -ze3wu
-                  IF( e3w_max_crs(ji,jj,iku) .NE. 0._wp ) zmaxu = zmaxu / e3w_max_crs(ji,jj,iku)
+                  zmaxu = -ze3wu / e3w_max_crs(ji,jj,iku)
                  !    zmaxu = -ze3wu / e3w_crs(ji,jj,iku)
                   ! interpolated values of tracers
@@ -149,7 +145,5 @@
                ! j- direction
                IF( ze3wv >= 0._wp ) THEN      ! case 1
-                  !cbr zmaxv =  ze3wv / e3w_max_crs(ji,jj+1,ikv)
-                  zmaxv =  ze3wv
-                  IF( e3w_max_crs(ji,jj+1,ikv) .NE. 0._wp ) zmaxv =  zmaxv / e3w_max_crs(ji,jj+1,ikv)
+                  zmaxv =  ze3wv / e3w_max_crs(ji,jj+1,ikv)
                !      zmaxv =  ze3wv / e3w_crs(ji,jj+1,ikv)
                   ! interpolated values of tracers
@@ -158,7 +152,5 @@
                   pgtv(ji,jj,jn) = vmask_crs(ji,jj,1) * ( zte(ji,jj,jn) - pta(ji,jj,ikv,jn) )
                ELSE                           ! case 2
-                  !cbr zmaxv =  -ze3wv / e3w_max_crs(ji,jj,ikv)
-                  zmaxv =  -ze3wv
-                  IF( e3w_max_crs(ji,jj,ikv) .NE. 0._wp )zmaxv = zmaxv / e3w_max_crs(ji,jj,ikv)
+                  zmaxv =  -ze3wv / e3w_max_crs(ji,jj,ikv)
                 !     zmaxv = -ze3wv / e3w_crs(ji,jj,ikv)
                   ! interpolated values of tracers
@@ -237,5 +229,5 @@
       DEALLOCATE( zri , zrj, zte, zhi, zhj, zti)
       !
-      IF( nn_timing == 1 )  CALL timing_stop( 'zps_hde')
+      IF( nn_timing == 1 )  CALL timing_stop( 'zps_hde_crs')
       !
    END SUBROUTINE zps_hde_crs
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 5601)
@@ -83,4 +83,5 @@
       REAL(wp) ::   zN2_c        ! local scalar
       INTEGER, POINTER, DIMENSION(:,:) ::   imld   ! 2D workspace
+      REAL(wp), POINTER, DIMENSION(:,:) ::   z2d   ! 2D workspace
       !!----------------------------------------------------------------------
       !
@@ -88,4 +89,5 @@
       !
       CALL wrk_alloc( jpi,jpj, imld )
+      CALL wrk_alloc( jpi,jpj, z2d )
 
       IF( kt == nit000 ) THEN
@@ -135,4 +137,6 @@
          CALL iom_put( "mldr10_1", hmlp )   ! mixed layer depth
          CALL iom_put( "mldkz5"  , hmld )   ! turbocline depth
+         z2d(:,:)=REAL(nmln,wp) 
+         CALL iom_put( "nmln"  , z2d )   ! turbocline depth
       ENDIF
       
@@ -140,4 +144,5 @@
       !
       CALL wrk_dealloc( jpi,jpj, imld )
+      CALL wrk_dealloc( jpi,jpj, z2d )
       !
       IF( nn_timing == 1 )  CALL timing_stop('zdf_mxl')
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl_crs.F90	(revision 5601)
@@ -6,12 +6,16 @@
    !! History :  1.0  ! 2003-08  (G. Madec)  original code
    !!            3.2  ! 2009-07  (S. Masson, G. Madec)  IOM + merge of DO-loop
+   !!            3.7  ! 2012-03  (G. Madec)  make public the density criteria for trdmxl 
+   !!             -   ! 2014-02  (F. Roquet)  mixed layer depth calculated using N2 instead of rhop 
    !!----------------------------------------------------------------------
    !!   zdf_mxl      : Compute the turbocline and mixed layer depths.
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables
+   !USE oce             ! ocean dynamics and tracers variables
+   !USE dom_oce         ! ocean space and time domain variables
+   !USE oce_trc
    USE zdf_oce         ! ocean vertical physics
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
+   USE phycst          ! physical constants
    USE iom             ! I/O library
    USE lib_mpp         ! MPP library
@@ -26,8 +30,5 @@
    PUBLIC   zdf_mxl_crs       ! called by step.F90
 
-   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by TOP)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld    !: mixing layer depth (turbocline)      [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlpt   !: mixed layer depth at t-points        [m]
+   REAL(wp)         ::   avt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
 
    !! * Substitutions
@@ -35,24 +36,8 @@
    !!----------------------------------------------------------------------
    !! NEMO/OPA 4.0 , NEMO Consortium (2011)
-   !! $Id: zdfmxl.F90 3294 2012-01-28 16:44:18Z rblod $ 
+   !! $Id: zdfmxl.F90 4990 2014-12-15 16:42:49Z timgraham $ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
-
-   INTEGER FUNCTION zdf_mxl_alloc_crs()
-      !!----------------------------------------------------------------------
-      !!               ***  FUNCTION zdf_mxl_alloc  ***
-      !!----------------------------------------------------------------------
-      zdf_mxl_alloc_crs = 0      ! set to zero if no array to be allocated
-      IF( .NOT. ALLOCATED( nmln_crs ) ) THEN
-         ALLOCATE( nmln_crs(jpi_crs,jpj_crs), hmld_crs(jpi_crs,jpj_crs), hmlp_crs(jpi_crs,jpj_crs) & !! declaration in crs.F90
-         &       , hmlpt_crs(jpi_crs,jpj_crs), STAT= zdf_mxl_alloc_crs )
-         !
-         IF( lk_mpp             )   CALL mpp_sum ( zdf_mxl_alloc_crs )
-         IF( zdf_mxl_alloc_crs /= 0 )   CALL ctl_warn('zdf_mxl_alloc: failed to allocate arrays.')
-         !
-      ENDIF
-   END FUNCTION zdf_mxl_alloc_crs
-
 
    SUBROUTINE zdf_mxl_crs( kt )
@@ -65,22 +50,21 @@
       !! ** Method  :   The mixed layer depth is the shallowest W depth with 
       !!      the density of the corresponding T point (just bellow) bellow a
-      !!      given value defined locally as rho(10m) + zrho_c
+      !!      given value defined locally as rho(10m) + rho_c
       !!               The turbocline depth is the depth at which the vertical
       !!      eddy diffusivity coefficient (resulting from the vertical physics
       !!      alone, not the isopycnal part, see trazdf.F) fall below a given
-      !!      value defined locally (avt_c here taken equal to 5 cm/s2)
+      !!      value defined locally (avt_c here taken equal to 5 cm/s2 by default)
       !!
       !! ** Action  :   nmln, hmld, hmlp, hmlpt
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !!
-      INTEGER  ::   ji, jj, jk          ! dummy loop indices
-      INTEGER  ::   iikn, iiki          ! temporary integer within a do loop
-      INTEGER, POINTER, DIMENSION(:,:) ::   imld                ! temporary workspace
-      REAL(wp) ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth
-      REAL(wp) ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   iiki,iikn   ! local integer
+      REAL(wp) ::   zN2_c        ! local scalar
+      INTEGER, POINTER, DIMENSION(:,:) ::   imld   ! 2D workspace
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('zdf_mxl')
+      IF( nn_timing == 1 )  CALL timing_start('zdf_mxl_crs')
       !
       CALL wrk_alloc( jpi_crs,jpj_crs, imld )
@@ -88,44 +72,33 @@
       IF( kt == nit000 ) THEN
          IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth'
+         IF(lwp) WRITE(numout,*) 'zdf_mxl_crs : mixed layer depth'
          IF(lwp) WRITE(numout,*) '~~~~~~~ '
-         !                             ! allocate zdfmxl arrays
-         IF( zdf_mxl_alloc_crs() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl : unable to allocate arrays' )
       ENDIF
 
-      ! w-level of the mixing and mixed layers
-      nmln_crs(:,:) = mbkt_crs(:,:) + 1        ! Initialization to the number of w ocean point
-      imld(:,:)     = mbkt_crs(:,:) + 1
-      DO jk = jpkm1, nlb10, -1         ! from the bottom to nlb10
+      ! w-level of the turbocline
+      imld(:,:)=0
+      DO jk = jpkm1, nlb10, -1         ! from the bottom to nlb10 
          DO jj = 1, jpj_crs
             DO ji = 1, jpi_crs
-               IF( rhop_crs(ji,jj,jk) > rhop_crs(ji,jj,nla10) + zrho_c )   nmln_crs(ji,jj) = jk      ! Mixed layer
-        !       IF( avt (ji,jj,jk) < zavt_c                     )   imld(ji,jj) = jk      ! Turbocline 
+               IF( avt_crs (ji,jj,jk) < avt_c )   imld(ji,jj) = MAX( jk, 1 )      ! Turbocline 
             END DO
          END DO
       END DO
+
       ! depth of the mixing and mixed layers
-      !write(narea+2000,*)"nlb10 ",nlb10,SHAPE(hmlpt_crs),SHAPE(gdepw_crs) ; call flush(narea+2000)
+      hmld_crs(:,:) = 0._wp
+      hmlpt_crs(:,:) = 0._wp
       DO jj = 1, jpj_crs
          DO ji = 1, jpi_crs
-           ! iiki = imld(ji,jj)
+            iiki = imld(ji,jj)
             iikn = nmln_crs(ji,jj)
-            ! write(narea+2000,*)ji,jj,iikn,gdept_crs(ji,jj,iikn-1) ; call flush(narea+2000)
-       !     hmld (ji,jj) = gdepw_crs(ji,jj,iiki  ) * tmask_crs(ji,jj,1)    ! Turbocline depth 
-            !IF( iikn .LT. 2 .OR. iikn .GT. jpk )write(narea+2000,*)"iikn ",ji,jj,iikn ; call flush(narea+2000)
-            hmlp_crs (ji,jj) = gdepw_crs(ji,jj,iikn  ) * tmask_crs(ji,jj,1)    ! Mixed layer depth
-            hmlpt_crs(ji,jj) = gdept_crs(ji,jj,iikn-1)                     ! depth of the last T-point inside the mixed layer
+            IF( iiki .NE. 0 ) hmld_crs (ji,jj) = ( gdepw_crs(ji,jj,iiki  ) - gdepw_crs(ji,jj,1 )            )   * tmask_crs(ji,jj,1)  ! Turbocline depth 
+            IF( iiki .NE. 0 ) hmlpt_crs(ji,jj) = ( gdept_crs(ji,jj,iikn-1) - gdepw_crs(ji,jj,1 )            )   * tmask_crs(ji,jj,1)  ! depth of the last T-point inside the mixed layer
          END DO
       END DO
-      IF( .NOT.lk_offline ) THEN            ! no need to output in offline mode
-  !       CALL iom_put( "mldr10_1", hmlp )   ! mixed layer depth
-   !      CALL iom_put( "mldkz5"  , hmld )   ! turbocline depth
-      ENDIF
-      
-    !  IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 )
       !
       CALL wrk_dealloc( jpi_crs,jpj_crs, imld )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('zdf_mxl')
+      IF( nn_timing == 1 )  CALL timing_stop('zdf_mxl_crs')
       !
    END SUBROUTINE zdf_mxl_crs
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 5601)
@@ -82,4 +82,5 @@
    USE crsini          ! initialise grid coarsening utility
    USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges 
+   USE trabbl_crs
 
    IMPLICIT NONE
@@ -114,4 +115,5 @@
       !!----------------------------------------------------------------------
       INTEGER ::   istp       ! time step index
+      CHARACTER(len=20) :: cmd 
       !!----------------------------------------------------------------------
       !
@@ -410,5 +412,5 @@
       IF( lk_ldfslp     )   CALL ldf_slp_init      ! slope of lateral mixing
       !
-      IF( ln_crs .AND. lk_ldfslp ) THEN
+      IF( ln_crs_top .AND. lk_ldfslp ) THEN
                             CALL dom_grid_crs
                             CALL ldf_slp_init_crs
@@ -420,5 +422,5 @@
       IF( lk_trabbl     )   CALL tra_bbl_init   ! advective (and/or diffusive) bottom boundary layer scheme
       !
-      IF( ln_crs .AND. lk_trabbl     )  THEN
+      IF( ln_crs_top .AND. lk_trabbl     )  THEN
                             CALL dom_grid_crs 
                             CALL tra_bbl_init_crs   ! advective (and/or diffusive) bottom boundary layer scheme
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 5601)
@@ -110,6 +110,6 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !  THERMODYNAMICS
-                         CALL eos_rab( tsb, rab_b )       ! before local thermal/haline expension ratio at T-points
-                         CALL eos_rab( tsn, rab_n )       ! now    local thermal/haline expension ratio at T-points
+                         !cbr not used CALL eos_rab( tsb, rab_b )       ! before local thermal/haline expension ratio at T-points
+                         !cbr not used CALL eos_rab( tsn, rab_n )       ! now    local thermal/haline expension ratio at T-points
                          CALL bn2    ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency
                          CALL bn2    ( tsn, rab_n, rn2  ) ! now    Brunt-Vaisala frequency
@@ -139,5 +139,4 @@
                          CALL zdf_mxl( kstp )         ! mixed layer depth
 
-      IF(ln_crs)         CALL zdf_mxl_crs(kstp)
                                                       ! write TKE or GLS information in the restart file
       IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
@@ -154,4 +153,8 @@
                          CALL ldf_slp_grif( kstp )
          ELSE
+                         CALL iom_put("rabt",rab_n(:,:,:,jp_tem))
+                         CALL iom_put("rabs",rab_n(:,:,:,jp_sal))
+                         CALL iom_put("rhd",rhd)
+                         CALL iom_put("rn2b",rn2b)
                          CALL ldf_slp( kstp, rhd, rn2b )     ! before slope for Madec operator
          ENDIF
@@ -228,12 +231,17 @@
       IF( ln_crs )   THEN
                          CALL dom_grid_crs
-                         CALL eos_crs(tsb_crs , rhd_crs, rhop_crs)
-                         CALL bn2_crs(tsb_crs , rb2_crs)
-         IF( ln_zps )    CALL zps_hde_crs( kstp, 2, tsb_crs, gtsu_crs, gtsv_crs, rhd_crs, gru_crs, grv_crs )
-                         CALL zdf_mxl_crs(kstp)
+
+                         CALL eos_rab_crs( tsn_crs, rab_crs_n )       ! now    local thermal/haline expension ratio at T-points
+                         CALL bn2_crs    ( tsn_crs, rab_crs_n, rb2_crs  ) ! now    Brunt-Vaisala frequency
+                         CALL eos_crs ( tsn_crs, rhd_crs, rhop_crs, gdept_crs(:,:,:) ) ! now in situ density for hpg computation
+
+         IF( ln_zps )    CALL zps_hde_crs( kstp, jpts, tsb_crs, gtsu_crs, gtsv_crs, rhd_crs, gru_crs, grv_crs )
+
          IF( lk_ldfslp .AND.  .NOT. ln_traldf_grif )  &
                          CALL ldf_slp_crs( kstp, rhd_crs, rb2_crs )
                          CALL dom_grid_glo
-      ENDIF
+
+      ENDIF
+                         CALL zdf_mxl_crs(kstp)
 
       IF( ln_crs_top )   CALL dom_grid_crs
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcini_my_trc.F90	(revision 5601)
@@ -16,4 +16,5 @@
    USE trc
    USE trcsms_my_trc
+   USE dom_oce, ONLY : gdepw_1d,e3t_1d,nyear_len
 
    IMPLICIT NONE
@@ -44,5 +45,14 @@
       IF(lwp) WRITE(numout,*) ' trc_ini_my_trc: initialisation of MY_TRC model'
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
+
+      nlb_age = MINLOC( gdepw_1d, mask = gdepw_1d > age_depth, dim = 1  )
+      nl_age = nlb_age - 1
+      nla_age = nl_age - 1
+      frac_kill_age = (age_depth - gdepw_1d(nl_age))/e3t_1d(nl_age)
+      frac_add_age = 1._wp -  frac_kill_age
+      rryear = 1._wp / ( nyear_len(1) * rday )
+
       
+      IF( .NOT. ln_rsttr ) trb(:,:,:,jp_myt0:jp_myt1) = 0.
       IF( .NOT. ln_rsttr ) trn(:,:,:,jp_myt0:jp_myt1) = 0.
       !
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcsms_my_trc.F90	(revision 5601)
@@ -25,4 +25,15 @@
    PUBLIC   trc_sms_my_trc_alloc ! called by trcini_my_trc.F90 module
 
+   INTEGER , PUBLIC :: nl_age                         ! T level surrounding age_depth
+   INTEGER , PUBLIC :: nla_age                        ! T level wholly above age_depth
+   INTEGER , PUBLIC :: nlb_age                        ! T level wholly below age_depth
+
+   REAL(wp), PUBLIC ::   rryear                    !: recip number of seconds in one year
+   REAL(wp), PUBLIC ::   age_depth = 10.           !: depth over which age tracer reset to zero
+   REAL(wp), PUBLIC ::   age_kill_rate = -1./7200. !: recip of relaxation timescale (s) for  age tracer shallower than age_depth
+   REAL(wp), PUBLIC ::   frac_kill_age             !: fraction of level nl_age above age_depth where it is relaxed towards zero
+   REAL(wp), PUBLIC ::   frac_add_age              !: fraction of level nl_age below age_depth where it is incremented
+
+
    ! Defined HERE the arrays specific to MY_TRC sms and ALLOCATE them in trc_sms_my_trc_alloc
 
@@ -44,5 +55,5 @@
       !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      INTEGER ::   jn   ! dummy loop index
+      INTEGER ::   jn, jk   ! dummy loop index
       REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrmyt
 !!----------------------------------------------------------------------
@@ -56,10 +67,15 @@
       IF( l_trdtrc )  CALL wrk_alloc( jpi, jpj, jpk, ztrmyt )
 
-      WHERE( (glamt <= 170) .AND. (glamt >= 160) .AND. (gphit <= -74) .AND. (gphit >=-75.6) )
-        trn(:,:,1,jpmyt1) = 1._wp
-        trb(:,:,1,jpmyt1) = 1._wp
-        tra(:,:,1,jpmyt1) = 0._wp
-      END WHERE
-
+      DO jk = 1, nla_age
+         tra(:,:,jk,jpmyt1) = age_kill_rate * trb(:,:,jk,jpmyt1)
+      ENDDO
+      !
+      tra(:,:,nl_age,jpmyt1) = frac_kill_age * age_kill_rate * trb(:,:,nl_age,jpmyt1)  &
+          &                  + frac_add_age  * rryear * tmask(:,:,nl_age)
+      !
+      DO jk = nlb_age, jpk
+         tra(:,:,jk,jpmyt1) = tmask(:,:,jk) * rryear
+      ENDDO
+      !
       IF( l_trdtrc ) THEN      ! Save the trends in the ixed layer
           DO jn = jp_myt0, jp_myt1
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90	(revision 5601)
@@ -14,5 +14,6 @@
    USE trc         ! passive tracers common variables 
    USE oce_trc
-   USE crs, ONLY : ln_crs
+   USE crs, ONLY : ln_crs,ln_crs_top,ahtt_crs,ahtu_crs,ahtv_crs,ahtw_crs,jpi_crs,jpj_crs
+   USE iom, ONLY : iom_swap, iom_put
 
    IMPLICIT NONE
@@ -33,5 +34,11 @@
       INTEGER              :: jn
       !!---------------------------------------------------------------------
-      IF( ln_crs ) CALL iom_swap( "nemo_crs" )
+      IF( ln_crs_top ) CALL iom_swap( "nemo_crs" )
+
+      CALL iom_put("ahtt_crs",ahtt_crs)
+      CALL iom_put("ahtu_crs",ahtu_crs)
+      CALL iom_put("ahtv_crs",ahtv_crs)
+      CALL iom_put("ahtw_crs",ahtw_crs)
+
  
       ! write the tracer concentrations in the file
@@ -40,5 +47,5 @@
          cltra = TRIM( ctrcnm(jn) )                  ! short title for tracer
          IF( lk_vvl ) THEN
-            CALL iom_put( cltra, trn(:,:,:,jn) * fse3t_n(:,:,:) )
+            CALL iom_put( TRIM(cltra), trn(:,:,:,jn) * fse3t_n(:,:,:) )
          ELSE
             CALL iom_put( TRIM(cltra), trn(:,:,:,jn) )
@@ -46,5 +53,5 @@
       END DO
       !
-      IF( ln_crs ) CALL iom_swap( "nemo" )
+      IF( ln_crs_top ) CALL iom_swap( "nemo" )
       !
    END SUBROUTINE trc_wri_my_trc
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 5601)
@@ -16,4 +16,5 @@
    USE oce_trc         ! ocean dynamics and active tracers
    USE trc             ! ocean passive tracers variables
+   USe domvvl
    USE trcnam_trp      ! passive tracers transport namelist variables
    USE traadv_cen2     ! 2nd order centered scheme (tra_adv_cen2   routine)
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl_crs.F90	(revision 5601)
@@ -25,5 +25,5 @@
    USE trabbl_crs              ! 
    USE prtctl_trc          ! Print control for debbuging
-   USE trdmod_oce
+   USE trd_oce
    USE trdtra
 
@@ -95,5 +95,5 @@
         DO jn = 1, jptra
            ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
-           CALL trd_tra( kt, 'TRC', jn, jptra_trd_ldf, ztrtrd(:,:,:,jn) )
+           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
         END DO
         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd ) ! temporary save of trends
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf_crs.F90	(revision 5601)
@@ -25,5 +25,5 @@
    USE traldf_iso_grif ! lateral mixing          (tra_ldf_iso_grif routine)
    USE traldf_lap_crs      ! lateral mixing            (tra_ldf_lap routine)
-   USE trdmod_oce
+   USE trd_oce
    USE trdtra
    USE prtctl_trc      ! Print control
@@ -83,5 +83,5 @@
                           CALL tra_ldf_iso_crs     ( kt, nittrc000, 'TRC', gtru ,gtrv , trb, tra, jptra, rn_ahtb_0 )
                        ENDIF
-      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra            )  ! iso-level bilaplacian
+      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )  ! iso-level bilaplacian
       CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt, nittrc000, 'TRC',             trb, tra, jptra            )  ! s-coord. horizontal bilaplacian
          !
@@ -97,5 +97,5 @@
          WRITE(charout, FMT="('ldf1 ')") ;  CALL prt_ctl_trc_info(charout)
                                             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-         CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra            )
+         CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )
          WRITE(charout, FMT="('ldf2 ')") ;  CALL prt_ctl_trc_info(charout)
                                             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
@@ -108,5 +108,5 @@
         DO jn = 1, jptra
            ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
-           CALL trd_tra( kt, 'TRC', jn, jptra_trd_ldf, ztrtrd(:,:,:,jn) )
+           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
         END DO
         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 5601)
@@ -95,11 +95,22 @@
          IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
          !                                             ! add the trend to the general tracer trend
-         DO jj = 2, jpj
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zse3t = 1. / fse3t(ji,jj,1)
-               tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + zsfx(ji,jj) *  zsrau * trn(ji,jj,1,jn) * zse3t
+         IF( lk_vvl ) THEN  ! online coupling with vvl
+
+            
+            DO jj = 2, jpj
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zse3t = 1. / fse3t(ji,jj,1)
+                  tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + zsfx(ji,jj) *  zsrau * trn(ji,jj,1,jn) * zse3t
+               END DO
             END DO
-         END DO
-         
+         ELSE
+            DO jj = 2, jpj
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zse3t = 1. / fse3t(ji,jj,1)
+                  tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + zsfx(ji,jj) *  zsrau * trn(ji,jj,1,jn) * zse3t
+               END DO
+            END DO
+         ENDIF
+
          IF( l_trdtrc ) THEN
             ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc_crs.F90	(revision 5601)
@@ -19,5 +19,5 @@
    USE trc             ! ocean  passive tracers variables
    USE prtctl_trc      ! Print control for debbuging
-   USE trdmod_oce
+   USE trd_oce
    USE trdtra
 !cbr   USE crs
@@ -101,5 +101,5 @@
          IF( l_trdtrc ) THEN
             ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
-            CALL trd_tra( kt, 'TRC', jn, jptra_trd_nsr, ztrtrd )
+            CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd )
          END IF
          !                                                       ! ===========
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 5601)
@@ -35,5 +35,6 @@
    USE zpshde_crs      ! partial step: hor. derivative       (zps_hde routine)
    USE dom_oce , ONLY : ln_crs
-   USe crs, ONLY : jpi_crs,jpj_crs,wn_crs !cbr
+   USE crs     , ONLY : jpi_crs,jpj_crs,wn_crs,ln_crs_top !cbr
+   USE ldfslp_crs
 
 #if defined key_agrif
@@ -75,25 +76,20 @@
       IF( .NOT. lk_c1d ) THEN
          !
-!         CALL test(kstp,1)
-!         IF( ln_crs ) THEN ;    CALL trc_sbc_crs( kstp )
-!         ELSE              ;    CALL trc_sbc( kstp )
-!         ENDIF
-!         CALL test(kstp,2)
-         IF( ln_crs ) THEN ;    CALL trc_bbl_crs( kstp )
+         IF( ln_crs_top ) THEN ;    CALL trc_sbc_crs( kstp )
+         ELSE              ;    CALL trc_sbc( kstp )
+         ENDIF
+         IF( ln_crs_top ) THEN ;    CALL trc_bbl_crs( kstp )
          ELSE              ;    CALL trc_bbl( kstp )
          ENDIF
          IF( ln_trcdmp )        CALL trc_dmp( kstp )            ! internal damping trends
-!         CALL test(kstp,3)
 
-         IF( ln_crs ) THEN ;    CALL trc_adv_crs( kstp )
+         IF( ln_crs_top ) THEN ;    CALL trc_adv_crs( kstp )
          ELSE              ;    CALL trc_adv( kstp )
          ENDIF
-!         CALL test(kstp,4)
 
          IF( ln_trcdmp_clo )    CALL trc_dmp_clo( kstp )        ! internal damping trends on closed seas only
-         IF( ln_crs ) THEN ;    CALL trc_ldf_crs( kstp )
+         IF( ln_crs_top ) THEN ;    CALL trc_ldf_crs( kstp )
          ELSE              ;    CALL trc_ldf( kstp )
          ENDIF
-!         CALL test(kstp,5)
          IF( .NOT. lk_offline .AND. lk_zdfkpp )    &
             &                   CALL trc_kpp( kstp )            ! KPP non-local tracer fluxes
@@ -101,10 +97,8 @@
          IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_trc           ! tracers sponge
 #endif
-         IF( ln_crs ) THEN ;    CALL trc_zdf_crs( kstp )
+         IF( ln_crs_top ) THEN ;    CALL trc_zdf_crs( kstp )
          ELSE              ;    CALL trc_zdf( kstp )
          ENDIF
-!         CALL test(kstp,6)
                                 CALL trc_nxt( kstp )            ! tracer fields at next time step     
-!         CALL test(kstp,7)
          IF( ln_trcrad )        CALL trc_rad( kstp )            ! Correct artificial negative concentrations
 
@@ -112,8 +106,8 @@
       IF( .NOT. Agrif_Root())   CALL Agrif_Update_Trc( kstp )   ! Update tracer at AGRIF zoom boundaries : children only
 #endif
-         IF( ln_zps    )        CALL zps_hde( kstp, jptra, trn, gtru, gtrv )  ! Partial steps: now horizontal gradient of passive
+          ! Partial steps: now horizontal gradient of passive
          IF( ln_zps    )THEN
-         IF( ln_crs ) THEN ;    CALL zps_hde_crs( kstp, jptra, trn, gtru, gtrv )
-         ELSE              ;    CALL zps_hde( kstp, jptra, trn, gtru, gtrv )
+         IF( ln_crs_top ) THEN ;    CALL zps_hde_crs( kstp, jptra, trn, gtru, gtrv )
+         ELSE              ;    CALL zps_hde( kstp, jptra, trn, pgtu=gtru, pgtv=gtrv, sgtu=gtrui, sgtv=gtrvi )
          ENDIF
          ENDIF
@@ -136,5 +130,5 @@
    INTEGER,INTENT(IN) :: kt,i
    REAL(wp)::zmin,zmax
-   INTEGER :: ji,jj,jk
+   INTEGER :: ii,jj,kk
    zmin=MINVAL( trb(2:jpi-1,2:jpj-1,:,1),mask=(tmask(2:jpi-1,2:jpj-1,:)==1)) ; CALL mpp_min(zmin)
    zmax=MAXVAL( trb(2:jpi-1,2:jpj-1,:,1),mask=(tmask(2:jpi-1,2:jpj-1,:)==1)) ; CALL mpp_max(zmax)
@@ -146,21 +140,7 @@
    zmax=MAXVAL( tra(2:jpi-1,2:jpj-1,:,1),mask=(tmask(2:jpi-1,2:jpj-1,:)==1)) ; CALL mpp_max(zmax)
    IF(lwp)WRITE(numout,*)"trctrp a ",kt,i,zmin,zmax   
-   zmin=MINVAL( trn(2:jpi-1,2:jpj-1,1:jpk-1,1),mask=(tmask(2:jpi-1,2:jpj-1,1:jpk-1)==1)) ; CALL mpp_min(zmin)
-   zmax=MAXVAL( trn(2:jpi-1,2:jpj-1,1:jpk-1,1),mask=(tmask(2:jpi-1,2:jpj-1,1:jpk-1)==1)) ; CALL mpp_max(zmax)
-   IF(lwp)WRITE(numout,*)"trctrp n ",kt,i,zmin,zmax   
-   zmin=MINVAL( tra(2:jpi-1,2:jpj-1,1:jpk-1,1),mask=(tmask(2:jpi-1,2:jpj-1,1:jpk-1)==1)) ; CALL mpp_min(zmin)
-   zmax=MAXVAL( tra(2:jpi-1,2:jpj-1,1:jpk-1,1),mask=(tmask(2:jpi-1,2:jpj-1,1:jpk-1)==1)) ; CALL mpp_max(zmax)
-   IF(lwp)WRITE(numout,*)"trctrp a ",kt,i,zmin,zmax   
+   zmin=MINVAL( tra(2:jpi-1,2:jpj-1,30,1),mask=(tmask(2:jpi-1,2:jpj-1,30)==1)) ; CALL mpp_min(zmin)
+   zmax=MAXVAL( tra(2:jpi-1,2:jpj-1,30,1),mask=(tmask(2:jpi-1,2:jpj-1,30)==1)) ; CALL mpp_max(zmax)
 
-   IF(narea==267)WRITE(narea+5000,*)"tra(17,5,74,1) = ",kt,i,tra(17,5,74,1)
-
-   DO ji=1,jpi
-   DO jj=1,jpj
-   DO jk=1,jpk
-      IF( tra(ji,jj,jk,1) .NE.  tra(ji,jj,jk,1) )WRITE(narea+200,*)"BUG7 ",ji,jj,jk, tra(ji,jj,jk,1); CALL FLUSH(narea+200)
-   ENDDO
-   ENDDO
-   ENDDO
-   
    END SUBROUTINE test
 #else
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf_crs.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf_crs.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf_crs.F90	(revision 5601)
@@ -19,7 +19,8 @@
    USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
    USE trazdf_imp_crs      ! vertical diffusion: implicit (tra_zdf_imp     routine)
-   USE trdmod_oce
+   USE trd_oce
    USE trdtra
    USE prtctl_trc      ! Print control
+   USE timing
 
    IMPLICIT NONE
@@ -72,14 +73,23 @@
       !
       IF( kt == nittrc000 )   CALL zdf_ctl          ! initialisation & control of options
-
-#if ! defined key_pisces
-      IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
-         r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
-      ELSEIF( kt <= nittrc000 + 1 ) THEN          ! at nittrc000 or nittrc000+1
-         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
+!cbr bug
+!#if ! defined key_pisces
+!      IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
+!         r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
+!      ELSEIF( kt <= nittrc000 + 1 ) THEN          ! at nittrc000 or nittrc000+1
+!         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
+!      ENDIF
+!#else
+!      r2dt(:) =  rdttrc(:)              ! = rdttrc (for PISCES use Euler time stepping)
+!#endif
+      IF( ln_top_euler) THEN
+         r2dt(:) =  rdttrc(:)              ! = rdttrc (use Euler time stepping)
+      ELSE
+         IF( neuler == 0 .AND. kt == nittrc000 ) THEN     ! at nittrc000
+            r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
+         ELSEIF( kt <= nittrc000 + 1 ) THEN          ! at nittrc000 or nittrc000+1
+            r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
+         ENDIF
       ENDIF
-#else
-      r2dt(:) =  rdttrc(:)              ! = rdttrc (for PISCES use Euler time stepping)
-#endif
 
       IF( l_trdtrc )  THEN
@@ -98,5 +108,4 @@
       CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme 
       CASE ( 1 ) ;  CALL tra_zdf_imp_crs( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme          
-
       END SELECT
 
@@ -106,5 +115,5 @@
                ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
             END DO
-            CALL trd_tra( kt, 'TRC', jn, jptra_trd_zdf, ztrtrd(:,:,:,jn) )
+            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:,jn) )
          END DO
          CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 5601)
@@ -142,5 +142,7 @@
    USE oce , ONLY :   tsa     =>    tsa     !: 4D array contaning ( ta, sa )
    USE oce , ONLY :   rhop    =>    rhop    !: potential volumic mass (kg m-3) 
-   USE oce , ONLY :   rhd     =>    rhd     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE crs , ONLY :   rhd     =>    rhd_crs    !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE crs , ONLY :   rn2b    =>    rb2_crs     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE crs , ONLY :   rab_n   =>    rab_crs_n     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
    USE crs , ONLY :   hdivn   =>    hdivn_crs   !: horizontal divergence (1/s)
    USE crs , ONLY :   hdivb   =>    hdivb_crs   !: horizontal divergence (1/s)
@@ -160,4 +162,10 @@
    USE crs , ONLY :   rnf        =>    rnf_crs        !: river runoff   [Kg/m2/s]
    USE crs , ONLY :   fr_i       =>    fr_i_crs       !: ice fraction (between 0 to 1)
+   USE trcnam_trp , ONLY :  aht0     =>   rn_ahtrc_0        !: horizontal eddy diffusivity for tracers (m2/s)
+   USE crs , ONLY :  ahtu     =>   ahtu_crs        !: lateral diffusivity coef. at u-points 
+   USE crs , ONLY :  ahtv     =>   ahtv_crs        !: lateral diffusivity coef. at v-points 
+   USE crs , ONLY :  ahtw     =>   ahtw_crs        !: lateral diffusivity coef. at w-points 
+   USE crs , ONLY :  ahtt     =>   ahtt_crs        !: lateral diffusivity coef. at t-points
+   USE ldftra_oce , ONLY :  rldf     =>   rldf
 
    USE crs , ONLY :   avt        =>   avt_crs         !: vert. diffusivity coef. at w-point for temp  
@@ -177,8 +185,8 @@
   !* direction of lateral diffusion *
 #if   defined key_ldfslp
-   USE ldfslp_crs , ONLY :   uslp       =>   uslp_crs         !: i-direction slope at u-, w-points
-   USE ldfslp_crs , ONLY :   vslp       =>   vslp_crs         !: j-direction slope at v-, w-points
-   USE ldfslp_crs , ONLY :   wslpi      =>   wslpi_crs        !: i-direction slope at u-, w-points
-   USE ldfslp_crs , ONLY :   wslpj      =>   wslpj_crs        !: j-direction slope at v-, w-points
+   USE crs , ONLY :   uslp       =>   uslp_crs         !: i-direction slope at u-, w-points
+   USE crs , ONLY :   vslp       =>   vslp_crs         !: j-direction slope at v-, w-points
+   USE crs , ONLY :   wslpi      =>   wslpi_crs        !: i-direction slope at u-, w-points
+   USE crs , ONLY :   wslpj      =>   wslpj_crs        !: j-direction slope at v-, w-points
 #endif
 
@@ -318,4 +326,6 @@
    USE oce , ONLY :   rhop    =>    rhop    !: potential volumic mass (kg m-3) 
    USE oce , ONLY :   rhd     =>    rhd     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE oce , ONLY :   rab_n     =>    rab_n   !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE oce , ONLY :   rn2b    =>    rn2b    !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
    USE oce , ONLY :   hdivn   =>    hdivn   !: horizontal divergence (1/s)
    USE oce , ONLY :   rotn    =>    rotn    !: relative vorticity    [s-1]
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 5601)
@@ -94,5 +94,5 @@
          cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
       END DO
-      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
+      !cbr IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
       !                                                              ! total volume of the ocean 
       areatot = glob_sum( cvol(:,:,:) )
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90	(revision 5601)
@@ -66,5 +66,5 @@
             cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
          END DO
-         IF( lk_degrad )  cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)       ! degrad option: reduction by facvol
+         !cbr IF( lk_degrad )  cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)       ! degrad option: reduction by facvol
          areatot         = glob_sum( cvol(:,:,:) )
       ENDIF
Index: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90
===================================================================
--- branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 5588)
+++ branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 5601)
@@ -14,5 +14,5 @@
    USE prtctl_trc       ! Print control for debbuging
    USE iom, ONLY : jpnf90
-   USE in_out_manager, ONLY : jprstlib
+   USE iom_def, ONLY : jprstlib
    USE lbclnk
 !#if defined key_zdftke
@@ -112,5 +112,5 @@
           sshn_tm  (:,:)         = sshn_tm  (:,:)         + sshn  (:,:) 
           rnf_tm   (:,:)         = rnf_tm   (:,:)         + rnf   (:,:) 
-          h_rnf_tm (:,:)         = h_rnf_tm (:,:)         + h_rnf (:,:) 
+!cbr          h_rnf_tm (:,:)         = h_rnf_tm (:,:)         + h_rnf (:,:) 
           hmld_tm  (:,:)         = hmld_tm  (:,:)         + hmld  (:,:)
           fr_i_tm  (:,:)         = fr_i_tm  (:,:)         + fr_i  (:,:)
@@ -151,5 +151,5 @@
          ssha_temp  (:,:)        = ssha  (:,:)
          rnf_temp   (:,:)        = rnf   (:,:)
-         h_rnf_temp (:,:)        = h_rnf (:,:)
+!cbr         h_rnf_temp (:,:)        = h_rnf (:,:)
          hmld_temp  (:,:)        = hmld  (:,:)
          fr_i_temp  (:,:)        = fr_i  (:,:)
@@ -197,5 +197,5 @@
          sshn_tm  (:,:)          = sshn_tm    (:,:)       + sshn  (:,:) 
          rnf_tm   (:,:)          = rnf_tm     (:,:)       + rnf   (:,:) 
-         h_rnf_tm (:,:)          = h_rnf_tm   (:,:)       + h_rnf (:,:) 
+!cbr         h_rnf_tm (:,:)          = h_rnf_tm   (:,:)       + h_rnf (:,:) 
          hmld_tm  (:,:)          = hmld_tm    (:,:)       + hmld  (:,:)
          fr_i_tm  (:,:)          = fr_i_tm    (:,:)       + fr_i  (:,:)
@@ -208,5 +208,5 @@
          sshb     (:,:)          = sshb_hold  (:,:)
          rnf      (:,:)          = rnf_tm     (:,:) * r1_ndttrcp1 
-         h_rnf    (:,:)          = h_rnf_tm   (:,:) * r1_ndttrcp1 
+!cbr         h_rnf    (:,:)          = h_rnf_tm   (:,:) * r1_ndttrcp1 
          hmld     (:,:)          = hmld_tm    (:,:) * r1_ndttrcp1 
          !  variables that are initialized after averages
@@ -320,5 +320,5 @@
       sshn_tm  (:,:) = sshn  (:,:) 
       rnf_tm   (:,:) = rnf   (:,:) 
-      h_rnf_tm (:,:) = h_rnf (:,:) 
+!cbr      h_rnf_tm (:,:) = h_rnf (:,:) 
       hmld_tm  (:,:) = hmld  (:,:)
 
@@ -379,5 +379,5 @@
       ssha  (:,:)     =  ssha_temp  (:,:)
       rnf   (:,:)     =  rnf_temp   (:,:)
-      h_rnf (:,:)     =  h_rnf_temp (:,:)
+!cbr      h_rnf (:,:)     =  h_rnf_temp (:,:)
       !
       hmld  (:,:)     =  hmld_temp  (:,:)
@@ -428,5 +428,5 @@
       sshn_tm    (:,:) = sshn  (:,:) 
       rnf_tm     (:,:) = rnf   (:,:) 
-      h_rnf_tm   (:,:) = h_rnf (:,:) 
+!cbr      h_rnf_tm   (:,:) = h_rnf (:,:) 
       hmld_tm    (:,:) = hmld  (:,:)
       fr_i_tm    (:,:) = fr_i  (:,:)
