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 7206)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 7207)
@@ -78,4 +78,5 @@
       REAL(wp):: z2dcrsu, z2dcrsv
       REAL(wp):: z1_2dt
+      REAL(wp):: zmin,zmax
       INTEGER :: i,j,ijis,ijie,ijjs,ijje
       INTEGER ::  iji,ijj
@@ -95,89 +96,105 @@
       CALL wrk_alloc( jpi_crs, jpj_crs, z2d_crs     )
 
-
-      IF( kt == nit000  ) THEN
-         tsn_crs  (:,:,:,:) = 0._wp    ! temp/sal  array, now 
-         un_crs   (:,:,:  ) = 0._wp    ! u-velocity
-         vn_crs   (:,:,:  ) = 0._wp    ! v-velocity
-         wn_crs   (:,:,:  ) = 0._wp    ! w
-         avt_crs  (:,:,:  ) = 0._wp    ! avt
-         hdivb_crs(:,:,:  ) = 0._wp    ! hdiv
-         hdivn_crs(:,:,:  ) = 0._wp    ! hdiv
-         rke_crs  (:,:,:  ) = 0._wp    ! rke
-         sshn_crs (:,:    ) = 0._wp    ! ssh
-         utau_crs (:,:    ) = 0._wp    ! taux
-         vtau_crs (:,:    ) = 0._wp    ! tauy
-         wndm_crs (:,:    ) = 0._wp    ! wind speed
-         qsr_crs  (:,:    ) = 0._wp    ! qsr
-         emp_crs  (:,:    ) = 0._wp    ! emp
-         emp_b_crs(:,:    ) = 0._wp    ! emp
-         rnf_crs  (:,:    ) = 0._wp    ! runoff
-         rnf_b_crs(:,:    ) = 0._wp    ! runoff
-         fr_i_crs (:,:    ) = 0._wp    ! ice cover
-      ENDIF
-
       CALL iom_swap( "nemo_crs" )    ! swap on the coarse grid
 
       !---------------------------------------------------------------------------------------------------
-      !variables domaine au temps before : swap 
-      !---------------------------------------------------------------------------------------------------
-#if defined key_vvl
-      e3t_b_crs(:,:,:) = e3t_n_crs(:,:,:)
-      e3u_b_crs(:,:,:) = e3u_n_crs(:,:,:)
-      e3v_b_crs(:,:,:) = e3v_n_crs(:,:,:)
-      e3w_b_crs(:,:,:) = e3w_n_crs(:,:,:)
+      !scale factors: swap 
+      !---------------------------------------------------------------------------------------------------
+#if defined key_vvl
+      !e3t_b_crs(:,:,:) = e3t_n_crs(:,:,:)
+      !e3u_b_crs(:,:,:) = e3u_n_crs(:,:,:)
+      !e3v_b_crs(:,:,:) = e3v_n_crs(:,:,:)
+      !e3w_b_crs(:,:,:) = e3w_n_crs(:,:,:)
+      !e3t_n_crs(:,:,:) = e3t_a_crs(:,:,:)
+      !e3u_n_crs(:,:,:) = e3u_a_crs(:,:,:)
+      !e3v_n_crs(:,:,:) = e3v_a_crs(:,:,:)
+      !e3w_n_crs(:,:,:) = e3w_a_crs(:,:,:)
+ 
+      !cbr: ds dynnxt, si  (lk_dynspg_ts.AND.ln_bt_fw) on fait un swap simple ( e3X_b_crs=e3X_n_crs )
+      !                 sinon e3X_b_crs passe par le filtre d'asselin !!!!!!
+      !     ds dommvl, swap simple pr  e3X_n_crs=e3X_a_crs 
+
+
+      IF( kt /= nit000 )THEN
+      zfse3t(:,:,:) = e3t_b(:,:,:)
+      zfse3u(:,:,:) = e3u_b(:,:,:)
+      zfse3v(:,:,:) = e3v_b(:,:,:)
+      zfse3w(:,:,:) = e3w_b(:,:,:)
+      CALL crs_dom_e3( e1t, e2t, zfse3t, p_sfc_3d_crs=e1e2w_crs, cd_type='T', p_mask=tmask, p_e3_crs=e3t_b_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1t, e2t, zfse3w, p_sfc_3d_crs=e1e2w_crs, cd_type='W', p_mask=tmask, p_e3_crs=e3w_b_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=e3u_b_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=e3v_b_crs, p_e3_max_crs=zs_crs)
+      DO jk = 1, jpk
+         DO ji = 1, jpi_crs
+            DO jj = 1, jpj_crs
+               IF( e3t_b_crs(ji,jj,jk) == 0._wp ) e3t_b_crs(ji,jj,jk) = e3t_1d(jk)
+               IF( e3w_b_crs(ji,jj,jk) == 0._wp ) e3w_b_crs(ji,jj,jk) = e3w_1d(jk)
+               IF( e3u_b_crs(ji,jj,jk) == 0._wp ) e3u_b_crs(ji,jj,jk) = e3t_1d(jk)
+               IF( e3v_b_crs(ji,jj,jk) == 0._wp ) e3v_b_crs(ji,jj,jk) = e3t_1d(jk)
+            ENDDO
+        ENDDO
+      ENDDO
+
       e3t_n_crs(:,:,:) = e3t_a_crs(:,:,:)
       e3u_n_crs(:,:,:) = e3u_a_crs(:,:,:)
       e3v_n_crs(:,:,:) = e3v_a_crs(:,:,:)
       e3w_n_crs(:,:,:) = e3w_a_crs(:,:,:)
-#endif
+
+      ENDIF
+#endif
+      !---------------------------------------------------------------------------------------------------
+      !variables domaine au temps before : swap 
+      !---------------------------------------------------------------------------------------------------
+#if defined key_vvl
+      zfse3t(:,:,:) = e3t_b(:,:,:)
+      zfse3u(:,:,:) = e3u_b(:,:,:)
+      zfse3v(:,:,:) = e3v_b(:,:,:)
+      zfse3w(:,:,:) = e3w_b(:,:,:)
+#else
+      zfse3t(:,:,:) = e3t_0(:,:,:)
+      zfse3u(:,:,:) = e3u_0(:,:,:)
+      zfse3v(:,:,:) = e3v_0(:,:,:)
+      zfse3w(:,:,:) = e3w_0(:,:,:)
+#endif
+
+      !zmin=MINVAL();zmax=MAXVAL();CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld ",zmin,zmax 
+      !zmin=MINVAL();zmax=MAXVAL();CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld ",zmin,zmax 
 
       IF( kt /= nit000 )THEN
-         tsb_crs(:,:,:,jp_tem) = tsn_crs(:,:,:,jp_tem) 
-         tsb_crs(:,:,:,jp_sal) = tsn_crs(:,:,:,jp_sal) 
-         ub_crs(:,:,:)         = un_crs(:,:,:) 
-         vb_crs(:,:,:)         = vn_crs(:,:,:) 
-         sshb_crs(:,:)         = sshb_crs(:,:)
          emp_b_crs(:,:)        = emp_crs(:,:)
          rnf_b_crs(:,:)        = rnf_crs(:,:)
-         rb2_crs(:,:,:)        = rn2_crs(:,:,:)
+         hdivb_crs(:,:,:)      = hdivn_crs(:,:,:) !cbr hdivb_crs pas utile ?????????????????????????????????
+      ELSE
+         emp_b_crs(:,:    ) = 0._wp
+         rnf_b_crs(:,:    ) = 0._wp
+         hdivb_crs(:,:,:  ) = 0._wp  !cbr hdivb_crs pas utile ?????????????????????????????????
       ENDIF
 
+      !  Temperature
+      zt(:,:,:) = tsb(:,:,:,jp_tem)  ;      zt_crs(:,:,:) = 0._wp
+      CALL crs_dom_ope( zt, 'VOL', 'T', tmask, zt_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
+      tsb_crs(:,:,:,jp_tem) = zt_crs(:,:,:)
+
+      !  Salinity
+      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) = zs_crs(:,:,:)
+
+      !  U-velocity  !cb  pas utile ?????????????????????????????????
+      CALL crs_dom_ope( ub, 'SUM', 'U', umask, ub_crs, p_e12=e2u, p_e3=zfse3u, p_surf_crs=e2e3u_msk, psgn=-1.0 )
+
+      !  V-velocity  pas utile ?????????????????????????????????
+      CALL crs_dom_ope( vb, 'SUM', 'V', vmask, vb_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
+
+      ! n2
+      CALL crs_dom_ope( rn2b, 'VOL', 'W', tmask, rb2_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
+
+      !ssh !cbr pas utile ??????????????????????????????????????
+      zfse3t(:,:,:) = 1._wp
+      CALL crs_dom_ope( sshb , 'VOL', 'T', tmask, sshb_crs , p_e12=e1e2t, p_e3=zfse3t         , psgn=1.0 )
+
       !---------------------------------------------------------------------------------------------------
       !variables domaine au temps now : 
       !---------------------------------------------------------------------------------------------------
-#if defined key_vvl
-      zfse3t(:,:,:) = e3t_n(:,:,:)
-      zfse3u(:,:,:) = e3u_n(:,:,:)
-      zfse3v(:,:,:) = e3v_n(:,:,:)
-      zfse3w(:,:,:) = e3w_n(:,:,:)
-
-      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 )
-      CALL iom_put("e2e3u_crs",e2e3u_crs)
-      CALL iom_put("e2e3u_msk",e2e3u_msk)
-      CALL iom_put("e1e3v_crs",e1e3v_crs)
-      CALL iom_put("e1e3v_msk",e1e3v_msk)
-      !                                                                                 
-      CALL crs_dom_e3( e1t, e2t, zfse3t, p_sfc_3d_crs=e1e2w_crs, cd_type='T', p_mask=tmask, p_e3_crs=zs_crs, p_e3_max_crs=e3t_max_0_crs)
-      CALL crs_dom_e3( e1t, e2t, zfse3w, p_sfc_3d_crs=e1e2w_crs, cd_type='W', p_mask=tmask, p_e3_crs=zs_crs, p_e3_max_crs=e3w_max_0_crs)
-      CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=zs_crs, p_e3_max_crs=e3u_max_0_crs)
-      CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=zs_crs, p_e3_max_crs=e3v_max_0_crs)
-
-      CALL crs_dom_ope( gdepw_n, 'MAX', 'T', tmask, gdept_n_crs, p_e3=zfse3t, psgn=1.0 )
-      CALL crs_dom_ope( gdepw_n, 'MAX', 'W', tmask, gdepw_n_crs, p_e3=zfse3w, psgn=1.0 )
-
-      CALL crs_dom_facvol( tmask, 'T', e1t, e2t, zfse3t, ocean_volume_crs_t, facvol_t )
-      CALL iom_put("cvol_crs_t",ocean_volume_crs_t)
-      !
-      bt_crs(:,:,:) = ocean_volume_crs_t(:,:,:) * facvol_t(:,:,:)*tmask_crs(:,:,:)
-      !
-      r1_bt_crs(:,:,:) = 0._wp
-      WHERE( bt_crs /= 0._wp ) r1_bt_crs(:,:,:) = 1._wp / bt_crs(:,:,:)
-
-      CALL crs_dom_facvol( tmask, 'W', e1t, e2t, zfse3w, ocean_volume_crs_w, facvol_w )
-
-#endif
-
 #if defined key_vvl
       zfse3t(:,:,:) = e3t_n(:,:,:)
@@ -196,4 +213,37 @@
 #endif
 
+#if defined key_vvl
+      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 )
+      CALL iom_put("e2e3u_crs",e2e3u_crs)
+      CALL iom_put("e2e3u_msk",e2e3u_msk)
+      CALL iom_put("e1e3v_crs",e1e3v_crs)
+      CALL iom_put("e1e3v_msk",e1e3v_msk)
+      !                                                                                 
+      CALL crs_dom_e3( e1t, e2t, zfse3t, p_sfc_3d_crs=e1e2w_crs, cd_type='T', p_mask=tmask, p_e3_crs=zs_crs, p_e3_max_crs=e3t_max_n_crs)
+      CALL crs_dom_e3( e1t, e2t, zfse3w, p_sfc_3d_crs=e1e2w_crs, cd_type='W', p_mask=tmask, p_e3_crs=zs_crs, p_e3_max_crs=e3w_max_n_crs)
+      CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=zs_crs, p_e3_max_crs=e3u_max_n_crs)
+      CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=zs_crs, p_e3_max_crs=e3v_max_n_crs)
+
+     WHERE(e3t_max_n_crs == 0._wp) e3t_max_n_crs=r_inf
+     WHERE(e3u_max_n_crs == 0._wp) e3u_max_n_crs=r_inf
+     WHERE(e3v_max_n_crs == 0._wp) e3v_max_n_crs=r_inf
+     WHERE(e3w_max_n_crs == 0._wp) e3w_max_n_crs=r_inf
+
+      CALL crs_dom_ope( gdepw_n, 'MAX', 'T', tmask, gdept_n_crs, p_e3=zfse3t, psgn=1.0 )
+      CALL crs_dom_ope( gdepw_n, 'MAX', 'W', tmask, gdepw_n_crs, p_e3=zfse3w, psgn=1.0 )
+
+      CALL crs_dom_facvol( tmask, 'T', e1t, e2t, zfse3t, ocean_volume_crs_t, facvol_t )
+      CALL iom_put("cvol_crs_t",ocean_volume_crs_t)
+      !
+      bt_crs(:,:,:) = ocean_volume_crs_t(:,:,:) * facvol_t(:,:,:)*tmask_crs(:,:,:)
+      !
+      r1_bt_crs(:,:,:) = 0._wp
+      WHERE( bt_crs /= 0._wp ) r1_bt_crs(:,:,:) = 1._wp / bt_crs(:,:,:)
+
+      CALL crs_dom_facvol( tmask, 'W', e1t, e2t, zfse3w, ocean_volume_crs_w, facvol_w )
+
+#endif
+
       !  Temperature
       zt(:,:,:) = tsn(:,:,:,jp_tem)  ;      zt_crs(:,:,:) = 0._wp
@@ -214,15 +264,17 @@
       !  U-velocity
       CALL crs_dom_ope( un, 'SUM', 'U', umask, un_crs, p_e12=e2u, p_e3=zfse3u, p_surf_crs=e2e3u_msk, psgn=-1.0 )
-      un_crs(:,:,:) = un_crs(:,:,:)*umask_crs(:,:,:)
+      un_crs(:,:,:) = un_crs(:,:,:)*umask_crs(:,:,:) !cbr utile ??????????????????
       CALL iom_put( "uoce"  , un_crs )   ! i-current 
 
       !  V-velocity
       CALL crs_dom_ope( vn, 'SUM', 'V', vmask, vn_crs, p_e12=e1v, p_e3=zfse3v, p_surf_crs=e1e3v_msk, psgn=-1.0 )
-      vn_crs(:,:,:) = vn_crs(:,:,:)*vmask_crs(:,:,:)
+      vn_crs(:,:,:) = vn_crs(:,:,:)*vmask_crs(:,:,:) !cbr utile ??????????????????
       CALL iom_put( "voce"  , vn_crs )   ! i-current 
+
+      !n2
+      CALL crs_dom_ope( rn2 , 'VOL', 'W', tmask, rn2_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
      
       !  Horizontal divergence ( following OPA_SRC/DYN/divcur.F90 ) 
       hdivn_crs(:,:,:)=0._wp
-
       DO jk = 1, jpkm1
          DO jj = 2,jpj_crs
@@ -268,5 +320,5 @@
       CALL iom_put( "avt", avt_crs )   !  Kz
      
-      CALL crs_dom_ope( sshn , 'VOL', 'T', tmask, sshn_crs , p_e12=e1e2t, p_e3=zfse3t         , psgn=1.0 )  
+      !2D fields
       CALL crs_dom_ope( utau , 'SUM', 'U', umask, utau_crs , p_e12=e2u  , p_surf_crs=e2u_crs  , psgn=1.0 )
       CALL crs_dom_ope( vtau , 'SUM', 'V', vmask, vtau_crs , p_e12=e1v  , p_surf_crs=e1v_crs  , psgn=1.0 )
@@ -279,10 +331,8 @@
       CALL crs_dom_ope( gdepw_0, 'MAX', 'W', tmask, gdepw_0_crs, p_e3=zfse3w, psgn=1.0 )
 #endif
-
-      CALL crs_dom_ope( emp  , 'SUM', 'T', tmask, emp_crs  , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
-
+      CALL crs_dom_ope( emp   ,'SUM', 'T', tmask, emp_crs   , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
       CALL crs_dom_ope( fmmflx,'SUM', 'T', tmask, fmmflx_crs, p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
-      CALL crs_dom_ope( sfx  , 'SUM', 'T', tmask, sfx_crs  , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
-      CALL crs_dom_ope( fr_i , 'SUM', 'T', tmask, fr_i_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
+      CALL crs_dom_ope( sfx   ,'SUM', 'T', tmask, sfx_crs   , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
+      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)
@@ -291,5 +341,4 @@
       nmln_crs=MAX(nlb10,nmln_crs)    
 
-      CALL iom_put( "ssh"      , sshn_crs )   ! ssh output 
       CALL iom_put( "utau"     , utau_crs )   ! i-tau output 
       CALL iom_put( "vtau"     , vtau_crs )   ! j-tau output 
@@ -301,41 +350,75 @@
       CALL iom_put( "ice_cover", fr_i_crs )   ! ice cover output 
 
-#if defined key_vvl
-     !---------------------------------------------------------------------------------------------------
-     !variables au temps after
-     !---------------------------------------------------------------------------------------------------
-
-     zfse3t(:,:,:) = 1._wp
-     zt(:,:,:) = tmask(:,:,:)
-     ssha(:,:) = ssha(:,:) * tmask(:,:,1)
-     CALL crs_dom_ope( ssha , 'VOL', 'T', zt, ssha_crs , p_e12=e1e2t,  p_e3=zfse3t , psgn=1.0 )
-     CALL crs_lbc_lnk( ssha_crs, 'T', 1.0 ) !!!!!!!!!!!!!!!!!!! pas utile !!!!!!!!!!!!!!!!!!!!!!!!!
-
-     zfse3t(:,:,:) = e3t_a(:,:,:)
-     zfse3u(:,:,:) = e3u_a(:,:,:)
-     zfse3v(:,:,:) = e3v_a(:,:,:)
-     CALL dom_vvl_interpol( zfse3t(:,:,:), zfse3w(:,:,:), 'W'   )
-
-     CALL crs_dom_sfc( umask, 'U', zt_crs, zs_crs, p_e2=e2u, p_e3=zfse3u ) ! zt_crs=e2e3u_crs,zs_crs=e2e3u_msk
-     CALL crs_dom_sfc( vmask, 'V', zt_crs, zs_crs, p_e1=e2v, p_e3=zfse3v ) ! zt_crs=e1e3v_crs,zs_crs=e1e3v_msk
-     CALL crs_dom_e3( e1t, e2t, zfse3t, p_sfc_3d_crs=e1e2w_crs, cd_type='T', p_mask=tmask, p_e3_crs=e3t_a_crs, p_e3_max_crs=zs_crs)
-     CALL crs_dom_e3( e1t, e2t, zfse3w, p_sfc_3d_crs=e1e2w_crs, cd_type='W', p_mask=tmask, p_e3_crs=e3w_a_crs, p_e3_max_crs=zs_crs)
-     CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=e3u_a_crs, p_e3_max_crs=zs_crs)
-     CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=e3v_a_crs, p_e3_max_crs=zs_crs)
-
-
-     DO jk = 1, jpk
-        DO ji = 1, jpi_crs
-           DO jj = 1, jpj_crs
-              IF( e3t_a_crs(ji,jj,jk) == 0._wp ) e3t_a_crs(ji,jj,jk) = e3t_1d(jk)
-              IF( e3w_a_crs(ji,jj,jk) == 0._wp ) e3w_a_crs(ji,jj,jk) = e3w_1d(jk)
-              IF( e3u_a_crs(ji,jj,jk) == 0._wp ) e3u_a_crs(ji,jj,jk) = e3t_1d(jk)
-              IF( e3v_a_crs(ji,jj,jk) == 0._wp ) e3v_a_crs(ji,jj,jk) = e3t_1d(jk)
-           ENDDO
-       ENDDO
-     ENDDO
-
-     !zt_crs=ocean_volume_crs_t ; zs_crs=facvol_t after time !!!
-     CALL crs_dom_facvol( tmask, 'T', e1t, e2t, zfse3t, zt_crs, zs_crs )
+      zfse3t(:,:,:) = 1._wp
+      CALL crs_dom_ope( sshn , 'VOL', 'T', tmask, sshn_crs , p_e12=e1e2t, p_e3=zfse3t         , psgn=1.0 )  
+      CALL iom_put( "ssh"      , sshn_crs )   ! ssh output 
+
+      zmin=MINVAL(emp);zmax=MAXVAL(emp);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld emp",zmin,zmax 
+      zmin=MINVAL(emp_b);zmax=MAXVAL(emp_b);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld emp_b",zmin,zmax 
+      zmin=MINVAL(emp_crs);zmax=MAXVAL(emp_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld emp_crs",zmin,zmax 
+      zmin=MINVAL(emp_b_crs);zmax=MAXVAL(emp_b_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld emp_b_crs",zmin,zmax 
+
+#if defined key_vvl
+      !---------------------------------------------------------------------------------------------------
+      !variables au temps after
+      !---------------------------------------------------------------------------------------------------
+
+      !cbr ssha_crs utile ??????????????????
+      zfse3t(:,:,:) = 1._wp
+      zt(:,:,:) = tmask(:,:,:)
+      ssha(:,:) = ssha(:,:) * tmask(:,:,1)  !cbr utile ??????????????????
+      CALL crs_dom_ope( ssha , 'VOL', 'T', zt, ssha_crs , p_e12=e1e2t,  p_e3=zfse3t , psgn=1.0 )
+      !CALL crs_lbc_lnk( ssha_crs, 'T', 1.0 ) !!!!!!!!!!!!!!!!!!! pas utile !!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+      zfse3t(:,:,:) = e3t_a(:,:,:)
+      zfse3u(:,:,:) = e3u_a(:,:,:)
+      zfse3v(:,:,:) = e3v_a(:,:,:)
+      CALL dom_vvl_interpol( zfse3t(:,:,:), zfse3w(:,:,:), 'W'   )
+
+      CALL crs_dom_e3( e1t, e2t, zfse3t, p_sfc_3d_crs=e1e2w_crs, cd_type='T', p_mask=tmask, p_e3_crs=e3t_a_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1t, e2t, zfse3w, p_sfc_3d_crs=e1e2w_crs, cd_type='W', p_mask=tmask, p_e3_crs=e3w_a_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=e3u_a_crs, p_e3_max_crs=zs_crs)
+      CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=e3v_a_crs, p_e3_max_crs=zs_crs)
+
+
+      !DO ji=1,jpi_crs
+      !   DO jj=1,jpj_crs
+      !      fse3t_a_crs(ji,jj,jk),fse3t_b_crs(ji,jj,jk)+fse3t_n_crs(ji,jj,jk)*(ssha_crs(ji,jj)-sshb_crs(ji,jj))/(ht_0_crs(ji,jj)+sshn_crs(ji,jj))
+      !   ENDDO
+      !ENDDO
+      !CALL dom_vvl_interpol_crs( fse3t_a_crs(:,:,:), fse3u_a(:,:,:), 'U' )
+      !CALL dom_vvl_interpol_crs( fse3t_a_crs(:,:,:), fse3v_a(:,:,:), 'V' )
+      !CALL dom_vvl_interpol_crs( fse3t_a_crs(:,:,:), fse3w_a(:,:,:), 'W' )
+
+      !CALL crs_dom_sfc( umask, 'U', zt_crs, zs_crs, p_e2=e2u, p_e3=zfse3u ) ! zt_crs=e2e3u_crs,zs_crs=e2e3u_msk ça sert à quoi ???????????????????????????????????????????
+      !CALL crs_dom_sfc( vmask, 'V', zt_crs, zs_crs, p_e1=e2v, p_e3=zfse3v ) ! zt_crs=e1e3v_crs,zs_crs=e1e3v_msk ça sert à quoi ???????????????????????????????????????????
+
+      DO jk = 1, jpk
+         DO ji = 1, jpi_crs
+            DO jj = 1, jpj_crs
+               IF( e3t_a_crs(ji,jj,jk) == 0._wp ) e3t_a_crs(ji,jj,jk) = e3t_1d(jk)
+               IF( e3w_a_crs(ji,jj,jk) == 0._wp ) e3w_a_crs(ji,jj,jk) = e3w_1d(jk)
+               IF( e3u_a_crs(ji,jj,jk) == 0._wp ) e3u_a_crs(ji,jj,jk) = e3t_1d(jk)
+               IF( e3v_a_crs(ji,jj,jk) == 0._wp ) e3v_a_crs(ji,jj,jk) = e3t_1d(jk)
+            ENDDO
+        ENDDO
+      ENDDO
+
+      zmin=MINVAL(e3t_b);zmax=MAXVAL(e3t_b);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_b",zmin,zmax 
+      zmin=MINVAL(e3t_n);zmax=MAXVAL(e3t_n);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_n",zmin,zmax 
+      zmin=MINVAL(e3t_a);zmax=MAXVAL(e3t_a);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_a",zmin,zmax 
+      zmin=MINVAL(e3t_b_crs);zmax=MAXVAL(e3t_b_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_b_crs",zmin,zmax 
+      zmin=MINVAL(e3t_n_crs);zmax=MAXVAL(e3t_n_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_n_crs",zmin,zmax 
+      zmin=MINVAL(e3t_a_crs);zmax=MAXVAL(e3t_a_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld e3t_a_crs",zmin,zmax 
+      zmin=MINVAL(sshb);zmax=MAXVAL(sshb);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld sshb",zmin,zmax 
+      zmin=MINVAL(sshn);zmax=MAXVAL(sshn);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld sshn",zmin,zmax 
+      zmin=MINVAL(ssha);zmax=MAXVAL(ssha);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld ssha",zmin,zmax 
+      zmin=MINVAL(sshb_crs);zmax=MAXVAL(sshb_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld sshb_crs",zmin,zmax 
+      zmin=MINVAL(sshn_crs);zmax=MAXVAL(sshn_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld sshn_crs",zmin,zmax 
+      zmin=MINVAL(ssha_crs);zmax=MAXVAL(ssha_crs);CALL mpp_min(zmin);CALL mpp_max(zmax);IF(lwp)WRITE(numout,*)"crsfld ssha_crs",zmin,zmax 
+
+      !zt_crs=ocean_volume_crs_t ; zs_crs=facvol_t after time !!! ça sert à quoi ???????????????????????????????????????????
+      CALL crs_dom_facvol( tmask, 'T', e1t, e2t, zfse3t, zt_crs, zs_crs )
 
 #endif
@@ -349,4 +432,6 @@
                &                          + z1_2dt * e1e2w_crs(:,:,jk) * ( e3t_a_crs(:,:,jk) - e3t_b_crs(:,:,jk) ) ) * tmask_crs(:,:,jk)
          WHERE( e1e2w_msk(:,:,jk) .NE. 0._wp )  wn_crs(:,:,jk) =  wn_crs(:,:,jk) /e1e2w_msk(:,:,jk)
+
+
       ENDDO
 #else
@@ -363,5 +448,6 @@
 #endif
       CALL crs_lbc_lnk( wn_crs, 'W', 1.0 )   !!!!!!!pas utile, nan ??????????????????????
-      wn_crs(:,:,:) = wn_crs(:,:,:) * tmask_crs(:,:,:)
+      wn_crs(:,:,:) = wn_crs(:,:,:) * tmask_crs(:,:,:)   !!!!!!!pas utile, nan ??????????????????????
+
       CALL iom_put( "woce", wn_crs  )   ! vertical velocity
 
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 7206)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90	(revision 7207)
@@ -201,4 +201,5 @@
      CALL crs_dom_sfc( vmask, 'V', e1e3v_crs, e1e3v_msk, p_e1=e1v, p_e3=zfse3v )
 
+     !cbr utile ????????????????????????????????
      DO jk=1,jpk
         DO ji=1,jpi_crs
@@ -221,4 +222,5 @@
      CALL crs_dom_e3( e1u, e2u, zfse3u, p_sfc_2d_crs=e2u_crs  , cd_type='U', p_mask=umask, p_e3_crs=e3u_0_crs, p_e3_max_crs=e3u_max_0_crs)
      CALL crs_dom_e3( e1v, e2v, zfse3v, p_sfc_2d_crs=e1v_crs  , cd_type='V', p_mask=vmask, p_e3_crs=e3v_0_crs, p_e3_max_crs=e3v_max_0_crs)
+
      WHERE(e3t_max_0_crs == 0._wp) e3t_max_0_crs=r_inf
      WHERE(e3u_max_0_crs == 0._wp) e3u_max_0_crs=r_inf
@@ -257,4 +259,5 @@
      ENDDO
 
+!cbr utile ???????? on le fait ds crsfld, nan ?
 #if defined key_vvl
      e3t_b_crs(:,:,:) = e3t_0_crs(:,:,:)
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 7206)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl_crs.F90	(revision 7207)
@@ -89,4 +89,5 @@
       ! depth of the mixing and mixed layers
       hmld_crs(:,:) = 0._wp
+      hmlp_crs(:,:) = 0._wp
       hmlpt_crs(:,:) = 0._wp
       DO jj = 1, jpj_crs
@@ -94,7 +95,7 @@
             iiki = imld(ji,jj)
             iikn = nmln_crs(ji,jj)
-            hmld_crs (ji,jj) = ( fsdepw_crs(ji,jj,iiki  ) - fsdepw_crs(ji,jj,1    )  ) * tmask_crs(ji,jj,1)    ! Turbocline depth 
-            hmlp_crs (ji,jj) = ( fsdepw_crs(ji,jj,iikn  ) - fsdepw_crs(ji,jj,nla10)  ) * tmask_crs(ji,jj,1)    ! Mixed layer depth
-            hmlpt_crs(ji,jj) = ( fsdept_crs(ji,jj,iikn-1) - fsdepw_crs(ji,jj,1    )  ) * tmask_crs(ji,jj,1)    ! depth of the last T-point inside the mixed layer
+            IF(iiki   .NE. 0 ) hmld_crs (ji,jj) = ( fsdepw_crs(ji,jj,iiki  ) - fsdepw_crs(ji,jj,1    )  ) * tmask_crs(ji,jj,1)    ! Turbocline depth 
+            IF(iikn   .NE. 0 ) hmlp_crs (ji,jj) = ( fsdepw_crs(ji,jj,iikn  ) - fsdepw_crs(ji,jj,nla10)  ) * tmask_crs(ji,jj,1)    ! Mixed layer depth
+            IF(iikn-1 .NE. 0 ) hmlpt_crs(ji,jj) = ( fsdept_crs(ji,jj,iikn-1) - fsdepw_crs(ji,jj,1    )  ) * tmask_crs(ji,jj,1)    ! depth of the last T-point inside the mixed layer
          END DO
       END DO
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 7206)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 7207)
@@ -154,4 +154,14 @@
    IF(lwp)WRITE(numout,*)"trctrp a ",kt,i,zmin,zmax   
 
+   DO ji=1,jpi
+   DO jj=1,jpj
+   DO jk=1,jpk
+   IF( ieee_is_nan(tra(ji,jj,jk,1)))WRITE(narea+200,*)"test nan a",kt,i,ji,jj,jk,tmask(ji,jj,jk)
+   IF( ieee_is_nan(trn(ji,jj,jk,1)))WRITE(narea+200,*)"test nan n",kt,i,ji,jj,jk,tmask(ji,jj,jk)
+   IF( ieee_is_nan(trb(ji,jj,jk,1)))WRITE(narea+200,*)"test nan b",kt,i,ji,jj,jk,tmask(ji,jj,jk)
+   ENDDO
+   ENDDO
+   ENDDO
+
    END SUBROUTINE test
 #else
