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 6785)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 6786)
@@ -75,18 +75,10 @@
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zt, zs , ztmp
       REAL(wp), POINTER, DIMENSION(:,:)   :: z2d,z2d_crs
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_crs, zs_crs, zerr_crs,zmax_crs
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztmp_crs
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: avte_crs
-      REAL(wp)       :: z2dcrsu, z2dcrsv
-      REAL(wp)       :: z1_2dt
-      REAL(wp)       :: icnt1,icnt2
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_crs, zs_crs
+      REAL(wp):: z2dcrsu, z2dcrsv
+      REAL(wp):: z1_2dt
       INTEGER :: i,j,ijis,ijie,ijjs,ijje
-      REAL(wp)       :: zw,zwp1,zum1,zu,zvm1,zv,zsnm,zsm,z
-      REAL(wp)       :: zerr, zerr0, zerr1, zmean
-      INTEGER,DIMENSION(4,3) :: ind
-      REAL(wp),DIMENSION(4) :: zwgt
       INTEGER ::  iji,ijj
       INTEGER :: jl,jm,jn
-      REAL(wp)       :: zmin,zmax,zsuma0,zsuma1,zsuma2,zsuma3,zsumb0,zsumb1,zsumb2,zsumb3,zsumb4
       !!
       !!----------------------------------------------------------------------
@@ -100,7 +92,5 @@
       CALL wrk_alloc( jpi, jpj,      z2d            )
       !
-      CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs, zerr_crs,zmax_crs )
-      CALL wrk_alloc( jpi_crs, jpj_crs, jpk, ztmp_crs )
-      CALL wrk_alloc( jpi_crs, jpj_crs, jpk, 4, avte_crs )
+      CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
       CALL wrk_alloc( jpi_crs, jpj_crs, z2d_crs     )
 
@@ -165,4 +155,8 @@
       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)
@@ -262,111 +256,11 @@
          CASE ( 5 )
 #if defined key_zdftke
-            CALL crs_dom_ope( en , 'VOL', 'W', tmask, en_crs, p_e12=e1e2t, p_e3=zfse3w, psgn=1.0 )
-            CALL crs_dom_ope( taum , 'SUM', 'T', tmask, taum_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
-            CALL crs_dom_ope( rn2(:,:,:), 'VOL', 'W', tmask, rn2_crs, p_e12=e1e2t, p_e3=zfse3t, psgn=1.0 )
+            CALL crs_dom_ope( en        , 'VOL', 'W', tmask, en_crs   , p_e12=e1e2t, p_e3=zfse3w         , psgn=1.0 )
+            CALL crs_dom_ope( taum      , 'SUM', 'T', tmask, taum_crs , p_e12=e1e2t, p_surf_crs=e1e2t_crs, psgn=1.0 )
+            CALL crs_dom_ope( rn2(:,:,:), 'VOL', 'W', tmask, rn2_crs  , p_e12=e1e2t, p_e3=zfse3t         , psgn=1.0 )
             IF( kt==nit000 )CALL tke_avn_ini_crs
             CALL tke_avn_crs
             CALL zdf_evd_crs(kt)
 #endif
-         CASE ( 6 )
-
-            avte_crs(:,:,:,:) = 0._wp
-            ztmp(:,:,:)=1.
-
-            zt(:,:,:) = 0._wp
-            zs(:,:,:) = 0._wp
-            DO jk=2,jpk 
-               WHERE( fse3w(:,:,jk) .NE. 0._wp) zs(:,:,jk) = ( tsn(:,:,jk-1,jp_tem) - tsn(:,:,jk,jp_tem) ) / fse3w(:,:,jk)
-               zt(:,:,jk)=  avt(:,:,jk) *  zs(:,:,jk)
-            ENDDO
-            CALL crs_dom_ope( zt, 'VOL', 'W', tmask, zt_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            CALL crs_dom_ope( zs, 'VOL', 'W', tmask, zs_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            zt_crs=tmask_crs*zt_crs
-            WHERE( zs_crs .NE. 0._wp ) avte_crs(:,:,:,1) = zt_crs / zs_crs
-
-            zt(:,:,:) = 0._wp
-            zs(:,:,:) = 0._wp
-            DO jk=2,jpk 
-               WHERE( fse3w(:,:,jk) .NE. 0._wp) zs(:,:,jk) = ( tsn(:,:,jk-1,jp_sal) - tsn(:,:,jk,jp_sal) ) / fse3w(:,:,jk)
-               zt(:,:,jk)=  avt(:,:,jk) *  zs(:,:,jk)
-            ENDDO
-            CALL crs_dom_ope( zt, 'VOL', 'W', tmask, zt_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            CALL crs_dom_ope( zs, 'VOL', 'W', tmask, zs_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            zt_crs=tmask_crs*zt_crs
-            WHERE( zs_crs .NE. 0._wp ) avte_crs(:,:,:,2) = zt_crs / zs_crs
-
-            zt(:,:,:) = 0._wp
-            zs(:,:,:) = 0._wp
-            DO jk=2,jpk
-                WHERE( fse3w(:,:,jk) .NE. 0._wp ) zs(:,:,jk)= ( rn_a0 * ( tsn(:,:,jk-1,jp_tem) - tsn(:,:,jk,jp_tem) ) +  &
-                                                                  &   rn_b0 * ( tsn(:,:,jk-1,jp_sal) - tsn(:,:,jk,jp_sal) ) )/ fse3w(:,:,jk) 
-                zt(:,:,jk)=  avt(:,:,jk) *  zs(:,:,jk)                                                           
-            ENDDO
-            CALL crs_dom_ope( zt, 'VOL', 'W', tmask, zt_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            CALL crs_dom_ope( zs, 'VOL', 'W', tmask, zs_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            zt_crs=tmask_crs*zt_crs
-            WHERE( zs_crs .NE. 0._wp ) avte_crs(:,:,:,3) = zt_crs / zs_crs
-
-            zt(:,:,:) = 0._wp
-            zs(:,:,:) = 0._wp
-            DO jk=2,jpk
-                WHERE( fse3w(:,:,jk) .NE. 0._wp ) zs(:,:,jk)= ( rn_a0 * ( tsn(:,:,jk-1,jp_tem) - tsn(:,:,jk,jp_tem) ) -  &
-                                                                  &   rn_b0 * ( tsn(:,:,jk-1,jp_sal) - tsn(:,:,jk,jp_sal) ) )/ fse3w(:,:,jk) 
-                zt(:,:,jk)=  avt(:,:,jk) *  zs(:,:,jk)
-            ENDDO
-            CALL crs_dom_ope( zt, 'VOL', 'W', tmask, zt_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            CALL crs_dom_ope( zs, 'VOL', 'W', tmask, zs_crs, p_e12=e1e2t, p_e3=ztmp, psgn=1.0 )
-            zt_crs=tmask_crs*zt_crs
-            WHERE( zs_crs .NE. 0._wp ) avte_crs(:,:,:,4) = zt_crs / zs_crs
-
-            CALL iom_put( "avte_crs1", avte_crs(:,:,:,1) )   !  Kz
-            CALL iom_put( "avte_crs2", avte_crs(:,:,:,2) )   !  Kz
-            CALL iom_put( "avte_crs3", avte_crs(:,:,:,3) )   !  Kz
-            CALL iom_put( "avte_crs4", avte_crs(:,:,:,4) )   !  Kz
-
-            CALL crs_dom_ope( avt, 'MED', 'W', tmask, zs_crs, p_e12=e1e2t, p_e3=zfse3w, p_mask_crs=tmask_crs, psgn=1.0 )
-            CALL iom_put( "zs_crs", zs_crs )   !  Kzlogvol
-
-            CALL crs_dom_ope( avt, 'VOL', 'W', tmask, zmax_crs, p_e12=e1e2t, p_e3=zfse3w,  psgn=1.0 )
-            CALL iom_put( "zmax_crs", zmax_crs )   !  Kzlogvol
-            avt_crs=zs_crs
-
-
-            zerr0=0.01
-
-            icnt1=0
-            icnt2=0
-
-            zt_crs(:,:,:)=0._wp
-            zerr_crs(:,:,:)=0._wp
-            DO ji=1,jpi_crs 
-            DO jj=1,jpj_crs 
-            DO jk=1,jpk
-
- 
-               zwgt(1:4)=0._wp
-               DO jm=1,4 ; IF( avte_crs(ji,jj,jk,jm)  .GE. 0._wp .AND.  avte_crs(ji,jj,jk,jm)  .LE. zmax_crs(ji,jj,jk)  ) zwgt(jm) = 1._wp ; ENDDO
-               IF( SUM(zwgt(1:4)) .NE. 0._wp ) THEN  
-                  zmean = SUM( zwgt(1:4)*avte_crs(ji,jj,jk,1:4)) / SUM(zwgt(1:4) )
-                  zerr  = SQRT(SUM( zwgt(1:4)*(avte_crs(ji,jj,jk,1:4)-zmean)*(avte_crs(ji,jj,jk,1:4)-zmean) ) / SUM(zwgt(1:4) ) )
-               ELSE
-                  zmean=0._wp
-                 zerr=1.e10
-               ENDIF
-
-               zerr_crs(ji,jj,jk)=zerr
-
-               IF( zerr .LE. zerr0 .AND. zmean .GT. 0._wp )zt_crs(ji,jj,jk)=zmean
-               IF( zerr .LE. zerr0 .AND. zmean .GT. 0._wp )avt_crs(ji,jj,jk)=zmean
-
-               IF( tmask_crs(ji,jj,jk) == 1 ) icnt1=icnt1+1
-               IF( tmask_crs(ji,jj,jk) == 1 .AND.  zerr .LE. zerr0 .AND. zmean .GT. 0._wp ) icnt2=icnt2+1
-
-            ENDDO
-            ENDDO
-            ENDDO
-
-            CALL iom_put( "zt_crs", zt_crs )   !  Kz
-            CALL iom_put( "zerr_crs", zerr_crs )   !  Kz
 
       END SELECT
@@ -477,7 +371,5 @@
       CALL wrk_dealloc( jpi, jpj, jpk, zt, zs, ztmp   )
       CALL wrk_dealloc( jpi, jpj, z2d                 )
-      CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs, zerr_crs,zmax_crs )
-      CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, ztmp_crs )
-      CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, 4, avte_crs )
+      CALL wrk_dealloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
       CALL wrk_dealloc( jpi_crs, jpj_crs, z2d_crs     )
       !
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 6785)
+++ /branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90	(revision 6786)
@@ -43,5 +43,4 @@
          cltra = TRIM( ctrcnm(jn) )                  ! short title for tracer
          CALL iom_put( TRIM(cltra), trn(:,:,:,jn) )
-         ENDIF
       END DO
       !
