Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbc_lnk_multi_generic.h90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 10136)
@@ -14,7 +14,14 @@
 #   define PTR_ptab              pt4d
 #endif
+#if defined ASYNC
+   SUBROUTINE ROUTINE_MULTI( rname, loop_fct &
+                           , pt1, cdna1, psgn1, pt2, cdna2, psgn2, pt3, cdna3, psgn3   &
+      &                    , pt4, cdna4, psgn4, pt5, cdna5, psgn5, pt6, cdna6, psgn6   &
+      &                    , pt7, cdna7, psgn7, pt8, cdna8, psgn8, pt9, cdna9, psgn9, cd_mpp, pval)
+#else
    SUBROUTINE ROUTINE_MULTI( rname, pt1, cdna1, psgn1, pt2, cdna2, psgn2, pt3, cdna3, psgn3   &
       &                    , pt4, cdna4, psgn4, pt5, cdna5, psgn5, pt6, cdna6, psgn6   &
       &                    , pt7, cdna7, psgn7, pt8, cdna8, psgn8, pt9, cdna9, psgn9, cd_mpp, pval)
+#endif
       !!---------------------------------------------------------------------
       ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) ::   pt1     ! arrays on which the lbc is applied
@@ -26,4 +33,12 @@
       CHARACTER(len=3)   , OPTIONAL        , INTENT(in   ) ::   cd_mpp  ! fill the overlap area only
       REAL(wp)           , OPTIONAL        , INTENT(in   ) ::   pval    ! background value (used at closed boundaries)
+#ifdef ASYNC
+      interface
+        subroutine loop_fct(i0, i1, j0, j1, k0, k1, buf)
+          integer, intent(in) :: i0, i1, j0, j1, k0, k1
+          REAL*8, dimension(:,:,:,:,:,:), optional, intent(out) :: buf
+        end subroutine loop_fct
+      end interface
+#endif
       !!
       INTEGER                         ::   kfld        ! number of elements that will be attributed
@@ -49,5 +64,9 @@
       IF( PRESENT(psgn9) )   CALL ROUTINE_LOAD( pt9, cdna9, psgn9, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
       !
+#ifdef ASYNC
+      CALL lbc_lnk_ptr_async( rname, ptab_ptr, cdna_ptr, psgn_ptr, loop_fct, kfld, cd_mpp, pval )
+#else
       CALL lbc_lnk_ptr( rname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, cd_mpp, pval )
+#endif
       !
    END SUBROUTINE ROUTINE_MULTI
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbclnk.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbclnk.F90	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lbclnk.F90	(revision 10136)
@@ -50,4 +50,19 @@
    PUBLIC   lbc_lnk_icb   ! iceberg lateral boundary conditions
 
+#ifdef BULL_ASYNC
+   INTERFACE lbc_lnk_async
+      MODULE PROCEDURE   mpp_lnk_2d_async      , mpp_lnk_3d_async      , mpp_lnk_4d_async
+   END INTERFACE
+   INTERFACE lbc_lnk_ptr_async
+      MODULE PROCEDURE   mpp_lnk_2d_ptr_async  , mpp_lnk_3d_ptr_async  , mpp_lnk_4d_ptr_async
+   END INTERFACE
+   INTERFACE lbc_lnk_multi_async
+      MODULE PROCEDURE   lbc_lnk_2d_multi_async, lbc_lnk_3d_multi_async, lbc_lnk_4d_multi_async
+   END INTERFACE
+
+   PUBLIC   lbc_lnk_async       ! ocean/ice  lateral boundary conditions
+   PUBLIC   lbc_lnk_multi_async ! modified ocean/ice lateral boundary conditions
+#endif
+
    PUBLIC   simulated_lbc_lnk
 
@@ -91,4 +106,5 @@
       MODULE PROCEDURE   lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi
    END INTERFACE
+
    !
    INTERFACE lbc_bdy_lnk
@@ -104,5 +120,5 @@
    PUBLIC   lbc_bdy_lnk   ! ocean lateral BDY boundary conditions
    PUBLIC   lbc_lnk_icb   ! iceberg lateral boundary conditions
-   
+  
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -327,4 +343,35 @@
 #     undef ROUTINE_LOAD
 #  undef DIM_4d
+
+#ifdef BULL_ASYNC
+#define ASYNC
+#  define DIM_2d
+#     define ROUTINE_MULTI          lbc_lnk_2d_multi_async
+#     define ROUTINE_LOAD           load_ptr_2d_async
+#     include "lbc_lnk_multi_generic.h90"
+#     undef ROUTINE_MULTI
+#     undef ROUTINE_LOAD
+#  undef DIM_2d
+
+
+#  define DIM_3d
+#     define ROUTINE_MULTI          lbc_lnk_3d_multi_async
+#     define ROUTINE_LOAD           load_ptr_3d_async
+#     include "lbc_lnk_multi_generic.h90"
+#     undef ROUTINE_MULTI
+#     undef ROUTINE_LOAD
+#  undef DIM_3d
+
+
+#  define DIM_4d
+#     define ROUTINE_MULTI          lbc_lnk_4d_multi_async
+#     define ROUTINE_LOAD           load_ptr_4d_async
+#     include "lbc_lnk_multi_generic.h90"
+#     undef ROUTINE_MULTI
+#     undef ROUTINE_LOAD
+#  undef DIM_4d
+
+#undef ASYNC
+#endif
 
    SUBROUTINE simulated_lbc_lnk ()
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lib_mpp.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lib_mpp.F90	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/lib_mpp.F90	(revision 10136)
@@ -72,4 +72,9 @@
    PUBLIC   mpp_lnk_2d_ptr, mpp_lnk_3d_ptr, mpp_lnk_4d_ptr
    !
+#ifdef BULL_ASYNC
+   ! Interface associated to the mpp_lnk_... routines is defined in lbclnk
+   PUBLIC   mpp_lnk_2d_async    , mpp_lnk_3d_async    , mpp_lnk_4d_async
+   PUBLIC   mpp_lnk_2d_ptr_async, mpp_lnk_3d_ptr_async, mpp_lnk_4d_ptr_async
+#endif
 !!gm  this should be useless
    PUBLIC   mpp_nfd_2d    , mpp_nfd_3d    , mpp_nfd_4d
@@ -270,4 +275,5 @@
             WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
             kstop = kstop + 1
+            WRITE(*,*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
          END SELECT
          !
@@ -276,4 +282,5 @@
          WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1
          kstop = kstop + 1
+         WRITE(*,*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1
       ELSE
          SELECT CASE ( cn_mpi_send )
@@ -292,4 +299,5 @@
             WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
             kstop = kstop + 1
+            WRITE(*,*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
          END SELECT
          !
@@ -383,4 +391,74 @@
 #     undef MULTI
 #  undef DIM_4d
+
+#ifdef BULL_ASYNC
+# define ASYNC
+
+#if (defined BULL_MPI_DATATYPE || defined BULL_MPI_DATATYPE_SUBARRAY)
+# define MPI_DATATYPE_SUBARRAY
+#warning "MPI_DATATYPE_SUBARRAY"
+#ifdef BULL_MPI_DATATYPE_VECTOR
+#undef MPI_DATATYPE_VECTOR
+#warning "BULL_MPI_DATATYPE_SUBARRAY and BULL_MPI_DATATYPE_VECTOR are defined: undef BULL_MPI_DATATYPE_VECTOR"
+#endif
+#endif
+#ifdef BULL_MPI_DATATYPE_VECTOR
+# define MPI_DATATYPE_VECTOR
+#warning "MPI_DATATYPE_VECTOR"
+#endif
+   !!----------------------------------------------------------------------
+   !!                   ***  routine mpp_lnk_(2,3,4)d  ***
+   !!
+   !!   * Argument : dummy argument use in mpp_lnk_... routines
+   !!                ptab   :   array or pointer of arrays on which the boundary condition is applied
+   !!                cd_nat :   nature of array grid-points
+   !!                psgn   :   sign used across the north fold boundary
+   !!                kfld   :   optional, number of pt3d arrays
+   !!                cd_mpp :   optional, fill the overlap area only
+   !!                pval   :   optional, background value (used at closed boundaries)
+   !!----------------------------------------------------------------------
+   !
+   !                       !==  2D array and array of 2D pointer  ==!
+   !
+#  define DIM_2d
+#     define ROUTINE_LNK           mpp_lnk_2d_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_2d_ptr_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_2d
+   !
+   !                       !==  3D array and array of 3D pointer  ==!
+   !
+#  define DIM_3d
+#     define ROUTINE_LNK           mpp_lnk_3d_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_3d_ptr_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_3d
+   !
+   !                       !==  4D array and array of 4D pointer  ==!
+   !
+#  define DIM_4d
+#     define ROUTINE_LNK           mpp_lnk_4d_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_4d_ptr_async
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_4d
+
+#undef ASYNC
+#undef MPI_DATATYPE
+#endif
 
    !!----------------------------------------------------------------------
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/mpp_lnk_generic.h90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10136)
@@ -1,4 +1,4 @@
 #if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
+#   define NAT_IN(k)                cd_nat(k)
 #   define SGN_IN(k)                psgn(k)
 #   define F_SIZE(ptab)             kfld
@@ -9,4 +9,5 @@
 #      define K_SIZE(ptab)             1
 #      define L_SIZE(ptab)             1
+#      define _INDEX(i,j,k,l)          (i+((j)+((0)+(0)*ipk)*jpj)*jpi)
 #   endif
 #   if defined DIM_3d
@@ -15,4 +16,5 @@
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
 #      define L_SIZE(ptab)             1
+#      define _INDEX(i,j,k,l)          (i+((j)+((k)+(0)*ipk)*jpj)*jpi)
 #   endif
 #   if defined DIM_4d
@@ -21,4 +23,5 @@
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
 #      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
+#      define _INDEX(i,j,k,l)          (i+((j)+((k)+(l)*ipk)*jpj)*jpi)
 #   endif
 #else
@@ -27,9 +30,10 @@
 #   define SGN_IN(k)                psgn
 #   define F_SIZE(ptab)             1
-#   define OPT_K(k)                 
+#   define OPT_K(k)
 #   if defined DIM_2d
 #      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
 #      define K_SIZE(ptab)          1
 #      define L_SIZE(ptab)          1
+#      define _INDEX(i,j,k,l)          (i+((j)+((0)+(0)*ipk)*jpj)*jpi)
 #   endif
 #   if defined DIM_3d
@@ -37,4 +41,5 @@
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          1
+#      define _INDEX(i,j,k,l)          (i+((j)+((k)+(0)*ipk)*jpj)*jpi)
 #   endif
 #   if defined DIM_4d
@@ -42,12 +47,28 @@
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          SIZE(ptab,4)
+#      define _INDEX(i,j,k,l)          (i+((j)+((k)+(l)*ipk)*jpj)*jpi)
 #   endif
 #endif
 
 #if defined MULTI
-   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn, kfld, cd_mpp, pval )
+#if defined ASYNC
+   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn, loop_fct, kfld, cd_mpp, pval )
       INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
 #else
-   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn      , cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn          , kfld, cd_mpp, pval )
+      INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
+#endif
+#else
+#if defined ASYNC
+   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn, loop_fct,       cd_mpp, pval )
+#else
+   SUBROUTINE ROUTINE_LNK( rname, ptab, cd_nat, psgn,                 cd_mpp, pval )
+#endif
+#endif
+#ifdef SCOREP_USER_ENABLE
+#include "scorep/SCOREP_User.inc"
+#else
+#define SCOREP_USER_REGION_BEGIN !
+#define SCOREP_USER_REGION_END   !
 #endif
       ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
@@ -56,4 +77,15 @@
       CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp      ! fill the overlap area only
       REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval        ! background value (used at closed boundaries)
+#ifdef ASYNC
+      interface
+        subroutine loop_fct(i0, i1, j0, j1, k0, k1, buf)
+          integer, intent(in) :: i0, i1, j0, j1, k0, k1
+          ! @BULL_FIXME
+          ! lib_mpp.f90(4209): error #6683: A kind type parameter must be a compile-time constant.   [WP]
+          !          REAL(wp), dimension(:), optional, intent(out) :: buf
+          REAL*8, dimension(:,:,:,:,:,:), optional, intent(out) :: buf
+        end subroutine loop_fct
+      end interface
+#endif
       CHARACTER(len=*),             INTENT(in   ) ::   rname       ! name of the calling subroutine
       !
@@ -66,4 +98,45 @@
       REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! north-south & south-north  halos
       REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! east -west  & west - east  halos
+#ifdef ASYNC
+      integer :: iflag, i
+      logical :: finished
+#if (defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      integer :: ml_reqs(8,F_SIZE(ptab))
+#else
+      integer :: ml_reqs(8)
+#endif
+#endif
+#ifdef SCOREP_USER_ENABLE
+      integer :: ier
+      SCOREP_USER_REGION_DEFINE( reg_cb )
+      SCOREP_USER_REGION_DEFINE( reg_cbWhole )
+      SCOREP_USER_REGION_DEFINE( reg_cbWE )
+      SCOREP_USER_REGION_DEFINE( reg_cbNS )
+      SCOREP_USER_REGION_DEFINE( reg_cbCenter )
+      SCOREP_USER_REGION_DEFINE( reg_pack )
+      SCOREP_USER_REGION_DEFINE( reg_unpack )
+#if (defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      SCOREP_USER_REGION_DEFINE( reg_datatype )
+#endif
+#endif
+#ifdef MPI_DATATYPE_VECTOR
+      integer :: type_ns, type_ew
+#endif
+#ifdef MPI_DATATYPE_SUBARRAY
+      integer :: ndims
+      integer, dimension(4) :: array_of_sizes
+      integer, dimension(4) :: array_of_subsizes
+      integer, dimension(4) :: array_of_starts
+      integer :: type_north_halo, type_north_ghost
+      integer :: type_south_halo, type_south_ghost
+      integer :: type_west_halo, type_west_ghost
+      integer :: type_east_halo, type_east_ghost
+#endif
+      real*8 :: t0
+      real*8, save :: time=0.0
+
+#ifdef ASYNC
+      ml_reqs = MPI_REQUEST_NULL
+#endif
       !!----------------------------------------------------------------------
       !
@@ -72,6 +145,8 @@
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
       ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2),   &
          &      zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2)  )
+#endif
       !
       IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
@@ -79,4 +154,5 @@
       ENDIF
 
+#ifndef ASYNC
       ! ------------------------------- !
       !   standard boundary treatment   !    ! CAUTION: semi-column notation is often impossible
@@ -133,4 +209,5 @@
       ! we play with the neigbours AND the row number because of the periodicity
       !
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
       CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
@@ -147,4 +224,5 @@
          END DO
       END SELECT
+      SCOREP_USER_REGION_END( reg_pack )
       !
       !                           ! Migrations
@@ -210,4 +288,5 @@
       iihom = nlci-nn_hls
       !
+      SCOREP_USER_REGION_BEGIN( reg_unpack, "unpack", SCOREP_USER_REGION_TYPE_COMMON )
       SELECT CASE ( nbondi )
       CASE ( -1 )
@@ -243,4 +322,5 @@
          END DO
       END SELECT
+      SCOREP_USER_REGION_END( reg_unpack )
 
       ! 3. North and south directions
@@ -248,4 +328,5 @@
       ! always closed : we play only with the neigbours
       !
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
       IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
          ijhom = nlcj-nrecj
@@ -261,4 +342,7 @@
          END DO
       ENDIF
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_pack )
+#endif
       !
       !                           ! Migrations
@@ -271,5 +355,5 @@
          !
          CALL tic_tac(.TRUE.)
-         ! 
+         !
          SELECT CASE ( nbondj )
          CASE ( -1 )
@@ -295,4 +379,5 @@
       !
       !                           ! Write Dirichlet lateral conditions
+      SCOREP_USER_REGION_BEGIN( reg_unpack, "unpack", SCOREP_USER_REGION_TYPE_COMMON )
       ijhom = nlcj-nn_hls
       !
@@ -330,5 +415,597 @@
          END DO
       END SELECT
-
+      SCOREP_USER_REGION_END( reg_unpack )
+#else
+! ASYNC implementation
+
+! prepare receptions
+   !SUBROUTINE mpprecv( ktyp, pmess, kbytes, ksource )
+   !CALL mpi_recv( pmess, kbytes, mpi_double_precision, use_source, ktyp, mpi_comm_oce, istatus, iflag )
+#ifdef MPI_DATATYPE_VECTOR
+!      IF( ln_timing )  t0=MPI_Wtime() 
+      SCOREP_USER_REGION_BEGIN( reg_datatype, "datatype vector", SCOREP_USER_REGION_TYPE_COMMON )
+      ! int MPI_Type_vector(int count,
+      !                 int blocklength,
+      !                 int stride,
+      !                 MPI_Datatype old_type,
+      !                 MPI_Datatype *newtype_p)        
+#ifdef DIM_2d
+      ! NS
+      call MPI_Type_contiguous((jpi-2*nn_hls), MPI_DOUBLE_PRECISION, type_ns, iflag)
+      call MPI_Type_commit(type_ns, iflag)
+      ! EW
+      call MPI_Type_vector((jpj-2*nn_hls), nn_hls, jpi, MPI_DOUBLE_PRECISION, type_ew, iflag)
+      call MPI_Type_commit(type_ew, iflag)
+#endif
+#   if (defined DIM_3d || defined DIM_4d)
+      ! NS
+      call MPI_Type_vector(nn_hls             *ipk*ipl,          (jpi-2*nn_hls), jpi*jpj, MPI_DOUBLE_PRECISION, type_ns, iflag)
+      call MPI_Type_commit(type_ns, iflag)
+      ! EW
+      call MPI_Type_vector(       (jpj-2*nn_hls)*ipk*ipl, nn_hls               , jpi,     MPI_DOUBLE_PRECISION, type_ew, iflag)
+      call MPI_Type_commit(type_ew, iflag)
+#endif
+      SCOREP_USER_REGION_END( reg_datatype )
+!      IF( ln_timing ) time=time+MPI_Wtime()-t0
+!      IF( ln_timing ) write(*,*) 'timing datatype vector: ',time
+
+      DO jf = 1, ipf
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+           call mpi_irecv(ARRAY_IN(1,2,1,1,jf), 1, type_ew, noea, 8*jf+1, mpi_comm_oce, ml_reqs(1,jf), iflag)
+         CASE ( 0 )
+           call mpi_irecv(ARRAY_IN(1,2,1,1,jf), 1, type_ew, noea, 8*jf+1, mpi_comm_oce, ml_reqs(1,jf), iflag)
+           call mpi_irecv(ARRAY_IN(jpi-nn_hls,2,1,1,jf), 1, type_ew, nowe, 8*jf+2, mpi_comm_oce, ml_reqs(2,jf), iflag)
+         CASE ( 1 )
+           call mpi_irecv(ARRAY_IN(jpi-nn_hls,2,1,1,jf), 1, type_ew, nowe, 8*jf+2, mpi_comm_oce, ml_reqs(2,jf), iflag)
+         END SELECT
+
+         SELECT CASE ( nbondj )
+         CASE ( -1 )
+           call mpi_irecv(ARRAY_IN(2,jpj-nn_hls,1,1,jf), 1, type_ns, nono, 8*jf+3, mpi_comm_oce, ml_reqs(3,jf), iflag)
+         CASE ( 0 )
+           call mpi_irecv(ARRAY_IN(2,jpj-nn_hls,1,1,jf), 1, type_ns, nono, 8*jf+3, mpi_comm_oce, ml_reqs(3,jf), iflag)
+           call mpi_irecv(ARRAY_IN(2,1,1,1,jf), 1, type_ns, noso, 8*jf+4, mpi_comm_oce, ml_reqs(4,jf), iflag)
+         CASE ( 1 )
+           call mpi_irecv(ARRAY_IN(2,1,1,1,jf), 1, type_ns, noso, 8*jf+4, mpi_comm_oce, ml_reqs(4,jf), iflag)
+         END SELECT
+      end do
+#endif
+
+#ifdef MPI_DATATYPE_SUBARRAY
+      IF( ln_timing )   CALL timing_start('datatype subarray')
+      SCOREP_USER_REGION_BEGIN( reg_datatype, "datatype", SCOREP_USER_REGION_TYPE_COMMON )
+
+      array_of_sizes = (/ jpi, jpj, ipk, ipl /)
+      array_of_subsizes(3:4) = (/ ipk, ipl /)
+      array_of_starts(3:4) = 0
+#   if defined DIM_2d
+      ndims = 2
+#   endif
+#   if defined DIM_3d
+      ndims = 3
+#   endif
+#   if defined DIM_4d
+      ndims = 4
+#   endif
+      ! ------------------------------- !
+      !      East and west exchange     !
+      ! ------------------------------- !
+      array_of_subsizes(1:2) = (/ nn_hls, jpj-2*nn_hls /)
+
+      array_of_starts(1:2) = (/ 1, 1 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_west_halo, iflag)
+      call MPI_Type_commit(type_west_halo, iflag)
+      array_of_starts(1:2) = (/ 0, 1 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_west_ghost, iflag)
+      call MPI_Type_commit(type_west_ghost, iflag)
+
+      array_of_starts(1:2) = (/ jpi-1-nn_hls, 1 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_east_halo, iflag)
+      call MPI_Type_commit(type_east_halo, iflag)
+      array_of_starts(1:2) = (/ jpi-nn_hls, 1 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_east_ghost, iflag)
+      call MPI_Type_commit(type_east_ghost, iflag)
+
+      ! ------------------------------- !
+      !      North and south exchange     !
+      ! ------------------------------- !
+      array_of_subsizes(1:2) = (/ jpi-2*nn_hls, nn_hls /)
+
+      array_of_starts(1:2) = (/ 1, 1 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_south_halo, iflag)
+      call MPI_Type_commit(type_south_halo, iflag)
+      array_of_starts(1:2) = (/ 1, 0 /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_south_ghost, iflag)
+      call MPI_Type_commit(type_south_ghost, iflag)
+
+      array_of_starts(1:2) = (/ 1, jpj-1-nn_hls /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_north_halo, iflag)
+      call MPI_Type_commit(type_north_halo, iflag)
+      array_of_starts(1:2) = (/ 1, jpj-nn_hls /) ! zero indexing (as in C)
+      call MPI_Type_create_subarray( ndims, array_of_sizes, array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN, MPI_DOUBLE_PRECISION, type_north_ghost, iflag)
+      call MPI_Type_commit(type_north_ghost, iflag)
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_datatype )
+#endif
+      IF( ln_timing )   CALL timing_stop('datatype subarray')
+
+      DO jf = 1, ipf
+         SELECT CASE ( nbondi )
+         CASE ( -1 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_east_ghost, noea, 8*jf+1, mpi_comm_oce, ml_reqs(1,jf), iflag)
+         CASE ( 0 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_east_ghost, noea, 8*jf+1, mpi_comm_oce, ml_reqs(1,jf), iflag)
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_west_ghost, nowe, 8*jf+2, mpi_comm_oce, ml_reqs(2,jf), iflag)
+         CASE ( 1 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_west_ghost, nowe, 8*jf+2, mpi_comm_oce, ml_reqs(2,jf), iflag)
+         END SELECT
+
+         SELECT CASE ( nbondj )
+         CASE ( -1 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_north_ghost, nono, 8*jf+3, mpi_comm_oce, ml_reqs(3,jf), iflag)
+         CASE ( 0 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_north_ghost, nono, 8*jf+3, mpi_comm_oce, ml_reqs(3,jf), iflag)
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_south_ghost, noso, 8*jf+4, mpi_comm_oce, ml_reqs(4,jf), iflag)
+         CASE ( 1 )
+           call mpi_irecv(ARRAY_IN(:,:,:,:,jf), 1, type_south_ghost, noso, 8*jf+4, mpi_comm_oce, ml_reqs(4,jf), iflag)
+         END SELECT
+      end do
+#endif
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      !                           ! Migrations
+      imigr = nn_hls * jpj * ipk * ipl * ipf
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+        call mpi_irecv(zt3ew(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, noea, 1, mpi_comm_oce, ml_reqs(1), iflag)
+      CASE ( 0 )
+        call mpi_irecv(zt3ew(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, noea, 1, mpi_comm_oce, ml_reqs(1), iflag)
+        call mpi_irecv(zt3we(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, nowe, 2, mpi_comm_oce, ml_reqs(2), iflag)
+      CASE ( 1 )
+        call mpi_irecv(zt3we(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, nowe, 2, mpi_comm_oce, ml_reqs(2), iflag)
+      END SELECT
+
+      imigr = nn_hls * jpi * ipk * ipl * ipf
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+        call mpi_irecv(zt3ns(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, nono, 3, mpi_comm_oce, ml_reqs(3), iflag)
+      CASE ( 0 )
+        call mpi_irecv(zt3ns(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, nono, 3, mpi_comm_oce, ml_reqs(3), iflag)
+        call mpi_irecv(zt3sn(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, noso, 4, mpi_comm_oce, ml_reqs(4), iflag)
+      CASE ( 1 )
+        call mpi_irecv(zt3sn(1,1,1,1,1,2), imigr, MPI_DOUBLE_PRECISION, noso, 4, mpi_comm_oce, ml_reqs(4), iflag)
+      END SELECT
+#endif
+
+! compute West
+#define TI 1
+#define TJ 1
+
+#define I0 2
+#define I1 jpi-1
+#define J0 2
+#define J1 jpj-1
+
+#define FULL_ROWS (I0 == 2 && I1 == jpi-1)
+#define FULL_COLUMNS (J0 == 2 && J1 == jpi-1)
+#define WHOLE_RANGE (FULL_ROWS && FULL_COLUMNS)
+
+#if (FULL_ROWS && FULL_COLUMNS)
+#warning "BULL: lib_mpp will compute whole cb "
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbWhole, "cb whole", SCOREP_USER_REGION_TYPE_COMMON )
+      call loop_fct( I0, I1 &
+                   , J0, J1  & ! stand for 3,jpjm2
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbWhole )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+
+#if !FULL_COLUMNS
+#warning "BULL: lib_mpp will compute cb S"
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbNS, "cbns", SCOREP_USER_REGION_TYPE_COMMON )
+! asynchrously send South
+      call loop_fct( I0, I1 &
+                   , J0-1, J0-1 &
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbNS )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+      ! 3. South directions
+      ! -----------------------------
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
+#ifdef MPI_DATATYPE_SUBARRAY
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(:,:,:,:,jf), 1, type_south_halo, noso, 8*jf+3, mpi_comm_oce, ml_reqs(4+3,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(:,:,:,:,jf), 1, type_south_halo, noso, 8*jf+3, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#elif (defined MPI_DATATYPE_VECTOR)
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(2,2,1,1,jf), 1, type_ns, noso, 8*jf+3, mpi_comm_oce, ml_reqs(4+3,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(2,2,1,1,jf), 1, type_ns, noso, 8*jf+3, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#else
+      ! always closed : we play only with the neigbours
+      !
+      imigr = nn_hls * jpi * ipk * ipl * ipf
+      SELECT CASE ( nbondj )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+         ijhom = nlcj-nrecj
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+         call mpi_isend(zt3ns(1,1,1,1,1,1), imigr, MPI_DOUBLE_PRECISION, noso, 3, mpi_comm_oce, ml_reqs(4+3), iflag)
+      END SELECT
+#endif
+      SCOREP_USER_REGION_END( reg_pack )
+
+      ! progress all previous operations
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Testall(8, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#else
+      call MPI_Testall(8*ipf, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#endif
+ 
+! compute North
+#if !FULL_COLUMNS
+#warning "BULL: lib_mpp will compute cb N"
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbNS, "cbns", SCOREP_USER_REGION_TYPE_COMMON )
+      call loop_fct( I0, I1   &
+                   , J1+1, J1+1   &
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbNS )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+      ! 3. North directions
+      ! -----------------------------
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
+#ifdef MPI_DATATYPE_SUBARRAY
+      ! always closed : we play only with the neigbours
+
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(:,:,:,:,jf), 1, type_north_halo, nono, 8*jf+4, mpi_comm_oce, ml_reqs(4+4,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(:,:,:,:,jf), 1, type_north_halo, nono, 8*jf+4, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#elif (defined MPI_DATATYPE_VECTOR)
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(2,jpj-nn_hls,1,1,jf), 1, type_ns, nono, 8*jf+4, mpi_comm_oce, ml_reqs(4+3,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(2,jpj-nn_hls,1,1,jf), 1, type_ns, nono, 8*jf+4, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#else
+      !
+      imigr = nn_hls * jpi * ipk * ipl * ipf
+      SELECT CASE ( nbondj )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0 )                ! all exept 2 (i.e. close case)
+         ijhom = nlcj-nrecj ! jpj-2*nn_hls
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+         call mpi_isend(zt3sn(1,1,1,1,1,1), imigr, MPI_DOUBLE_PRECISION, nono, 4, mpi_comm_oce, ml_reqs(4+4), iflag)
+      END SELECT
+#endif
+      SCOREP_USER_REGION_END( reg_pack )
+
+      ! progress all previous operations
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Testall(8, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#else
+      call MPI_Testall(8*ipf, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#endif
+
+#if !FULL_ROWS
+#warning "BULL: lib_mpp will compute cb W"
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbWE, "cbew", SCOREP_USER_REGION_TYPE_COMMON )
+      call loop_fct( I0-1, I0-1 &
+                   , J0, J1  & ! stand for 3,jpjm2
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbWE )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+      ! ------------------------------- !
+      !      West exchange     !
+      ! ------------------------------- !
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
+#ifdef MPI_DATATYPE_SUBARRAY
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+           call mpi_isend(ARRAY_IN(:,:,:,:,jf), 1, type_west_halo, nowe, 8*jf+1, mpi_comm_oce, ml_reqs(4+1,jf), iflag)
+#else
+           call mpi_send(ARRAY_IN(:,:,:,:,jf), 1, type_west_halo, nowe, 8*jf+1, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#elif (defined MPI_DATATYPE_VECTOR)
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(2,2,1,1,jf), 1, type_ew, nowe, 8*jf+1, mpi_comm_oce, ml_reqs(4+3,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(2,2,1,1,jf), 1, type_ew, nowe, 8*jf+1, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#else
+      ! we play with the neigbours AND the row number because of the periodicity
+      !
+      imigr = nn_hls * jpj * ipk * ipl * ipf
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+           DO jl = 1, ipl
+              DO jk = 1, ipk
+                 DO jh = 1, nn_hls
+                    zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
+                 END DO
+              END DO
+           END DO
+        END DO
+        call mpi_isend(zt3ew(1,1,1,1,1,1), imigr, MPI_DOUBLE_PRECISION, nowe, 1, mpi_comm_oce, ml_reqs(4+1), iflag)
+      END SELECT
+#endif
+      SCOREP_USER_REGION_END( reg_pack )
+
+      ! progress all previous operations
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Testall(8, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#else
+      call MPI_Testall(8*ipf, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#endif
+
+! compute East
+#if !FULL_ROWS
+#warning "BULL: lib_mpp will compute cb E"
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbWE, "cbew", SCOREP_USER_REGION_TYPE_COMMON )
+      call loop_fct( I1+1, I1+1 &
+                   , J0, J1  & ! stand for 3,jpjm2
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbWE )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+      ! ------------------------------- !
+      !      East exchange     !
+      ! ------------------------------- !
+      SCOREP_USER_REGION_BEGIN( reg_pack, "pack", SCOREP_USER_REGION_TYPE_COMMON )
+#ifdef MPI_DATATYPE_SUBARRAY
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(:,:,:,:,jf), 1, type_east_halo, noea, 8*jf+2, mpi_comm_oce, ml_reqs(4+2,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(:,:,:,:,jf), 1, type_east_halo, noea, 8*jf+2, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#elif (defined MPI_DATATYPE_VECTOR)
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( 0, 1 )                ! all exept 2 (i.e. close case)
+        DO jf = 1, ipf
+#ifdef BULL_ISEND
+          call mpi_isend(ARRAY_IN(jpi-nn_hls,2,1,1,jf), 1, type_ew, noea, 8*jf+2, mpi_comm_oce, ml_reqs(4+3,jf), iflag)
+#else
+          call mpi_send(ARRAY_IN(jpi-nn_hls,2,1,1,jf), 1, type_ew, noea, 8*jf+2, mpi_comm_oce, iflag)
+#endif
+        END DO
+      END SELECT
+#else
+      ! we play with the neigbours AND the row number because of the periodicity
+      !
+      imigr = nn_hls * jpj * ipk * ipl * ipf
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0 )                ! all exept 2 (i.e. close case)
+         iihom = nlci-nreci ! jpi-2*nn_hls
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+         END DO
+         call mpi_isend(zt3we(1,1,1,1,1,1), imigr, MPI_DOUBLE_PRECISION, noea, 2, mpi_comm_oce, ml_reqs(4+2), iflag)
+      END SELECT
+#endif
+      SCOREP_USER_REGION_END( reg_pack )
+
+      ! progress all previous operations
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Testall(8, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#else
+      call MPI_Testall(8*ipf, ml_reqs, finished, MPI_STATUSES_IGNORE, iflag)
+#endif
+
+! compute Inner
+#if !(FULL_ROWS && FULL_COLUMNS)
+#warning "BULL: lib_mpp will compute inner cb"
+      SCOREP_USER_REGION_BEGIN( reg_cb, "cb", SCOREP_USER_REGION_TYPE_COMMON )
+      SCOREP_USER_REGION_BEGIN( reg_cbCenter, "cbcenter", SCOREP_USER_REGION_TYPE_COMMON )
+      call loop_fct( I0, I1 &
+                   , J0, J1  & ! stand for 3,jpjm2
+                   , 1, jpkm1 & ! TODO check if always jpkm1
+                   )
+      SCOREP_USER_REGION_END( reg_cbCenter )
+      SCOREP_USER_REGION_END( reg_cb )
+#endif
+
+      ! ------------------------------- !
+      !   standard boundary treatment   !    ! CAUTION: semi-column notation is often impossible
+      ! ------------------------------- !
+      !
+      IF( PRESENT( cd_mpp ) ) THEN     !==  halos filled with inner values  ==!
+         !
+         DO jf = 1, ipf                      ! number of arrays to be treated
+            !
+            DO jl = 1, ipl                   ! CAUTION: ptab is defined only between nld and nle
+               DO jk = 1, ipk
+                  DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
+                     ARRAY_IN(nldi  :nlei  ,jj,jk,jl,jf) = ARRAY_IN(nldi:nlei,nlej,jk,jl,jf)
+                     ARRAY_IN(1     :nldi-1,jj,jk,jl,jf) = ARRAY_IN(nldi     ,nlej,jk,jl,jf)
+                     ARRAY_IN(nlei+1:nlci  ,jj,jk,jl,jf) = ARRAY_IN(     nlei,nlej,jk,jl,jf)
+                  END DO
+                  DO ji = nlci+1, jpi                 ! added column(s) (full)
+                     ARRAY_IN(ji,nldj  :nlej  ,jk,jl,jf) = ARRAY_IN(nlei,nldj:nlej,jk,jl,jf)
+                     ARRAY_IN(ji,1     :nldj-1,jk,jl,jf) = ARRAY_IN(nlei,nldj     ,jk,jl,jf)
+                     ARRAY_IN(ji,nlej+1:jpj   ,jk,jl,jf) = ARRAY_IN(nlei,     nlej,jk,jl,jf)
+                  END DO
+               END DO
+            END DO
+            !
+         END DO
+         !
+      ELSE                              !==  standard close or cyclic treatment  ==!
+         !
+         DO jf = 1, ipf                      ! number of arrays to be treated
+            !
+            !                                ! East-West boundaries
+            IF( l_Iperio ) THEN                    !* cyclic
+               ARRAY_IN( 1 ,:,:,:,jf) = ARRAY_IN(jpim1,:,:,:,jf)
+               ARRAY_IN(jpi,:,:,:,jf) = ARRAY_IN(  2  ,:,:,:,jf)
+            ELSE                                   !* closed
+               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(     1       :nn_hls,:,:,:,jf) = zland    ! east except F-point
+                                               ARRAY_IN(nlci-nn_hls+1:jpi   ,:,:,:,jf) = zland    ! west
+            ENDIF
+            !                                ! North-South boundaries
+            IF( l_Jperio ) THEN                    !* cyclic (only with no mpp j-split)
+               ARRAY_IN(:, 1 ,:,:,jf) = ARRAY_IN(:, jpjm1,:,:,jf)
+               ARRAY_IN(:,jpj,:,:,jf) = ARRAY_IN(:,   2  ,:,:,jf)
+            ELSE                                   !* closed
+               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,     1       :nn_hls,:,:,jf) = zland    ! south except F-point
+                                               ARRAY_IN(:,nlcj-nn_hls+1:jpj   ,:,:,jf) = zland    ! north
+            ENDIF
+         END DO
+         !
+      ENDIF
+
+! Wait for any reception (unpack?)
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Waitall(4, ml_reqs, MPI_STATUSES_IGNORE, iflag)
+#endif
+      !                           ! Write Dirichlet lateral conditions
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      SCOREP_USER_REGION_BEGIN( reg_unpack, "unpack", SCOREP_USER_REGION_TYPE_COMMON )
+      iihom = nlci-nn_hls
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 0 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 1 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = nlcj-nn_hls
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 0 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(:,      jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      CASE ( 1 )
+         DO jf = 1, ipf
+            DO jl = 1, ipl
+               DO jk = 1, ipk
+                  DO jh = 1, nn_hls
+                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      SCOREP_USER_REGION_END( reg_unpack )
+#endif
+#endif
       ! 4. north fold treatment
       ! -----------------------
@@ -343,5 +1020,34 @@
       ENDIF
       !
+#ifdef ASYNC
+! wait all sending messages
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
+      call MPI_Waitall(4, ml_reqs(5), MPI_STATUSES_IGNORE, iflag)
+#else
+      call MPI_Waitall(8*ipf, ml_reqs, MPI_STATUSES_IGNORE, iflag)
+#endif
+      !                           ! Write Dirichlet lateral conditions
+#ifdef MPI_DATATYPE_SUBARRAY
+      SCOREP_USER_REGION_BEGIN( reg_datatype, "datatype", SCOREP_USER_REGION_TYPE_COMMON )
+      call MPI_Type_free(type_north_halo, iflag)
+      call MPI_Type_free(type_south_halo, iflag)
+      call MPI_Type_free(type_east_halo, iflag)
+      call MPI_Type_free(type_west_halo, iflag)
+      call MPI_Type_free(type_north_ghost, iflag)
+      call MPI_Type_free(type_south_ghost, iflag)
+      call MPI_Type_free(type_east_ghost, iflag)
+      call MPI_Type_free(type_west_ghost, iflag)
+      SCOREP_USER_REGION_END( reg_datatype )
+#endif
+#ifdef MPI_DATATYPE_VECTOR
+      SCOREP_USER_REGION_BEGIN( reg_datatype, "datatype vector", SCOREP_USER_REGION_TYPE_COMMON )
+      call MPI_Type_free(type_ew, iflag)
+      call MPI_Type_free(type_ns, iflag)
+      SCOREP_USER_REGION_END( reg_datatype )
+#endif
+#endif
+#if !(defined MPI_DATATYPE_SUBARRAY || defined MPI_DATATYPE_VECTOR)
       DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we )
+#endif
       !
    END SUBROUTINE ROUTINE_LNK
@@ -355,2 +1061,3 @@
 #undef F_SIZE
 #undef OPT_K
+#undef _INDEX
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/TRA/traadv_fct.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/TRA/traadv_fct.F90	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/src/OCE/TRA/traadv_fct.F90	(revision 10136)
@@ -27,4 +27,5 @@
    USE lbclnk         ! ocean lateral boundary condition (or mpp link) 
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE timing         ! Timing
 
    IMPLICIT NONE
@@ -325,4 +326,8 @@
 
    SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, p2dt )
+#ifdef SCOREP_USER_ENABLE
+         use mpi
+#include "scorep/SCOREP_User.inc"
+#endif
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE nonosc  ***
@@ -346,9 +351,30 @@
       REAL(wp) ::   zau, zbu, zcu, zav, zbv, zcv, zup, zdo            !   -      -
       REAL(wp), DIMENSION(jpi,jpj,jpk) :: zbetup, zbetdo, zbup, zbdo
+      !dir$ attributes align:64 :: zbetup, zbetdo, zbup, zbdo
+#ifdef SCOREP_USER_ENABLE
+      integer :: ier
+      SCOREP_USER_REGION_DEFINE( reg_nonosc )
+      SCOREP_USER_REGION_DEFINE( reg_nonosc_setup )
+      SCOREP_USER_REGION_DEFINE( reg_nonosc_cb1 )
+      SCOREP_USER_REGION_DEFINE( reg_nonosc_cb2 )
+      SCOREP_USER_REGION_DEFINE( reg_nonosc_barrier )
+      SCOREP_USER_REGION_DEFINE( reg_nonosc_imbalance )
+
+      SCOREP_USER_REGION_BEGIN( reg_nonosc_barrier, "nonosc barrier", SCOREP_USER_REGION_TYPE_COMMON )
+      call MPI_Barrier(MPI_COMM_WORLD, ier)
+      SCOREP_USER_REGION_END( reg_nonosc_barrier )
+      SCOREP_USER_REGION_BEGIN( reg_nonosc, "nonosc", SCOREP_USER_REGION_TYPE_FUNCTION )
+      SCOREP_USER_REGION_BEGIN( reg_nonosc_setup, "nonosc setup", SCOREP_USER_REGION_TYPE_COMMON )
+#endif
+      IF( ln_timing )   CALL timing_start( 'nonosc' )
       !!----------------------------------------------------------------------
       !
       zbig  = 1.e+40_wp
       zrtrn = 1.e-15_wp
+#ifndef BULL_NONOSC_INIT
       zbetup(:,:,:) = 0._wp   ;   zbetdo(:,:,:) = 0._wp
+#else
+      zbetup(:,:,jpk) = 0._wp   ;   zbetdo(:,:,jpk) = 0._wp
+#endif
 
       ! Search local extrema
@@ -360,4 +386,23 @@
          &        paft * tmask + zbig * ( 1._wp - tmask )  )
 
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_nonosc_setup )
+#endif
+
+#ifndef BULL_ASYNC
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_BEGIN( reg_nonosc_cb1, "cb1", SCOREP_USER_REGION_TYPE_LOOP )
+#endif
+! loads:
+! - zbup: ji-1/ji/ji+1, jj-1/jj/jj+1, ji/jk+1/jk-1
+! - zbdo: "
+! - paa:  ji-1/ji
+! - pbb:  jj-1/jj
+! - pcc: ji, jj, jk/jk+1
+! - e1e2t, e3t_n, paft (*2): ji,jj,jk
+!
+! stores:
+! - zbetup
+! - zbetdo
       DO jk = 1, jpkm1
          ikm1 = MAX(jk-1,1)
@@ -394,8 +439,18 @@
          END DO
       END DO
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_nonosc_cb1 )
+#endif
       CALL lbc_lnk_multi("traadv_fct",zbetup, 'T', 1. , zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
-
+#else
+      call lbc_lnk_multi_async( "traadv_fct", cb1, zbetup, 'T', 1. , zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
+#endif
+
+#ifndef BULL_ASYNC
       ! 3. monotonic flux in the i & j direction (paa & pbb)
       ! ----------------------------------------
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_BEGIN( reg_nonosc_cb2, "cb2", SCOREP_USER_REGION_TYPE_LOOP )
+#endif
       DO jk = 1, jpkm1
          DO jj = 2, jpjm1
@@ -420,6 +475,183 @@
          END DO
       END DO
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_nonosc_cb2 )
+#endif
       CALL lbc_lnk_multi("traadv_fct",paa, 'U', -1. , pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
-      !
+#else
+      call lbc_lnk_multi_async( "traadv_fct", cb2, paa, 'U', -1. , pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
+#endif
+      !
+      IF( ln_timing )   CALL timing_stop( 'nonosc' )
+#ifdef SCOREP_USER_ENABLE
+      SCOREP_USER_REGION_END( reg_nonosc )
+      SCOREP_USER_REGION_BEGIN( reg_nonosc_imbalance, "nonosc imbalance", SCOREP_USER_REGION_TYPE_COMMON )
+      call MPI_Barrier(MPI_COMM_WORLD, ier)
+      SCOREP_USER_REGION_END( reg_nonosc_imbalance )
+#endif
+#ifdef BULL_ASYNC
+      contains
+        subroutine cb1(i0, i1, j0, j1, k0, k1, buf)
+          integer, intent(in) :: i0, i1, j0, j1, k0, k1
+          real(wp), dimension(:,:,:,:,:,:), optional, intent(out) :: buf
+          integer jji, jjj, jjk
+          real(wp) :: p2dt_inv
+      !REAL(wp), DIMENSION (40,jpj,jpk) ::   paa, pbb, pcc   ! monotonic fluxes in the 3 directions
+      !REAL(wp), DIMENSION (40,jpj,jpk) ::   e3t_n, paft
+      !REAL(wp), DIMENSION (40,jpj) :: e1e2t
+      !REAL(wp), DIMENSION(40,jpj,jpk) :: zbetup, zbetdo, zbup, zbdo
+          !DIR$ ASSUME_ALIGNED zbup:64
+          !DIR$ ASSUME (jpi .EQ.40)
+          !DIR$ ASSUME (jpj .EQ.42)
+          !DIR$ ASSUME (jpk .EQ.75)
+
+          p2dt_inv = 1._wp * p2dt
+          if(i0 == i1) then
+             ji=i0
+      !  DO jjj = j0, j1, 8
+             DO jk = k0, k1
+                ikm1 = MAX(jk-1,1)
+!DIR$ vector always
+                DO jj = j0, j1
+                !DO jj = jjj, min(jjj+7, j1)
+                       ! search maximum in neighbourhood
+                       zup = MAX(  zbup(ji  ,jj  ,jk  ),   &
+                          &        zbup(ji-1,jj  ,jk  ), zbup(ji+1,jj  ,jk  ),   &
+                          &        zbup(ji  ,jj-1,jk  ), zbup(ji  ,jj+1,jk  ),   &
+                          &        zbup(ji  ,jj  ,ikm1), zbup(ji  ,jj  ,jk+1)  )
+
+                       ! search minimum in neighbourhood
+                       zdo = MIN(  zbdo(ji  ,jj  ,jk  ),   &
+                          &        zbdo(ji-1,jj  ,jk  ), zbdo(ji+1,jj  ,jk  ),   &
+                          &        zbdo(ji  ,jj-1,jk  ), zbdo(ji  ,jj+1,jk  ),   &
+                          &        zbdo(ji  ,jj  ,ikm1), zbdo(ji  ,jj  ,jk+1)  )
+
+                       ! positive part of the flux
+                       zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
+                          & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
+                          & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+
+                       ! negative part of the flux
+                       zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
+                          & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
+                          & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+
+                       ! up & down beta terms
+                       zbt = e1e2t(ji,jj) * e3t_n(ji,jj,jk) * p2dt_inv
+                       zbetup(ji,jj,jk) = ( zup            - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt
+                       zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo            ) / ( zneg + zrtrn ) * zbt
+
+#ifdef BULL_CB_WITH_BUF
+                       ! zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf
+                       buf(jj,1,jk,1,1,1) = zbetup(ji,jj,jk)
+                       buf(jj,1,jk,1,2,1) = zbetdo(ji,jj,jk)
+#endif
+                 END DO
+              END DO
+              !end do
+          else
+             DO jk = k0, k1
+                ikm1 = MAX(jk-1,1)
+                DO jj = j0, j1
+!DIR$ vector always
+                   DO ji = i0, i1
+
+                       ! search maximum in neighbourhood
+                       zup = MAX(  zbup(ji  ,jj  ,jk  ),   &
+                          &        zbup(ji-1,jj  ,jk  ), zbup(ji+1,jj  ,jk  ),   &
+                          &        zbup(ji  ,jj-1,jk  ), zbup(ji  ,jj+1,jk  ),   &
+                          &        zbup(ji  ,jj  ,ikm1), zbup(ji  ,jj  ,jk+1)  )
+
+                       ! search minimum in neighbourhood
+                       zdo = MIN(  zbdo(ji  ,jj  ,jk  ),   &
+                          &        zbdo(ji-1,jj  ,jk  ), zbdo(ji+1,jj  ,jk  ),   &
+                          &        zbdo(ji  ,jj-1,jk  ), zbdo(ji  ,jj+1,jk  ),   &
+                          &        zbdo(ji  ,jj  ,ikm1), zbdo(ji  ,jj  ,jk+1)  )
+
+                       ! positive part of the flux
+                       zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
+                          & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
+                          & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+
+                       ! negative part of the flux
+                       zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
+                          & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
+                          & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+
+                       ! up & down beta terms
+                       zbt = e1e2t(ji,jj) * e3t_n(ji,jj,jk) * p2dt_inv
+                       zbetup(ji,jj,jk) = ( zup            - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt
+                       zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo            ) / ( zneg + zrtrn ) * zbt
+
+                    END DO
+                 END DO
+              END DO
+           endif
+
+        end subroutine
+        subroutine cb2(i0, i1, j0, j1, k0, k1, buf)
+          integer, intent(in) :: i0, i1, j0, j1, k0, k1
+          real(wp), dimension(:,:,:,:,:,:), optional, intent(out) :: buf
+          integer jji, jjj, jjk
+
+          ! 3. monotonic flux in the i & j direction (paa & pbb)
+          if(i0 == i1) then
+             ji=i0
+             do jjj=j0, j1, 8
+             DO jk = k0, k1
+!DIR$ vector always
+                !DO jj = j0, j1
+                DO jj = jjj, min(jjj+7, j1)
+                      zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
+                      zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
+                      zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
+                      paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu )
+
+                      zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
+                      zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
+                      zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
+                      pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv )
+
+             ! monotonic flux in the k direction, i.e. pcc
+             ! -------------------------------------------
+                      za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) )
+                      zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
+                      zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
+                      pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb )
+#ifdef BULL_CB_WITH_BUF
+                       ! zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf
+                       buf(jj,1,jk,1,1,1) = paa(ji,jj,jk)
+                       buf(jj,1,jk,1,2,1) = pbb(ji,jj,jk)
+#endif
+                END DO
+             END DO
+             end do
+          else
+             DO jk = k0, k1
+                DO jj = j0, j1
+!DIR$ vector always
+                   DO ji = i0, i1
+                      zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
+                      zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
+                      zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
+                      paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu )
+
+                      zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
+                      zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
+                      zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
+                      pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv )
+
+             ! monotonic flux in the k direction, i.e. pcc
+             ! -------------------------------------------
+                      za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) )
+                      zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
+                      zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
+                      pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb )
+                   END DO
+                END DO
+             END DO
+           endif
+        end subroutine
+#endif
    END SUBROUTINE nonosc
 
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/best_jpni_jpnj_eorca025
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/best_jpni_jpnj_eorca025	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/best_jpni_jpnj_eorca025	(revision 10136)
@@ -0,0 +1,625 @@
+    nb_cores 1 ( 1 x 1 ), nb_points 1740494 ( 1442 x 1207 )
+    nb_cores 2 ( 2 x 1 ), nb_points 871454 ( 722 x 1207 )
+    nb_cores 3 ( 3 x 1 ), nb_points 581774 ( 482 x 1207 )
+    nb_cores 4 ( 2 x 2 ), nb_points 436810 ( 722 x 605 )
+    nb_cores 5 ( 5 x 1 ), nb_points 350030 ( 290 x 1207 )
+    nb_cores 6 ( 3 x 2 ), nb_points 291610 ( 482 x 605 )
+    nb_cores 7 ( 7 x 1 ), nb_points 251056 ( 208 x 1207 )
+    nb_cores 8 ( 4 x 2 ), nb_points 219010 ( 362 x 605 )
+    nb_cores 9 ( 3 x 3 ), nb_points 194728 ( 482 x 404 )
+    nb_cores 10 ( 2 x 5 ), nb_points 175446 ( 722 x 243 )
+    nb_cores 11 ( 11 x 1 ), nb_points 160531 ( 133 x 1207 )
+    nb_cores 12 ( 4 x 3 ), nb_points 146248 ( 362 x 404 )
+    nb_cores 13 ( 13 x 1 ), nb_points 136391 ( 113 x 1207 )
+    nb_cores 14 ( 7 x 2 ), nb_points 125840 ( 208 x 605 )
+    nb_cores 15 ( 3 x 5 ), nb_points 117126 ( 482 x 243 )
+    nb_cores 16 ( 4 x 4 ), nb_points 110048 ( 362 x 304 )
+    nb_cores 17 ( 17 x 1 ), nb_points 105009 ( 87 x 1207 )
+    nb_cores 18 ( 6 x 3 ), nb_points 97768 ( 242 x 404 )
+    nb_cores 19 ( 19 x 1 ), nb_points 94146 ( 78 x 1207 )
+    nb_cores 20 ( 4 x 5 ), nb_points 87966 ( 362 x 243 )
+    nb_cores 21 ( 7 x 3 ), nb_points 84032 ( 208 x 404 )
+    nb_cores 22 ( 11 x 2 ), nb_points 80465 ( 133 x 605 )
+    nb_cores 23 ( 23 x 1 ), nb_points 78455 ( 65 x 1207 )
+    nb_cores 24 ( 4 x 6 ), nb_points 73486 ( 362 x 203 )
+    nb_cores 25 ( 5 x 5 ), nb_points 70470 ( 290 x 243 )
+    nb_cores 26 ( 13 x 2 ), nb_points 68365 ( 113 x 605 )
+    nb_cores 27 ( 9 x 3 ), nb_points 65448 ( 162 x 404 )
+    nb_cores 28 ( 7 x 4 ), nb_points 63232 ( 208 x 304 )
+    nb_cores 29 ( 29 x 1 ), nb_points 62764 ( 52 x 1207 )
+    nb_cores 30 ( 6 x 5 ), nb_points 58806 ( 242 x 243 )
+    nb_cores 32 ( 8 x 4 ), nb_points 55328 ( 182 x 304 )
+    nb_cores 33 ( 11 x 3 ), nb_points 53732 ( 133 x 404 )
+    nb_cores 34 ( 17 x 2 ), nb_points 52635 ( 87 x 605 )
+    nb_cores 35 ( 7 x 5 ), nb_points 50544 ( 208 x 243 )
+    nb_cores 36 ( 6 x 6 ), nb_points 49126 ( 242 x 203 )
+    nb_cores 38 ( 19 x 2 ), nb_points 47190 ( 78 x 605 )
+    nb_cores 39 ( 13 x 3 ), nb_points 45652 ( 113 x 404 )
+    nb_cores 40 ( 8 x 5 ), nb_points 44226 ( 182 x 243 )
+    nb_cores 42 ( 7 x 6 ), nb_points 42224 ( 208 x 203 )
+    nb_cores 44 ( 11 x 4 ), nb_points 40432 ( 133 x 304 )
+    nb_cores 45 ( 9 x 5 ), nb_points 39366 ( 162 x 243 )
+    nb_cores 46 ( 23 x 2 ), nb_points 39325 ( 65 x 605 )
+    nb_cores 48 ( 8 x 6 ), nb_points 36946 ( 182 x 203 )
+    nb_cores 49 ( 7 x 7 ), nb_points 36400 ( 208 x 175 )
+    nb_cores 50 ( 10 x 5 ), nb_points 35478 ( 146 x 243 )
+    nb_cores 51 ( 17 x 3 ), nb_points 35148 ( 87 x 404 )
+    nb_cores 52 ( 13 x 4 ), nb_points 34352 ( 113 x 304 )
+    nb_cores 54 ( 9 x 6 ), nb_points 32886 ( 162 x 203 )
+    nb_cores 55 ( 11 x 5 ), nb_points 32319 ( 133 x 243 )
+    nb_cores 56 ( 7 x 8 ), nb_points 31824 ( 208 x 153 )
+    nb_cores 57 ( 19 x 3 ), nb_points 31512 ( 78 x 404 )
+    nb_cores 58 ( 29 x 2 ), nb_points 31460 ( 52 x 605 )
+    nb_cores 60 ( 10 x 6 ), nb_points 29638 ( 146 x 203 )
+    nb_cores 62 ( 2 x 31 ), nb_points 29602 ( 722 x 41 )
+    nb_cores 63 ( 7 x 9 ), nb_points 28288 ( 208 x 136 )
+    nb_cores 64 ( 8 x 8 ), nb_points 27846 ( 182 x 153 )
+    nb_cores 65 ( 13 x 5 ), nb_points 27459 ( 113 x 243 )
+    nb_cores 66 ( 11 x 6 ), nb_points 26999 ( 133 x 203 )
+    nb_cores 68 ( 4 x 17 ), nb_points 26426 ( 362 x 73 )
+    nb_cores 69 ( 23 x 3 ), nb_points 26260 ( 65 x 404 )
+    nb_cores 70 ( 14 x 5 ), nb_points 25515 ( 105 x 243 )
+    nb_cores 72 ( 8 x 9 ), nb_points 24752 ( 182 x 136 )
+    nb_cores 75 ( 15 x 5 ), nb_points 23814 ( 98 x 243 )
+    nb_cores 76 ( 19 x 4 ), nb_points 23712 ( 78 x 304 )
+    nb_cores 77 ( 11 x 7 ), nb_points 23275 ( 133 x 175 )
+    nb_cores 78 ( 13 x 6 ), nb_points 22939 ( 113 x 203 )
+    nb_cores 80 ( 10 x 8 ), nb_points 22338 ( 146 x 153 )
+    nb_cores 81 ( 9 x 9 ), nb_points 22032 ( 162 x 136 )
+    nb_cores 84 ( 14 x 6 ), nb_points 21315 ( 105 x 203 )
+    nb_cores 85 ( 17 x 5 ), nb_points 21141 ( 87 x 243 )
+    nb_cores 87 ( 29 x 3 ), nb_points 21008 ( 52 x 404 )
+    nb_cores 88 ( 11 x 8 ), nb_points 20349 ( 133 x 153 )
+    nb_cores 90 ( 10 x 9 ), nb_points 19856 ( 146 x 136 )
+    nb_cores 91 ( 7 x 13 ), nb_points 19760 ( 208 x 95 )
+    nb_cores 95 ( 19 x 5 ), nb_points 18954 ( 78 x 243 )
+    nb_cores 96 ( 12 x 8 ), nb_points 18666 ( 122 x 153 )
+    nb_cores 98 ( 14 x 7 ), nb_points 18375 ( 105 x 175 )
+    nb_cores 99 ( 11 x 9 ), nb_points 18088 ( 133 x 136 )
+    nb_cores 100 ( 10 x 10 ), nb_points 17958 ( 146 x 123 )
+    nb_cores 102 ( 17 x 6 ), nb_points 17661 ( 87 x 203 )
+    nb_cores 104 ( 13 x 8 ), nb_points 17289 ( 113 x 153 )
+    nb_cores 105 ( 15 x 7 ), nb_points 17150 ( 98 x 175 )
+    nb_cores 108 ( 12 x 9 ), nb_points 16592 ( 122 x 136 )
+    nb_cores 110 ( 10 x 11 ), nb_points 16352 ( 146 x 112 )
+    nb_cores 112 ( 14 x 8 ), nb_points 16065 ( 105 x 153 )
+    nb_cores 114 ( 19 x 6 ), nb_points 15834 ( 78 x 203 )
+    nb_cores 115 ( 23 x 5 ), nb_points 15795 ( 65 x 243 )
+    nb_cores 117 ( 13 x 9 ), nb_points 15368 ( 113 x 136 )
+    nb_cores 119 ( 7 x 17 ), nb_points 15184 ( 208 x 73 )
+    nb_cores 120 ( 15 x 8 ), nb_points 14994 ( 98 x 153 )
+    nb_cores 121 ( 11 x 11 ), nb_points 14896 ( 133 x 112 )
+    nb_cores 124 ( 4 x 31 ), nb_points 14842 ( 362 x 41 )
+    nb_cores 125 ( 25 x 5 ), nb_points 14580 ( 60 x 243 )
+    nb_cores 126 ( 14 x 9 ), nb_points 14280 ( 105 x 136 )
+    nb_cores 128 ( 16 x 8 ), nb_points 14076 ( 92 x 153 )
+    nb_cores 130 ( 10 x 13 ), nb_points 13870 ( 146 x 95 )
+    nb_cores 132 ( 12 x 11 ), nb_points 13664 ( 122 x 112 )
+    nb_cores 133 ( 19 x 7 ), nb_points 13650 ( 78 x 175 )
+    nb_cores 135 ( 15 x 9 ), nb_points 13328 ( 98 x 136 )
+    nb_cores 136 ( 8 x 17 ), nb_points 13286 ( 182 x 73 )
+    nb_cores 138 ( 23 x 6 ), nb_points 13195 ( 65 x 203 )
+    nb_cores 140 ( 14 x 10 ), nb_points 12915 ( 105 x 123 )
+    nb_cores 143 ( 11 x 13 ), nb_points 12635 ( 133 x 95 )
+    nb_cores 144 ( 16 x 9 ), nb_points 12512 ( 92 x 136 )
+    nb_cores 147 ( 21 x 7 ), nb_points 12425 ( 71 x 175 )
+    nb_cores 150 ( 15 x 10 ), nb_points 12054 ( 98 x 123 )
+    nb_cores 152 ( 19 x 8 ), nb_points 11934 ( 78 x 153 )
+    nb_cores 153 ( 9 x 17 ), nb_points 11826 ( 162 x 73 )
+    nb_cores 154 ( 14 x 11 ), nb_points 11760 ( 105 x 112 )
+    nb_cores 156 ( 12 x 13 ), nb_points 11590 ( 122 x 95 )
+    nb_cores 160 ( 16 x 10 ), nb_points 11316 ( 92 x 123 )
+    nb_cores 162 ( 18 x 9 ), nb_points 11152 ( 82 x 136 )
+    nb_cores 165 ( 15 x 11 ), nb_points 10976 ( 98 x 112 )
+    nb_cores 168 ( 14 x 12 ), nb_points 10815 ( 105 x 103 )
+    nb_cores 169 ( 13 x 13 ), nb_points 10735 ( 113 x 95 )
+    nb_cores 170 ( 10 x 17 ), nb_points 10658 ( 146 x 73 )
+    nb_cores 171 ( 19 x 9 ), nb_points 10608 ( 78 x 136 )
+    nb_cores 174 ( 29 x 6 ), nb_points 10556 ( 52 x 203 )
+    nb_cores 175 ( 25 x 7 ), nb_points 10500 ( 60 x 175 )
+    nb_cores 176 ( 16 x 11 ), nb_points 10304 ( 92 x 112 )
+    nb_cores 180 ( 20 x 9 ), nb_points 10064 ( 74 x 136 )
+    nb_cores 182 ( 14 x 13 ), nb_points 9975 ( 105 x 95 )
+    nb_cores 184 ( 23 x 8 ), nb_points 9945 ( 65 x 153 )
+    nb_cores 186 ( 6 x 31 ), nb_points 9922 ( 242 x 41 )
+    nb_cores 187 ( 11 x 17 ), nb_points 9709 ( 133 x 73 )
+    nb_cores 189 ( 21 x 9 ), nb_points 9656 ( 71 x 136 )
+    nb_cores 190 ( 19 x 10 ), nb_points 9594 ( 78 x 123 )
+    nb_cores 192 ( 16 x 12 ), nb_points 9476 ( 92 x 103 )
+    nb_cores 195 ( 15 x 13 ), nb_points 9310 ( 98 x 95 )
+    nb_cores 198 ( 11 x 18 ), nb_points 9177 ( 133 x 69 )
+    nb_cores 200 ( 20 x 10 ), nb_points 9102 ( 74 x 123 )
+    nb_cores 203 ( 29 x 7 ), nb_points 9100 ( 52 x 175 )
+    nb_cores 204 ( 12 x 17 ), nb_points 8906 ( 122 x 73 )
+    nb_cores 207 ( 23 x 9 ), nb_points 8840 ( 65 x 136 )
+    nb_cores 208 ( 16 x 13 ), nb_points 8740 ( 92 x 95 )
+    nb_cores 209 ( 19 x 11 ), nb_points 8736 ( 78 x 112 )
+    nb_cores 210 ( 14 x 15 ), nb_points 8715 ( 105 x 83 )
+    nb_cores 216 ( 12 x 18 ), nb_points 8418 ( 122 x 69 )
+    nb_cores 220 ( 20 x 11 ), nb_points 8288 ( 74 x 112 )
+    nb_cores 221 ( 13 x 17 ), nb_points 8249 ( 113 x 73 )
+    nb_cores 224 ( 16 x 14 ), nb_points 8188 ( 92 x 89 )
+    nb_cores 225 ( 15 x 15 ), nb_points 8134 ( 98 x 83 )
+    nb_cores 228 ( 19 x 12 ), nb_points 8034 ( 78 x 103 )
+    nb_cores 230 ( 23 x 10 ), nb_points 7995 ( 65 x 123 )
+    nb_cores 231 ( 21 x 11 ), nb_points 7952 ( 71 x 112 )
+    nb_cores 234 ( 18 x 13 ), nb_points 7790 ( 82 x 95 )
+    nb_cores 238 ( 14 x 17 ), nb_points 7665 ( 105 x 73 )
+    nb_cores 240 ( 20 x 12 ), nb_points 7622 ( 74 x 103 )
+    nb_cores 242 ( 11 x 22 ), nb_points 7581 ( 133 x 57 )
+    nb_cores 247 ( 19 x 13 ), nb_points 7410 ( 78 x 95 )
+    nb_cores 250 ( 25 x 10 ), nb_points 7380 ( 60 x 123 )
+    nb_cores 252 ( 14 x 18 ), nb_points 7245 ( 105 x 69 )
+    nb_cores 255 ( 15 x 17 ), nb_points 7154 ( 98 x 73 )
+    nb_cores 260 ( 20 x 13 ), nb_points 7030 ( 74 x 95 )
+    nb_cores 264 ( 24 x 11 ), nb_points 6944 ( 62 x 112 )
+    nb_cores 266 ( 14 x 19 ), nb_points 6930 ( 105 x 66 )
+    nb_cores 270 ( 15 x 18 ), nb_points 6762 ( 98 x 69 )
+    nb_cores 272 ( 16 x 17 ), nb_points 6716 ( 92 x 73 )
+    nb_cores 276 ( 23 x 12 ), nb_points 6695 ( 65 x 103 )
+    nb_cores 279 ( 9 x 31 ), nb_points 6642 ( 162 x 41 )
+    nb_cores 280 ( 20 x 14 ), nb_points 6586 ( 74 x 89 )
+    nb_cores 285 ( 15 x 19 ), nb_points 6468 ( 98 x 66 )
+    nb_cores 286 ( 13 x 22 ), nb_points 6441 ( 113 x 57 )
+    nb_cores 288 ( 16 x 18 ), nb_points 6348 ( 92 x 69 )
+    nb_cores 294 ( 14 x 21 ), nb_points 6300 ( 105 x 60 )
+    nb_cores 296 ( 37 x 8 ), nb_points 6273 ( 41 x 153 )
+    nb_cores 297 ( 11 x 27 ), nb_points 6251 ( 133 x 47 )
+    nb_cores 299 ( 23 x 13 ), nb_points 6175 ( 65 x 95 )
+    nb_cores 300 ( 20 x 15 ), nb_points 6142 ( 74 x 83 )
+    nb_cores 304 ( 16 x 19 ), nb_points 6072 ( 92 x 66 )
+    nb_cores 306 ( 18 x 17 ), nb_points 5986 ( 82 x 73 )
+    nb_cores 308 ( 14 x 22 ), nb_points 5985 ( 105 x 57 )
+    nb_cores 312 ( 24 x 13 ), nb_points 5890 ( 62 x 95 )
+    nb_cores 315 ( 15 x 21 ), nb_points 5880 ( 98 x 60 )
+    nb_cores 319 ( 29 x 11 ), nb_points 5824 ( 52 x 112 )
+    nb_cores 320 ( 20 x 16 ), nb_points 5772 ( 74 x 78 )
+    nb_cores 323 ( 19 x 17 ), nb_points 5694 ( 78 x 73 )
+    nb_cores 324 ( 18 x 18 ), nb_points 5658 ( 82 x 69 )
+    nb_cores 330 ( 15 x 22 ), nb_points 5586 ( 98 x 57 )
+    nb_cores 333 ( 37 x 9 ), nb_points 5576 ( 41 x 136 )
+    nb_cores 336 ( 24 x 14 ), nb_points 5518 ( 62 x 89 )
+    nb_cores 338 ( 26 x 13 ), nb_points 5510 ( 58 x 95 )
+    nb_cores 340 ( 20 x 17 ), nb_points 5402 ( 74 x 73 )
+    nb_cores 342 ( 19 x 18 ), nb_points 5382 ( 78 x 69 )
+    nb_cores 348 ( 29 x 12 ), nb_points 5356 ( 52 x 103 )
+    nb_cores 350 ( 25 x 14 ), nb_points 5340 ( 60 x 89 )
+    nb_cores 351 ( 39 x 9 ), nb_points 5304 ( 39 x 136 )
+    nb_cores 352 ( 16 x 22 ), nb_points 5244 ( 92 x 57 )
+    nb_cores 357 ( 21 x 17 ), nb_points 5183 ( 71 x 73 )
+    nb_cores 360 ( 20 x 18 ), nb_points 5106 ( 74 x 69 )
+    nb_cores 368 ( 16 x 23 ), nb_points 5060 ( 92 x 55 )
+    nb_cores 370 ( 37 x 10 ), nb_points 5043 ( 41 x 123 )
+    nb_cores 372 ( 12 x 31 ), nb_points 5002 ( 122 x 41 )
+    nb_cores 374 ( 17 x 22 ), nb_points 4959 ( 87 x 57 )
+    nb_cores 377 ( 29 x 13 ), nb_points 4940 ( 52 x 95 )
+    nb_cores 378 ( 21 x 18 ), nb_points 4899 ( 71 x 69 )
+    nb_cores 380 ( 20 x 19 ), nb_points 4884 ( 74 x 66 )
+    nb_cores 384 ( 24 x 16 ), nb_points 4836 ( 62 x 78 )
+    nb_cores 390 ( 30 x 13 ), nb_points 4750 ( 50 x 95 )
+    nb_cores 391 ( 23 x 17 ), nb_points 4745 ( 65 x 73 )
+    nb_cores 396 ( 18 x 22 ), nb_points 4674 ( 82 x 57 )
+    nb_cores 400 ( 20 x 20 ), nb_points 4662 ( 74 x 63 )
+    nb_cores 403 ( 13 x 31 ), nb_points 4633 ( 113 x 41 )
+    nb_cores 405 ( 15 x 27 ), nb_points 4606 ( 98 x 47 )
+    nb_cores 407 ( 37 x 11 ), nb_points 4592 ( 41 x 112 )
+    nb_cores 408 ( 24 x 17 ), nb_points 4526 ( 62 x 73 )
+    nb_cores 414 ( 23 x 18 ), nb_points 4485 ( 65 x 69 )
+    nb_cores 416 ( 32 x 13 ), nb_points 4465 ( 47 x 95 )
+    nb_cores 418 ( 19 x 22 ), nb_points 4446 ( 78 x 57 )
+    nb_cores 420 ( 20 x 21 ), nb_points 4440 ( 74 x 60 )
+    nb_cores 425 ( 25 x 17 ), nb_points 4380 ( 60 x 73 )
+    nb_cores 429 ( 39 x 11 ), nb_points 4368 ( 39 x 112 )
+    nb_cores 432 ( 24 x 18 ), nb_points 4278 ( 62 x 69 )
+    nb_cores 440 ( 20 x 22 ), nb_points 4218 ( 74 x 57 )
+    nb_cores 448 ( 32 x 14 ), nb_points 4183 ( 47 x 89 )
+    nb_cores 450 ( 25 x 18 ), nb_points 4140 ( 60 x 69 )
+    nb_cores 456 ( 24 x 19 ), nb_points 4092 ( 62 x 66 )
+    nb_cores 459 ( 27 x 17 ), nb_points 4088 ( 56 x 73 )
+    nb_cores 460 ( 20 x 23 ), nb_points 4070 ( 74 x 55 )
+    nb_cores 462 ( 21 x 22 ), nb_points 4047 ( 71 x 57 )
+    nb_cores 465 ( 15 x 31 ), nb_points 4018 ( 98 x 41 )
+    nb_cores 468 ( 36 x 13 ), nb_points 3990 ( 42 x 95 )
+    nb_cores 475 ( 25 x 19 ), nb_points 3960 ( 60 x 66 )
+    nb_cores 476 ( 28 x 17 ), nb_points 3942 ( 54 x 73 )
+    nb_cores 480 ( 30 x 16 ), nb_points 3900 ( 50 x 78 )
+    nb_cores 481 ( 37 x 13 ), nb_points 3895 ( 41 x 95 )
+    nb_cores 484 ( 22 x 22 ), nb_points 3876 ( 68 x 57 )
+    nb_cores 486 ( 18 x 27 ), nb_points 3854 ( 82 x 47 )
+    nb_cores 493 ( 29 x 17 ), nb_points 3796 ( 52 x 73 )
+    nb_cores 496 ( 16 x 31 ), nb_points 3772 ( 92 x 41 )
+    nb_cores 504 ( 24 x 21 ), nb_points 3720 ( 62 x 60 )
+    nb_cores 506 ( 23 x 22 ), nb_points 3705 ( 65 x 57 )
+    nb_cores 510 ( 30 x 17 ), nb_points 3650 ( 50 x 73 )
+    nb_cores 518 ( 37 x 14 ), nb_points 3649 ( 41 x 89 )
+    nb_cores 520 ( 40 x 13 ), nb_points 3610 ( 38 x 95 )
+    nb_cores 522 ( 29 x 18 ), nb_points 3588 ( 52 x 69 )
+    nb_cores 527 ( 17 x 31 ), nb_points 3567 ( 87 x 41 )
+    nb_cores 528 ( 24 x 22 ), nb_points 3534 ( 62 x 57 )
+    nb_cores 540 ( 30 x 18 ), nb_points 3450 ( 50 x 69 )
+    nb_cores 544 ( 32 x 17 ), nb_points 3431 ( 47 x 73 )
+    nb_cores 550 ( 25 x 22 ), nb_points 3420 ( 60 x 57 )
+    nb_cores 552 ( 24 x 23 ), nb_points 3410 ( 62 x 55 )
+    nb_cores 555 ( 37 x 15 ), nb_points 3403 ( 41 x 83 )
+    nb_cores 558 ( 18 x 31 ), nb_points 3362 ( 82 x 41 )
+    nb_cores 561 ( 33 x 17 ), nb_points 3358 ( 46 x 73 )
+    nb_cores 567 ( 21 x 27 ), nb_points 3337 ( 71 x 47 )
+    nb_cores 570 ( 30 x 19 ), nb_points 3300 ( 50 x 66 )
+    nb_cores 576 ( 32 x 18 ), nb_points 3243 ( 47 x 69 )
+    nb_cores 585 ( 45 x 13 ), nb_points 3230 ( 34 x 95 )
+    nb_cores 589 ( 19 x 31 ), nb_points 3198 ( 78 x 41 )
+    nb_cores 594 ( 33 x 18 ), nb_points 3174 ( 46 x 69 )
+    nb_cores 600 ( 30 x 20 ), nb_points 3150 ( 50 x 63 )
+    nb_cores 608 ( 32 x 19 ), nb_points 3102 ( 47 x 66 )
+    nb_cores 612 ( 36 x 17 ), nb_points 3066 ( 42 x 73 )
+    nb_cores 620 ( 20 x 31 ), nb_points 3034 ( 74 x 41 )
+    nb_cores 629 ( 37 x 17 ), nb_points 2993 ( 41 x 73 )
+    nb_cores 638 ( 29 x 22 ), nb_points 2964 ( 52 x 57 )
+    nb_cores 640 ( 20 x 32 ), nb_points 2960 ( 74 x 40 )
+    nb_cores 646 ( 38 x 17 ), nb_points 2920 ( 40 x 73 )
+    nb_cores 648 ( 36 x 18 ), nb_points 2898 ( 42 x 69 )
+    nb_cores 660 ( 30 x 22 ), nb_points 2850 ( 50 x 57 )
+    nb_cores 663 ( 39 x 17 ), nb_points 2847 ( 39 x 73 )
+    nb_cores 666 ( 37 x 18 ), nb_points 2829 ( 41 x 69 )
+    nb_cores 672 ( 32 x 21 ), nb_points 2820 ( 47 x 60 )
+    nb_cores 680 ( 40 x 17 ), nb_points 2774 ( 38 x 73 )
+    nb_cores 684 ( 38 x 18 ), nb_points 2760 ( 40 x 69 )
+    nb_cores 690 ( 30 x 23 ), nb_points 2750 ( 50 x 55 )
+    nb_cores 696 ( 24 x 29 ), nb_points 2728 ( 62 x 44 )
+    nb_cores 702 ( 39 x 18 ), nb_points 2691 ( 39 x 69 )
+    nb_cores 704 ( 32 x 22 ), nb_points 2679 ( 47 x 57 )
+    nb_cores 713 ( 23 x 31 ), nb_points 2665 ( 65 x 41 )
+    nb_cores 720 ( 40 x 18 ), nb_points 2622 ( 38 x 69 )
+    nb_cores 736 ( 32 x 23 ), nb_points 2585 ( 47 x 55 )
+    nb_cores 740 ( 37 x 20 ), nb_points 2583 ( 41 x 63 )
+    nb_cores 741 ( 19 x 39 ), nb_points 2574 ( 78 x 33 )
+    nb_cores 741 ( 39 x 19 ), nb_points 2574 ( 39 x 66 )
+    nb_cores 744 ( 24 x 31 ), nb_points 2542 ( 62 x 41 )
+    nb_cores 756 ( 36 x 21 ), nb_points 2520 ( 42 x 60 )
+    nb_cores 760 ( 40 x 19 ), nb_points 2508 ( 38 x 66 )
+    nb_cores 765 ( 45 x 17 ), nb_points 2482 ( 34 x 73 )
+    nb_cores 768 ( 24 x 32 ), nb_points 2480 ( 62 x 40 )
+    nb_cores 775 ( 25 x 31 ), nb_points 2460 ( 60 x 41 )
+    nb_cores 780 ( 20 x 39 ), nb_points 2442 ( 74 x 33 )
+    nb_cores 792 ( 36 x 22 ), nb_points 2394 ( 42 x 57 )
+    nb_cores 806 ( 26 x 31 ), nb_points 2378 ( 58 x 41 )
+    nb_cores 810 ( 45 x 18 ), nb_points 2346 ( 34 x 69 )
+    nb_cores 814 ( 37 x 22 ), nb_points 2337 ( 41 x 57 )
+    nb_cores 816 ( 48 x 17 ), nb_points 2336 ( 32 x 73 )
+    nb_cores 828 ( 36 x 23 ), nb_points 2310 ( 42 x 55 )
+    nb_cores 832 ( 32 x 26 ), nb_points 2303 ( 47 x 49 )
+    nb_cores 836 ( 38 x 22 ), nb_points 2280 ( 40 x 57 )
+    nb_cores 846 ( 47 x 18 ), nb_points 2277 ( 33 x 69 )
+    nb_cores 850 ( 50 x 17 ), nb_points 2263 ( 31 x 73 )
+    nb_cores 851 ( 37 x 23 ), nb_points 2255 ( 41 x 55 )
+    nb_cores 855 ( 45 x 19 ), nb_points 2244 ( 34 x 66 )
+    nb_cores 858 ( 39 x 22 ), nb_points 2223 ( 39 x 57 )
+    nb_cores 864 ( 48 x 18 ), nb_points 2208 ( 32 x 69 )
+    nb_cores 870 ( 30 x 29 ), nb_points 2200 ( 50 x 44 )
+    nb_cores 880 ( 40 x 22 ), nb_points 2166 ( 38 x 57 )
+    nb_cores 891 ( 33 x 27 ), nb_points 2162 ( 46 x 47 )
+    nb_cores 896 ( 28 x 32 ), nb_points 2160 ( 54 x 40 )
+    nb_cores 897 ( 23 x 39 ), nb_points 2145 ( 65 x 33 )
+    nb_cores 897 ( 39 x 23 ), nb_points 2145 ( 39 x 55 )
+    nb_cores 899 ( 29 x 31 ), nb_points 2132 ( 52 x 41 )
+    nb_cores 912 ( 24 x 38 ), nb_points 2108 ( 62 x 34 )
+    nb_cores 920 ( 40 x 23 ), nb_points 2090 ( 38 x 55 )
+    nb_cores 928 ( 32 x 29 ), nb_points 2068 ( 47 x 44 )
+    nb_cores 930 ( 30 x 31 ), nb_points 2050 ( 50 x 41 )
+    nb_cores 936 ( 24 x 39 ), nb_points 2046 ( 62 x 33 )
+    nb_cores 945 ( 45 x 21 ), nb_points 2040 ( 34 x 60 )
+    nb_cores 957 ( 33 x 29 ), nb_points 2024 ( 46 x 44 )
+    nb_cores 960 ( 30 x 32 ), nb_points 2000 ( 50 x 40 )
+    nb_cores 968 ( 44 x 22 ), nb_points 1995 ( 35 x 57 )
+    nb_cores 972 ( 36 x 27 ), nb_points 1974 ( 42 x 47 )
+    nb_cores 986 ( 58 x 17 ), nb_points 1971 ( 27 x 73 )
+    nb_cores 988 ( 38 x 26 ), nb_points 1960 ( 40 x 49 )
+    nb_cores 990 ( 45 x 22 ), nb_points 1938 ( 34 x 57 )
+    nb_cores 992 ( 32 x 31 ), nb_points 1927 ( 47 x 41 )
+    nb_cores 1008 ( 48 x 21 ), nb_points 1920 ( 32 x 60 )
+    nb_cores 1014 ( 39 x 26 ), nb_points 1911 ( 39 x 49 )
+    nb_cores 1020 ( 60 x 17 ), nb_points 1898 ( 26 x 73 )
+    nb_cores 1023 ( 33 x 31 ), nb_points 1886 ( 46 x 41 )
+    nb_cores 1024 ( 32 x 32 ), nb_points 1880 ( 47 x 40 )
+    nb_cores 1035 ( 45 x 23 ), nb_points 1870 ( 34 x 55 )
+    nb_cores 1040 ( 40 x 26 ), nb_points 1862 ( 38 x 49 )
+    nb_cores 1044 ( 36 x 29 ), nb_points 1848 ( 42 x 44 )
+    nb_cores 1053 ( 39 x 27 ), nb_points 1833 ( 39 x 47 )
+    nb_cores 1056 ( 48 x 22 ), nb_points 1824 ( 32 x 57 )
+    nb_cores 1073 ( 37 x 29 ), nb_points 1804 ( 41 x 44 )
+    nb_cores 1080 ( 40 x 27 ), nb_points 1786 ( 38 x 47 )
+    nb_cores 1092 ( 28 x 39 ), nb_points 1782 ( 54 x 33 )
+    nb_cores 1100 ( 50 x 22 ), nb_points 1767 ( 31 x 57 )
+    nb_cores 1102 ( 38 x 29 ), nb_points 1760 ( 40 x 44 )
+    nb_cores 1110 ( 30 x 37 ), nb_points 1750 ( 50 x 35 )
+    nb_cores 1116 ( 36 x 31 ), nb_points 1722 ( 42 x 41 )
+    nb_cores 1131 ( 39 x 29 ), nb_points 1716 ( 39 x 44 )
+    nb_cores 1131 ( 29 x 39 ), nb_points 1716 ( 52 x 33 )
+    nb_cores 1140 ( 30 x 38 ), nb_points 1700 ( 50 x 34 )
+    nb_cores 1147 ( 37 x 31 ), nb_points 1681 ( 41 x 41 )
+    nb_cores 1152 ( 36 x 32 ), nb_points 1680 ( 42 x 40 )
+    nb_cores 1160 ( 40 x 29 ), nb_points 1672 ( 38 x 44 )
+    nb_cores 1170 ( 30 x 39 ), nb_points 1650 ( 50 x 33 )
+    nb_cores 1178 ( 38 x 31 ), nb_points 1640 ( 40 x 41 )
+    nb_cores 1188 ( 36 x 33 ), nb_points 1638 ( 42 x 39 )
+    nb_cores 1200 ( 48 x 25 ), nb_points 1632 ( 32 x 51 )
+    nb_cores 1209 ( 39 x 31 ), nb_points 1599 ( 39 x 41 )
+    nb_cores 1215 ( 45 x 27 ), nb_points 1598 ( 34 x 47 )
+    nb_cores 1224 ( 36 x 34 ), nb_points 1596 ( 42 x 38 )
+    nb_cores 1240 ( 40 x 31 ), nb_points 1558 ( 38 x 41 )
+    nb_cores 1248 ( 32 x 39 ), nb_points 1551 ( 47 x 33 )
+    nb_cores 1260 ( 30 x 42 ), nb_points 1550 ( 50 x 31 )
+    nb_cores 1276 ( 58 x 22 ), nb_points 1539 ( 27 x 57 )
+    nb_cores 1280 ( 40 x 32 ), nb_points 1520 ( 38 x 40 )
+    nb_cores 1287 ( 33 x 39 ), nb_points 1518 ( 46 x 33 )
+    nb_cores 1295 ( 37 x 35 ), nb_points 1517 ( 41 x 37 )
+    nb_cores 1296 ( 48 x 27 ), nb_points 1504 ( 32 x 47 )
+    nb_cores 1305 ( 45 x 29 ), nb_points 1496 ( 34 x 44 )
+    nb_cores 1320 ( 40 x 33 ), nb_points 1482 ( 38 x 39 )
+    nb_cores 1320 ( 60 x 22 ), nb_points 1482 ( 26 x 57 )
+    nb_cores 1330 ( 38 x 35 ), nb_points 1480 ( 40 x 37 )
+    nb_cores 1332 ( 36 x 37 ), nb_points 1470 ( 42 x 35 )
+    nb_cores 1344 ( 32 x 42 ), nb_points 1457 ( 47 x 31 )
+    nb_cores 1350 ( 30 x 45 ), nb_points 1450 ( 50 x 29 )
+    nb_cores 1360 ( 40 x 34 ), nb_points 1444 ( 38 x 38 )
+    nb_cores 1364 ( 44 x 31 ), nb_points 1435 ( 35 x 41 )
+    nb_cores 1368 ( 36 x 38 ), nb_points 1428 ( 42 x 34 )
+    nb_cores 1386 ( 63 x 22 ), nb_points 1425 ( 25 x 57 )
+    nb_cores 1392 ( 48 x 29 ), nb_points 1408 ( 32 x 44 )
+    nb_cores 1395 ( 45 x 31 ), nb_points 1394 ( 34 x 41 )
+    nb_cores 1404 ( 36 x 39 ), nb_points 1386 ( 42 x 33 )
+    nb_cores 1440 ( 45 x 32 ), nb_points 1360 ( 34 x 40 )
+    nb_cores 1443 ( 37 x 39 ), nb_points 1353 ( 41 x 33 )
+    nb_cores 1470 ( 30 x 49 ), nb_points 1350 ( 50 x 27 )
+    nb_cores 1476 ( 36 x 41 ), nb_points 1344 ( 42 x 32 )
+    nb_cores 1480 ( 40 x 37 ), nb_points 1330 ( 38 x 35 )
+    nb_cores 1482 ( 38 x 39 ), nb_points 1320 ( 40 x 33 )
+    nb_cores 1488 ( 48 x 31 ), nb_points 1312 ( 32 x 41 )
+    nb_cores 1512 ( 36 x 42 ), nb_points 1302 ( 42 x 31 )
+    nb_cores 1520 ( 40 x 38 ), nb_points 1292 ( 38 x 34 )
+    nb_cores 1521 ( 39 x 39 ), nb_points 1287 ( 39 x 33 )
+    nb_cores 1536 ( 48 x 32 ), nb_points 1280 ( 32 x 40 )
+    nb_cores 1550 ( 50 x 31 ), nb_points 1271 ( 31 x 41 )
+    nb_cores 1560 ( 40 x 39 ), nb_points 1254 ( 38 x 33 )
+    nb_cores 1584 ( 48 x 33 ), nb_points 1248 ( 32 x 39 )
+    nb_cores 1596 ( 38 x 42 ), nb_points 1240 ( 40 x 31 )
+    nb_cores 1612 ( 52 x 31 ), nb_points 1230 ( 30 x 41 )
+    nb_cores 1620 ( 36 x 45 ), nb_points 1218 ( 42 x 29 )
+    nb_cores 1632 ( 48 x 34 ), nb_points 1216 ( 32 x 38 )
+    nb_cores 1638 ( 39 x 42 ), nb_points 1209 ( 39 x 31 )
+    nb_cores 1650 ( 30 x 55 ), nb_points 1200 ( 50 x 24 )
+    nb_cores 1665 ( 37 x 45 ), nb_points 1189 ( 41 x 29 )
+    nb_cores 1677 ( 43 x 39 ), nb_points 1188 ( 36 x 33 )
+    nb_cores 1680 ( 40 x 42 ), nb_points 1178 ( 38 x 31 )
+    nb_cores 1692 ( 36 x 47 ), nb_points 1176 ( 42 x 28 )
+    nb_cores 1696 ( 32 x 53 ), nb_points 1175 ( 47 x 25 )
+    nb_cores 1710 ( 45 x 38 ), nb_points 1156 ( 34 x 34 )
+    nb_cores 1716 ( 44 x 39 ), nb_points 1155 ( 35 x 33 )
+    nb_cores 1728 ( 48 x 36 ), nb_points 1152 ( 32 x 36 )
+    nb_cores 1736 ( 56 x 31 ), nb_points 1148 ( 28 x 41 )
+    nb_cores 1740 ( 60 x 29 ), nb_points 1144 ( 26 x 44 )
+    nb_cores 1755 ( 45 x 39 ), nb_points 1122 ( 34 x 33 )
+    nb_cores 1776 ( 48 x 37 ), nb_points 1120 ( 32 x 35 )
+    nb_cores 1798 ( 58 x 31 ), nb_points 1107 ( 27 x 41 )
+    nb_cores 1800 ( 40 x 45 ), nb_points 1102 ( 38 x 29 )
+    nb_cores 1824 ( 48 x 38 ), nb_points 1088 ( 32 x 34 )
+    nb_cores 1848 ( 44 x 42 ), nb_points 1085 ( 35 x 31 )
+    nb_cores 1856 ( 58 x 32 ), nb_points 1080 ( 27 x 40 )
+    nb_cores 1860 ( 60 x 31 ), nb_points 1066 ( 26 x 41 )
+    nb_cores 1872 ( 48 x 39 ), nb_points 1056 ( 32 x 33 )
+    nb_cores 1890 ( 45 x 42 ), nb_points 1054 ( 34 x 31 )
+    nb_cores 1908 ( 36 x 53 ), nb_points 1050 ( 42 x 25 )
+    nb_cores 1920 ( 60 x 32 ), nb_points 1040 ( 26 x 40 )
+    nb_cores 1944 ( 72 x 27 ), nb_points 1034 ( 22 x 47 )
+    nb_cores 1950 ( 50 x 39 ), nb_points 1023 ( 31 x 33 )
+    nb_cores 1976 ( 52 x 38 ), nb_points 1020 ( 30 x 34 )
+    nb_cores 1980 ( 36 x 55 ), nb_points 1008 ( 42 x 24 )
+    nb_cores 2010 ( 30 x 67 ), nb_points 1000 ( 50 x 20 )
+    nb_cores 2016 ( 48 x 42 ), nb_points 992 ( 32 x 31 )
+    nb_cores 2025 ( 45 x 45 ), nb_points 986 ( 34 x 29 )
+    nb_cores 2035 ( 37 x 55 ), nb_points 984 ( 41 x 24 )
+    nb_cores 2067 ( 39 x 53 ), nb_points 975 ( 39 x 25 )
+    nb_cores 2088 ( 36 x 58 ), nb_points 966 ( 42 x 23 )
+    nb_cores 2090 ( 38 x 55 ), nb_points 960 ( 40 x 24 )
+    nb_cores 2106 ( 54 x 39 ), nb_points 957 ( 29 x 33 )
+    nb_cores 2115 ( 45 x 47 ), nb_points 952 ( 34 x 28 )
+    nb_cores 2120 ( 40 x 53 ), nb_points 950 ( 38 x 25 )
+    nb_cores 2139 ( 69 x 31 ), nb_points 943 ( 23 x 41 )
+    nb_cores 2144 ( 32 x 67 ), nb_points 940 ( 47 x 20 )
+    nb_cores 2145 ( 39 x 55 ), nb_points 936 ( 39 x 24 )
+    nb_cores 2160 ( 48 x 45 ), nb_points 928 ( 32 x 29 )
+    nb_cores 2184 ( 56 x 39 ), nb_points 924 ( 28 x 33 )
+    nb_cores 2200 ( 40 x 55 ), nb_points 912 ( 38 x 24 )
+    nb_cores 2220 ( 60 x 37 ), nb_points 910 ( 26 x 35 )
+    nb_cores 2232 ( 72 x 31 ), nb_points 902 ( 22 x 41 )
+    nb_cores 2250 ( 50 x 45 ), nb_points 899 ( 31 x 29 )
+    nb_cores 2256 ( 48 x 47 ), nb_points 896 ( 32 x 28 )
+    nb_cores 2262 ( 58 x 39 ), nb_points 891 ( 27 x 33 )
+    nb_cores 2280 ( 60 x 38 ), nb_points 884 ( 26 x 34 )
+    nb_cores 2304 ( 72 x 32 ), nb_points 880 ( 22 x 40 )
+    nb_cores 2320 ( 40 x 58 ), nb_points 874 ( 38 x 23 )
+    nb_cores 2340 ( 60 x 39 ), nb_points 858 ( 26 x 33 )
+    nb_cores 2385 ( 45 x 53 ), nb_points 850 ( 34 x 25 )
+    nb_cores 2412 ( 36 x 67 ), nb_points 840 ( 42 x 20 )
+    nb_cores 2436 ( 58 x 42 ), nb_points 837 ( 27 x 31 )
+    nb_cores 2440 ( 40 x 61 ), nb_points 836 ( 38 x 22 )
+    nb_cores 2448 ( 48 x 51 ), nb_points 832 ( 32 x 26 )
+    nb_cores 2457 ( 63 x 39 ), nb_points 825 ( 25 x 33 )
+    nb_cores 2475 ( 45 x 55 ), nb_points 816 ( 34 x 24 )
+    nb_cores 2520 ( 60 x 42 ), nb_points 806 ( 26 x 31 )
+    nb_cores 2544 ( 48 x 53 ), nb_points 800 ( 32 x 25 )
+    nb_cores 2556 ( 36 x 71 ), nb_points 798 ( 42 x 19 )
+    nb_cores 2574 ( 66 x 39 ), nb_points 792 ( 24 x 33 )
+    nb_cores 2610 ( 45 x 58 ), nb_points 782 ( 34 x 23 )
+    nb_cores 2613 ( 39 x 67 ), nb_points 780 ( 39 x 20 )
+    nb_cores 2627 ( 37 x 71 ), nb_points 779 ( 41 x 19 )
+    nb_cores 2640 ( 48 x 55 ), nb_points 768 ( 32 x 24 )
+    nb_cores 2680 ( 40 x 67 ), nb_points 760 ( 38 x 20 )
+    nb_cores 2691 ( 69 x 39 ), nb_points 759 ( 23 x 33 )
+    nb_cores 2700 ( 60 x 45 ), nb_points 754 ( 26 x 29 )
+    nb_cores 2736 ( 72 x 38 ), nb_points 748 ( 22 x 34 )
+    nb_cores 2750 ( 50 x 55 ), nb_points 744 ( 31 x 24 )
+    nb_cores 2769 ( 39 x 71 ), nb_points 741 ( 39 x 19 )
+    nb_cores 2784 ( 48 x 58 ), nb_points 736 ( 32 x 23 )
+    nb_cores 2808 ( 72 x 39 ), nb_points 726 ( 22 x 33 )
+    nb_cores 2835 ( 63 x 45 ), nb_points 725 ( 25 x 29 )
+    nb_cores 2840 ( 40 x 71 ), nb_points 722 ( 38 x 19 )
+    nb_cores 2860 ( 52 x 55 ), nb_points 720 ( 30 x 24 )
+    nb_cores 2880 ( 45 x 64 ), nb_points 714 ( 34 x 21 )
+    nb_cores 2898 ( 69 x 42 ), nb_points 713 ( 23 x 31 )
+    nb_cores 2928 ( 48 x 61 ), nb_points 704 ( 32 x 22 )
+    nb_cores 2940 ( 60 x 49 ), nb_points 702 ( 26 x 27 )
+    nb_cores 2948 ( 44 x 67 ), nb_points 700 ( 35 x 20 )
+    nb_cores 2964 ( 76 x 39 ), nb_points 693 ( 21 x 33 )
+    nb_cores 3015 ( 45 x 67 ), nb_points 680 ( 34 x 20 )
+    nb_cores 3060 ( 60 x 51 ), nb_points 676 ( 26 x 26 )
+    nb_cores 3072 ( 48 x 64 ), nb_points 672 ( 32 x 21 )
+    nb_cores 3105 ( 69 x 45 ), nb_points 667 ( 23 x 29 )
+    nb_cores 3120 ( 80 x 39 ), nb_points 660 ( 20 x 33 )
+    nb_cores 3180 ( 60 x 53 ), nb_points 650 ( 26 x 25 )
+    nb_cores 3190 ( 58 x 55 ), nb_points 648 ( 27 x 24 )
+    nb_cores 3195 ( 45 x 71 ), nb_points 646 ( 34 x 19 )
+    nb_cores 3216 ( 48 x 67 ), nb_points 640 ( 32 x 20 )
+    nb_cores 3240 ( 72 x 45 ), nb_points 638 ( 22 x 29 )
+    nb_cores 3300 ( 60 x 55 ), nb_points 624 ( 26 x 24 )
+    nb_cores 3350 ( 50 x 67 ), nb_points 620 ( 31 x 20 )
+    nb_cores 3384 ( 72 x 47 ), nb_points 616 ( 22 x 28 )
+    nb_cores 3408 ( 48 x 71 ), nb_points 608 ( 32 x 19 )
+    nb_cores 3465 ( 63 x 55 ), nb_points 600 ( 25 x 24 )
+    nb_cores 3480 ( 60 x 58 ), nb_points 598 ( 26 x 23 )
+    nb_cores 3510 ( 90 x 39 ), nb_points 594 ( 18 x 33 )
+    nb_cores 3550 ( 50 x 71 ), nb_points 589 ( 31 x 19 )
+    nb_cores 3572 ( 76 x 47 ), nb_points 588 ( 21 x 28 )
+    nb_cores 3600 ( 80 x 45 ), nb_points 580 ( 20 x 29 )
+    nb_cores 3630 ( 66 x 55 ), nb_points 576 ( 24 x 24 )
+    nb_cores 3654 ( 63 x 58 ), nb_points 575 ( 25 x 23 )
+    nb_cores 3660 ( 60 x 61 ), nb_points 572 ( 26 x 22 )
+    nb_cores 3692 ( 52 x 71 ), nb_points 570 ( 30 x 19 )
+    nb_cores 3712 ( 58 x 64 ), nb_points 567 ( 27 x 21 )
+    nb_cores 3744 ( 96 x 39 ), nb_points 561 ( 17 x 33 )
+    nb_cores 3752 ( 56 x 67 ), nb_points 560 ( 28 x 20 )
+    nb_cores 3780 ( 90 x 42 ), nb_points 558 ( 18 x 31 )
+    nb_cores 3795 ( 69 x 55 ), nb_points 552 ( 23 x 24 )
+    nb_cores 3816 ( 72 x 53 ), nb_points 550 ( 22 x 25 )
+    nb_cores 3840 ( 60 x 64 ), nb_points 546 ( 26 x 21 )
+    nb_cores 3886 ( 58 x 67 ), nb_points 540 ( 27 x 20 )
+    nb_cores 3960 ( 72 x 55 ), nb_points 528 ( 22 x 24 )
+    nb_cores 4020 ( 60 x 67 ), nb_points 520 ( 26 x 20 )
+    nb_cores 4118 ( 58 x 71 ), nb_points 513 ( 27 x 19 )
+    nb_cores 4176 ( 72 x 58 ), nb_points 506 ( 22 x 23 )
+    nb_cores 4180 ( 76 x 55 ), nb_points 504 ( 21 x 24 )
+    nb_cores 4221 ( 63 x 67 ), nb_points 500 ( 25 x 20 )
+    nb_cores 4260 ( 60 x 71 ), nb_points 494 ( 26 x 19 )
+    nb_cores 4320 ( 96 x 45 ), nb_points 493 ( 17 x 29 )
+    nb_cores 4392 ( 72 x 61 ), nb_points 484 ( 22 x 22 )
+    nb_cores 4400 ( 80 x 55 ), nb_points 480 ( 20 x 24 )
+    nb_cores 4473 ( 63 x 71 ), nb_points 475 ( 25 x 19 )
+    nb_cores 4560 ( 60 x 76 ), nb_points 468 ( 26 x 18 )
+    nb_cores 4608 ( 72 x 64 ), nb_points 462 ( 22 x 21 )
+    nb_cores 4623 ( 69 x 67 ), nb_points 460 ( 23 x 20 )
+    nb_cores 4675 ( 85 x 55 ), nb_points 456 ( 19 x 24 )
+    nb_cores 4770 ( 90 x 53 ), nb_points 450 ( 18 x 25 )
+    nb_cores 4824 ( 72 x 67 ), nb_points 440 ( 22 x 20 )
+    nb_cores 4899 ( 69 x 71 ), nb_points 437 ( 23 x 19 )
+    nb_cores 4950 ( 90 x 55 ), nb_points 432 ( 18 x 24 )
+    nb_cores 5088 ( 96 x 53 ), nb_points 425 ( 17 x 25 )
+    nb_cores 5092 ( 76 x 67 ), nb_points 420 ( 21 x 20 )
+    nb_cores 5112 ( 72 x 71 ), nb_points 418 ( 22 x 19 )
+    nb_cores 5220 ( 90 x 58 ), nb_points 414 ( 18 x 23 )
+    nb_cores 5280 ( 96 x 55 ), nb_points 408 ( 17 x 24 )
+    nb_cores 5360 ( 80 x 67 ), nb_points 400 ( 20 x 20 )
+    nb_cores 5396 ( 76 x 71 ), nb_points 399 ( 21 x 19 )
+    nb_cores 5472 ( 72 x 76 ), nb_points 396 ( 22 x 18 )
+    nb_cores 5568 ( 96 x 58 ), nb_points 391 ( 17 x 23 )
+    nb_cores 5580 ( 60 x 93 ), nb_points 390 ( 26 x 15 )
+    nb_cores 5665 ( 103 x 55 ), nb_points 384 ( 16 x 24 )
+    nb_cores 5680 ( 80 x 71 ), nb_points 380 ( 20 x 19 )
+    nb_cores 5760 ( 90 x 64 ), nb_points 378 ( 18 x 21 )
+    nb_cores 5832 ( 72 x 81 ), nb_points 374 ( 22 x 17 )
+    nb_cores 5974 ( 103 x 58 ), nb_points 368 ( 16 x 23 )
+    nb_cores 6030 ( 90 x 67 ), nb_points 360 ( 18 x 20 )
+    nb_cores 6144 ( 96 x 64 ), nb_points 357 ( 17 x 21 )
+    nb_cores 6264 ( 72 x 87 ), nb_points 352 ( 22 x 16 )
+    nb_cores 6360 ( 120 x 53 ), nb_points 350 ( 14 x 25 )
+    nb_cores 6390 ( 90 x 71 ), nb_points 342 ( 18 x 19 )
+    nb_cores 6432 ( 96 x 67 ), nb_points 340 ( 17 x 20 )
+    nb_cores 6592 ( 103 x 64 ), nb_points 336 ( 16 x 21 )
+    nb_cores 6696 ( 72 x 93 ), nb_points 330 ( 22 x 15 )
+    nb_cores 6816 ( 96 x 71 ), nb_points 323 ( 17 x 19 )
+    nb_cores 6901 ( 103 x 67 ), nb_points 320 ( 16 x 20 )
+    nb_cores 7068 ( 76 x 93 ), nb_points 315 ( 21 x 15 )
+    nb_cores 7205 ( 131 x 55 ), nb_points 312 ( 13 x 24 )
+    nb_cores 7272 ( 72 x 101 ), nb_points 308 ( 22 x 14 )
+    nb_cores 7290 ( 90 x 81 ), nb_points 306 ( 18 x 17 )
+    nb_cores 7313 ( 103 x 71 ), nb_points 304 ( 16 x 19 )
+    nb_cores 7437 ( 111 x 67 ), nb_points 300 ( 15 x 20 )
+    nb_cores 7590 ( 69 x 110 ), nb_points 299 ( 23 x 13 )
+    nb_cores 7676 ( 76 x 101 ), nb_points 294 ( 21 x 14 )
+    nb_cores 7776 ( 96 x 81 ), nb_points 289 ( 17 x 17 )
+    nb_cores 7828 ( 103 x 76 ), nb_points 288 ( 16 x 18 )
+    nb_cores 7881 ( 111 x 71 ), nb_points 285 ( 15 x 19 )
+    nb_cores 8040 ( 120 x 67 ), nb_points 280 ( 14 x 20 )
+    nb_cores 8343 ( 103 x 81 ), nb_points 272 ( 16 x 17 )
+    nb_cores 8370 ( 90 x 93 ), nb_points 270 ( 18 x 15 )
+    nb_cores 8520 ( 120 x 71 ), nb_points 266 ( 14 x 19 )
+    nb_cores 8712 ( 72 x 121 ), nb_points 264 ( 22 x 12 )
+    nb_cores 8777 ( 131 x 67 ), nb_points 260 ( 13 x 20 )
+    nb_cores 8928 ( 96 x 93 ), nb_points 255 ( 17 x 15 )
+    nb_cores 9090 ( 90 x 101 ), nb_points 252 ( 18 x 14 )
+    nb_cores 9301 ( 131 x 71 ), nb_points 247 ( 13 x 19 )
+    nb_cores 9579 ( 103 x 93 ), nb_points 240 ( 16 x 15 )
+    nb_cores 9696 ( 96 x 101 ), nb_points 238 ( 17 x 14 )
+    nb_cores 9900 ( 90 x 110 ), nb_points 234 ( 18 x 13 )
+    nb_cores 10184 ( 76 x 134 ), nb_points 231 ( 21 x 11 )
+    nb_cores 10224 ( 144 x 71 ), nb_points 228 ( 12 x 19 )
+    nb_cores 10323 ( 111 x 93 ), nb_points 225 ( 15 x 15 )
+    nb_cores 10403 ( 103 x 101 ), nb_points 224 ( 16 x 14 )
+    nb_cores 10560 ( 96 x 110 ), nb_points 221 ( 17 x 13 )
+    nb_cores 10720 ( 80 x 134 ), nb_points 220 ( 20 x 11 )
+    nb_cores 10720 ( 160 x 67 ), nb_points 220 ( 11 x 20 )
+    nb_cores 10890 ( 90 x 121 ), nb_points 216 ( 18 x 12 )
+    nb_cores 11160 ( 120 x 93 ), nb_points 210 ( 14 x 15 )
+    nb_cores 11330 ( 103 x 110 ), nb_points 208 ( 16 x 13 )
+    nb_cores 11616 ( 96 x 121 ), nb_points 204 ( 17 x 12 )
+    nb_cores 12060 ( 90 x 134 ), nb_points 198 ( 18 x 11 )
+    nb_cores 12120 ( 120 x 101 ), nb_points 196 ( 14 x 14 )
+    nb_cores 12183 ( 131 x 93 ), nb_points 195 ( 13 x 15 )
+    nb_cores 12463 ( 103 x 121 ), nb_points 192 ( 16 x 12 )
+    nb_cores 12780 ( 180 x 71 ), nb_points 190 ( 10 x 19 )
+    nb_cores 12864 ( 96 x 134 ), nb_points 187 ( 17 x 11 )
+    nb_cores 13200 ( 120 x 110 ), nb_points 182 ( 14 x 13 )
+    nb_cores 13392 ( 144 x 93 ), nb_points 180 ( 12 x 15 )
+    nb_cores 13802 ( 103 x 134 ), nb_points 176 ( 16 x 11 )
+    nb_cores 14410 ( 131 x 110 ), nb_points 169 ( 13 x 13 )
+    nb_cores 14520 ( 120 x 121 ), nb_points 168 ( 14 x 12 )
+    nb_cores 14874 ( 111 x 134 ), nb_points 165 ( 15 x 11 )
+    nb_cores 15553 ( 103 x 151 ), nb_points 160 ( 16 x 10 )
+    nb_cores 15840 ( 144 x 110 ), nb_points 156 ( 12 x 13 )
+    nb_cores 16080 ( 120 x 134 ), nb_points 154 ( 14 x 11 )
+    nb_cores 16608 ( 96 x 173 ), nb_points 153 ( 17 x 9 )
+    nb_cores 16740 ( 180 x 93 ), nb_points 150 ( 10 x 15 )
+    nb_cores 17424 ( 144 x 121 ), nb_points 144 ( 12 x 12 )
+    nb_cores 17554 ( 131 x 134 ), nb_points 143 ( 13 x 11 )
+    nb_cores 18120 ( 120 x 151 ), nb_points 140 ( 14 x 10 )
+    nb_cores 19158 ( 206 x 93 ), nb_points 135 ( 9 x 15 )
+    nb_cores 19296 ( 144 x 134 ), nb_points 132 ( 12 x 11 )
+    nb_cores 19781 ( 131 x 151 ), nb_points 130 ( 13 x 10 )
+    nb_cores 20703 ( 103 x 201 ), nb_points 128 ( 16 x 8 )
+    nb_cores 20760 ( 120 x 173 ), nb_points 126 ( 14 x 9 )
+    nb_cores 21440 ( 160 x 134 ), nb_points 121 ( 11 x 11 )
+    nb_cores 21744 ( 144 x 151 ), nb_points 120 ( 12 x 10 )
+    nb_cores 22660 ( 206 x 110 ), nb_points 117 ( 9 x 13 )
+    nb_cores 24120 ( 180 x 134 ), nb_points 110 ( 10 x 11 )
+    nb_cores 24912 ( 144 x 173 ), nb_points 108 ( 12 x 9 )
+    nb_cores 26331 ( 131 x 201 ), nb_points 104 ( 13 x 8 )
+    nb_cores 27180 ( 180 x 151 ), nb_points 100 ( 10 x 10 )
+    nb_cores 27604 ( 206 x 134 ), nb_points 99 ( 9 x 11 )
+    nb_cores 28920 ( 120 x 241 ), nb_points 98 ( 14 x 7 )
+    nb_cores 28944 ( 144 x 201 ), nb_points 96 ( 12 x 8 )
+    nb_cores 31106 ( 206 x 151 ), nb_points 90 ( 9 x 10 )
+    nb_cores 32160 ( 240 x 134 ), nb_points 88 ( 8 x 11 )
+    nb_cores 32160 ( 160 x 201 ), nb_points 88 ( 11 x 8 )
+    nb_cores 34704 ( 144 x 241 ), nb_points 84 ( 12 x 7 )
+    nb_cores 35638 ( 206 x 173 ), nb_points 81 ( 9 x 9 )
+    nb_cores 36180 ( 180 x 201 ), nb_points 80 ( 10 x 8 )
+    nb_cores 38560 ( 160 x 241 ), nb_points 77 ( 11 x 7 )
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg	(revision 10136)
@@ -0,0 +1,1 @@
+link namelist_cfg_orca025_like
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg_orca025_like
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg_orca025_like	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_cfg_orca025_like	(revision 10136)
@@ -0,0 +1,216 @@
+! vim: ft=fortran :
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  BENCH Configuration namelist : overwrite some defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   'BENCH' !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =    1000   !  last time step 
+   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+/
+!-----------------------------------------------------------------------
+&namusr_def    !   User defined :   BENCH configuration: Flat bottom, beta-plane
+!-----------------------------------------------------------------------
+   nn_isize   =   1442     ! number of point in i-direction of global(local) domain if >0 (<0)  
+   nn_jsize   =   1207  !!  1050    ! number of point in j-direction of global(local) domain if >0 (<0)  
+   nn_ksize   =   75       ! total number of point in k-direction
+   nn_perio   =   4        ! periodicity
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+!-----------------------------------------------------------------------
+   ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
+   jpni        =   3       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =   3       !  jpnj   number of processors following j (set automatically if < 1)
+!   nn_comm_mod  =   1      !  step routine call frequency
+!   ln_comm_only = .false.  !  replace step routine by realistic communications only
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   ln_timing   = .true.   !  timing by routine write out in timing.output file
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   rn_rdt      =    900.   !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =   0.05    !  asselin time filter parameter
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+  ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+/
+
+!
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid   (read by child model only)       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  free slip
+/
+
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_OFF =F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_OFF =F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_non_lin  = .true.   !  non-linear  drag: Cd = Cd0 |U|
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbc   = .true.   !  Apply a geothermal heating at the ocean bottom
+      nn_geoflx     = 1       !  geothermal heat flux: = 1 constant flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbl   = .true.   !  Bottom Boundary Layer parameterisation flag
+/
+
+!!======================================================================
+!!                        Tracer (T & S) namelists                    !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_teos10   = .true.         !  = Use TEOS-10
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_fct = .true.  !  FCT scheme
+      nn_fct_h   =  4            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_blp   = .true.   !    laplacian operator
+   ln_traldf_iso   = .true.   !  iso-neutral (standard operator)
+   !
+   ln_traldf_msc   = .true.   !  Method of Stabilizing Correction      (both operators)
+   nn_aht_ijk_t    = 20       !  space/time variation of eddy coefficient:
+/
+!-----------------------------------------------------------------------
+&namtra_mle    !   mixed layer eddy parametrisation (Fox-Kemper)       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_mle      = .false.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+/
+!-----------------------------------------------------------------------
+&namtra_eiv    !   eddy induced velocity param.                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ldfeiv   = .false.   ! use eddy induced velocity parameterization
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nam_vvl       !   vertical coordinate options                          (default: z-star)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  z-star vertical coordinate
+   ln_vvl_dbg    = .false.          !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true. !  vector form (T) or flux form (F)
+      nn_dynkeg     = 1       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_een = .true. !  energy & enstrophy scheme
+      nn_een_e3f = 0          ! =0  e3f = mi(mj(e3t))/4 
+      !                       ! =1  e3f = mi(mj(e3t))/mi(mj( tmask))
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts   = .true.   ! split-explicit free surface
+      ln_bt_auto    = .false.    ! Number of sub-step defined from:
+         nn_baro      =  30         ! =F : the number of sub-step in rn_rdt seconds
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynldf_blp =  .true.    !    laplacian operator
+   ln_dynldf_hor =  .true.    !  horizontal (geopotential)
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 30           !  space/time variation of eddy coef
+/
+
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics                                     (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdftke   = .true.       !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
+   ln_zdfevd   = .true.       !  enhanced vertical diffusion
+   ln_zdfddm   = .true.       ! double diffusive mixing
+   ln_zdfiwm   = .true.       ! internal wave-induced mixing            (T =>   fill namzdf_iwm)
+/
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_ref
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_ref	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/namelist_ref	(revision 10136)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/sh_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/sh_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/sh_bench	(revision 10136)
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -u
+#set -xv
+
+resolution=${1:?"you must provide the resolution: 1 025 or 12"}
+mincore=${2:-1} # minimum number of core to be tested
+maxcore=${3:-0} # maximum number of core to be tested
+
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+case $machine in 
+    "beaufixlogin") ncore_node=40 ;;
+    "curie")        ncore_node=16 ;;
+    "irene")        ncore_node=48 ;;
+    *) echo "you must add your machine \"$machine\" with its number of cores per node" ; exit 1 ;;
+esac
+
+[ $mincore -eq 1 ] && targetnb=$ncore_node || targetnb=$mincore
+#
+# build the list of experiences:
+# must be a multiple of ncore_node and as close as possible of the targeted number of core
+#
+n1=0
+list=""
+
+# Prepare gnuplot data file
+dateref=$( date "+%Y%m%d-%Hh%Mm%Ss" )
+echo "# nb_proc    jpi    jpj" > gnuplot_tbc_${resolution}_${dateref}.dat
+nbl=$( cat best_jpni_jpnj_eorca${resolution} | wc -l )
+for ll in $( seq 1 $nbl )
+do
+    line=$( sed -n ${ll}p best_jpni_jpnj_eorca${resolution} )    # for each line
+    nn=$( echo $line | sed -e "s/.*nb_cores \([0-9]*\).*/\1/" )  # get the number of core
+    [ $maxcore -gt 1 -a $nn -gt $maxcore ] && break              # if below $maxcore (if specified)
+        if [ $(( $nn % $ncore_node )) -eq 0 ]                    # if it is a multiple of $ncore_node
+        then
+            if [ $nn -lt $targetnb ]
+            then
+                n1=$nn       # store the number of core
+                line1=$line  # store the line
+            else
+                [ $(( $targetnb - $n1 )) -le $(( $nn -$targetnb )) ] && line=$line1   # keep the previous line
+                echo $line
+                nb=$( echo $line | sed -e "s/[^(]*( \([0-9]*\) x \([0-9]*\) .*/\1*\2/" ) # get jpni*jpnj
+                list="${list} ${nb}"
+                targetnb=$(( $targetnb * 2 ))
+                subsize=$( echo $line | awk {'printf "%d   %d", $11, $13'})
+                corenb=$( echo $line | awk {'printf "%d", $2'})
+                echo "$corenb  $subsize" >> gnuplot_tbc_${resolution}.dat
+            fi
+        fi
+done
+echo $list
+
+for cores in $list
+do
+    ./submit_bench $cores $ncore_node ${resolution} ${dateref}
+done
+
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/submit_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/submit_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/EXPREF/submit_bench	(revision 10136)
@@ -0,0 +1,197 @@
+#!/bin/bash
+#  
+#  BENCH launching scripts for beaufix, Meteo-France
+#                          and curie, TGCC
+#  To be modified for other machines
+#
+set -u
+set -vx
+#
+cores=$1
+ncore_node=$2
+resolution=$3
+dateref=$4
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+#
+# number of processes for each executable
+    nproc_exe1=$( echo $cores | bc )
+  (( nproc = $nproc_exe1 ))
+(( nnode = $nproc / $ncore_node ))
+[ $nnode -lt 1 ] && nnode=1
+
+nproc5=$( printf "%05d\n" ${nproc_exe1} )
+
+######################################################################
+### beaufixlogin
+######################################################################
+
+if [ "$machine" == "beaufixlogin" ]
+then
+    
+cat > Log/run_bench << EOF
+#!/bin/bash
+#SBATCH --time=00:1:00
+#SBATCH -p  normal64         # partition/queue
+#SBATCH --job-name=bench      # job name
+#SBATCH -N $nnode            # number of nodes
+#SBATCH -n $nproc            # number of procs
+#SBATCH -o /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH -e /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH --exclusive
+
+module unload intelmpi intel grib_api
+module load intel/16.1.150 intelmpi/5.1.2.150
+
+itac=0
+xpmpi=0
+
+if [ \$xpmpi == 1 ]; then
+  module load bullxde
+  module load xPMPI/1.1_intelmpi
+fi
+
+[ \$itac == 1 ] && module load itac/2017.2.028
+
+set -vx
+
+cd \${TMPDIR}
+cp /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/* .
+
+# Best decompositions BENCH-1
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+export OMP_NUM_THREADS=1
+ulimit -s unlimited
+#
+if [ \$itac == 1 ]; then
+  source /opt/softs/intel/2017/update_1/itac_latest/bin/itacvars.sh
+  time mpirun -ordered-output -prepend-rank -trace -np $nproc_exe1 ./nemo > jobout 2>joberr
+else
+  time mpirun -ordered-output -prepend-rank -np $nproc_exe1 ./nemo > jobout_${resolution}_${nproc5}
+fi
+/opt/softs/bin/ja
+
+if [ \$xpmpi == 1 ]; then
+  module unload xPMPI/1.1_intelmpi
+  module unload bullxde
+fi
+#
+EOF
+
+
+### 4. Execute the model
+
+    echo 'Submitting the job to queue using sbatch'
+    sbatch Log/run_bench
+    squeue -u cglo315
+
+echo 'is executed or submitted to queue.'
+
+
+fi
+
+######################################################################
+### curie or irene
+######################################################################
+
+if [[ ( "$machine" == "curie" ) || ( "$machine" == "irene" ) ]]
+then
+    
+    case ${resolution} in
+	"1")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=1800
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=900
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"025")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=7000
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=2000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=1000
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"12")
+	    if [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=30000
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=8000
+	    elif [ $nproc_exe1 -lt 1600 ]
+	    then
+		timejob=5000
+	    elif [ $nproc_exe1 -lt 3200 ]
+	    then
+		timejob=2500
+	    else
+		timejob=1200
+	    fi
+	;;
+    esac
+
+    [ "$machine" == "curie" ] && queuename=standard || queuename=skylake
+    
+    jobname=$HOME/binrun/jobbench
+    cat > $jobname << EOF
+#!/bin/bash
+#MSUB -r bench${nproc5}
+#MSUB -n ${nproc_exe1}
+#MSUB -T $timejob
+#MSUB -e bench_${resolution}_${nproc5}_%I.eo
+#MSUB -o bench_${resolution}_${nproc5}_%I.eo
+#MSUB -j oe
+#MSUB -x
+#MSUB -q ${queuename}
+#MSUB -A gen6895
+#==========================================
+set -u
+#
+
+cd \${BRIDGE_MSUB_PWD}/..
+
+
+EXPjob=EXP_${resolution}_${nproc5}_${dateref}
+rsync -av --exclude="*eo" EXPREF/ \${EXPjob}/
+rsync -av EXP00/nemo \${EXPjob}/nemo
+cd \${EXPjob}
+
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+time ccc_mprun -n \${BRIDGE_MSUB_NPROC} ./nemo > jobout_${resolution}_${nproc5}_${dateref}
+
+EOF
+
+    ccc_msub $jobname
+
+fi
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/diawri.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/diawri.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/diawri.F90	(revision 10136)
@@ -0,0 +1,586 @@
+MODULE diawri
+   !!======================================================================
+   !!                     ***  MODULE  diawri  ***
+   !! Ocean diagnostics :  write ocean output files
+   !!=====================================================================
+   !! History :  OPA  ! 1991-03  (M.-A. Foujols)  Original code
+   !!            4.0  ! 1991-11  (G. Madec)
+   !!                 ! 1992-06  (M. Imbard)  correction restart file
+   !!                 ! 1992-07  (M. Imbard)  split into diawri and rstwri
+   !!                 ! 1993-03  (M. Imbard)  suppress writibm
+   !!                 ! 1998-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
+   !!                 ! 1999-02  (E. Guilyardi)  name of netCDF files + variables
+   !!            8.2  ! 2000-06  (M. Imbard)  Original code (diabort.F)
+   !!   NEMO     1.0  ! 2002-06  (A.Bozec, E. Durand)  Original code (diainit.F)
+   !!             -   ! 2002-09  (G. Madec)  F90: Free form and module
+   !!             -   ! 2002-12  (G. Madec)  merge of diabort and diainit, F90
+   !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
+   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
+   !!                 !                     change name of output variables in dia_wri_state
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_wri       : create the standart output files
+   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers 
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE dianam         ! build name of file (routine)
+   USE diahth         ! thermocline diagnostics
+   USE dynadv   , ONLY: ln_dynadv_vec
+   USE icb_oce        ! Icebergs
+   USE icbdia         ! Iceberg budgets
+   USE ldftra         ! lateral physics: eddy diffusivity coef.
+   USE ldfdyn         ! lateral physics: eddy viscosity   coef.
+   USE sbc_oce        ! Surface boundary condition: ocean fields
+   USE sbc_ice        ! Surface boundary condition: ice fields
+   USE sbcssr         ! restoring term toward SST/SSS climatology
+   USE sbcwave        ! wave parameters
+   USE wet_dry        ! wetting and drying
+   USE zdf_oce        ! ocean vertical physics
+   USE zdfdrg         ! ocean vertical physics: top/bottom friction
+   USE zdfmxl         ! mixed layer
+   !
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager ! I/O manager
+   USE diatmb         ! Top,middle,bottom output
+   USE dia25h         ! 25h Mean output
+   USE iom            ! 
+   USE ioipsl         ! 
+
+#if defined key_si3
+   USE icewri 
+#endif
+   USE lib_mpp         ! MPP library
+   USE timing          ! preformance summary
+   USE diurnal_bulk    ! diurnal warm layer
+   USE cool_skin       ! Cool skin
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_wri                 ! routines called by step.F90
+   PUBLIC   dia_wri_state
+   PUBLIC   dia_wri_alloc           ! Called by nemogcm module
+
+   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT   ! grid_T file
+   INTEGER ::          nb_T              , ndim_bT   ! grid_T file
+   INTEGER ::   nid_U, nz_U, nh_U, ndim_U, ndim_hU   ! grid_U file
+   INTEGER ::   nid_V, nz_V, nh_V, ndim_V, ndim_hV   ! grid_V file
+   INTEGER ::   nid_W, nz_W, nh_W                    ! grid_W file
+   INTEGER ::   ndex(1)                              ! ???
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_bT
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: diawri.F90 9598 2018-05-15 22:47:16Z nicolasmartin $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if defined key_iomput
+   !!----------------------------------------------------------------------
+   !!   'key_iomput'                                        use IOM library
+   !!----------------------------------------------------------------------
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   
+   SUBROUTINE dia_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :  use iom_put
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk       ! dummy loop indices
+      INTEGER ::   ikbot            ! local integer
+      REAL(wp)::   zztmp , zztmpx   ! local scalar
+      REAL(wp)::   zztmp2, zztmpy   !   -      -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
+      !!----------------------------------------------------------------------
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      ! 
+      ! Output the initial state and forcings
+      IF( ninist == 1 ) THEN                       
+         CALL dia_wri_state( 'output.init', kt )
+         ninist = 0
+      ENDIF
+
+      ! Output of initial vertical scale factor
+      CALL iom_put("e3t_0", e3t_0(:,:,:) )
+      CALL iom_put("e3u_0", e3t_0(:,:,:) )
+      CALL iom_put("e3v_0", e3t_0(:,:,:) )
+      !
+      CALL iom_put( "e3t" , e3t_n(:,:,:) )
+      CALL iom_put( "e3u" , e3u_n(:,:,:) )
+      CALL iom_put( "e3v" , e3v_n(:,:,:) )
+      CALL iom_put( "e3w" , e3w_n(:,:,:) )
+      IF( iom_use("e3tdef") )   &
+         CALL iom_put( "e3tdef"  , ( ( e3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
+
+      IF( ll_wd ) THEN
+         CALL iom_put( "ssh" , (sshn+ssh_ref)*tmask(:,:,1) )   ! sea surface height (brought back to the reference used for wetting and drying)
+      ELSE
+         CALL iom_put( "ssh" , sshn )              ! sea surface height
+      ENDIF
+
+      IF( iom_use("wetdep") )   &                  ! wet depth
+         CALL iom_put( "wetdep" , ht_0(:,:) + sshn(:,:) )
+      
+      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
+      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
+      IF ( iom_use("sbt") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_tem)
+            END DO
+         END DO
+         CALL iom_put( "sbt", z2d )                ! bottom temperature
+      ENDIF
+      
+      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
+      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
+      IF ( iom_use("sbs") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_sal)
+            END DO
+         END DO
+         CALL iom_put( "sbs", z2d )                ! bottom salinity
+      ENDIF
+
+      IF ( iom_use("taubot") ) THEN                ! bottom stress
+         zztmp = rau0 * 0.25
+         z2d(:,:) = 0._wp
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp2 = (  ( rCdU_bot(ji+1,jj)+rCdU_bot(ji  ,jj) ) * un(ji  ,jj,mbku(ji  ,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji  ,jj)+rCdU_bot(ji-1,jj) ) * un(ji-1,jj,mbku(ji-1,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj  ) ) * vn(ji,jj  ,mbkv(ji,jj  ))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj  )+rCdU_bot(ji,jj-1) ) * vn(ji,jj-1,mbkv(ji,jj-1))  )**2
+               z2d(ji,jj) = zztmp * SQRT( zztmp2 ) * tmask(ji,jj,1) 
+               !
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "taubot", z2d )           
+      ENDIF
+         
+      CALL iom_put( "uoce", un(:,:,:) )            ! 3D i-current
+      CALL iom_put(  "ssu", un(:,:,1) )            ! surface i-current
+      IF ( iom_use("sbu") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbku(ji,jj)
+               z2d(ji,jj) = un(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbu", z2d )                ! bottom i-current
+      ENDIF
+      
+      CALL iom_put( "voce", vn(:,:,:) )            ! 3D j-current
+      CALL iom_put(  "ssv", vn(:,:,1) )            ! surface j-current
+      IF ( iom_use("sbv") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkv(ji,jj)
+               z2d(ji,jj) = vn(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbv", z2d )                ! bottom j-current
+      ENDIF
+
+      CALL iom_put( "woce", wn )                   ! vertical velocity
+      IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
+         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
+         z2d(:,:) = rau0 * e1e2t(:,:)
+         DO jk = 1, jpk
+            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
+         END DO
+         CALL iom_put( "w_masstr" , z3d )  
+         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
+      ENDIF
+
+      CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
+      CALL iom_put( "avs" , avs )                  ! S vert. eddy diff. coef.
+      CALL iom_put( "avm" , avm )                  ! T vert. eddy visc. coef.
+
+      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt(:,:,:) ) ) )
+      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
+
+      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
+         DO jj = 2, jpjm1                                    ! sst gradient
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp  = tsn(ji,jj,1,jp_tem)
+               zztmpx = ( tsn(ji+1,jj,1,jp_tem) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) * r1_e1u(ji-1,jj)
+               zztmpy = ( tsn(ji,jj+1,1,jp_tem) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) * r1_e2v(ji,jj-1)
+               z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
+                  &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
+         z2d(:,:) = SQRT( z2d(:,:) )
+         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
+      ENDIF
+         
+      ! heat and salt contents
+      IF( iom_use("heatc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "heatc", rau0_rcp * z2d )   ! vertically integrated heat content (J/m2)
+      ENDIF
+
+      IF( iom_use("saltc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "saltc", rau0 * z2d )          ! vertically integrated salt content (PSU*kg/m2)
+      ENDIF
+      !
+      IF ( iom_use("eken") ) THEN
+         z3d(:,:,jpk) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zztmp  = 0.25_wp * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
+                  z3d(ji,jj,jk) = zztmp * (  un(ji-1,jj,jk)**2 * e2u(ji-1,jj) * e3u_n(ji-1,jj,jk)   &
+                     &                     + un(ji  ,jj,jk)**2 * e2u(ji  ,jj) * e3u_n(ji  ,jj,jk)   &
+                     &                     + vn(ji,jj-1,jk)**2 * e1v(ji,jj-1) * e3v_n(ji,jj-1,jk)   &
+                     &                     + vn(ji,jj  ,jk)**2 * e1v(ji,jj  ) * e3v_n(ji,jj  ,jk)   )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z3d, 'T', 1. )
+         CALL iom_put( "eken", z3d )                 ! kinetic energy
+      ENDIF
+      !
+      CALL iom_put( "hdiv", hdivn )                  ! Horizontal divergence
+      !
+      IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         z2d(:,:) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * un(:,:,jk) * e2u(:,:) * e3u_n(:,:,jk) * umask(:,:,jk)
+            z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
+         END DO
+         CALL iom_put( "u_masstr"     , z3d )         ! mass transport in i-direction
+         CALL iom_put( "u_masstr_vint", z2d )         ! mass transport in i-direction vertical sum
+      ENDIF
+      
+      IF( iom_use("u_heattr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
+      ENDIF
+
+      IF( iom_use("u_salttr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
+      ENDIF
+
+      
+      IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e1v(:,:) * e3v_n(:,:,jk) * vmask(:,:,jk)
+         END DO
+         CALL iom_put( "v_masstr", z3d )              ! mass transport in j-direction
+      ENDIF
+      
+      IF( iom_use("v_heattr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("v_salttr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("tosmint") ) THEN
+         z2d(:,:) = 0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) *  tsn(ji,jj,jk,jp_tem)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
+      ENDIF
+      IF( iom_use("somint") ) THEN
+         z2d(:,:)=0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
+      ENDIF
+
+      CALL iom_put( "bn2", rn2 )                      ! Brunt-Vaisala buoyancy frequency (N^2)
+      !
+
+      IF (ln_diatmb)   CALL dia_tmb                   ! tmb values 
+          
+      IF (ln_dia25h)   CALL dia_25h( kt )             ! 25h averaging
+
+      IF( ln_timing )   CALL timing_stop('dia_wri')
+      !
+   END SUBROUTINE dia_wri
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                  use IOIPSL  library
+   !!----------------------------------------------------------------------
+
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   SUBROUTINE dia_wri( kt )
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+   END SUBROUTINE dia_wri
+
+#endif
+
+   SUBROUTINE dia_wri_state( cdfile_name, kt )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_wri_state  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ocean state and forcing fields.
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! ** Method  :   NetCDF files using ioipsl
+      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
+      !!      File 'output.abort.nc' is created in case of abnormal job end
+      !!----------------------------------------------------------------------
+      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
+      INTEGER           , INTENT( in ) ::   kt               ! ocean time-step index
+      !! 
+      CHARACTER (len=32) :: clname
+      CHARACTER (len=40) :: clop
+      INTEGER  ::   id_i , nz_i, nh_i       
+      INTEGER, DIMENSION(1) ::   idex             ! local workspace
+      REAL(wp) ::   zsto, zout, zmax, zjulian
+      !!----------------------------------------------------------------------
+      ! 
+      ! 0. Initialisation
+      ! -----------------
+
+      ! Define name, frequency of output and means
+      clname = cdfile_name
+      IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      zsto = rdt
+      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
+      zout = rdt
+      zmax = ( nitend - nit000 + 1 ) * rdt
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
+      IF(lwp) WRITE(numout,*) '                and named :', clname, '.nc'
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      ! Compute julian date from starting date of the run
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )         ! time axis 
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      CALL histbeg( clname, jpi, glamt, jpj, gphit,   &
+          1, jpi, 1, jpj, nit000-1, zjulian, rdt, nh_i, id_i, domain_id=nidom, snc4chunks=snc4set ) ! Horizontal grid : glamt and gphit
+      CALL histvert( id_i, "deptht", "Vertical T levels",   &    ! Vertical grid : gdept
+          "m", jpk, gdept_1d, nz_i, "down")
+
+      ! Declare all the output fields as NetCDF variables
+
+      CALL histdef( id_i, "vosaline", "Salinity"              , "PSU"    ,   &   ! salinity
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
+         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vomecrty", "Meridional Current"    , "m/s"    ,   &   ! meridonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      CALL histdef( id_i, "vovecrtz", "Vertical Velocity"     , "m/s"    ,   &   ! vertical current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+         !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histdef( id_i, "ahtu"    , "u-eddy diffusivity"    , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahtv"    , "v-eddy diffusivity"    , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN 
+         CALL histdef( id_i, "ahmt"    , "t-eddy viscosity"      , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahmf"    , "f-eddy viscosity"      , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+         !
+      CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S",   &   ! net freshwater 
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2"   ,   &   ! net heat flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soshfldo", "Shortwave Radiation"   , "W/m2"   ,   &   ! solar flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soicecov", "Ice fraction"          , "[0,1]"  ,   &   ! fr_i
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sozotaux", "Zonal Wind Stress"     , "N/m2"   ,   &   ! i-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      IF( .NOT.ln_linssh ) THEN
+         CALL histdef( id_i, "vovvldep", "T point depth"         , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "vovvle3t", "T point thickness"     , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+      !
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histdef( id_i, "sdzocrtx", "Stokes Drift Zonal"    , "m/s"    , &   ! StokesDrift zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdmecrty", "Stokes Drift Merid"    , "m/s"    , &   ! StokesDrift meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdvecrtz", "Stokes Drift Vert"     , "m/s"    , &   ! StokesDrift vertical current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+
+#if defined key_si3
+      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
+         CALL ice_wri_state( kt, id_i, nh_i )
+      ENDIF
+#else
+      CALL histend( id_i, snc4chunks=snc4set )
+#endif
+
+      ! 2. Start writing data
+      ! ---------------------
+      ! idex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et idex la liste des indices a sortir
+      idex(1) = 1   ! init to avoid compil warning
+
+      ! Write all fields on T grid
+      CALL histwrite( id_i, "votemper", kt, tsn(:,:,:,jp_tem), jpi*jpj*jpk, idex )    ! now temperature
+      CALL histwrite( id_i, "vosaline", kt, tsn(:,:,:,jp_sal), jpi*jpj*jpk, idex )    ! now salinity
+      CALL histwrite( id_i, "sossheig", kt, sshn             , jpi*jpj    , idex )    ! sea surface height
+      CALL histwrite( id_i, "vozocrtx", kt, un               , jpi*jpj*jpk, idex )    ! now i-velocity
+      CALL histwrite( id_i, "vomecrty", kt, vn               , jpi*jpj*jpk, idex )    ! now j-velocity
+      CALL histwrite( id_i, "vovecrtz", kt, wn               , jpi*jpj*jpk, idex )    ! now k-velocity
+      !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histwrite( id_i, "ahtu"    , kt, ahtu             , jpi*jpj*jpk, idex )    ! aht at u-point
+         CALL histwrite( id_i, "ahtv"    , kt, ahtv             , jpi*jpj*jpk, idex )    !  -  at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL histwrite( id_i, "ahmt"    , kt, ahmt             , jpi*jpj*jpk, idex )    ! ahm at t-point
+         CALL histwrite( id_i, "ahmf"    , kt, ahmf             , jpi*jpj*jpk, idex )    !  -  at f-point
+      ENDIF
+      !
+      CALL histwrite( id_i, "sowaflup", kt, emp - rnf        , jpi*jpj    , idex )    ! freshwater budget
+      CALL histwrite( id_i, "sohefldo", kt, qsr + qns        , jpi*jpj    , idex )    ! total heat flux
+      CALL histwrite( id_i, "soshfldo", kt, qsr              , jpi*jpj    , idex )    ! solar heat flux
+      CALL histwrite( id_i, "soicecov", kt, fr_i             , jpi*jpj    , idex )    ! ice fraction
+      CALL histwrite( id_i, "sozotaux", kt, utau             , jpi*jpj    , idex )    ! i-wind stress
+      CALL histwrite( id_i, "sometauy", kt, vtau             , jpi*jpj    , idex )    ! j-wind stress
+
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL histwrite( id_i, "vovvldep", kt, gdept_n(:,:,:), jpi*jpj*jpk, idex )!  T-cell depth 
+         CALL histwrite( id_i, "vovvle3t", kt, e3t_n (:,:,:) , jpi*jpj*jpk, idex )!  T-cell thickness  
+      END IF 
+ 
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histwrite( id_i, "sdzocrtx", kt, usd           , jpi*jpj*jpk, idex)     ! now StokesDrift i-velocity
+         CALL histwrite( id_i, "sdmecrty", kt, vsd           , jpi*jpj*jpk, idex)     ! now StokesDrift j-velocity
+         CALL histwrite( id_i, "sdvecrtz", kt, wsd           , jpi*jpj*jpk, idex)     ! now StokesDrift k-velocity
+      ENDIF
+
+      ! 3. Close the file
+      ! -----------------
+      CALL histclo( id_i )
+#if ! defined key_iomput
+      IF( ninist /= 1  ) THEN
+         CALL histclo( nid_T )
+         CALL histclo( nid_U )
+         CALL histclo( nid_V )
+         CALL histclo( nid_W )
+      ENDIF
+#endif
+      ! 
+   END SUBROUTINE dia_wri_state
+
+   !!======================================================================
+END MODULE diawri
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/restart.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/restart.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/restart.F90	(revision 10136)
@@ -0,0 +1,316 @@
+MODULE restart
+   !!======================================================================
+   !!                     ***  MODULE  restart  ***
+   !! Ocean restart :  write the ocean restart file
+   !!======================================================================
+   !! History :  OPA  !  1999-11  (M. Imbard)  Original code
+   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form
+   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart
+   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
+   !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
+   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   rst_opn    : open the ocean restart file
+   !!   rst_write  : write the ocean restart file
+   !!   rst_read   : read the ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_ice         ! only lk_si3 
+   USE phycst          ! physical constants
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE diurnal_bulk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   rst_opn         ! routine called by step module
+   PUBLIC   rst_write       ! routine called by step module
+   PUBLIC   rst_read        ! routine called by istate module
+   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: restart.F90 9654 2018-05-28 09:08:53Z clem $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE rst_opn( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rst_opn  ***
+      !!                     
+      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
+      !!              + open the restart when we are one time step before nitrst
+      !!                   - restart header is defined when kt = nitrst-1
+      !!                   - restart data  are written when kt = nitrst
+      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(lc)       ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
+      CHARACTER(LEN=256)  ::   clinfo    ! info character
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN   ! default definitions
+         lrst_oce = .FALSE.   
+         IF( ln_rst_list ) THEN
+            nrst_lst = 1
+            nitrst = nstocklist( nrst_lst )
+         ELSE
+            nitrst = nitend
+         ENDIF
+      ENDIF
+
+      ! frequency-based restart dumping (nn_stock)
+      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN   
+         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
+         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
+      ENDIF
+      ! to get better performances with NetCDF format:
+      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
+      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
+      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
+         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
+            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+            ENDIF
+            ! create the file
+            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
+            clpath = TRIM(cn_ocerst_outdir)
+            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+            IF(lwp) THEN
+               WRITE(numout,*)
+               IF(.NOT.lwxios) THEN
+                  SELECT CASE ( jprstlib )
+                  CASE DEFAULT         ;   WRITE(numout,*)                            &
+                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
+                  END SELECT
+                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
+                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
+                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+                  ENDIF
+               ENDIF
+            ENDIF
+            !
+            IF(.NOT.lwxios) THEN
+               !EM no call to restart opening
+               !EM CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+            ELSE
+#if defined key_iomput
+               cwxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
+               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+                  clpname = clname
+               ELSE
+                  clpname = TRIM(Agrif_CFixed())//"_"//clname   
+               ENDIF
+               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname))
+               CALL xios_update_calendar(nitrst)
+               CALL iom_swap(      cxios_context          )
+#else
+               clinfo = 'Can not use XIOS in rst_opn'
+               CALL ctl_stop(TRIM(clinfo))
+#endif
+            ENDIF
+               !EM restart writing
+            !EM lrst_oce = .TRUE.
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_opn
+
+
+   SUBROUTINE rst_write( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rstwrite  ***
+      !!                     
+      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !!
+      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
+      !!              file, save fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step
+      !!----------------------------------------------------------------------
+                     IF(lwxios) CALL iom_swap(      cwxios_context          )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
+
+      IF ( .NOT. ln_diurnal_only ) THEN
+                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub, ldxios = lwxios        )     ! before fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb, ldxios = lwxios      )
+                     !
+                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un, ldxios = lwxios        )     ! now fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn, ldxios = lwxios      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop, ldxios = lwxios      )
+                  ! extra variable needed for the ice sheet coupling
+                  IF ( ln_iscpl ) THEN 
+                     CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask, ldxios = lwxios ) ! need to extrapolate T/S
+                     CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask, ldxios = lwxios) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:), ldxios = lwxios )   ! need to compute temperature correction
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:), ldxios = lwxios ) ! need to compute extrapolation if vvl
+                  END IF
+      ENDIF
+      
+      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )  
+      IF(lwxios) CALL iom_swap(      cxios_context          )
+      IF( kt == nitrst ) THEN
+         IF(.NOT.lwxios) THEN
+            CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         ELSE
+            CALL iom_context_finalize(      cwxios_context          )
+         ENDIF
+!!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
+!!gm  not sure what to do here   ===>>>  ask to Sebastian
+         lrst_oce = .FALSE.
+            IF( ln_rst_list ) THEN
+               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1))
+               nitrst = nstocklist( nrst_lst )
+            ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_write
+
+
+   SUBROUTINE rst_read_open
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read_open  ***
+      !! 
+      !! ** Purpose :   Open read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
+      !!                the file has already been opened
+      !!----------------------------------------------------------------------
+      INTEGER        ::   jlibalt = jprstlib
+      LOGICAL        ::   llok
+      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
+      !!----------------------------------------------------------------------
+      !
+      IF( numror <= 0 ) THEN
+         IF(lwp) THEN                                             ! Contol prints
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+            END SELECT
+            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
+            WRITE(numout,*) '~~~~~~~~'
+         ENDIF
+         lxios_sini = .FALSE.
+         clpath = TRIM(cn_ocerst_indir)
+         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
+! are we using XIOS to read the data? Part above will have to modified once XIOS
+! can handle checking if variable is in the restart file (there will be no need to open
+! restart)
+         IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
+         IF( lrxios) THEN
+             crxios_context = 'nemo_rst'
+             IF( .NOT.lxios_set ) THEN
+                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
+                 CALL iom_init( crxios_context )
+                 lxios_set = .TRUE.
+             ENDIF
+         ENDIF
+         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
+             CALL iom_init( crxios_context )
+             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
+             lxios_set = .TRUE.
+         ENDIF 
+      ENDIF
+
+   END SUBROUTINE rst_read_open
+
+
+   SUBROUTINE rst_read
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read  ***
+      !! 
+      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zrdt
+      INTEGER  ::   jk
+      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
+      !!----------------------------------------------------------------------
+
+      CALL rst_read_open           ! open restart for reading (if not already opened)
+
+      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
+      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
+         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
+         IF( zrdt /= rdt )   neuler = 0
+      ENDIF
+
+      ! Diurnal DSST 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
+      IF ( ln_diurnal_only ) THEN 
+         IF(lwp) WRITE( numout, * ) &
+         &   "rst_read:- ln_diurnal_only set, setting rhop=rau0" 
+         rhop = rau0
+         CALL iom_get( numror, jpdom_autoglo, 'tn'     , w3d, ldxios = lrxios ) 
+         tsn(:,:,1,jp_tem) = w3d(:,:,1)
+         RETURN 
+      ENDIF  
+      
+      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub, ldxios = lrxios                )   ! before fields
+         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb, ldxios = lrxios                )
+         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb, ldxios = lrxios              )
+      ELSE
+         neuler = 0
+      ENDIF
+      !
+      CALL iom_get( numror, jpdom_autoglo, 'un'     , un, ldxios = lrxios )   ! now    fields
+      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vn, ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, ldxios = lrxios )
+      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
+      ELSE
+         CALL eos( tsn, rhd, rhop, gdept_n(:,:,:) )   
+      ENDIF
+      !
+      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
+         tsb  (:,:,:,:) = tsn  (:,:,:,:)                             ! all before fields set to now values
+         ub   (:,:,:)   = un   (:,:,:)
+         vb   (:,:,:)   = vn   (:,:,:)
+         sshb (:,:)     = sshn (:,:)
+         !
+         IF( .NOT.ln_linssh ) THEN
+            DO jk = 1, jpk
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE rst_read
+
+   !!=====================================================================
+END MODULE restart
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_hgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_hgr.F90	(revision 10136)
@@ -0,0 +1,118 @@
+MODULE usrdef_hgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_hgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   mesh and Coriolis parameter of a user configuration
+   !!======================================================================
+   !! History :  NEMO  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_hgr    : initialize the horizontal mesh for BENCH configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE par_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_hgr   ! called by domhgr.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0, NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
+      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
+      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
+      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
+      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE usr_def_hgr  ***
+      !!
+      !! ** Purpose :   square box mesh mesh and Coriolis parameter
+      !!
+      !! ** Method  :   set all intent(out) argument to a proper value
+      !!                BENCH configuration : beta-plance with uniform grid spacing (zres)
+      !!
+      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in grid points) 
+      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
+      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
+      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
+      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
+      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise 
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zres, zf0
+      REAL(wp) ::   zti, zui, ztj, zvj   ! local scalars
+      !!-------------------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_hgr : BENCH configuration bassin'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
+      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
+      !
+      !                          
+      ! Position coordinates (in grid points)
+      !                          ==========         
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            
+            zti = REAL( ji - 1 + nimpp - 1, wp )          ;  ztj = REAL( jj - 1 + njmpp - 1, wp )
+            zui = REAL( ji - 1 + nimpp - 1, wp ) + 0.5_wp ;  zvj = REAL( jj - 1 + njmpp - 1, wp ) + 0.5_wp
+
+            plamt(ji,jj) = zti
+            plamu(ji,jj) = zui
+            plamv(ji,jj) = zti
+            plamf(ji,jj) = zui
+   
+            pphit(ji,jj) = ztj
+            pphiv(ji,jj) = zvj
+            pphiu(ji,jj) = ztj
+            pphif(ji,jj) = zvj
+            
+         END DO
+      END DO
+      !     
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      zres = 1.e+5   !  100km
+      pe1t(:,:) = zres  ;   pe2t(:,:) = zres 
+      pe1u(:,:) = zres  ;   pe2u(:,:) = zres
+      pe1v(:,:) = zres  ;   pe2v(:,:) = zres
+      pe1f(:,:) = zres  ;   pe2f(:,:) = zres 
+
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
+      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
+      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
+      !
+      !
+      !                       !==  Coriolis parameter  ==!
+      kff = 1                       !  indicate not to compute Coriolis parameter afterward
+      !
+      zf0   = 2._wp * omega * SIN( rad * 45 )   ! constant coriolis factor corresponding to 45°N
+      pff_f(:,:) = zf0
+      pff_t(:,:) = zf0
+      !
+   END SUBROUTINE usr_def_hgr
+
+   !!======================================================================
+END MODULE usrdef_hgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_istate.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_istate.F90	(revision 10136)
@@ -0,0 +1,72 @@
+MODULE usrdef_istate
+   !!======================================================================
+   !!                     ***  MODULE usrdef_istate   ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the initial state of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  usr_def_istate : initial state in Temperature and salinity
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE dom_oce        
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   !   
+   USE usrdef_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_istate   ! called by istate.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+  
+   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers
+      !!                Here BENCH configuration 
+      !!
+      !! ** Method  :   Set a gaussian anomaly of pressure and associated
+      !!                geostrophic velocities
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pdept   ! depth of t-point               [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  ! t-point ocean mask             [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   pts     ! T & S fields      [Celsius ; g/kg]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pu      ! i-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pv      ! j-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : BENCH configuration, analytical definition of initial state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
+      !
+      ! sea level:
+      pssh(:,:) = 0.
+      ! temperature:
+      pts(:,:,:,jp_tem) = 10._wp
+      ! salinity:  
+      pts(:,:,:,jp_sal) = 35._wp
+      ! velocities:
+      pu(:,:,:) = 0.
+      pv(:,:,:) = 0.
+      !
+
+   END SUBROUTINE usr_def_istate
+
+   !!======================================================================
+END MODULE usrdef_istate
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_nam.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_nam.F90	(revision 10136)
@@ -0,0 +1,119 @@
+MODULE usrdef_nam
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_nam  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the domain characteristics of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_nam   : read user defined namelist and set global domain size
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! to get ctl_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_nam   ! called by nemogcm.F90
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read user defined namelist and define the domain size
+      !!
+      !! ** Method  :   read in namusr_def containing all the user specific namelist parameter
+      !!
+      !!                Here EW_CANAL configuration
+      !!
+      !! ** input   : - namusr_def namelist found in namelist_cfg
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
+      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
+      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
+      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
+      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      !
+      !
+      INTEGER ::   ios, ii      ! Local integer
+      !                              !!* namusr_def namelist *!!
+      INTEGER ::   nn_isize    ! number of point in i-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_jsize    ! number of point in j-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_ksize    ! total number of point in k-direction
+      INTEGER ::   nn_perio    ! periodicity
+      !                              !!* nammpp namelist *!!
+      CHARACTER(len=1) ::   cn_mpi_send
+      INTEGER          ::   nn_buffer, jpni, jpnj, jpnij
+      LOGICAL          ::   ln_nnogather
+      !!
+      NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, nn_perio
+      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, jpnij, ln_nnogather
+      !!----------------------------------------------------------------------     
+      !
+      REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
+      READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+      WRITE( ldnam(:), namusr_def )      
+      !
+      cd_cfg = 'BENCH'             ! name & resolution (not used)
+      kk_cfg = 0
+
+      IF( nn_isize < 0 .AND. nn_jsize < 0 ) THEN
+      !
+         REWIND( numnam_ref )              ! Namelist nammpp in reference namelist: mpi variables
+         READ  ( numnam_ref, nammpp, IOSTAT = ios, ERR = 901)
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist', lwp )
+         !
+         REWIND( numnam_cfg )              ! Namelist nammpp in configuration namelist: mpi variables
+         READ  ( numnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist', lwp )
+
+         kpi = ( -nn_isize - 2*nn_hls ) * jpni + 2*nn_hls
+         kpj = ( -nn_jsize - 2*nn_hls ) * jpnj + 2*nn_hls
+      ELSE
+         kpi = nn_isize
+         kpj = nn_jsize
+      ENDIF
+ 
+      kpk = nn_ksize
+      kperio = nn_perio
+
+      !                             ! control print
+      ii = 1
+      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '   Namelist namusr_def : BENCH test case'                                     ;   ii = ii + 1
+      IF( nn_isize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-x            nn_isize = ',  nn_isize              ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpni = ', jpni                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-x           -nn_isize = ', -nn_isize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-x                 kpi = ', kpi                    ;   ii = ii + 1
+      ENDIF
+      IF( nn_jsize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-y            nn_jsize = ', nn_jsize               ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpnj = ', jpnj                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-y           -nn_jsize = ', -nn_jsize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-y                 kpj = ', kpj                    ;   ii = ii + 1
+      ENDIF
+      WRITE(ldtxt(ii),*) '      global domain size-z            nn_ksize = ', nn_ksize                  ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '      LBC of the global domain          kperio = ', kperio                    ;   ii = ii + 1
+      !
+   END SUBROUTINE usr_def_nam
+
+   !!======================================================================
+END MODULE usrdef_nam
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_sbc.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_sbc.F90	(revision 10136)
@@ -0,0 +1,78 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_sbc  ***
+   !! 
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_sbc    : user defined surface bounday conditions in BENCH case
+   !!----------------------------------------------------------------------
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usrdef_sbc_oce      ! routine called in sbcmod module
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by sbcice_lim.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by sbcice_lim.F90 for ice thermo
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE usr_def_sbc  ***
+      !!              
+      !! ** Purpose :   provide at each time-step the surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   all 0 fields, for BENCH case
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set to ZERO all the ocean surface boundary condition, i.e.   
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !     
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) WRITE(numout,*)' usr_sbc : BENCH case: surface forcing'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~~~~~   vtau = taum = wndm = qns = qsr = emp = sfx = 0'
+         !
+         utau(:,:) = 0._wp
+         vtau(:,:) = 0._wp
+         taum(:,:) = 0._wp
+         wndm(:,:) = 0._wp
+         !
+         emp (:,:) = 0._wp
+         sfx (:,:) = 0._wp
+         qns (:,:) = 0._wp
+         qsr (:,:) = 0._wp
+         !         
+      ENDIF
+      
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+   SUBROUTINE usrdef_sbc_ice_flx( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_zgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/usrdef_zgr.F90	(revision 10136)
@@ -0,0 +1,240 @@
+MODULE usrdef_zgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_zgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : vertical coordinate system of a user configuration
+   !!======================================================================
+   !! History :  4.0  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_zgr   : user defined vertical coordinate system
+   !!      zgr_z      : reference 1D z-coordinate 
+   !!      zgr_top_bot: ocean top and bottom level indices
+   !!      zgr_zco    : 3D verticl coordinate in pure z-coordinate case
+   !!---------------------------------------------------------------------
+   USE oce            ! ocean variables
+   USE dom_oce        ! ocean domain
+   USE phycst         ! physical constants
+   USE depth_e3       ! depth <=> e3
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_zgr        ! called by domzgr.F90
+
+  !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS             
+
+   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
+      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
+      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
+      &                    pe3t  , pe3u  , pe3v   , pe3f ,             &   ! vertical scale factors
+      &                    pe3w  , pe3uw , pe3vw         ,             &   !     -      -      -
+      &                    k_top  , k_bot    )                             ! top & bottom ocean level
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE usr_def_zgr  ***
+      !!
+      !! ** Purpose :   User defined the vertical coordinates
+      !!
+      !!----------------------------------------------------------------------
+      LOGICAL                   , INTENT(out) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags
+      LOGICAL                   , INTENT(out) ::   ld_isfcav                   ! under iceshelf cavity flag
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pdept, pdepw                ! grid-point depth        [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors 
+      INTEGER , DIMENSION(:,:)  , INTENT(out) ::   k_top, k_bot                ! first & last ocean level
+      !
+      INTEGER  ::   inum   ! local logical unit
+      REAL(WP) ::   z_zco, z_zps, z_sco, z_cav
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_zgr : BENCH configuration (z-coordinate closed flat box ocean)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      !
+      !
+      ! type of vertical coordinate
+      ! ---------------------------
+      ld_zco    = .TRUE.         ! BENCH case:  z-coordinate without ocean cavities
+      ld_zps    = .FALSE.
+      ld_sco    = .FALSE.
+      ld_isfcav = .FALSE.
+      !
+      !
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+      CALL zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
+      !
+      CALL zgr_msk_top_bot( k_top , k_bot )                 ! masked top and bottom ocean t-level indices
+      !
+      !                                                     ! z-coordinate (3D arrays) from the 1D z-coord.
+      CALL zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in  : 1D reference vertical coordinate
+         &          pdept   , pdepw   ,                     &   ! out : 3D t & w-points depth
+         &          pe3t    , pe3u    , pe3v   , pe3f   ,   &   !       vertical scale factors
+         &          pe3w    , pe3uw   , pe3vw             )     !           -      -      -
+      !
+   END SUBROUTINE usr_def_zgr
+
+
+   SUBROUTINE zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z  ***
+      !!
+      !! ** Purpose :   set the 1D depth of model levels and the resulting 
+      !!              vertical scale factors.
+      !!
+      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
+      !!       The depth of model levels is set from dep(k), an analytical function:
+      !!                   w-level: depw_1d  = dep(k)
+      !!                   t-level: dept_1d  = dep(k+0.5)
+      !!       The scale factors are the discrete derivative of the depth:
+      !!                   e3w_1d(jk) = dk[ dept_1d ] 
+      !!                   e3t_1d(jk) = dk[ depw_1d ]
+      !!           with at top and bottom :
+      !!                   e3w_1d( 1 ) = 2 * ( dept_1d( 1 ) - depw_1d( 1 ) )
+      !!                   e3t_1d(jpk) = 2 * ( dept_1d(jpk) - depw_1d(jpk) )
+      !!       The depth are then re-computed from the sum of e3. This ensures 
+      !!    that depths are identical when reading domain configuration file. 
+      !!    Indeed, only e3. are saved in this file, depth are compute by a call
+      !!    to the e3_to_depth subroutine.
+      !!
+      !!       Here the Madec & Imbard (1996) function is used.
+      !!
+      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
+      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!
+      !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+      !!             Madec and Imbard, 1996, Clim. Dyn.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
+      !
+      INTEGER  ::   jk       ! dummy loop indices
+      REAL(wp) ::   zd       ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      zd = 5000./FLOAT(jpkm1)
+      !
+      IF(lwp) THEN            ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z   : Reference vertical z-coordinates '
+         WRITE(numout,*) '    ~~~~~~~'
+         WRITE(numout,*) '       BENCH case : uniform vertical grid :'
+         WRITE(numout,*) '                     with thickness = ', zd
+      ENDIF
+
+      !
+      ! 1D Reference z-coordinate    (using Madec & Imbard 1996 function)
+      ! -------------------------
+      !
+      pdepw_1d(1) = 0._wp
+      pdept_1d(1) = 0.5_wp * zd
+      ! 
+      DO jk = 2, jpk          ! depth at T and W-points
+         pdepw_1d(jk) = pdepw_1d(jk-1) + zd 
+         pdept_1d(jk) = pdept_1d(jk-1) + zd 
+      END DO
+      !
+      !                       ! e3t and e3w from depth
+      CALL depth_to_e3( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d ) 
+      !
+      !                       ! recompute depths from SUM(e3)  <== needed
+      CALL e3_to_depth( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d ) 
+      !
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
+      ENDIF
+      !
+   END SUBROUTINE zgr_z
+
+
+   SUBROUTINE zgr_msk_top_bot( k_top , k_bot )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_msk_top_bot  ***
+      !!
+      !! ** Purpose :   set the masked top and bottom ocean t-levels
+      !!
+      !! ** Method  :   BENCH case = closed flat box ocean without ocean cavities
+      !!                   k_top = 1     except along north, south, east and west boundaries
+      !!                   k_bot = jpk-1 except along north, south, east and west boundaries
+      !!
+      !! ** Action  : - k_top : first wet ocean level index
+      !!              - k_bot : last  wet ocean level index
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(:,:), INTENT(out) ::   k_top , k_bot   ! first & last wet ocean level
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D local workspace
+      REAL(wp)                     ::   zmaxlam, zscl
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_top_bot : defines the top and bottom wet ocean levels.'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '       BENCH case : closed flat box ocean without ocean cavities'
+      !
+      z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
+      !
+      CALL lbc_lnk( "usrdef_zgr", z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      !
+      k_bot(:,:) = INT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
+      !
+      k_top(:,:) = MIN( 1 , k_bot(:,:) )     ! = 1    over the ocean point, =0 elsewhere
+      !
+   END SUBROUTINE zgr_msk_top_bot
+   
+
+   SUBROUTINE zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in : 1D reference vertical coordinate
+      &                pdept   , pdepw   ,                     &   ! out: 3D t & w-points depth
+      &                pe3t    , pe3u    , pe3v   , pe3f   ,   &   !      vertical scale factors
+      &                pe3w    , pe3uw   , pe3vw             )     !          -      -      -
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zco  ***
+      !!
+      !! ** Purpose :   define the reference z-coordinate system
+      !!
+      !! ** Method  :   set 3D coord. arrays to reference 1D array 
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth       [m]
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pe3t_1d , pe3w_1d           ! 1D vertical scale factors [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept, pdepw                ! grid-point depth          [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors    [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3w , pe3uw, pe3vw         !    -       -      -
+      !
+      INTEGER  ::   jk
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         pdept(:,:,jk) = pdept_1d(jk)
+         pdepw(:,:,jk) = pdepw_1d(jk)
+         pe3t (:,:,jk) = pe3t_1d (jk)
+         pe3u (:,:,jk) = pe3t_1d (jk)
+         pe3v (:,:,jk) = pe3t_1d (jk)
+         pe3f (:,:,jk) = pe3t_1d (jk)
+         pe3w (:,:,jk) = pe3w_1d (jk)
+         pe3uw(:,:,jk) = pe3w_1d (jk)
+         pe3vw(:,:,jk) = pe3w_1d (jk)
+      END DO
+      !
+   END SUBROUTINE zgr_zco
+
+   !!======================================================================
+END MODULE usrdef_zgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/zdfiwm.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/zdfiwm.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/MY_SRC/zdfiwm.F90	(revision 10136)
@@ -0,0 +1,482 @@
+MODULE zdfiwm
+   !!========================================================================
+   !!                       ***  MODULE  zdfiwm  ***
+   !! Ocean physics: Internal gravity wave-driven vertical mixing
+   !!========================================================================
+   !! History :  1.0  !  2004-04  (L. Bessieres, G. Madec)  Original code
+   !!             -   !  2006-08  (A. Koch-Larrouy)  Indonesian strait
+   !!            3.3  !  2010-10  (C. Ethe, G. Madec)  reorganisation of initialisation phase
+   !!            3.6  !  2016-03  (C. de Lavergne)  New param: internal wave-driven mixing 
+   !!            4.0  !  2017-04  (G. Madec)  renamed module, remove the old param. and the CPP keys
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_iwm       : global     momentum & tracer Kz with wave induced Kz
+   !!   zdf_iwm_init  : global     momentum & tracer Kz with wave induced Kz
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE zdf_oce        ! ocean vertical physics variables
+   USE zdfddm         ! ocean vertical physics: double diffusive mixing
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE eosbn2         ! ocean equation of state
+   USE phycst         ! physical constants
+   !
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O Manager
+   USE lib_mpp        ! MPP library
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_iwm        ! called in step module 
+   PUBLIC   zdf_iwm_init   ! called in nemogcm module 
+
+   !                      !!* Namelist  namzdf_iwm : internal wave-driven mixing *
+   INTEGER ::  nn_zpyc     ! pycnocline-intensified mixing energy proportional to N (=1) or N^2 (=2)
+   LOGICAL ::  ln_mevar    ! variable (=T) or constant (=F) mixing efficiency
+   LOGICAL ::  ln_tsdiff   ! account for differential T/S wave-driven mixing (=T) or not (=F)
+
+   REAL(wp)::  r1_6 = 1._wp / 6._wp
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ebot_iwm   ! power available from high-mode wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   epyc_iwm   ! power available from low-mode, pycnocline-intensified wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ecri_iwm   ! power available from low-mode, critical slope wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hbot_iwm   ! WKB decay scale for high-mode energy dissipation (m)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hcri_iwm   ! decay scale for low-mode critical slope dissipation (m)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: zdfiwm.F90 8093 2017-05-30 08:13:14Z gm $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION zdf_iwm_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  FUNCTION zdf_iwm_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( ebot_iwm(jpi,jpj),  epyc_iwm(jpi,jpj),  ecri_iwm(jpi,jpj) ,     &
+      &         hbot_iwm(jpi,jpj),  hcri_iwm(jpi,jpj)                     , STAT=zdf_iwm_alloc )
+      !
+      IF( lk_mpp             )   CALL mpp_sum ( zdf_iwm_alloc )
+      IF( zdf_iwm_alloc /= 0 )   CALL ctl_warn('zdf_iwm_alloc: failed to allocate arrays')
+   END FUNCTION zdf_iwm_alloc
+
+
+   SUBROUTINE zdf_iwm( kt, p_avm, p_avt, p_avs )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm  ***
+      !!                   
+      !! ** Purpose :   add to the vertical mixing coefficients the effect of
+      !!              breaking internal waves.
+      !!
+      !! ** Method  : - internal wave-driven vertical mixing is given by:
+      !!                  Kz_wave = min(  100 cm2/s, f(  Reb = zemx_iwm /( Nu * N^2 )  )
+      !!              where zemx_iwm is the 3D space distribution of the wave-breaking 
+      !!              energy and Nu the molecular kinematic viscosity.
+      !!              The function f(Reb) is linear (constant mixing efficiency)
+      !!              if the namelist parameter ln_mevar = F and nonlinear if ln_mevar = T.
+      !!
+      !!              - Compute zemx_iwm, the 3D power density that allows to compute
+      !!              Reb and therefrom the wave-induced vertical diffusivity.
+      !!              This is divided into three components:
+      !!                 1. Bottom-intensified low-mode dissipation at critical slopes
+      !!                     zemx_iwm(z) = ( ecri_iwm / rau0 ) * EXP( -(H-z)/hcri_iwm )
+      !!                                   / ( 1. - EXP( - H/hcri_iwm ) ) * hcri_iwm
+      !!              where hcri_iwm is the characteristic length scale of the bottom 
+      !!              intensification, ecri_iwm a map of available power, and H the ocean depth.
+      !!                 2. Pycnocline-intensified low-mode dissipation
+      !!                     zemx_iwm(z) = ( epyc_iwm / rau0 ) * ( sqrt(rn2(z))^nn_zpyc )
+      !!                                   / SUM( sqrt(rn2(z))^nn_zpyc * e3w(z) )
+      !!              where epyc_iwm is a map of available power, and nn_zpyc
+      !!              is the chosen stratification-dependence of the internal wave
+      !!              energy dissipation.
+      !!                 3. WKB-height dependent high mode dissipation
+      !!                     zemx_iwm(z) = ( ebot_iwm / rau0 ) * rn2(z) * EXP(-z_wkb(z)/hbot_iwm)
+      !!                                   / SUM( rn2(z) * EXP(-z_wkb(z)/hbot_iwm) * e3w(z) )
+      !!              where hbot_iwm is the characteristic length scale of the WKB bottom 
+      !!              intensification, ebot_iwm is a map of available power, and z_wkb is the
+      !!              WKB-stretched height above bottom defined as
+      !!                    z_wkb(z) = H * SUM( sqrt(rn2(z'>=z)) * e3w(z'>=z) )
+      !!                                 / SUM( sqrt(rn2(z'))    * e3w(z')    )
+      !!
+      !!              - update the model vertical eddy viscosity and diffusivity: 
+      !!                     avt  = avt  +    av_wave
+      !!                     avm  = avm  +    av_wave
+      !!
+      !!              - if namelist parameter ln_tsdiff = T, account for differential mixing:
+      !!                     avs  = avt  +    av_wave * diffusivity_ratio(Reb)
+      !!
+      !! ** Action  : - avt, avs, avm, increased by tide internal wave-driven mixing    
+      !!
+      !! References :  de Lavergne et al. 2015, JPO; 2016, in prep.
+      !!----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kt             ! ocean time step
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avm          ! momentum Kz (w-points)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avt, p_avs   ! tracer   Kz (w-points)
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zztmp        ! scalar workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zfact       ! Used for vertical structure
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhdep       ! Ocean depth
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwkb        ! WKB-stretched height above bottom
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zweight     ! Weight for high mode vertical distribution
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_t       ! Molecular kinematic viscosity (T grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_w       ! Molecular kinematic viscosity (W grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zReb        ! Turbulence intensity parameter
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zemx_iwm    ! local energy density available for mixing (W/kg)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_ratio   ! S/T diffusivity ratio (only for ln_tsdiff=T)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_wave    ! Internal wave-induced diffusivity
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   z3d  ! 3D workspace used for iom_put 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   z2d  ! 2D     -      -    -     -
+      !!----------------------------------------------------------------------
+      !
+      !                       !* Set to zero the 1st and last vertical levels of appropriate variables
+      zemx_iwm (:,:,1) = 0._wp   ;   zemx_iwm (:,:,jpk) = 0._wp
+      zav_ratio(:,:,1) = 0._wp   ;   zav_ratio(:,:,jpk) = 0._wp
+      zav_wave (:,:,1) = 0._wp   ;   zav_wave (:,:,jpk) = 0._wp
+      !
+      !                       ! ----------------------------- !
+      !                       !  Internal wave-driven mixing  !  (compute zav_wave)
+      !                       ! ----------------------------- !
+      !                             
+      !                       !* Critical slope mixing: distribute energy over the time-varying ocean depth,
+      !                                                 using an exponential decay from the seafloor.
+      DO jj = 1, jpj                ! part independent of the level
+         DO ji = 1, jpi
+            zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
+            zfact(ji,jj) = rau0 * (  1._wp - EXP( -zhdep(ji,jj) / hcri_iwm(ji,jj) )  )
+            IF( zfact(ji,jj) /= 0._wp )   zfact(ji,jj) = ecri_iwm(ji,jj) / zfact(ji,jj)
+         END DO
+      END DO
+!!gm gde3w ==>>>  check for ssh taken into account.... seem OK gde3w_n=gdept_n - sshn
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zfact(:,:) * (  EXP( ( gde3w_n(:,:,jk  ) - zhdep(:,:) ) / hcri_iwm(:,:) )                      &
+            &                             - EXP( ( gde3w_n(:,:,jk-1) - zhdep(:,:) ) / hcri_iwm(:,:) )  ) * wmask(:,:,jk)   &
+            &                          / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+
+!!gm delta(gde3w_n) = e3t_n  !!  Please verify the grid-point position w versus t-point
+!!gm it seems to me that only 1/hcri_iwm  is used ==>  compute it one for all
+
+      END DO
+
+      !                        !* Pycnocline-intensified mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to sqrt(rn2)^nn_zpyc
+      !                                          ! (NB: N2 is masked, so no use of wmask here)
+      SELECT CASE ( nn_zpyc )
+      !
+      CASE ( 1 )               ! Dissipation scales as N (recommended)
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+      CASE ( 2 )               ! Dissipation scales as N^2
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj= 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+      END SELECT
+
+      !                        !* WKB-height dependent mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to rn2 * exp(-z_wkb/rn_hbot)
+      !
+      zwkb (:,:,:) = 0._wp
+      zfact(:,:)   = 0._wp
+      DO jk = 2, jpkm1
+         zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         zwkb(:,:,jk) = zfact(:,:)
+      END DO
+!!gm even better:
+!      DO jk = 2, jpkm1
+!         zwkb(:,:) = zwkb(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  )
+!      END DO
+!      zfact(:,:) = zwkb(:,:,jpkm1)
+!!gm or just use zwkb(k=jpk-1) instead of zfact...
+!!gm
+      !
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zwkb(ji,jj,jk) = zhdep(ji,jj) * ( zfact(ji,jj) - zwkb(ji,jj,jk) )   &
+                  &                                     * wmask(ji,jj,jk) / zfact(ji,jj)
+            END DO
+         END DO
+      END DO
+      zwkb(:,:,1) = zhdep(:,:) * wmask(:,:,1)
+      !
+      zweight(:,:,:) = 0._wp
+      DO jk = 2, jpkm1
+         zweight(:,:,jk) = MAX( 0._wp, rn2(:,:,jk) ) * hbot_iwm(:,:) * wmask(:,:,jk)                    &
+            &   * (  EXP( -zwkb(:,:,jk) / hbot_iwm(:,:) ) - EXP( -zwkb(:,:,jk-1) / hbot_iwm(:,:) )  )
+      END DO
+      !
+      zfact(:,:) = 0._wp
+      DO jk = 2, jpkm1              ! part independent of the level
+         zfact(:,:) = zfact(:,:) + zweight(:,:,jk)
+      END DO
+      !
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = ebot_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+         END DO
+      END DO
+      !
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zweight(:,:,jk) * zfact(:,:) * wmask(:,:,jk)   &
+            &                                / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+!!gm  use of e3t_n just above?
+      END DO
+      !
+!!gm  this is to be replaced by just a constant value znu=1.e-6 m2/s
+      ! Calculate molecular kinematic viscosity
+      znu_t(:,:,:) = 1.e-4_wp * (  17.91_wp - 0.53810_wp * tsn(:,:,:,jp_tem) + 0.00694_wp * tsn(:,:,:,jp_tem) * tsn(:,:,:,jp_tem)  &
+         &                                  + 0.02305_wp * tsn(:,:,:,jp_sal)  ) * tmask(:,:,:) * r1_rau0
+      DO jk = 2, jpkm1
+         znu_w(:,:,jk) = 0.5_wp * ( znu_t(:,:,jk-1) + znu_t(:,:,jk) ) * wmask(:,:,jk)
+      END DO
+!!gm end
+      !
+      ! Calculate turbulence intensity parameter Reb
+      DO jk = 2, jpkm1
+         zReb(:,:,jk) = zemx_iwm(:,:,jk) / MAX( 1.e-20_wp, znu_w(:,:,jk) * rn2(:,:,jk) )
+      END DO
+      !
+      ! Define internal wave-induced diffusivity
+      DO jk = 2, jpkm1
+         zav_wave(:,:,jk) = znu_w(:,:,jk) * zReb(:,:,jk) * r1_6   ! This corresponds to a constant mixing efficiency of 1/6
+      END DO
+      !
+      IF( ln_mevar ) THEN              ! Variable mixing efficiency case : modify zav_wave in the
+         DO jk = 2, jpkm1              ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( zReb(ji,jj,jk) > 480.00_wp ) THEN
+                     zav_wave(ji,jj,jk) = 3.6515_wp * znu_w(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ELSEIF( zReb(ji,jj,jk) < 10.224_wp ) THEN
+                     zav_wave(ji,jj,jk) = 0.052125_wp * znu_w(ji,jj,jk) * zReb(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jk = 2, jpkm1                 ! Bound diffusivity by molecular value and 100 cm2/s
+         zav_wave(:,:,jk) = MIN(  MAX( 1.4e-7_wp, zav_wave(:,:,jk) ), 1.e-2_wp  ) * wmask(:,:,jk)
+      END DO
+      !
+      IF( kt == nit000 ) THEN        !* Control print at first time-step: diagnose the energy consumed by zav_wave
+         zztmp = 0._wp
+!!gm used of glosum 3D....
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zztmp = zztmp + e3w_n(ji,jj,jk) * e1e2t(ji,jj)   &
+                     &          * MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( zztmp )
+         zztmp = rau0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'zdf_iwm : Internal wave-driven mixing (iwm)'
+            WRITE(numout,*) '~~~~~~~ '
+            WRITE(numout,*)
+            WRITE(numout,*) '      Total power consumption by av_wave =  ', zztmp * 1.e-12_wp, 'TW'
+         ENDIF
+      ENDIF
+
+      !                          ! ----------------------- !
+      !                          !   Update  mixing coefs  !                          
+      !                          ! ----------------------- !
+      !      
+      IF( ln_tsdiff ) THEN          !* Option for differential mixing of salinity and temperature
+         DO jk = 2, jpkm1              ! Calculate S/T diffusivity ratio as a function of Reb
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zav_ratio(ji,jj,jk) = ( 0.505_wp + 0.495_wp *                                                                  &
+                      &   TANH(    0.92_wp * (   LOG10(  MAX( 1.e-20_wp, zReb(ji,jj,jk) * 5._wp * r1_6 )  ) - 0.60_wp   )    )   &
+                      &                 ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "av_ratio", zav_ratio )
+         DO jk = 2, jpkm1           !* update momentum & tracer diffusivity with wave-driven mixing
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk) * zav_ratio(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+         !
+      ELSE                          !* update momentum & tracer diffusivity with wave-driven mixing
+         DO jk = 2, jpkm1
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+      ENDIF
+
+      !                             !* output internal wave-driven mixing coefficient
+      CALL iom_put( "av_wave", zav_wave )
+                                    !* output useful diagnostics: Kz*N^2 , 
+!!gm Kz*N2 should take into account the ratio avs/avt if it is used.... (see diaar5)
+                                    !  vertical integral of rau0 * Kz * N^2 , energy density (zemx_iwm)
+      IF( iom_use("bflx_iwm") .OR. iom_use("pcmap_iwm") ) THEN
+         ALLOCATE( z2d(jpi,jpj) , z3d(jpi,jpj,jpk) )
+         z3d(:,:,:) = MAX( 0._wp, rn2(:,:,:) ) * zav_wave(:,:,:)
+         z2d(:,:) = 0._wp
+         DO jk = 2, jpkm1
+            z2d(:,:) = z2d(:,:) + e3w_n(:,:,jk) * z3d(:,:,jk) * wmask(:,:,jk)
+         END DO
+         z2d(:,:) = rau0 * z2d(:,:)
+         CALL iom_put( "bflx_iwm", z3d )
+         CALL iom_put( "pcmap_iwm", z2d )
+         DEALLOCATE( z2d , z3d )
+      ENDIF
+      CALL iom_put( "emix_iwm", zemx_iwm )
+      
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_wave , clinfo1=' iwm - av_wave: ', tab3d_2=avt, clinfo2=' avt: ', kdim=jpk)
+      !
+   END SUBROUTINE zdf_iwm
+
+
+   SUBROUTINE zdf_iwm_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the wave-driven vertical mixing, reading
+      !!              of input power maps and decay length scales in netcdf files.
+      !!
+      !! ** Method  : - Read the namzdf_iwm namelist and check the parameters
+      !!
+      !!              - Read the input data in NetCDF files :
+      !!              power available from high-mode wave breaking (mixing_power_bot.nc)
+      !!              power available from pycnocline-intensified wave-breaking (mixing_power_pyc.nc)
+      !!              power available from critical slope wave-breaking (mixing_power_cri.nc)
+      !!              WKB decay scale for high-mode wave-breaking (decay_scale_bot.nc)
+      !!              decay scale for critical slope wave-breaking (decay_scale_cri.nc)
+      !!
+      !! ** input   : - Namlist namzdf_iwm
+      !!              - NetCDF files : mixing_power_bot.nc, mixing_power_pyc.nc, mixing_power_cri.nc,
+      !!              decay_scale_bot.nc decay_scale_cri.nc
+      !!
+      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
+      !!              - Define ebot_iwm, epyc_iwm, ecri_iwm, hbot_iwm, hcri_iwm
+      !!
+      !! References : de Lavergne et al. JPO, 2015 ; de Lavergne PhD 2016
+      !!              de Lavergne et al. in prep., 2017
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   inum         ! local integer
+      INTEGER  ::   ios
+      REAL(wp) ::   zbot, zpyc, zcri   ! local scalars
+      !!
+      NAMELIST/namzdf_iwm/ nn_zpyc, ln_mevar, ln_tsdiff
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist namzdf_iwm in reference namelist : Wave-driven mixing
+      READ  ( numnam_ref, namzdf_iwm, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namzdf_iwm in configuration namelist : Wave-driven mixing
+      READ  ( numnam_cfg, namzdf_iwm, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namzdf_iwm )
+      !
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_iwm_init : internal wave-driven mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_iwm : set wave-driven mixing parameters'
+         WRITE(numout,*) '      Pycnocline-intensified diss. scales as N (=1) or N^2 (=2) = ', nn_zpyc
+         WRITE(numout,*) '      Variable (T) or constant (F) mixing efficiency            = ', ln_mevar
+         WRITE(numout,*) '      Differential internal wave-driven mixing (T) or not (F)   = ', ln_tsdiff
+      ENDIF
+      
+      ! The new wave-driven mixing parameterization elevates avt and avm in the interior, and
+      ! ensures that avt remains larger than its molecular value (=1.4e-7). Therefore, avtb should 
+      ! be set here to a very small value, and avmb to its (uniform) molecular value (=1.4e-6).
+      avmb(:) = 1.4e-6_wp        ! viscous molecular value
+      avtb(:) = 1.e-10_wp        ! very small diffusive minimum (background avt is specified in zdf_iwm)    
+      avtb_2d(:,:) = 1.e0_wp     ! uniform 
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Force the background value applied to avm & avt in TKE to be everywhere ',   &
+            &               'the viscous molecular value & a very small diffusive value, resp.'
+      ENDIF
+            
+      !                             ! allocate iwm arrays
+      IF( zdf_iwm_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_iwm_init : unable to allocate iwm arrays' )
+      !
+      !                             ! read necessary fields
+!!$      CALL iom_open('mixing_power_bot',inum)       ! energy flux for high-mode wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ebot_iwm, 1 ) 
+!!$      CALL iom_close(inum)
+      ebot_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_pyc',inum)       ! energy flux for pynocline-intensified wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', epyc_iwm, 1 )
+!!$      CALL iom_close(inum)
+      epyc_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_cri',inum)       ! energy flux for critical slope wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ecri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      ecri_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('decay_scale_bot',inum)        ! spatially variable decay scale for high-mode wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hbot_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hbot_iwm(:,:) = 1.
+      !
+!!$      CALL iom_open('decay_scale_cri',inum)        ! spatially variable decay scale for critical slope wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hcri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hcri_iwm(:,:) = 1.
+
+      ebot_iwm(:,:) = ebot_iwm(:,:) * ssmask(:,:)
+      epyc_iwm(:,:) = epyc_iwm(:,:) * ssmask(:,:)
+      ecri_iwm(:,:) = ecri_iwm(:,:) * ssmask(:,:)
+
+      zbot = glob_sum( e1e2t(:,:) * ebot_iwm(:,:) )
+      zpyc = glob_sum( e1e2t(:,:) * epyc_iwm(:,:) )
+      zcri = glob_sum( e1e2t(:,:) * ecri_iwm(:,:) )
+      IF(lwp) THEN
+         WRITE(numout,*) '      High-mode wave-breaking energy:             ', zbot * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Pycnocline-intensifed wave-breaking energy: ', zpyc * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Critical slope wave-breaking energy:        ', zcri * 1.e-12_wp, 'TW'
+      ENDIF
+      !
+   END SUBROUTINE zdf_iwm_init
+
+   !!======================================================================
+END MODULE zdfiwm
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/cpp_BENCH.fcm
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/cpp_BENCH.fcm	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_025/cpp_BENCH.fcm	(revision 10136)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys  key_mpp_mpi  
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/best_jpni_jpnj_eorca1
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/best_jpni_jpnj_eorca1	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/best_jpni_jpnj_eorca1	(revision 10136)
@@ -0,0 +1,205 @@
+    nb_cores 1 ( 1 x 1 ), nb_points 120184 ( 362 x 332 )
+    nb_cores 2 ( 2 x 1 ), nb_points 60424 ( 182 x 332 )
+#    nb_cores 3 ( 3 x 1 ), nb_points 40504 ( 122 x 332 )
+#    nb_cores 4 ( 2 x 2 ), nb_points 30394 ( 182 x 167 )
+#    nb_cores 5 ( 5 x 1 ), nb_points 24568 ( 74 x 332 )
+#    nb_cores 6 ( 3 x 2 ), nb_points 20374 ( 122 x 167 )
+#    nb_cores 7 ( 7 x 1 ), nb_points 17928 ( 54 x 332 )
+#    nb_cores 8 ( 4 x 2 ), nb_points 15364 ( 92 x 167 )
+    nb_cores 9 ( 3 x 3 ), nb_points 13664 ( 122 x 112 )
+#    nb_cores 10 ( 5 x 2 ), nb_points 12358 ( 74 x 167 )
+#    nb_cores 11 ( 1 x 11 ), nb_points 11584 ( 362 x 32 )
+#    nb_cores 12 ( 4 x 3 ), nb_points 10304 ( 92 x 112 )
+#    nb_cores 13 ( 13 x 1 ), nb_points 9960 ( 30 x 332 )
+#    nb_cores 14 ( 7 x 2 ), nb_points 9018 ( 54 x 167 )
+#    nb_cores 15 ( 5 x 3 ), nb_points 8288 ( 74 x 112 )
+#    nb_cores 16 ( 4 x 4 ), nb_points 7820 ( 92 x 85 )
+#    nb_cores 18 ( 6 x 3 ), nb_points 6944 ( 62 x 112 )
+    nb_cores 20 ( 4 x 5 ), nb_points 6256 ( 92 x 68 )
+#    nb_cores 21 ( 7 x 3 ), nb_points 6048 ( 54 x 112 )
+#    nb_cores 22 ( 2 x 11 ), nb_points 5824 ( 182 x 32 )
+#    nb_cores 24 ( 4 x 6 ), nb_points 5244 ( 92 x 57 )
+#    nb_cores 25 ( 5 x 5 ), nb_points 5032 ( 74 x 68 )
+#    nb_cores 26 ( 13 x 2 ), nb_points 5010 ( 30 x 167 )
+#    nb_cores 27 ( 9 x 3 ), nb_points 4704 ( 42 x 112 )
+#    nb_cores 28 ( 7 x 4 ), nb_points 4590 ( 54 x 85 )
+    nb_cores 30 ( 6 x 5 ), nb_points 4216 ( 62 x 68 )
+    nb_cores 32 ( 8 x 4 ), nb_points 3995 ( 47 x 85 )
+#    nb_cores 33 ( 3 x 11 ), nb_points 3904 ( 122 x 32 )
+#    nb_cores 35 ( 7 x 5 ), nb_points 3672 ( 54 x 68 )
+#    nb_cores 36 ( 6 x 6 ), nb_points 3534 ( 62 x 57 )
+#    nb_cores 38 ( 19 x 2 ), nb_points 3507 ( 21 x 167 )
+#    nb_cores 39 ( 13 x 3 ), nb_points 3360 ( 30 x 112 )
+    nb_cores 40 ( 8 x 5 ), nb_points 3196 ( 47 x 68 )
+#    nb_cores 42 ( 7 x 6 ), nb_points 3078 ( 54 x 57 )
+#    nb_cores 44 ( 4 x 11 ), nb_points 2944 ( 92 x 32 )
+#    nb_cores 45 ( 9 x 5 ), nb_points 2856 ( 42 x 68 )
+#    nb_cores 48 ( 8 x 6 ), nb_points 2679 ( 47 x 57 )
+    nb_cores 50 ( 10 x 5 ), nb_points 2584 ( 38 x 68 )
+#    nb_cores 52 ( 13 x 4 ), nb_points 2550 ( 30 x 85 )
+#    nb_cores 54 ( 9 x 6 ), nb_points 2394 ( 42 x 57 )
+#    nb_cores 55 ( 5 x 11 ), nb_points 2368 ( 74 x 32 )
+#    nb_cores 56 ( 8 x 7 ), nb_points 2350 ( 47 x 50 )
+    nb_cores 60 ( 10 x 6 ), nb_points 2166 ( 38 x 57 )
+#    nb_cores 63 ( 9 x 7 ), nb_points 2100 ( 42 x 50 )
+#    nb_cores 64 ( 8 x 8 ), nb_points 2068 ( 47 x 44 )
+#    nb_cores 65 ( 13 x 5 ), nb_points 2040 ( 30 x 68 )
+#    nb_cores 66 ( 6 x 11 ), nb_points 1984 ( 62 x 32 )
+    nb_cores 70 ( 7 x 10 ), nb_points 1890 ( 54 x 35 )
+#    nb_cores 72 ( 12 x 6 ), nb_points 1824 ( 32 x 57 )
+#    nb_cores 75 ( 15 x 5 ), nb_points 1768 ( 26 x 68 )
+#    nb_cores 77 ( 7 x 11 ), nb_points 1728 ( 54 x 32 )
+#    nb_cores 78 ( 13 x 6 ), nb_points 1710 ( 30 x 57 )
+    nb_cores 80 ( 8 x 10 ), nb_points 1645 ( 47 x 35 )
+#    nb_cores 81 ( 9 x 9 ), nb_points 1638 ( 42 x 39 )
+#    nb_cores 84 ( 14 x 6 ), nb_points 1596 ( 28 x 57 )
+#    nb_cores 88 ( 8 x 11 ), nb_points 1504 ( 47 x 32 )
+#    nb_cores 90 ( 9 x 10 ), nb_points 1470 ( 42 x 35 )
+#    nb_cores 95 ( 19 x 5 ), nb_points 1428 ( 21 x 68 )
+#    nb_cores 96 ( 12 x 8 ), nb_points 1408 ( 32 x 44 )
+#    nb_cores 98 ( 14 x 7 ), nb_points 1400 ( 28 x 50 )
+#    nb_cores 99 ( 9 x 11 ), nb_points 1344 ( 42 x 32 )
+#    nb_cores 100 ( 10 x 10 ), nb_points 1330 ( 38 x 35 )
+#    nb_cores 104 ( 8 x 13 ), nb_points 1316 ( 47 x 28 )
+#    nb_cores 105 ( 7 x 15 ), nb_points 1296 ( 54 x 24 )
+#    nb_cores 108 ( 12 x 9 ), nb_points 1248 ( 32 x 39 )
+#    nb_cores 110 ( 10 x 11 ), nb_points 1216 ( 38 x 32 )
+#    nb_cores 114 ( 19 x 6 ), nb_points 1197 ( 21 x 57 )
+#    nb_cores 117 ( 13 x 9 ), nb_points 1170 ( 30 x 39 )
+    nb_cores 120 ( 12 x 10 ), nb_points 1120 ( 32 x 35 )
+#    nb_cores 126 ( 9 x 14 ), nb_points 1092 ( 42 x 26 )
+#    nb_cores 126 ( 14 x 9 ), nb_points 1092 ( 28 x 39 )
+#    nb_cores 128 ( 8 x 16 ), nb_points 1081 ( 47 x 23 )
+#    nb_cores 130 ( 13 x 10 ), nb_points 1050 ( 30 x 35 )
+#    nb_cores 132 ( 12 x 11 ), nb_points 1024 ( 32 x 32 )
+#    nb_cores 135 ( 9 x 15 ), nb_points 1008 ( 42 x 24 )
+#    nb_cores 140 ( 14 x 10 ), nb_points 980 ( 28 x 35 )
+#    nb_cores 143 ( 13 x 11 ), nb_points 960 ( 30 x 32 )
+#    nb_cores 150 ( 15 x 10 ), nb_points 910 ( 26 x 35 )
+#    nb_cores 154 ( 14 x 11 ), nb_points 896 ( 28 x 32 )
+#    nb_cores 160 ( 10 x 16 ), nb_points 874 ( 38 x 23 )
+#    nb_cores 162 ( 18 x 9 ), nb_points 858 ( 22 x 39 )
+#    nb_cores 165 ( 15 x 11 ), nb_points 832 ( 26 x 32 )
+#    nb_cores 171 ( 19 x 9 ), nb_points 819 ( 21 x 39 )
+#    nb_cores 176 ( 8 x 22 ), nb_points 799 ( 47 x 17 )
+#    nb_cores 180 ( 12 x 15 ), nb_points 768 ( 32 x 24 )
+#    nb_cores 189 ( 9 x 21 ), nb_points 756 ( 42 x 18 )
+#    nb_cores 190 ( 19 x 10 ), nb_points 735 ( 21 x 35 )
+#    nb_cores 195 ( 13 x 15 ), nb_points 720 ( 30 x 24 )
+#    nb_cores 198 ( 18 x 11 ), nb_points 704 ( 22 x 32 )
+#    nb_cores 200 ( 20 x 10 ), nb_points 700 ( 20 x 35 )
+#    nb_cores 208 ( 13 x 16 ), nb_points 690 ( 30 x 23 )
+#    nb_cores 209 ( 19 x 11 ), nb_points 672 ( 21 x 32 )
+#    nb_cores 216 ( 18 x 12 ), nb_points 660 ( 22 x 30 )
+#    nb_cores 220 ( 20 x 11 ), nb_points 640 ( 20 x 32 )
+#    nb_cores 225 ( 15 x 15 ), nb_points 624 ( 26 x 24 )
+#    nb_cores 234 ( 18 x 13 ), nb_points 616 ( 22 x 28 )
+#    nb_cores 240 ( 24 x 10 ), nb_points 595 ( 17 x 35 )
+#    nb_cores 247 ( 19 x 13 ), nb_points 588 ( 21 x 28 )
+#    nb_cores 252 ( 18 x 14 ), nb_points 572 ( 22 x 26 )
+#    nb_cores 260 ( 20 x 13 ), nb_points 560 ( 20 x 28 )
+#    nb_cores 260 ( 26 x 10 ), nb_points 560 ( 16 x 35 )
+#    nb_cores 264 ( 12 x 22 ), nb_points 544 ( 32 x 17 )
+#    nb_cores 264 ( 24 x 11 ), nb_points 544 ( 17 x 32 )
+#    nb_cores 270 ( 18 x 15 ), nb_points 528 ( 22 x 24 )
+#    nb_cores 280 ( 20 x 14 ), nb_points 520 ( 20 x 26 )
+#    nb_cores 285 ( 19 x 15 ), nb_points 504 ( 21 x 24 )
+#    nb_cores 300 ( 20 x 15 ), nb_points 480 ( 20 x 24 )
+#    nb_cores 308 ( 14 x 22 ), nb_points 476 ( 28 x 17 )
+#    nb_cores 315 ( 15 x 21 ), nb_points 468 ( 26 x 18 )
+#    nb_cores 320 ( 20 x 16 ), nb_points 460 ( 20 x 23 )
+#    nb_cores 330 ( 15 x 22 ), nb_points 442 ( 26 x 17 )
+#    nb_cores 340 ( 20 x 17 ), nb_points 440 ( 20 x 22 )
+#    nb_cores 345 ( 23 x 15 ), nb_points 432 ( 18 x 24 )
+#    nb_cores 352 ( 16 x 22 ), nb_points 425 ( 25 x 17 )
+#    nb_cores 360 ( 24 x 15 ), nb_points 408 ( 17 x 24 )
+#    nb_cores 378 ( 18 x 21 ), nb_points 396 ( 22 x 18 )
+#    nb_cores 384 ( 24 x 16 ), nb_points 391 ( 17 x 23 )
+#    nb_cores 390 ( 26 x 15 ), nb_points 384 ( 16 x 24 )
+#    nb_cores 396 ( 18 x 22 ), nb_points 374 ( 22 x 17 )
+#    nb_cores 416 ( 26 x 16 ), nb_points 368 ( 16 x 23 )
+#    nb_cores 418 ( 19 x 22 ), nb_points 357 ( 21 x 17 )
+#    nb_cores 432 ( 18 x 24 ), nb_points 352 ( 22 x 16 )
+#    nb_cores 440 ( 20 x 22 ), nb_points 340 ( 20 x 17 )
+#    nb_cores 450 ( 30 x 15 ), nb_points 336 ( 14 x 24 )
+#    nb_cores 468 ( 18 x 26 ), nb_points 330 ( 22 x 15 )
+#    nb_cores 480 ( 20 x 24 ), nb_points 320 ( 20 x 16 )
+#    nb_cores 494 ( 19 x 26 ), nb_points 315 ( 21 x 15 )
+#    nb_cores 495 ( 15 x 33 ), nb_points 312 ( 26 x 12 )
+#    nb_cores 495 ( 33 x 15 ), nb_points 312 ( 13 x 24 )
+#    nb_cores 504 ( 24 x 21 ), nb_points 306 ( 17 x 18 )
+#    nb_cores 520 ( 20 x 26 ), nb_points 300 ( 20 x 15 )
+#    nb_cores 528 ( 24 x 22 ), nb_points 289 ( 17 x 17 )
+#    nb_cores 540 ( 18 x 30 ), nb_points 286 ( 22 x 13 )
+#    nb_cores 560 ( 20 x 28 ), nb_points 280 ( 20 x 14 )
+#    nb_cores 570 ( 19 x 30 ), nb_points 273 ( 21 x 13 )
+#    nb_cores 572 ( 26 x 22 ), nb_points 272 ( 16 x 17 )
+#    nb_cores 588 ( 28 x 21 ), nb_points 270 ( 15 x 18 )
+#    nb_cores 594 ( 18 x 33 ), nb_points 264 ( 22 x 12 )
+#    nb_cores 600 ( 20 x 30 ), nb_points 260 ( 20 x 13 )
+#    nb_cores 616 ( 28 x 22 ), nb_points 255 ( 15 x 17 )
+#    nb_cores 627 ( 19 x 33 ), nb_points 252 ( 21 x 12 )
+#    nb_cores 660 ( 30 x 22 ), nb_points 238 ( 14 x 17 )
+#    nb_cores 690 ( 23 x 30 ), nb_points 234 ( 18 x 13 )
+#    nb_cores 703 ( 19 x 37 ), nb_points 231 ( 21 x 11 )
+#    nb_cores 720 ( 24 x 30 ), nb_points 221 ( 17 x 13 )
+#    nb_cores 740 ( 20 x 37 ), nb_points 220 ( 20 x 11 )
+#    nb_cores 756 ( 36 x 21 ), nb_points 216 ( 12 x 18 )
+#    nb_cores 780 ( 26 x 30 ), nb_points 208 ( 16 x 13 )
+#    nb_cores 792 ( 36 x 22 ), nb_points 204 ( 12 x 17 )
+#    nb_cores 792 ( 24 x 33 ), nb_points 204 ( 17 x 12 )
+#    nb_cores 840 ( 28 x 30 ), nb_points 195 ( 15 x 13 )
+#    nb_cores 858 ( 26 x 33 ), nb_points 192 ( 16 x 12 )
+#    nb_cores 880 ( 40 x 22 ), nb_points 187 ( 11 x 17 )
+#    nb_cores 900 ( 30 x 30 ), nb_points 182 ( 14 x 13 )
+#    nb_cores 924 ( 28 x 33 ), nb_points 180 ( 15 x 12 )
+#    nb_cores 960 ( 40 x 24 ), nb_points 176 ( 11 x 16 )
+#    nb_cores 990 ( 30 x 33 ), nb_points 168 ( 14 x 12 )
+#    nb_cores 1036 ( 28 x 37 ), nb_points 165 ( 15 x 11 )
+#    nb_cores 1080 ( 36 x 30 ), nb_points 156 ( 12 x 13 )
+#    nb_cores 1110 ( 30 x 37 ), nb_points 154 ( 14 x 11 )
+#    nb_cores 1144 ( 52 x 22 ), nb_points 153 ( 9 x 17 )
+#    nb_cores 1170 ( 45 x 26 ), nb_points 150 ( 10 x 15 )
+#    nb_cores 1188 ( 36 x 33 ), nb_points 144 ( 12 x 12 )
+#    nb_cores 1200 ( 40 x 30 ), nb_points 143 ( 11 x 13 )
+#    nb_cores 1260 ( 30 x 42 ), nb_points 140 ( 14 x 10 )
+#    nb_cores 1260 ( 45 x 28 ), nb_points 140 ( 10 x 14 )
+#    nb_cores 1320 ( 40 x 33 ), nb_points 132 ( 11 x 12 )
+#    nb_cores 1350 ( 45 x 30 ), nb_points 130 ( 10 x 13 )
+#    nb_cores 1430 ( 26 x 55 ), nb_points 128 ( 16 x 8 )
+#    nb_cores 1440 ( 30 x 48 ), nb_points 126 ( 14 x 9 )
+#    nb_cores 1480 ( 40 x 37 ), nb_points 121 ( 11 x 11 )
+#    nb_cores 1485 ( 45 x 33 ), nb_points 120 ( 10 x 12 )
+#    nb_cores 1560 ( 52 x 30 ), nb_points 117 ( 9 x 13 )
+#    nb_cores 1650 ( 30 x 55 ), nb_points 112 ( 14 x 8 )
+#    nb_cores 1665 ( 45 x 37 ), nb_points 110 ( 10 x 11 )
+#    nb_cores 1716 ( 52 x 33 ), nb_points 108 ( 9 x 12 )
+#    nb_cores 1800 ( 60 x 30 ), nb_points 104 ( 8 x 13 )
+#    nb_cores 1890 ( 45 x 42 ), nb_points 100 ( 10 x 10 )
+#    nb_cores 1920 ( 40 x 48 ), nb_points 99 ( 11 x 9 )
+#    nb_cores 1980 ( 60 x 33 ), nb_points 96 ( 8 x 12 )
+#    nb_cores 1980 ( 36 x 55 ), nb_points 96 ( 12 x 8 )
+#    nb_cores 2160 ( 45 x 48 ), nb_points 90 ( 10 x 9 )
+#    nb_cores 2200 ( 40 x 55 ), nb_points 88 ( 11 x 8 )
+#    nb_cores 2376 ( 72 x 33 ), nb_points 84 ( 7 x 12 )
+#    nb_cores 2376 ( 36 x 66 ), nb_points 84 ( 12 x 7 )
+#    nb_cores 2475 ( 45 x 55 ), nb_points 80 ( 10 x 8 )
+#    nb_cores 2640 ( 40 x 66 ), nb_points 77 ( 11 x 7 )
+#    nb_cores 2860 ( 52 x 55 ), nb_points 72 ( 9 x 8 )
+#    nb_cores 2970 ( 45 x 66 ), nb_points 70 ( 10 x 7 )
+#    nb_cores 3300 ( 60 x 55 ), nb_points 64 ( 8 x 8 )
+#    nb_cores 3432 ( 52 x 66 ), nb_points 63 ( 9 x 7 )
+#    nb_cores 3735 ( 45 x 83 ), nb_points 60 ( 10 x 6 )
+#    nb_cores 3960 ( 60 x 66 ), nb_points 56 ( 8 x 7 )
+#    nb_cores 3960 ( 72 x 55 ), nb_points 56 ( 7 x 8 )
+#    nb_cores 4316 ( 52 x 83 ), nb_points 54 ( 9 x 6 )
+#    nb_cores 4752 ( 72 x 66 ), nb_points 49 ( 7 x 7 )
+#    nb_cores 4950 ( 90 x 55 ), nb_points 48 ( 6 x 8 )
+#    nb_cores 5720 ( 52 x 110 ), nb_points 45 ( 9 x 5 )
+#    nb_cores 5940 ( 90 x 66 ), nb_points 42 ( 6 x 7 )
+#    nb_cores 6600 ( 120 x 55 ), nb_points 40 ( 5 x 8 )
+#    nb_cores 6600 ( 60 x 110 ), nb_points 40 ( 8 x 5 )
+#    nb_cores 7470 ( 90 x 83 ), nb_points 36 ( 6 x 6 )
+#    nb_cores 7920 ( 72 x 110 ), nb_points 35 ( 7 x 5 )
+#    nb_cores 7920 ( 120 x 66 ), nb_points 35 ( 5 x 7 )
+#    nb_cores 9900 ( 90 x 110 ), nb_points 30 ( 6 x 5 )
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg	(revision 10136)
@@ -0,0 +1,1 @@
+link namelist_cfg_orca1_like
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg_orca1_like
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg_orca1_like	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_cfg_orca1_like	(revision 10136)
@@ -0,0 +1,215 @@
+! vim: ft=fortran :
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  BENCH Configuration namelist : overwrite some defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   'BENCH' !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =    1000   !  last time step 
+   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+/
+!-----------------------------------------------------------------------
+&namusr_def    !   User defined :   BENCH configuration: Flat bottom, beta-plane
+!-----------------------------------------------------------------------
+   nn_isize   =   362      ! number of point in i-direction of global(local) domain if >0 (<0)  
+   nn_jsize   =   332      ! number of point in j-direction of global(local) domain if >0 (<0)  
+   nn_ksize   =   75       ! total number of point in k-direction
+   nn_perio   =   6        ! periodicity
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+!-----------------------------------------------------------------------
+   ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
+   jpni        =   3       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =   3       !  jpnj   number of processors following j (set automatically if < 1)
+!   nn_comm_mod  =   1      !  step routine call frequency
+!   ln_comm_only = .false.  !  replace step routine by realistic communications only
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   ln_timing   = .true.   !  timing by routine write out in timing.output file
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   rn_rdt      =   3600.   !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =   0.05    !  asselin time filter parameter
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+  ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+/
+
+!
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid   (read by child model only)       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  free slip
+/
+
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_OFF =F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_OFF =F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_non_lin  = .true.   !  non-linear  drag: Cd = Cd0 |U|
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbc   = .true.   !  Apply a geothermal heating at the ocean bottom
+      nn_geoflx     = 1       !  geothermal heat flux: = 1 constant flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbl   = .true.   !  Bottom Boundary Layer parameterisation flag
+/
+
+!!======================================================================
+!!                        Tracer (T & S) namelists                    !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_teos10   = .true.         !  = Use TEOS-10
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_fct = .true.  !  FCT scheme
+      nn_fct_h   =  2            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_lap   = .true.   !    laplacian operator
+   ln_traldf_iso   = .true.   !  iso-neutral (standard operator)
+   !
+   nn_aht_ijk_t    = 20       !  space/time variation of eddy coefficient:
+/
+!-----------------------------------------------------------------------
+&namtra_mle    !   mixed layer eddy parametrisation (Fox-Kemper)       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_mle      = .true.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+/
+!-----------------------------------------------------------------------
+&namtra_eiv    !   eddy induced velocity param.                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ldfeiv   = .true.   ! use eddy induced velocity parameterization
+   !
+   nn_aei_ijk_t    = 20          !  space/time variation of eddy coefficient:
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nam_vvl       !   vertical coordinate options                          (default: z-star)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  z-star vertical coordinate
+   ln_vvl_dbg    = .false.          !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true. !  vector form (T) or flux form (F)
+      nn_dynkeg     = 1       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_een = .true. !  energy & enstrophy scheme
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts   = .true.   ! split-explicit free surface
+      ln_bt_auto    = .false.    ! Number of sub-step defined from:
+         nn_baro      =  30         ! =F : the number of sub-step in rn_rdt seconds
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynldf_lap =  .true.    !    laplacian operator
+   ln_dynldf_hor =  .true.    !  horizontal (geopotential)
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 30           !  space/time variation of eddy coef
+/
+
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics                                     (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdftke   = .true.       !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
+   ln_zdfevd   = .true.       !  enhanced vertical diffusion
+   ln_zdfddm   = .true.       ! double diffusive mixing
+   ln_zdfiwm   = .true.       ! internal wave-induced mixing            (T =>   fill namzdf_iwm)
+/
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_ref
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_ref	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/namelist_ref	(revision 10136)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/sh_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/sh_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/sh_bench	(revision 10136)
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -u
+#set -xv
+
+resolution=${1:?"you must provide the resolution: 1 025 or 12"}
+mincore=${2:-1} # minimum number of core to be tested
+maxcore=${3:-0} # maximum number of core to be tested
+
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+case $machine in 
+    "beaufixlogin") ncore_node=40 ;;
+    "curie")        ncore_node=16 ;;
+    "irene")        ncore_node=48 ;;
+    *) echo "you must add your machine \"$machine\" with its number of cores per node" ; exit 1 ;;
+esac
+
+[ $mincore -eq 1 ] && targetnb=$ncore_node || targetnb=$mincore
+#
+# build the list of experiences:
+# must be a multiple of ncore_node and as close as possible of the targeted number of core
+#
+n1=0
+list=""
+
+# Prepare gnuplot data file
+dateref=$( date "+%Y%m%d-%Hh%Mm%Ss" )
+echo "# nb_proc    jpi    jpj" > gnuplot_tbc_${resolution}_${dateref}.dat
+nbl=$( cat best_jpni_jpnj_eorca${resolution} | wc -l )
+for ll in $( seq 1 $nbl )
+do
+    line=$( sed -n ${ll}p best_jpni_jpnj_eorca${resolution} )    # for each line
+    nn=$( echo $line | sed -e "s/.*nb_cores \([0-9]*\).*/\1/" )  # get the number of core
+    [ $maxcore -gt 1 -a $nn -gt $maxcore ] && break              # if below $maxcore (if specified)
+        if [ $(( $nn % $ncore_node )) -eq 0 ]                    # if it is a multiple of $ncore_node
+        then
+            if [ $nn -lt $targetnb ]
+            then
+                n1=$nn       # store the number of core
+                line1=$line  # store the line
+            else
+                [ $(( $targetnb - $n1 )) -le $(( $nn -$targetnb )) ] && line=$line1   # keep the previous line
+                echo $line
+                nb=$( echo $line | sed -e "s/[^(]*( \([0-9]*\) x \([0-9]*\) .*/\1*\2/" ) # get jpni*jpnj
+                list="${list} ${nb}"
+                targetnb=$(( $targetnb * 2 ))
+                subsize=$( echo $line | awk {'printf "%d   %d", $11, $13'})
+                corenb=$( echo $line | awk {'printf "%d", $2'})
+                echo "$corenb  $subsize" >> gnuplot_tbc_${resolution}.dat
+            fi
+        fi
+done
+echo $list
+
+for cores in $list
+do
+    ./submit_bench $cores $ncore_node ${resolution} ${dateref}
+done
+
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/submit_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/submit_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/EXPREF/submit_bench	(revision 10136)
@@ -0,0 +1,197 @@
+#!/bin/bash
+#  
+#  BENCH launching scripts for beaufix, Meteo-France
+#                          and curie, TGCC
+#  To be modified for other machines
+#
+set -u
+set -vx
+#
+cores=$1
+ncore_node=$2
+resolution=$3
+dateref=$4
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+#
+# number of processes for each executable
+    nproc_exe1=$( echo $cores | bc )
+  (( nproc = $nproc_exe1 ))
+(( nnode = $nproc / $ncore_node ))
+[ $nnode -lt 1 ] && nnode=1
+
+nproc5=$( printf "%05d\n" ${nproc_exe1} )
+
+######################################################################
+### beaufixlogin
+######################################################################
+
+if [ "$machine" == "beaufixlogin" ]
+then
+    
+cat > Log/run_bench << EOF
+#!/bin/bash
+#SBATCH --time=00:1:00
+#SBATCH -p  normal64         # partition/queue
+#SBATCH --job-name=bench      # job name
+#SBATCH -N $nnode            # number of nodes
+#SBATCH -n $nproc            # number of procs
+#SBATCH -o /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH -e /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH --exclusive
+
+module unload intelmpi intel grib_api
+module load intel/16.1.150 intelmpi/5.1.2.150
+
+itac=0
+xpmpi=0
+
+if [ \$xpmpi == 1 ]; then
+  module load bullxde
+  module load xPMPI/1.1_intelmpi
+fi
+
+[ \$itac == 1 ] && module load itac/2017.2.028
+
+set -vx
+
+cd \${TMPDIR}
+cp /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/* .
+
+# Best decompositions BENCH-1
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+export OMP_NUM_THREADS=1
+ulimit -s unlimited
+#
+if [ \$itac == 1 ]; then
+  source /opt/softs/intel/2017/update_1/itac_latest/bin/itacvars.sh
+  time mpirun -ordered-output -prepend-rank -trace -np $nproc_exe1 ./nemo > jobout 2>joberr
+else
+  time mpirun -ordered-output -prepend-rank -np $nproc_exe1 ./nemo > jobout_${resolution}_${nproc5}
+fi
+/opt/softs/bin/ja
+
+if [ \$xpmpi == 1 ]; then
+  module unload xPMPI/1.1_intelmpi
+  module unload bullxde
+fi
+#
+EOF
+
+
+### 4. Execute the model
+
+    echo 'Submitting the job to queue using sbatch'
+    sbatch Log/run_bench
+    squeue -u cglo315
+
+echo 'is executed or submitted to queue.'
+
+
+fi
+
+######################################################################
+### curie or irene
+######################################################################
+
+if [[ ( "$machine" == "curie" ) || ( "$machine" == "irene" ) ]]
+then
+    
+    case ${resolution} in
+	"1")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=1800
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=900
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"025")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=7000
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=2000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=1000
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"12")
+	    if [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=30000
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=8000
+	    elif [ $nproc_exe1 -lt 1600 ]
+	    then
+		timejob=5000
+	    elif [ $nproc_exe1 -lt 3200 ]
+	    then
+		timejob=2500
+	    else
+		timejob=1200
+	    fi
+	;;
+    esac
+
+    [ "$machine" == "curie" ] && queuename=standard || queuename=skylake
+    
+    jobname=$HOME/binrun/jobbench
+    cat > $jobname << EOF
+#!/bin/bash
+#MSUB -r bench${nproc5}
+#MSUB -n ${nproc_exe1}
+#MSUB -T $timejob
+#MSUB -e bench_${resolution}_${nproc5}_%I.eo
+#MSUB -o bench_${resolution}_${nproc5}_%I.eo
+#MSUB -j oe
+#MSUB -x
+#MSUB -q ${queuename}
+#MSUB -A gen6895
+#==========================================
+set -u
+#
+
+cd \${BRIDGE_MSUB_PWD}/..
+
+
+EXPjob=EXP_${resolution}_${nproc5}_${dateref}
+rsync -av --exclude="*eo" EXPREF/ \${EXPjob}/
+rsync -av EXP00/nemo \${EXPjob}/nemo
+cd \${EXPjob}
+
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+time ccc_mprun -n \${BRIDGE_MSUB_NPROC} ./nemo > jobout_${resolution}_${nproc5}_${dateref}
+
+EOF
+
+    ccc_msub $jobname
+
+fi
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/diawri.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/diawri.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/diawri.F90	(revision 10136)
@@ -0,0 +1,586 @@
+MODULE diawri
+   !!======================================================================
+   !!                     ***  MODULE  diawri  ***
+   !! Ocean diagnostics :  write ocean output files
+   !!=====================================================================
+   !! History :  OPA  ! 1991-03  (M.-A. Foujols)  Original code
+   !!            4.0  ! 1991-11  (G. Madec)
+   !!                 ! 1992-06  (M. Imbard)  correction restart file
+   !!                 ! 1992-07  (M. Imbard)  split into diawri and rstwri
+   !!                 ! 1993-03  (M. Imbard)  suppress writibm
+   !!                 ! 1998-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
+   !!                 ! 1999-02  (E. Guilyardi)  name of netCDF files + variables
+   !!            8.2  ! 2000-06  (M. Imbard)  Original code (diabort.F)
+   !!   NEMO     1.0  ! 2002-06  (A.Bozec, E. Durand)  Original code (diainit.F)
+   !!             -   ! 2002-09  (G. Madec)  F90: Free form and module
+   !!             -   ! 2002-12  (G. Madec)  merge of diabort and diainit, F90
+   !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
+   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
+   !!                 !                     change name of output variables in dia_wri_state
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_wri       : create the standart output files
+   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers 
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE dianam         ! build name of file (routine)
+   USE diahth         ! thermocline diagnostics
+   USE dynadv   , ONLY: ln_dynadv_vec
+   USE icb_oce        ! Icebergs
+   USE icbdia         ! Iceberg budgets
+   USE ldftra         ! lateral physics: eddy diffusivity coef.
+   USE ldfdyn         ! lateral physics: eddy viscosity   coef.
+   USE sbc_oce        ! Surface boundary condition: ocean fields
+   USE sbc_ice        ! Surface boundary condition: ice fields
+   USE sbcssr         ! restoring term toward SST/SSS climatology
+   USE sbcwave        ! wave parameters
+   USE wet_dry        ! wetting and drying
+   USE zdf_oce        ! ocean vertical physics
+   USE zdfdrg         ! ocean vertical physics: top/bottom friction
+   USE zdfmxl         ! mixed layer
+   !
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager ! I/O manager
+   USE diatmb         ! Top,middle,bottom output
+   USE dia25h         ! 25h Mean output
+   USE iom            ! 
+   USE ioipsl         ! 
+
+#if defined key_si3
+   USE icewri 
+#endif
+   USE lib_mpp         ! MPP library
+   USE timing          ! preformance summary
+   USE diurnal_bulk    ! diurnal warm layer
+   USE cool_skin       ! Cool skin
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_wri                 ! routines called by step.F90
+   PUBLIC   dia_wri_state
+   PUBLIC   dia_wri_alloc           ! Called by nemogcm module
+
+   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT   ! grid_T file
+   INTEGER ::          nb_T              , ndim_bT   ! grid_T file
+   INTEGER ::   nid_U, nz_U, nh_U, ndim_U, ndim_hU   ! grid_U file
+   INTEGER ::   nid_V, nz_V, nh_V, ndim_V, ndim_hV   ! grid_V file
+   INTEGER ::   nid_W, nz_W, nh_W                    ! grid_W file
+   INTEGER ::   ndex(1)                              ! ???
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_bT
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: diawri.F90 9598 2018-05-15 22:47:16Z nicolasmartin $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if defined key_iomput
+   !!----------------------------------------------------------------------
+   !!   'key_iomput'                                        use IOM library
+   !!----------------------------------------------------------------------
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   
+   SUBROUTINE dia_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :  use iom_put
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk       ! dummy loop indices
+      INTEGER ::   ikbot            ! local integer
+      REAL(wp)::   zztmp , zztmpx   ! local scalar
+      REAL(wp)::   zztmp2, zztmpy   !   -      -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
+      !!----------------------------------------------------------------------
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      ! 
+      ! Output the initial state and forcings
+      IF( ninist == 1 ) THEN                       
+         CALL dia_wri_state( 'output.init', kt )
+         ninist = 0
+      ENDIF
+
+      ! Output of initial vertical scale factor
+      CALL iom_put("e3t_0", e3t_0(:,:,:) )
+      CALL iom_put("e3u_0", e3t_0(:,:,:) )
+      CALL iom_put("e3v_0", e3t_0(:,:,:) )
+      !
+      CALL iom_put( "e3t" , e3t_n(:,:,:) )
+      CALL iom_put( "e3u" , e3u_n(:,:,:) )
+      CALL iom_put( "e3v" , e3v_n(:,:,:) )
+      CALL iom_put( "e3w" , e3w_n(:,:,:) )
+      IF( iom_use("e3tdef") )   &
+         CALL iom_put( "e3tdef"  , ( ( e3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
+
+      IF( ll_wd ) THEN
+         CALL iom_put( "ssh" , (sshn+ssh_ref)*tmask(:,:,1) )   ! sea surface height (brought back to the reference used for wetting and drying)
+      ELSE
+         CALL iom_put( "ssh" , sshn )              ! sea surface height
+      ENDIF
+
+      IF( iom_use("wetdep") )   &                  ! wet depth
+         CALL iom_put( "wetdep" , ht_0(:,:) + sshn(:,:) )
+      
+      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
+      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
+      IF ( iom_use("sbt") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_tem)
+            END DO
+         END DO
+         CALL iom_put( "sbt", z2d )                ! bottom temperature
+      ENDIF
+      
+      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
+      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
+      IF ( iom_use("sbs") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_sal)
+            END DO
+         END DO
+         CALL iom_put( "sbs", z2d )                ! bottom salinity
+      ENDIF
+
+      IF ( iom_use("taubot") ) THEN                ! bottom stress
+         zztmp = rau0 * 0.25
+         z2d(:,:) = 0._wp
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp2 = (  ( rCdU_bot(ji+1,jj)+rCdU_bot(ji  ,jj) ) * un(ji  ,jj,mbku(ji  ,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji  ,jj)+rCdU_bot(ji-1,jj) ) * un(ji-1,jj,mbku(ji-1,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj  ) ) * vn(ji,jj  ,mbkv(ji,jj  ))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj  )+rCdU_bot(ji,jj-1) ) * vn(ji,jj-1,mbkv(ji,jj-1))  )**2
+               z2d(ji,jj) = zztmp * SQRT( zztmp2 ) * tmask(ji,jj,1) 
+               !
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "taubot", z2d )           
+      ENDIF
+         
+      CALL iom_put( "uoce", un(:,:,:) )            ! 3D i-current
+      CALL iom_put(  "ssu", un(:,:,1) )            ! surface i-current
+      IF ( iom_use("sbu") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbku(ji,jj)
+               z2d(ji,jj) = un(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbu", z2d )                ! bottom i-current
+      ENDIF
+      
+      CALL iom_put( "voce", vn(:,:,:) )            ! 3D j-current
+      CALL iom_put(  "ssv", vn(:,:,1) )            ! surface j-current
+      IF ( iom_use("sbv") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkv(ji,jj)
+               z2d(ji,jj) = vn(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbv", z2d )                ! bottom j-current
+      ENDIF
+
+      CALL iom_put( "woce", wn )                   ! vertical velocity
+      IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
+         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
+         z2d(:,:) = rau0 * e1e2t(:,:)
+         DO jk = 1, jpk
+            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
+         END DO
+         CALL iom_put( "w_masstr" , z3d )  
+         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
+      ENDIF
+
+      CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
+      CALL iom_put( "avs" , avs )                  ! S vert. eddy diff. coef.
+      CALL iom_put( "avm" , avm )                  ! T vert. eddy visc. coef.
+
+      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt(:,:,:) ) ) )
+      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
+
+      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
+         DO jj = 2, jpjm1                                    ! sst gradient
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp  = tsn(ji,jj,1,jp_tem)
+               zztmpx = ( tsn(ji+1,jj,1,jp_tem) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) * r1_e1u(ji-1,jj)
+               zztmpy = ( tsn(ji,jj+1,1,jp_tem) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) * r1_e2v(ji,jj-1)
+               z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
+                  &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
+         z2d(:,:) = SQRT( z2d(:,:) )
+         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
+      ENDIF
+         
+      ! heat and salt contents
+      IF( iom_use("heatc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "heatc", rau0_rcp * z2d )   ! vertically integrated heat content (J/m2)
+      ENDIF
+
+      IF( iom_use("saltc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "saltc", rau0 * z2d )          ! vertically integrated salt content (PSU*kg/m2)
+      ENDIF
+      !
+      IF ( iom_use("eken") ) THEN
+         z3d(:,:,jpk) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zztmp  = 0.25_wp * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
+                  z3d(ji,jj,jk) = zztmp * (  un(ji-1,jj,jk)**2 * e2u(ji-1,jj) * e3u_n(ji-1,jj,jk)   &
+                     &                     + un(ji  ,jj,jk)**2 * e2u(ji  ,jj) * e3u_n(ji  ,jj,jk)   &
+                     &                     + vn(ji,jj-1,jk)**2 * e1v(ji,jj-1) * e3v_n(ji,jj-1,jk)   &
+                     &                     + vn(ji,jj  ,jk)**2 * e1v(ji,jj  ) * e3v_n(ji,jj  ,jk)   )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z3d, 'T', 1. )
+         CALL iom_put( "eken", z3d )                 ! kinetic energy
+      ENDIF
+      !
+      CALL iom_put( "hdiv", hdivn )                  ! Horizontal divergence
+      !
+      IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         z2d(:,:) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * un(:,:,jk) * e2u(:,:) * e3u_n(:,:,jk) * umask(:,:,jk)
+            z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
+         END DO
+         CALL iom_put( "u_masstr"     , z3d )         ! mass transport in i-direction
+         CALL iom_put( "u_masstr_vint", z2d )         ! mass transport in i-direction vertical sum
+      ENDIF
+      
+      IF( iom_use("u_heattr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
+      ENDIF
+
+      IF( iom_use("u_salttr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
+      ENDIF
+
+      
+      IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e1v(:,:) * e3v_n(:,:,jk) * vmask(:,:,jk)
+         END DO
+         CALL iom_put( "v_masstr", z3d )              ! mass transport in j-direction
+      ENDIF
+      
+      IF( iom_use("v_heattr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("v_salttr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("tosmint") ) THEN
+         z2d(:,:) = 0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) *  tsn(ji,jj,jk,jp_tem)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
+      ENDIF
+      IF( iom_use("somint") ) THEN
+         z2d(:,:)=0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
+      ENDIF
+
+      CALL iom_put( "bn2", rn2 )                      ! Brunt-Vaisala buoyancy frequency (N^2)
+      !
+
+      IF (ln_diatmb)   CALL dia_tmb                   ! tmb values 
+          
+      IF (ln_dia25h)   CALL dia_25h( kt )             ! 25h averaging
+
+      IF( ln_timing )   CALL timing_stop('dia_wri')
+      !
+   END SUBROUTINE dia_wri
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                  use IOIPSL  library
+   !!----------------------------------------------------------------------
+
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   SUBROUTINE dia_wri( kt )
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+   END SUBROUTINE dia_wri
+
+#endif
+
+   SUBROUTINE dia_wri_state( cdfile_name, kt )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_wri_state  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ocean state and forcing fields.
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! ** Method  :   NetCDF files using ioipsl
+      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
+      !!      File 'output.abort.nc' is created in case of abnormal job end
+      !!----------------------------------------------------------------------
+      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
+      INTEGER           , INTENT( in ) ::   kt               ! ocean time-step index
+      !! 
+      CHARACTER (len=32) :: clname
+      CHARACTER (len=40) :: clop
+      INTEGER  ::   id_i , nz_i, nh_i       
+      INTEGER, DIMENSION(1) ::   idex             ! local workspace
+      REAL(wp) ::   zsto, zout, zmax, zjulian
+      !!----------------------------------------------------------------------
+      ! 
+      ! 0. Initialisation
+      ! -----------------
+
+      ! Define name, frequency of output and means
+      clname = cdfile_name
+      IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      zsto = rdt
+      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
+      zout = rdt
+      zmax = ( nitend - nit000 + 1 ) * rdt
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
+      IF(lwp) WRITE(numout,*) '                and named :', clname, '.nc'
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      ! Compute julian date from starting date of the run
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )         ! time axis 
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      CALL histbeg( clname, jpi, glamt, jpj, gphit,   &
+          1, jpi, 1, jpj, nit000-1, zjulian, rdt, nh_i, id_i, domain_id=nidom, snc4chunks=snc4set ) ! Horizontal grid : glamt and gphit
+      CALL histvert( id_i, "deptht", "Vertical T levels",   &    ! Vertical grid : gdept
+          "m", jpk, gdept_1d, nz_i, "down")
+
+      ! Declare all the output fields as NetCDF variables
+
+      CALL histdef( id_i, "vosaline", "Salinity"              , "PSU"    ,   &   ! salinity
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
+         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vomecrty", "Meridional Current"    , "m/s"    ,   &   ! meridonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      CALL histdef( id_i, "vovecrtz", "Vertical Velocity"     , "m/s"    ,   &   ! vertical current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+         !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histdef( id_i, "ahtu"    , "u-eddy diffusivity"    , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahtv"    , "v-eddy diffusivity"    , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN 
+         CALL histdef( id_i, "ahmt"    , "t-eddy viscosity"      , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahmf"    , "f-eddy viscosity"      , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+         !
+      CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S",   &   ! net freshwater 
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2"   ,   &   ! net heat flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soshfldo", "Shortwave Radiation"   , "W/m2"   ,   &   ! solar flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soicecov", "Ice fraction"          , "[0,1]"  ,   &   ! fr_i
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sozotaux", "Zonal Wind Stress"     , "N/m2"   ,   &   ! i-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      IF( .NOT.ln_linssh ) THEN
+         CALL histdef( id_i, "vovvldep", "T point depth"         , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "vovvle3t", "T point thickness"     , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+      !
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histdef( id_i, "sdzocrtx", "Stokes Drift Zonal"    , "m/s"    , &   ! StokesDrift zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdmecrty", "Stokes Drift Merid"    , "m/s"    , &   ! StokesDrift meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdvecrtz", "Stokes Drift Vert"     , "m/s"    , &   ! StokesDrift vertical current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+
+#if defined key_si3
+      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
+         CALL ice_wri_state( kt, id_i, nh_i )
+      ENDIF
+#else
+      CALL histend( id_i, snc4chunks=snc4set )
+#endif
+
+      ! 2. Start writing data
+      ! ---------------------
+      ! idex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et idex la liste des indices a sortir
+      idex(1) = 1   ! init to avoid compil warning
+
+      ! Write all fields on T grid
+      CALL histwrite( id_i, "votemper", kt, tsn(:,:,:,jp_tem), jpi*jpj*jpk, idex )    ! now temperature
+      CALL histwrite( id_i, "vosaline", kt, tsn(:,:,:,jp_sal), jpi*jpj*jpk, idex )    ! now salinity
+      CALL histwrite( id_i, "sossheig", kt, sshn             , jpi*jpj    , idex )    ! sea surface height
+      CALL histwrite( id_i, "vozocrtx", kt, un               , jpi*jpj*jpk, idex )    ! now i-velocity
+      CALL histwrite( id_i, "vomecrty", kt, vn               , jpi*jpj*jpk, idex )    ! now j-velocity
+      CALL histwrite( id_i, "vovecrtz", kt, wn               , jpi*jpj*jpk, idex )    ! now k-velocity
+      !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histwrite( id_i, "ahtu"    , kt, ahtu             , jpi*jpj*jpk, idex )    ! aht at u-point
+         CALL histwrite( id_i, "ahtv"    , kt, ahtv             , jpi*jpj*jpk, idex )    !  -  at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL histwrite( id_i, "ahmt"    , kt, ahmt             , jpi*jpj*jpk, idex )    ! ahm at t-point
+         CALL histwrite( id_i, "ahmf"    , kt, ahmf             , jpi*jpj*jpk, idex )    !  -  at f-point
+      ENDIF
+      !
+      CALL histwrite( id_i, "sowaflup", kt, emp - rnf        , jpi*jpj    , idex )    ! freshwater budget
+      CALL histwrite( id_i, "sohefldo", kt, qsr + qns        , jpi*jpj    , idex )    ! total heat flux
+      CALL histwrite( id_i, "soshfldo", kt, qsr              , jpi*jpj    , idex )    ! solar heat flux
+      CALL histwrite( id_i, "soicecov", kt, fr_i             , jpi*jpj    , idex )    ! ice fraction
+      CALL histwrite( id_i, "sozotaux", kt, utau             , jpi*jpj    , idex )    ! i-wind stress
+      CALL histwrite( id_i, "sometauy", kt, vtau             , jpi*jpj    , idex )    ! j-wind stress
+
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL histwrite( id_i, "vovvldep", kt, gdept_n(:,:,:), jpi*jpj*jpk, idex )!  T-cell depth 
+         CALL histwrite( id_i, "vovvle3t", kt, e3t_n (:,:,:) , jpi*jpj*jpk, idex )!  T-cell thickness  
+      END IF 
+ 
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histwrite( id_i, "sdzocrtx", kt, usd           , jpi*jpj*jpk, idex)     ! now StokesDrift i-velocity
+         CALL histwrite( id_i, "sdmecrty", kt, vsd           , jpi*jpj*jpk, idex)     ! now StokesDrift j-velocity
+         CALL histwrite( id_i, "sdvecrtz", kt, wsd           , jpi*jpj*jpk, idex)     ! now StokesDrift k-velocity
+      ENDIF
+
+      ! 3. Close the file
+      ! -----------------
+      CALL histclo( id_i )
+#if ! defined key_iomput
+      IF( ninist /= 1  ) THEN
+         CALL histclo( nid_T )
+         CALL histclo( nid_U )
+         CALL histclo( nid_V )
+         CALL histclo( nid_W )
+      ENDIF
+#endif
+      ! 
+   END SUBROUTINE dia_wri_state
+
+   !!======================================================================
+END MODULE diawri
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/restart.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/restart.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/restart.F90	(revision 10136)
@@ -0,0 +1,316 @@
+MODULE restart
+   !!======================================================================
+   !!                     ***  MODULE  restart  ***
+   !! Ocean restart :  write the ocean restart file
+   !!======================================================================
+   !! History :  OPA  !  1999-11  (M. Imbard)  Original code
+   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form
+   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart
+   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
+   !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
+   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   rst_opn    : open the ocean restart file
+   !!   rst_write  : write the ocean restart file
+   !!   rst_read   : read the ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_ice         ! only lk_si3 
+   USE phycst          ! physical constants
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE diurnal_bulk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   rst_opn         ! routine called by step module
+   PUBLIC   rst_write       ! routine called by step module
+   PUBLIC   rst_read        ! routine called by istate module
+   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: restart.F90 9654 2018-05-28 09:08:53Z clem $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE rst_opn( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rst_opn  ***
+      !!                     
+      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
+      !!              + open the restart when we are one time step before nitrst
+      !!                   - restart header is defined when kt = nitrst-1
+      !!                   - restart data  are written when kt = nitrst
+      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(lc)       ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
+      CHARACTER(LEN=256)  ::   clinfo    ! info character
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN   ! default definitions
+         lrst_oce = .FALSE.   
+         IF( ln_rst_list ) THEN
+            nrst_lst = 1
+            nitrst = nstocklist( nrst_lst )
+         ELSE
+            nitrst = nitend
+         ENDIF
+      ENDIF
+
+      ! frequency-based restart dumping (nn_stock)
+      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN   
+         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
+         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
+      ENDIF
+      ! to get better performances with NetCDF format:
+      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
+      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
+      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
+         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
+            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+            ENDIF
+            ! create the file
+            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
+            clpath = TRIM(cn_ocerst_outdir)
+            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+            IF(lwp) THEN
+               WRITE(numout,*)
+               IF(.NOT.lwxios) THEN
+                  SELECT CASE ( jprstlib )
+                  CASE DEFAULT         ;   WRITE(numout,*)                            &
+                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
+                  END SELECT
+                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
+                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
+                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+                  ENDIF
+               ENDIF
+            ENDIF
+            !
+            IF(.NOT.lwxios) THEN
+               !EM no call to restart opening
+               !EM CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+            ELSE
+#if defined key_iomput
+               cwxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
+               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+                  clpname = clname
+               ELSE
+                  clpname = TRIM(Agrif_CFixed())//"_"//clname   
+               ENDIF
+               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname))
+               CALL xios_update_calendar(nitrst)
+               CALL iom_swap(      cxios_context          )
+#else
+               clinfo = 'Can not use XIOS in rst_opn'
+               CALL ctl_stop(TRIM(clinfo))
+#endif
+            ENDIF
+               !EM restart writing
+            !EM lrst_oce = .TRUE.
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_opn
+
+
+   SUBROUTINE rst_write( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rstwrite  ***
+      !!                     
+      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !!
+      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
+      !!              file, save fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step
+      !!----------------------------------------------------------------------
+                     IF(lwxios) CALL iom_swap(      cwxios_context          )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
+
+      IF ( .NOT. ln_diurnal_only ) THEN
+                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub, ldxios = lwxios        )     ! before fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb, ldxios = lwxios      )
+                     !
+                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un, ldxios = lwxios        )     ! now fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn, ldxios = lwxios      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop, ldxios = lwxios      )
+                  ! extra variable needed for the ice sheet coupling
+                  IF ( ln_iscpl ) THEN 
+                     CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask, ldxios = lwxios ) ! need to extrapolate T/S
+                     CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask, ldxios = lwxios) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:), ldxios = lwxios )   ! need to compute temperature correction
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:), ldxios = lwxios ) ! need to compute extrapolation if vvl
+                  END IF
+      ENDIF
+      
+      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )  
+      IF(lwxios) CALL iom_swap(      cxios_context          )
+      IF( kt == nitrst ) THEN
+         IF(.NOT.lwxios) THEN
+            CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         ELSE
+            CALL iom_context_finalize(      cwxios_context          )
+         ENDIF
+!!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
+!!gm  not sure what to do here   ===>>>  ask to Sebastian
+         lrst_oce = .FALSE.
+            IF( ln_rst_list ) THEN
+               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1))
+               nitrst = nstocklist( nrst_lst )
+            ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_write
+
+
+   SUBROUTINE rst_read_open
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read_open  ***
+      !! 
+      !! ** Purpose :   Open read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
+      !!                the file has already been opened
+      !!----------------------------------------------------------------------
+      INTEGER        ::   jlibalt = jprstlib
+      LOGICAL        ::   llok
+      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
+      !!----------------------------------------------------------------------
+      !
+      IF( numror <= 0 ) THEN
+         IF(lwp) THEN                                             ! Contol prints
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+            END SELECT
+            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
+            WRITE(numout,*) '~~~~~~~~'
+         ENDIF
+         lxios_sini = .FALSE.
+         clpath = TRIM(cn_ocerst_indir)
+         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
+! are we using XIOS to read the data? Part above will have to modified once XIOS
+! can handle checking if variable is in the restart file (there will be no need to open
+! restart)
+         IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
+         IF( lrxios) THEN
+             crxios_context = 'nemo_rst'
+             IF( .NOT.lxios_set ) THEN
+                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
+                 CALL iom_init( crxios_context )
+                 lxios_set = .TRUE.
+             ENDIF
+         ENDIF
+         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
+             CALL iom_init( crxios_context )
+             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
+             lxios_set = .TRUE.
+         ENDIF 
+      ENDIF
+
+   END SUBROUTINE rst_read_open
+
+
+   SUBROUTINE rst_read
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read  ***
+      !! 
+      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zrdt
+      INTEGER  ::   jk
+      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
+      !!----------------------------------------------------------------------
+
+      CALL rst_read_open           ! open restart for reading (if not already opened)
+
+      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
+      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
+         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
+         IF( zrdt /= rdt )   neuler = 0
+      ENDIF
+
+      ! Diurnal DSST 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
+      IF ( ln_diurnal_only ) THEN 
+         IF(lwp) WRITE( numout, * ) &
+         &   "rst_read:- ln_diurnal_only set, setting rhop=rau0" 
+         rhop = rau0
+         CALL iom_get( numror, jpdom_autoglo, 'tn'     , w3d, ldxios = lrxios ) 
+         tsn(:,:,1,jp_tem) = w3d(:,:,1)
+         RETURN 
+      ENDIF  
+      
+      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub, ldxios = lrxios                )   ! before fields
+         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb, ldxios = lrxios                )
+         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb, ldxios = lrxios              )
+      ELSE
+         neuler = 0
+      ENDIF
+      !
+      CALL iom_get( numror, jpdom_autoglo, 'un'     , un, ldxios = lrxios )   ! now    fields
+      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vn, ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, ldxios = lrxios )
+      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
+      ELSE
+         CALL eos( tsn, rhd, rhop, gdept_n(:,:,:) )   
+      ENDIF
+      !
+      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
+         tsb  (:,:,:,:) = tsn  (:,:,:,:)                             ! all before fields set to now values
+         ub   (:,:,:)   = un   (:,:,:)
+         vb   (:,:,:)   = vn   (:,:,:)
+         sshb (:,:)     = sshn (:,:)
+         !
+         IF( .NOT.ln_linssh ) THEN
+            DO jk = 1, jpk
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE rst_read
+
+   !!=====================================================================
+END MODULE restart
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_hgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_hgr.F90	(revision 10136)
@@ -0,0 +1,118 @@
+MODULE usrdef_hgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_hgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   mesh and Coriolis parameter of a user configuration
+   !!======================================================================
+   !! History :  NEMO  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_hgr    : initialize the horizontal mesh for BENCH configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE par_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_hgr   ! called by domhgr.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0, NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
+      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
+      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
+      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
+      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE usr_def_hgr  ***
+      !!
+      !! ** Purpose :   square box mesh mesh and Coriolis parameter
+      !!
+      !! ** Method  :   set all intent(out) argument to a proper value
+      !!                BENCH configuration : beta-plance with uniform grid spacing (zres)
+      !!
+      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in grid points) 
+      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
+      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
+      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
+      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
+      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise 
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zres, zf0
+      REAL(wp) ::   zti, zui, ztj, zvj   ! local scalars
+      !!-------------------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_hgr : BENCH configuration bassin'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
+      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
+      !
+      !                          
+      ! Position coordinates (in grid points)
+      !                          ==========         
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            
+            zti = REAL( ji - 1 + nimpp - 1, wp )          ;  ztj = REAL( jj - 1 + njmpp - 1, wp )
+            zui = REAL( ji - 1 + nimpp - 1, wp ) + 0.5_wp ;  zvj = REAL( jj - 1 + njmpp - 1, wp ) + 0.5_wp
+
+            plamt(ji,jj) = zti
+            plamu(ji,jj) = zui
+            plamv(ji,jj) = zti
+            plamf(ji,jj) = zui
+   
+            pphit(ji,jj) = ztj
+            pphiv(ji,jj) = zvj
+            pphiu(ji,jj) = ztj
+            pphif(ji,jj) = zvj
+            
+         END DO
+      END DO
+      !     
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      zres = 1.e+5   !  100km
+      pe1t(:,:) = zres  ;   pe2t(:,:) = zres 
+      pe1u(:,:) = zres  ;   pe2u(:,:) = zres
+      pe1v(:,:) = zres  ;   pe2v(:,:) = zres
+      pe1f(:,:) = zres  ;   pe2f(:,:) = zres 
+
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
+      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
+      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
+      !
+      !
+      !                       !==  Coriolis parameter  ==!
+      kff = 1                       !  indicate not to compute Coriolis parameter afterward
+      !
+      zf0   = 2._wp * omega * SIN( rad * 45 )   ! constant coriolis factor corresponding to 45°N
+      pff_f(:,:) = zf0
+      pff_t(:,:) = zf0
+      !
+   END SUBROUTINE usr_def_hgr
+
+   !!======================================================================
+END MODULE usrdef_hgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_istate.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_istate.F90	(revision 10136)
@@ -0,0 +1,72 @@
+MODULE usrdef_istate
+   !!======================================================================
+   !!                     ***  MODULE usrdef_istate   ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the initial state of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  usr_def_istate : initial state in Temperature and salinity
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE dom_oce        
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   !   
+   USE usrdef_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_istate   ! called by istate.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+  
+   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers
+      !!                Here BENCH configuration 
+      !!
+      !! ** Method  :   Set a gaussian anomaly of pressure and associated
+      !!                geostrophic velocities
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pdept   ! depth of t-point               [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  ! t-point ocean mask             [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   pts     ! T & S fields      [Celsius ; g/kg]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pu      ! i-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pv      ! j-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : BENCH configuration, analytical definition of initial state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
+      !
+      ! sea level:
+      pssh(:,:) = 0.
+      ! temperature:
+      pts(:,:,:,jp_tem) = 10._wp
+      ! salinity:  
+      pts(:,:,:,jp_sal) = 35._wp
+      ! velocities:
+      pu(:,:,:) = 0.
+      pv(:,:,:) = 0.
+      !
+
+   END SUBROUTINE usr_def_istate
+
+   !!======================================================================
+END MODULE usrdef_istate
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_nam.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_nam.F90	(revision 10136)
@@ -0,0 +1,119 @@
+MODULE usrdef_nam
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_nam  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the domain characteristics of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_nam   : read user defined namelist and set global domain size
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! to get ctl_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_nam   ! called by nemogcm.F90
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read user defined namelist and define the domain size
+      !!
+      !! ** Method  :   read in namusr_def containing all the user specific namelist parameter
+      !!
+      !!                Here EW_CANAL configuration
+      !!
+      !! ** input   : - namusr_def namelist found in namelist_cfg
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
+      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
+      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
+      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
+      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      !
+      !
+      INTEGER ::   ios, ii      ! Local integer
+      !                              !!* namusr_def namelist *!!
+      INTEGER ::   nn_isize    ! number of point in i-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_jsize    ! number of point in j-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_ksize    ! total number of point in k-direction
+      INTEGER ::   nn_perio    ! periodicity
+      !                              !!* nammpp namelist *!!
+      CHARACTER(len=1) ::   cn_mpi_send
+      INTEGER          ::   nn_buffer, jpni, jpnj, jpnij
+      LOGICAL          ::   ln_nnogather
+      !!
+      NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, nn_perio
+      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, jpnij, ln_nnogather
+      !!----------------------------------------------------------------------     
+      !
+      REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
+      READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+      WRITE( ldnam(:), namusr_def )      
+      !
+      cd_cfg = 'BENCH'             ! name & resolution (not used)
+      kk_cfg = 0
+
+      IF( nn_isize < 0 .AND. nn_jsize < 0 ) THEN
+      !
+         REWIND( numnam_ref )              ! Namelist nammpp in reference namelist: mpi variables
+         READ  ( numnam_ref, nammpp, IOSTAT = ios, ERR = 901)
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist', lwp )
+         !
+         REWIND( numnam_cfg )              ! Namelist nammpp in configuration namelist: mpi variables
+         READ  ( numnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist', lwp )
+
+         kpi = ( -nn_isize - 2*nn_hls ) * jpni + 2*nn_hls
+         kpj = ( -nn_jsize - 2*nn_hls ) * jpnj + 2*nn_hls
+      ELSE
+         kpi = nn_isize
+         kpj = nn_jsize
+      ENDIF
+ 
+      kpk = nn_ksize
+      kperio = nn_perio
+
+      !                             ! control print
+      ii = 1
+      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '   Namelist namusr_def : BENCH test case'                                     ;   ii = ii + 1
+      IF( nn_isize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-x            nn_isize = ',  nn_isize              ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpni = ', jpni                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-x           -nn_isize = ', -nn_isize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-x                 kpi = ', kpi                    ;   ii = ii + 1
+      ENDIF
+      IF( nn_jsize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-y            nn_jsize = ', nn_jsize               ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpnj = ', jpnj                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-y           -nn_jsize = ', -nn_jsize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-y                 kpj = ', kpj                    ;   ii = ii + 1
+      ENDIF
+      WRITE(ldtxt(ii),*) '      global domain size-z            nn_ksize = ', nn_ksize                  ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '      LBC of the global domain          kperio = ', kperio                    ;   ii = ii + 1
+      !
+   END SUBROUTINE usr_def_nam
+
+   !!======================================================================
+END MODULE usrdef_nam
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_sbc.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_sbc.F90	(revision 10136)
@@ -0,0 +1,78 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_sbc  ***
+   !! 
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_sbc    : user defined surface bounday conditions in BENCH case
+   !!----------------------------------------------------------------------
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usrdef_sbc_oce      ! routine called in sbcmod module
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by sbcice_lim.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by sbcice_lim.F90 for ice thermo
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE usr_def_sbc  ***
+      !!              
+      !! ** Purpose :   provide at each time-step the surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   all 0 fields, for BENCH case
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set to ZERO all the ocean surface boundary condition, i.e.   
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !     
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) WRITE(numout,*)' usr_sbc : BENCH case: surface forcing'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~~~~~   vtau = taum = wndm = qns = qsr = emp = sfx = 0'
+         !
+         utau(:,:) = 0._wp
+         vtau(:,:) = 0._wp
+         taum(:,:) = 0._wp
+         wndm(:,:) = 0._wp
+         !
+         emp (:,:) = 0._wp
+         sfx (:,:) = 0._wp
+         qns (:,:) = 0._wp
+         qsr (:,:) = 0._wp
+         !         
+      ENDIF
+      
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+   SUBROUTINE usrdef_sbc_ice_flx( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_zgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/usrdef_zgr.F90	(revision 10136)
@@ -0,0 +1,240 @@
+MODULE usrdef_zgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_zgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : vertical coordinate system of a user configuration
+   !!======================================================================
+   !! History :  4.0  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_zgr   : user defined vertical coordinate system
+   !!      zgr_z      : reference 1D z-coordinate 
+   !!      zgr_top_bot: ocean top and bottom level indices
+   !!      zgr_zco    : 3D verticl coordinate in pure z-coordinate case
+   !!---------------------------------------------------------------------
+   USE oce            ! ocean variables
+   USE dom_oce        ! ocean domain
+   USE phycst         ! physical constants
+   USE depth_e3       ! depth <=> e3
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_zgr        ! called by domzgr.F90
+
+  !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS             
+
+   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
+      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
+      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
+      &                    pe3t  , pe3u  , pe3v   , pe3f ,             &   ! vertical scale factors
+      &                    pe3w  , pe3uw , pe3vw         ,             &   !     -      -      -
+      &                    k_top  , k_bot    )                             ! top & bottom ocean level
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE usr_def_zgr  ***
+      !!
+      !! ** Purpose :   User defined the vertical coordinates
+      !!
+      !!----------------------------------------------------------------------
+      LOGICAL                   , INTENT(out) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags
+      LOGICAL                   , INTENT(out) ::   ld_isfcav                   ! under iceshelf cavity flag
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pdept, pdepw                ! grid-point depth        [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors 
+      INTEGER , DIMENSION(:,:)  , INTENT(out) ::   k_top, k_bot                ! first & last ocean level
+      !
+      INTEGER  ::   inum   ! local logical unit
+      REAL(WP) ::   z_zco, z_zps, z_sco, z_cav
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_zgr : BENCH configuration (z-coordinate closed flat box ocean)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      !
+      !
+      ! type of vertical coordinate
+      ! ---------------------------
+      ld_zco    = .TRUE.         ! BENCH case:  z-coordinate without ocean cavities
+      ld_zps    = .FALSE.
+      ld_sco    = .FALSE.
+      ld_isfcav = .FALSE.
+      !
+      !
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+      CALL zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
+      !
+      CALL zgr_msk_top_bot( k_top , k_bot )                 ! masked top and bottom ocean t-level indices
+      !
+      !                                                     ! z-coordinate (3D arrays) from the 1D z-coord.
+      CALL zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in  : 1D reference vertical coordinate
+         &          pdept   , pdepw   ,                     &   ! out : 3D t & w-points depth
+         &          pe3t    , pe3u    , pe3v   , pe3f   ,   &   !       vertical scale factors
+         &          pe3w    , pe3uw   , pe3vw             )     !           -      -      -
+      !
+   END SUBROUTINE usr_def_zgr
+
+
+   SUBROUTINE zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z  ***
+      !!
+      !! ** Purpose :   set the 1D depth of model levels and the resulting 
+      !!              vertical scale factors.
+      !!
+      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
+      !!       The depth of model levels is set from dep(k), an analytical function:
+      !!                   w-level: depw_1d  = dep(k)
+      !!                   t-level: dept_1d  = dep(k+0.5)
+      !!       The scale factors are the discrete derivative of the depth:
+      !!                   e3w_1d(jk) = dk[ dept_1d ] 
+      !!                   e3t_1d(jk) = dk[ depw_1d ]
+      !!           with at top and bottom :
+      !!                   e3w_1d( 1 ) = 2 * ( dept_1d( 1 ) - depw_1d( 1 ) )
+      !!                   e3t_1d(jpk) = 2 * ( dept_1d(jpk) - depw_1d(jpk) )
+      !!       The depth are then re-computed from the sum of e3. This ensures 
+      !!    that depths are identical when reading domain configuration file. 
+      !!    Indeed, only e3. are saved in this file, depth are compute by a call
+      !!    to the e3_to_depth subroutine.
+      !!
+      !!       Here the Madec & Imbard (1996) function is used.
+      !!
+      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
+      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!
+      !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+      !!             Madec and Imbard, 1996, Clim. Dyn.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
+      !
+      INTEGER  ::   jk       ! dummy loop indices
+      REAL(wp) ::   zd       ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      zd = 5000./FLOAT(jpkm1)
+      !
+      IF(lwp) THEN            ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z   : Reference vertical z-coordinates '
+         WRITE(numout,*) '    ~~~~~~~'
+         WRITE(numout,*) '       BENCH case : uniform vertical grid :'
+         WRITE(numout,*) '                     with thickness = ', zd
+      ENDIF
+
+      !
+      ! 1D Reference z-coordinate    (using Madec & Imbard 1996 function)
+      ! -------------------------
+      !
+      pdepw_1d(1) = 0._wp
+      pdept_1d(1) = 0.5_wp * zd
+      ! 
+      DO jk = 2, jpk          ! depth at T and W-points
+         pdepw_1d(jk) = pdepw_1d(jk-1) + zd 
+         pdept_1d(jk) = pdept_1d(jk-1) + zd 
+      END DO
+      !
+      !                       ! e3t and e3w from depth
+      CALL depth_to_e3( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d ) 
+      !
+      !                       ! recompute depths from SUM(e3)  <== needed
+      CALL e3_to_depth( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d ) 
+      !
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
+      ENDIF
+      !
+   END SUBROUTINE zgr_z
+
+
+   SUBROUTINE zgr_msk_top_bot( k_top , k_bot )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_msk_top_bot  ***
+      !!
+      !! ** Purpose :   set the masked top and bottom ocean t-levels
+      !!
+      !! ** Method  :   BENCH case = closed flat box ocean without ocean cavities
+      !!                   k_top = 1     except along north, south, east and west boundaries
+      !!                   k_bot = jpk-1 except along north, south, east and west boundaries
+      !!
+      !! ** Action  : - k_top : first wet ocean level index
+      !!              - k_bot : last  wet ocean level index
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(:,:), INTENT(out) ::   k_top , k_bot   ! first & last wet ocean level
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D local workspace
+      REAL(wp)                     ::   zmaxlam, zscl
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_top_bot : defines the top and bottom wet ocean levels.'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '       BENCH case : closed flat box ocean without ocean cavities'
+      !
+      z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
+      !
+      CALL lbc_lnk( "usrdef_zgr", z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      !
+      k_bot(:,:) = INT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
+      !
+      k_top(:,:) = MIN( 1 , k_bot(:,:) )     ! = 1    over the ocean point, =0 elsewhere
+      !
+   END SUBROUTINE zgr_msk_top_bot
+   
+
+   SUBROUTINE zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in : 1D reference vertical coordinate
+      &                pdept   , pdepw   ,                     &   ! out: 3D t & w-points depth
+      &                pe3t    , pe3u    , pe3v   , pe3f   ,   &   !      vertical scale factors
+      &                pe3w    , pe3uw   , pe3vw             )     !          -      -      -
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zco  ***
+      !!
+      !! ** Purpose :   define the reference z-coordinate system
+      !!
+      !! ** Method  :   set 3D coord. arrays to reference 1D array 
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth       [m]
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pe3t_1d , pe3w_1d           ! 1D vertical scale factors [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept, pdepw                ! grid-point depth          [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors    [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3w , pe3uw, pe3vw         !    -       -      -
+      !
+      INTEGER  ::   jk
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         pdept(:,:,jk) = pdept_1d(jk)
+         pdepw(:,:,jk) = pdepw_1d(jk)
+         pe3t (:,:,jk) = pe3t_1d (jk)
+         pe3u (:,:,jk) = pe3t_1d (jk)
+         pe3v (:,:,jk) = pe3t_1d (jk)
+         pe3f (:,:,jk) = pe3t_1d (jk)
+         pe3w (:,:,jk) = pe3w_1d (jk)
+         pe3uw(:,:,jk) = pe3w_1d (jk)
+         pe3vw(:,:,jk) = pe3w_1d (jk)
+      END DO
+      !
+   END SUBROUTINE zgr_zco
+
+   !!======================================================================
+END MODULE usrdef_zgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/zdfiwm.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/zdfiwm.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/MY_SRC/zdfiwm.F90	(revision 10136)
@@ -0,0 +1,482 @@
+MODULE zdfiwm
+   !!========================================================================
+   !!                       ***  MODULE  zdfiwm  ***
+   !! Ocean physics: Internal gravity wave-driven vertical mixing
+   !!========================================================================
+   !! History :  1.0  !  2004-04  (L. Bessieres, G. Madec)  Original code
+   !!             -   !  2006-08  (A. Koch-Larrouy)  Indonesian strait
+   !!            3.3  !  2010-10  (C. Ethe, G. Madec)  reorganisation of initialisation phase
+   !!            3.6  !  2016-03  (C. de Lavergne)  New param: internal wave-driven mixing 
+   !!            4.0  !  2017-04  (G. Madec)  renamed module, remove the old param. and the CPP keys
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_iwm       : global     momentum & tracer Kz with wave induced Kz
+   !!   zdf_iwm_init  : global     momentum & tracer Kz with wave induced Kz
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE zdf_oce        ! ocean vertical physics variables
+   USE zdfddm         ! ocean vertical physics: double diffusive mixing
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE eosbn2         ! ocean equation of state
+   USE phycst         ! physical constants
+   !
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O Manager
+   USE lib_mpp        ! MPP library
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_iwm        ! called in step module 
+   PUBLIC   zdf_iwm_init   ! called in nemogcm module 
+
+   !                      !!* Namelist  namzdf_iwm : internal wave-driven mixing *
+   INTEGER ::  nn_zpyc     ! pycnocline-intensified mixing energy proportional to N (=1) or N^2 (=2)
+   LOGICAL ::  ln_mevar    ! variable (=T) or constant (=F) mixing efficiency
+   LOGICAL ::  ln_tsdiff   ! account for differential T/S wave-driven mixing (=T) or not (=F)
+
+   REAL(wp)::  r1_6 = 1._wp / 6._wp
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ebot_iwm   ! power available from high-mode wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   epyc_iwm   ! power available from low-mode, pycnocline-intensified wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ecri_iwm   ! power available from low-mode, critical slope wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hbot_iwm   ! WKB decay scale for high-mode energy dissipation (m)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hcri_iwm   ! decay scale for low-mode critical slope dissipation (m)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: zdfiwm.F90 8093 2017-05-30 08:13:14Z gm $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION zdf_iwm_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  FUNCTION zdf_iwm_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( ebot_iwm(jpi,jpj),  epyc_iwm(jpi,jpj),  ecri_iwm(jpi,jpj) ,     &
+      &         hbot_iwm(jpi,jpj),  hcri_iwm(jpi,jpj)                     , STAT=zdf_iwm_alloc )
+      !
+      IF( lk_mpp             )   CALL mpp_sum ( zdf_iwm_alloc )
+      IF( zdf_iwm_alloc /= 0 )   CALL ctl_warn('zdf_iwm_alloc: failed to allocate arrays')
+   END FUNCTION zdf_iwm_alloc
+
+
+   SUBROUTINE zdf_iwm( kt, p_avm, p_avt, p_avs )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm  ***
+      !!                   
+      !! ** Purpose :   add to the vertical mixing coefficients the effect of
+      !!              breaking internal waves.
+      !!
+      !! ** Method  : - internal wave-driven vertical mixing is given by:
+      !!                  Kz_wave = min(  100 cm2/s, f(  Reb = zemx_iwm /( Nu * N^2 )  )
+      !!              where zemx_iwm is the 3D space distribution of the wave-breaking 
+      !!              energy and Nu the molecular kinematic viscosity.
+      !!              The function f(Reb) is linear (constant mixing efficiency)
+      !!              if the namelist parameter ln_mevar = F and nonlinear if ln_mevar = T.
+      !!
+      !!              - Compute zemx_iwm, the 3D power density that allows to compute
+      !!              Reb and therefrom the wave-induced vertical diffusivity.
+      !!              This is divided into three components:
+      !!                 1. Bottom-intensified low-mode dissipation at critical slopes
+      !!                     zemx_iwm(z) = ( ecri_iwm / rau0 ) * EXP( -(H-z)/hcri_iwm )
+      !!                                   / ( 1. - EXP( - H/hcri_iwm ) ) * hcri_iwm
+      !!              where hcri_iwm is the characteristic length scale of the bottom 
+      !!              intensification, ecri_iwm a map of available power, and H the ocean depth.
+      !!                 2. Pycnocline-intensified low-mode dissipation
+      !!                     zemx_iwm(z) = ( epyc_iwm / rau0 ) * ( sqrt(rn2(z))^nn_zpyc )
+      !!                                   / SUM( sqrt(rn2(z))^nn_zpyc * e3w(z) )
+      !!              where epyc_iwm is a map of available power, and nn_zpyc
+      !!              is the chosen stratification-dependence of the internal wave
+      !!              energy dissipation.
+      !!                 3. WKB-height dependent high mode dissipation
+      !!                     zemx_iwm(z) = ( ebot_iwm / rau0 ) * rn2(z) * EXP(-z_wkb(z)/hbot_iwm)
+      !!                                   / SUM( rn2(z) * EXP(-z_wkb(z)/hbot_iwm) * e3w(z) )
+      !!              where hbot_iwm is the characteristic length scale of the WKB bottom 
+      !!              intensification, ebot_iwm is a map of available power, and z_wkb is the
+      !!              WKB-stretched height above bottom defined as
+      !!                    z_wkb(z) = H * SUM( sqrt(rn2(z'>=z)) * e3w(z'>=z) )
+      !!                                 / SUM( sqrt(rn2(z'))    * e3w(z')    )
+      !!
+      !!              - update the model vertical eddy viscosity and diffusivity: 
+      !!                     avt  = avt  +    av_wave
+      !!                     avm  = avm  +    av_wave
+      !!
+      !!              - if namelist parameter ln_tsdiff = T, account for differential mixing:
+      !!                     avs  = avt  +    av_wave * diffusivity_ratio(Reb)
+      !!
+      !! ** Action  : - avt, avs, avm, increased by tide internal wave-driven mixing    
+      !!
+      !! References :  de Lavergne et al. 2015, JPO; 2016, in prep.
+      !!----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kt             ! ocean time step
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avm          ! momentum Kz (w-points)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avt, p_avs   ! tracer   Kz (w-points)
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zztmp        ! scalar workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zfact       ! Used for vertical structure
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhdep       ! Ocean depth
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwkb        ! WKB-stretched height above bottom
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zweight     ! Weight for high mode vertical distribution
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_t       ! Molecular kinematic viscosity (T grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_w       ! Molecular kinematic viscosity (W grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zReb        ! Turbulence intensity parameter
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zemx_iwm    ! local energy density available for mixing (W/kg)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_ratio   ! S/T diffusivity ratio (only for ln_tsdiff=T)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_wave    ! Internal wave-induced diffusivity
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   z3d  ! 3D workspace used for iom_put 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   z2d  ! 2D     -      -    -     -
+      !!----------------------------------------------------------------------
+      !
+      !                       !* Set to zero the 1st and last vertical levels of appropriate variables
+      zemx_iwm (:,:,1) = 0._wp   ;   zemx_iwm (:,:,jpk) = 0._wp
+      zav_ratio(:,:,1) = 0._wp   ;   zav_ratio(:,:,jpk) = 0._wp
+      zav_wave (:,:,1) = 0._wp   ;   zav_wave (:,:,jpk) = 0._wp
+      !
+      !                       ! ----------------------------- !
+      !                       !  Internal wave-driven mixing  !  (compute zav_wave)
+      !                       ! ----------------------------- !
+      !                             
+      !                       !* Critical slope mixing: distribute energy over the time-varying ocean depth,
+      !                                                 using an exponential decay from the seafloor.
+      DO jj = 1, jpj                ! part independent of the level
+         DO ji = 1, jpi
+            zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
+            zfact(ji,jj) = rau0 * (  1._wp - EXP( -zhdep(ji,jj) / hcri_iwm(ji,jj) )  )
+            IF( zfact(ji,jj) /= 0._wp )   zfact(ji,jj) = ecri_iwm(ji,jj) / zfact(ji,jj)
+         END DO
+      END DO
+!!gm gde3w ==>>>  check for ssh taken into account.... seem OK gde3w_n=gdept_n - sshn
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zfact(:,:) * (  EXP( ( gde3w_n(:,:,jk  ) - zhdep(:,:) ) / hcri_iwm(:,:) )                      &
+            &                             - EXP( ( gde3w_n(:,:,jk-1) - zhdep(:,:) ) / hcri_iwm(:,:) )  ) * wmask(:,:,jk)   &
+            &                          / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+
+!!gm delta(gde3w_n) = e3t_n  !!  Please verify the grid-point position w versus t-point
+!!gm it seems to me that only 1/hcri_iwm  is used ==>  compute it one for all
+
+      END DO
+
+      !                        !* Pycnocline-intensified mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to sqrt(rn2)^nn_zpyc
+      !                                          ! (NB: N2 is masked, so no use of wmask here)
+      SELECT CASE ( nn_zpyc )
+      !
+      CASE ( 1 )               ! Dissipation scales as N (recommended)
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+      CASE ( 2 )               ! Dissipation scales as N^2
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj= 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+      END SELECT
+
+      !                        !* WKB-height dependent mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to rn2 * exp(-z_wkb/rn_hbot)
+      !
+      zwkb (:,:,:) = 0._wp
+      zfact(:,:)   = 0._wp
+      DO jk = 2, jpkm1
+         zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         zwkb(:,:,jk) = zfact(:,:)
+      END DO
+!!gm even better:
+!      DO jk = 2, jpkm1
+!         zwkb(:,:) = zwkb(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  )
+!      END DO
+!      zfact(:,:) = zwkb(:,:,jpkm1)
+!!gm or just use zwkb(k=jpk-1) instead of zfact...
+!!gm
+      !
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zwkb(ji,jj,jk) = zhdep(ji,jj) * ( zfact(ji,jj) - zwkb(ji,jj,jk) )   &
+                  &                                     * wmask(ji,jj,jk) / zfact(ji,jj)
+            END DO
+         END DO
+      END DO
+      zwkb(:,:,1) = zhdep(:,:) * wmask(:,:,1)
+      !
+      zweight(:,:,:) = 0._wp
+      DO jk = 2, jpkm1
+         zweight(:,:,jk) = MAX( 0._wp, rn2(:,:,jk) ) * hbot_iwm(:,:) * wmask(:,:,jk)                    &
+            &   * (  EXP( -zwkb(:,:,jk) / hbot_iwm(:,:) ) - EXP( -zwkb(:,:,jk-1) / hbot_iwm(:,:) )  )
+      END DO
+      !
+      zfact(:,:) = 0._wp
+      DO jk = 2, jpkm1              ! part independent of the level
+         zfact(:,:) = zfact(:,:) + zweight(:,:,jk)
+      END DO
+      !
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = ebot_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+         END DO
+      END DO
+      !
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zweight(:,:,jk) * zfact(:,:) * wmask(:,:,jk)   &
+            &                                / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+!!gm  use of e3t_n just above?
+      END DO
+      !
+!!gm  this is to be replaced by just a constant value znu=1.e-6 m2/s
+      ! Calculate molecular kinematic viscosity
+      znu_t(:,:,:) = 1.e-4_wp * (  17.91_wp - 0.53810_wp * tsn(:,:,:,jp_tem) + 0.00694_wp * tsn(:,:,:,jp_tem) * tsn(:,:,:,jp_tem)  &
+         &                                  + 0.02305_wp * tsn(:,:,:,jp_sal)  ) * tmask(:,:,:) * r1_rau0
+      DO jk = 2, jpkm1
+         znu_w(:,:,jk) = 0.5_wp * ( znu_t(:,:,jk-1) + znu_t(:,:,jk) ) * wmask(:,:,jk)
+      END DO
+!!gm end
+      !
+      ! Calculate turbulence intensity parameter Reb
+      DO jk = 2, jpkm1
+         zReb(:,:,jk) = zemx_iwm(:,:,jk) / MAX( 1.e-20_wp, znu_w(:,:,jk) * rn2(:,:,jk) )
+      END DO
+      !
+      ! Define internal wave-induced diffusivity
+      DO jk = 2, jpkm1
+         zav_wave(:,:,jk) = znu_w(:,:,jk) * zReb(:,:,jk) * r1_6   ! This corresponds to a constant mixing efficiency of 1/6
+      END DO
+      !
+      IF( ln_mevar ) THEN              ! Variable mixing efficiency case : modify zav_wave in the
+         DO jk = 2, jpkm1              ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( zReb(ji,jj,jk) > 480.00_wp ) THEN
+                     zav_wave(ji,jj,jk) = 3.6515_wp * znu_w(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ELSEIF( zReb(ji,jj,jk) < 10.224_wp ) THEN
+                     zav_wave(ji,jj,jk) = 0.052125_wp * znu_w(ji,jj,jk) * zReb(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jk = 2, jpkm1                 ! Bound diffusivity by molecular value and 100 cm2/s
+         zav_wave(:,:,jk) = MIN(  MAX( 1.4e-7_wp, zav_wave(:,:,jk) ), 1.e-2_wp  ) * wmask(:,:,jk)
+      END DO
+      !
+      IF( kt == nit000 ) THEN        !* Control print at first time-step: diagnose the energy consumed by zav_wave
+         zztmp = 0._wp
+!!gm used of glosum 3D....
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zztmp = zztmp + e3w_n(ji,jj,jk) * e1e2t(ji,jj)   &
+                     &          * MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( zztmp )
+         zztmp = rau0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'zdf_iwm : Internal wave-driven mixing (iwm)'
+            WRITE(numout,*) '~~~~~~~ '
+            WRITE(numout,*)
+            WRITE(numout,*) '      Total power consumption by av_wave =  ', zztmp * 1.e-12_wp, 'TW'
+         ENDIF
+      ENDIF
+
+      !                          ! ----------------------- !
+      !                          !   Update  mixing coefs  !                          
+      !                          ! ----------------------- !
+      !      
+      IF( ln_tsdiff ) THEN          !* Option for differential mixing of salinity and temperature
+         DO jk = 2, jpkm1              ! Calculate S/T diffusivity ratio as a function of Reb
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zav_ratio(ji,jj,jk) = ( 0.505_wp + 0.495_wp *                                                                  &
+                      &   TANH(    0.92_wp * (   LOG10(  MAX( 1.e-20_wp, zReb(ji,jj,jk) * 5._wp * r1_6 )  ) - 0.60_wp   )    )   &
+                      &                 ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "av_ratio", zav_ratio )
+         DO jk = 2, jpkm1           !* update momentum & tracer diffusivity with wave-driven mixing
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk) * zav_ratio(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+         !
+      ELSE                          !* update momentum & tracer diffusivity with wave-driven mixing
+         DO jk = 2, jpkm1
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+      ENDIF
+
+      !                             !* output internal wave-driven mixing coefficient
+      CALL iom_put( "av_wave", zav_wave )
+                                    !* output useful diagnostics: Kz*N^2 , 
+!!gm Kz*N2 should take into account the ratio avs/avt if it is used.... (see diaar5)
+                                    !  vertical integral of rau0 * Kz * N^2 , energy density (zemx_iwm)
+      IF( iom_use("bflx_iwm") .OR. iom_use("pcmap_iwm") ) THEN
+         ALLOCATE( z2d(jpi,jpj) , z3d(jpi,jpj,jpk) )
+         z3d(:,:,:) = MAX( 0._wp, rn2(:,:,:) ) * zav_wave(:,:,:)
+         z2d(:,:) = 0._wp
+         DO jk = 2, jpkm1
+            z2d(:,:) = z2d(:,:) + e3w_n(:,:,jk) * z3d(:,:,jk) * wmask(:,:,jk)
+         END DO
+         z2d(:,:) = rau0 * z2d(:,:)
+         CALL iom_put( "bflx_iwm", z3d )
+         CALL iom_put( "pcmap_iwm", z2d )
+         DEALLOCATE( z2d , z3d )
+      ENDIF
+      CALL iom_put( "emix_iwm", zemx_iwm )
+      
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_wave , clinfo1=' iwm - av_wave: ', tab3d_2=avt, clinfo2=' avt: ', kdim=jpk)
+      !
+   END SUBROUTINE zdf_iwm
+
+
+   SUBROUTINE zdf_iwm_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the wave-driven vertical mixing, reading
+      !!              of input power maps and decay length scales in netcdf files.
+      !!
+      !! ** Method  : - Read the namzdf_iwm namelist and check the parameters
+      !!
+      !!              - Read the input data in NetCDF files :
+      !!              power available from high-mode wave breaking (mixing_power_bot.nc)
+      !!              power available from pycnocline-intensified wave-breaking (mixing_power_pyc.nc)
+      !!              power available from critical slope wave-breaking (mixing_power_cri.nc)
+      !!              WKB decay scale for high-mode wave-breaking (decay_scale_bot.nc)
+      !!              decay scale for critical slope wave-breaking (decay_scale_cri.nc)
+      !!
+      !! ** input   : - Namlist namzdf_iwm
+      !!              - NetCDF files : mixing_power_bot.nc, mixing_power_pyc.nc, mixing_power_cri.nc,
+      !!              decay_scale_bot.nc decay_scale_cri.nc
+      !!
+      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
+      !!              - Define ebot_iwm, epyc_iwm, ecri_iwm, hbot_iwm, hcri_iwm
+      !!
+      !! References : de Lavergne et al. JPO, 2015 ; de Lavergne PhD 2016
+      !!              de Lavergne et al. in prep., 2017
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   inum         ! local integer
+      INTEGER  ::   ios
+      REAL(wp) ::   zbot, zpyc, zcri   ! local scalars
+      !!
+      NAMELIST/namzdf_iwm/ nn_zpyc, ln_mevar, ln_tsdiff
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist namzdf_iwm in reference namelist : Wave-driven mixing
+      READ  ( numnam_ref, namzdf_iwm, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namzdf_iwm in configuration namelist : Wave-driven mixing
+      READ  ( numnam_cfg, namzdf_iwm, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namzdf_iwm )
+      !
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_iwm_init : internal wave-driven mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_iwm : set wave-driven mixing parameters'
+         WRITE(numout,*) '      Pycnocline-intensified diss. scales as N (=1) or N^2 (=2) = ', nn_zpyc
+         WRITE(numout,*) '      Variable (T) or constant (F) mixing efficiency            = ', ln_mevar
+         WRITE(numout,*) '      Differential internal wave-driven mixing (T) or not (F)   = ', ln_tsdiff
+      ENDIF
+      
+      ! The new wave-driven mixing parameterization elevates avt and avm in the interior, and
+      ! ensures that avt remains larger than its molecular value (=1.4e-7). Therefore, avtb should 
+      ! be set here to a very small value, and avmb to its (uniform) molecular value (=1.4e-6).
+      avmb(:) = 1.4e-6_wp        ! viscous molecular value
+      avtb(:) = 1.e-10_wp        ! very small diffusive minimum (background avt is specified in zdf_iwm)    
+      avtb_2d(:,:) = 1.e0_wp     ! uniform 
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Force the background value applied to avm & avt in TKE to be everywhere ',   &
+            &               'the viscous molecular value & a very small diffusive value, resp.'
+      ENDIF
+            
+      !                             ! allocate iwm arrays
+      IF( zdf_iwm_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_iwm_init : unable to allocate iwm arrays' )
+      !
+      !                             ! read necessary fields
+!!$      CALL iom_open('mixing_power_bot',inum)       ! energy flux for high-mode wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ebot_iwm, 1 ) 
+!!$      CALL iom_close(inum)
+      ebot_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_pyc',inum)       ! energy flux for pynocline-intensified wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', epyc_iwm, 1 )
+!!$      CALL iom_close(inum)
+      epyc_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_cri',inum)       ! energy flux for critical slope wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ecri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      ecri_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('decay_scale_bot',inum)        ! spatially variable decay scale for high-mode wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hbot_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hbot_iwm(:,:) = 1.
+      !
+!!$      CALL iom_open('decay_scale_cri',inum)        ! spatially variable decay scale for critical slope wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hcri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hcri_iwm(:,:) = 1.
+
+      ebot_iwm(:,:) = ebot_iwm(:,:) * ssmask(:,:)
+      epyc_iwm(:,:) = epyc_iwm(:,:) * ssmask(:,:)
+      ecri_iwm(:,:) = ecri_iwm(:,:) * ssmask(:,:)
+
+      zbot = glob_sum( e1e2t(:,:) * ebot_iwm(:,:) )
+      zpyc = glob_sum( e1e2t(:,:) * epyc_iwm(:,:) )
+      zcri = glob_sum( e1e2t(:,:) * ecri_iwm(:,:) )
+      IF(lwp) THEN
+         WRITE(numout,*) '      High-mode wave-breaking energy:             ', zbot * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Pycnocline-intensifed wave-breaking energy: ', zpyc * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Critical slope wave-breaking energy:        ', zcri * 1.e-12_wp, 'TW'
+      ENDIF
+      !
+   END SUBROUTINE zdf_iwm_init
+
+   !!======================================================================
+END MODULE zdfiwm
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/cpp_BENCH_1.fcm
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/cpp_BENCH_1.fcm	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_1/cpp_BENCH_1.fcm	(revision 10136)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys  key_mpp_mpi  
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/best_jpni_jpnj_eorca12
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/best_jpni_jpnj_eorca12	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/best_jpni_jpnj_eorca12	(revision 10136)
@@ -0,0 +1,1301 @@
+    nb_cores 1 ( 1 x 1 ), nb_points 13601334 ( 4322 x 3147 )
+    nb_cores 2 ( 2 x 1 ), nb_points 6803814 ( 2162 x 3147 )
+    nb_cores 3 ( 3 x 1 ), nb_points 4537974 ( 1442 x 3147 )
+    nb_cores 4 ( 4 x 1 ), nb_points 3405054 ( 1082 x 3147 )
+    nb_cores 5 ( 5 x 1 ), nb_points 2725302 ( 866 x 3147 )
+    nb_cores 6 ( 3 x 2 ), nb_points 2271150 ( 1442 x 1575 )
+    nb_cores 7 ( 7 x 1 ), nb_points 1951140 ( 620 x 3147 )
+    nb_cores 8 ( 4 x 2 ), nb_points 1704150 ( 1082 x 1575 )
+    nb_cores 9 ( 3 x 3 ), nb_points 1515542 ( 1442 x 1051 )
+    nb_cores 10 ( 5 x 2 ), nb_points 1363950 ( 866 x 1575 )
+    nb_cores 11 ( 11 x 1 ), nb_points 1243065 ( 395 x 3147 )
+    nb_cores 12 ( 6 x 2 ), nb_points 1137150 ( 722 x 1575 )
+    nb_cores 13 ( 13 x 1 ), nb_points 1054245 ( 335 x 3147 )
+    nb_cores 14 ( 7 x 2 ), nb_points 976500 ( 620 x 1575 )
+    nb_cores 15 ( 3 x 5 ), nb_points 909902 ( 1442 x 631 )
+    nb_cores 16 ( 8 x 2 ), nb_points 853650 ( 542 x 1575 )
+    nb_cores 17 ( 1 x 17 ), nb_points 808214 ( 4322 x 187 )
+    nb_cores 18 ( 6 x 3 ), nb_points 758822 ( 722 x 1051 )
+    nb_cores 19 ( 19 x 1 ), nb_points 723810 ( 230 x 3147 )
+    nb_cores 20 ( 4 x 5 ), nb_points 682742 ( 1082 x 631 )
+    nb_cores 21 ( 7 x 3 ), nb_points 651620 ( 620 x 1051 )
+    nb_cores 22 ( 11 x 2 ), nb_points 622125 ( 395 x 1575 )
+    nb_cores 23 ( 23 x 1 ), nb_points 597930 ( 190 x 3147 )
+    nb_cores 24 ( 8 x 3 ), nb_points 569642 ( 542 x 1051 )
+    nb_cores 25 ( 5 x 5 ), nb_points 546446 ( 866 x 631 )
+    nb_cores 26 ( 2 x 13 ), nb_points 527528 ( 2162 x 244 )
+    nb_cores 27 ( 9 x 3 ), nb_points 506582 ( 482 x 1051 )
+    nb_cores 28 ( 4 x 7 ), nb_points 489064 ( 1082 x 452 )
+    nb_cores 29 ( 29 x 1 ), nb_points 475197 ( 151 x 3147 )
+    nb_cores 30 ( 6 x 5 ), nb_points 455582 ( 722 x 631 )
+    nb_cores 31 ( 31 x 1 ), nb_points 446874 ( 142 x 3147 )
+    nb_cores 32 ( 8 x 4 ), nb_points 427638 ( 542 x 789 )
+    nb_cores 33 ( 11 x 3 ), nb_points 415145 ( 395 x 1051 )
+    nb_cores 34 ( 2 x 17 ), nb_points 404294 ( 2162 x 187 )
+    nb_cores 35 ( 7 x 5 ), nb_points 391220 ( 620 x 631 )
+    nb_cores 36 ( 9 x 4 ), nb_points 380298 ( 482 x 789 )
+    nb_cores 37 ( 37 x 1 ), nb_points 374493 ( 119 x 3147 )
+    nb_cores 38 ( 19 x 2 ), nb_points 362250 ( 230 x 1575 )
+    nb_cores 39 ( 3 x 13 ), nb_points 351848 ( 1442 x 244 )
+    nb_cores 40 ( 8 x 5 ), nb_points 342002 ( 542 x 631 )
+    nb_cores 41 ( 41 x 1 ), nb_points 339876 ( 108 x 3147 )
+    nb_cores 42 ( 6 x 7 ), nb_points 326344 ( 722 x 452 )
+    nb_cores 43 ( 43 x 1 ), nb_points 324141 ( 103 x 3147 )
+    nb_cores 44 ( 4 x 11 ), nb_points 311616 ( 1082 x 288 )
+    nb_cores 45 ( 9 x 5 ), nb_points 304142 ( 482 x 631 )
+    nb_cores 46 ( 23 x 2 ), nb_points 299250 ( 190 x 1575 )
+    nb_cores 47 ( 47 x 1 ), nb_points 295818 ( 94 x 3147 )
+    nb_cores 48 ( 12 x 4 ), nb_points 285618 ( 362 x 789 )
+    nb_cores 49 ( 7 x 7 ), nb_points 280240 ( 620 x 452 )
+    nb_cores 50 ( 10 x 5 ), nb_points 273854 ( 434 x 631 )
+    nb_cores 51 ( 3 x 17 ), nb_points 269654 ( 1442 x 187 )
+    nb_cores 52 ( 4 x 13 ), nb_points 264008 ( 1082 x 244 )
+    nb_cores 54 ( 9 x 6 ), nb_points 254014 ( 482 x 527 )
+    nb_cores 55 ( 11 x 5 ), nb_points 249245 ( 395 x 631 )
+    nb_cores 56 ( 8 x 7 ), nb_points 244984 ( 542 x 452 )
+    nb_cores 57 ( 19 x 3 ), nb_points 241730 ( 230 x 1051 )
+    nb_cores 58 ( 29 x 2 ), nb_points 237825 ( 151 x 1575 )
+    nb_cores 60 ( 12 x 5 ), nb_points 228422 ( 362 x 631 )
+    nb_cores 62 ( 31 x 2 ), nb_points 223650 ( 142 x 1575 )
+    nb_cores 63 ( 9 x 7 ), nb_points 217864 ( 482 x 452 )
+    nb_cores 64 ( 16 x 4 ), nb_points 214608 ( 272 x 789 )
+    nb_cores 65 ( 5 x 13 ), nb_points 211304 ( 866 x 244 )
+    nb_cores 66 ( 6 x 11 ), nb_points 207936 ( 722 x 288 )
+    nb_cores 68 ( 4 x 17 ), nb_points 202334 ( 1082 x 187 )
+    nb_cores 69 ( 23 x 3 ), nb_points 199690 ( 190 x 1051 )
+    nb_cores 70 ( 10 x 7 ), nb_points 196168 ( 434 x 452 )
+    nb_cores 72 ( 12 x 6 ), nb_points 190774 ( 362 x 527 )
+    nb_cores 74 ( 37 x 2 ), nb_points 187425 ( 119 x 1575 )
+    nb_cores 75 ( 15 x 5 ), nb_points 182990 ( 290 x 631 )
+    nb_cores 76 ( 19 x 4 ), nb_points 181470 ( 230 x 789 )
+    nb_cores 77 ( 11 x 7 ), nb_points 178540 ( 395 x 452 )
+    nb_cores 78 ( 6 x 13 ), nb_points 176168 ( 722 x 244 )
+    nb_cores 80 ( 16 x 5 ), nb_points 171632 ( 272 x 631 )
+    nb_cores 81 ( 9 x 9 ), nb_points 169664 ( 482 x 352 )
+    nb_cores 84 ( 12 x 7 ), nb_points 163624 ( 362 x 452 )
+    nb_cores 85 ( 5 x 17 ), nb_points 161942 ( 866 x 187 )
+    nb_cores 87 ( 29 x 3 ), nb_points 158701 ( 151 x 1051 )
+    nb_cores 88 ( 8 x 11 ), nb_points 156096 ( 542 x 288 )
+    nb_cores 90 ( 18 x 5 ), nb_points 152702 ( 242 x 631 )
+    nb_cores 91 ( 7 x 13 ), nb_points 151280 ( 620 x 244 )
+    nb_cores 92 ( 23 x 4 ), nb_points 149910 ( 190 x 789 )
+    nb_cores 93 ( 31 x 3 ), nb_points 149242 ( 142 x 1051 )
+    nb_cores 94 ( 47 x 2 ), nb_points 148050 ( 94 x 1575 )
+    nb_cores 95 ( 19 x 5 ), nb_points 145130 ( 230 x 631 )
+    nb_cores 96 ( 16 x 6 ), nb_points 143344 ( 272 x 527 )
+    nb_cores 98 ( 14 x 7 ), nb_points 140572 ( 311 x 452 )
+    nb_cores 99 ( 9 x 11 ), nb_points 138816 ( 482 x 288 )
+    nb_cores 100 ( 20 x 5 ), nb_points 137558 ( 218 x 631 )
+    nb_cores 102 ( 6 x 17 ), nb_points 135014 ( 722 x 187 )
+    nb_cores 104 ( 8 x 13 ), nb_points 132248 ( 542 x 244 )
+    nb_cores 105 ( 15 x 7 ), nb_points 131080 ( 290 x 452 )
+    nb_cores 108 ( 12 x 9 ), nb_points 127424 ( 362 x 352 )
+    nb_cores 110 ( 10 x 11 ), nb_points 124992 ( 434 x 288 )
+    nb_cores 112 ( 16 x 7 ), nb_points 122944 ( 272 x 452 )
+    nb_cores 114 ( 19 x 6 ), nb_points 121210 ( 230 x 527 )
+    nb_cores 115 ( 23 x 5 ), nb_points 119890 ( 190 x 631 )
+    nb_cores 116 ( 29 x 4 ), nb_points 119139 ( 151 x 789 )
+    nb_cores 117 ( 9 x 13 ), nb_points 117608 ( 482 x 244 )
+    nb_cores 119 ( 7 x 17 ), nb_points 115940 ( 620 x 187 )
+    nb_cores 120 ( 12 x 10 ), nb_points 114754 ( 362 x 317 )
+    nb_cores 121 ( 11 x 11 ), nb_points 113760 ( 395 x 288 )
+    nb_cores 123 ( 41 x 3 ), nb_points 113508 ( 108 x 1051 )
+    nb_cores 124 ( 31 x 4 ), nb_points 112038 ( 142 x 789 )
+    nb_cores 125 ( 25 x 5 ), nb_points 110425 ( 175 x 631 )
+    nb_cores 126 ( 18 x 7 ), nb_points 109384 ( 242 x 452 )
+    nb_cores 128 ( 16 x 8 ), nb_points 107712 ( 272 x 396 )
+    nb_cores 130 ( 10 x 13 ), nb_points 105896 ( 434 x 244 )
+    nb_cores 132 ( 12 x 11 ), nb_points 104256 ( 362 x 288 )
+    nb_cores 133 ( 19 x 7 ), nb_points 103960 ( 230 x 452 )
+    nb_cores 135 ( 15 x 9 ), nb_points 102080 ( 290 x 352 )
+    nb_cores 136 ( 8 x 17 ), nb_points 101354 ( 542 x 187 )
+    nb_cores 138 ( 23 x 6 ), nb_points 100130 ( 190 x 527 )
+    nb_cores 140 ( 10 x 14 ), nb_points 98518 ( 434 x 227 )
+    nb_cores 143 ( 11 x 13 ), nb_points 96380 ( 395 x 244 )
+    nb_cores 144 ( 16 x 9 ), nb_points 95744 ( 272 x 352 )
+    nb_cores 145 ( 29 x 5 ), nb_points 95281 ( 151 x 631 )
+    nb_cores 147 ( 21 x 7 ), nb_points 94016 ( 208 x 452 )
+    nb_cores 148 ( 37 x 4 ), nb_points 93891 ( 119 x 789 )
+    nb_cores 150 ( 15 x 10 ), nb_points 91930 ( 290 x 317 )
+    nb_cores 152 ( 8 x 19 ), nb_points 91056 ( 542 x 168 )
+    nb_cores 153 ( 9 x 17 ), nb_points 90134 ( 482 x 187 )
+    nb_cores 154 ( 14 x 11 ), nb_points 89568 ( 311 x 288 )
+    nb_cores 156 ( 12 x 13 ), nb_points 88328 ( 362 x 244 )
+    nb_cores 159 ( 53 x 3 ), nb_points 88284 ( 84 x 1051 )
+    nb_cores 160 ( 16 x 10 ), nb_points 86224 ( 272 x 317 )
+    nb_cores 161 ( 23 x 7 ), nb_points 85880 ( 190 x 452 )
+    nb_cores 162 ( 18 x 9 ), nb_points 85184 ( 242 x 352 )
+    nb_cores 165 ( 15 x 11 ), nb_points 83520 ( 290 x 288 )
+    nb_cores 168 ( 12 x 14 ), nb_points 82174 ( 362 x 227 )
+    nb_cores 169 ( 13 x 13 ), nb_points 81740 ( 335 x 244 )
+    nb_cores 170 ( 10 x 17 ), nb_points 81158 ( 434 x 187 )
+    nb_cores 171 ( 19 x 9 ), nb_points 80960 ( 230 x 352 )
+    nb_cores 174 ( 29 x 6 ), nb_points 79577 ( 151 x 527 )
+    nb_cores 175 ( 25 x 7 ), nb_points 79100 ( 175 x 452 )
+    nb_cores 176 ( 16 x 11 ), nb_points 78336 ( 272 x 288 )
+    nb_cores 180 ( 18 x 10 ), nb_points 76714 ( 242 x 317 )
+    nb_cores 182 ( 14 x 13 ), nb_points 75884 ( 311 x 244 )
+    nb_cores 184 ( 23 x 8 ), nb_points 75240 ( 190 x 396 )
+    nb_cores 185 ( 37 x 5 ), nb_points 75089 ( 119 x 631 )
+    nb_cores 186 ( 31 x 6 ), nb_points 74834 ( 142 x 527 )
+    nb_cores 187 ( 11 x 17 ), nb_points 73865 ( 395 x 187 )
+    nb_cores 189 ( 21 x 9 ), nb_points 73216 ( 208 x 352 )
+    nb_cores 190 ( 19 x 10 ), nb_points 72910 ( 230 x 317 )
+    nb_cores 192 ( 12 x 16 ), nb_points 72038 ( 362 x 199 )
+    nb_cores 195 ( 15 x 13 ), nb_points 70760 ( 290 x 244 )
+    nb_cores 196 ( 14 x 14 ), nb_points 70597 ( 311 x 227 )
+    nb_cores 198 ( 18 x 11 ), nb_points 69696 ( 242 x 288 )
+    nb_cores 200 ( 20 x 10 ), nb_points 69106 ( 218 x 317 )
+    nb_cores 203 ( 29 x 7 ), nb_points 68252 ( 151 x 452 )
+    nb_cores 204 ( 12 x 17 ), nb_points 67694 ( 362 x 187 )
+    nb_cores 207 ( 23 x 9 ), nb_points 66880 ( 190 x 352 )
+    nb_cores 208 ( 16 x 13 ), nb_points 66368 ( 272 x 244 )
+    nb_cores 209 ( 19 x 11 ), nb_points 66240 ( 230 x 288 )
+    nb_cores 210 ( 15 x 14 ), nb_points 65830 ( 290 x 227 )
+    nb_cores 215 ( 43 x 5 ), nb_points 64993 ( 103 x 631 )
+    nb_cores 216 ( 24 x 9 ), nb_points 64064 ( 182 x 352 )
+    nb_cores 220 ( 20 x 11 ), nb_points 62784 ( 218 x 288 )
+    nb_cores 221 ( 13 x 17 ), nb_points 62645 ( 335 x 187 )
+    nb_cores 224 ( 16 x 14 ), nb_points 61744 ( 272 x 227 )
+    nb_cores 225 ( 15 x 15 ), nb_points 61480 ( 290 x 212 )
+    nb_cores 228 ( 12 x 19 ), nb_points 60816 ( 362 x 168 )
+    nb_cores 230 ( 23 x 10 ), nb_points 60230 ( 190 x 317 )
+    nb_cores 231 ( 21 x 11 ), nb_points 59904 ( 208 x 288 )
+    nb_cores 232 ( 29 x 8 ), nb_points 59796 ( 151 x 396 )
+    nb_cores 234 ( 18 x 13 ), nb_points 59048 ( 242 x 244 )
+    nb_cores 238 ( 14 x 17 ), nb_points 58157 ( 311 x 187 )
+    nb_cores 240 ( 16 x 15 ), nb_points 57664 ( 272 x 212 )
+    nb_cores 242 ( 11 x 22 ), nb_points 57275 ( 395 x 145 )
+    nb_cores 243 ( 27 x 9 ), nb_points 57024 ( 162 x 352 )
+    nb_cores 245 ( 35 x 7 ), nb_points 56952 ( 126 x 452 )
+    nb_cores 246 ( 41 x 6 ), nb_points 56916 ( 108 x 527 )
+    nb_cores 247 ( 19 x 13 ), nb_points 56120 ( 230 x 244 )
+    nb_cores 250 ( 25 x 10 ), nb_points 55475 ( 175 x 317 )
+    nb_cores 252 ( 18 x 14 ), nb_points 54934 ( 242 x 227 )
+    nb_cores 253 ( 23 x 11 ), nb_points 54720 ( 190 x 288 )
+    nb_cores 255 ( 15 x 17 ), nb_points 54230 ( 290 x 187 )
+    nb_cores 256 ( 16 x 16 ), nb_points 54128 ( 272 x 199 )
+    nb_cores 259 ( 37 x 7 ), nb_points 53788 ( 119 x 452 )
+    nb_cores 260 ( 20 x 13 ), nb_points 53192 ( 218 x 244 )
+    nb_cores 261 ( 29 x 9 ), nb_points 53152 ( 151 x 352 )
+    nb_cores 264 ( 24 x 11 ), nb_points 52416 ( 182 x 288 )
+    nb_cores 266 ( 19 x 14 ), nb_points 52210 ( 230 x 227 )
+    nb_cores 270 ( 18 x 15 ), nb_points 51304 ( 242 x 212 )
+    nb_cores 272 ( 16 x 17 ), nb_points 50864 ( 272 x 187 )
+    nb_cores 273 ( 21 x 13 ), nb_points 50752 ( 208 x 244 )
+    nb_cores 275 ( 25 x 11 ), nb_points 50400 ( 175 x 288 )
+    nb_cores 276 ( 12 x 23 ), nb_points 50318 ( 362 x 139 )
+    nb_cores 279 ( 31 x 9 ), nb_points 49984 ( 142 x 352 )
+    nb_cores 280 ( 20 x 14 ), nb_points 49486 ( 218 x 227 )
+    nb_cores 285 ( 15 x 19 ), nb_points 48720 ( 290 x 168 )
+    nb_cores 286 ( 22 x 13 ), nb_points 48556 ( 199 x 244 )
+    nb_cores 288 ( 16 x 18 ), nb_points 48144 ( 272 x 177 )
+    nb_cores 289 ( 17 x 17 ), nb_points 48059 ( 257 x 187 )
+    nb_cores 290 ( 29 x 10 ), nb_points 47867 ( 151 x 317 )
+    nb_cores 294 ( 21 x 14 ), nb_points 47216 ( 208 x 227 )
+    nb_cores 296 ( 37 x 8 ), nb_points 47124 ( 119 x 396 )
+    nb_cores 297 ( 27 x 11 ), nb_points 46656 ( 162 x 288 )
+    nb_cores 299 ( 23 x 13 ), nb_points 46360 ( 190 x 244 )
+    nb_cores 300 ( 20 x 15 ), nb_points 46216 ( 218 x 212 )
+    nb_cores 304 ( 16 x 19 ), nb_points 45696 ( 272 x 168 )
+    nb_cores 306 ( 18 x 17 ), nb_points 45254 ( 242 x 187 )
+    nb_cores 308 ( 14 x 22 ), nb_points 45095 ( 311 x 145 )
+    nb_cores 310 ( 31 x 10 ), nb_points 45014 ( 142 x 317 )
+    nb_cores 312 ( 24 x 13 ), nb_points 44408 ( 182 x 244 )
+    nb_cores 315 ( 15 x 21 ), nb_points 44080 ( 290 x 152 )
+    nb_cores 319 ( 29 x 11 ), nb_points 43488 ( 151 x 288 )
+    nb_cores 320 ( 20 x 16 ), nb_points 43382 ( 218 x 199 )
+    nb_cores 322 ( 23 x 14 ), nb_points 43130 ( 190 x 227 )
+    nb_cores 323 ( 19 x 17 ), nb_points 43010 ( 230 x 187 )
+    nb_cores 324 ( 18 x 18 ), nb_points 42834 ( 242 x 177 )
+    nb_cores 325 ( 25 x 13 ), nb_points 42700 ( 175 x 244 )
+    nb_cores 329 ( 47 x 7 ), nb_points 42488 ( 94 x 452 )
+    nb_cores 330 ( 30 x 11 ), nb_points 42048 ( 146 x 288 )
+    nb_cores 333 ( 37 x 9 ), nb_points 41888 ( 119 x 352 )
+    nb_cores 336 ( 24 x 14 ), nb_points 41314 ( 182 x 227 )
+    nb_cores 338 ( 13 x 26 ), nb_points 41205 ( 335 x 123 )
+    nb_cores 340 ( 20 x 17 ), nb_points 40766 ( 218 x 187 )
+    nb_cores 342 ( 18 x 19 ), nb_points 40656 ( 242 x 168 )
+    nb_cores 345 ( 23 x 15 ), nb_points 40280 ( 190 x 212 )
+    nb_cores 348 ( 29 x 12 ), nb_points 40015 ( 151 x 265 )
+    nb_cores 350 ( 25 x 14 ), nb_points 39725 ( 175 x 227 )
+    nb_cores 351 ( 27 x 13 ), nb_points 39528 ( 162 x 244 )
+    nb_cores 352 ( 16 x 22 ), nb_points 39440 ( 272 x 145 )
+    nb_cores 357 ( 21 x 17 ), nb_points 38896 ( 208 x 187 )
+    nb_cores 360 ( 24 x 15 ), nb_points 38584 ( 182 x 212 )
+    nb_cores 363 ( 33 x 11 ), nb_points 38304 ( 133 x 288 )
+    nb_cores 364 ( 14 x 26 ), nb_points 38253 ( 311 x 123 )
+    nb_cores 368 ( 16 x 23 ), nb_points 37808 ( 272 x 139 )
+    nb_cores 370 ( 37 x 10 ), nb_points 37723 ( 119 x 317 )
+    nb_cores 372 ( 31 x 12 ), nb_points 37630 ( 142 x 265 )
+    nb_cores 374 ( 22 x 17 ), nb_points 37213 ( 199 x 187 )
+    nb_cores 375 ( 25 x 15 ), nb_points 37100 ( 175 x 212 )
+    nb_cores 377 ( 29 x 13 ), nb_points 36844 ( 151 x 244 )
+    nb_cores 378 ( 27 x 14 ), nb_points 36774 ( 162 x 227 )
+    nb_cores 380 ( 20 x 19 ), nb_points 36624 ( 218 x 168 )
+    nb_cores 384 ( 24 x 16 ), nb_points 36218 ( 182 x 199 )
+    nb_cores 390 ( 30 x 13 ), nb_points 35624 ( 146 x 244 )
+    nb_cores 391 ( 23 x 17 ), nb_points 35530 ( 190 x 187 )
+    nb_cores 396 ( 18 x 22 ), nb_points 35090 ( 242 x 145 )
+    nb_cores 399 ( 21 x 19 ), nb_points 34944 ( 208 x 168 )
+    nb_cores 400 ( 16 x 25 ), nb_points 34816 ( 272 x 128 )
+    nb_cores 403 ( 31 x 13 ), nb_points 34648 ( 142 x 244 )
+    nb_cores 405 ( 27 x 15 ), nb_points 34344 ( 162 x 212 )
+    nb_cores 406 ( 29 x 14 ), nb_points 34277 ( 151 x 227 )
+    nb_cores 407 ( 37 x 11 ), nb_points 34272 ( 119 x 288 )
+    nb_cores 408 ( 24 x 17 ), nb_points 34034 ( 182 x 187 )
+    nb_cores 414 ( 23 x 18 ), nb_points 33630 ( 190 x 177 )
+    nb_cores 416 ( 32 x 13 ), nb_points 33428 ( 137 x 244 )
+    nb_cores 418 ( 19 x 22 ), nb_points 33350 ( 230 x 145 )
+    nb_cores 420 ( 20 x 21 ), nb_points 33136 ( 218 x 152 )
+    nb_cores 423 ( 47 x 9 ), nb_points 33088 ( 94 x 352 )
+    nb_cores 425 ( 25 x 17 ), nb_points 32725 ( 175 x 187 )
+    nb_cores 429 ( 33 x 13 ), nb_points 32452 ( 133 x 244 )
+    nb_cores 432 ( 24 x 18 ), nb_points 32214 ( 182 x 177 )
+    nb_cores 435 ( 29 x 15 ), nb_points 32012 ( 151 x 212 )
+    nb_cores 437 ( 23 x 19 ), nb_points 31920 ( 190 x 168 )
+    nb_cores 440 ( 20 x 22 ), nb_points 31610 ( 218 x 145 )
+    nb_cores 442 ( 26 x 17 ), nb_points 31603 ( 169 x 187 )
+    nb_cores 444 ( 12 x 37 ), nb_points 31494 ( 362 x 87 )
+    nb_cores 448 ( 32 x 14 ), nb_points 31099 ( 137 x 227 )
+    nb_cores 450 ( 30 x 15 ), nb_points 30952 ( 146 x 212 )
+    nb_cores 455 ( 35 x 13 ), nb_points 30744 ( 126 x 244 )
+    nb_cores 456 ( 24 x 19 ), nb_points 30576 ( 182 x 168 )
+    nb_cores 459 ( 27 x 17 ), nb_points 30294 ( 162 x 187 )
+    nb_cores 462 ( 21 x 22 ), nb_points 30160 ( 208 x 145 )
+    nb_cores 464 ( 29 x 16 ), nb_points 30049 ( 151 x 199 )
+    nb_cores 468 ( 18 x 26 ), nb_points 29766 ( 242 x 123 )
+    nb_cores 473 ( 43 x 11 ), nb_points 29664 ( 103 x 288 )
+    nb_cores 475 ( 25 x 19 ), nb_points 29400 ( 175 x 168 )
+    nb_cores 476 ( 28 x 17 ), nb_points 29359 ( 157 x 187 )
+    nb_cores 480 ( 32 x 15 ), nb_points 29044 ( 137 x 212 )
+    nb_cores 481 ( 37 x 13 ), nb_points 29036 ( 119 x 244 )
+    nb_cores 483 ( 23 x 21 ), nb_points 28880 ( 190 x 152 )
+    nb_cores 484 ( 22 x 22 ), nb_points 28855 ( 199 x 145 )
+    nb_cores 486 ( 27 x 18 ), nb_points 28674 ( 162 x 177 )
+    nb_cores 490 ( 35 x 14 ), nb_points 28602 ( 126 x 227 )
+    nb_cores 492 ( 12 x 41 ), nb_points 28598 ( 362 x 79 )
+    nb_cores 493 ( 29 x 17 ), nb_points 28237 ( 151 x 187 )
+    nb_cores 495 ( 33 x 15 ), nb_points 28196 ( 133 x 212 )
+    nb_cores 500 ( 20 x 25 ), nb_points 27904 ( 218 x 128 )
+    nb_cores 504 ( 24 x 21 ), nb_points 27664 ( 182 x 152 )
+    nb_cores 506 ( 23 x 22 ), nb_points 27550 ( 190 x 145 )
+    nb_cores 510 ( 30 x 17 ), nb_points 27302 ( 146 x 187 )
+    nb_cores 512 ( 32 x 16 ), nb_points 27263 ( 137 x 199 )
+    nb_cores 513 ( 27 x 19 ), nb_points 27216 ( 162 x 168 )
+    nb_cores 517 ( 47 x 11 ), nb_points 27072 ( 94 x 288 )
+    nb_cores 518 ( 37 x 14 ), nb_points 27013 ( 119 x 227 )
+    nb_cores 520 ( 20 x 26 ), nb_points 26814 ( 218 x 123 )
+    nb_cores 522 ( 29 x 18 ), nb_points 26727 ( 151 x 177 )
+    nb_cores 525 ( 25 x 21 ), nb_points 26600 ( 175 x 152 )
+    nb_cores 527 ( 31 x 17 ), nb_points 26554 ( 142 x 187 )
+    nb_cores 528 ( 24 x 22 ), nb_points 26390 ( 182 x 145 )
+    nb_cores 532 ( 38 x 14 ), nb_points 26332 ( 116 x 227 )
+    nb_cores 539 ( 49 x 11 ), nb_points 26208 ( 91 x 288 )
+    nb_cores 540 ( 30 x 18 ), nb_points 25842 ( 146 x 177 )
+    nb_cores 544 ( 32 x 17 ), nb_points 25619 ( 137 x 187 )
+    nb_cores 546 ( 21 x 26 ), nb_points 25584 ( 208 x 123 )
+    nb_cores 550 ( 25 x 22 ), nb_points 25375 ( 175 x 145 )
+    nb_cores 551 ( 29 x 19 ), nb_points 25368 ( 151 x 168 )
+    nb_cores 552 ( 24 x 23 ), nb_points 25298 ( 182 x 139 )
+    nb_cores 555 ( 37 x 15 ), nb_points 25228 ( 119 x 212 )
+    nb_cores 558 ( 31 x 18 ), nb_points 25134 ( 142 x 177 )
+    nb_cores 559 ( 43 x 13 ), nb_points 25132 ( 103 x 244 )
+    nb_cores 560 ( 40 x 14 ), nb_points 24970 ( 110 x 227 )
+    nb_cores 561 ( 33 x 17 ), nb_points 24871 ( 133 x 187 )
+    nb_cores 567 ( 27 x 21 ), nb_points 24624 ( 162 x 152 )
+    nb_cores 570 ( 30 x 19 ), nb_points 24528 ( 146 x 168 )
+    nb_cores 572 ( 22 x 26 ), nb_points 24477 ( 199 x 123 )
+    nb_cores 575 ( 23 x 25 ), nb_points 24320 ( 190 x 128 )
+    nb_cores 576 ( 32 x 18 ), nb_points 24249 ( 137 x 177 )
+    nb_cores 580 ( 29 x 20 ), nb_points 24160 ( 151 x 160 )
+    nb_cores 585 ( 45 x 13 ), nb_points 23912 ( 98 x 244 )
+    nb_cores 588 ( 42 x 14 ), nb_points 23835 ( 105 x 227 )
+    nb_cores 592 ( 16 x 37 ), nb_points 23664 ( 272 x 87 )
+    nb_cores 594 ( 27 x 22 ), nb_points 23490 ( 162 x 145 )
+    nb_cores 598 ( 23 x 26 ), nb_points 23370 ( 190 x 123 )
+    nb_cores 600 ( 24 x 25 ), nb_points 23296 ( 182 x 128 )
+    nb_cores 608 ( 32 x 19 ), nb_points 23016 ( 137 x 168 )
+    nb_cores 609 ( 29 x 21 ), nb_points 22952 ( 151 x 152 )
+    nb_cores 611 ( 47 x 13 ), nb_points 22936 ( 94 x 244 )
+    nb_cores 612 ( 36 x 17 ), nb_points 22814 ( 122 x 187 )
+    nb_cores 616 ( 28 x 22 ), nb_points 22765 ( 157 x 145 )
+    nb_cores 620 ( 20 x 31 ), nb_points 22672 ( 218 x 104 )
+    nb_cores 621 ( 27 x 23 ), nb_points 22518 ( 162 x 139 )
+    nb_cores 624 ( 24 x 26 ), nb_points 22386 ( 182 x 123 )
+    nb_cores 627 ( 33 x 19 ), nb_points 22344 ( 133 x 168 )
+    nb_cores 629 ( 37 x 17 ), nb_points 22253 ( 119 x 187 )
+    nb_cores 630 ( 30 x 21 ), nb_points 22192 ( 146 x 152 )
+    nb_cores 638 ( 29 x 22 ), nb_points 21895 ( 151 x 145 )
+    nb_cores 640 ( 40 x 16 ), nb_points 21890 ( 110 x 199 )
+    nb_cores 644 ( 46 x 14 ), nb_points 21792 ( 96 x 227 )
+    nb_cores 646 ( 38 x 17 ), nb_points 21692 ( 116 x 187 )
+    nb_cores 648 ( 36 x 18 ), nb_points 21594 ( 122 x 177 )
+    nb_cores 650 ( 25 x 26 ), nb_points 21525 ( 175 x 123 )
+    nb_cores 656 ( 16 x 41 ), nb_points 21488 ( 272 x 79 )
+    nb_cores 658 ( 47 x 14 ), nb_points 21338 ( 94 x 227 )
+    nb_cores 660 ( 30 x 22 ), nb_points 21170 ( 146 x 145 )
+    nb_cores 663 ( 39 x 17 ), nb_points 21131 ( 113 x 187 )
+    nb_cores 666 ( 18 x 37 ), nb_points 21054 ( 242 x 87 )
+    nb_cores 667 ( 29 x 23 ), nb_points 20989 ( 151 x 139 )
+    nb_cores 672 ( 32 x 21 ), nb_points 20824 ( 137 x 152 )
+    nb_cores 675 ( 27 x 25 ), nb_points 20736 ( 162 x 128 )
+    nb_cores 680 ( 40 x 17 ), nb_points 20570 ( 110 x 187 )
+    nb_cores 684 ( 36 x 19 ), nb_points 20496 ( 122 x 168 )
+    nb_cores 690 ( 30 x 23 ), nb_points 20294 ( 146 x 139 )
+    nb_cores 693 ( 33 x 21 ), nb_points 20216 ( 133 x 152 )
+    nb_cores 696 ( 24 x 29 ), nb_points 20202 ( 182 x 111 )
+    nb_cores 697 ( 41 x 17 ), nb_points 20196 ( 108 x 187 )
+    nb_cores 700 ( 20 x 35 ), nb_points 20056 ( 218 x 92 )
+    nb_cores 702 ( 27 x 26 ), nb_points 19926 ( 162 x 123 )
+    nb_cores 704 ( 32 x 22 ), nb_points 19865 ( 137 x 145 )
+    nb_cores 713 ( 31 x 23 ), nb_points 19738 ( 142 x 139 )
+    nb_cores 714 ( 42 x 17 ), nb_points 19635 ( 105 x 187 )
+    nb_cores 720 ( 40 x 18 ), nb_points 19470 ( 110 x 177 )
+    nb_cores 725 ( 29 x 25 ), nb_points 19328 ( 151 x 128 )
+    nb_cores 726 ( 33 x 22 ), nb_points 19285 ( 133 x 145 )
+    nb_cores 729 ( 27 x 27 ), nb_points 19278 ( 162 x 119 )
+    nb_cores 731 ( 43 x 17 ), nb_points 19261 ( 103 x 187 )
+    nb_cores 735 ( 21 x 35 ), nb_points 19136 ( 208 x 92 )
+    nb_cores 736 ( 32 x 23 ), nb_points 19043 ( 137 x 139 )
+    nb_cores 740 ( 20 x 37 ), nb_points 18966 ( 218 x 87 )
+    nb_cores 744 ( 24 x 31 ), nb_points 18928 ( 182 x 104 )
+    nb_cores 748 ( 34 x 22 ), nb_points 18850 ( 130 x 145 )
+    nb_cores 750 ( 30 x 25 ), nb_points 18688 ( 146 x 128 )
+    nb_cores 754 ( 29 x 26 ), nb_points 18573 ( 151 x 123 )
+    nb_cores 756 ( 36 x 21 ), nb_points 18544 ( 122 x 152 )
+    nb_cores 759 ( 33 x 23 ), nb_points 18487 ( 133 x 139 )
+    nb_cores 760 ( 40 x 19 ), nb_points 18480 ( 110 x 168 )
+    nb_cores 765 ( 45 x 17 ), nb_points 18326 ( 98 x 187 )
+    nb_cores 768 ( 48 x 16 ), nb_points 18308 ( 92 x 199 )
+    nb_cores 770 ( 35 x 22 ), nb_points 18270 ( 126 x 145 )
+    nb_cores 774 ( 43 x 18 ), nb_points 18231 ( 103 x 177 )
+    nb_cores 775 ( 31 x 25 ), nb_points 18176 ( 142 x 128 )
+    nb_cores 777 ( 37 x 21 ), nb_points 18088 ( 119 x 152 )
+    nb_cores 780 ( 30 x 26 ), nb_points 17958 ( 146 x 123 )
+    nb_cores 782 ( 46 x 17 ), nb_points 17952 ( 96 x 187 )
+    nb_cores 792 ( 36 x 22 ), nb_points 17690 ( 122 x 145 )
+    nb_cores 798 ( 38 x 21 ), nb_points 17632 ( 116 x 152 )
+    nb_cores 799 ( 47 x 17 ), nb_points 17578 ( 94 x 187 )
+    nb_cores 800 ( 32 x 25 ), nb_points 17536 ( 137 x 128 )
+    nb_cores 805 ( 23 x 35 ), nb_points 17480 ( 190 x 92 )
+    nb_cores 806 ( 31 x 26 ), nb_points 17466 ( 142 x 123 )
+    nb_cores 810 ( 27 x 30 ), nb_points 17334 ( 162 x 107 )
+    nb_cores 814 ( 37 x 22 ), nb_points 17255 ( 119 x 145 )
+    nb_cores 816 ( 48 x 17 ), nb_points 17204 ( 92 x 187 )
+    nb_cores 819 ( 39 x 21 ), nb_points 17176 ( 113 x 152 )
+    nb_cores 825 ( 33 x 25 ), nb_points 17024 ( 133 x 128 )
+    nb_cores 828 ( 36 x 23 ), nb_points 16958 ( 122 x 139 )
+    nb_cores 832 ( 32 x 26 ), nb_points 16851 ( 137 x 123 )
+    nb_cores 836 ( 38 x 22 ), nb_points 16820 ( 116 x 145 )
+    nb_cores 840 ( 40 x 21 ), nb_points 16720 ( 110 x 152 )
+    nb_cores 846 ( 47 x 18 ), nb_points 16638 ( 94 x 177 )
+    nb_cores 850 ( 25 x 34 ), nb_points 16625 ( 175 x 95 )
+    nb_cores 851 ( 23 x 37 ), nb_points 16530 ( 190 x 87 )
+    nb_cores 855 ( 45 x 19 ), nb_points 16464 ( 98 x 168 )
+    nb_cores 858 ( 33 x 26 ), nb_points 16359 ( 133 x 123 )
+    nb_cores 864 ( 48 x 18 ), nb_points 16284 ( 92 x 177 )
+    nb_cores 867 ( 51 x 17 ), nb_points 16269 ( 87 x 187 )
+    nb_cores 870 ( 29 x 30 ), nb_points 16157 ( 151 x 107 )
+    nb_cores 874 ( 38 x 23 ), nb_points 16124 ( 116 x 139 )
+    nb_cores 875 ( 25 x 35 ), nb_points 16100 ( 175 x 92 )
+    nb_cores 880 ( 40 x 22 ), nb_points 15950 ( 110 x 145 )
+    nb_cores 888 ( 24 x 37 ), nb_points 15834 ( 182 x 87 )
+    nb_cores 891 ( 33 x 27 ), nb_points 15827 ( 133 x 119 )
+    nb_cores 893 ( 47 x 19 ), nb_points 15792 ( 94 x 168 )
+    nb_cores 896 ( 32 x 28 ), nb_points 15755 ( 137 x 115 )
+    nb_cores 897 ( 39 x 23 ), nb_points 15707 ( 113 x 139 )
+    nb_cores 899 ( 29 x 31 ), nb_points 15704 ( 151 x 104 )
+    nb_cores 900 ( 36 x 25 ), nb_points 15616 ( 122 x 128 )
+    nb_cores 910 ( 35 x 26 ), nb_points 15498 ( 126 x 123 )
+    nb_cores 912 ( 48 x 19 ), nb_points 15456 ( 92 x 168 )
+    nb_cores 918 ( 54 x 17 ), nb_points 15334 ( 82 x 187 )
+    nb_cores 920 ( 40 x 23 ), nb_points 15290 ( 110 x 139 )
+    nb_cores 924 ( 42 x 22 ), nb_points 15225 ( 105 x 145 )
+    nb_cores 928 ( 32 x 29 ), nb_points 15207 ( 137 x 111 )
+    nb_cores 930 ( 30 x 31 ), nb_points 15184 ( 146 x 104 )
+    nb_cores 935 ( 55 x 17 ), nb_points 15147 ( 81 x 187 )
+    nb_cores 936 ( 36 x 26 ), nb_points 15006 ( 122 x 123 )
+    nb_cores 945 ( 45 x 21 ), nb_points 14896 ( 98 x 152 )
+    nb_cores 950 ( 38 x 25 ), nb_points 14848 ( 116 x 128 )
+    nb_cores 957 ( 33 x 29 ), nb_points 14763 ( 133 x 111 )
+    nb_cores 960 ( 32 x 30 ), nb_points 14659 ( 137 x 107 )
+    nb_cores 962 ( 37 x 26 ), nb_points 14637 ( 119 x 123 )
+    nb_cores 966 ( 46 x 21 ), nb_points 14592 ( 96 x 152 )
+    nb_cores 969 ( 57 x 17 ), nb_points 14586 ( 78 x 187 )
+    nb_cores 972 ( 54 x 18 ), nb_points 14514 ( 82 x 177 )
+    nb_cores 975 ( 39 x 25 ), nb_points 14464 ( 113 x 128 )
+    nb_cores 980 ( 28 x 35 ), nb_points 14444 ( 157 x 92 )
+    nb_cores 984 ( 24 x 41 ), nb_points 14378 ( 182 x 79 )
+    nb_cores 986 ( 29 x 34 ), nb_points 14345 ( 151 x 95 )
+    nb_cores 987 ( 47 x 21 ), nb_points 14288 ( 94 x 152 )
+    nb_cores 988 ( 38 x 26 ), nb_points 14268 ( 116 x 123 )
+    nb_cores 990 ( 45 x 22 ), nb_points 14210 ( 98 x 145 )
+    nb_cores 999 ( 27 x 37 ), nb_points 14094 ( 162 x 87 )
+    nb_cores 1000 ( 40 x 25 ), nb_points 14080 ( 110 x 128 )
+    nb_cores 1008 ( 48 x 21 ), nb_points 13984 ( 92 x 152 )
+    nb_cores 1012 ( 46 x 22 ), nb_points 13920 ( 96 x 145 )
+    nb_cores 1014 ( 39 x 26 ), nb_points 13899 ( 113 x 123 )
+    nb_cores 1015 ( 29 x 35 ), nb_points 13892 ( 151 x 92 )
+    nb_cores 1020 ( 60 x 17 ), nb_points 13838 ( 74 x 187 )
+    nb_cores 1023 ( 33 x 31 ), nb_points 13832 ( 133 x 104 )
+    nb_cores 1025 ( 41 x 25 ), nb_points 13824 ( 108 x 128 )
+    nb_cores 1026 ( 27 x 38 ), nb_points 13770 ( 162 x 85 )
+    nb_cores 1034 ( 47 x 22 ), nb_points 13630 ( 94 x 145 )
+    nb_cores 1035 ( 45 x 23 ), nb_points 13622 ( 98 x 139 )
+    nb_cores 1040 ( 40 x 26 ), nb_points 13530 ( 110 x 123 )
+    nb_cores 1050 ( 30 x 35 ), nb_points 13432 ( 146 x 92 )
+    nb_cores 1056 ( 48 x 22 ), nb_points 13340 ( 92 x 145 )
+    nb_cores 1066 ( 41 x 26 ), nb_points 13284 ( 108 x 123 )
+    nb_cores 1071 ( 51 x 21 ), nb_points 13224 ( 87 x 152 )
+    nb_cores 1073 ( 29 x 37 ), nb_points 13137 ( 151 x 87 )
+    nb_cores 1080 ( 36 x 30 ), nb_points 13054 ( 122 x 107 )
+    nb_cores 1088 ( 32 x 34 ), nb_points 13015 ( 137 x 95 )
+    nb_cores 1092 ( 42 x 26 ), nb_points 12915 ( 105 x 123 )
+    nb_cores 1100 ( 50 x 22 ), nb_points 12905 ( 89 x 145 )
+    nb_cores 1102 ( 29 x 38 ), nb_points 12835 ( 151 x 85 )
+    nb_cores 1104 ( 48 x 23 ), nb_points 12788 ( 92 x 139 )
+    nb_cores 1110 ( 30 x 37 ), nb_points 12702 ( 146 x 87 )
+    nb_cores 1116 ( 36 x 31 ), nb_points 12688 ( 122 x 104 )
+    nb_cores 1118 ( 43 x 26 ), nb_points 12669 ( 103 x 123 )
+    nb_cores 1120 ( 32 x 35 ), nb_points 12604 ( 137 x 92 )
+    nb_cores 1125 ( 45 x 25 ), nb_points 12544 ( 98 x 128 )
+    nb_cores 1131 ( 29 x 39 ), nb_points 12533 ( 151 x 83 )
+    nb_cores 1134 ( 54 x 21 ), nb_points 12464 ( 82 x 152 )
+    nb_cores 1140 ( 30 x 38 ), nb_points 12410 ( 146 x 85 )
+    nb_cores 1147 ( 31 x 37 ), nb_points 12354 ( 142 x 87 )
+    nb_cores 1150 ( 46 x 25 ), nb_points 12288 ( 96 x 128 )
+    nb_cores 1155 ( 33 x 35 ), nb_points 12236 ( 133 x 92 )
+    nb_cores 1160 ( 40 x 29 ), nb_points 12210 ( 110 x 111 )
+    nb_cores 1166 ( 53 x 22 ), nb_points 12180 ( 84 x 145 )
+    nb_cores 1170 ( 45 x 26 ), nb_points 12054 ( 98 x 123 )
+    nb_cores 1175 ( 47 x 25 ), nb_points 12032 ( 94 x 128 )
+    nb_cores 1184 ( 32 x 37 ), nb_points 11919 ( 137 x 87 )
+    nb_cores 1188 ( 54 x 22 ), nb_points 11890 ( 82 x 145 )
+    nb_cores 1196 ( 46 x 26 ), nb_points 11808 ( 96 x 123 )
+    nb_cores 1200 ( 40 x 30 ), nb_points 11770 ( 110 x 107 )
+    nb_cores 1209 ( 39 x 31 ), nb_points 11752 ( 113 x 104 )
+    nb_cores 1210 ( 55 x 22 ), nb_points 11745 ( 81 x 145 )
+    nb_cores 1215 ( 45 x 27 ), nb_points 11662 ( 98 x 119 )
+    nb_cores 1216 ( 32 x 38 ), nb_points 11645 ( 137 x 85 )
+    nb_cores 1218 ( 29 x 42 ), nb_points 11627 ( 151 x 77 )
+    nb_cores 1221 ( 33 x 37 ), nb_points 11571 ( 133 x 87 )
+    nb_cores 1222 ( 47 x 26 ), nb_points 11562 ( 94 x 123 )
+    nb_cores 1230 ( 30 x 41 ), nb_points 11534 ( 146 x 79 )
+    nb_cores 1240 ( 40 x 31 ), nb_points 11440 ( 110 x 104 )
+    nb_cores 1242 ( 54 x 23 ), nb_points 11398 ( 82 x 139 )
+    nb_cores 1248 ( 48 x 26 ), nb_points 11316 ( 92 x 123 )
+    nb_cores 1254 ( 33 x 38 ), nb_points 11305 ( 133 x 85 )
+    nb_cores 1260 ( 36 x 35 ), nb_points 11224 ( 122 x 92 )
+    nb_cores 1269 ( 27 x 47 ), nb_points 11178 ( 162 x 69 )
+    nb_cores 1275 ( 51 x 25 ), nb_points 11136 ( 87 x 128 )
+    nb_cores 1280 ( 32 x 40 ), nb_points 11097 ( 137 x 81 )
+    nb_cores 1281 ( 61 x 21 ), nb_points 11096 ( 73 x 152 )
+    nb_cores 1287 ( 33 x 39 ), nb_points 11039 ( 133 x 83 )
+    nb_cores 1290 ( 43 x 30 ), nb_points 11021 ( 103 x 107 )
+    nb_cores 1292 ( 38 x 34 ), nb_points 11020 ( 116 x 95 )
+    nb_cores 1295 ( 37 x 35 ), nb_points 10948 ( 119 x 92 )
+    nb_cores 1300 ( 50 x 26 ), nb_points 10947 ( 89 x 123 )
+    nb_cores 1302 ( 42 x 31 ), nb_points 10920 ( 105 x 104 )
+    nb_cores 1305 ( 29 x 45 ), nb_points 10872 ( 151 x 72 )
+    nb_cores 1311 ( 57 x 23 ), nb_points 10842 ( 78 x 139 )
+    nb_cores 1312 ( 32 x 41 ), nb_points 10823 ( 137 x 79 )
+    nb_cores 1316 ( 47 x 28 ), nb_points 10810 ( 94 x 115 )
+    nb_cores 1320 ( 60 x 22 ), nb_points 10730 ( 74 x 145 )
+    nb_cores 1326 ( 51 x 26 ), nb_points 10701 ( 87 x 123 )
+    nb_cores 1330 ( 38 x 35 ), nb_points 10672 ( 116 x 92 )
+    nb_cores 1332 ( 36 x 37 ), nb_points 10614 ( 122 x 87 )
+    nb_cores 1342 ( 61 x 22 ), nb_points 10585 ( 73 x 145 )
+    nb_cores 1344 ( 32 x 42 ), nb_points 10549 ( 137 x 77 )
+    nb_cores 1350 ( 45 x 30 ), nb_points 10486 ( 98 x 107 )
+    nb_cores 1360 ( 40 x 34 ), nb_points 10450 ( 110 x 95 )
+    nb_cores 1363 ( 29 x 47 ), nb_points 10419 ( 151 x 69 )
+    nb_cores 1365 ( 39 x 35 ), nb_points 10396 ( 113 x 92 )
+    nb_cores 1368 ( 36 x 38 ), nb_points 10370 ( 122 x 85 )
+    nb_cores 1369 ( 37 x 37 ), nb_points 10353 ( 119 x 87 )
+    nb_cores 1378 ( 53 x 26 ), nb_points 10332 ( 84 x 123 )
+    nb_cores 1380 ( 46 x 30 ), nb_points 10272 ( 96 x 107 )
+    nb_cores 1386 ( 33 x 42 ), nb_points 10241 ( 133 x 77 )
+    nb_cores 1392 ( 48 x 29 ), nb_points 10212 ( 92 x 111 )
+    nb_cores 1395 ( 45 x 31 ), nb_points 10192 ( 98 x 104 )
+    nb_cores 1400 ( 40 x 35 ), nb_points 10120 ( 110 x 92 )
+    nb_cores 1404 ( 54 x 26 ), nb_points 10086 ( 82 x 123 )
+    nb_cores 1410 ( 47 x 30 ), nb_points 10058 ( 94 x 107 )
+    nb_cores 1425 ( 57 x 25 ), nb_points 9984 ( 78 x 128 )
+    nb_cores 1428 ( 42 x 34 ), nb_points 9975 ( 105 x 95 )
+    nb_cores 1430 ( 55 x 26 ), nb_points 9963 ( 81 x 123 )
+    nb_cores 1435 ( 41 x 35 ), nb_points 9936 ( 108 x 92 )
+    nb_cores 1440 ( 48 x 30 ), nb_points 9844 ( 92 x 107 )
+    nb_cores 1443 ( 39 x 37 ), nb_points 9831 ( 113 x 87 )
+    nb_cores 1450 ( 29 x 50 ), nb_points 9815 ( 151 x 65 )
+    nb_cores 1457 ( 47 x 31 ), nb_points 9776 ( 94 x 104 )
+    nb_cores 1458 ( 54 x 27 ), nb_points 9758 ( 82 x 119 )
+    nb_cores 1470 ( 42 x 35 ), nb_points 9660 ( 105 x 92 )
+    nb_cores 1476 ( 36 x 41 ), nb_points 9638 ( 122 x 79 )
+    nb_cores 1480 ( 40 x 37 ), nb_points 9570 ( 110 x 87 )
+    nb_cores 1488 ( 48 x 31 ), nb_points 9568 ( 92 x 104 )
+    nb_cores 1500 ( 60 x 25 ), nb_points 9472 ( 74 x 128 )
+    nb_cores 1504 ( 32 x 47 ), nb_points 9453 ( 137 x 69 )
+    nb_cores 1512 ( 36 x 42 ), nb_points 9394 ( 122 x 77 )
+    nb_cores 1520 ( 40 x 38 ), nb_points 9350 ( 110 x 85 )
+    nb_cores 1525 ( 61 x 25 ), nb_points 9344 ( 73 x 128 )
+    nb_cores 1530 ( 51 x 30 ), nb_points 9309 ( 87 x 107 )
+    nb_cores 1536 ( 48 x 32 ), nb_points 9292 ( 92 x 101 )
+    nb_cores 1539 ( 57 x 27 ), nb_points 9282 ( 78 x 119 )
+    nb_cores 1540 ( 70 x 22 ), nb_points 9280 ( 64 x 145 )
+    nb_cores 1548 ( 43 x 36 ), nb_points 9270 ( 103 x 90 )
+    nb_cores 1550 ( 62 x 25 ), nb_points 9216 ( 72 x 128 )
+    nb_cores 1551 ( 33 x 47 ), nb_points 9177 ( 133 x 69 )
+    nb_cores 1554 ( 42 x 37 ), nb_points 9135 ( 105 x 87 )
+    nb_cores 1560 ( 60 x 26 ), nb_points 9102 ( 74 x 123 )
+    nb_cores 1575 ( 45 x 35 ), nb_points 9016 ( 98 x 92 )
+    nb_cores 1584 ( 72 x 22 ), nb_points 8990 ( 62 x 145 )
+    nb_cores 1586 ( 61 x 26 ), nb_points 8979 ( 73 x 123 )
+    nb_cores 1591 ( 43 x 37 ), nb_points 8961 ( 103 x 87 )
+    nb_cores 1596 ( 42 x 38 ), nb_points 8925 ( 105 x 85 )
+    nb_cores 1600 ( 32 x 50 ), nb_points 8905 ( 137 x 65 )
+    nb_cores 1610 ( 46 x 35 ), nb_points 8832 ( 96 x 92 )
+    nb_cores 1620 ( 54 x 30 ), nb_points 8774 ( 82 x 107 )
+    nb_cores 1632 ( 48 x 34 ), nb_points 8740 ( 92 x 95 )
+    nb_cores 1638 ( 39 x 42 ), nb_points 8701 ( 113 x 77 )
+    nb_cores 1640 ( 40 x 41 ), nb_points 8690 ( 110 x 79 )
+    nb_cores 1645 ( 47 x 35 ), nb_points 8648 ( 94 x 92 )
+    nb_cores 1650 ( 33 x 50 ), nb_points 8645 ( 133 x 65 )
+    nb_cores 1656 ( 72 x 23 ), nb_points 8618 ( 62 x 139 )
+    nb_cores 1664 ( 64 x 26 ), nb_points 8610 ( 70 x 123 )
+    nb_cores 1665 ( 45 x 37 ), nb_points 8526 ( 98 x 87 )
+    nb_cores 1680 ( 48 x 35 ), nb_points 8464 ( 92 x 92 )
+    nb_cores 1692 ( 36 x 47 ), nb_points 8418 ( 122 x 69 )
+    nb_cores 1702 ( 46 x 37 ), nb_points 8352 ( 96 x 87 )
+    nb_cores 1710 ( 45 x 38 ), nb_points 8330 ( 98 x 85 )
+    nb_cores 1722 ( 42 x 41 ), nb_points 8295 ( 105 x 79 )
+    nb_cores 1728 ( 48 x 36 ), nb_points 8280 ( 92 x 90 )
+    nb_cores 1734 ( 51 x 34 ), nb_points 8265 ( 87 x 95 )
+    nb_cores 1739 ( 47 x 37 ), nb_points 8178 ( 94 x 87 )
+    nb_cores 1748 ( 46 x 38 ), nb_points 8160 ( 96 x 85 )
+    nb_cores 1755 ( 45 x 39 ), nb_points 8134 ( 98 x 83 )
+    nb_cores 1760 ( 80 x 22 ), nb_points 8120 ( 56 x 145 )
+    nb_cores 1764 ( 42 x 42 ), nb_points 8085 ( 105 x 77 )
+    nb_cores 1775 ( 71 x 25 ), nb_points 8064 ( 63 x 128 )
+    nb_cores 1776 ( 48 x 37 ), nb_points 8004 ( 92 x 87 )
+    nb_cores 1786 ( 47 x 38 ), nb_points 7990 ( 94 x 85 )
+    nb_cores 1794 ( 46 x 39 ), nb_points 7968 ( 96 x 83 )
+    nb_cores 1800 ( 60 x 30 ), nb_points 7918 ( 74 x 107 )
+    nb_cores 1813 ( 49 x 37 ), nb_points 7917 ( 91 x 87 )
+    nb_cores 1820 ( 70 x 26 ), nb_points 7872 ( 64 x 123 )
+    nb_cores 1824 ( 48 x 38 ), nb_points 7820 ( 92 x 85 )
+    nb_cores 1830 ( 61 x 30 ), nb_points 7811 ( 73 x 107 )
+    nb_cores 1833 ( 39 x 47 ), nb_points 7797 ( 113 x 69 )
+    nb_cores 1836 ( 54 x 34 ), nb_points 7790 ( 82 x 95 )
+    nb_cores 1840 ( 46 x 40 ), nb_points 7776 ( 96 x 81 )
+    nb_cores 1845 ( 45 x 41 ), nb_points 7742 ( 98 x 79 )
+    nb_cores 1850 ( 37 x 50 ), nb_points 7735 ( 119 x 65 )
+    nb_cores 1855 ( 53 x 35 ), nb_points 7728 ( 84 x 92 )
+    nb_cores 1860 ( 60 x 31 ), nb_points 7696 ( 74 x 104 )
+    nb_cores 1870 ( 85 x 22 ), nb_points 7685 ( 53 x 145 )
+    nb_cores 1872 ( 72 x 26 ), nb_points 7626 ( 62 x 123 )
+    nb_cores 1880 ( 40 x 47 ), nb_points 7590 ( 110 x 69 )
+    nb_cores 1886 ( 46 x 41 ), nb_points 7584 ( 96 x 79 )
+    nb_cores 1887 ( 51 x 37 ), nb_points 7569 ( 87 x 87 )
+    nb_cores 1890 ( 54 x 35 ), nb_points 7544 ( 82 x 92 )
+    nb_cores 1900 ( 38 x 50 ), nb_points 7540 ( 116 x 65 )
+    nb_cores 1917 ( 71 x 27 ), nb_points 7497 ( 63 x 119 )
+    nb_cores 1920 ( 48 x 40 ), nb_points 7452 ( 92 x 81 )
+    nb_cores 1927 ( 47 x 41 ), nb_points 7426 ( 94 x 79 )
+    nb_cores 1932 ( 46 x 42 ), nb_points 7392 ( 96 x 77 )
+    nb_cores 1944 ( 72 x 27 ), nb_points 7378 ( 62 x 119 )
+    nb_cores 1950 ( 39 x 50 ), nb_points 7345 ( 113 x 65 )
+    nb_cores 1961 ( 53 x 37 ), nb_points 7308 ( 84 x 87 )
+    nb_cores 1968 ( 48 x 41 ), nb_points 7268 ( 92 x 79 )
+    nb_cores 1974 ( 47 x 42 ), nb_points 7238 ( 94 x 77 )
+    nb_cores 1989 ( 51 x 39 ), nb_points 7221 ( 87 x 83 )
+    nb_cores 1995 ( 57 x 35 ), nb_points 7176 ( 78 x 92 )
+    nb_cores 1998 ( 54 x 37 ), nb_points 7134 ( 82 x 87 )
+    nb_cores 2016 ( 48 x 42 ), nb_points 7084 ( 92 x 77 )
+    nb_cores 2025 ( 45 x 45 ), nb_points 7056 ( 98 x 72 )
+    nb_cores 2035 ( 55 x 37 ), nb_points 7047 ( 81 x 87 )
+    nb_cores 2040 ( 60 x 34 ), nb_points 7030 ( 74 x 95 )
+    nb_cores 2050 ( 41 x 50 ), nb_points 7020 ( 108 x 65 )
+    nb_cores 2052 ( 54 x 38 ), nb_points 6970 ( 82 x 85 )
+    nb_cores 2068 ( 47 x 44 ), nb_points 6956 ( 94 x 74 )
+    nb_cores 2070 ( 46 x 45 ), nb_points 6912 ( 96 x 72 )
+    nb_cores 2080 ( 80 x 26 ), nb_points 6888 ( 56 x 123 )
+    nb_cores 2088 ( 72 x 29 ), nb_points 6882 ( 62 x 111 )
+    nb_cores 2091 ( 51 x 41 ), nb_points 6873 ( 87 x 79 )
+    nb_cores 2100 ( 60 x 35 ), nb_points 6808 ( 74 x 92 )
+    nb_cores 2106 ( 54 x 39 ), nb_points 6806 ( 82 x 83 )
+    nb_cores 2109 ( 57 x 37 ), nb_points 6786 ( 78 x 87 )
+    nb_cores 2115 ( 45 x 47 ), nb_points 6762 ( 98 x 69 )
+    nb_cores 2130 ( 71 x 30 ), nb_points 6741 ( 63 x 107 )
+    nb_cores 2135 ( 61 x 35 ), nb_points 6716 ( 73 x 92 )
+    nb_cores 2142 ( 51 x 42 ), nb_points 6699 ( 87 x 77 )
+    nb_cores 2150 ( 43 x 50 ), nb_points 6695 ( 103 x 65 )
+    nb_cores 2160 ( 48 x 45 ), nb_points 6624 ( 92 x 72 )
+    nb_cores 2183 ( 59 x 37 ), nb_points 6612 ( 76 x 87 )
+    nb_cores 2193 ( 43 x 51 ), nb_points 6592 ( 103 x 64 )
+    nb_cores 2196 ( 61 x 36 ), nb_points 6570 ( 73 x 90 )
+    nb_cores 2200 ( 55 x 40 ), nb_points 6561 ( 81 x 81 )
+    nb_cores 2201 ( 71 x 31 ), nb_points 6552 ( 63 x 104 )
+    nb_cores 2204 ( 58 x 38 ), nb_points 6545 ( 77 x 85 )
+    nb_cores 2205 ( 63 x 35 ), nb_points 6532 ( 71 x 92 )
+    nb_cores 2208 ( 46 x 48 ), nb_points 6528 ( 96 x 68 )
+    nb_cores 2209 ( 47 x 47 ), nb_points 6486 ( 94 x 69 )
+    nb_cores 2214 ( 54 x 41 ), nb_points 6478 ( 82 x 79 )
+    nb_cores 2220 ( 60 x 37 ), nb_points 6438 ( 74 x 87 )
+    nb_cores 2250 ( 45 x 50 ), nb_points 6370 ( 98 x 65 )
+    nb_cores 2256 ( 48 x 47 ), nb_points 6348 ( 92 x 69 )
+    nb_cores 2268 ( 54 x 42 ), nb_points 6314 ( 82 x 77 )
+    nb_cores 2280 ( 60 x 38 ), nb_points 6290 ( 74 x 85 )
+    nb_cores 2294 ( 62 x 37 ), nb_points 6264 ( 72 x 87 )
+    nb_cores 2300 ( 46 x 50 ), nb_points 6240 ( 96 x 65 )
+    nb_cores 2310 ( 55 x 42 ), nb_points 6237 ( 81 x 77 )
+    nb_cores 2318 ( 61 x 38 ), nb_points 6205 ( 73 x 85 )
+    nb_cores 2331 ( 63 x 37 ), nb_points 6177 ( 71 x 87 )
+    nb_cores 2337 ( 57 x 41 ), nb_points 6162 ( 78 x 79 )
+    nb_cores 2340 ( 60 x 39 ), nb_points 6142 ( 74 x 83 )
+    nb_cores 2350 ( 47 x 50 ), nb_points 6110 ( 94 x 65 )
+    nb_cores 2368 ( 64 x 37 ), nb_points 6090 ( 70 x 87 )
+    nb_cores 2376 ( 54 x 44 ), nb_points 6068 ( 82 x 74 )
+    nb_cores 2379 ( 61 x 39 ), nb_points 6059 ( 73 x 83 )
+    nb_cores 2385 ( 53 x 45 ), nb_points 6048 ( 84 x 72 )
+    nb_cores 2392 ( 92 x 26 ), nb_points 6027 ( 49 x 123 )
+    nb_cores 2394 ( 57 x 42 ), nb_points 6006 ( 78 x 77 )
+    nb_cores 2397 ( 51 x 47 ), nb_points 6003 ( 87 x 69 )
+    nb_cores 2400 ( 48 x 50 ), nb_points 5980 ( 92 x 65 )
+    nb_cores 2412 ( 36 x 67 ), nb_points 5978 ( 122 x 49 )
+    nb_cores 2418 ( 62 x 39 ), nb_points 5976 ( 72 x 83 )
+    nb_cores 2430 ( 54 x 45 ), nb_points 5904 ( 82 x 72 )
+    nb_cores 2448 ( 48 x 51 ), nb_points 5888 ( 92 x 64 )
+    nb_cores 2457 ( 39 x 63 ), nb_points 5876 ( 113 x 52 )
+    nb_cores 2460 ( 60 x 41 ), nb_points 5846 ( 74 x 79 )
+    nb_cores 2475 ( 55 x 45 ), nb_points 5832 ( 81 x 72 )
+    nb_cores 2479 ( 67 x 37 ), nb_points 5829 ( 67 x 87 )
+    nb_cores 2480 ( 80 x 31 ), nb_points 5824 ( 56 x 104 )
+    nb_cores 2484 ( 54 x 46 ), nb_points 5822 ( 82 x 71 )
+    nb_cores 2485 ( 71 x 35 ), nb_points 5796 ( 63 x 92 )
+    nb_cores 2496 ( 96 x 26 ), nb_points 5781 ( 47 x 123 )
+    nb_cores 2501 ( 61 x 41 ), nb_points 5767 ( 73 x 79 )
+    nb_cores 2516 ( 68 x 37 ), nb_points 5742 ( 66 x 87 )
+    nb_cores 2520 ( 60 x 42 ), nb_points 5698 ( 74 x 77 )
+    nb_cores 2538 ( 54 x 47 ), nb_points 5658 ( 82 x 69 )
+    nb_cores 2550 ( 51 x 50 ), nb_points 5655 ( 87 x 65 )
+    nb_cores 2562 ( 61 x 42 ), nb_points 5621 ( 73 x 77 )
+    nb_cores 2565 ( 57 x 45 ), nb_points 5616 ( 78 x 72 )
+    nb_cores 2583 ( 63 x 41 ), nb_points 5609 ( 71 x 79 )
+    nb_cores 2584 ( 76 x 34 ), nb_points 5605 ( 59 x 95 )
+    nb_cores 2585 ( 55 x 47 ), nb_points 5589 ( 81 x 69 )
+    nb_cores 2590 ( 70 x 37 ), nb_points 5568 ( 64 x 87 )
+    nb_cores 2604 ( 62 x 42 ), nb_points 5544 ( 72 x 77 )
+    nb_cores 2613 ( 39 x 67 ), nb_points 5537 ( 113 x 49 )
+    nb_cores 2622 ( 69 x 38 ), nb_points 5525 ( 65 x 85 )
+    nb_cores 2625 ( 75 x 35 ), nb_points 5520 ( 60 x 92 )
+    nb_cores 2627 ( 71 x 37 ), nb_points 5481 ( 63 x 87 )
+    nb_cores 2640 ( 60 x 44 ), nb_points 5476 ( 74 x 74 )
+    nb_cores 2646 ( 42 x 63 ), nb_points 5460 ( 105 x 52 )
+    nb_cores 2660 ( 76 x 35 ), nb_points 5428 ( 59 x 92 )
+    nb_cores 2664 ( 72 x 37 ), nb_points 5394 ( 62 x 87 )
+    nb_cores 2679 ( 57 x 47 ), nb_points 5382 ( 78 x 69 )
+    nb_cores 2698 ( 71 x 38 ), nb_points 5355 ( 63 x 85 )
+    nb_cores 2700 ( 60 x 45 ), nb_points 5328 ( 74 x 72 )
+    nb_cores 2720 ( 80 x 34 ), nb_points 5320 ( 56 x 95 )
+    nb_cores 2726 ( 58 x 47 ), nb_points 5313 ( 77 x 69 )
+    nb_cores 2730 ( 39 x 70 ), nb_points 5311 ( 113 x 47 )
+    nb_cores 2736 ( 72 x 38 ), nb_points 5270 ( 62 x 85 )
+    nb_cores 2745 ( 61 x 45 ), nb_points 5256 ( 73 x 72 )
+    nb_cores 2754 ( 54 x 51 ), nb_points 5248 ( 82 x 64 )
+    nb_cores 2760 ( 92 x 30 ), nb_points 5243 ( 49 x 107 )
+    nb_cores 2769 ( 71 x 39 ), nb_points 5229 ( 63 x 83 )
+    nb_cores 2775 ( 75 x 37 ), nb_points 5220 ( 60 x 87 )
+    nb_cores 2784 ( 96 x 29 ), nb_points 5217 ( 47 x 111 )
+    nb_cores 2788 ( 68 x 41 ), nb_points 5214 ( 66 x 79 )
+    nb_cores 2790 ( 62 x 45 ), nb_points 5184 ( 72 x 72 )
+    nb_cores 2800 ( 80 x 35 ), nb_points 5152 ( 56 x 92 )
+    nb_cores 2808 ( 72 x 39 ), nb_points 5146 ( 62 x 83 )
+    nb_cores 2812 ( 76 x 37 ), nb_points 5133 ( 59 x 87 )
+    nb_cores 2820 ( 60 x 47 ), nb_points 5106 ( 74 x 69 )
+    nb_cores 2835 ( 45 x 63 ), nb_points 5096 ( 98 x 52 )
+    nb_cores 2850 ( 57 x 50 ), nb_points 5070 ( 78 x 65 )
+    nb_cores 2867 ( 61 x 47 ), nb_points 5037 ( 73 x 69 )
+    nb_cores 2880 ( 72 x 40 ), nb_points 5022 ( 62 x 81 )
+    nb_cores 2888 ( 76 x 38 ), nb_points 5015 ( 59 x 85 )
+    nb_cores 2898 ( 46 x 63 ), nb_points 4992 ( 96 x 52 )
+    nb_cores 2911 ( 71 x 41 ), nb_points 4977 ( 63 x 79 )
+    nb_cores 2914 ( 62 x 47 ), nb_points 4968 ( 72 x 69 )
+    nb_cores 2923 ( 79 x 37 ), nb_points 4959 ( 57 x 87 )
+    nb_cores 2940 ( 70 x 42 ), nb_points 4928 ( 64 x 77 )
+    nb_cores 2952 ( 72 x 41 ), nb_points 4898 ( 62 x 79 )
+    nb_cores 2960 ( 80 x 37 ), nb_points 4872 ( 56 x 87 )
+    nb_cores 2982 ( 71 x 42 ), nb_points 4851 ( 63 x 77 )
+    nb_cores 3000 ( 60 x 50 ), nb_points 4810 ( 74 x 65 )
+    nb_cores 3015 ( 45 x 67 ), nb_points 4802 ( 98 x 49 )
+    nb_cores 3024 ( 72 x 42 ), nb_points 4774 ( 62 x 77 )
+    nb_cores 3040 ( 80 x 38 ), nb_points 4760 ( 56 x 85 )
+    nb_cores 3050 ( 61 x 50 ), nb_points 4745 ( 73 x 65 )
+    nb_cores 3060 ( 60 x 51 ), nb_points 4736 ( 74 x 64 )
+    nb_cores 3080 ( 40 x 77 ), nb_points 4730 ( 110 x 43 )
+    nb_cores 3082 ( 46 x 67 ), nb_points 4704 ( 96 x 49 )
+    nb_cores 3100 ( 62 x 50 ), nb_points 4680 ( 72 x 65 )
+    nb_cores 3111 ( 61 x 51 ), nb_points 4672 ( 73 x 64 )
+    nb_cores 3116 ( 76 x 41 ), nb_points 4661 ( 59 x 79 )
+    nb_cores 3120 ( 80 x 39 ), nb_points 4648 ( 56 x 83 )
+    nb_cores 3145 ( 85 x 37 ), nb_points 4611 ( 53 x 87 )
+    nb_cores 3149 ( 47 x 67 ), nb_points 4606 ( 94 x 49 )
+    nb_cores 3150 ( 90 x 35 ), nb_points 4600 ( 50 x 92 )
+    nb_cores 3168 ( 72 x 44 ), nb_points 4588 ( 62 x 74 )
+    nb_cores 3192 ( 76 x 42 ), nb_points 4543 ( 59 x 77 )
+    nb_cores 3195 ( 71 x 45 ), nb_points 4536 ( 63 x 72 )
+    nb_cores 3213 ( 51 x 63 ), nb_points 4524 ( 87 x 52 )
+    nb_cores 3216 ( 48 x 67 ), nb_points 4508 ( 92 x 49 )
+    nb_cores 3230 ( 85 x 38 ), nb_points 4505 ( 53 x 85 )
+    nb_cores 3239 ( 79 x 41 ), nb_points 4503 ( 57 x 79 )
+    nb_cores 3240 ( 72 x 45 ), nb_points 4464 ( 62 x 72 )
+    nb_cores 3280 ( 80 x 41 ), nb_points 4424 ( 56 x 79 )
+    nb_cores 3290 ( 94 x 35 ), nb_points 4416 ( 48 x 92 )
+    nb_cores 3290 ( 70 x 47 ), nb_points 4416 ( 64 x 69 )
+    nb_cores 3312 ( 72 x 46 ), nb_points 4402 ( 62 x 71 )
+    nb_cores 3315 ( 85 x 39 ), nb_points 4399 ( 53 x 83 )
+    nb_cores 3318 ( 79 x 42 ), nb_points 4389 ( 57 x 77 )
+    nb_cores 3330 ( 90 x 37 ), nb_points 4350 ( 50 x 87 )
+    nb_cores 3337 ( 71 x 47 ), nb_points 4347 ( 63 x 69 )
+    nb_cores 3348 ( 54 x 62 ), nb_points 4346 ( 82 x 53 )
+    nb_cores 3360 ( 80 x 42 ), nb_points 4312 ( 56 x 77 )
+    nb_cores 3384 ( 72 x 47 ), nb_points 4278 ( 62 x 69 )
+    nb_cores 3402 ( 54 x 63 ), nb_points 4264 ( 82 x 52 )
+    nb_cores 3404 ( 92 x 37 ), nb_points 4263 ( 49 x 87 )
+    nb_cores 3420 ( 76 x 45 ), nb_points 4248 ( 59 x 72 )
+    nb_cores 3444 ( 82 x 42 ), nb_points 4235 ( 55 x 77 )
+    nb_cores 3450 ( 46 x 75 ), nb_points 4224 ( 96 x 44 )
+    nb_cores 3456 ( 72 x 48 ), nb_points 4216 ( 62 x 68 )
+    nb_cores 3465 ( 55 x 63 ), nb_points 4212 ( 81 x 52 )
+    nb_cores 3478 ( 94 x 37 ), nb_points 4176 ( 48 x 87 )
+    nb_cores 3496 ( 92 x 38 ), nb_points 4165 ( 49 x 85 )
+    nb_cores 3500 ( 70 x 50 ), nb_points 4160 ( 64 x 65 )
+    nb_cores 3510 ( 90 x 39 ), nb_points 4150 ( 50 x 83 )
+    nb_cores 3520 ( 80 x 44 ), nb_points 4144 ( 56 x 74 )
+    nb_cores 3525 ( 47 x 75 ), nb_points 4136 ( 94 x 44 )
+    nb_cores 3534 ( 57 x 62 ), nb_points 4134 ( 78 x 53 )
+    nb_cores 3542 ( 46 x 77 ), nb_points 4128 ( 96 x 43 )
+    nb_cores 3550 ( 71 x 50 ), nb_points 4095 ( 63 x 65 )
+    nb_cores 3552 ( 96 x 37 ), nb_points 4089 ( 47 x 87 )
+    nb_cores 3570 ( 85 x 42 ), nb_points 4081 ( 53 x 77 )
+    nb_cores 3572 ( 76 x 47 ), nb_points 4071 ( 59 x 69 )
+    nb_cores 3588 ( 92 x 39 ), nb_points 4067 ( 49 x 83 )
+    nb_cores 3591 ( 57 x 63 ), nb_points 4056 ( 78 x 52 )
+    nb_cores 3600 ( 72 x 50 ), nb_points 4030 ( 62 x 65 )
+    nb_cores 3618 ( 54 x 67 ), nb_points 4018 ( 82 x 49 )
+    nb_cores 3648 ( 96 x 38 ), nb_points 3995 ( 47 x 85 )
+    nb_cores 3666 ( 94 x 39 ), nb_points 3984 ( 48 x 83 )
+    nb_cores 3672 ( 72 x 51 ), nb_points 3968 ( 62 x 64 )
+    nb_cores 3690 ( 90 x 41 ), nb_points 3950 ( 50 x 79 )
+    nb_cores 3710 ( 53 x 70 ), nb_points 3948 ( 84 x 47 )
+    nb_cores 3713 ( 79 x 47 ), nb_points 3933 ( 57 x 69 )
+    nb_cores 3720 ( 60 x 62 ), nb_points 3922 ( 74 x 53 )
+    nb_cores 3735 ( 45 x 83 ), nb_points 3920 ( 98 x 40 )
+    nb_cores 3737 ( 101 x 37 ), nb_points 3915 ( 45 x 87 )
+    nb_cores 3744 ( 96 x 39 ), nb_points 3901 ( 47 x 83 )
+    nb_cores 3750 ( 75 x 50 ), nb_points 3900 ( 60 x 65 )
+    nb_cores 3760 ( 80 x 47 ), nb_points 3864 ( 56 x 69 )
+    nb_cores 3780 ( 60 x 63 ), nb_points 3848 ( 74 x 52 )
+    nb_cores 3800 ( 76 x 50 ), nb_points 3835 ( 59 x 65 )
+    nb_cores 3811 ( 103 x 37 ), nb_points 3828 ( 44 x 87 )
+    nb_cores 3819 ( 57 x 67 ), nb_points 3822 ( 78 x 49 )
+    nb_cores 3825 ( 85 x 45 ), nb_points 3816 ( 53 x 72 )
+    nb_cores 3840 ( 96 x 40 ), nb_points 3807 ( 47 x 81 )
+    nb_cores 3843 ( 61 x 63 ), nb_points 3796 ( 73 x 52 )
+    nb_cores 3854 ( 94 x 41 ), nb_points 3792 ( 48 x 79 )
+    nb_cores 3864 ( 92 x 42 ), nb_points 3773 ( 49 x 77 )
+    nb_cores 3885 ( 111 x 35 ), nb_points 3772 ( 41 x 92 )
+    nb_cores 3900 ( 78 x 50 ), nb_points 3770 ( 58 x 65 )
+    nb_cores 3901 ( 47 x 83 ), nb_points 3760 ( 94 x 40 )
+    nb_cores 3906 ( 62 x 63 ), nb_points 3744 ( 72 x 52 )
+    nb_cores 3914 ( 103 x 38 ), nb_points 3740 ( 44 x 85 )
+    nb_cores 3936 ( 96 x 41 ), nb_points 3713 ( 47 x 79 )
+    nb_cores 3948 ( 94 x 42 ), nb_points 3696 ( 48 x 77 )
+    nb_cores 3969 ( 63 x 63 ), nb_points 3692 ( 71 x 52 )
+    nb_cores 3984 ( 48 x 83 ), nb_points 3680 ( 92 x 40 )
+    nb_cores 3990 ( 57 x 70 ), nb_points 3666 ( 78 x 47 )
+    nb_cores 3995 ( 85 x 47 ), nb_points 3657 ( 53 x 69 )
+    nb_cores 3996 ( 108 x 37 ), nb_points 3654 ( 42 x 87 )
+    nb_cores 4000 ( 80 x 50 ), nb_points 3640 ( 56 x 65 )
+    nb_cores 4020 ( 60 x 67 ), nb_points 3626 ( 74 x 49 )
+    nb_cores 4032 ( 96 x 42 ), nb_points 3619 ( 47 x 77 )
+    nb_cores 4050 ( 90 x 45 ), nb_points 3600 ( 50 x 72 )
+    nb_cores 4080 ( 80 x 51 ), nb_points 3584 ( 56 x 64 )
+    nb_cores 4087 ( 61 x 67 ), nb_points 3577 ( 73 x 49 )
+    nb_cores 4100 ( 82 x 50 ), nb_points 3575 ( 55 x 65 )
+    nb_cores 4104 ( 108 x 38 ), nb_points 3570 ( 42 x 85 )
+    nb_cores 4107 ( 111 x 37 ), nb_points 3567 ( 41 x 87 )
+    nb_cores 4120 ( 103 x 40 ), nb_points 3564 ( 44 x 81 )
+    nb_cores 4136 ( 94 x 44 ), nb_points 3552 ( 48 x 74 )
+    nb_cores 4140 ( 92 x 45 ), nb_points 3528 ( 49 x 72 )
+    nb_cores 4158 ( 54 x 77 ), nb_points 3526 ( 82 x 43 )
+    nb_cores 4182 ( 82 x 51 ), nb_points 3520 ( 55 x 64 )
+    nb_cores 4183 ( 89 x 47 ), nb_points 3519 ( 51 x 69 )
+    nb_cores 4200 ( 60 x 70 ), nb_points 3478 ( 74 x 47 )
+    nb_cores 4223 ( 103 x 41 ), nb_points 3476 ( 44 x 79 )
+    nb_cores 4230 ( 90 x 47 ), nb_points 3450 ( 50 x 69 )
+    nb_cores 4250 ( 85 x 50 ), nb_points 3445 ( 53 x 65 )
+    nb_cores 4266 ( 54 x 79 ), nb_points 3444 ( 82 x 42 )
+    nb_cores 4270 ( 61 x 70 ), nb_points 3431 ( 73 x 47 )
+    nb_cores 4288 ( 64 x 67 ), nb_points 3430 ( 70 x 49 )
+    nb_cores 4320 ( 96 x 45 ), nb_points 3384 ( 47 x 72 )
+    nb_cores 4324 ( 92 x 47 ), nb_points 3381 ( 49 x 69 )
+    nb_cores 4347 ( 69 x 63 ), nb_points 3380 ( 65 x 52 )
+    nb_cores 4374 ( 54 x 81 ), nb_points 3362 ( 82 x 41 )
+    nb_cores 4389 ( 57 x 77 ), nb_points 3354 ( 78 x 43 )
+    nb_cores 4392 ( 72 x 61 ), nb_points 3348 ( 62 x 54 )
+    nb_cores 4402 ( 71 x 62 ), nb_points 3339 ( 63 x 53 )
+    nb_cores 4410 ( 70 x 63 ), nb_points 3328 ( 64 x 52 )
+    nb_cores 4418 ( 94 x 47 ), nb_points 3312 ( 48 x 69 )
+    nb_cores 4440 ( 120 x 37 ), nb_points 3306 ( 38 x 87 )
+    nb_cores 4464 ( 72 x 62 ), nb_points 3286 ( 62 x 53 )
+    nb_cores 4473 ( 71 x 63 ), nb_points 3276 ( 63 x 52 )
+    nb_cores 4500 ( 90 x 50 ), nb_points 3250 ( 50 x 65 )
+    nb_cores 4512 ( 96 x 47 ), nb_points 3243 ( 47 x 69 )
+    nb_cores 4536 ( 72 x 63 ), nb_points 3224 ( 62 x 52 )
+    nb_cores 4575 ( 61 x 75 ), nb_points 3212 ( 73 x 44 )
+    nb_cores 4590 ( 54 x 85 ), nb_points 3198 ( 82 x 39 )
+    nb_cores 4600 ( 92 x 50 ), nb_points 3185 ( 49 x 65 )
+    nb_cores 4620 ( 60 x 77 ), nb_points 3182 ( 74 x 43 )
+    nb_cores 4635 ( 103 x 45 ), nb_points 3168 ( 44 x 72 )
+    nb_cores 4662 ( 111 x 42 ), nb_points 3157 ( 41 x 77 )
+    nb_cores 4680 ( 90 x 52 ), nb_points 3150 ( 50 x 63 )
+    nb_cores 4690 ( 70 x 67 ), nb_points 3136 ( 64 x 49 )
+    nb_cores 4700 ( 94 x 50 ), nb_points 3120 ( 48 x 65 )
+    nb_cores 4740 ( 60 x 79 ), nb_points 3108 ( 74 x 42 )
+    nb_cores 4747 ( 101 x 47 ), nb_points 3105 ( 45 x 69 )
+    nb_cores 4752 ( 72 x 66 ), nb_points 3100 ( 62 x 50 )
+    nb_cores 4757 ( 71 x 67 ), nb_points 3087 ( 63 x 49 )
+    nb_cores 4788 ( 76 x 63 ), nb_points 3068 ( 59 x 52 )
+    nb_cores 4800 ( 96 x 50 ), nb_points 3055 ( 47 x 65 )
+    nb_cores 4824 ( 72 x 67 ), nb_points 3038 ( 62 x 49 )
+    nb_cores 4841 ( 103 x 47 ), nb_points 3036 ( 44 x 69 )
+    nb_cores 4860 ( 108 x 45 ), nb_points 3024 ( 42 x 72 )
+    nb_cores 4896 ( 96 x 51 ), nb_points 3008 ( 47 x 64 )
+    nb_cores 4914 ( 117 x 42 ), nb_points 3003 ( 39 x 77 )
+    nb_cores 4920 ( 120 x 41 ), nb_points 3002 ( 38 x 79 )
+    nb_cores 4941 ( 61 x 81 ), nb_points 2993 ( 73 x 41 )
+    nb_cores 4944 ( 103 x 48 ), nb_points 2992 ( 44 x 68 )
+    nb_cores 4950 ( 99 x 50 ), nb_points 2990 ( 46 x 65 )
+    nb_cores 4958 ( 74 x 67 ), nb_points 2989 ( 61 x 49 )
+    nb_cores 4960 ( 80 x 62 ), nb_points 2968 ( 56 x 53 )
+    nb_cores 4970 ( 71 x 70 ), nb_points 2961 ( 63 x 47 )
+    nb_cores 4980 ( 60 x 83 ), nb_points 2960 ( 74 x 40 )
+    nb_cores 4995 ( 111 x 45 ), nb_points 2952 ( 41 x 72 )
+    nb_cores 5016 ( 76 x 66 ), nb_points 2950 ( 59 x 50 )
+    nb_cores 5025 ( 75 x 67 ), nb_points 2940 ( 60 x 49 )
+    nb_cores 5040 ( 80 x 63 ), nb_points 2912 ( 56 x 52 )
+    nb_cores 5076 ( 108 x 47 ), nb_points 2898 ( 42 x 69 )
+    nb_cores 5092 ( 76 x 67 ), nb_points 2891 ( 59 x 49 )
+    nb_cores 5100 ( 60 x 85 ), nb_points 2886 ( 74 x 39 )
+    nb_cores 5130 ( 114 x 45 ), nb_points 2880 ( 40 x 72 )
+    nb_cores 5150 ( 103 x 50 ), nb_points 2860 ( 44 x 65 )
+    nb_cores 5184 ( 72 x 72 ), nb_points 2852 ( 62 x 46 )
+    nb_cores 5185 ( 61 x 85 ), nb_points 2847 ( 73 x 39 )
+    nb_cores 5217 ( 111 x 47 ), nb_points 2829 ( 41 x 69 )
+    nb_cores 5250 ( 70 x 75 ), nb_points 2816 ( 64 x 44 )
+    nb_cores 5265 ( 117 x 45 ), nb_points 2808 ( 39 x 72 )
+    nb_cores 5280 ( 80 x 66 ), nb_points 2800 ( 56 x 50 )
+    nb_cores 5293 ( 79 x 67 ), nb_points 2793 ( 57 x 49 )
+    nb_cores 5320 ( 76 x 70 ), nb_points 2773 ( 59 x 47 )
+    nb_cores 5325 ( 71 x 75 ), nb_points 2772 ( 63 x 44 )
+    nb_cores 5355 ( 85 x 63 ), nb_points 2756 ( 53 x 52 )
+    nb_cores 5360 ( 80 x 67 ), nb_points 2744 ( 56 x 49 )
+    nb_cores 5400 ( 72 x 75 ), nb_points 2728 ( 62 x 44 )
+    nb_cores 5460 ( 78 x 70 ), nb_points 2726 ( 58 x 47 )
+    nb_cores 5467 ( 71 x 77 ), nb_points 2709 ( 63 x 43 )
+    nb_cores 5481 ( 87 x 63 ), nb_points 2704 ( 52 x 52 )
+    nb_cores 5490 ( 90 x 61 ), nb_points 2700 ( 50 x 54 )
+    nb_cores 5494 ( 82 x 67 ), nb_points 2695 ( 55 x 49 )
+    nb_cores 5499 ( 117 x 47 ), nb_points 2691 ( 39 x 69 )
+    nb_cores 5508 ( 108 x 51 ), nb_points 2688 ( 42 x 64 )
+    nb_cores 5530 ( 79 x 70 ), nb_points 2679 ( 57 x 47 )
+    nb_cores 5544 ( 72 x 77 ), nb_points 2666 ( 62 x 43 )
+    nb_cores 5550 ( 111 x 50 ), nb_points 2665 ( 41 x 65 )
+    nb_cores 5580 ( 90 x 62 ), nb_points 2650 ( 50 x 53 )
+    nb_cores 5600 ( 80 x 70 ), nb_points 2632 ( 56 x 47 )
+    nb_cores 5640 ( 120 x 47 ), nb_points 2622 ( 38 x 69 )
+    nb_cores 5670 ( 90 x 63 ), nb_points 2600 ( 50 x 52 )
+    nb_cores 5695 ( 85 x 67 ), nb_points 2597 ( 53 x 49 )
+    nb_cores 5700 ( 76 x 75 ), nb_points 2596 ( 59 x 44 )
+    nb_cores 5734 ( 94 x 61 ), nb_points 2592 ( 48 x 54 )
+    nb_cores 5740 ( 82 x 70 ), nb_points 2585 ( 55 x 47 )
+    nb_cores 5751 ( 71 x 81 ), nb_points 2583 ( 63 x 41 )
+    nb_cores 5760 ( 80 x 72 ), nb_points 2576 ( 56 x 46 )
+    nb_cores 5780 ( 68 x 85 ), nb_points 2574 ( 66 x 39 )
+    nb_cores 5796 ( 92 x 63 ), nb_points 2548 ( 49 x 52 )
+    nb_cores 5828 ( 94 x 62 ), nb_points 2544 ( 48 x 53 )
+    nb_cores 5832 ( 72 x 81 ), nb_points 2542 ( 62 x 41 )
+    nb_cores 5850 ( 117 x 50 ), nb_points 2535 ( 39 x 65 )
+    nb_cores 5893 ( 71 x 83 ), nb_points 2520 ( 63 x 40 )
+    nb_cores 5922 ( 94 x 63 ), nb_points 2496 ( 48 x 52 )
+    nb_cores 5950 ( 85 x 70 ), nb_points 2491 ( 53 x 47 )
+    nb_cores 5976 ( 72 x 83 ), nb_points 2480 ( 62 x 40 )
+    nb_cores 6000 ( 80 x 75 ), nb_points 2464 ( 56 x 44 )
+    nb_cores 6030 ( 90 x 67 ), nb_points 2450 ( 50 x 49 )
+    nb_cores 6048 ( 96 x 63 ), nb_points 2444 ( 47 x 52 )
+    nb_cores 6120 ( 72 x 85 ), nb_points 2418 ( 62 x 39 )
+    nb_cores 6157 ( 131 x 47 ), nb_points 2415 ( 35 x 69 )
+    nb_cores 6160 ( 80 x 77 ), nb_points 2408 ( 56 x 43 )
+    nb_cores 6164 ( 92 x 67 ), nb_points 2401 ( 49 x 49 )
+    nb_cores 6204 ( 94 x 66 ), nb_points 2400 ( 48 x 50 )
+    nb_cores 6230 ( 89 x 70 ), nb_points 2397 ( 51 x 47 )
+    nb_cores 6237 ( 99 x 63 ), nb_points 2392 ( 46 x 52 )
+    nb_cores 6258 ( 149 x 42 ), nb_points 2387 ( 31 x 77 )
+    nb_cores 6262 ( 101 x 62 ), nb_points 2385 ( 45 x 53 )
+    nb_cores 6283 ( 103 x 61 ), nb_points 2376 ( 44 x 54 )
+    nb_cores 6298 ( 94 x 67 ), nb_points 2352 ( 48 x 49 )
+    nb_cores 6300 ( 90 x 70 ), nb_points 2350 ( 50 x 47 )
+    nb_cores 6345 ( 135 x 47 ), nb_points 2346 ( 34 x 69 )
+    nb_cores 6363 ( 101 x 63 ), nb_points 2340 ( 45 x 52 )
+    nb_cores 6375 ( 85 x 75 ), nb_points 2332 ( 53 x 44 )
+    nb_cores 6390 ( 71 x 90 ), nb_points 2331 ( 63 x 37 )
+    nb_cores 6432 ( 96 x 67 ), nb_points 2303 ( 47 x 49 )
+    nb_cores 6460 ( 76 x 85 ), nb_points 2301 ( 59 x 39 )
+    nb_cores 6480 ( 72 x 90 ), nb_points 2294 ( 62 x 37 )
+    nb_cores 6489 ( 103 x 63 ), nb_points 2288 ( 44 x 52 )
+    nb_cores 6545 ( 85 x 77 ), nb_points 2279 ( 53 x 43 )
+    nb_cores 6550 ( 131 x 50 ), nb_points 2275 ( 35 x 65 )
+    nb_cores 6580 ( 94 x 70 ), nb_points 2256 ( 48 x 47 )
+    nb_cores 6624 ( 92 x 72 ), nb_points 2254 ( 49 x 46 )
+    nb_cores 6640 ( 80 x 83 ), nb_points 2240 ( 56 x 40 )
+    nb_cores 6678 ( 106 x 63 ), nb_points 2236 ( 43 x 52 )
+    nb_cores 6696 ( 108 x 62 ), nb_points 2226 ( 42 x 53 )
+    nb_cores 6715 ( 79 x 85 ), nb_points 2223 ( 57 x 39 )
+    nb_cores 6720 ( 96 x 70 ), nb_points 2209 ( 47 x 47 )
+    nb_cores 6750 ( 90 x 75 ), nb_points 2200 ( 50 x 44 )
+    nb_cores 6800 ( 80 x 85 ), nb_points 2184 ( 56 x 39 )
+    nb_cores 6840 ( 76 x 90 ), nb_points 2183 ( 59 x 37 )
+    nb_cores 6882 ( 111 x 62 ), nb_points 2173 ( 41 x 53 )
+    nb_cores 6900 ( 92 x 75 ), nb_points 2156 ( 49 x 44 )
+    nb_cores 6930 ( 90 x 77 ), nb_points 2150 ( 50 x 43 )
+    nb_cores 6970 ( 82 x 85 ), nb_points 2145 ( 55 x 39 )
+    nb_cores 6993 ( 111 x 63 ), nb_points 2132 ( 41 x 52 )
+    nb_cores 7040 ( 80 x 88 ), nb_points 2128 ( 56 x 38 )
+    nb_cores 7050 ( 94 x 75 ), nb_points 2112 ( 48 x 44 )
+    nb_cores 7084 ( 92 x 77 ), nb_points 2107 ( 49 x 43 )
+    nb_cores 7110 ( 90 x 79 ), nb_points 2100 ( 50 x 42 )
+    nb_cores 7182 ( 114 x 63 ), nb_points 2080 ( 40 x 52 )
+    nb_cores 7200 ( 96 x 75 ), nb_points 2068 ( 47 x 44 )
+    nb_cores 7225 ( 85 x 85 ), nb_points 2067 ( 53 x 39 )
+    nb_cores 7236 ( 108 x 67 ), nb_points 2058 ( 42 x 49 )
+    nb_cores 7290 ( 90 x 81 ), nb_points 2050 ( 50 x 41 )
+    nb_cores 7344 ( 72 x 102 ), nb_points 2046 ( 62 x 33 )
+    nb_cores 7371 ( 117 x 63 ), nb_points 2028 ( 39 x 52 )
+    nb_cores 7392 ( 96 x 77 ), nb_points 2021 ( 47 x 43 )
+    nb_cores 7426 ( 94 x 79 ), nb_points 2016 ( 48 x 42 )
+    nb_cores 7437 ( 111 x 67 ), nb_points 2009 ( 41 x 49 )
+    nb_cores 7470 ( 90 x 83 ), nb_points 2000 ( 50 x 40 )
+    nb_cores 7560 ( 108 x 70 ), nb_points 1974 ( 42 x 47 )
+    nb_cores 7614 ( 94 x 81 ), nb_points 1968 ( 48 x 41 )
+    nb_cores 7636 ( 92 x 83 ), nb_points 1960 ( 49 x 40 )
+    nb_cores 7650 ( 90 x 85 ), nb_points 1950 ( 50 x 39 )
+    nb_cores 7725 ( 103 x 75 ), nb_points 1936 ( 44 x 44 )
+    nb_cores 7770 ( 111 x 70 ), nb_points 1927 ( 41 x 47 )
+    nb_cores 7802 ( 94 x 83 ), nb_points 1920 ( 48 x 40 )
+    nb_cores 7820 ( 92 x 85 ), nb_points 1911 ( 49 x 39 )
+    nb_cores 7905 ( 85 x 93 ), nb_points 1908 ( 53 x 36 )
+    nb_cores 7920 ( 120 x 66 ), nb_points 1900 ( 38 x 50 )
+    nb_cores 7920 ( 90 x 88 ), nb_points 1900 ( 50 x 38 )
+    nb_cores 7931 ( 103 x 77 ), nb_points 1892 ( 44 x 43 )
+    nb_cores 7968 ( 96 x 83 ), nb_points 1880 ( 47 x 40 )
+    nb_cores 7990 ( 94 x 85 ), nb_points 1872 ( 48 x 39 )
+    nb_cores 8040 ( 120 x 67 ), nb_points 1862 ( 38 x 49 )
+    nb_cores 8100 ( 108 x 75 ), nb_points 1848 ( 42 x 44 )
+    nb_cores 8160 ( 96 x 85 ), nb_points 1833 ( 47 x 39 )
+    nb_cores 8253 ( 131 x 63 ), nb_points 1820 ( 35 x 52 )
+    nb_cores 8280 ( 92 x 90 ), nb_points 1813 ( 49 x 37 )
+    nb_cores 8316 ( 108 x 77 ), nb_points 1806 ( 42 x 43 )
+    nb_cores 8325 ( 111 x 75 ), nb_points 1804 ( 41 x 44 )
+    nb_cores 8370 ( 90 x 93 ), nb_points 1800 ( 50 x 36 )
+    nb_cores 8400 ( 120 x 70 ), nb_points 1786 ( 38 x 47 )
+    nb_cores 8460 ( 94 x 90 ), nb_points 1776 ( 48 x 37 )
+    nb_cores 8505 ( 135 x 63 ), nb_points 1768 ( 34 x 52 )
+    nb_cores 8532 ( 108 x 79 ), nb_points 1764 ( 42 x 42 )
+    nb_cores 8547 ( 111 x 77 ), nb_points 1763 ( 41 x 43 )
+    nb_cores 8549 ( 103 x 83 ), nb_points 1760 ( 44 x 40 )
+    nb_cores 8585 ( 101 x 85 ), nb_points 1755 ( 45 x 39 )
+    nb_cores 8640 ( 96 x 90 ), nb_points 1739 ( 47 x 37 )
+    nb_cores 8712 ( 72 x 121 ), nb_points 1736 ( 62 x 28 )
+    nb_cores 8742 ( 94 x 93 ), nb_points 1728 ( 48 x 36 )
+    nb_cores 8748 ( 108 x 81 ), nb_points 1722 ( 42 x 41 )
+    nb_cores 8755 ( 103 x 85 ), nb_points 1716 ( 44 x 39 )
+    nb_cores 8777 ( 131 x 67 ), nb_points 1715 ( 35 x 49 )
+    nb_cores 8880 ( 120 x 74 ), nb_points 1710 ( 38 x 45 )
+    nb_cores 8910 ( 90 x 99 ), nb_points 1700 ( 50 x 34 )
+    nb_cores 8910 ( 135 x 66 ), nb_points 1700 ( 34 x 50 )
+    nb_cores 8925 ( 85 x 105 ), nb_points 1696 ( 53 x 32 )
+    nb_cores 8928 ( 96 x 93 ), nb_points 1692 ( 47 x 36 )
+    nb_cores 8964 ( 108 x 83 ), nb_points 1680 ( 42 x 40 )
+    nb_cores 9000 ( 120 x 75 ), nb_points 1672 ( 38 x 44 )
+    nb_cores 9045 ( 135 x 67 ), nb_points 1666 ( 34 x 49 )
+    nb_cores 9072 ( 144 x 63 ), nb_points 1664 ( 32 x 52 )
+    nb_cores 9170 ( 131 x 70 ), nb_points 1645 ( 35 x 47 )
+    nb_cores 9180 ( 108 x 85 ), nb_points 1638 ( 42 x 39 )
+    nb_cores 9240 ( 120 x 77 ), nb_points 1634 ( 38 x 43 )
+    nb_cores 9270 ( 103 x 90 ), nb_points 1628 ( 44 x 37 )
+    nb_cores 9360 ( 80 x 117 ), nb_points 1624 ( 56 x 29 )
+    nb_cores 9380 ( 140 x 67 ), nb_points 1617 ( 33 x 49 )
+    nb_cores 9387 ( 149 x 63 ), nb_points 1612 ( 31 x 52 )
+    nb_cores 9432 ( 131 x 72 ), nb_points 1610 ( 35 x 46 )
+    nb_cores 9435 ( 111 x 85 ), nb_points 1599 ( 41 x 39 )
+    nb_cores 9450 ( 135 x 70 ), nb_points 1598 ( 34 x 47 )
+    nb_cores 9480 ( 120 x 79 ), nb_points 1596 ( 38 x 42 )
+    nb_cores 9540 ( 106 x 90 ), nb_points 1591 ( 43 x 37 )
+    nb_cores 9579 ( 103 x 93 ), nb_points 1584 ( 44 x 36 )
+    nb_cores 9648 ( 144 x 67 ), nb_points 1568 ( 32 x 49 )
+    nb_cores 9690 ( 114 x 85 ), nb_points 1560 ( 40 x 39 )
+    nb_cores 9720 ( 108 x 90 ), nb_points 1554 ( 42 x 37 )
+    nb_cores 9792 ( 96 x 102 ), nb_points 1551 ( 47 x 33 )
+    nb_cores 9810 ( 90 x 109 ), nb_points 1550 ( 50 x 31 )
+    nb_cores 9825 ( 131 x 75 ), nb_points 1540 ( 35 x 44 )
+    nb_cores 9870 ( 94 x 105 ), nb_points 1536 ( 48 x 32 )
+    nb_cores 9945 ( 117 x 85 ), nb_points 1521 ( 39 x 39 )
+    nb_cores 9960 ( 120 x 83 ), nb_points 1520 ( 38 x 40 )
+    nb_cores 9983 ( 149 x 67 ), nb_points 1519 ( 31 x 49 )
+    nb_cores 9990 ( 111 x 90 ), nb_points 1517 ( 41 x 37 )
+    nb_cores 10044 ( 108 x 93 ), nb_points 1512 ( 42 x 36 )
+    nb_cores 10080 ( 96 x 105 ), nb_points 1504 ( 47 x 32 )
+    nb_cores 10080 ( 144 x 70 ), nb_points 1504 ( 32 x 47 )
+    nb_cores 10125 ( 135 x 75 ), nb_points 1496 ( 34 x 44 )
+    nb_cores 10200 ( 120 x 85 ), nb_points 1482 ( 38 x 39 )
+    nb_cores 10260 ( 114 x 90 ), nb_points 1480 ( 40 x 37 )
+    nb_cores 10323 ( 111 x 93 ), nb_points 1476 ( 41 x 36 )
+    nb_cores 10349 ( 131 x 79 ), nb_points 1470 ( 35 x 42 )
+    nb_cores 10395 ( 135 x 77 ), nb_points 1462 ( 34 x 43 )
+    nb_cores 10430 ( 149 x 70 ), nb_points 1457 ( 31 x 47 )
+    nb_cores 10500 ( 140 x 75 ), nb_points 1452 ( 33 x 44 )
+    nb_cores 10530 ( 117 x 90 ), nb_points 1443 ( 39 x 37 )
+    nb_cores 10602 ( 114 x 93 ), nb_points 1440 ( 40 x 36 )
+    nb_cores 10611 ( 131 x 81 ), nb_points 1435 ( 35 x 41 )
+    nb_cores 10665 ( 135 x 79 ), nb_points 1428 ( 34 x 42 )
+    nb_cores 10720 ( 160 x 67 ), nb_points 1421 ( 29 x 49 )
+    nb_cores 10780 ( 140 x 77 ), nb_points 1419 ( 33 x 43 )
+    nb_cores 10800 ( 120 x 90 ), nb_points 1406 ( 38 x 37 )
+    nb_cores 10873 ( 131 x 83 ), nb_points 1400 ( 35 x 40 )
+    nb_cores 10935 ( 135 x 81 ), nb_points 1394 ( 34 x 41 )
+    nb_cores 10998 ( 94 x 117 ), nb_points 1392 ( 48 x 29 )
+    nb_cores 11016 ( 108 x 102 ), nb_points 1386 ( 42 x 33 )
+    nb_cores 11088 ( 144 x 77 ), nb_points 1376 ( 32 x 43 )
+    nb_cores 11132 ( 92 x 121 ), nb_points 1372 ( 49 x 28 )
+    nb_cores 11135 ( 131 x 85 ), nb_points 1365 ( 35 x 39 )
+    nb_cores 11175 ( 149 x 75 ), nb_points 1364 ( 31 x 44 )
+    nb_cores 11200 ( 160 x 70 ), nb_points 1363 ( 29 x 47 )
+    nb_cores 11205 ( 135 x 83 ), nb_points 1360 ( 34 x 40 )
+    nb_cores 11322 ( 111 x 102 ), nb_points 1353 ( 41 x 33 )
+    nb_cores 11340 ( 108 x 105 ), nb_points 1344 ( 42 x 32 )
+    nb_cores 11473 ( 149 x 77 ), nb_points 1333 ( 31 x 43 )
+    nb_cores 11475 ( 135 x 85 ), nb_points 1326 ( 34 x 39 )
+    nb_cores 11591 ( 173 x 67 ), nb_points 1323 ( 27 x 49 )
+    nb_cores 11616 ( 96 x 121 ), nb_points 1316 ( 47 x 28 )
+    nb_cores 11655 ( 111 x 105 ), nb_points 1312 ( 41 x 32 )
+    nb_cores 11771 ( 149 x 79 ), nb_points 1302 ( 31 x 42 )
+    nb_cores 11790 ( 131 x 90 ), nb_points 1295 ( 35 x 37 )
+    nb_cores 11880 ( 120 x 99 ), nb_points 1292 ( 38 x 34 )
+    nb_cores 11880 ( 135 x 88 ), nb_points 1292 ( 34 x 38 )
+    nb_cores 11900 ( 140 x 85 ), nb_points 1287 ( 33 x 39 )
+    nb_cores 11952 ( 144 x 83 ), nb_points 1280 ( 32 x 40 )
+    nb_cores 12000 ( 160 x 75 ), nb_points 1276 ( 29 x 44 )
+    nb_cores 12060 ( 180 x 67 ), nb_points 1274 ( 26 x 49 )
+    nb_cores 12069 ( 149 x 81 ), nb_points 1271 ( 31 x 41 )
+    nb_cores 12096 ( 96 x 126 ), nb_points 1269 ( 47 x 27 )
+    nb_cores 12150 ( 135 x 90 ), nb_points 1258 ( 34 x 37 )
+    nb_cores 12240 ( 144 x 85 ), nb_points 1248 ( 32 x 39 )
+    nb_cores 12320 ( 160 x 77 ), nb_points 1247 ( 29 x 43 )
+    nb_cores 12367 ( 149 x 83 ), nb_points 1240 ( 31 x 40 )
+    nb_cores 12463 ( 103 x 121 ), nb_points 1232 ( 44 x 28 )
+    nb_cores 12543 ( 111 x 113 ), nb_points 1230 ( 41 x 30 )
+    nb_cores 12555 ( 135 x 93 ), nb_points 1224 ( 34 x 36 )
+    nb_cores 12600 ( 120 x 105 ), nb_points 1216 ( 38 x 32 )
+    nb_cores 12665 ( 149 x 85 ), nb_points 1209 ( 31 x 39 )
+    nb_cores 12826 ( 106 x 121 ), nb_points 1204 ( 43 x 28 )
+    nb_cores 12865 ( 155 x 83 ), nb_points 1200 ( 30 x 40 )
+    nb_cores 12960 ( 144 x 90 ), nb_points 1184 ( 32 x 37 )
+    nb_cores 13068 ( 108 x 121 ), nb_points 1176 ( 42 x 28 )
+    nb_cores 13152 ( 96 x 137 ), nb_points 1175 ( 47 x 25 )
+    nb_cores 13175 ( 155 x 85 ), nb_points 1170 ( 30 x 39 )
+    nb_cores 13280 ( 160 x 83 ), nb_points 1160 ( 29 x 40 )
+    nb_cores 13362 ( 131 x 102 ), nb_points 1155 ( 35 x 33 )
+    nb_cores 13392 ( 144 x 93 ), nb_points 1152 ( 32 x 36 )
+    nb_cores 13410 ( 149 x 90 ), nb_points 1147 ( 31 x 37 )
+    nb_cores 13500 ( 180 x 75 ), nb_points 1144 ( 26 x 44 )
+    nb_cores 13560 ( 120 x 113 ), nb_points 1140 ( 38 x 30 )
+    nb_cores 13600 ( 160 x 85 ), nb_points 1131 ( 29 x 39 )
+    nb_cores 13728 ( 96 x 143 ), nb_points 1128 ( 47 x 24 )
+    nb_cores 13755 ( 131 x 105 ), nb_points 1120 ( 35 x 32 )
+    nb_cores 13857 ( 149 x 93 ), nb_points 1116 ( 31 x 36 )
+    nb_cores 13950 ( 155 x 90 ), nb_points 1110 ( 30 x 37 )
+    nb_cores 13986 ( 111 x 126 ), nb_points 1107 ( 41 x 27 )
+    nb_cores 14040 ( 120 x 117 ), nb_points 1102 ( 38 x 29 )
+    nb_cores 14100 ( 188 x 75 ), nb_points 1100 ( 25 x 44 )
+    nb_cores 14157 ( 117 x 121 ), nb_points 1092 ( 39 x 28 )
+    nb_cores 14175 ( 135 x 105 ), nb_points 1088 ( 34 x 32 )
+    nb_cores 14279 ( 131 x 109 ), nb_points 1085 ( 35 x 31 )
+    nb_cores 14359 ( 173 x 83 ), nb_points 1080 ( 27 x 40 )
+    nb_cores 14400 ( 160 x 90 ), nb_points 1073 ( 29 x 37 )
+    nb_cores 14520 ( 120 x 121 ), nb_points 1064 ( 38 x 28 )
+    nb_cores 14688 ( 144 x 102 ), nb_points 1056 ( 32 x 33 )
+    nb_cores 14705 ( 173 x 85 ), nb_points 1053 ( 27 x 39 )
+    nb_cores 14796 ( 108 x 137 ), nb_points 1050 ( 42 x 25 )
+    nb_cores 14880 ( 160 x 93 ), nb_points 1044 ( 29 x 36 )
+    nb_cores 14940 ( 180 x 83 ), nb_points 1040 ( 26 x 40 )
+    nb_cores 15004 ( 124 x 121 ), nb_points 1036 ( 37 x 28 )
+    nb_cores 15120 ( 144 x 105 ), nb_points 1024 ( 32 x 32 )
+    nb_cores 15198 ( 149 x 102 ), nb_points 1023 ( 31 x 33 )
+    nb_cores 15255 ( 135 x 113 ), nb_points 1020 ( 34 x 30 )
+    nb_cores 15300 ( 180 x 85 ), nb_points 1014 ( 26 x 39 )
+    nb_cores 15444 ( 108 x 143 ), nb_points 1008 ( 42 x 24 )
+    nb_cores 15570 ( 173 x 90 ), nb_points 999 ( 27 x 37 )
+    nb_cores 15645 ( 149 x 105 ), nb_points 992 ( 31 x 32 )
+    nb_cores 15795 ( 135 x 117 ), nb_points 986 ( 34 x 29 )
+    nb_cores 15851 ( 131 x 121 ), nb_points 980 ( 35 x 28 )
+    nb_cores 15980 ( 188 x 85 ), nb_points 975 ( 25 x 39 )
+    nb_cores 16089 ( 173 x 93 ), nb_points 972 ( 27 x 36 )
+    nb_cores 16200 ( 180 x 90 ), nb_points 962 ( 26 x 37 )
+    nb_cores 16241 ( 149 x 109 ), nb_points 961 ( 31 x 31 )
+    nb_cores 16272 ( 144 x 113 ), nb_points 960 ( 32 x 30 )
+    nb_cores 16320 ( 160 x 102 ), nb_points 957 ( 29 x 33 )
+    nb_cores 16335 ( 135 x 121 ), nb_points 952 ( 34 x 28 )
+    nb_cores 16440 ( 120 x 137 ), nb_points 950 ( 38 x 25 )
+    nb_cores 16506 ( 131 x 126 ), nb_points 945 ( 35 x 27 )
+    nb_cores 16650 ( 111 x 150 ), nb_points 943 ( 41 x 23 )
+    nb_cores 16731 ( 117 x 143 ), nb_points 936 ( 39 x 24 )
+    nb_cores 16800 ( 160 x 105 ), nb_points 928 ( 29 x 32 )
+    nb_cores 16920 ( 188 x 90 ), nb_points 925 ( 25 x 37 )
+    nb_cores 16940 ( 140 x 121 ), nb_points 924 ( 33 x 28 )
+    nb_cores 17010 ( 135 x 126 ), nb_points 918 ( 34 x 27 )
+    nb_cores 17160 ( 120 x 143 ), nb_points 912 ( 38 x 24 )
+    nb_cores 17280 ( 180 x 96 ), nb_points 910 ( 26 x 35 )
+    nb_cores 17424 ( 144 x 121 ), nb_points 896 ( 32 x 28 )
+    nb_cores 17640 ( 140 x 126 ), nb_points 891 ( 33 x 27 )
+    nb_cores 17730 ( 197 x 90 ), nb_points 888 ( 24 x 37 )
+    nb_cores 17820 ( 135 x 132 ), nb_points 884 ( 34 x 26 )
+    nb_cores 17820 ( 180 x 99 ), nb_points 884 ( 26 x 34 )
+    nb_cores 17928 ( 216 x 83 ), nb_points 880 ( 22 x 40 )
+    nb_cores 17947 ( 131 x 137 ), nb_points 875 ( 35 x 25 )
+    nb_cores 18000 ( 120 x 150 ), nb_points 874 ( 38 x 23 )
+    nb_cores 18029 ( 149 x 121 ), nb_points 868 ( 31 x 28 )
+    nb_cores 18144 ( 144 x 126 ), nb_points 864 ( 32 x 27 )
+    nb_cores 18360 ( 180 x 102 ), nb_points 858 ( 26 x 33 )
+    nb_cores 18360 ( 216 x 85 ), nb_points 858 ( 22 x 39 )
+    nb_cores 18495 ( 135 x 137 ), nb_points 850 ( 34 x 25 )
+    nb_cores 18720 ( 160 x 117 ), nb_points 841 ( 29 x 29 )
+    nb_cores 18733 ( 131 x 143 ), nb_points 840 ( 35 x 24 )
+    nb_cores 18774 ( 149 x 126 ), nb_points 837 ( 31 x 27 )
+    nb_cores 18900 ( 180 x 105 ), nb_points 832 ( 26 x 32 )
+    nb_cores 19158 ( 206 x 93 ), nb_points 828 ( 23 x 36 )
+    nb_cores 19176 ( 188 x 102 ), nb_points 825 ( 25 x 33 )
+    nb_cores 19305 ( 135 x 143 ), nb_points 816 ( 34 x 24 )
+    nb_cores 19360 ( 160 x 121 ), nb_points 812 ( 29 x 28 )
+    nb_cores 19530 ( 155 x 126 ), nb_points 810 ( 30 x 27 )
+    nb_cores 19620 ( 180 x 109 ), nb_points 806 ( 26 x 31 )
+    nb_cores 19650 ( 131 x 150 ), nb_points 805 ( 35 x 23 )
+    nb_cores 19728 ( 144 x 137 ), nb_points 800 ( 32 x 25 )
+    nb_cores 19920 ( 120 x 166 ), nb_points 798 ( 38 x 21 )
+    nb_cores 20020 ( 140 x 143 ), nb_points 792 ( 33 x 24 )
+    nb_cores 20160 ( 160 x 126 ), nb_points 783 ( 29 x 27 )
+    nb_cores 20250 ( 135 x 150 ), nb_points 782 ( 34 x 23 )
+    nb_cores 20340 ( 180 x 113 ), nb_points 780 ( 26 x 30 )
+    nb_cores 20413 ( 149 x 137 ), nb_points 775 ( 31 x 25 )
+    nb_cores 20592 ( 144 x 143 ), nb_points 768 ( 32 x 24 )
+    nb_cores 20933 ( 173 x 121 ), nb_points 756 ( 27 x 28 )
+    nb_cores 21060 ( 180 x 117 ), nb_points 754 ( 26 x 29 )
+    nb_cores 21235 ( 155 x 137 ), nb_points 750 ( 30 x 25 )
+    nb_cores 21307 ( 149 x 143 ), nb_points 744 ( 31 x 24 )
+    nb_cores 21600 ( 144 x 150 ), nb_points 736 ( 32 x 23 )
+    nb_cores 21746 ( 131 x 166 ), nb_points 735 ( 35 x 21 )
+    nb_cores 21780 ( 180 x 121 ), nb_points 728 ( 26 x 28 )
+    nb_cores 21920 ( 160 x 137 ), nb_points 725 ( 29 x 25 )
+    nb_cores 22165 ( 155 x 143 ), nb_points 720 ( 30 x 24 )
+    nb_cores 22350 ( 149 x 150 ), nb_points 713 ( 31 x 23 )
+    nb_cores 22680 ( 180 x 126 ), nb_points 702 ( 26 x 27 )
+    nb_cores 22748 ( 188 x 121 ), nb_points 700 ( 25 x 28 )
+    nb_cores 22880 ( 160 x 143 ), nb_points 696 ( 29 x 24 )
+    nb_cores 23240 ( 140 x 166 ), nb_points 693 ( 33 x 21 )
+    nb_cores 23250 ( 155 x 150 ), nb_points 690 ( 30 x 23 )
+    nb_cores 23542 ( 149 x 158 ), nb_points 682 ( 31 x 22 )
+    nb_cores 23625 ( 135 x 175 ), nb_points 680 ( 34 x 20 )
+    nb_cores 23688 ( 188 x 126 ), nb_points 675 ( 25 x 27 )
+    nb_cores 23837 ( 197 x 121 ), nb_points 672 ( 24 x 28 )
+    nb_cores 24000 ( 160 x 150 ), nb_points 667 ( 29 x 23 )
+    nb_cores 24235 ( 131 x 185 ), nb_points 665 ( 35 x 19 )
+    nb_cores 24408 ( 216 x 113 ), nb_points 660 ( 22 x 30 )
+    nb_cores 24660 ( 180 x 137 ), nb_points 650 ( 26 x 25 )
+    nb_cores 24739 ( 173 x 143 ), nb_points 648 ( 27 x 24 )
+    nb_cores 24926 ( 206 x 121 ), nb_points 644 ( 23 x 28 )
+    nb_cores 25200 ( 240 x 105 ), nb_points 640 ( 20 x 32 )
+    nb_cores 25200 ( 144 x 175 ), nb_points 640 ( 32 x 20 )
+    nb_cores 25272 ( 216 x 117 ), nb_points 638 ( 22 x 29 )
+    nb_cores 25730 ( 155 x 166 ), nb_points 630 ( 30 x 21 )
+    nb_cores 25740 ( 180 x 143 ), nb_points 624 ( 26 x 24 )
+    nb_cores 25950 ( 173 x 150 ), nb_points 621 ( 27 x 23 )
+    nb_cores 26075 ( 149 x 175 ), nb_points 620 ( 31 x 20 )
+    nb_cores 26136 ( 216 x 121 ), nb_points 616 ( 22 x 28 )
+    nb_cores 26560 ( 160 x 166 ), nb_points 609 ( 29 x 21 )
+    nb_cores 26640 ( 144 x 185 ), nb_points 608 ( 32 x 19 )
+    nb_cores 26884 ( 188 x 143 ), nb_points 600 ( 25 x 24 )
+    nb_cores 27000 ( 180 x 150 ), nb_points 598 ( 26 x 23 )
+    nb_cores 27216 ( 216 x 126 ), nb_points 594 ( 22 x 27 )
+    nb_cores 27565 ( 149 x 185 ), nb_points 589 ( 31 x 19 )
+    nb_cores 27588 ( 228 x 121 ), nb_points 588 ( 21 x 28 )
+    nb_cores 28000 ( 160 x 175 ), nb_points 580 ( 29 x 20 )
+    nb_cores 28171 ( 197 x 143 ), nb_points 576 ( 24 x 24 )
+    nb_cores 28200 ( 188 x 150 ), nb_points 575 ( 25 x 23 )
+    nb_cores 28440 ( 180 x 158 ), nb_points 572 ( 26 x 22 )
+    nb_cores 28675 ( 155 x 185 ), nb_points 570 ( 30 x 19 )
+    nb_cores 28718 ( 173 x 166 ), nb_points 567 ( 27 x 21 )
+    nb_cores 29040 ( 240 x 121 ), nb_points 560 ( 20 x 28 )
+    nb_cores 29353 ( 149 x 197 ), nb_points 558 ( 31 x 18 )
+    nb_cores 29458 ( 206 x 143 ), nb_points 552 ( 23 x 24 )
+    nb_cores 29592 ( 216 x 137 ), nb_points 550 ( 22 x 25 )
+    nb_cores 29880 ( 180 x 166 ), nb_points 546 ( 26 x 21 )
+    nb_cores 30240 ( 240 x 126 ), nb_points 540 ( 20 x 27 )
+    nb_cores 30855 ( 255 x 121 ), nb_points 532 ( 19 x 28 )
+    nb_cores 30888 ( 216 x 143 ), nb_points 528 ( 22 x 24 )
+    nb_cores 31208 ( 188 x 166 ), nb_points 525 ( 25 x 21 )
+    nb_cores 31500 ( 180 x 175 ), nb_points 520 ( 26 x 20 )
+    nb_cores 32005 ( 173 x 185 ), nb_points 513 ( 27 x 19 )
+    nb_cores 32400 ( 216 x 150 ), nb_points 506 ( 22 x 23 )
+    nb_cores 32604 ( 228 x 143 ), nb_points 504 ( 21 x 24 )
+    nb_cores 32880 ( 240 x 137 ), nb_points 500 ( 20 x 25 )
+    nb_cores 33300 ( 180 x 185 ), nb_points 494 ( 26 x 19 )
+    nb_cores 33600 ( 160 x 210 ), nb_points 493 ( 29 x 17 )
+    nb_cores 34020 ( 270 x 126 ), nb_points 486 ( 18 x 27 )
+    nb_cores 34128 ( 216 x 158 ), nb_points 484 ( 22 x 22 )
+    nb_cores 34196 ( 206 x 166 ), nb_points 483 ( 23 x 21 )
+    nb_cores 34320 ( 240 x 143 ), nb_points 480 ( 20 x 24 )
+    nb_cores 34780 ( 188 x 185 ), nb_points 475 ( 25 x 19 )
+    nb_cores 35460 ( 180 x 197 ), nb_points 468 ( 26 x 18 )
+    nb_cores 35856 ( 216 x 166 ), nb_points 462 ( 22 x 21 )
+    nb_cores 36000 ( 240 x 150 ), nb_points 460 ( 20 x 23 )
+    nb_cores 36288 ( 288 x 126 ), nb_points 459 ( 17 x 27 )
+    nb_cores 36445 ( 197 x 185 ), nb_points 456 ( 24 x 19 )
+    nb_cores 36990 ( 270 x 137 ), nb_points 450 ( 18 x 25 )
+    nb_cores 37389 ( 309 x 121 ), nb_points 448 ( 16 x 28 )
+    nb_cores 37800 ( 216 x 175 ), nb_points 440 ( 22 x 20 )
+    nb_cores 38110 ( 206 x 185 ), nb_points 437 ( 23 x 19 )
+    nb_cores 38610 ( 270 x 143 ), nb_points 432 ( 18 x 24 )
+    nb_cores 39456 ( 288 x 137 ), nb_points 425 ( 17 x 25 )
+    nb_cores 39840 ( 240 x 166 ), nb_points 420 ( 20 x 21 )
+    nb_cores 39960 ( 216 x 185 ), nb_points 418 ( 22 x 19 )
+    nb_cores 40500 ( 270 x 150 ), nb_points 414 ( 18 x 23 )
+    nb_cores 41184 ( 288 x 143 ), nb_points 408 ( 17 x 24 )
+    nb_cores 41866 ( 173 x 242 ), nb_points 405 ( 27 x 15 )
+    nb_cores 42000 ( 240 x 175 ), nb_points 400 ( 20 x 20 )
+    nb_cores 42180 ( 228 x 185 ), nb_points 399 ( 21 x 19 )
+    nb_cores 42552 ( 216 x 197 ), nb_points 396 ( 22 x 18 )
+    nb_cores 43200 ( 288 x 150 ), nb_points 391 ( 17 x 23 )
+    nb_cores 43560 ( 180 x 242 ), nb_points 390 ( 26 x 15 )
+    nb_cores 44187 ( 309 x 143 ), nb_points 384 ( 16 x 24 )
+    nb_cores 44400 ( 240 x 185 ), nb_points 380 ( 20 x 19 )
+    nb_cores 44820 ( 270 x 166 ), nb_points 378 ( 18 x 21 )
+    nb_cores 45360 ( 216 x 210 ), nb_points 374 ( 22 x 17 )
+    nb_cores 46350 ( 309 x 150 ), nb_points 368 ( 16 x 23 )
+    nb_cores 46350 ( 206 x 225 ), nb_points 368 ( 23 x 16 )
+    nb_cores 47175 ( 255 x 185 ), nb_points 361 ( 19 x 19 )
+    nb_cores 47250 ( 270 x 175 ), nb_points 360 ( 18 x 20 )
+    nb_cores 47808 ( 288 x 166 ), nb_points 357 ( 17 x 21 )
+    nb_cores 48600 ( 216 x 225 ), nb_points 352 ( 22 x 16 )
+    nb_cores 49320 ( 360 x 137 ), nb_points 350 ( 14 x 25 )
+    nb_cores 49852 ( 206 x 242 ), nb_points 345 ( 23 x 15 )
+    nb_cores 49950 ( 270 x 185 ), nb_points 342 ( 18 x 19 )
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg	(revision 10136)
@@ -0,0 +1,1 @@
+link namelist_cfg_orca12_like
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg_orca12_like
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg_orca12_like	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_cfg_orca12_like	(revision 10136)
@@ -0,0 +1,212 @@
+! vim: ft=fortran :
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  BENCH Configuration namelist : overwrite some defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   'BENCH' !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =    1000   !  last time step 
+   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+/
+!-----------------------------------------------------------------------
+&namusr_def    !   User defined :   BENCH configuration: Flat bottom, beta-plane
+!-----------------------------------------------------------------------
+   nn_isize   =   4322     ! number of point in i-direction of global(local) domain if >0 (<0)  
+   nn_jsize   =   3147     ! number of point in j-direction of global(local) domain if >0 (<0)  
+   nn_ksize   =   75       ! total number of point in k-direction
+   nn_perio   =   4        ! periodicity
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+!-----------------------------------------------------------------------
+   ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
+   jpni        =   3       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =   3       !  jpnj   number of processors following j (set automatically if < 1)
+!   nn_comm_mod  =   1      !  step routine call frequency
+!   ln_comm_only = .false.  !  replace step routine by realistic communications only
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   ln_timing   = .true.   !  timing by routine write out in timing.output file
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   rn_rdt      =    300.   !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =   0.05    !  asselin time filter parameter
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+  ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+/
+
+!
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid   (read by child model only)       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  free slip
+/
+
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_OFF =F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_OFF =F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_non_lin  = .true.   !  non-linear  drag: Cd = Cd0 |U|
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbc   = .true.   !  Apply a geothermal heating at the ocean bottom
+      nn_geoflx     = 1       !  geothermal heat flux: = 1 constant flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbl   = .true.   !  Bottom Boundary Layer parameterisation flag
+/
+
+!!======================================================================
+!!                        Tracer (T & S) namelists                    !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_teos10   = .true.         !  = Use TEOS-10
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_fct = .true.  !  FCT scheme
+      nn_fct_h   =  4            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  4            !  =2/4, vertical   2nd / COMPACT 4th order
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_blp   = .true.   !    laplacian operator
+   ln_traldf_iso   = .true.   !  iso-neutral (standard operator)
+   !
+   ln_traldf_msc   = .true.   !  Method of Stabilizing Correction      (both operators)
+   nn_aht_ijk_t    = 20       !  space/time variation of eddy coefficient:
+/
+!-----------------------------------------------------------------------
+&namtra_mle    !   mixed layer eddy parametrisation (Fox-Kemper)       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_mle      = .false.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+/
+!-----------------------------------------------------------------------
+&namtra_eiv    !   eddy induced velocity param.                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ldfeiv   = .false.   ! use eddy induced velocity parameterization
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nam_vvl       !   vertical coordinate options                          (default: z-star)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  z-star vertical coordinate
+   ln_vvl_dbg    = .false.          !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_ubs = .true. !  flux form - 3rd order UBS      scheme
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_een = .true. !  energy & enstrophy scheme
+      nn_een_e3f = 0          ! =0  e3f = mi(mj(e3t))/4 
+      !                       ! =1  e3f = mi(mj(e3t))/mi(mj( tmask))
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts   = .true.   ! split-explicit free surface
+      ln_bt_auto    = .false.    ! Number of sub-step defined from:
+         nn_baro      =  30         ! =F : the number of sub-step in rn_rdt seconds
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynldf_OFF = .true.     !  No operator (i.e. no explicit diffusion)
+/
+
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics                                     (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdftke   = .true.       !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
+   ln_zdfevd   = .true.       !  enhanced vertical diffusion
+   ln_zdfddm   = .true.       ! double diffusive mixing
+   ln_zdfiwm   = .true.       ! internal wave-induced mixing            (T =>   fill namzdf_iwm)
+/
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_ref
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_ref	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/namelist_ref	(revision 10136)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/sh_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/sh_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/sh_bench	(revision 10136)
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -u
+#set -xv
+
+resolution=${1:?"you must provide the resolution: 1 025 or 12"}
+mincore=${2:-1} # minimum number of core to be tested
+maxcore=${3:-0} # maximum number of core to be tested
+
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+case $machine in 
+    "beaufixlogin") ncore_node=40 ;;
+    "curie")        ncore_node=16 ;;
+    "irene")        ncore_node=48 ;;
+    *) echo "you must add your machine \"$machine\" with its number of cores per node" ; exit 1 ;;
+esac
+
+[ $mincore -eq 1 ] && targetnb=$ncore_node || targetnb=$mincore
+#
+# build the list of experiences:
+# must be a multiple of ncore_node and as close as possible of the targeted number of core
+#
+n1=0
+list=""
+
+# Prepare gnuplot data file
+dateref=$( date "+%Y%m%d-%Hh%Mm%Ss" )
+echo "# nb_proc    jpi    jpj" > gnuplot_tbc_${resolution}_${dateref}.dat
+nbl=$( cat best_jpni_jpnj_eorca${resolution} | wc -l )
+for ll in $( seq 1 $nbl )
+do
+    line=$( sed -n ${ll}p best_jpni_jpnj_eorca${resolution} )    # for each line
+    nn=$( echo $line | sed -e "s/.*nb_cores \([0-9]*\).*/\1/" )  # get the number of core
+    [ $maxcore -gt 1 -a $nn -gt $maxcore ] && break              # if below $maxcore (if specified)
+        if [ $(( $nn % $ncore_node )) -eq 0 ]                    # if it is a multiple of $ncore_node
+        then
+            if [ $nn -lt $targetnb ]
+            then
+                n1=$nn       # store the number of core
+                line1=$line  # store the line
+            else
+                [ $(( $targetnb - $n1 )) -le $(( $nn -$targetnb )) ] && line=$line1   # keep the previous line
+                echo $line
+                nb=$( echo $line | sed -e "s/[^(]*( \([0-9]*\) x \([0-9]*\) .*/\1*\2/" ) # get jpni*jpnj
+                list="${list} ${nb}"
+                targetnb=$(( $targetnb * 2 ))
+                subsize=$( echo $line | awk {'printf "%d   %d", $11, $13'})
+                corenb=$( echo $line | awk {'printf "%d", $2'})
+                echo "$corenb  $subsize" >> gnuplot_tbc_${resolution}.dat
+            fi
+        fi
+done
+echo $list
+
+for cores in $list
+do
+    ./submit_bench $cores $ncore_node ${resolution} ${dateref}
+done
+
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/submit_bench
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/submit_bench	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/EXPREF/submit_bench	(revision 10136)
@@ -0,0 +1,197 @@
+#!/bin/bash
+#  
+#  BENCH launching scripts for beaufix, Meteo-France
+#                          and curie, TGCC
+#  To be modified for other machines
+#
+set -u
+set -vx
+#
+cores=$1
+ncore_node=$2
+resolution=$3
+dateref=$4
+machine=$( hostname | sed -e "s/[0-9]*//g" )
+#
+# number of processes for each executable
+    nproc_exe1=$( echo $cores | bc )
+  (( nproc = $nproc_exe1 ))
+(( nnode = $nproc / $ncore_node ))
+[ $nnode -lt 1 ] && nnode=1
+
+nproc5=$( printf "%05d\n" ${nproc_exe1} )
+
+######################################################################
+### beaufixlogin
+######################################################################
+
+if [ "$machine" == "beaufixlogin" ]
+then
+    
+cat > Log/run_bench << EOF
+#!/bin/bash
+#SBATCH --time=00:1:00
+#SBATCH -p  normal64         # partition/queue
+#SBATCH --job-name=bench      # job name
+#SBATCH -N $nnode            # number of nodes
+#SBATCH -n $nproc            # number of procs
+#SBATCH -o /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH -e /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/Log/job.out%j
+#SBATCH --exclusive
+
+module unload intelmpi intel grib_api
+module load intel/16.1.150 intelmpi/5.1.2.150
+
+itac=0
+xpmpi=0
+
+if [ \$xpmpi == 1 ]; then
+  module load bullxde
+  module load xPMPI/1.1_intelmpi
+fi
+
+[ \$itac == 1 ] && module load itac/2017.2.028
+
+set -vx
+
+cd \${TMPDIR}
+cp /scratch/work/cglo315/ESIWACE/dev_r9759_HPC09_ESIWACE/tests/LBENCH_RN/EXP00/* .
+
+# Best decompositions BENCH-1
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+export OMP_NUM_THREADS=1
+ulimit -s unlimited
+#
+if [ \$itac == 1 ]; then
+  source /opt/softs/intel/2017/update_1/itac_latest/bin/itacvars.sh
+  time mpirun -ordered-output -prepend-rank -trace -np $nproc_exe1 ./nemo > jobout 2>joberr
+else
+  time mpirun -ordered-output -prepend-rank -np $nproc_exe1 ./nemo > jobout_${resolution}_${nproc5}
+fi
+/opt/softs/bin/ja
+
+if [ \$xpmpi == 1 ]; then
+  module unload xPMPI/1.1_intelmpi
+  module unload bullxde
+fi
+#
+EOF
+
+
+### 4. Execute the model
+
+    echo 'Submitting the job to queue using sbatch'
+    sbatch Log/run_bench
+    squeue -u cglo315
+
+echo 'is executed or submitted to queue.'
+
+
+fi
+
+######################################################################
+### curie or irene
+######################################################################
+
+if [[ ( "$machine" == "curie" ) || ( "$machine" == "irene" ) ]]
+then
+    
+    case ${resolution} in
+	"1")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=1800
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=900
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"025")
+	    if [ $nproc_exe1 -lt 50 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 100 ]
+	    then
+		timejob=7000
+	    elif [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=3600
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=2000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=1000
+	    else
+		timejob=600
+	    fi
+	    ;;
+	"12")
+	    if [ $nproc_exe1 -lt 200 ]
+	    then
+		timejob=30000
+	    elif [ $nproc_exe1 -lt 400 ]
+	    then
+		timejob=15000
+	    elif [ $nproc_exe1 -lt 800 ]
+	    then
+		timejob=8000
+	    elif [ $nproc_exe1 -lt 1600 ]
+	    then
+		timejob=5000
+	    elif [ $nproc_exe1 -lt 3200 ]
+	    then
+		timejob=2500
+	    else
+		timejob=1200
+	    fi
+	;;
+    esac
+
+    [ "$machine" == "curie" ] && queuename=standard || queuename=skylake
+    
+    jobname=$HOME/binrun/jobbench
+    cat > $jobname << EOF
+#!/bin/bash
+#MSUB -r bench${nproc5}
+#MSUB -n ${nproc_exe1}
+#MSUB -T $timejob
+#MSUB -e bench_${resolution}_${nproc5}_%I.eo
+#MSUB -o bench_${resolution}_${nproc5}_%I.eo
+#MSUB -j oe
+#MSUB -x
+#MSUB -q ${queuename}
+#MSUB -A gen6895
+#==========================================
+set -u
+#
+
+cd \${BRIDGE_MSUB_PWD}/..
+
+
+EXPjob=EXP_${resolution}_${nproc5}_${dateref}
+rsync -av --exclude="*eo" EXPREF/ \${EXPjob}/
+rsync -av EXP00/nemo \${EXPjob}/nemo
+cd \${EXPjob}
+
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
+
+time ccc_mprun -n \${BRIDGE_MSUB_NPROC} ./nemo > jobout_${resolution}_${nproc5}_${dateref}
+
+EOF
+
+    ccc_msub $jobname
+
+fi
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/diawri.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/diawri.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/diawri.F90	(revision 10136)
@@ -0,0 +1,586 @@
+MODULE diawri
+   !!======================================================================
+   !!                     ***  MODULE  diawri  ***
+   !! Ocean diagnostics :  write ocean output files
+   !!=====================================================================
+   !! History :  OPA  ! 1991-03  (M.-A. Foujols)  Original code
+   !!            4.0  ! 1991-11  (G. Madec)
+   !!                 ! 1992-06  (M. Imbard)  correction restart file
+   !!                 ! 1992-07  (M. Imbard)  split into diawri and rstwri
+   !!                 ! 1993-03  (M. Imbard)  suppress writibm
+   !!                 ! 1998-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
+   !!                 ! 1999-02  (E. Guilyardi)  name of netCDF files + variables
+   !!            8.2  ! 2000-06  (M. Imbard)  Original code (diabort.F)
+   !!   NEMO     1.0  ! 2002-06  (A.Bozec, E. Durand)  Original code (diainit.F)
+   !!             -   ! 2002-09  (G. Madec)  F90: Free form and module
+   !!             -   ! 2002-12  (G. Madec)  merge of diabort and diainit, F90
+   !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
+   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
+   !!                 !                     change name of output variables in dia_wri_state
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_wri       : create the standart output files
+   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers 
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE dianam         ! build name of file (routine)
+   USE diahth         ! thermocline diagnostics
+   USE dynadv   , ONLY: ln_dynadv_vec
+   USE icb_oce        ! Icebergs
+   USE icbdia         ! Iceberg budgets
+   USE ldftra         ! lateral physics: eddy diffusivity coef.
+   USE ldfdyn         ! lateral physics: eddy viscosity   coef.
+   USE sbc_oce        ! Surface boundary condition: ocean fields
+   USE sbc_ice        ! Surface boundary condition: ice fields
+   USE sbcssr         ! restoring term toward SST/SSS climatology
+   USE sbcwave        ! wave parameters
+   USE wet_dry        ! wetting and drying
+   USE zdf_oce        ! ocean vertical physics
+   USE zdfdrg         ! ocean vertical physics: top/bottom friction
+   USE zdfmxl         ! mixed layer
+   !
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager ! I/O manager
+   USE diatmb         ! Top,middle,bottom output
+   USE dia25h         ! 25h Mean output
+   USE iom            ! 
+   USE ioipsl         ! 
+
+#if defined key_si3
+   USE icewri 
+#endif
+   USE lib_mpp         ! MPP library
+   USE timing          ! preformance summary
+   USE diurnal_bulk    ! diurnal warm layer
+   USE cool_skin       ! Cool skin
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_wri                 ! routines called by step.F90
+   PUBLIC   dia_wri_state
+   PUBLIC   dia_wri_alloc           ! Called by nemogcm module
+
+   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT   ! grid_T file
+   INTEGER ::          nb_T              , ndim_bT   ! grid_T file
+   INTEGER ::   nid_U, nz_U, nh_U, ndim_U, ndim_hU   ! grid_U file
+   INTEGER ::   nid_V, nz_V, nh_V, ndim_V, ndim_hV   ! grid_V file
+   INTEGER ::   nid_W, nz_W, nh_W                    ! grid_W file
+   INTEGER ::   ndex(1)                              ! ???
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V
+   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_bT
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: diawri.F90 9598 2018-05-15 22:47:16Z nicolasmartin $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if defined key_iomput
+   !!----------------------------------------------------------------------
+   !!   'key_iomput'                                        use IOM library
+   !!----------------------------------------------------------------------
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   
+   SUBROUTINE dia_wri( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_wri  ***
+      !!                   
+      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
+      !!      NETCDF format is used by default 
+      !!
+      !! ** Method  :  use iom_put
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER ::   ji, jj, jk       ! dummy loop indices
+      INTEGER ::   ikbot            ! local integer
+      REAL(wp)::   zztmp , zztmpx   ! local scalar
+      REAL(wp)::   zztmp2, zztmpy   !   -      -
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
+      !!----------------------------------------------------------------------
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      ! 
+      ! Output the initial state and forcings
+      IF( ninist == 1 ) THEN                       
+         CALL dia_wri_state( 'output.init', kt )
+         ninist = 0
+      ENDIF
+
+      ! Output of initial vertical scale factor
+      CALL iom_put("e3t_0", e3t_0(:,:,:) )
+      CALL iom_put("e3u_0", e3t_0(:,:,:) )
+      CALL iom_put("e3v_0", e3t_0(:,:,:) )
+      !
+      CALL iom_put( "e3t" , e3t_n(:,:,:) )
+      CALL iom_put( "e3u" , e3u_n(:,:,:) )
+      CALL iom_put( "e3v" , e3v_n(:,:,:) )
+      CALL iom_put( "e3w" , e3w_n(:,:,:) )
+      IF( iom_use("e3tdef") )   &
+         CALL iom_put( "e3tdef"  , ( ( e3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
+
+      IF( ll_wd ) THEN
+         CALL iom_put( "ssh" , (sshn+ssh_ref)*tmask(:,:,1) )   ! sea surface height (brought back to the reference used for wetting and drying)
+      ELSE
+         CALL iom_put( "ssh" , sshn )              ! sea surface height
+      ENDIF
+
+      IF( iom_use("wetdep") )   &                  ! wet depth
+         CALL iom_put( "wetdep" , ht_0(:,:) + sshn(:,:) )
+      
+      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
+      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
+      IF ( iom_use("sbt") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_tem)
+            END DO
+         END DO
+         CALL iom_put( "sbt", z2d )                ! bottom temperature
+      ENDIF
+      
+      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
+      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
+      IF ( iom_use("sbs") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkt(ji,jj)
+               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_sal)
+            END DO
+         END DO
+         CALL iom_put( "sbs", z2d )                ! bottom salinity
+      ENDIF
+
+      IF ( iom_use("taubot") ) THEN                ! bottom stress
+         zztmp = rau0 * 0.25
+         z2d(:,:) = 0._wp
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp2 = (  ( rCdU_bot(ji+1,jj)+rCdU_bot(ji  ,jj) ) * un(ji  ,jj,mbku(ji  ,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji  ,jj)+rCdU_bot(ji-1,jj) ) * un(ji-1,jj,mbku(ji-1,jj))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj  ) ) * vn(ji,jj  ,mbkv(ji,jj  ))  )**2   &
+                  &   + (  ( rCdU_bot(ji,jj  )+rCdU_bot(ji,jj-1) ) * vn(ji,jj-1,mbkv(ji,jj-1))  )**2
+               z2d(ji,jj) = zztmp * SQRT( zztmp2 ) * tmask(ji,jj,1) 
+               !
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "taubot", z2d )           
+      ENDIF
+         
+      CALL iom_put( "uoce", un(:,:,:) )            ! 3D i-current
+      CALL iom_put(  "ssu", un(:,:,1) )            ! surface i-current
+      IF ( iom_use("sbu") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbku(ji,jj)
+               z2d(ji,jj) = un(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbu", z2d )                ! bottom i-current
+      ENDIF
+      
+      CALL iom_put( "voce", vn(:,:,:) )            ! 3D j-current
+      CALL iom_put(  "ssv", vn(:,:,1) )            ! surface j-current
+      IF ( iom_use("sbv") ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ikbot = mbkv(ji,jj)
+               z2d(ji,jj) = vn(ji,jj,ikbot)
+            END DO
+         END DO
+         CALL iom_put( "sbv", z2d )                ! bottom j-current
+      ENDIF
+
+      CALL iom_put( "woce", wn )                   ! vertical velocity
+      IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
+         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
+         z2d(:,:) = rau0 * e1e2t(:,:)
+         DO jk = 1, jpk
+            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
+         END DO
+         CALL iom_put( "w_masstr" , z3d )  
+         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
+      ENDIF
+
+      CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
+      CALL iom_put( "avs" , avs )                  ! S vert. eddy diff. coef.
+      CALL iom_put( "avm" , avm )                  ! T vert. eddy visc. coef.
+
+      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt(:,:,:) ) ) )
+      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
+
+      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
+         DO jj = 2, jpjm1                                    ! sst gradient
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zztmp  = tsn(ji,jj,1,jp_tem)
+               zztmpx = ( tsn(ji+1,jj,1,jp_tem) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) * r1_e1u(ji-1,jj)
+               zztmpy = ( tsn(ji,jj+1,1,jp_tem) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) * r1_e2v(ji,jj-1)
+               z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
+                  &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', 1. )
+         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
+         z2d(:,:) = SQRT( z2d(:,:) )
+         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
+      ENDIF
+         
+      ! heat and salt contents
+      IF( iom_use("heatc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "heatc", rau0_rcp * z2d )   ! vertically integrated heat content (J/m2)
+      ENDIF
+
+      IF( iom_use("saltc") ) THEN
+         z2d(:,:)  = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "saltc", rau0 * z2d )          ! vertically integrated salt content (PSU*kg/m2)
+      ENDIF
+      !
+      IF ( iom_use("eken") ) THEN
+         z3d(:,:,jpk) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zztmp  = 0.25_wp * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
+                  z3d(ji,jj,jk) = zztmp * (  un(ji-1,jj,jk)**2 * e2u(ji-1,jj) * e3u_n(ji-1,jj,jk)   &
+                     &                     + un(ji  ,jj,jk)**2 * e2u(ji  ,jj) * e3u_n(ji  ,jj,jk)   &
+                     &                     + vn(ji,jj-1,jk)**2 * e1v(ji,jj-1) * e3v_n(ji,jj-1,jk)   &
+                     &                     + vn(ji,jj  ,jk)**2 * e1v(ji,jj  ) * e3v_n(ji,jj  ,jk)   )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z3d, 'T', 1. )
+         CALL iom_put( "eken", z3d )                 ! kinetic energy
+      ENDIF
+      !
+      CALL iom_put( "hdiv", hdivn )                  ! Horizontal divergence
+      !
+      IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         z2d(:,:) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * un(:,:,jk) * e2u(:,:) * e3u_n(:,:,jk) * umask(:,:,jk)
+            z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
+         END DO
+         CALL iom_put( "u_masstr"     , z3d )         ! mass transport in i-direction
+         CALL iom_put( "u_masstr_vint", z2d )         ! mass transport in i-direction vertical sum
+      ENDIF
+      
+      IF( iom_use("u_heattr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
+      ENDIF
+
+      IF( iom_use("u_salttr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'U', -1. )
+         CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
+      ENDIF
+
+      
+      IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
+         z3d(:,:,jpk) = 0.e0
+         DO jk = 1, jpkm1
+            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e1v(:,:) * e3v_n(:,:,jk) * vmask(:,:,jk)
+         END DO
+         CALL iom_put( "v_masstr", z3d )              ! mass transport in j-direction
+      ENDIF
+      
+      IF( iom_use("v_heattr") ) THEN
+         z2d(:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("v_salttr") ) THEN
+         z2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'V', -1. )
+         CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
+      ENDIF
+
+      IF( iom_use("tosmint") ) THEN
+         z2d(:,:) = 0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) *  tsn(ji,jj,jk,jp_tem)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
+      ENDIF
+      IF( iom_use("somint") ) THEN
+         z2d(:,:)=0._wp
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( "diawri",z2d, 'T', -1. )
+         CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
+      ENDIF
+
+      CALL iom_put( "bn2", rn2 )                      ! Brunt-Vaisala buoyancy frequency (N^2)
+      !
+
+      IF (ln_diatmb)   CALL dia_tmb                   ! tmb values 
+          
+      IF (ln_dia25h)   CALL dia_25h( kt )             ! 25h averaging
+
+      IF( ln_timing )   CALL timing_stop('dia_wri')
+      !
+   END SUBROUTINE dia_wri
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                  use IOIPSL  library
+   !!----------------------------------------------------------------------
+
+   INTEGER FUNCTION dia_wri_alloc()
+      !
+      dia_wri_alloc = 0
+      !
+   END FUNCTION dia_wri_alloc
+
+   SUBROUTINE dia_wri( kt )
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+   END SUBROUTINE dia_wri
+
+#endif
+
+   SUBROUTINE dia_wri_state( cdfile_name, kt )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_wri_state  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!      the instantaneous ocean state and forcing fields.
+      !!        Used to find errors in the initial state or save the last
+      !!      ocean state in case of abnormal end of a simulation
+      !!
+      !! ** Method  :   NetCDF files using ioipsl
+      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
+      !!      File 'output.abort.nc' is created in case of abnormal job end
+      !!----------------------------------------------------------------------
+      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
+      INTEGER           , INTENT( in ) ::   kt               ! ocean time-step index
+      !! 
+      CHARACTER (len=32) :: clname
+      CHARACTER (len=40) :: clop
+      INTEGER  ::   id_i , nz_i, nh_i       
+      INTEGER, DIMENSION(1) ::   idex             ! local workspace
+      REAL(wp) ::   zsto, zout, zmax, zjulian
+      !!----------------------------------------------------------------------
+      ! 
+      ! 0. Initialisation
+      ! -----------------
+
+      ! Define name, frequency of output and means
+      clname = cdfile_name
+      IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      zsto = rdt
+      clop = "inst(x)"           ! no use of the mask value (require less cpu time)
+      zout = rdt
+      zmax = ( nitend - nit000 + 1 ) * rdt
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
+      IF(lwp) WRITE(numout,*) '                and named :', clname, '.nc'
+
+
+      ! 1. Define NETCDF files and fields at beginning of first time step
+      ! -----------------------------------------------------------------
+
+      ! Compute julian date from starting date of the run
+      CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )         ! time axis 
+      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
+      CALL histbeg( clname, jpi, glamt, jpj, gphit,   &
+          1, jpi, 1, jpj, nit000-1, zjulian, rdt, nh_i, id_i, domain_id=nidom, snc4chunks=snc4set ) ! Horizontal grid : glamt and gphit
+      CALL histvert( id_i, "deptht", "Vertical T levels",   &    ! Vertical grid : gdept
+          "m", jpk, gdept_1d, nz_i, "down")
+
+      ! Declare all the output fields as NetCDF variables
+
+      CALL histdef( id_i, "vosaline", "Salinity"              , "PSU"    ,   &   ! salinity
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
+         &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      CALL histdef( id_i, "vomecrty", "Meridional Current"    , "m/s"    ,   &   ! meridonal current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      CALL histdef( id_i, "vovecrtz", "Vertical Velocity"     , "m/s"    ,   &   ! vertical current
+         &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+         !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histdef( id_i, "ahtu"    , "u-eddy diffusivity"    , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahtv"    , "v-eddy diffusivity"    , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN 
+         CALL histdef( id_i, "ahmt"    , "t-eddy viscosity"      , "m2/s"    ,   &   ! zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "ahmf"    , "f-eddy viscosity"      , "m2/s"    ,   &   ! meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout ) 
+      ENDIF
+         !
+      CALL histdef( id_i, "sowaflup", "Net Upward Water Flux" , "Kg/m2/S",   &   ! net freshwater 
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sohefldo", "Net Downward Heat Flux", "W/m2"   ,   &   ! net heat flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soshfldo", "Shortwave Radiation"   , "W/m2"   ,   &   ! solar flux
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "soicecov", "Ice fraction"          , "[0,1]"  ,   &   ! fr_i
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sozotaux", "Zonal Wind Stress"     , "N/m2"   ,   &   ! i-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
+         &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      IF( .NOT.ln_linssh ) THEN
+         CALL histdef( id_i, "vovvldep", "T point depth"         , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "vovvle3t", "T point thickness"     , "m"      , &   ! t-point depth
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+      !
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histdef( id_i, "sdzocrtx", "Stokes Drift Zonal"    , "m/s"    , &   ! StokesDrift zonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdmecrty", "Stokes Drift Merid"    , "m/s"    , &   ! StokesDrift meridonal current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+         CALL histdef( id_i, "sdvecrtz", "Stokes Drift Vert"     , "m/s"    , &   ! StokesDrift vertical current
+            &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
+      ENDIF
+
+#if defined key_si3
+      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
+         CALL ice_wri_state( kt, id_i, nh_i )
+      ENDIF
+#else
+      CALL histend( id_i, snc4chunks=snc4set )
+#endif
+
+      ! 2. Start writing data
+      ! ---------------------
+      ! idex(1) est utilise ssi l'avant dernier argument est diffferent de 
+      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
+      ! donne le nombre d'elements, et idex la liste des indices a sortir
+      idex(1) = 1   ! init to avoid compil warning
+
+      ! Write all fields on T grid
+      CALL histwrite( id_i, "votemper", kt, tsn(:,:,:,jp_tem), jpi*jpj*jpk, idex )    ! now temperature
+      CALL histwrite( id_i, "vosaline", kt, tsn(:,:,:,jp_sal), jpi*jpj*jpk, idex )    ! now salinity
+      CALL histwrite( id_i, "sossheig", kt, sshn             , jpi*jpj    , idex )    ! sea surface height
+      CALL histwrite( id_i, "vozocrtx", kt, un               , jpi*jpj*jpk, idex )    ! now i-velocity
+      CALL histwrite( id_i, "vomecrty", kt, vn               , jpi*jpj*jpk, idex )    ! now j-velocity
+      CALL histwrite( id_i, "vovecrtz", kt, wn               , jpi*jpj*jpk, idex )    ! now k-velocity
+      !
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL histwrite( id_i, "ahtu"    , kt, ahtu             , jpi*jpj*jpk, idex )    ! aht at u-point
+         CALL histwrite( id_i, "ahtv"    , kt, ahtv             , jpi*jpj*jpk, idex )    !  -  at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL histwrite( id_i, "ahmt"    , kt, ahmt             , jpi*jpj*jpk, idex )    ! ahm at t-point
+         CALL histwrite( id_i, "ahmf"    , kt, ahmf             , jpi*jpj*jpk, idex )    !  -  at f-point
+      ENDIF
+      !
+      CALL histwrite( id_i, "sowaflup", kt, emp - rnf        , jpi*jpj    , idex )    ! freshwater budget
+      CALL histwrite( id_i, "sohefldo", kt, qsr + qns        , jpi*jpj    , idex )    ! total heat flux
+      CALL histwrite( id_i, "soshfldo", kt, qsr              , jpi*jpj    , idex )    ! solar heat flux
+      CALL histwrite( id_i, "soicecov", kt, fr_i             , jpi*jpj    , idex )    ! ice fraction
+      CALL histwrite( id_i, "sozotaux", kt, utau             , jpi*jpj    , idex )    ! i-wind stress
+      CALL histwrite( id_i, "sometauy", kt, vtau             , jpi*jpj    , idex )    ! j-wind stress
+
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL histwrite( id_i, "vovvldep", kt, gdept_n(:,:,:), jpi*jpj*jpk, idex )!  T-cell depth 
+         CALL histwrite( id_i, "vovvle3t", kt, e3t_n (:,:,:) , jpi*jpj*jpk, idex )!  T-cell thickness  
+      END IF 
+ 
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL histwrite( id_i, "sdzocrtx", kt, usd           , jpi*jpj*jpk, idex)     ! now StokesDrift i-velocity
+         CALL histwrite( id_i, "sdmecrty", kt, vsd           , jpi*jpj*jpk, idex)     ! now StokesDrift j-velocity
+         CALL histwrite( id_i, "sdvecrtz", kt, wsd           , jpi*jpj*jpk, idex)     ! now StokesDrift k-velocity
+      ENDIF
+
+      ! 3. Close the file
+      ! -----------------
+      CALL histclo( id_i )
+#if ! defined key_iomput
+      IF( ninist /= 1  ) THEN
+         CALL histclo( nid_T )
+         CALL histclo( nid_U )
+         CALL histclo( nid_V )
+         CALL histclo( nid_W )
+      ENDIF
+#endif
+      ! 
+   END SUBROUTINE dia_wri_state
+
+   !!======================================================================
+END MODULE diawri
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/restart.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/restart.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/restart.F90	(revision 10136)
@@ -0,0 +1,316 @@
+MODULE restart
+   !!======================================================================
+   !!                     ***  MODULE  restart  ***
+   !! Ocean restart :  write the ocean restart file
+   !!======================================================================
+   !! History :  OPA  !  1999-11  (M. Imbard)  Original code
+   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form
+   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart
+   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
+   !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
+   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   rst_opn    : open the ocean restart file
+   !!   rst_write  : write the ocean restart file
+   !!   rst_read   : read the ocean restart file
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_ice         ! only lk_si3 
+   USE phycst          ! physical constants
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
+   USE diurnal_bulk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   rst_opn         ! routine called by step module
+   PUBLIC   rst_write       ! routine called by step module
+   PUBLIC   rst_read        ! routine called by istate module
+   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: restart.F90 9654 2018-05-28 09:08:53Z clem $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE rst_opn( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rst_opn  ***
+      !!                     
+      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
+      !!              + open the restart when we are one time step before nitrst
+      !!                   - restart header is defined when kt = nitrst-1
+      !!                   - restart data  are written when kt = nitrst
+      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(lc)       ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
+      CHARACTER(LEN=256)  ::   clinfo    ! info character
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN   ! default definitions
+         lrst_oce = .FALSE.   
+         IF( ln_rst_list ) THEN
+            nrst_lst = 1
+            nitrst = nstocklist( nrst_lst )
+         ELSE
+            nitrst = nitend
+         ENDIF
+      ENDIF
+
+      ! frequency-based restart dumping (nn_stock)
+      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN   
+         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
+         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
+      ENDIF
+      ! to get better performances with NetCDF format:
+      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
+      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
+      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
+         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
+            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+            ENDIF
+            ! create the file
+            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
+            clpath = TRIM(cn_ocerst_outdir)
+            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+            IF(lwp) THEN
+               WRITE(numout,*)
+               IF(.NOT.lwxios) THEN
+                  SELECT CASE ( jprstlib )
+                  CASE DEFAULT         ;   WRITE(numout,*)                            &
+                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
+                  END SELECT
+                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
+                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
+                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
+                  ENDIF
+               ENDIF
+            ENDIF
+            !
+            IF(.NOT.lwxios) THEN
+               !EM no call to restart opening
+               !EM CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+            ELSE
+#if defined key_iomput
+               cwxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
+               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+                  clpname = clname
+               ELSE
+                  clpname = TRIM(Agrif_CFixed())//"_"//clname   
+               ENDIF
+               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname))
+               CALL xios_update_calendar(nitrst)
+               CALL iom_swap(      cxios_context          )
+#else
+               clinfo = 'Can not use XIOS in rst_opn'
+               CALL ctl_stop(TRIM(clinfo))
+#endif
+            ENDIF
+               !EM restart writing
+            !EM lrst_oce = .TRUE.
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_opn
+
+
+   SUBROUTINE rst_write( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rstwrite  ***
+      !!                     
+      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !!
+      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
+      !!              file, save fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step
+      !!----------------------------------------------------------------------
+                     IF(lwxios) CALL iom_swap(      cwxios_context          )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
+
+      IF ( .NOT. ln_diurnal_only ) THEN
+                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub, ldxios = lwxios        )     ! before fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb, ldxios = lwxios      )
+                     !
+                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un, ldxios = lwxios        )     ! now fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn, ldxios = lwxios        )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lwxios )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn, ldxios = lwxios      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop, ldxios = lwxios      )
+                  ! extra variable needed for the ice sheet coupling
+                  IF ( ln_iscpl ) THEN 
+                     CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask, ldxios = lwxios ) ! need to extrapolate T/S
+                     CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask, ldxios = lwxios ) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask, ldxios = lwxios) ! need to correct barotropic velocity
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:), ldxios = lwxios )   ! need to compute temperature correction
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:), ldxios = lwxios ) ! need to compute extrapolation if vvl
+                  END IF
+      ENDIF
+      
+      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )  
+      IF(lwxios) CALL iom_swap(      cxios_context          )
+      IF( kt == nitrst ) THEN
+         IF(.NOT.lwxios) THEN
+            CALL iom_close( numrow )     ! close the restart file (only at last time step)
+         ELSE
+            CALL iom_context_finalize(      cwxios_context          )
+         ENDIF
+!!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
+!!gm  not sure what to do here   ===>>>  ask to Sebastian
+         lrst_oce = .FALSE.
+            IF( ln_rst_list ) THEN
+               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1))
+               nitrst = nstocklist( nrst_lst )
+            ENDIF
+      ENDIF
+      !
+   END SUBROUTINE rst_write
+
+
+   SUBROUTINE rst_read_open
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read_open  ***
+      !! 
+      !! ** Purpose :   Open read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
+      !!                the file has already been opened
+      !!----------------------------------------------------------------------
+      INTEGER        ::   jlibalt = jprstlib
+      LOGICAL        ::   llok
+      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
+      !!----------------------------------------------------------------------
+      !
+      IF( numror <= 0 ) THEN
+         IF(lwp) THEN                                             ! Contol prints
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
+            END SELECT
+            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
+            WRITE(numout,*) '~~~~~~~~'
+         ENDIF
+         lxios_sini = .FALSE.
+         clpath = TRIM(cn_ocerst_indir)
+         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
+! are we using XIOS to read the data? Part above will have to modified once XIOS
+! can handle checking if variable is in the restart file (there will be no need to open
+! restart)
+         IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
+         IF( lrxios) THEN
+             crxios_context = 'nemo_rst'
+             IF( .NOT.lxios_set ) THEN
+                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
+                 CALL iom_init( crxios_context )
+                 lxios_set = .TRUE.
+             ENDIF
+         ENDIF
+         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
+             CALL iom_init( crxios_context )
+             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
+             lxios_set = .TRUE.
+         ENDIF 
+      ENDIF
+
+   END SUBROUTINE rst_read_open
+
+
+   SUBROUTINE rst_read
+      !!---------------------------------------------------------------------- 
+      !!                   ***  ROUTINE rst_read  ***
+      !! 
+      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! 
+      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   zrdt
+      INTEGER  ::   jk
+      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
+      !!----------------------------------------------------------------------
+
+      CALL rst_read_open           ! open restart for reading (if not already opened)
+
+      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
+      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
+         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
+         IF( zrdt /= rdt )   neuler = 0
+      ENDIF
+
+      ! Diurnal DSST 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
+      IF ( ln_diurnal_only ) THEN 
+         IF(lwp) WRITE( numout, * ) &
+         &   "rst_read:- ln_diurnal_only set, setting rhop=rau0" 
+         rhop = rau0
+         CALL iom_get( numror, jpdom_autoglo, 'tn'     , w3d, ldxios = lrxios ) 
+         tsn(:,:,1,jp_tem) = w3d(:,:,1)
+         RETURN 
+      ENDIF  
+      
+      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub, ldxios = lrxios                )   ! before fields
+         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb, ldxios = lrxios                )
+         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb, ldxios = lrxios              )
+      ELSE
+         neuler = 0
+      ENDIF
+      !
+      CALL iom_get( numror, jpdom_autoglo, 'un'     , un, ldxios = lrxios )   ! now    fields
+      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vn, ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, ldxios = lrxios )
+      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
+         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
+      ELSE
+         CALL eos( tsn, rhd, rhop, gdept_n(:,:,:) )   
+      ENDIF
+      !
+      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
+         tsb  (:,:,:,:) = tsn  (:,:,:,:)                             ! all before fields set to now values
+         ub   (:,:,:)   = un   (:,:,:)
+         vb   (:,:,:)   = vn   (:,:,:)
+         sshb (:,:)     = sshn (:,:)
+         !
+         IF( .NOT.ln_linssh ) THEN
+            DO jk = 1, jpk
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE rst_read
+
+   !!=====================================================================
+END MODULE restart
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_hgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_hgr.F90	(revision 10136)
@@ -0,0 +1,118 @@
+MODULE usrdef_hgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_hgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   mesh and Coriolis parameter of a user configuration
+   !!======================================================================
+   !! History :  NEMO  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_hgr    : initialize the horizontal mesh for BENCH configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE par_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_hgr   ! called by domhgr.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0, NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
+      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
+      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
+      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
+      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE usr_def_hgr  ***
+      !!
+      !! ** Purpose :   square box mesh mesh and Coriolis parameter
+      !!
+      !! ** Method  :   set all intent(out) argument to a proper value
+      !!                BENCH configuration : beta-plance with uniform grid spacing (zres)
+      !!
+      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in grid points) 
+      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
+      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
+      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
+      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
+      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise 
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      REAL(wp) ::   zres, zf0
+      REAL(wp) ::   zti, zui, ztj, zvj   ! local scalars
+      !!-------------------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_hgr : BENCH configuration bassin'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
+      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
+      !
+      !                          
+      ! Position coordinates (in grid points)
+      !                          ==========         
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            
+            zti = REAL( ji - 1 + nimpp - 1, wp )          ;  ztj = REAL( jj - 1 + njmpp - 1, wp )
+            zui = REAL( ji - 1 + nimpp - 1, wp ) + 0.5_wp ;  zvj = REAL( jj - 1 + njmpp - 1, wp ) + 0.5_wp
+
+            plamt(ji,jj) = zti
+            plamu(ji,jj) = zui
+            plamv(ji,jj) = zti
+            plamf(ji,jj) = zui
+   
+            pphit(ji,jj) = ztj
+            pphiv(ji,jj) = zvj
+            pphiu(ji,jj) = ztj
+            pphif(ji,jj) = zvj
+            
+         END DO
+      END DO
+      !     
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      zres = 1.e+5   !  100km
+      pe1t(:,:) = zres  ;   pe2t(:,:) = zres 
+      pe1u(:,:) = zres  ;   pe2u(:,:) = zres
+      pe1v(:,:) = zres  ;   pe2v(:,:) = zres
+      pe1f(:,:) = zres  ;   pe2f(:,:) = zres 
+
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
+      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
+      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
+      !
+      !
+      !                       !==  Coriolis parameter  ==!
+      kff = 1                       !  indicate not to compute Coriolis parameter afterward
+      !
+      zf0   = 2._wp * omega * SIN( rad * 45 )   ! constant coriolis factor corresponding to 45°N
+      pff_f(:,:) = zf0
+      pff_t(:,:) = zf0
+      !
+   END SUBROUTINE usr_def_hgr
+
+   !!======================================================================
+END MODULE usrdef_hgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_istate.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_istate.F90	(revision 10136)
@@ -0,0 +1,72 @@
+MODULE usrdef_istate
+   !!======================================================================
+   !!                     ***  MODULE usrdef_istate   ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the initial state of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  usr_def_istate : initial state in Temperature and salinity
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE dom_oce        
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   !   
+   USE usrdef_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_istate   ! called by istate.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+  
+   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers
+      !!                Here BENCH configuration 
+      !!
+      !! ** Method  :   Set a gaussian anomaly of pressure and associated
+      !!                geostrophic velocities
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pdept   ! depth of t-point               [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  ! t-point ocean mask             [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   pts     ! T & S fields      [Celsius ; g/kg]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pu      ! i-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pv      ! j-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : BENCH configuration, analytical definition of initial state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
+      !
+      ! sea level:
+      pssh(:,:) = 0.
+      ! temperature:
+      pts(:,:,:,jp_tem) = 10._wp
+      ! salinity:  
+      pts(:,:,:,jp_sal) = 35._wp
+      ! velocities:
+      pu(:,:,:) = 0.
+      pv(:,:,:) = 0.
+      !
+
+   END SUBROUTINE usr_def_istate
+
+   !!======================================================================
+END MODULE usrdef_istate
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_nam.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_nam.F90	(revision 10136)
@@ -0,0 +1,119 @@
+MODULE usrdef_nam
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_nam  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : set the domain characteristics of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_nam   : read user defined namelist and set global domain size
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! to get ctl_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_nam   ! called by nemogcm.F90
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read user defined namelist and define the domain size
+      !!
+      !! ** Method  :   read in namusr_def containing all the user specific namelist parameter
+      !!
+      !!                Here EW_CANAL configuration
+      !!
+      !! ** input   : - namusr_def namelist found in namelist_cfg
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
+      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
+      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
+      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
+      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      !
+      !
+      INTEGER ::   ios, ii      ! Local integer
+      !                              !!* namusr_def namelist *!!
+      INTEGER ::   nn_isize    ! number of point in i-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_jsize    ! number of point in j-direction of global(local) domain if >0 (<0)  
+      INTEGER ::   nn_ksize    ! total number of point in k-direction
+      INTEGER ::   nn_perio    ! periodicity
+      !                              !!* nammpp namelist *!!
+      CHARACTER(len=1) ::   cn_mpi_send
+      INTEGER          ::   nn_buffer, jpni, jpnj, jpnij
+      LOGICAL          ::   ln_nnogather
+      !!
+      NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, nn_perio
+      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, jpnij, ln_nnogather
+      !!----------------------------------------------------------------------     
+      !
+      REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
+      READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+      WRITE( ldnam(:), namusr_def )      
+      !
+      cd_cfg = 'BENCH'             ! name & resolution (not used)
+      kk_cfg = 0
+
+      IF( nn_isize < 0 .AND. nn_jsize < 0 ) THEN
+      !
+         REWIND( numnam_ref )              ! Namelist nammpp in reference namelist: mpi variables
+         READ  ( numnam_ref, nammpp, IOSTAT = ios, ERR = 901)
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist', lwp )
+         !
+         REWIND( numnam_cfg )              ! Namelist nammpp in configuration namelist: mpi variables
+         READ  ( numnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist', lwp )
+
+         kpi = ( -nn_isize - 2*nn_hls ) * jpni + 2*nn_hls
+         kpj = ( -nn_jsize - 2*nn_hls ) * jpnj + 2*nn_hls
+      ELSE
+         kpi = nn_isize
+         kpj = nn_jsize
+      ENDIF
+ 
+      kpk = nn_ksize
+      kperio = nn_perio
+
+      !                             ! control print
+      ii = 1
+      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '   Namelist namusr_def : BENCH test case'                                     ;   ii = ii + 1
+      IF( nn_isize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-x            nn_isize = ',  nn_isize              ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpni = ', jpni                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-x           -nn_isize = ', -nn_isize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-x                 kpi = ', kpi                    ;   ii = ii + 1
+      ENDIF
+      IF( nn_jsize > 0 ) THEN
+         WRITE(ldtxt(ii),*) '      global domain size-y            nn_jsize = ', nn_jsize               ;   ii = ii + 1
+      ELSE
+         WRITE(ldtxt(ii),*) '                                          jpnj = ', jpnj                   ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '       local domain size-y           -nn_jsize = ', -nn_jsize              ;   ii = ii + 1
+         WRITE(ldtxt(ii),*) '      global domain size-y                 kpj = ', kpj                    ;   ii = ii + 1
+      ENDIF
+      WRITE(ldtxt(ii),*) '      global domain size-z            nn_ksize = ', nn_ksize                  ;   ii = ii + 1
+      WRITE(ldtxt(ii),*) '      LBC of the global domain          kperio = ', kperio                    ;   ii = ii + 1
+      !
+   END SUBROUTINE usr_def_nam
+
+   !!======================================================================
+END MODULE usrdef_nam
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_sbc.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_sbc.F90	(revision 10136)
@@ -0,0 +1,78 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_sbc  ***
+   !! 
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_sbc    : user defined surface bounday conditions in BENCH case
+   !!----------------------------------------------------------------------
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usrdef_sbc_oce      ! routine called in sbcmod module
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by sbcice_lim.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by sbcice_lim.F90 for ice thermo
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE usr_def_sbc  ***
+      !!              
+      !! ** Purpose :   provide at each time-step the surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   all 0 fields, for BENCH case
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set to ZERO all the ocean surface boundary condition, i.e.   
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !     
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) WRITE(numout,*)' usr_sbc : BENCH case: surface forcing'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~~~~~   vtau = taum = wndm = qns = qsr = emp = sfx = 0'
+         !
+         utau(:,:) = 0._wp
+         vtau(:,:) = 0._wp
+         taum(:,:) = 0._wp
+         wndm(:,:) = 0._wp
+         !
+         emp (:,:) = 0._wp
+         sfx (:,:) = 0._wp
+         qns (:,:) = 0._wp
+         qsr (:,:) = 0._wp
+         !         
+      ENDIF
+      
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+   SUBROUTINE usrdef_sbc_ice_flx( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_zgr.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/usrdef_zgr.F90	(revision 10136)
@@ -0,0 +1,240 @@
+MODULE usrdef_zgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_zgr  ***
+   !!
+   !!                      ===  BENCH configuration  ===
+   !!
+   !! User defined : vertical coordinate system of a user configuration
+   !!======================================================================
+   !! History :  4.0  ! 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_zgr   : user defined vertical coordinate system
+   !!      zgr_z      : reference 1D z-coordinate 
+   !!      zgr_top_bot: ocean top and bottom level indices
+   !!      zgr_zco    : 3D verticl coordinate in pure z-coordinate case
+   !!---------------------------------------------------------------------
+   USE oce            ! ocean variables
+   USE dom_oce        ! ocean domain
+   USE phycst         ! physical constants
+   USE depth_e3       ! depth <=> e3
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_zgr        ! called by domzgr.F90
+
+  !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS             
+
+   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
+      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
+      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
+      &                    pe3t  , pe3u  , pe3v   , pe3f ,             &   ! vertical scale factors
+      &                    pe3w  , pe3uw , pe3vw         ,             &   !     -      -      -
+      &                    k_top  , k_bot    )                             ! top & bottom ocean level
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE usr_def_zgr  ***
+      !!
+      !! ** Purpose :   User defined the vertical coordinates
+      !!
+      !!----------------------------------------------------------------------
+      LOGICAL                   , INTENT(out) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags
+      LOGICAL                   , INTENT(out) ::   ld_isfcav                   ! under iceshelf cavity flag
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pdept, pdepw                ! grid-point depth        [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors 
+      INTEGER , DIMENSION(:,:)  , INTENT(out) ::   k_top, k_bot                ! first & last ocean level
+      !
+      INTEGER  ::   inum   ! local logical unit
+      REAL(WP) ::   z_zco, z_zps, z_sco, z_cav
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_zgr : BENCH configuration (z-coordinate closed flat box ocean)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      !
+      !
+      ! type of vertical coordinate
+      ! ---------------------------
+      ld_zco    = .TRUE.         ! BENCH case:  z-coordinate without ocean cavities
+      ld_zps    = .FALSE.
+      ld_sco    = .FALSE.
+      ld_isfcav = .FALSE.
+      !
+      !
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+      CALL zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
+      !
+      CALL zgr_msk_top_bot( k_top , k_bot )                 ! masked top and bottom ocean t-level indices
+      !
+      !                                                     ! z-coordinate (3D arrays) from the 1D z-coord.
+      CALL zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in  : 1D reference vertical coordinate
+         &          pdept   , pdepw   ,                     &   ! out : 3D t & w-points depth
+         &          pe3t    , pe3u    , pe3v   , pe3f   ,   &   !       vertical scale factors
+         &          pe3w    , pe3uw   , pe3vw             )     !           -      -      -
+      !
+   END SUBROUTINE usr_def_zgr
+
+
+   SUBROUTINE zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z  ***
+      !!
+      !! ** Purpose :   set the 1D depth of model levels and the resulting 
+      !!              vertical scale factors.
+      !!
+      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
+      !!       The depth of model levels is set from dep(k), an analytical function:
+      !!                   w-level: depw_1d  = dep(k)
+      !!                   t-level: dept_1d  = dep(k+0.5)
+      !!       The scale factors are the discrete derivative of the depth:
+      !!                   e3w_1d(jk) = dk[ dept_1d ] 
+      !!                   e3t_1d(jk) = dk[ depw_1d ]
+      !!           with at top and bottom :
+      !!                   e3w_1d( 1 ) = 2 * ( dept_1d( 1 ) - depw_1d( 1 ) )
+      !!                   e3t_1d(jpk) = 2 * ( dept_1d(jpk) - depw_1d(jpk) )
+      !!       The depth are then re-computed from the sum of e3. This ensures 
+      !!    that depths are identical when reading domain configuration file. 
+      !!    Indeed, only e3. are saved in this file, depth are compute by a call
+      !!    to the e3_to_depth subroutine.
+      !!
+      !!       Here the Madec & Imbard (1996) function is used.
+      !!
+      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
+      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!
+      !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+      !!             Madec and Imbard, 1996, Clim. Dyn.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
+      !
+      INTEGER  ::   jk       ! dummy loop indices
+      REAL(wp) ::   zd       ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      zd = 5000./FLOAT(jpkm1)
+      !
+      IF(lwp) THEN            ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z   : Reference vertical z-coordinates '
+         WRITE(numout,*) '    ~~~~~~~'
+         WRITE(numout,*) '       BENCH case : uniform vertical grid :'
+         WRITE(numout,*) '                     with thickness = ', zd
+      ENDIF
+
+      !
+      ! 1D Reference z-coordinate    (using Madec & Imbard 1996 function)
+      ! -------------------------
+      !
+      pdepw_1d(1) = 0._wp
+      pdept_1d(1) = 0.5_wp * zd
+      ! 
+      DO jk = 2, jpk          ! depth at T and W-points
+         pdepw_1d(jk) = pdepw_1d(jk-1) + zd 
+         pdept_1d(jk) = pdept_1d(jk-1) + zd 
+      END DO
+      !
+      !                       ! e3t and e3w from depth
+      CALL depth_to_e3( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d ) 
+      !
+      !                       ! recompute depths from SUM(e3)  <== needed
+      CALL e3_to_depth( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d ) 
+      !
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
+      ENDIF
+      !
+   END SUBROUTINE zgr_z
+
+
+   SUBROUTINE zgr_msk_top_bot( k_top , k_bot )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_msk_top_bot  ***
+      !!
+      !! ** Purpose :   set the masked top and bottom ocean t-levels
+      !!
+      !! ** Method  :   BENCH case = closed flat box ocean without ocean cavities
+      !!                   k_top = 1     except along north, south, east and west boundaries
+      !!                   k_bot = jpk-1 except along north, south, east and west boundaries
+      !!
+      !! ** Action  : - k_top : first wet ocean level index
+      !!              - k_bot : last  wet ocean level index
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(:,:), INTENT(out) ::   k_top , k_bot   ! first & last wet ocean level
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D local workspace
+      REAL(wp)                     ::   zmaxlam, zscl
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_top_bot : defines the top and bottom wet ocean levels.'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '       BENCH case : closed flat box ocean without ocean cavities'
+      !
+      z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
+      !
+      CALL lbc_lnk( "usrdef_zgr", z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      !
+      k_bot(:,:) = INT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
+      !
+      k_top(:,:) = MIN( 1 , k_bot(:,:) )     ! = 1    over the ocean point, =0 elsewhere
+      !
+   END SUBROUTINE zgr_msk_top_bot
+   
+
+   SUBROUTINE zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in : 1D reference vertical coordinate
+      &                pdept   , pdepw   ,                     &   ! out: 3D t & w-points depth
+      &                pe3t    , pe3u    , pe3v   , pe3f   ,   &   !      vertical scale factors
+      &                pe3w    , pe3uw   , pe3vw             )     !          -      -      -
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zco  ***
+      !!
+      !! ** Purpose :   define the reference z-coordinate system
+      !!
+      !! ** Method  :   set 3D coord. arrays to reference 1D array 
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth       [m]
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pe3t_1d , pe3w_1d           ! 1D vertical scale factors [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept, pdepw                ! grid-point depth          [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors    [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3w , pe3uw, pe3vw         !    -       -      -
+      !
+      INTEGER  ::   jk
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         pdept(:,:,jk) = pdept_1d(jk)
+         pdepw(:,:,jk) = pdepw_1d(jk)
+         pe3t (:,:,jk) = pe3t_1d (jk)
+         pe3u (:,:,jk) = pe3t_1d (jk)
+         pe3v (:,:,jk) = pe3t_1d (jk)
+         pe3f (:,:,jk) = pe3t_1d (jk)
+         pe3w (:,:,jk) = pe3w_1d (jk)
+         pe3uw(:,:,jk) = pe3w_1d (jk)
+         pe3vw(:,:,jk) = pe3w_1d (jk)
+      END DO
+      !
+   END SUBROUTINE zgr_zco
+
+   !!======================================================================
+END MODULE usrdef_zgr
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/zdfiwm.F90
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/zdfiwm.F90	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/MY_SRC/zdfiwm.F90	(revision 10136)
@@ -0,0 +1,482 @@
+MODULE zdfiwm
+   !!========================================================================
+   !!                       ***  MODULE  zdfiwm  ***
+   !! Ocean physics: Internal gravity wave-driven vertical mixing
+   !!========================================================================
+   !! History :  1.0  !  2004-04  (L. Bessieres, G. Madec)  Original code
+   !!             -   !  2006-08  (A. Koch-Larrouy)  Indonesian strait
+   !!            3.3  !  2010-10  (C. Ethe, G. Madec)  reorganisation of initialisation phase
+   !!            3.6  !  2016-03  (C. de Lavergne)  New param: internal wave-driven mixing 
+   !!            4.0  !  2017-04  (G. Madec)  renamed module, remove the old param. and the CPP keys
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   zdf_iwm       : global     momentum & tracer Kz with wave induced Kz
+   !!   zdf_iwm_init  : global     momentum & tracer Kz with wave induced Kz
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE zdf_oce        ! ocean vertical physics variables
+   USE zdfddm         ! ocean vertical physics: double diffusive mixing
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE eosbn2         ! ocean equation of state
+   USE phycst         ! physical constants
+   !
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O Manager
+   USE lib_mpp        ! MPP library
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   zdf_iwm        ! called in step module 
+   PUBLIC   zdf_iwm_init   ! called in nemogcm module 
+
+   !                      !!* Namelist  namzdf_iwm : internal wave-driven mixing *
+   INTEGER ::  nn_zpyc     ! pycnocline-intensified mixing energy proportional to N (=1) or N^2 (=2)
+   LOGICAL ::  ln_mevar    ! variable (=T) or constant (=F) mixing efficiency
+   LOGICAL ::  ln_tsdiff   ! account for differential T/S wave-driven mixing (=T) or not (=F)
+
+   REAL(wp)::  r1_6 = 1._wp / 6._wp
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ebot_iwm   ! power available from high-mode wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   epyc_iwm   ! power available from low-mode, pycnocline-intensified wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ecri_iwm   ! power available from low-mode, critical slope wave breaking (W/m2)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hbot_iwm   ! WKB decay scale for high-mode energy dissipation (m)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hcri_iwm   ! decay scale for low-mode critical slope dissipation (m)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: zdfiwm.F90 8093 2017-05-30 08:13:14Z gm $
+   !! Software governed by the CeCILL licence     (./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   INTEGER FUNCTION zdf_iwm_alloc()
+      !!----------------------------------------------------------------------
+      !!                ***  FUNCTION zdf_iwm_alloc  ***
+      !!----------------------------------------------------------------------
+      ALLOCATE( ebot_iwm(jpi,jpj),  epyc_iwm(jpi,jpj),  ecri_iwm(jpi,jpj) ,     &
+      &         hbot_iwm(jpi,jpj),  hcri_iwm(jpi,jpj)                     , STAT=zdf_iwm_alloc )
+      !
+      IF( lk_mpp             )   CALL mpp_sum ( zdf_iwm_alloc )
+      IF( zdf_iwm_alloc /= 0 )   CALL ctl_warn('zdf_iwm_alloc: failed to allocate arrays')
+   END FUNCTION zdf_iwm_alloc
+
+
+   SUBROUTINE zdf_iwm( kt, p_avm, p_avt, p_avs )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm  ***
+      !!                   
+      !! ** Purpose :   add to the vertical mixing coefficients the effect of
+      !!              breaking internal waves.
+      !!
+      !! ** Method  : - internal wave-driven vertical mixing is given by:
+      !!                  Kz_wave = min(  100 cm2/s, f(  Reb = zemx_iwm /( Nu * N^2 )  )
+      !!              where zemx_iwm is the 3D space distribution of the wave-breaking 
+      !!              energy and Nu the molecular kinematic viscosity.
+      !!              The function f(Reb) is linear (constant mixing efficiency)
+      !!              if the namelist parameter ln_mevar = F and nonlinear if ln_mevar = T.
+      !!
+      !!              - Compute zemx_iwm, the 3D power density that allows to compute
+      !!              Reb and therefrom the wave-induced vertical diffusivity.
+      !!              This is divided into three components:
+      !!                 1. Bottom-intensified low-mode dissipation at critical slopes
+      !!                     zemx_iwm(z) = ( ecri_iwm / rau0 ) * EXP( -(H-z)/hcri_iwm )
+      !!                                   / ( 1. - EXP( - H/hcri_iwm ) ) * hcri_iwm
+      !!              where hcri_iwm is the characteristic length scale of the bottom 
+      !!              intensification, ecri_iwm a map of available power, and H the ocean depth.
+      !!                 2. Pycnocline-intensified low-mode dissipation
+      !!                     zemx_iwm(z) = ( epyc_iwm / rau0 ) * ( sqrt(rn2(z))^nn_zpyc )
+      !!                                   / SUM( sqrt(rn2(z))^nn_zpyc * e3w(z) )
+      !!              where epyc_iwm is a map of available power, and nn_zpyc
+      !!              is the chosen stratification-dependence of the internal wave
+      !!              energy dissipation.
+      !!                 3. WKB-height dependent high mode dissipation
+      !!                     zemx_iwm(z) = ( ebot_iwm / rau0 ) * rn2(z) * EXP(-z_wkb(z)/hbot_iwm)
+      !!                                   / SUM( rn2(z) * EXP(-z_wkb(z)/hbot_iwm) * e3w(z) )
+      !!              where hbot_iwm is the characteristic length scale of the WKB bottom 
+      !!              intensification, ebot_iwm is a map of available power, and z_wkb is the
+      !!              WKB-stretched height above bottom defined as
+      !!                    z_wkb(z) = H * SUM( sqrt(rn2(z'>=z)) * e3w(z'>=z) )
+      !!                                 / SUM( sqrt(rn2(z'))    * e3w(z')    )
+      !!
+      !!              - update the model vertical eddy viscosity and diffusivity: 
+      !!                     avt  = avt  +    av_wave
+      !!                     avm  = avm  +    av_wave
+      !!
+      !!              - if namelist parameter ln_tsdiff = T, account for differential mixing:
+      !!                     avs  = avt  +    av_wave * diffusivity_ratio(Reb)
+      !!
+      !! ** Action  : - avt, avs, avm, increased by tide internal wave-driven mixing    
+      !!
+      !! References :  de Lavergne et al. 2015, JPO; 2016, in prep.
+      !!----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kt             ! ocean time step
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avm          ! momentum Kz (w-points)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(inout) ::   p_avt, p_avs   ! tracer   Kz (w-points)
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zztmp        ! scalar workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zfact       ! Used for vertical structure
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhdep       ! Ocean depth
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwkb        ! WKB-stretched height above bottom
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zweight     ! Weight for high mode vertical distribution
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_t       ! Molecular kinematic viscosity (T grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   znu_w       ! Molecular kinematic viscosity (W grid)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zReb        ! Turbulence intensity parameter
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zemx_iwm    ! local energy density available for mixing (W/kg)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_ratio   ! S/T diffusivity ratio (only for ln_tsdiff=T)
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zav_wave    ! Internal wave-induced diffusivity
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   z3d  ! 3D workspace used for iom_put 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   z2d  ! 2D     -      -    -     -
+      !!----------------------------------------------------------------------
+      !
+      !                       !* Set to zero the 1st and last vertical levels of appropriate variables
+      zemx_iwm (:,:,1) = 0._wp   ;   zemx_iwm (:,:,jpk) = 0._wp
+      zav_ratio(:,:,1) = 0._wp   ;   zav_ratio(:,:,jpk) = 0._wp
+      zav_wave (:,:,1) = 0._wp   ;   zav_wave (:,:,jpk) = 0._wp
+      !
+      !                       ! ----------------------------- !
+      !                       !  Internal wave-driven mixing  !  (compute zav_wave)
+      !                       ! ----------------------------- !
+      !                             
+      !                       !* Critical slope mixing: distribute energy over the time-varying ocean depth,
+      !                                                 using an exponential decay from the seafloor.
+      DO jj = 1, jpj                ! part independent of the level
+         DO ji = 1, jpi
+            zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
+            zfact(ji,jj) = rau0 * (  1._wp - EXP( -zhdep(ji,jj) / hcri_iwm(ji,jj) )  )
+            IF( zfact(ji,jj) /= 0._wp )   zfact(ji,jj) = ecri_iwm(ji,jj) / zfact(ji,jj)
+         END DO
+      END DO
+!!gm gde3w ==>>>  check for ssh taken into account.... seem OK gde3w_n=gdept_n - sshn
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zfact(:,:) * (  EXP( ( gde3w_n(:,:,jk  ) - zhdep(:,:) ) / hcri_iwm(:,:) )                      &
+            &                             - EXP( ( gde3w_n(:,:,jk-1) - zhdep(:,:) ) / hcri_iwm(:,:) )  ) * wmask(:,:,jk)   &
+            &                          / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+
+!!gm delta(gde3w_n) = e3t_n  !!  Please verify the grid-point position w versus t-point
+!!gm it seems to me that only 1/hcri_iwm  is used ==>  compute it one for all
+
+      END DO
+
+      !                        !* Pycnocline-intensified mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to sqrt(rn2)^nn_zpyc
+      !                                          ! (NB: N2 is masked, so no use of wmask here)
+      SELECT CASE ( nn_zpyc )
+      !
+      CASE ( 1 )               ! Dissipation scales as N (recommended)
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         END DO
+         !
+      CASE ( 2 )               ! Dissipation scales as N^2
+         !
+         zfact(:,:) = 0._wp
+         DO jk = 2, jpkm1              ! part independent of the level
+            zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+         DO jj= 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = epyc_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+            END DO
+         END DO
+         !
+         DO jk = 2, jpkm1              ! complete with the level-dependent part
+            zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zfact(:,:) * MAX( 0._wp, rn2(:,:,jk) ) * wmask(:,:,jk)
+         END DO
+         !
+      END SELECT
+
+      !                        !* WKB-height dependent mixing: distribute energy over the time-varying 
+      !                        !* ocean depth as proportional to rn2 * exp(-z_wkb/rn_hbot)
+      !
+      zwkb (:,:,:) = 0._wp
+      zfact(:,:)   = 0._wp
+      DO jk = 2, jpkm1
+         zfact(:,:) = zfact(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  ) * wmask(:,:,jk)
+         zwkb(:,:,jk) = zfact(:,:)
+      END DO
+!!gm even better:
+!      DO jk = 2, jpkm1
+!         zwkb(:,:) = zwkb(:,:) + e3w_n(:,:,jk) * SQRT(  MAX( 0._wp, rn2(:,:,jk) )  )
+!      END DO
+!      zfact(:,:) = zwkb(:,:,jpkm1)
+!!gm or just use zwkb(k=jpk-1) instead of zfact...
+!!gm
+      !
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zfact(ji,jj) /= 0 )   zwkb(ji,jj,jk) = zhdep(ji,jj) * ( zfact(ji,jj) - zwkb(ji,jj,jk) )   &
+                  &                                     * wmask(ji,jj,jk) / zfact(ji,jj)
+            END DO
+         END DO
+      END DO
+      zwkb(:,:,1) = zhdep(:,:) * wmask(:,:,1)
+      !
+      zweight(:,:,:) = 0._wp
+      DO jk = 2, jpkm1
+         zweight(:,:,jk) = MAX( 0._wp, rn2(:,:,jk) ) * hbot_iwm(:,:) * wmask(:,:,jk)                    &
+            &   * (  EXP( -zwkb(:,:,jk) / hbot_iwm(:,:) ) - EXP( -zwkb(:,:,jk-1) / hbot_iwm(:,:) )  )
+      END DO
+      !
+      zfact(:,:) = 0._wp
+      DO jk = 2, jpkm1              ! part independent of the level
+         zfact(:,:) = zfact(:,:) + zweight(:,:,jk)
+      END DO
+      !
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = ebot_iwm(ji,jj) / ( rau0 * zfact(ji,jj) )
+         END DO
+      END DO
+      !
+      DO jk = 2, jpkm1              ! complete with the level-dependent part
+         zemx_iwm(:,:,jk) = zemx_iwm(:,:,jk) + zweight(:,:,jk) * zfact(:,:) * wmask(:,:,jk)   &
+            &                                / ( gde3w_n(:,:,jk) - gde3w_n(:,:,jk-1) )
+!!gm  use of e3t_n just above?
+      END DO
+      !
+!!gm  this is to be replaced by just a constant value znu=1.e-6 m2/s
+      ! Calculate molecular kinematic viscosity
+      znu_t(:,:,:) = 1.e-4_wp * (  17.91_wp - 0.53810_wp * tsn(:,:,:,jp_tem) + 0.00694_wp * tsn(:,:,:,jp_tem) * tsn(:,:,:,jp_tem)  &
+         &                                  + 0.02305_wp * tsn(:,:,:,jp_sal)  ) * tmask(:,:,:) * r1_rau0
+      DO jk = 2, jpkm1
+         znu_w(:,:,jk) = 0.5_wp * ( znu_t(:,:,jk-1) + znu_t(:,:,jk) ) * wmask(:,:,jk)
+      END DO
+!!gm end
+      !
+      ! Calculate turbulence intensity parameter Reb
+      DO jk = 2, jpkm1
+         zReb(:,:,jk) = zemx_iwm(:,:,jk) / MAX( 1.e-20_wp, znu_w(:,:,jk) * rn2(:,:,jk) )
+      END DO
+      !
+      ! Define internal wave-induced diffusivity
+      DO jk = 2, jpkm1
+         zav_wave(:,:,jk) = znu_w(:,:,jk) * zReb(:,:,jk) * r1_6   ! This corresponds to a constant mixing efficiency of 1/6
+      END DO
+      !
+      IF( ln_mevar ) THEN              ! Variable mixing efficiency case : modify zav_wave in the
+         DO jk = 2, jpkm1              ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF( zReb(ji,jj,jk) > 480.00_wp ) THEN
+                     zav_wave(ji,jj,jk) = 3.6515_wp * znu_w(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ELSEIF( zReb(ji,jj,jk) < 10.224_wp ) THEN
+                     zav_wave(ji,jj,jk) = 0.052125_wp * znu_w(ji,jj,jk) * zReb(ji,jj,jk) * SQRT( zReb(ji,jj,jk) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+      !
+      DO jk = 2, jpkm1                 ! Bound diffusivity by molecular value and 100 cm2/s
+         zav_wave(:,:,jk) = MIN(  MAX( 1.4e-7_wp, zav_wave(:,:,jk) ), 1.e-2_wp  ) * wmask(:,:,jk)
+      END DO
+      !
+      IF( kt == nit000 ) THEN        !* Control print at first time-step: diagnose the energy consumed by zav_wave
+         zztmp = 0._wp
+!!gm used of glosum 3D....
+         DO jk = 2, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zztmp = zztmp + e3w_n(ji,jj,jk) * e1e2t(ji,jj)   &
+                     &          * MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
+               END DO
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( zztmp )
+         zztmp = rau0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'zdf_iwm : Internal wave-driven mixing (iwm)'
+            WRITE(numout,*) '~~~~~~~ '
+            WRITE(numout,*)
+            WRITE(numout,*) '      Total power consumption by av_wave =  ', zztmp * 1.e-12_wp, 'TW'
+         ENDIF
+      ENDIF
+
+      !                          ! ----------------------- !
+      !                          !   Update  mixing coefs  !                          
+      !                          ! ----------------------- !
+      !      
+      IF( ln_tsdiff ) THEN          !* Option for differential mixing of salinity and temperature
+         DO jk = 2, jpkm1              ! Calculate S/T diffusivity ratio as a function of Reb
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zav_ratio(ji,jj,jk) = ( 0.505_wp + 0.495_wp *                                                                  &
+                      &   TANH(    0.92_wp * (   LOG10(  MAX( 1.e-20_wp, zReb(ji,jj,jk) * 5._wp * r1_6 )  ) - 0.60_wp   )    )   &
+                      &                 ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "av_ratio", zav_ratio )
+         DO jk = 2, jpkm1           !* update momentum & tracer diffusivity with wave-driven mixing
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk) * zav_ratio(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+         !
+      ELSE                          !* update momentum & tracer diffusivity with wave-driven mixing
+         DO jk = 2, jpkm1
+            p_avs(:,:,jk) = p_avs(:,:,jk) + zav_wave(:,:,jk)
+            p_avt(:,:,jk) = p_avt(:,:,jk) + zav_wave(:,:,jk)
+            p_avm(:,:,jk) = p_avm(:,:,jk) + zav_wave(:,:,jk)
+         END DO
+      ENDIF
+
+      !                             !* output internal wave-driven mixing coefficient
+      CALL iom_put( "av_wave", zav_wave )
+                                    !* output useful diagnostics: Kz*N^2 , 
+!!gm Kz*N2 should take into account the ratio avs/avt if it is used.... (see diaar5)
+                                    !  vertical integral of rau0 * Kz * N^2 , energy density (zemx_iwm)
+      IF( iom_use("bflx_iwm") .OR. iom_use("pcmap_iwm") ) THEN
+         ALLOCATE( z2d(jpi,jpj) , z3d(jpi,jpj,jpk) )
+         z3d(:,:,:) = MAX( 0._wp, rn2(:,:,:) ) * zav_wave(:,:,:)
+         z2d(:,:) = 0._wp
+         DO jk = 2, jpkm1
+            z2d(:,:) = z2d(:,:) + e3w_n(:,:,jk) * z3d(:,:,jk) * wmask(:,:,jk)
+         END DO
+         z2d(:,:) = rau0 * z2d(:,:)
+         CALL iom_put( "bflx_iwm", z3d )
+         CALL iom_put( "pcmap_iwm", z2d )
+         DEALLOCATE( z2d , z3d )
+      ENDIF
+      CALL iom_put( "emix_iwm", zemx_iwm )
+      
+      IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_wave , clinfo1=' iwm - av_wave: ', tab3d_2=avt, clinfo2=' avt: ', kdim=jpk)
+      !
+   END SUBROUTINE zdf_iwm
+
+
+   SUBROUTINE zdf_iwm_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_iwm_init  ***
+      !!                     
+      !! ** Purpose :   Initialization of the wave-driven vertical mixing, reading
+      !!              of input power maps and decay length scales in netcdf files.
+      !!
+      !! ** Method  : - Read the namzdf_iwm namelist and check the parameters
+      !!
+      !!              - Read the input data in NetCDF files :
+      !!              power available from high-mode wave breaking (mixing_power_bot.nc)
+      !!              power available from pycnocline-intensified wave-breaking (mixing_power_pyc.nc)
+      !!              power available from critical slope wave-breaking (mixing_power_cri.nc)
+      !!              WKB decay scale for high-mode wave-breaking (decay_scale_bot.nc)
+      !!              decay scale for critical slope wave-breaking (decay_scale_cri.nc)
+      !!
+      !! ** input   : - Namlist namzdf_iwm
+      !!              - NetCDF files : mixing_power_bot.nc, mixing_power_pyc.nc, mixing_power_cri.nc,
+      !!              decay_scale_bot.nc decay_scale_cri.nc
+      !!
+      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
+      !!              - Define ebot_iwm, epyc_iwm, ecri_iwm, hbot_iwm, hcri_iwm
+      !!
+      !! References : de Lavergne et al. JPO, 2015 ; de Lavergne PhD 2016
+      !!              de Lavergne et al. in prep., 2017
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   inum         ! local integer
+      INTEGER  ::   ios
+      REAL(wp) ::   zbot, zpyc, zcri   ! local scalars
+      !!
+      NAMELIST/namzdf_iwm/ nn_zpyc, ln_mevar, ln_tsdiff
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist namzdf_iwm in reference namelist : Wave-driven mixing
+      READ  ( numnam_ref, namzdf_iwm, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namzdf_iwm in configuration namelist : Wave-driven mixing
+      READ  ( numnam_cfg, namzdf_iwm, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namzdf_iwm )
+      !
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'zdf_iwm_init : internal wave-driven mixing'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namzdf_iwm : set wave-driven mixing parameters'
+         WRITE(numout,*) '      Pycnocline-intensified diss. scales as N (=1) or N^2 (=2) = ', nn_zpyc
+         WRITE(numout,*) '      Variable (T) or constant (F) mixing efficiency            = ', ln_mevar
+         WRITE(numout,*) '      Differential internal wave-driven mixing (T) or not (F)   = ', ln_tsdiff
+      ENDIF
+      
+      ! The new wave-driven mixing parameterization elevates avt and avm in the interior, and
+      ! ensures that avt remains larger than its molecular value (=1.4e-7). Therefore, avtb should 
+      ! be set here to a very small value, and avmb to its (uniform) molecular value (=1.4e-6).
+      avmb(:) = 1.4e-6_wp        ! viscous molecular value
+      avtb(:) = 1.e-10_wp        ! very small diffusive minimum (background avt is specified in zdf_iwm)    
+      avtb_2d(:,:) = 1.e0_wp     ! uniform 
+      IF(lwp) THEN                  ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Force the background value applied to avm & avt in TKE to be everywhere ',   &
+            &               'the viscous molecular value & a very small diffusive value, resp.'
+      ENDIF
+            
+      !                             ! allocate iwm arrays
+      IF( zdf_iwm_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_iwm_init : unable to allocate iwm arrays' )
+      !
+      !                             ! read necessary fields
+!!$      CALL iom_open('mixing_power_bot',inum)       ! energy flux for high-mode wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ebot_iwm, 1 ) 
+!!$      CALL iom_close(inum)
+      ebot_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_pyc',inum)       ! energy flux for pynocline-intensified wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', epyc_iwm, 1 )
+!!$      CALL iom_close(inum)
+      epyc_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('mixing_power_cri',inum)       ! energy flux for critical slope wave breaking [W/m2]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', ecri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      ecri_iwm(:,:) = 0.
+      !
+!!$      CALL iom_open('decay_scale_bot',inum)        ! spatially variable decay scale for high-mode wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hbot_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hbot_iwm(:,:) = 1.
+      !
+!!$      CALL iom_open('decay_scale_cri',inum)        ! spatially variable decay scale for critical slope wave breaking [m]
+!!$      CALL iom_get  (inum, jpdom_data, 'field', hcri_iwm, 1 )
+!!$      CALL iom_close(inum)
+      hcri_iwm(:,:) = 1.
+
+      ebot_iwm(:,:) = ebot_iwm(:,:) * ssmask(:,:)
+      epyc_iwm(:,:) = epyc_iwm(:,:) * ssmask(:,:)
+      ecri_iwm(:,:) = ecri_iwm(:,:) * ssmask(:,:)
+
+      zbot = glob_sum( e1e2t(:,:) * ebot_iwm(:,:) )
+      zpyc = glob_sum( e1e2t(:,:) * epyc_iwm(:,:) )
+      zcri = glob_sum( e1e2t(:,:) * ecri_iwm(:,:) )
+      IF(lwp) THEN
+         WRITE(numout,*) '      High-mode wave-breaking energy:             ', zbot * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Pycnocline-intensifed wave-breaking energy: ', zpyc * 1.e-12_wp, 'TW'
+         WRITE(numout,*) '      Critical slope wave-breaking energy:        ', zcri * 1.e-12_wp, 'TW'
+      ENDIF
+      !
+   END SUBROUTINE zdf_iwm_init
+
+   !!======================================================================
+END MODULE zdfiwm
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/cpp_BENCH.fcm
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/cpp_BENCH.fcm	(revision 10136)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/BENCH_12/cpp_BENCH.fcm	(revision 10136)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys  key_mpp_mpi  
Index: /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/demo_cfgs.txt
===================================================================
--- /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/demo_cfgs.txt	(revision 10135)
+++ /NEMO/branches/2018/dev_r9759_HPC09_ESIWACE/tests/demo_cfgs.txt	(revision 10136)
@@ -6,3 +6,5 @@
 VORTEX OCE NST
 WAD OCE
-BENCH OCE
+BENCH_1 OCE
+BENCH_025 OCE
+BENCH_12 OCE
