Index: /NEMO/trunk/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm
===================================================================
--- /NEMO/trunk/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm	(revision 10424)
+++ /NEMO/trunk/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm	(revision 10425)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_iomput key_mpp_mpi key_nosignedzero key_agrif
+bld::tool::fppkeys   key_si3 key_iomput key_mpp_mpi key_agrif
Index: /NEMO/trunk/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm
===================================================================
--- /NEMO/trunk/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm	(revision 10424)
+++ /NEMO/trunk/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm	(revision 10425)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_nosignedzero
+bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi 
Index: /NEMO/trunk/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/trunk/cfgs/SHARED/namelist_ref	(revision 10424)
+++ /NEMO/trunk/cfgs/SHARED/namelist_ref	(revision 10425)
@@ -1295,5 +1295,5 @@
    !                       !  buffer blocking send or immediate non-blocking sends, resp.
    nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
-   ln_nnogather =  .false.  !  activate code to avoid mpi_allgather use at the northfold
+   ln_nnogather =  .true.  !  activate code to avoid mpi_allgather use at the northfold
    jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)
    jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)
Index: /NEMO/trunk/cfgs/SPITZ12/cpp_SPITZ12.fcm
===================================================================
--- /NEMO/trunk/cfgs/SPITZ12/cpp_SPITZ12.fcm	(revision 10424)
+++ /NEMO/trunk/cfgs/SPITZ12/cpp_SPITZ12.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_iomput key_nosignedzero key_si3
+ bld::tool::fppkeys key_mpp_mpi key_iomput key_si3
Index: /NEMO/trunk/src/ICE/ice.F90
===================================================================
--- /NEMO/trunk/src/ICE/ice.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/ice.F90	(revision 10425)
@@ -207,4 +207,6 @@
    REAL(wp), PUBLIC, PARAMETER ::   epsi20 = 1.e-20_wp  !: small number 
 
+   !                                     !!** some other parameters for advection using the ULTIMATE-MACHO scheme
+   LOGICAL, PUBLIC, DIMENSION(2) :: l_split_advumx = .FALSE.    ! force one iteration at the first time-step
 
    !                                     !!** define arrays
@@ -463,5 +465,5 @@
 
       ice_alloc = MAXVAL( ierr(:) )
-      IF( ice_alloc /= 0 )   CALL ctl_warn('ice_alloc: failed to allocate arrays.')
+      IF( ice_alloc /= 0 )   CALL ctl_stop( 'STOP', 'ice_alloc: failed to allocate arrays.' )
       !
    END FUNCTION ice_alloc
Index: /NEMO/trunk/src/ICE/ice1d.F90
===================================================================
--- /NEMO/trunk/src/ICE/ice1d.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/ice1d.F90	(revision 10425)
@@ -229,5 +229,5 @@
 
       ice1D_alloc = MAXVAL( ierr(:) )
-      IF( ice1D_alloc /= 0 )   CALL ctl_warn( 'ice1D_alloc: failed to allocate arrays.' )
+      IF( ice1D_alloc /= 0 )   CALL ctl_stop( 'STOP',  'ice1D_alloc: failed to allocate arrays.'  )
       !
    END FUNCTION ice1D_alloc
Index: /NEMO/trunk/src/ICE/icecor.F90
===================================================================
--- /NEMO/trunk/src/ICE/icecor.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icecor.F90	(revision 10425)
@@ -119,5 +119,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( u_ice, 'U', -1., v_ice, 'V', -1. )            ! lateral boundary conditions
+         CALL lbc_lnk_multi( 'icecor', u_ice, 'U', -1., v_ice, 'V', -1. )            ! lateral boundary conditions
       ENDIF
 
Index: /NEMO/trunk/src/ICE/icectl.F90
===================================================================
--- /NEMO/trunk/src/ICE/icectl.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icectl.F90	(revision 10425)
@@ -77,5 +77,6 @@
       IF( icount == 0 ) THEN
          !                          ! water flux
-         pdiag_fv = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
+         pdiag_fv = glob_sum( 'icectl',                                                                       &
+            &                 -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
             &                    wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
             &                    wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
@@ -84,18 +85,20 @@
          !
          !                          ! salt flux
-         pdiag_fs = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
+         pdiag_fs = glob_sum( 'icectl',                                                                     &
+            &                  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
             &                    sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    &
             &                  ) *  e1e2t(:,:) ) * zconv 
          !
          !                          ! heat flux
-         pdiag_ft = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
+         pdiag_ft = glob_sum( 'icectl',                                                                    &
+            &                  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
             &                  - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
             &                  ) *  e1e2t(:,:) ) * zconv
 
-         pdiag_v = glob_sum( SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t * zconv )
-
-         pdiag_s = glob_sum( SUM( sv_i * rhoi            , dim=3 ) * e1e2t * zconv )
-
-         pdiag_t = glob_sum( (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )     &
+         pdiag_v = glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t * zconv )
+
+         pdiag_s = glob_sum( 'icectl', SUM( sv_i * rhoi            , dim=3 ) * e1e2t * zconv )
+
+         pdiag_t = glob_sum( 'icectl', (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )     &
             &                 + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 ) ) * e1e2t ) * zconv
 
@@ -103,5 +106,6 @@
 
          ! water flux
-         zfv  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
+         zfv = glob_sum( 'icectl',                                                                        &
+            &             -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
             &                wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
             &                wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
@@ -110,34 +114,37 @@
 
          ! salt flux
-         zfs  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
+         zfs = glob_sum( 'icectl',                                                                       &
+            &              ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
             &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    & 
             &              ) * e1e2t(:,:) ) * zconv - pdiag_fs
 
          ! heat flux
-         zft  = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
+         zft = glob_sum( 'icectl',                                                                      &
+            &              ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
             &              - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
             &              ) * e1e2t(:,:) ) * zconv - pdiag_ft
  
          ! outputs
-         zv = ( ( glob_sum( SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t ) * zconv  &
+         zv = ( ( glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t ) * zconv  &
             &     - pdiag_v ) * r1_rdtice - zfv ) * rday
 
-         zs = ( ( glob_sum( SUM( sv_i * rhoi            , dim=3 ) * e1e2t ) * zconv  &
+         zs = ( ( glob_sum( 'icectl', SUM( sv_i * rhoi            , dim=3 ) * e1e2t ) * zconv  &
             &     - pdiag_s ) * r1_rdtice + zfs ) * rday
 
-         zt = ( glob_sum( (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )   &
+         zt = ( glob_sum( 'icectl',                                                                &
+            &             (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )                       &
             &              + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 ) ) * e1e2t ) * zconv   &
             &   - pdiag_t ) * r1_rdtice + zft
 
          ! zvtrp and zetrp must be close to 0 if the advection scheme is conservative
-         zvtrp = glob_sum( ( diag_trp_vi * rhoi + diag_trp_vs * rhos ) * e1e2t  ) * zconv * rday 
-         zetrp = glob_sum( ( diag_trp_ei        + diag_trp_es        ) * e1e2t  ) * zconv
-
-         zvmin = glob_min( v_i )
-         zamax = glob_max( SUM( a_i, dim=3 ) )
-         zamin = glob_min( a_i )
+         zvtrp = glob_sum( 'icectl', ( diag_trp_vi * rhoi + diag_trp_vs * rhos ) * e1e2t  ) * zconv * rday 
+         zetrp = glob_sum( 'icectl', ( diag_trp_ei        + diag_trp_es        ) * e1e2t  ) * zconv
+
+         zvmin = glob_min( 'icectl', v_i )
+         zamax = glob_max( 'icectl', SUM( a_i, dim=3 ) )
+         zamin = glob_min( 'icectl', a_i )
 
          ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-         zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
+         zarea   = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
          zv_sill = zarea * 2.5e-5
          zs_sill = zarea * 25.e-5
@@ -184,14 +191,14 @@
 
       ! water flux
-      zvfx  = glob_sum( ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t ) * zconv * rday
+      zvfx  = glob_sum( 'icectl', ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t ) * zconv * rday
 
       ! salt flux
-      zsfx  = glob_sum( ( sfx + diag_sice ) * e1e2t ) * zconv * rday
+      zsfx  = glob_sum( 'icectl', ( sfx + diag_sice ) * e1e2t ) * zconv * rday
 
       ! heat flux
-      zhfx  = glob_sum( ( qt_atm_oi - qt_oce_ai - diag_heat ) * e1e2t ) * zconv
+      zhfx  = glob_sum( 'icectl', ( qt_atm_oi - qt_oce_ai - diag_heat ) * e1e2t ) * zconv
 
       ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-      zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
+      zarea   = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
       zv_sill = zarea * 2.5e-5
       zs_sill = zarea * 25.e-5
@@ -400,5 +407,5 @@
       IF( lk_mpp ) THEN
          DO ialert_id = 1, inb_altests
-            CALL mpp_sum(inb_alp(ialert_id))
+            CALL mpp_sum('icectl', inb_alp(ialert_id))
          END DO
       ENDIF
Index: /NEMO/trunk/src/ICE/icedia.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedia.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedia.F90	(revision 10425)
@@ -52,6 +52,6 @@
       ALLOCATE( vol_loc_ini(jpi,jpj), sal_loc_ini(jpi,jpj), tem_loc_ini(jpi,jpj), STAT=ice_dia_alloc )
 
-      IF( lk_mpp             )   CALL mpp_sum ( ice_dia_alloc )
-      IF( ice_dia_alloc /= 0 )   CALL ctl_warn( 'ice_dia_alloc: failed to allocate arrays' )
+      CALL mpp_sum ( 'icedia', ice_dia_alloc )
+      IF( ice_dia_alloc /= 0 )   CALL ctl_stop( 'STOP',  'ice_dia_alloc: failed to allocate arrays'  )
       !
    END FUNCTION ice_dia_alloc
@@ -85,19 +85,19 @@
       ! 1 -  Contents !
       ! ----------------------- !
-      zbg_ivol = glob_sum( vt_i(:,:) * e1e2t(:,:) ) * 1.e-9                  ! ice volume (km3)
-      zbg_svol = glob_sum( vt_s(:,:) * e1e2t(:,:) ) * 1.e-9                  ! snow volume (km3)
-      zbg_area = glob_sum( at_i(:,:) * e1e2t(:,:) ) * 1.e-6                  ! area (km2)
-      zbg_isal = glob_sum( SUM( sv_i(:,:,:), dim=3 ) * e1e2t(:,:) ) * 1.e-9 ! salt content (pss*km3)
-      zbg_item = glob_sum( et_i * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
-      zbg_stem = glob_sum( et_s * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
+      zbg_ivol = glob_sum( 'icedia', vt_i(:,:) * e1e2t(:,:) ) * 1.e-9                  ! ice volume (km3)
+      zbg_svol = glob_sum( 'icedia', vt_s(:,:) * e1e2t(:,:) ) * 1.e-9                  ! snow volume (km3)
+      zbg_area = glob_sum( 'icedia', at_i(:,:) * e1e2t(:,:) ) * 1.e-6                  ! area (km2)
+      zbg_isal = glob_sum( 'icedia', SUM( sv_i(:,:,:), dim=3 ) * e1e2t(:,:) ) * 1.e-9  ! salt content (pss*km3)
+      zbg_item = glob_sum( 'icedia', et_i * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
+      zbg_stem = glob_sum( 'icedia', et_s * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
       
       ! ---------------------------!
       ! 2 - Trends due to forcing  !
       ! ---------------------------!
-      z_frc_volbot = r1_rau0 * glob_sum( - ( wfx_ice(:,:) + wfx_snw(:,:) + wfx_err_sub(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-ocean 
-      z_frc_voltop = r1_rau0 * glob_sum( - ( wfx_sub(:,:) + wfx_spr(:,:) )                    * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-atm
-      z_frc_sal    = r1_rau0 * glob_sum( -       sfx(:,:)                                     * e1e2t(:,:) ) * 1.e-9   ! salt fluxes ice/snow-ocean
-      z_frc_tembot =           glob_sum(   qt_oce_ai(:,:)                                     * e1e2t(:,:) ) * 1.e-20  ! heat on top of ocean (and below ice)
-      z_frc_temtop =           glob_sum(   qt_atm_oi(:,:)                                     * e1e2t(:,:) ) * 1.e-20  ! heat on top of ice-coean
+      z_frc_volbot = r1_rau0 * glob_sum( 'icedia', -( wfx_ice(:,:) + wfx_snw(:,:) + wfx_err_sub(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-ocean 
+      z_frc_voltop = r1_rau0 * glob_sum( 'icedia', -( wfx_sub(:,:) + wfx_spr(:,:) )                    * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-atm
+      z_frc_sal    = r1_rau0 * glob_sum( 'icedia', -      sfx(:,:)                                     * e1e2t(:,:) ) * 1.e-9   ! salt fluxes ice/snow-ocean
+      z_frc_tembot =           glob_sum( 'icedia',  qt_oce_ai(:,:)                                     * e1e2t(:,:) ) * 1.e-20  ! heat on top of ocean (and below ice)
+      z_frc_temtop =           glob_sum( 'icedia',  qt_atm_oi(:,:)                                     * e1e2t(:,:) ) * 1.e-20  ! heat on top of ice-coean
       !
       frc_voltop  = frc_voltop  + z_frc_voltop  * rdt_ice ! km3
@@ -110,7 +110,7 @@
       ! 3 -  Content variations !
       ! ----------------------- !
-      zdiff_vol = r1_rau0 * glob_sum( ( rhoi*vt_i(:,:) + rhos*vt_s(:,:) - vol_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater trend (km3) 
-      zdiff_sal = r1_rau0 * glob_sum( ( rhoi* SUM( sv_i(:,:,:), dim=3 ) - sal_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! salt content trend (km3*pss)
-      zdiff_tem =           glob_sum( ( et_i(:,:) + et_s(:,:)           - tem_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-20  ! heat content trend (1.e20 J)
+      zdiff_vol = r1_rau0 * glob_sum( 'icedia', ( rhoi*vt_i(:,:) + rhos*vt_s(:,:) - vol_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater trend (km3) 
+      zdiff_sal = r1_rau0 * glob_sum( 'icedia', ( rhoi* SUM( sv_i(:,:,:), dim=3 ) - sal_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! salt content trend (km3*pss)
+      zdiff_tem =           glob_sum( 'icedia', ( et_i(:,:) + et_s(:,:)           - tem_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-20  ! heat content trend (1.e20 J)
       !                               + SUM( qevap_ice * a_i_b, dim=3 )       !! clem: I think this term should not be there (but needs a check)
 
@@ -125,5 +125,5 @@
       ! 5 - Diagnostics writing !
       ! ----------------------- !
-!!gm I don't understand the division by the ocean surface (i.e. glob_sum( e1e2t(:,:) ) * 1.e-20 * kt*rdt )
+!!gm I don't understand the division by the ocean surface (i.e. glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt )
 !!   and its multiplication bu kt ! is it really what we want ? what is this quantity ?
 !!   IF it is really what we want, compute it at kt=nit000, not 3 time by time-step !
@@ -135,5 +135,5 @@
       IF( iom_use('ibgheatco')    )   CALL iom_put( 'ibgheatco' , zdiff_tem     )   ! ice/snow heat content drift       (1.e20 J)
       IF( iom_use('ibgheatfx')    )   CALL iom_put( 'ibgheatfx' ,               &   ! ice/snow heat flux drift          (W/m2)
-         &                                                     zdiff_tem /glob_sum( e1e2t(:,:) * 1.e-20 * kt*rdt ) )
+         &                                                     zdiff_tem /glob_sum( 'icedia', e1e2t(:,:) * 1.e-20 * kt*rdt ) )
 
       IF( iom_use('ibgfrcvoltop') )   CALL iom_put( 'ibgfrcvoltop' , frc_voltop )   ! vol  forcing ice/snw-atm          (km3 equivalent ocean water) 
@@ -143,7 +143,7 @@
       IF( iom_use('ibgfrctembot') )   CALL iom_put( 'ibgfrctembot' , frc_tembot )   ! heat on top of ocean(below ice)   (1.e20 J)   
       IF( iom_use('ibgfrchfxtop') )   CALL iom_put( 'ibgfrchfxtop' ,            &   ! heat on top of ice/snw/ocean      (W/m2) 
-         &                                                          frc_temtop / glob_sum( e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
+         &                                                          frc_temtop / glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
       IF( iom_use('ibgfrchfxbot') )   CALL iom_put( 'ibgfrchfxbot' ,            &   ! heat on top of ocean(below ice)   (W/m2) 
-         &                                                          frc_tembot / glob_sum( e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
+         &                                                          frc_tembot / glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
 
       IF( iom_use('ibgvol_tot' )  )   CALL iom_put( 'ibgvol_tot'  , zbg_ivol     )   ! ice volume                       (km3)
Index: /NEMO/trunk/src/ICE/icedyn.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedyn.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedyn.F90	(revision 10425)
@@ -116,5 +116,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zhi_max(:,:,:), 'T', 1., zhs_max(:,:,:), 'T', 1., zhip_max(:,:,:), 'T', 1. )
+      CALL lbc_lnk_multi( 'icedyn', zhi_max(:,:,:), 'T', 1., zhs_max(:,:,:), 'T', 1., zhip_max(:,:,:), 'T', 1. )
       !
       !
@@ -155,5 +155,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zdivu_i, 'T', 1. )
+         CALL lbc_lnk( 'icedyn', zdivu_i, 'T', 1. )
          IF( iom_use('icediv') )   CALL iom_put( "icediv" , zdivu_i(:,:) )
 
@@ -176,5 +176,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zdivu_i, 'T', 1. )
+         CALL lbc_lnk( 'icedyn', zdivu_i, 'T', 1. )
          IF( iom_use('icediv') )   CALL iom_put( "icediv" , zdivu_i(:,:) )
 
Index: /NEMO/trunk/src/ICE/icedyn_adv_pra.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedyn_adv_pra.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedyn_adv_pra.F90	(revision 10425)
@@ -101,5 +101,5 @@
       zcfl  =            MAXVAL( ABS( pu_ice(:,:) ) * rdt_ice * r1_e1u(:,:) )
       zcfl  = MAX( zcfl, MAXVAL( ABS( pv_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
-      IF( lk_mpp )   CALL mpp_max( zcfl )
+      CALL mpp_max( 'icedyn_adv_pra', zcfl )
       
       IF( zcfl > 0.5 ) THEN   ;   initad = 2   ;   zusnit = 0.5_wp
@@ -425,5 +425,5 @@
 
       !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( psm , 'T',  1., ps0 , 'T',  1.   &
+      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm , 'T',  1., ps0 , 'T',  1.   &
          &              , psx , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
          &              , psxx, 'T',  1., psyy, 'T',  1.   &
@@ -599,5 +599,5 @@
 
       !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( psm , 'T',  1.,  ps0 , 'T',  1.   &
+      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm , 'T',  1.,  ps0 , 'T',  1.   &
          &              , psx , 'T', -1.,  psy , 'T', -1.   &   ! caution gradient ==> the sign changes
          &              , psxx, 'T',  1.,  psyy, 'T',  1.   &
@@ -640,5 +640,5 @@
          &      STAT = ierr )
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'icedyn_adv_pra', ierr )
       IF( ierr /= 0 )   CALL ctl_stop('STOP', 'adv_pra_init : unable to allocate ice arrays for Prather advection scheme')
       !
Index: /NEMO/trunk/src/ICE/icedyn_adv_umx.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedyn_adv_umx.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedyn_adv_umx.F90	(revision 10425)
@@ -35,5 +35,5 @@
    REAL(wp) ::   z1_120 = 1._wp / 120._wp   ! =1/120
 
-   REAL(wp), DIMENSION(:,:), ALLOCATABLE :: amaxu, amaxv
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: amaxu, amaxv
    
    ! advect H all the way (and get V=H*A at the end)
@@ -119,8 +119,16 @@
       INTEGER  ::   icycle                  ! number of sub-timestep for the advection
       REAL(wp) ::   zamsk                   ! 1 if advection of concentration, 0 if advection of other tracers
-      REAL(wp) ::   zcfl , zdt
-      REAL(wp), DIMENSION(jpi,jpj) ::   zudy, zvdx, zcu_box, zcv_box, zua_ho, zva_ho
-      REAL(wp), DIMENSION(jpi,jpj) ::   zhvar
-      REAL(wp), DIMENSION(jpi,jpj) ::   zati1, zati2, z1_ai, z1_aip
+      REAL(wp) ::   zdt
+      REAL(wp), DIMENSION(1)       ::   zcflprv, zcflnow   ! send zcflnow and receive zcflprv
+      REAL(wp), DIMENSION(jpi,jpj) ::   zudy, zvdx
+      REAL(wp), DIMENSION(jpi,jpj) ::   zati1, zati2
+
+
+
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zcu_box, zcv_box
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zua_ho, zva_ho
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   z1_ai, z1_aip
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zhvar
+
       !!----------------------------------------------------------------------
       !
@@ -128,11 +136,15 @@
       !
       !
-      ! --- If ice drift field is too fast, use an appropriate time step for advection (CFL test for stability) --- !        
-      zcfl  =            MAXVAL( ABS( pu_ice(:,:) ) * rdt_ice * r1_e1u(:,:) )
-      zcfl  = MAX( zcfl, MAXVAL( ABS( pv_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
-      IF( lk_mpp )   CALL mpp_max( zcfl )
-
-      IF( zcfl > 0.5 ) THEN   ;   icycle = 2 
-      ELSE                    ;   icycle = 1 
+      ! --- If ice drift field is too fast, use an appropriate time step for advection (CFL test for stability) --- !
+      !     When needed, the advection split is applied at the next time-step in order to avoid blocking global comm.
+      !     ...this should not affect too much the stability... Was ok on the tests we did...
+      zcflnow(1) =                  MAXVAL( ABS( pu_ice(:,:) ) * rdt_ice * r1_e1u(:,:) )
+      zcflnow(1) = MAX( zcflnow(1), MAXVAL( ABS( pv_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
+      
+      ! non-blocking global communication send zcflnow and receive zcflprv
+      CALL mpp_delay_max( 'icedyn_adv_umx', 'cflice', zcflnow(:), zcflprv(:), kt == nitend - nn_fsbc + 1 )
+
+      IF( zcflprv(1) > .5 ) THEN   ;   icycle = 2
+      ELSE                         ;   icycle = 1
       ENDIF
       
@@ -159,6 +171,6 @@
 
       IF( ll_zeroup2 ) THEN
-         IF(.NOT. ALLOCATED(amaxu))       ALLOCATE(amaxu (jpi,jpj))
-         IF(.NOT. ALLOCATED(amaxv))       ALLOCATE(amaxv (jpi,jpj))
+         IF(.NOT. ALLOCATED(amaxu))       ALLOCATE(amaxu (jpi,jpj,jpl))
+         IF(.NOT. ALLOCATED(amaxv))       ALLOCATE(amaxv (jpi,jpj,jpl))
       ENDIF
       !---------------!
@@ -167,83 +179,91 @@
       DO jt = 1, icycle
 
-         IF( ll_ADVopw ) THEN
-            zamsk = 1._wp
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zudy, zvdx, zcu_box, zcv_box, pato_i(:,:), pato_i(:,:) )   ! Open water area 
-            zamsk = 0._wp
-         ELSE
+!!$         IF( ll_ADVopw ) THEN
+!!$            zamsk = 1._wp
+!!$            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zudy, zvdx, zcu_box, zcv_box, pato_i(:,:), pato_i(:,:) )   ! Open water area 
+!!$            zamsk = 0._wp
+!!$         ELSE
             zati1(:,:) = SUM( pa_i(:,:,:), dim=3 )
-         ENDIF
+!!$         ENDIF
          
-         DO jl = 1, jpl
+         WHERE( pa_i(:,:,:) >= epsi20 )   ;   z1_ai(:,:,:) = 1._wp / pa_i(:,:,:)
+         ELSEWHERE                        ;   z1_ai(:,:,:) = 0.
+         END WHERE
             !
-            WHERE( pa_i(:,:,jl) >= epsi20 )   ;   z1_ai(:,:) = 1._wp / pa_i(:,:,jl)
-            ELSEWHERE                         ;   z1_ai(:,:) = 0.
-            END WHERE
-            !
-            WHERE( pa_ip(:,:,jl) >= epsi20 )  ;   z1_aip(:,:) = 1._wp / pa_ip(:,:,jl)
-            ELSEWHERE                         ;   z1_aip(:,:) = 0.
-            END WHERE
-            !
-            IF( ll_zeroup2 ) THEN
+         WHERE( pa_ip(:,:,:) >= epsi20 )  ;   z1_aip(:,:,:) = 1._wp / pa_ip(:,:,:)
+         ELSEWHERE                        ;   z1_aip(:,:,:) = 0.
+         END WHERE
+         !
+         IF( ll_zeroup2 ) THEN
+            DO jl = 1, jpl
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1
-                     amaxu(ji,jj)=MAX( pa_i(ji,jj,jl), pa_i(ji,jj-1,jl), pa_i(ji,jj+1,jl), &
-                        &                              pa_i(ji+1,jj,jl), pa_i(ji+1,jj-1,jl), pa_i(ji+1,jj+1,jl) )
-                     amaxv(ji,jj)=MAX( pa_i(ji,jj,jl), pa_i(ji-1,jj,jl), pa_i(ji+1,jj,jl), &
-                        &                              pa_i(ji,jj+1,jl), pa_i(ji-1,jj+1,jl), pa_i(ji+1,jj+1,jl) )
-                 END DO
-               END DO
-               CALL lbc_lnk_multi(amaxu, 'T', 1., amaxv, 'T', 1.)
-            ENDIF
+                     amaxu(ji,jj,jl)=MAX( pa_i(ji,jj,jl), pa_i(ji,jj-1,jl), pa_i(ji,jj+1,jl), &
+                        &                                 pa_i(ji+1,jj,jl), pa_i(ji+1,jj-1,jl), pa_i(ji+1,jj+1,jl) )
+                     amaxv(ji,jj,jl)=MAX( pa_i(ji,jj,jl), pa_i(ji-1,jj,jl), pa_i(ji+1,jj,jl), &
+                        &                                 pa_i(ji,jj+1,jl), pa_i(ji-1,jj+1,jl), pa_i(ji+1,jj+1,jl) )
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk_multi('icedyn_adv_umx', amaxu, 'T', 1., amaxv, 'T', 1.)
+         ENDIF
+         !
+         DO jl = 1, jpl
+            zua_ho(:,:,jl) = zudy(:,:)
+            zva_ho(:,:,jl) = zvdx(:,:)
+         END DO
+         
+         zamsk = 1._wp
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, pa_i, pa_i, zua_ho, zva_ho ) ! Ice area
+         zamsk = 0._wp
+         !
+         IF( ll_thickness ) THEN
+            DO jl = 1, jpl
+               zua_ho(:,:,jl) = zudy(:,:)
+               zva_ho(:,:,jl) = zvdx(:,:)
+            END DO
+         ENDIF
             !
+         zhvar(:,:,:) = pv_i(:,:,:) * z1_ai(:,:,:)
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar, pv_i )    ! Ice volume
+         IF( ll_thickness )   pv_i(:,:,:) = zhvar(:,:,:) * pa_i(:,:,:)
+         !
+         zhvar(:,:,:) = pv_s(:,:,:) * z1_ai(:,:,:)
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar, pv_s )    ! Snw volume
+         IF( ll_thickness )   pv_s(:,:,:) = zhvar(:,:,:) * pa_i(:,:,:)
+         !
+         zhvar(:,:,:) = psv_i(:,:,:) * z1_ai(:,:,:)
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar, psv_i )    ! Salt content
+         !
+         zhvar(:,:,:) = poa_i(:,:,:) * z1_ai(:,:,:)
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar, poa_i )    ! Age content
+         !
+         DO jk = 1, nlay_i
+            zhvar(:,:,:) = pe_i(:,:,jk,:) * z1_ai(:,:,:)
+            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, zhvar, pe_i(:,:,jk,:) ) ! Ice heat content
+         END DO
+         !
+         DO jk = 1, nlay_s
+            zhvar(:,:,:) = pe_s(:,:,jk,:) * z1_ai(:,:,:)
+            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, zhvar, pe_s(:,:,jk,:) ) ! Snw heat content
+         END DO
+            !
+         IF ( ln_pnd_H12 ) THEN
+            !
+            DO jl = 1, jpl
+               zua_ho(:,:,jl) = zudy(:,:)
+               zva_ho(:,:,jl) = zvdx(:,:)
+            END DO
+            
             zamsk = 1._wp
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zudy, zvdx, zcu_box, zcv_box, pa_i(:,:,jl), pa_i(:,:,jl), &        ! Ice area
-               &          zua_ho, zva_ho )
+            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, pa_ip, pa_ip, zua_ho, zva_ho ) ! mp fraction
             zamsk = 0._wp
             !
-            IF( ll_thickness ) THEN
-               zua_ho(:,:) = zudy(:,:)
-               zva_ho(:,:) = zvdx(:,:)
-            ENDIF
-            !
-            zhvar(:,:) = pv_i(:,:,jl) * z1_ai(:,:)
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar(:,:), pv_i (:,:,jl) )    ! Ice volume
-            IF( ll_thickness )   pv_i(:,:,jl) = zhvar(:,:) * pa_i(:,:,jl)
-            !
-            zhvar(:,:) = pv_s(:,:,jl) * z1_ai(:,:)
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar(:,:), pv_s (:,:,jl) )    ! Snw volume
-            IF( ll_thickness )   pv_s(:,:,jl) = zhvar(:,:) * pa_i(:,:,jl)
-            !
-            zhvar(:,:) = psv_i(:,:,jl) * z1_ai(:,:)
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar(:,:), psv_i(:,:,jl) )    ! Salt content
-            !
-            zhvar(:,:) = poa_i(:,:,jl) * z1_ai(:,:)
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar(:,:), poa_i(:,:,jl) )    ! Age content
-            !
-            DO jk = 1, nlay_i
-               zhvar(:,:) = pe_i(:,:,jk,jl) * z1_ai(:,:)
-               CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, zhvar(:,:), pe_i(:,:,jk,jl) ) ! Ice heat content
-            END DO
-            !
-            DO jk = 1, nlay_s
-               zhvar(:,:) = pe_s(:,:,jk,jl) * z1_ai(:,:)
-               CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho, zva_ho, zcu_box, zcv_box, zhvar(:,:), pe_s(:,:,jk,jl) ) ! Snw heat content
-            END DO
-            !
-            IF ( ln_pnd_H12 ) THEN
-               !
-               zamsk = 1._wp
-               CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zudy, zvdx, zcu_box, zcv_box, pa_ip(:,:,jl), pa_ip(:,:,jl), &   ! mp fraction
-                  &          zua_ho, zva_ho )
-               zamsk = 0._wp
-
-               zhvar(:,:) = pv_ip(:,:,jl) * z1_ai(:,:)
-               CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar(:,:), pv_ip(:,:,jl) ) ! mp volume
-            ENDIF
-            !
-            !
-         END DO
-         !
-         IF( .NOT. ll_ADVopw ) THEN
+            zhvar(:,:,:) = pv_ip(:,:,:) * z1_ai(:,:,:)
+            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy, zvdx, zua_ho , zva_ho , zcu_box, zcv_box, zhvar, pv_ip ) ! mp volume
+         ENDIF
+         !
+         !
+!!$         IF( .NOT. ll_ADVopw ) THEN
             zati2(:,:) = SUM( pa_i(:,:,:), dim=3 )
             DO jj = 2, jpjm1
@@ -253,6 +273,6 @@
                END DO
             END DO
-            CALL lbc_lnk( pato_i(:,:), 'T',  1. )
-         ENDIF
+            CALL lbc_lnk( 'icedyn_adv_umx', pato_i(:,:), 'T',  1. )
+!!$         ENDIF
          !
       END DO
@@ -279,16 +299,16 @@
       INTEGER                     , INTENT(in   )           ::   kt             ! number of iteration
       REAL(wp)                    , INTENT(in   )           ::   pdt            ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   )           ::   pu   , pv      ! 2 ice velocity components => u*e2
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   )           ::   puc  , pvc     ! 2 ice velocity components => u*e2 or u*a*e2u
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   )           ::   pubox, pvbox   ! upstream velocity
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout)           ::   pt             ! tracer field
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout)           ::   ptc            ! tracer content field
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out), OPTIONAL ::   pua_ho, pva_ho ! high order u*a fluxes
-      !
-      INTEGER  ::   ji, jj           ! dummy loop indices  
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   )           ::   pu   , pv      ! 2 ice velocity components => u*e2
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   )           ::   puc  , pvc     ! 2 ice velocity components => u*e2 or u*a*e2u
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   )           ::   pubox, pvbox   ! upstream velocity
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout)           ::   pt             ! tracer field
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout)           ::   ptc            ! tracer content field
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out), OPTIONAL ::   pua_ho, pva_ho ! high order u*a fluxes
+      !
+      INTEGER  ::   ji, jj, jl       ! dummy loop indices  
       REAL(wp) ::   ztra             ! local scalar
       INTEGER  ::   kn_limiter = 1   ! 1=nonosc ; 2=superbee ; 3=h3(rachid)
-      REAL(wp), DIMENSION(jpi,jpj) ::   zfu_ho , zfv_ho , zt_u, zt_v, zpt
-      REAL(wp), DIMENSION(jpi,jpj) ::   zfu_ups, zfv_ups, zt_ups   ! only for nonosc 
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zfu_ho , zfv_ho , zt_u, zt_v, zpt
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zfu_ups, zfv_ups, zt_ups   ! only for nonosc 
       !!----------------------------------------------------------------------
       !
@@ -297,11 +317,14 @@
 
       IF( ll_gurvan .AND. pamsk==0. ) THEN
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               pt(ji,jj) = ( pt (ji,jj) + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) &
-                  &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-            END DO
-         END DO
-         CALL lbc_lnk( pt, 'T', 1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  pt(ji,jj,jl) = ( pt (ji,jj,jl) + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj)     &
+                     &                           + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) )   &
+                     &           * tmask(ji,jj,1)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( 'icedyn_adv_umx', pt, 'T', 1. )
       ENDIF
 
@@ -310,108 +333,121 @@
 
          ! fluxes in both x-y directions
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               IF( ll_clem ) THEN
-                  zfu_ups(ji,jj) = MAX( pu(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pu(ji,jj), 0._wp ) * pt(ji+1,jj)
-                  zfv_ups(ji,jj) = MAX( pv(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pv(ji,jj), 0._wp ) * pt(ji,jj+1)
-               ELSE
-                  zfu_ups(ji,jj) = MAX( puc(ji,jj), 0._wp ) * pt(ji,jj) + MIN( puc(ji,jj), 0._wp ) * pt(ji+1,jj)
-                  zfv_ups(ji,jj) = MAX( pvc(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pvc(ji,jj), 0._wp ) * pt(ji,jj+1)
-               ENDIF
-            END DO
-         END DO
-
-      ELSE
-         !
-         IF( MOD( (kt - 1) / nn_fsbc , 2 ) ==  MOD( (jt - 1) , 2 ) ) THEN   !==  odd ice time step:  adv_x then adv_y  ==!
-            ! flux in x-direction
+         DO jl = 1, jpl
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1
                   IF( ll_clem ) THEN
-                     zfu_ups(ji,jj) = MAX( pu(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pu(ji,jj), 0._wp ) * pt(ji+1,jj)
+                     zfu_ups(ji,jj,jl) = MAX( pu(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pu(ji,jj), 0._wp ) * pt(ji+1,jj,jl)
+                     zfv_ups(ji,jj,jl) = MAX( pv(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pv(ji,jj), 0._wp ) * pt(ji,jj+1,jl)
                   ELSE
-                     zfu_ups(ji,jj) = MAX( puc(ji,jj), 0._wp ) * pt(ji,jj) + MIN( puc(ji,jj), 0._wp ) * pt(ji+1,jj)
-                  ENDIF
+                     zfu_ups(ji,jj,jl) = MAX( puc(ji,jj,jl), 0._wp ) * pt(ji,jj,jl) + MIN( puc(ji,jj,jl), 0._wp ) * pt(ji+1,jj,jl)
+                     zfv_ups(ji,jj,jl) = MAX( pvc(ji,jj,jl), 0._wp ) * pt(ji,jj,jl) + MIN( pvc(ji,jj,jl), 0._wp ) * pt(ji,jj+1,jl)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+
+      ELSE
+         !
+         IF( MOD( (kt - 1) / nn_fsbc , 2 ) ==  MOD( (jt - 1) , 2 ) ) THEN   !==  odd ice time step:  adv_x then adv_y  ==!
+            ! flux in x-direction
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        zfu_ups(ji,jj,jl) = MAX( pu(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pu(ji,jj), 0._wp ) * pt(ji+1,jj,jl)
+                     ELSE
+                        zfu_ups(ji,jj,jl) = MAX( puc(ji,jj,jl), 0._wp ) * pt(ji,jj,jl) + MIN( puc(ji,jj,jl), 0._wp ) * pt(ji+1,jj,jl)
+                     ENDIF
+                  END DO
                END DO
             END DO
             
             ! first guess of tracer content from u-flux
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
-                     IF( ll_gurvan ) THEN
-                        zpt(ji,jj) = ( pt(ji,jj) - ( zfu_ups(ji,jj) - zfu_ups(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        IF( ll_gurvan ) THEN
+                           zpt(ji,jj,jl) = ( pt(ji,jj,jl) - ( zfu_ups(ji,jj,jl) - zfu_ups(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                        ELSE
+                           zpt(ji,jj,jl) = ( pt(ji,jj,jl) - ( zfu_ups(ji,jj,jl) - zfu_ups(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                              &            + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                              &            ) * tmask(ji,jj,1)
+                        ENDIF
                      ELSE
-                        zpt(ji,jj) = ( pt(ji,jj) - ( zfu_ups(ji,jj) - zfu_ups(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                           &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                           &         ) * tmask(ji,jj,1)
-                     ENDIF
-                  ELSE
-                     zpt(ji,jj) = ( ptc(ji,jj) - ( zfu_ups(ji,jj) - zfu_ups(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj) ) &
-                        &         * tmask(ji,jj,1)
-                  ENDIF
-!!                  IF( ji==26 .AND. jj==86) THEN
-!!                     WRITE(numout,*) '************************'
-!!                     WRITE(numout,*) 'zpt upstream',zpt(ji,jj)
-!!                  ENDIF
-               END DO
-            END DO
-            CALL lbc_lnk( zpt, 'T', 1. )
+                        zpt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( zfu_ups(ji,jj,jl) - zfu_ups(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj) ) &
+                           &         * tmask(ji,jj,1)
+                     ENDIF
+                     !!                  IF( ji==26 .AND. jj==86) THEN
+                     !!                     WRITE(numout,*) '************************'
+                     !!                     WRITE(numout,*) 'zpt upstream',zpt(ji,jj)
+                     !!                  ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zpt, 'T', 1. )
             !
             ! flux in y-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     zfv_ups(ji,jj) = MAX( pv(ji,jj), 0._wp ) * zpt(ji,jj) + MIN( pv(ji,jj), 0._wp ) * zpt(ji,jj+1)
-                  ELSE
-                     zfv_ups(ji,jj) = MAX( pvc(ji,jj), 0._wp ) * zpt(ji,jj) + MIN( pvc(ji,jj), 0._wp ) * zpt(ji,jj+1)
-                  ENDIF
-               END DO
-            END DO
-
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        zfv_ups(ji,jj,jl) = MAX( pv(ji,jj), 0._wp ) * zpt(ji,jj,jl) + MIN( pv(ji,jj), 0._wp ) * zpt(ji,jj+1,jl)
+                     ELSE
+                        zfv_ups(ji,jj,jl) = MAX( pvc(ji,jj,jl), 0._wp ) * zpt(ji,jj,jl) + MIN( pvc(ji,jj,jl), 0._wp ) * zpt(ji,jj+1,jl)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
          !
          ELSE                                                               !==  even ice time step:  adv_y then adv_x  ==!
             ! flux in y-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     zfv_ups(ji,jj) = MAX( pv(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pv(ji,jj), 0._wp ) * pt(ji,jj+1)
-                  ELSE
-                     zfv_ups(ji,jj) = MAX( pvc(ji,jj), 0._wp ) * pt(ji,jj) + MIN( pvc(ji,jj), 0._wp ) * pt(ji,jj+1)
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        zfv_ups(ji,jj,jl) = MAX( pv(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pv(ji,jj), 0._wp ) * pt(ji,jj+1,jl)
+                     ELSE
+                        zfv_ups(ji,jj,jl) = MAX( pvc(ji,jj,jl), 0._wp ) * pt(ji,jj,jl) + MIN( pvc(ji,jj,jl), 0._wp ) * pt(ji,jj+1,jl)
+                     ENDIF
+                  END DO
                END DO
             END DO
 
             ! first guess of tracer content from v-flux
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
-                     IF( ll_gurvan ) THEN
-                        zpt(ji,jj) = ( pt(ji,jj) - ( zfv_ups(ji,jj) - zfv_ups(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        IF( ll_gurvan ) THEN
+                           zpt(ji,jj,jl) = ( pt(ji,jj,jl) - ( zfv_ups(ji,jj,jl) - zfv_ups(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                        ELSE
+                           zpt(ji,jj,jl) = ( pt(ji,jj,jl) - ( zfv_ups(ji,jj,jl) - zfv_ups(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) &
+                              &            + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
+                              &            * tmask(ji,jj,1)
+                        ENDIF
                      ELSE
-                        zpt(ji,jj) = ( pt(ji,jj) - ( zfv_ups(ji,jj) - zfv_ups(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) &
-                        &                        + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
-                        &         * tmask(ji,jj,1)
-                     ENDIF
-                  ELSE
-                     zpt(ji,jj) = ( ptc(ji,jj) - ( zfv_ups(ji,jj) - zfv_ups(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) &
-                        &         * tmask(ji,jj,1)
-                  ENDIF
-!!                  IF( ji==26 .AND. jj==86) THEN
-!!                     WRITE(numout,*) '************************'
-!!                     WRITE(numout,*) 'zpt upstream',zpt(ji,jj)
-!!                  ENDIF
-                END DO
-            END DO
-            CALL lbc_lnk( zpt, 'T', 1. )
+                        zpt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( zfv_ups(ji,jj,jl) - zfv_ups(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) &
+                           &            * tmask(ji,jj,1)
+                     ENDIF
+                     !!                  IF( ji==26 .AND. jj==86) THEN
+                     !!                     WRITE(numout,*) '************************'
+                     !!                     WRITE(numout,*) 'zpt upstream',zpt(ji,jj)
+                     !!                  ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zpt, 'T', 1. )
             !
             ! flux in x-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     zfu_ups(ji,jj) = MAX( pu(ji,jj), 0._wp ) * zpt(ji,jj) + MIN( pu(ji,jj), 0._wp ) * zpt(ji+1,jj)
-                  ELSE
-                     zfu_ups(ji,jj) = MAX( puc(ji,jj), 0._wp ) * zpt(ji,jj) + MIN( puc(ji,jj), 0._wp ) * zpt(ji+1,jj)
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        zfu_ups(ji,jj,jl) = MAX( pu(ji,jj), 0._wp ) * zpt(ji,jj,jl) + MIN( pu(ji,jj), 0._wp ) * zpt(ji+1,jj,jl)
+                     ELSE
+                        zfu_ups(ji,jj,jl) = MAX( puc(ji,jj,jl), 0._wp ) * zpt(ji,jj,jl) + MIN( puc(ji,jj,jl), 0._wp ) * zpt(ji+1,jj,jl)
+                     ENDIF
+                  END DO
                END DO
             END DO
@@ -425,8 +461,10 @@
 
       IF( ll_zeroup2 ) THEN
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               IF( amaxu(ji,jj) == 0._wp )   zfu_ups(ji,jj) = 0._wp
-               IF( amaxv(ji,jj) == 0._wp )   zfv_ups(ji,jj) = 0._wp
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  IF( amaxu(ji,jj,jl) == 0._wp )   zfu_ups(ji,jj,jl) = 0._wp
+                  IF( amaxv(ji,jj,jl) == 0._wp )   zfv_ups(ji,jj,jl) = 0._wp
+               END DO
             END DO
          END DO
@@ -434,26 +472,28 @@
 
       ! guess after content field with upstream scheme
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1
-            ztra          = - (   zfu_ups(ji,jj) - zfu_ups(ji-1,jj  )   &
-               &                + zfv_ups(ji,jj) - zfv_ups(ji  ,jj-1) ) * r1_e1e2t(ji,jj)
-            IF( ll_clem ) THEN
-               IF( ll_gurvan ) THEN
-                  zt_ups(ji,jj) = ( pt (ji,jj) + pdt * ztra ) * tmask(ji,jj,1)
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ztra          = - (   zfu_ups(ji,jj,jl) - zfu_ups(ji-1,jj  ,jl)   &
+                  &                + zfv_ups(ji,jj,jl) - zfv_ups(ji  ,jj-1,jl) ) * r1_e1e2t(ji,jj)
+               IF( ll_clem ) THEN
+                  IF( ll_gurvan ) THEN
+                     zt_ups(ji,jj,jl) = ( pt (ji,jj,jl) + pdt * ztra ) * tmask(ji,jj,1)
+                  ELSE
+                     zt_ups(ji,jj,jl) = ( pt (ji,jj,jl) + pdt * ztra + ( pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) )   &
+                        &                                            +   pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) ) &
+                        &                                              * r1_e1e2t(ji,jj) * (1.-pamsk) ) * tmask(ji,jj,1)
+                  ENDIF
                ELSE
-                  zt_ups(ji,jj) = ( pt (ji,jj) + pdt * ztra + ( pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) )   &
-                     &                                      +   pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) ) &
-                     &                                        * r1_e1e2t(ji,jj) * (1.-pamsk) ) * tmask(ji,jj,1)
+                  zt_ups(ji,jj,jl) = ( ptc(ji,jj,jl) + pdt * ztra ) * tmask(ji,jj,1)
                ENDIF
-            ELSE
-               zt_ups(ji,jj) = ( ptc(ji,jj) + pdt * ztra ) * tmask(ji,jj,1)
-            ENDIF
-!!            IF( ji==26 .AND. jj==86) THEN
-!!               WRITE(numout,*) '**************************'
-!!               WRITE(numout,*) 'zt upstream',zt_ups(ji,jj)
-!!            ENDIF
+               !!            IF( ji==26 .AND. jj==86) THEN
+               !!               WRITE(numout,*) '**************************'
+               !!               WRITE(numout,*) 'zt upstream',zt_ups(ji,jj)
+               !!            ENDIF
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( zt_ups, 'T', 1. )
+      CALL lbc_lnk( 'icedyn_adv_umx', zt_ups, 'T', 1. )
 
       ! High order (_ho) fluxes 
@@ -476,27 +516,29 @@
          ! final trend with corrected fluxes
          ! ------------------------------------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               IF( ll_gurvan ) THEN
-                  ztra       = - ( zfu_ho(ji,jj) - zfu_ho(ji-1,jj) + zfv_ho(ji,jj) - zfv_ho(ji,jj-1) ) * r1_e1e2t(ji,jj) 
-               ELSE
-                  ztra       = ( - ( zfu_ho(ji,jj) - zfu_ho(ji-1,jj) + zfv_ho(ji,jj) - zfv_ho(ji,jj-1) )  & 
-                     &           + ( pt(ji,jj) * ( pu(ji,jj) - pu(ji-1,jj) ) * (1.-pamsk) ) &
-                     &           + ( pt(ji,jj) * ( pv(ji,jj) - pv(ji,jj-1) ) * (1.-pamsk) ) ) * r1_e1e2t(ji,jj)
-               ENDIF
-               pt(ji,jj) = ( pt(ji,jj) + pdt * ztra ) * tmask(ji,jj,1)
-
-               IF( pt(ji,jj) < -epsi20 ) THEN
-                  WRITE(numout,*) 'T<0 ',pt(ji,jj)
-               ENDIF
-               
-               IF( pt(ji,jj) < 0._wp .AND. pt(ji,jj) >= -epsi20 )   pt(ji,jj) = 0._wp
-               
-!!               IF( ji==26 .AND. jj==86) THEN
-!!                  WRITE(numout,*) 'zt high order',pt(ji,jj)
-!!               ENDIF
-            END DO
-         END DO
-         CALL lbc_lnk( pt, 'T',  1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  IF( ll_gurvan ) THEN
+                     ztra       = - ( zfu_ho(ji,jj,jl) - zfu_ho(ji-1,jj,jl) + zfv_ho(ji,jj,jl) - zfv_ho(ji,jj-1,jl) ) * r1_e1e2t(ji,jj) 
+                  ELSE
+                     ztra       = ( - ( zfu_ho(ji,jj,jl) - zfu_ho(ji-1,jj,jl) + zfv_ho(ji,jj,jl) - zfv_ho(ji,jj-1,jl) )  & 
+                        &           + ( pt(ji,jj,jl) * ( pu(ji,jj) - pu(ji-1,jj) ) * (1.-pamsk) ) &
+                        &           + ( pt(ji,jj,jl) * ( pv(ji,jj) - pv(ji,jj-1) ) * (1.-pamsk) ) ) * r1_e1e2t(ji,jj)
+                  ENDIF
+                  pt(ji,jj,jl) = ( pt(ji,jj,jl) + pdt * ztra ) * tmask(ji,jj,1)
+                  
+                  IF( pt(ji,jj,jl) < -epsi20 ) THEN
+                     WRITE(numout,*) 'T<0 ',pt(ji,jj,jl)
+                  ENDIF
+                  
+                  IF( pt(ji,jj,jl) < 0._wp .AND. pt(ji,jj,jl) >= -epsi20 )   pt(ji,jj,jl) = 0._wp
+                  
+                  !!               IF( ji==26 .AND. jj==86) THEN
+                  !!                  WRITE(numout,*) 'zt high order',pt(ji,jj)
+                  !!               ENDIF
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( 'icedyn_adv_umx', pt, 'T',  1. )
       ENDIF
    
@@ -505,40 +547,44 @@
       IF( ll_clem ) THEN
          IF( pamsk == 0. ) THEN
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ABS( puc(ji,jj) ) > 0._wp .AND. ABS( pu(ji,jj) ) > 0._wp ) THEN
-                     zfu_ho (ji,jj) = zfu_ho (ji,jj) * puc(ji,jj) / pu(ji,jj)
-                     zfu_ups(ji,jj) = zfu_ups(ji,jj) * puc(ji,jj) / pu(ji,jj)
-                  ELSE
-                     zfu_ho (ji,jj) = 0._wp
-                     zfu_ups(ji,jj) = 0._wp
-                  ENDIF
-                  !
-                  IF( ABS( pvc(ji,jj) ) > 0._wp .AND. ABS( pv(ji,jj) ) > 0._wp ) THEN
-                     zfv_ho (ji,jj) = zfv_ho (ji,jj) * pvc(ji,jj) / pv(ji,jj)
-                     zfv_ups(ji,jj) = zfv_ups(ji,jj) * pvc(ji,jj) / pv(ji,jj)
-                  ELSE
-                     zfv_ho (ji,jj) = 0._wp  
-                     zfv_ups(ji,jj) = 0._wp  
-                  ENDIF
-               ENDDO
-            ENDDO
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ABS( puc(ji,jj,jl) ) > 0._wp .AND. ABS( pu(ji,jj) ) > 0._wp ) THEN
+                        zfu_ho (ji,jj,jl) = zfu_ho (ji,jj,jl) * puc(ji,jj,jl) / pu(ji,jj)
+                        zfu_ups(ji,jj,jl) = zfu_ups(ji,jj,jl) * puc(ji,jj,jl) / pu(ji,jj)
+                     ELSE
+                        zfu_ho (ji,jj,jl) = 0._wp
+                        zfu_ups(ji,jj,jl) = 0._wp
+                     ENDIF
+                     !
+                     IF( ABS( pvc(ji,jj,jl) ) > 0._wp .AND. ABS( pv(ji,jj) ) > 0._wp ) THEN
+                        zfv_ho (ji,jj,jl) = zfv_ho (ji,jj,jl) * pvc(ji,jj,jl) / pv(ji,jj)
+                        zfv_ups(ji,jj,jl) = zfv_ups(ji,jj,jl) * pvc(ji,jj,jl) / pv(ji,jj)
+                     ELSE
+                        zfv_ho (ji,jj,jl) = 0._wp  
+                        zfv_ups(ji,jj,jl) = 0._wp  
+                     ENDIF
+                  END DO
+               END DO
+            END DO
          ENDIF
       ENDIF
 
       IF( ll_zeroup5 ) THEN
-         DO jj = 2, jpjm1
-            DO ji = 2, fs_jpim1   ! vector opt.
-               zpt(ji,jj) = ( ptc(ji,jj) - ( zfu_ho(ji,jj) - zfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                  &                      - ( zfv_ho(ji,jj) - zfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj)  ) * tmask(ji,jj,1)
-               IF( zpt(ji,jj) < 0. ) THEN
-                  zfu_ho(ji,jj)   = zfu_ups(ji,jj)
-                  zfu_ho(ji-1,jj) = zfu_ups(ji-1,jj)
-                  zfv_ho(ji,jj)   = zfv_ups(ji,jj)
-                  zfv_ho(ji,jj-1) = zfv_ups(ji,jj-1)
-               ENDIF
-            END DO
-         END DO
-         CALL lbc_lnk_multi( zfu_ho, 'U',  -1., zfv_ho, 'V',  -1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = 2, fs_jpim1   ! vector opt.
+                  zpt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( zfu_ho(ji,jj,jl) - zfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                     &                            - ( zfv_ho(ji,jj,jl) - zfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj)  ) * tmask(ji,jj,1)
+                  IF( zpt(ji,jj,jl) < 0. ) THEN
+                     zfu_ho(ji  ,jj,jl) = zfu_ups(ji  ,jj,jl)
+                     zfu_ho(ji-1,jj,jl) = zfu_ups(ji-1,jj,jl)
+                     zfv_ho(ji  ,jj,jl) = zfv_ups(ji  ,jj,jl)
+                     zfv_ho(ji,jj-1,jl) = zfv_ups(ji,jj-1,jl)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', zfu_ho, 'U',  -1., zfv_ho, 'V',  -1. )
       ENDIF
 
@@ -546,8 +592,10 @@
       ! ----------------------------
       IF( PRESENT( pua_ho ) ) THEN
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               pua_ho(ji,jj) = zfu_ho(ji,jj)
-               pva_ho(ji,jj) = zfv_ho(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  pua_ho(ji,jj,jl) = zfu_ho(ji,jj,jl)
+                  pva_ho(ji,jj,jl) = zfv_ho(ji,jj,jl)
+               END DO
             END DO
          END DO
@@ -558,17 +606,19 @@
          ! final trend with corrected fluxes
          ! ------------------------------------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1 
-               ztra = - ( zfu_ho(ji,jj) - zfu_ho(ji-1,jj) + zfv_ho(ji,jj) - zfv_ho(ji,jj-1) ) * r1_e1e2t(ji,jj) * pdt  
-
-               ptc(ji,jj) = ( ptc(ji,jj) + ztra ) * tmask(ji,jj,1)
-                             
-!!               IF( ji==26 .AND. jj==86) THEN
-!!                  WRITE(numout,*) 'ztc high order',ptc(ji,jj)
-!!               ENDIF
-               
-            END DO
-         END DO
-         CALL lbc_lnk( ptc, 'T',  1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1 
+                  ztra = - ( zfu_ho(ji,jj,jl) - zfu_ho(ji-1,jj,jl) + zfv_ho(ji,jj,jl) - zfv_ho(ji,jj-1,jl) ) * r1_e1e2t(ji,jj) * pdt  
+                  
+                  ptc(ji,jj,jl) = ( ptc(ji,jj,jl) + ztra ) * tmask(ji,jj,1)
+                  
+                  !!               IF( ji==26 .AND. jj==86) THEN
+                  !!                  WRITE(numout,*) 'ztc high order',ptc(ji,jj)
+                  !!               ENDIF
+                  
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( 'icedyn_adv_umx', ptc, 'T',  1. )
       ENDIF
       
@@ -593,28 +643,30 @@
       INTEGER                     , INTENT(in   ) ::   kt               ! number of iteration
       REAL(wp)                    , INTENT(in   ) ::   pdt              ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt               ! tracer fields
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pu, pv           ! 2 ice velocity components
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   puc, pvc         ! 2 ice velocity * A components
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptc              ! tracer content at before time step 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pfu_ho, pfv_ho   ! high order fluxes 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt_ups           ! upstream guess of tracer content 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pfu_ups, pfv_ups ! upstream fluxes 
-      !
-      INTEGER  ::   ji, jj    ! dummy loop indices
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt               ! tracer fields
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   ) ::   pu, pv           ! 2 ice velocity components
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   puc, pvc         ! 2 ice velocity * A components
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   ptc              ! tracer content at before time step 
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pfu_ho, pfv_ho   ! high order fluxes 
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt_ups           ! upstream guess of tracer content 
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pfu_ups, pfv_ups ! upstream fluxes 
+      !
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
       LOGICAL  ::   ll_xy = .TRUE.
-      REAL(wp), DIMENSION(jpi,jpj) ::   zzt
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zzt
       !!----------------------------------------------------------------------
       !
       IF( .NOT.ll_xy ) THEN   !-- no alternate directions --!
          !
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               IF( ll_clem ) THEN
-                  pfu_ho(ji,jj) = 0.5 * pu(ji,jj) * ( pt(ji,jj) + pt(ji+1,jj) )
-                  pfv_ho(ji,jj) = 0.5 * pv(ji,jj) * ( pt(ji,jj) + pt(ji,jj+1) )
-               ELSE
-                  pfu_ho(ji,jj) = 0.5 * puc(ji,jj) * ( pt(ji,jj) + pt(ji+1,jj) )
-                  pfv_ho(ji,jj) = 0.5 * pvc(ji,jj) * ( pt(ji,jj) + pt(ji,jj+1) )
-               ENDIF
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  IF( ll_clem ) THEN
+                     pfu_ho(ji,jj,jl) = 0.5 * pu(ji,jj) * ( pt(ji,jj,jl) + pt(ji+1,jj,jl) )
+                     pfv_ho(ji,jj,jl) = 0.5 * pv(ji,jj) * ( pt(ji,jj,jl) + pt(ji,jj+1,jl) )
+                  ELSE
+                     pfu_ho(ji,jj,jl) = 0.5 * puc(ji,jj,jl) * ( pt(ji,jj,jl) + pt(ji+1,jj,jl) )
+                     pfv_ho(ji,jj,jl) = 0.5 * pvc(ji,jj,jl) * ( pt(ji,jj,jl) + pt(ji,jj+1,jl) )
+                  ENDIF
+               END DO
             END DO
          END DO
@@ -638,11 +690,13 @@
             !
             ! flux in x-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     pfu_ho(ji,jj) = 0.5 * pu(ji,jj) * ( pt(ji,jj) + pt(ji+1,jj) )
-                  ELSE
-                     pfu_ho(ji,jj) = 0.5 * puc(ji,jj) * ( pt(ji,jj) + pt(ji+1,jj) )
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        pfu_ho(ji,jj,jl) = 0.5 * pu(ji,jj) * ( pt(ji,jj,jl) + pt(ji+1,jj,jl) )
+                     ELSE
+                        pfu_ho(ji,jj,jl) = 0.5 * puc(ji,jj,jl) * ( pt(ji,jj,jl) + pt(ji+1,jj,jl) )
+                     ENDIF
+                  END DO
                END DO
             END DO
@@ -651,25 +705,29 @@
 
             ! first guess of tracer content from u-flux
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
-                     zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)        &
-                           &                  + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)        &
+                           &            + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
                            &         * tmask(ji,jj,1)
-                  ELSE                     
-                     zzt(ji,jj) = ( ptc(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-                  ENDIF
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+                     ELSE                     
+                        zzt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
 
             ! flux in y-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     pfv_ho(ji,jj) = 0.5 * pv(ji,jj) * ( zzt(ji,jj) + zzt(ji,jj+1) )
-                  ELSE                     
-                     pfv_ho(ji,jj) = 0.5 * pvc(ji,jj) * ( zzt(ji,jj) + zzt(ji,jj+1) )
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        pfv_ho(ji,jj,jl) = 0.5 * pv(ji,jj) * ( zzt(ji,jj,jl) + zzt(ji,jj+1,jl) )
+                     ELSE                     
+                        pfv_ho(ji,jj,jl) = 0.5 * pvc(ji,jj,jl) * ( zzt(ji,jj,jl) + zzt(ji,jj+1,jl) )
+                     ENDIF
+                  END DO
                END DO
             END DO
@@ -680,11 +738,13 @@
             !
             ! flux in y-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     pfv_ho(ji,jj) = 0.5 * pv(ji,jj) * ( pt(ji,jj) + pt(ji,jj+1) )
-                  ELSE                     
-                     pfv_ho(ji,jj) = 0.5 * pvc(ji,jj) * ( pt(ji,jj) + pt(ji,jj+1) )
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        pfv_ho(ji,jj,jl) = 0.5 * pv(ji,jj) * ( pt(ji,jj,jl) + pt(ji,jj+1,jl) )
+                     ELSE                     
+                        pfv_ho(ji,jj,jl) = 0.5 * pvc(ji,jj,jl) * ( pt(ji,jj,jl) + pt(ji,jj+1,jl) )
+                     ENDIF
+                  END DO
                END DO
             END DO
@@ -693,25 +753,29 @@
             !
             ! first guess of tracer content from v-flux
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
-                     zzt(ji,jj) = ( pt(ji,jj) - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) &
-                        &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
-                        &         * tmask(ji,jj,1)
-                  ELSE
-                     zzt(ji,jj) = ( ptc(ji,jj) - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-                  ENDIF
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) &
+                           &                     + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) ) &
+                           &         * tmask(ji,jj,1)
+                     ELSE
+                        zzt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
             !
             ! flux in x-direction
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1
-                  IF( ll_clem ) THEN
-                     pfu_ho(ji,jj) = 0.5 * pu(ji,jj) * ( zzt(ji,jj) + zzt(ji+1,jj) )
-                  ELSE
-                     pfu_ho(ji,jj) = 0.5 * puc(ji,jj) * ( zzt(ji,jj) + zzt(ji+1,jj) )
-                  ENDIF
+            DO jl = 1, jpl
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1
+                     IF( ll_clem ) THEN
+                        pfu_ho(ji,jj,jl) = 0.5 * pu(ji,jj) * ( zzt(ji,jj,jl) + zzt(ji+1,jj,jl) )
+                     ELSE
+                        pfu_ho(ji,jj,jl) = 0.5 * puc(ji,jj,jl) * ( zzt(ji,jj,jl) + zzt(ji+1,jj,jl) )
+                     ENDIF
+                  END DO
                END DO
             END DO
@@ -749,17 +813,17 @@
       INTEGER                     , INTENT(in   ) ::   kt               ! number of iteration
       REAL(wp)                    , INTENT(in   ) ::   pdt              ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt               ! tracer fields
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pu, pv           ! 2 ice velocity components
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   puc, pvc         ! 2 ice velocity * A components
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pubox, pvbox     ! upstream velocity
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptc              ! tracer content at before time step 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pt_u, pt_v       ! tracer at u- and v-points 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pfu_ho, pfv_ho   ! high order fluxes 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt_ups           ! upstream guess of tracer content 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pfu_ups, pfv_ups ! upstream fluxes 
-      !
-      INTEGER  ::   ji, jj    ! dummy loop indices
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt               ! tracer fields
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   ) ::   pu, pv           ! 2 ice velocity components
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   puc, pvc         ! 2 ice velocity * A components
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   ) ::   pubox, pvbox     ! upstream velocity
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   ptc              ! tracer content at before time step 
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pt_u, pt_v       ! tracer at u- and v-points 
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pfu_ho, pfv_ho   ! high order fluxes 
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt_ups           ! upstream guess of tracer content 
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pfu_ups, pfv_ups ! upstream fluxes 
+      !
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
       REAL(wp) ::   ztra
-      REAL(wp), DIMENSION(jpi,jpj) ::   zzt, zzfu_ho, zzfv_ho
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zzt, zzfu_ho, zzfv_ho
       !!----------------------------------------------------------------------
       !
@@ -776,36 +840,40 @@
 
             ! first guess of tracer content from u-flux
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        IF( ll_gurvan ) THEN
+                           zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                        ELSE
+                           zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                              &            + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                              &         ) * tmask(ji,jj,1)
+                        ENDIF
+                     ELSE
+                        zzt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
+
+         ELSE
+
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
                      IF( ll_gurvan ) THEN
-                        zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                        zzt(ji,jj,jl) = pt(ji,jj,jl) - pubox(ji,jj   ) * pdt * ( pt_u(ji,jj,jl) - pt_u(ji-1,jj,jl) ) * r1_e1t(ji,jj)  &
+                           &                         - pt   (ji,jj,jl) * pdt * ( pu  (ji,jj) - pu  (ji-1,jj) ) * r1_e1e2t(ji,jj)
                      ELSE
-                        zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                           &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                           &         ) * tmask(ji,jj,1)
-                     ENDIF
-                  ELSE
-                     zzt(ji,jj) = ( ptc(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-                  ENDIF
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
-
-         ELSE
-
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_gurvan ) THEN
-                     zzt(ji,jj) = pt(ji,jj) - pubox(ji,jj) * pdt * ( pt_u(ji,jj) - pt_u(ji-1,jj) ) * r1_e1t(ji,jj)  &
-                        &                   - pt   (ji,jj) * pdt * ( pu  (ji,jj) - pu  (ji-1,jj) ) * r1_e1e2t(ji,jj)
-                  ELSE
-                     zzt(ji,jj) = pt(ji,jj) - pubox(ji,jj) * pdt * ( pt_u(ji,jj) - pt_u(ji-1,jj) ) * r1_e1t(ji,jj)  &
-                        &                   - pt   (ji,jj) * pdt * ( pu  (ji,jj) - pu  (ji-1,jj) ) * r1_e1e2t(ji,jj) * pamsk
-                  ENDIF
-                  zzt(ji,jj) = zzt(ji,jj) * tmask(ji,jj,1)
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+                        zzt(ji,jj,jl) = pt(ji,jj,jl) - pubox(ji,jj   ) * pdt * ( pt_u(ji,jj,jl) - pt_u(ji-1,jj,jl) ) * r1_e1t(ji,jj)  &
+                           &                         - pt   (ji,jj,jl) * pdt * ( pu  (ji,jj) - pu  (ji-1,jj) ) * r1_e1e2t(ji,jj) * pamsk
+                     ENDIF
+                     zzt(ji,jj,jl) = zzt(ji,jj,jl) * tmask(ji,jj,1)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
          ENDIF
          !
@@ -832,37 +900,41 @@
             
             ! first guess of tracer content from v-flux 
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( ll_clem ) THEN
-                     IF( ll_gurvan ) THEN
-                        zzt(ji,jj) = ( pt(ji,jj) - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( ll_clem ) THEN
+                        IF( ll_gurvan ) THEN
+                           zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                        ELSE
+                           zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) &
+                              &            + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                              &         ) * tmask(ji,jj,1)
+                        ENDIF
                      ELSE
-                        zzt(ji,jj) = ( pt(ji,jj) - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) &
-                           &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                           &         ) * tmask(ji,jj,1)
-                     ENDIF
-                  ELSE
-                     zzt(ji,jj) = ( ptc(ji,jj) - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) &
-                        &         * tmask(ji,jj,1)
-                  ENDIF
-                END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+                        zzt(ji,jj,jl) = ( ptc(ji,jj,jl) - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) &
+                           &         * tmask(ji,jj,1)
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
             
          ELSE
             
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1
-                  IF( ll_gurvan ) THEN
-                     zzt(ji,jj) = pt(ji,jj) - pvbox(ji,jj) * pdt * ( pt_v(ji,jj) - pt_v(ji,jj-1) ) * r1_e2t(ji,jj)  &
-                        &                   - pt   (ji,jj) * pdt * ( pv  (ji,jj) - pv  (ji,jj-1) ) * r1_e1e2t(ji,jj)
-                  ELSE
-                     zzt(ji,jj) = pt(ji,jj) - pvbox(ji,jj) * pdt * ( pt_v(ji,jj) - pt_v(ji,jj-1) ) * r1_e2t(ji,jj)  &
-                        &                   - pt   (ji,jj) * pdt * ( pv  (ji,jj) - pv  (ji,jj-1) ) * r1_e1e2t(ji,jj) * pamsk
-                  ENDIF
-                  zzt(ji,jj) = zzt(ji,jj) * tmask(ji,jj,1)
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     IF( ll_gurvan ) THEN
+                        zzt(ji,jj,jl) = pt(ji,jj,jl) - pvbox(ji,jj   ) * pdt * ( pt_v(ji,jj,jl) - pt_v(ji,jj-1,jl) ) * r1_e2t(ji,jj)  &
+                           &                         - pt   (ji,jj,jl) * pdt * ( pv  (ji,jj) - pv  (ji,jj-1) ) * r1_e1e2t(ji,jj)
+                     ELSE
+                        zzt(ji,jj,jl) = pt(ji,jj,jl) - pvbox(ji,jj   ) * pdt * ( pt_v(ji,jj,jl) - pt_v(ji,jj-1,jl) ) * r1_e2t(ji,jj)  &
+                           &                         - pt   (ji,jj,jl) * pdt * ( pv  (ji,jj) - pv  (ji,jj-1) ) * r1_e1e2t(ji,jj) * pamsk
+                     ENDIF
+                     zzt(ji,jj,jl) = zzt(ji,jj,jl) * tmask(ji,jj,1)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
          ENDIF
          !
@@ -889,6 +961,6 @@
             ENDIF
          ELSE
-            zzfu_ho(:,:) = pfu_ho(:,:)
-            zzfv_ho(:,:) = pfv_ho(:,:)
+            zzfu_ho(:,:,:) = pfu_ho(:,:,:)
+            zzfv_ho(:,:,:) = pfv_ho(:,:,:)
             ! 1st iteration of nonosc (limit the flux with the upstream solution)
             IF( ll_clem ) THEN
@@ -898,11 +970,13 @@
             ENDIF
             ! guess after content field with high order
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1
-                  ztra       = - ( zzfu_ho(ji,jj) - zzfu_ho(ji-1,jj) + zzfv_ho(ji,jj) - zzfv_ho(ji,jj-1) ) * r1_e1e2t(ji,jj)
-                  zzt(ji,jj) =   ( ptc(ji,jj) + pdt * ztra ) * tmask(ji,jj,1)
-               END DO
-            END DO
-            CALL lbc_lnk( zzt, 'T', 1. )
+            DO jl = 1, jpl
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztra          = - ( zzfu_ho(ji,jj,jl) - zzfu_ho(ji-1,jj,jl) + zzfv_ho(ji,jj,jl) - zzfv_ho(ji,jj-1,jl) ) * r1_e1e2t(ji,jj)
+                     zzt(ji,jj,jl) =   ( ptc(ji,jj,jl) + pdt * ztra ) * tmask(ji,jj,1)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( 'icedyn_adv_umx', zzt, 'T', 1. )
             ! 2nd iteration of nonosc (limit the flux with the limited high order solution)
             IF( ll_clem ) THEN
@@ -930,38 +1004,42 @@
       INTEGER                     , INTENT(in   ) ::   kn_umx    ! order of the scheme (1-5=UM or 20=CEN2)
       REAL(wp)                    , INTENT(in   ) ::   pdt       ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pu        ! ice i-velocity component
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   puc       ! ice i-velocity * A component
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt        ! tracer fields
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pt_u      ! tracer at u-point 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pfu_ho    ! high order flux 
-      !
-      INTEGER  ::   ji, jj             ! dummy loop indices
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   ) ::   pu        ! ice i-velocity component
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   puc       ! ice i-velocity * A component
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt        ! tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pt_u      ! tracer at u-point 
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pfu_ho    ! high order flux 
+      !
+      INTEGER  ::   ji, jj, jl             ! dummy loop indices
       REAL(wp) ::   zcu, zdx2, zdx4    !   -      -
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztu1, ztu2, ztu3, ztu4
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   ztu1, ztu2, ztu3, ztu4
       !!----------------------------------------------------------------------
       !
       !                                                     !--  Laplacian in i-direction  --!
-      DO jj = 2, jpjm1         ! First derivative (gradient)
-         DO ji = 1, fs_jpim1
-            ztu1(ji,jj) = ( pt(ji+1,jj) - pt(ji,jj) ) * r1_e1u(ji,jj) * umask(ji,jj,1)
-         END DO
-         !                     ! Second derivative (Laplacian)
-         DO ji = fs_2, fs_jpim1
-            ztu2(ji,jj) = ( ztu1(ji,jj) - ztu1(ji-1,jj) ) * r1_e1t(ji,jj)
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1         ! First derivative (gradient)
+            DO ji = 1, fs_jpim1
+               ztu1(ji,jj,jl) = ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) * r1_e1u(ji,jj) * umask(ji,jj,1)
+            END DO
+            !                     ! Second derivative (Laplacian)
+            DO ji = fs_2, fs_jpim1
+               ztu2(ji,jj,jl) = ( ztu1(ji,jj,jl) - ztu1(ji-1,jj,jl) ) * r1_e1t(ji,jj)
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( ztu2, 'T', 1. )
+      CALL lbc_lnk( 'icedyn_adv_umx', ztu2, 'T', 1. )
       !
       !                                                     !--  BiLaplacian in i-direction  --!
-      DO jj = 2, jpjm1         ! Third derivative
-         DO ji = 1, fs_jpim1
-            ztu3(ji,jj) = ( ztu2(ji+1,jj) - ztu2(ji,jj) ) * r1_e1u(ji,jj) * umask(ji,jj,1)
-         END DO
-         !                     ! Fourth derivative
-         DO ji = fs_2, fs_jpim1
-            ztu4(ji,jj) = ( ztu3(ji,jj) - ztu3(ji-1,jj) ) * r1_e1t(ji,jj)
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1         ! Third derivative
+            DO ji = 1, fs_jpim1
+               ztu3(ji,jj,jl) = ( ztu2(ji+1,jj,jl) - ztu2(ji,jj,jl) ) * r1_e1u(ji,jj) * umask(ji,jj,1)
+            END DO
+            !                     ! Fourth derivative
+            DO ji = fs_2, fs_jpim1
+               ztu4(ji,jj,jl) = ( ztu3(ji,jj,jl) - ztu3(ji-1,jj,jl) ) * r1_e1t(ji,jj)
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( ztu4, 'T', 1. )
+      CALL lbc_lnk( 'icedyn_adv_umx', ztu4, 'T', 1. )
       !
       !
@@ -970,8 +1048,10 @@
       CASE( 1 )                                                   !==  1st order central TIM  ==! (Eq. 21)
          !        
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (                              pt(ji+1,jj) + pt(ji,jj)   &
-                  &                                    - SIGN( 1._wp, pu(ji,jj) ) * ( pt(ji+1,jj) - pt(ji,jj) ) )
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                           pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
+                     &                                    - SIGN( 1._wp, pu(ji,jj) ) * ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) )
+               END DO
             END DO
          END DO
@@ -979,9 +1059,11 @@
       CASE( 2 )                                                   !==  2nd order central TIM  ==! (Eq. 23)
          !
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
-               pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (                                   pt(ji+1,jj) + pt(ji,jj)   &
-                  &                                               -              zcu   * ( pt(ji+1,jj) - pt(ji,jj) ) ) 
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
+                  pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                                pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
+                     &                                               -              zcu   * ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) ) 
+               END DO
             END DO
          END DO
@@ -989,13 +1071,15 @@
       CASE( 3 )                                                   !==  3rd order central TIM  ==! (Eq. 24)
          !
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
-               zdx2 = e1u(ji,jj) * e1u(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
+                  zdx2 = e1u(ji,jj) * e1u(ji,jj)
 !!rachid       zdx2 = e1u(ji,jj) * e1t(ji,jj)
-               pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (         (                         pt  (ji+1,jj) + pt  (ji,jj)        &
-                  &                                               -              zcu   * ( pt  (ji+1,jj) - pt  (ji,jj) )  )   &
-                  &        + z1_6 * zdx2 * ( zcu*zcu - 1._wp ) * (                         ztu2(ji+1,jj) + ztu2(ji,jj)        &
-                  &                                               - SIGN( 1._wp, zcu ) * ( ztu2(ji+1,jj) - ztu2(ji,jj) )  )   )
+                  pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (         (                      pt  (ji+1,jj,jl) + pt  (ji,jj,jl)        &
+                     &                                               -              zcu   * ( pt  (ji+1,jj,jl) - pt  (ji,jj,jl) )  )   &
+                     &        + z1_6 * zdx2 * ( zcu*zcu - 1._wp ) * (                         ztu2(ji+1,jj,jl) + ztu2(ji,jj,jl)        &
+                     &                                               - SIGN( 1._wp, zcu ) * ( ztu2(ji+1,jj,jl) - ztu2(ji,jj,jl) )  )   )
+               END DO
             END DO
          END DO
@@ -1003,13 +1087,15 @@
       CASE( 4 )                                                   !==  4th order central TIM  ==! (Eq. 27)
          !
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
-               zdx2 = e1u(ji,jj) * e1u(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
+                  zdx2 = e1u(ji,jj) * e1u(ji,jj)
 !!rachid       zdx2 = e1u(ji,jj) * e1t(ji,jj)
-               pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (         (                   pt  (ji+1,jj) + pt  (ji,jj)        &
-                  &                                               -          zcu * ( pt  (ji+1,jj) - pt  (ji,jj) )  )   &
-                  &        + z1_6 * zdx2 * ( zcu*zcu - 1._wp ) * (                   ztu2(ji+1,jj) + ztu2(ji,jj)        &
-                  &                                               - 0.5_wp * zcu * ( ztu2(ji+1,jj) - ztu2(ji,jj) )  )   )
+                  pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (         (                pt  (ji+1,jj,jl) + pt  (ji,jj,jl)        &
+                     &                                               -          zcu * ( pt  (ji+1,jj,jl) - pt  (ji,jj,jl) )  )   &
+                     &        + z1_6 * zdx2 * ( zcu*zcu - 1._wp ) * (                   ztu2(ji+1,jj,jl) + ztu2(ji,jj,jl)        &
+                     &                                               - 0.5_wp * zcu * ( ztu2(ji+1,jj,jl) - ztu2(ji,jj,jl) )  )   )
+               END DO
             END DO
          END DO
@@ -1017,16 +1103,18 @@
       CASE( 5 )                                                   !==  5th order central TIM  ==! (Eq. 29)
          !
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
-               zdx2 = e1u(ji,jj) * e1u(ji,jj)
-!!rachid       zdx2 = e1u(ji,jj) * e1t(ji,jj)
-               zdx4 = zdx2 * zdx2
-               pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (               (                   pt  (ji+1,jj) + pt  (ji,jj)       &
-                  &                                                     -          zcu * ( pt  (ji+1,jj) - pt  (ji,jj) ) )   &
-                  &        + z1_6   * zdx2 * ( zcu*zcu - 1._wp ) *     (                   ztu2(ji+1,jj) + ztu2(ji,jj)       &
-                  &                                                     - 0.5_wp * zcu * ( ztu2(ji+1,jj) - ztu2(ji,jj) ) )   &
-                  &        + z1_120 * zdx4 * ( zcu*zcu - 1._wp ) * ( zcu*zcu - 4._wp ) * ( ztu4(ji+1,jj) + ztu4(ji,jj)       &
-                  &                                               - SIGN( 1._wp, zcu ) * ( ztu4(ji+1,jj) - ztu4(ji,jj) ) ) )
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
+                  zdx2 = e1u(ji,jj) * e1u(ji,jj)
+                  !!rachid       zdx2 = e1u(ji,jj) * e1t(ji,jj)
+                  zdx4 = zdx2 * zdx2
+                  pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (            (                   pt  (ji+1,jj,jl) + pt  (ji,jj,jl)       &
+                     &                                                     -          zcu * ( pt  (ji+1,jj,jl) - pt  (ji,jj,jl) ) )   &
+                     &        + z1_6   * zdx2 * ( zcu*zcu - 1._wp ) *     (                   ztu2(ji+1,jj,jl) + ztu2(ji,jj,jl)       &
+                     &                                                     - 0.5_wp * zcu * ( ztu2(ji+1,jj,jl) - ztu2(ji,jj,jl) ) )   &
+                     &        + z1_120 * zdx4 * ( zcu*zcu - 1._wp ) * ( zcu*zcu - 4._wp ) * ( ztu4(ji+1,jj,jl) + ztu4(ji,jj,jl)       &
+                     &                                               - SIGN( 1._wp, zcu ) * ( ztu4(ji+1,jj,jl) - ztu4(ji,jj,jl) ) ) )
+               END DO
             END DO
          END DO
@@ -1035,21 +1123,25 @@
       !                                                     !-- High order flux in i-direction  --!
       IF( ll_neg ) THEN
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  IF( pt_u(ji,jj,jl) < 0._wp ) THEN
+                     pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                           pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
+                        &                                    - SIGN( 1._wp, pu(ji,jj) ) * ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      DO jl = 1, jpl
          DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               IF( pt_u(ji,jj) < 0._wp ) THEN
-                  pt_u(ji,jj) = 0.5_wp * umask(ji,jj,1) * (                              pt(ji+1,jj) + pt(ji,jj)   &
-                     &                                    - SIGN( 1._wp, pu(ji,jj) ) * ( pt(ji+1,jj) - pt(ji,jj) ) )
+            DO ji = 1, fs_jpim1   ! vector opt.
+               IF( ll_clem ) THEN
+                  pfu_ho(ji,jj,jl) = pu(ji,jj) * pt_u(ji,jj,jl)
+               ELSE
+                  pfu_ho(ji,jj,jl) = puc(ji,jj,jl) * pt_u(ji,jj,jl)
                ENDIF
             END DO
-         END DO
-      ENDIF
-
-      DO jj = 1, jpjm1
-         DO ji = 1, fs_jpim1   ! vector opt.
-            IF( ll_clem ) THEN
-               pfu_ho(ji,jj) = pu(ji,jj) * pt_u(ji,jj)
-            ELSE
-               pfu_ho(ji,jj) = puc(ji,jj) * pt_u(ji,jj)
-            ENDIF
          END DO
       END DO
@@ -1071,101 +1163,115 @@
       INTEGER                     , INTENT(in   ) ::   kn_umx    ! order of the scheme (1-5=UM or 20=CEN2)
       REAL(wp)                    , INTENT(in   ) ::   pdt       ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pv        ! ice j-velocity component
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pvc       ! ice j-velocity*A component
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pt        ! tracer fields
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pt_v      ! tracer at v-point 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pfv_ho    ! high order flux 
-      !
-      INTEGER  ::   ji, jj       ! dummy loop indices
+      REAL(wp), DIMENSION(:,:  ), INTENT(in   ) ::   pv        ! ice j-velocity component
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pvc       ! ice j-velocity*A component
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pt        ! tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pt_v      ! tracer at v-point 
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   pfv_ho    ! high order flux 
+      !
+      INTEGER  ::   ji, jj, jl       ! dummy loop indices
       REAL(wp) ::   zcv, zdy2, zdy4    !   -      -
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztv1, ztv2, ztv3, ztv4
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   ztv1, ztv2, ztv3, ztv4
       !!----------------------------------------------------------------------
       !
       !                                                     !--  Laplacian in j-direction  --!
-      DO jj = 1, jpjm1         ! First derivative (gradient)
-         DO ji = fs_2, fs_jpim1
-            ztv1(ji,jj) = ( pt(ji,jj+1) - pt(ji,jj) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
+      DO jl = 1, jpl
+         DO jj = 1, jpjm1         ! First derivative (gradient)
+            DO ji = fs_2, fs_jpim1
+               ztv1(ji,jj,jl) = ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
+            END DO
+         END DO
+         DO jj = 2, jpjm1         ! Second derivative (Laplacian)
+            DO ji = fs_2, fs_jpim1
+               ztv2(ji,jj,jl) = ( ztv1(ji,jj,jl) - ztv1(ji,jj-1,jl) ) * r1_e2t(ji,jj)
+            END DO
          END DO
       END DO
-      DO jj = 2, jpjm1         ! Second derivative (Laplacian)
-         DO ji = fs_2, fs_jpim1
-            ztv2(ji,jj) = ( ztv1(ji,jj) - ztv1(ji,jj-1) ) * r1_e2t(ji,jj)
+      CALL lbc_lnk( 'icedyn_adv_umx', ztv2, 'T', 1. )
+      !
+      !                                                     !--  BiLaplacian in j-direction  --!
+      DO jl = 1, jpl
+         DO jj = 1, jpjm1         ! First derivative
+            DO ji = fs_2, fs_jpim1
+               ztv3(ji,jj,jl) = ( ztv2(ji,jj+1,jl) - ztv2(ji,jj,jl) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
+            END DO
+         END DO
+         DO jj = 2, jpjm1         ! Second derivative
+            DO ji = fs_2, fs_jpim1
+               ztv4(ji,jj,jl) = ( ztv3(ji,jj,jl) - ztv3(ji,jj-1,jl) ) * r1_e2t(ji,jj)
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( ztv2, 'T', 1. )
-      !
-      !                                                     !--  BiLaplacian in j-direction  --!
-      DO jj = 1, jpjm1         ! First derivative
-         DO ji = fs_2, fs_jpim1
-            ztv3(ji,jj) = ( ztv2(ji,jj+1) - ztv2(ji,jj) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
-         END DO
-      END DO
-      DO jj = 2, jpjm1         ! Second derivative
-         DO ji = fs_2, fs_jpim1
-            ztv4(ji,jj) = ( ztv3(ji,jj) - ztv3(ji,jj-1) ) * r1_e2t(ji,jj)
-         END DO
-      END DO
-      CALL lbc_lnk( ztv4, 'T', 1. )
+      CALL lbc_lnk( 'icedyn_adv_umx', ztv4, 'T', 1. )
       !
       !
       SELECT CASE (kn_umx )
-      !
+         !
       CASE( 1 )                                                !==  1st order central TIM  ==! (Eq. 21)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (                             ( pt(ji,jj+1) + pt(ji,jj) )  &
-                  &                                     - SIGN( 1._wp, pv(ji,jj) ) * ( pt(ji,jj+1) - pt(ji,jj) ) )
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                          ( pt(ji,jj+1,jl) + pt(ji,jj,jl) )  &
+                     &                                     - SIGN( 1._wp, pv(ji,jj) ) * ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) )
+               END DO
             END DO
          END DO
          !
       CASE( 2 )                                                !==  2nd order central TIM  ==! (Eq. 23)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
-               pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (        ( pt(ji,jj+1) + pt(ji,jj) )  &
-                  &                                     - zcv * ( pt(ji,jj+1) - pt(ji,jj) ) )
-            END DO
-         END DO
-         CALL lbc_lnk( pt_v, 'V',  1. )
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
+                  pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (     ( pt(ji,jj+1,jl) + pt(ji,jj,jl) )  &
+                     &                                     - zcv * ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( 'icedyn_adv_umx', pt_v, 'V',  1. )
          !
       CASE( 3 )                                                !==  3rd order central TIM  ==! (Eq. 24)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
-               zdy2 = e2v(ji,jj) * e2v(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
+                  zdy2 = e2v(ji,jj) * e2v(ji,jj)
 !!rachid       zdy2 = e2v(ji,jj) * e2t(ji,jj)
-               pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (                                 ( pt  (ji,jj+1) + pt  (ji,jj)       &
-                  &                                     -                        zcv   * ( pt  (ji,jj+1) - pt  (ji,jj) ) )   &
-                  &        + z1_6 * zdy2 * ( zcv*zcv - 1._wp ) * (                         ztv2(ji,jj+1) + ztv2(ji,jj)       &
-                  &                                               - SIGN( 1._wp, zcv ) * ( ztv2(ji,jj+1) - ztv2(ji,jj) ) ) )
+                  pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                              ( pt  (ji,jj+1,jl) + pt  (ji,jj,jl)       &
+                     &                                     -                        zcv   * ( pt  (ji,jj+1,jl) - pt  (ji,jj,jl) ) )   &
+                     &        + z1_6 * zdy2 * ( zcv*zcv - 1._wp ) * (                         ztv2(ji,jj+1,jl) + ztv2(ji,jj,jl)       &
+                     &                                               - SIGN( 1._wp, zcv ) * ( ztv2(ji,jj+1,jl) - ztv2(ji,jj,jl) ) ) )
+               END DO
             END DO
          END DO
          !
       CASE( 4 )                                                !==  4th order central TIM  ==! (Eq. 27)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
-               zdy2 = e2v(ji,jj) * e2v(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
+                  zdy2 = e2v(ji,jj) * e2v(ji,jj)
 !!rachid       zdy2 = e2v(ji,jj) * e2t(ji,jj)
-               pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (                           ( pt  (ji,jj+1) + pt  (ji,jj)       &
-                  &                                               -          zcv * ( pt  (ji,jj+1) - pt  (ji,jj) ) )   &
-                  &        + z1_6 * zdy2 * ( zcv*zcv - 1._wp ) * (                   ztv2(ji,jj+1) + ztv2(ji,jj)       &
-                  &                                               - 0.5_wp * zcv * ( ztv2(ji,jj+1) - ztv2(ji,jj) ) ) )
+                  pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                        ( pt  (ji,jj+1,jl) + pt  (ji,jj,jl)       &
+                     &                                               -          zcv * ( pt  (ji,jj+1,jl) - pt  (ji,jj,jl) ) )   &
+                     &        + z1_6 * zdy2 * ( zcv*zcv - 1._wp ) * (                   ztv2(ji,jj+1,jl) + ztv2(ji,jj,jl)       &
+                     &                                               - 0.5_wp * zcv * ( ztv2(ji,jj+1,jl) - ztv2(ji,jj,jl) ) ) )
+               END DO
             END DO
          END DO
          !
       CASE( 5 )                                                !==  5th order central TIM  ==! (Eq. 29)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
-               zdy2 = e2v(ji,jj) * e2v(ji,jj)
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
+                  zdy2 = e2v(ji,jj) * e2v(ji,jj)
 !!rachid       zdy2 = e2v(ji,jj) * e2t(ji,jj)
-               zdy4 = zdy2 * zdy2
-               pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (                                 ( pt  (ji,jj+1) + pt  (ji,jj)      &
-                  &                                                     -          zcv * ( pt  (ji,jj+1) - pt  (ji,jj) ) )  &
-                  &        + z1_6   * zdy2 * ( zcv*zcv - 1._wp ) *     (                   ztv2(ji,jj+1) + ztv2(ji,jj)      &
-                  &                                                     - 0.5_wp * zcv * ( ztv2(ji,jj+1) - ztv2(ji,jj) ) )  &
-                  &        + z1_120 * zdy4 * ( zcv*zcv - 1._wp ) * ( zcv*zcv - 4._wp ) * ( ztv4(ji,jj+1) + ztv4(ji,jj)      &
-                  &                                               - SIGN( 1._wp, zcv ) * ( ztv4(ji,jj+1) - ztv4(ji,jj) ) ) )
+                  zdy4 = zdy2 * zdy2
+                  pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                              ( pt  (ji,jj+1,jl) + pt  (ji,jj,jl)      &
+                     &                                                     -          zcv * ( pt  (ji,jj+1,jl) - pt  (ji,jj,jl) ) )  &
+                     &        + z1_6   * zdy2 * ( zcv*zcv - 1._wp ) *     (                   ztv2(ji,jj+1,jl) + ztv2(ji,jj,jl)      &
+                     &                                                     - 0.5_wp * zcv * ( ztv2(ji,jj+1,jl) - ztv2(ji,jj,jl) ) )  &
+                     &        + z1_120 * zdy4 * ( zcv*zcv - 1._wp ) * ( zcv*zcv - 4._wp ) * ( ztv4(ji,jj+1,jl) + ztv4(ji,jj,jl)      &
+                     &                                               - SIGN( 1._wp, zcv ) * ( ztv4(ji,jj+1,jl) - ztv4(ji,jj,jl) ) ) )
+               END DO
             END DO
          END DO
@@ -1174,21 +1280,25 @@
       !                                                     !-- High order flux in j-direction  --!
       IF( ll_neg ) THEN
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  IF( pt_v(ji,jj,jl) < 0._wp ) THEN
+                     pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                          ( pt(ji,jj+1,jl) + pt(ji,jj,jl) )  &
+                        &                                     - SIGN( 1._wp, pv(ji,jj) ) * ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) )
+                  ENDIF
+               END DO
+            END DO
+         END DO
+      ENDIF
+
+      DO jl = 1, jpl
          DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1
-               IF( pt_v(ji,jj) < 0._wp ) THEN
-                  pt_v(ji,jj) = 0.5_wp * vmask(ji,jj,1) * (                             ( pt(ji,jj+1) + pt(ji,jj) )  &
-                     &                                     - SIGN( 1._wp, pv(ji,jj) ) * ( pt(ji,jj+1) - pt(ji,jj) ) )
+            DO ji = 1, fs_jpim1   ! vector opt.
+               IF( ll_clem ) THEN
+                  pfv_ho(ji,jj,jl) = pv(ji,jj) * pt_v(ji,jj,jl)
+               ELSE
+                  pfv_ho(ji,jj,jl) = pvc(ji,jj,jl) * pt_v(ji,jj,jl)
                ENDIF
             END DO
-         END DO
-      ENDIF
-
-      DO jj = 1, jpjm1
-         DO ji = 1, fs_jpim1   ! vector opt.
-            IF( ll_clem ) THEN
-               pfv_ho(ji,jj) = pv(ji,jj) * pt_v(ji,jj)
-            ELSE
-               pfv_ho(ji,jj) = pvc(ji,jj) * pt_v(ji,jj)
-            ENDIF
          END DO
       END DO
@@ -1212,34 +1322,39 @@
       REAL(wp)                     , INTENT(in   ) ::   pamsk            ! advection of concentration (1) or other tracers (0)
       REAL(wp)                     , INTENT(in   ) ::   pdt              ! tracer time-step
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pu               ! ice i-velocity => u*e2
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   puc              ! ice i-velocity *A => u*e2*a
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pv               ! ice j-velocity => v*e1
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pvc              ! ice j-velocity *A => v*e1*a
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   ptc, pt, pt_low  ! before field & upstream guess of after field
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(inout) ::   pfv_low, pfu_low ! upstream flux
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(inout) ::   pfv_ho, pfu_ho   ! monotonic flux
-      !
-      INTEGER  ::   ji, jj    ! dummy loop indices
+      REAL(wp), DIMENSION (:,:  ), INTENT(in   ) ::   pu               ! ice i-velocity => u*e2
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   ) ::   puc              ! ice i-velocity *A => u*e2*a
+      REAL(wp), DIMENSION (:,:  ), INTENT(in   ) ::   pv               ! ice j-velocity => v*e1
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   ) ::   pvc              ! ice j-velocity *A => v*e1*a
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   ) ::   ptc, pt, pt_low  ! before field & upstream guess of after field
+      REAL(wp), DIMENSION (:,:,:), INTENT(inout) ::   pfv_low, pfu_low ! upstream flux
+      REAL(wp), DIMENSION (:,:,:), INTENT(inout) ::   pfv_ho, pfu_ho   ! monotonic flux
+      !
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
       REAL(wp) ::   zpos, zneg, zbig, zsml, z1_dt, zpos2, zneg2   ! local scalars
       REAL(wp) ::   zau, zbu, zcu, zav, zbv, zcv, zup, zdo, zsign, zcoef        !   -      -
-      REAL(wp), DIMENSION(jpi,jpj) :: zbetup, zbetdo, zbup, zbdo, zti_low, ztj_low, zzt
+      REAL(wp), DIMENSION(jpi,jpj    ) :: zbup, zbdo
+      REAL(wp), DIMENSION(jpi,jpj,jpl) :: zbetup, zbetdo, zti_low, ztj_low, zzt
       !!----------------------------------------------------------------------
       zbig = 1.e+40_wp
       zsml = epsi20
-
+      
       IF( ll_zeroup2 ) THEN
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               IF( amaxu(ji,jj) == 0._wp )   pfu_ho(ji,jj) = 0._wp
-               IF( amaxv(ji,jj) == 0._wp )   pfv_ho(ji,jj) = 0._wp
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  IF( amaxu(ji,jj,jl) == 0._wp )   pfu_ho(ji,jj,jl) = 0._wp
+                  IF( amaxv(ji,jj,jl) == 0._wp )   pfv_ho(ji,jj,jl) = 0._wp
+               END DO
             END DO
          END DO
       ENDIF
-      
+
       IF( ll_zeroup4 ) THEN
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               IF( pfu_low(ji,jj) == 0._wp )   pfu_ho(ji,jj) = 0._wp
-               IF( pfv_low(ji,jj) == 0._wp )   pfv_ho(ji,jj) = 0._wp
+         DO jl = 1, jpl
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  IF( pfu_low(ji,jj,jl) == 0._wp )   pfu_ho(ji,jj,jl) = 0._wp
+                  IF( pfv_low(ji,jj,jl) == 0._wp )   pfv_ho(ji,jj,jl) = 0._wp
+               END DO
             END DO
          END DO
@@ -1248,59 +1363,61 @@
 
       IF( ll_zeroup1 ) THEN
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               IF( ll_gurvan ) THEN
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-               ELSE
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &         ) * tmask(ji,jj,1)
-               ENDIF
-               IF( zzt(ji,jj) < 0._wp ) THEN
-                  pfu_ho(ji,jj)   = pfu_low(ji,jj)
-                  pfv_ho(ji,jj)   = pfv_low(ji,jj)
-                  WRITE(numout,*) '*** 1 negative high order zzt ***',ji,jj,zzt(ji,jj)
-               ENDIF
-!!               IF( ji==26 .AND. jj==86) THEN
-!!                  WRITE(numout,*) 'zzt high order',zzt(ji,jj)
-!!                  WRITE(numout,*) 'pfu_ho',(pfu_ho(ji,jj)) * r1_e1e2t(ji,jj) * pdt
-!!                  WRITE(numout,*) 'pfv_ho',(pfv_ho(ji,jj)) * r1_e1e2t(ji,jj) * pdt
-!!                  WRITE(numout,*) 'pfu_hom1',(pfu_ho(ji-1,jj)) * r1_e1e2t(ji,jj) * pdt
-!!                  WRITE(numout,*) 'pfv_hom1',(pfv_ho(ji,jj-1)) * r1_e1e2t(ji,jj) * pdt
-!!               ENDIF
-               IF( ll_gurvan ) THEN
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-               ELSE
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &         ) * tmask(ji,jj,1)
-               ENDIF
-               IF( zzt(ji,jj) < 0._wp ) THEN
-                  pfu_ho(ji-1,jj) = pfu_low(ji-1,jj)
-                  pfv_ho(ji,jj-1) = pfv_low(ji,jj-1)
-                  WRITE(numout,*) '*** 2 negative high order zzt ***',ji,jj,zzt(ji,jj)
-               ENDIF
-               IF( ll_gurvan ) THEN
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-               ELSE
-                  zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj)  &
-                     &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                     &         ) * tmask(ji,jj,1)
-               ENDIF
-               IF( zzt(ji,jj) < 0._wp ) THEN
-                  WRITE(numout,*) '*** 3 negative high order zzt ***',ji,jj,zzt(ji,jj)
-               ENDIF
-            END DO
-         END DO
-         CALL lbc_lnk_multi( pfu_ho, 'U', -1., pfv_ho, 'V', -1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  IF( ll_gurvan ) THEN
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                  ELSE
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                     + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &                     + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &         ) * tmask(ji,jj,1)
+                  ENDIF
+                  IF( zzt(ji,jj,jl) < 0._wp ) THEN
+                     pfu_ho(ji,jj,jl)   = pfu_low(ji,jj,jl)
+                     pfv_ho(ji,jj,jl)   = pfv_low(ji,jj,jl)
+                     WRITE(numout,*) '*** 1 negative high order zzt ***',ji,jj,zzt(ji,jj,jl)
+                  ENDIF
+                  !!               IF( ji==26 .AND. jj==86) THEN
+                  !!                  WRITE(numout,*) 'zzt high order',zzt(ji,jj)
+                  !!                  WRITE(numout,*) 'pfu_ho',(pfu_ho(ji,jj,jl)) * r1_e1e2t(ji,jj) * pdt
+                  !!                  WRITE(numout,*) 'pfv_ho',(pfv_ho(ji,jj,jl)) * r1_e1e2t(ji,jj) * pdt
+                  !!                  WRITE(numout,*) 'pfu_hom1',(pfu_ho(ji-1,jj,jl)) * r1_e1e2t(ji,jj) * pdt
+                  !!                  WRITE(numout,*) 'pfv_hom1',(pfv_ho(ji,jj-1,jl)) * r1_e1e2t(ji,jj) * pdt
+                  !!               ENDIF
+                  IF( ll_gurvan ) THEN
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                  ELSE
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                     + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &                     + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &         ) * tmask(ji,jj,1)
+                  ENDIF
+                  IF( zzt(ji,jj,jl) < 0._wp ) THEN
+                     pfu_ho(ji-1,jj,jl) = pfu_low(ji-1,jj,jl)
+                     pfv_ho(ji,jj-1,jl) = pfv_low(ji,jj-1,jl)
+                     WRITE(numout,*) '*** 2 negative high order zzt ***',ji,jj,zzt(ji,jj,jl)
+                  ENDIF
+                  IF( ll_gurvan ) THEN
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+                  ELSE
+                     zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                        &                     + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &                     + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                        &         ) * tmask(ji,jj,1)
+                  ENDIF
+                  IF( zzt(ji,jj,jl) < 0._wp ) THEN
+                     WRITE(numout,*) '*** 3 negative high order zzt ***',ji,jj,zzt(ji,jj,jl)
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', pfu_ho, 'U', -1., pfv_ho, 'V', -1. )
       ENDIF
 
@@ -1308,9 +1425,11 @@
       ! antidiffusive flux : high order minus low order
       ! --------------------------------------------------
-      DO jj = 1, jpjm1
-         DO ji = 1, fs_jpim1   ! vector opt.
-            pfu_ho(ji,jj) = pfu_ho(ji,jj) - pfu_low(ji,jj)
-            pfv_ho(ji,jj) = pfv_ho(ji,jj) - pfv_low(ji,jj)
-          END DO
+      DO jl = 1, jpl
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               pfu_ho(ji,jj,jl) = pfu_ho(ji,jj,jl) - pfu_low(ji,jj,jl)
+               pfv_ho(ji,jj,jl) = pfv_ho(ji,jj,jl) - pfv_low(ji,jj,jl)
+            END DO
+         END DO
       END DO
 
@@ -1325,11 +1444,13 @@
       IF( ll_prelimiter_zalesak ) THEN
          
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1 
-               zti_low(ji,jj)= pt_low(ji+1,jj  )
-               ztj_low(ji,jj)= pt_low(ji  ,jj+1)
-            END DO
-         END DO
-         CALL lbc_lnk_multi( zti_low, 'T', 1., ztj_low, 'T', 1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1 
+                  zti_low(ji,jj,jl)= pt_low(ji+1,jj  ,jl)
+                  ztj_low(ji,jj,jl)= pt_low(ji  ,jj+1,jl)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', zti_low, 'T', 1., ztj_low, 'T', 1. )
 
          !! this does not work ??
@@ -1353,112 +1474,119 @@
          !!            END DO            
 
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               IF ( pfu_ho(ji,jj) * ( pt_low(ji+1,jj) - pt_low(ji,jj) ) <= 0. .AND.  &
-                  & pfv_ho(ji,jj) * ( pt_low(ji,jj+1) - pt_low(ji,jj) ) <= 0. ) THEN
-                  !
-                  IF(  pfu_ho(ji,jj) * ( zti_low(ji+1,jj) - zti_low(ji,jj) ) <= 0 .AND.  &
-                     & pfv_ho(ji,jj) * ( ztj_low(ji,jj+1) - ztj_low(ji,jj) ) <= 0)  pfu_ho(ji,jj)=0. ; pfv_ho(ji,jj)=0.
-                  !
-                  IF(  pfu_ho(ji,jj) * ( pt_low(ji  ,jj) - pt_low(ji-1,jj) ) <= 0 .AND.  &
-                     & pfv_ho(ji,jj) * ( pt_low(ji  ,jj) - pt_low(ji,jj-1) ) <= 0)  pfu_ho(ji,jj)=0. ; pfv_ho(ji,jj)=0.
-                  !
-               ENDIF
-            END DO
-         END DO
-         CALL lbc_lnk_multi( pfu_ho, 'U', -1., pfv_ho, 'V', -1. )   ! lateral boundary cond.
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  IF ( pfu_ho(ji,jj,jl) * ( pt_low(ji+1,jj,jl) - pt_low(ji,jj,jl) ) <= 0. .AND.  &
+                     & pfv_ho(ji,jj,jl) * ( pt_low(ji,jj+1,jl) - pt_low(ji,jj,jl) ) <= 0. ) THEN
+                     !
+                     IF(  pfu_ho(ji,jj,jl) * ( zti_low(ji+1,jj,jl) - zti_low(ji,jj,jl) ) <= 0 .AND.  &
+                        & pfv_ho(ji,jj,jl) * ( ztj_low(ji,jj+1,jl) - ztj_low(ji,jj,jl) ) <= 0)  pfu_ho(ji,jj,jl)=0. ; pfv_ho(ji,jj,jl)=0.
+                     !
+                     IF(  pfu_ho(ji,jj,jl) * ( pt_low(ji  ,jj,jl) - pt_low(ji-1,jj,jl) ) <= 0 .AND.  &
+                        & pfv_ho(ji,jj,jl) * ( pt_low(ji  ,jj,jl) - pt_low(ji,jj-1,jl) ) <= 0)  pfu_ho(ji,jj,jl)=0. ; pfv_ho(ji,jj,jl)=0.
+                     !
+                  ENDIF
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', pfu_ho, 'U', -1., pfv_ho, 'V', -1. )   ! lateral boundary cond.
 
       ELSEIF( ll_prelimiter_devore ) THEN
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1 
-               zti_low(ji,jj)= pt_low(ji+1,jj  )
-               ztj_low(ji,jj)= pt_low(ji  ,jj+1)
-            END DO
-         END DO
-         CALL lbc_lnk_multi( zti_low, 'T', 1., ztj_low, 'T', 1. )
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1 
+                  zti_low(ji,jj,jl)= pt_low(ji+1,jj  ,jl)
+                  ztj_low(ji,jj,jl)= pt_low(ji  ,jj+1,jl)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', zti_low, 'T', 1., ztj_low, 'T', 1. )
 
          z1_dt = 1._wp / pdt
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               zsign = SIGN( 1., pt_low(ji+1,jj) - pt_low(ji,jj) )
-               pfu_ho(ji,jj) =  zsign * MAX( 0. , MIN( ABS(pfu_ho(ji,jj)) , &
-                  &                          zsign * ( pt_low (ji  ,jj) - pt_low (ji-1,jj) ) * e1e2t(ji  ,jj) * z1_dt , &
-                  &                          zsign * ( zti_low(ji+1,jj) - zti_low(ji  ,jj) ) * e1e2t(ji+1,jj) * z1_dt ) )
-
-               zsign = SIGN( 1., pt_low(ji,jj+1) - pt_low(ji,jj) )
-               pfv_ho(ji,jj) =  zsign * MAX( 0. , MIN( ABS(pfv_ho(ji,jj)) , &
-                  &                          zsign * ( pt_low (ji,jj  ) - pt_low (ji,jj-1) ) * e1e2t(ji,jj  ) * z1_dt , &
-                  &                          zsign * ( ztj_low(ji,jj+1) - ztj_low(ji,jj  ) ) * e1e2t(ji,jj+1) * z1_dt ) )
-            END DO
-         END DO
-         CALL lbc_lnk_multi( pfu_ho, 'U', -1., pfv_ho, 'V', -1. )   ! lateral boundary cond.
-            
+         DO jl = 1, jpl
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  zsign = SIGN( 1., pt_low(ji+1,jj,jl) - pt_low(ji,jj,jl) )
+                  pfu_ho(ji,jj,jl) =  zsign * MAX( 0. , MIN( ABS(pfu_ho(ji,jj,jl)) , &
+                     &                          zsign * ( pt_low (ji  ,jj,jl) - pt_low (ji-1,jj,jl) ) * e1e2t(ji  ,jj) * z1_dt , &
+                     &                          zsign * ( zti_low(ji+1,jj,jl) - zti_low(ji  ,jj,jl) ) * e1e2t(ji+1,jj) * z1_dt ) )
+
+                  zsign = SIGN( 1., pt_low(ji,jj+1,jl) - pt_low(ji,jj,jl) )
+                  pfv_ho(ji,jj,jl) =  zsign * MAX( 0. , MIN( ABS(pfv_ho(ji,jj,jl)) , &
+                     &                          zsign * ( pt_low (ji,jj  ,jl) - pt_low (ji,jj-1,jl) ) * e1e2t(ji,jj  ) * z1_dt , &
+                     &                          zsign * ( ztj_low(ji,jj+1,jl) - ztj_low(ji,jj  ,jl) ) * e1e2t(ji,jj+1) * z1_dt ) )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk_multi( 'icedyn_adv_umx', pfu_ho, 'U', -1., pfv_ho, 'V', -1. )   ! lateral boundary cond.
+
       ENDIF
-         
-      
+
+
       ! Search local extrema
       ! --------------------
       ! max/min of pt & pt_low with large negative/positive value (-/+zbig) outside ice cover
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            IF    ( pt(ji,jj) <= 0._wp .AND. pt_low(ji,jj) <= 0._wp ) THEN
-               zbup(ji,jj) = -zbig
-               zbdo(ji,jj) =  zbig
-            ELSEIF( pt(ji,jj) <= 0._wp .AND. pt_low(ji,jj) > 0._wp ) THEN
-               zbup(ji,jj) = pt_low(ji,jj)
-               zbdo(ji,jj) = pt_low(ji,jj)
-            ELSEIF( pt(ji,jj) > 0._wp .AND. pt_low(ji,jj) <= 0._wp ) THEN
-               zbup(ji,jj) = pt(ji,jj)
-               zbdo(ji,jj) = pt(ji,jj)
-            ELSE
-               zbup(ji,jj) = MAX( pt(ji,jj) , pt_low(ji,jj) )
-               zbdo(ji,jj) = MIN( pt(ji,jj) , pt_low(ji,jj) )
-            ENDIF
-         END DO
-      END DO
-
- 
       z1_dt = 1._wp / pdt
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            !
-            IF( .NOT. ll_9points ) THEN
-            zup  = MAX( zbup(ji,jj), zbup(ji-1,jj  ), zbup(ji+1,jj  ), zbup(ji  ,jj-1), zbup(ji  ,jj+1) )  ! search max/min in neighbourhood
-            zdo  = MIN( zbdo(ji,jj), zbdo(ji-1,jj  ), zbdo(ji+1,jj  ), zbdo(ji  ,jj-1), zbdo(ji  ,jj+1) )
-            !
-            ELSE
-            zup  = MAX( zbup(ji,jj), zbup(ji-1,jj  ), zbup(ji+1,jj  ), zbup(ji  ,jj-1), zbup(ji  ,jj+1), &  ! search max/min in neighbourhood
-               &                     zbup(ji-1,jj-1), zbup(ji+1,jj+1), zbup(ji+1,jj-1), zbup(ji-1,jj+1)  )
-            zdo  = MIN( zbdo(ji,jj), zbdo(ji-1,jj  ), zbdo(ji+1,jj  ), zbdo(ji  ,jj-1), zbdo(ji  ,jj+1), &
-               &                     zbdo(ji-1,jj-1), zbdo(ji+1,jj+1), zbdo(ji+1,jj-1), zbdo(ji-1,jj+1)  )
-            ENDIF
-            !
-            zpos = MAX( 0., pfu_ho(ji-1,jj) ) - MIN( 0., pfu_ho(ji  ,jj) ) &  ! positive/negative part of the flux
-               & + MAX( 0., pfv_ho(ji,jj-1) ) - MIN( 0., pfv_ho(ji,jj  ) )
-            zneg = MAX( 0., pfu_ho(ji  ,jj) ) - MIN( 0., pfu_ho(ji-1,jj) ) &
-               & + MAX( 0., pfv_ho(ji,jj  ) ) - MIN( 0., pfv_ho(ji,jj-1) )
-            !
-            IF( ll_HgradU .AND. .NOT.ll_gurvan ) THEN
-               zneg2 = (   pt(ji,jj) * MAX( 0., pu(ji,jj) - pu(ji-1,jj) ) + pt(ji,jj) * MAX( 0., pv(ji,jj) - pv(ji,jj-1) ) &
-                  &    ) * ( 1. - pamsk )
-               zpos2 = ( - pt(ji,jj) * MIN( 0., pu(ji,jj) - pu(ji-1,jj) ) - pt(ji,jj) * MIN( 0., pv(ji,jj) - pv(ji,jj-1) ) &
-                  &    ) * ( 1. - pamsk )
-            ELSE
-               zneg2 = 0. ; zpos2 = 0.
-            ENDIF
-            !
-            !                                  ! up & down beta terms
-            IF( (zpos+zpos2) > 0. ) THEN ; zbetup(ji,jj) = MAX( 0._wp, zup - pt_low(ji,jj) ) / (zpos+zpos2) * e1e2t(ji,jj) * z1_dt
-            ELSE                         ; zbetup(ji,jj) = 0. ! zbig
-            ENDIF
-            !
-            IF( (zneg+zneg2) > 0. ) THEN ; zbetdo(ji,jj) = MAX( 0._wp, pt_low(ji,jj) - zdo ) / (zneg+zneg2) * e1e2t(ji,jj) * z1_dt
-            ELSE                         ; zbetdo(ji,jj) = 0. ! zbig
-            ENDIF
-            !
-            ! if all the points are outside ice cover
-            IF( zup == -zbig )   zbetup(ji,jj) = 0. ! zbig
-            IF( zdo ==  zbig )   zbetdo(ji,jj) = 0. ! zbig            
-            !
+      DO jl = 1, jpl
+         
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF    ( pt(ji,jj,jl) <= 0._wp .AND. pt_low(ji,jj,jl) <= 0._wp ) THEN
+                  zbup(ji,jj) = -zbig
+                  zbdo(ji,jj) =  zbig
+               ELSEIF( pt(ji,jj,jl) <= 0._wp .AND. pt_low(ji,jj,jl) > 0._wp ) THEN
+                  zbup(ji,jj) = pt_low(ji,jj,jl)
+                  zbdo(ji,jj) = pt_low(ji,jj,jl)
+               ELSEIF( pt(ji,jj,jl) > 0._wp .AND. pt_low(ji,jj,jl) <= 0._wp ) THEN
+                  zbup(ji,jj) = pt(ji,jj,jl)
+                  zbdo(ji,jj) = pt(ji,jj,jl)
+               ELSE
+                  zbup(ji,jj) = MAX( pt(ji,jj,jl) , pt_low(ji,jj,jl) )
+                  zbdo(ji,jj) = MIN( pt(ji,jj,jl) , pt_low(ji,jj,jl) )
+               ENDIF
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !
+               IF( .NOT. ll_9points ) THEN
+                  zup  = MAX( zbup(ji,jj), zbup(ji-1,jj  ), zbup(ji+1,jj  ), zbup(ji  ,jj-1), zbup(ji  ,jj+1) )  ! search max/min in neighbourhood
+                  zdo  = MIN( zbdo(ji,jj), zbdo(ji-1,jj  ), zbdo(ji+1,jj  ), zbdo(ji  ,jj-1), zbdo(ji  ,jj+1) )
+                  !
+               ELSE
+                  zup  = MAX( zbup(ji,jj), zbup(ji-1,jj  ), zbup(ji+1,jj  ), zbup(ji  ,jj-1), zbup(ji  ,jj+1), &  ! search max/min in neighbourhood
+                     &                     zbup(ji-1,jj-1), zbup(ji+1,jj+1), zbup(ji+1,jj-1), zbup(ji-1,jj+1)  )
+                  zdo  = MIN( zbdo(ji,jj), zbdo(ji-1,jj  ), zbdo(ji+1,jj  ), zbdo(ji  ,jj-1), zbdo(ji  ,jj+1), &
+                     &                     zbdo(ji-1,jj-1), zbdo(ji+1,jj+1), zbdo(ji+1,jj-1), zbdo(ji-1,jj+1)  )
+               ENDIF
+               !
+               zpos = MAX( 0., pfu_ho(ji-1,jj,jl) ) - MIN( 0., pfu_ho(ji  ,jj,jl) ) &  ! positive/negative part of the flux
+                  & + MAX( 0., pfv_ho(ji,jj-1,jl) ) - MIN( 0., pfv_ho(ji,jj  ,jl) )
+               zneg = MAX( 0., pfu_ho(ji  ,jj,jl) ) - MIN( 0., pfu_ho(ji-1,jj,jl) ) &
+                  & + MAX( 0., pfv_ho(ji,jj  ,jl) ) - MIN( 0., pfv_ho(ji,jj-1,jl) )
+               !
+               IF( ll_HgradU .AND. .NOT.ll_gurvan ) THEN
+                  zneg2 = (   pt(ji,jj,jl) * MAX( 0., pu(ji,jj) - pu(ji-1,jj) ) + pt(ji,jj,jl) * MAX( 0., pv(ji,jj) - pv(ji,jj-1) ) &
+                     &    ) * ( 1. - pamsk )
+                  zpos2 = ( - pt(ji,jj,jl) * MIN( 0., pu(ji,jj) - pu(ji-1,jj) ) - pt(ji,jj,jl) * MIN( 0., pv(ji,jj) - pv(ji,jj-1) ) &
+                     &    ) * ( 1. - pamsk )
+               ELSE
+                  zneg2 = 0. ; zpos2 = 0.
+               ENDIF
+               !
+               !                                  ! up & down beta terms
+               IF( (zpos+zpos2) > 0. ) THEN ; zbetup(ji,jj,jl) = MAX( 0._wp, zup - pt_low(ji,jj,jl) ) / (zpos+zpos2) * e1e2t(ji,jj) * z1_dt
+               ELSE                         ; zbetup(ji,jj,jl) = 0. ! zbig
+               ENDIF
+               !
+               IF( (zneg+zneg2) > 0. ) THEN ; zbetdo(ji,jj,jl) = MAX( 0._wp, pt_low(ji,jj,jl) - zdo ) / (zneg+zneg2) * e1e2t(ji,jj) * z1_dt
+               ELSE                         ; zbetdo(ji,jj,jl) = 0. ! zbig
+               ENDIF
+               !
+               ! if all the points are outside ice cover
+               IF( zup == -zbig )   zbetup(ji,jj,jl) = 0. ! zbig
+               IF( zdo ==  zbig )   zbetdo(ji,jj,jl) = 0. ! zbig            
+               !
 
 !!            IF( ji==26 .AND. jj==86) THEN
@@ -1489,67 +1617,71 @@
 !            ENDIF
             !
+            END DO
          END DO
       END DO
-      CALL lbc_lnk_multi( zbetup, 'T', 1., zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
+      CALL lbc_lnk_multi( 'icedyn_adv_umx', zbetup, 'T', 1., zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
 
       
       ! monotonic flux in the y direction
       ! ---------------------------------
-      DO jj = 1, jpjm1
-         DO ji = 1, fs_jpim1   ! vector opt.
-            zau = MIN( 1._wp , zbetdo(ji,jj) , zbetup(ji+1,jj) )
-            zbu = MIN( 1._wp , zbetup(ji,jj) , zbetdo(ji+1,jj) )
-            zcu = 0.5  + SIGN( 0.5 , pfu_ho(ji,jj) )
-            !
-            zcoef = ( zcu * zau + ( 1._wp - zcu ) * zbu )
-            
-            pfu_ho(ji,jj) = pfu_ho(ji,jj) * zcoef + pfu_low(ji,jj)
+      DO jl = 1, jpl
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zau = MIN( 1._wp , zbetdo(ji,jj,jl) , zbetup(ji+1,jj,jl) )
+               zbu = MIN( 1._wp , zbetup(ji,jj,jl) , zbetdo(ji+1,jj,jl) )
+               zcu = 0.5  + SIGN( 0.5 , pfu_ho(ji,jj,jl) )
+               !
+               zcoef = ( zcu * zau + ( 1._wp - zcu ) * zbu )
+
+               pfu_ho(ji,jj,jl) = pfu_ho(ji,jj,jl) * zcoef + pfu_low(ji,jj,jl)
 
 !!            IF( ji==26 .AND. jj==86) THEN
 !!               WRITE(numout,*) 'coefU',zcoef
-!!               WRITE(numout,*) 'pfu_ho',(pfu_ho(ji,jj)) * r1_e1e2t(ji,jj) * pdt
-!!               WRITE(numout,*) 'pfu_hom1',(pfu_ho(ji-1,jj)) * r1_e1e2t(ji,jj) * pdt
+!!               WRITE(numout,*) 'pfu_ho',(pfu_ho(ji,jj,jl)) * r1_e1e2t(ji,jj) * pdt
+!!               WRITE(numout,*) 'pfu_hom1',(pfu_ho(ji-1,jj,jl)) * r1_e1e2t(ji,jj) * pdt
 !!            ENDIF
 
-         END DO
-      END DO
-
-      DO jj = 1, jpjm1
-         DO ji = 1, fs_jpim1   ! vector opt.
-            zav = MIN( 1._wp , zbetdo(ji,jj) , zbetup(ji,jj+1) )
-            zbv = MIN( 1._wp , zbetup(ji,jj) , zbetdo(ji,jj+1) )
-            zcv = 0.5  + SIGN( 0.5 , pfv_ho(ji,jj) )
-            !
-            zcoef = ( zcv * zav + ( 1._wp - zcv ) * zbv )
-            
-            pfv_ho(ji,jj) = pfv_ho(ji,jj) * zcoef + pfv_low(ji,jj)
+            END DO
+         END DO
+
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zav = MIN( 1._wp , zbetdo(ji,jj,jl) , zbetup(ji,jj+1,jl) )
+               zbv = MIN( 1._wp , zbetup(ji,jj,jl) , zbetdo(ji,jj+1,jl) )
+               zcv = 0.5  + SIGN( 0.5 , pfv_ho(ji,jj,jl) )
+               !
+               zcoef = ( zcv * zav + ( 1._wp - zcv ) * zbv )
+
+               pfv_ho(ji,jj,jl) = pfv_ho(ji,jj,jl) * zcoef + pfv_low(ji,jj,jl)
 
 !!            IF( ji==26 .AND. jj==86) THEN
 !!               WRITE(numout,*) 'coefV',zcoef
-!!               WRITE(numout,*) 'pfv_ho',(pfv_ho(ji,jj)) * r1_e1e2t(ji,jj) * pdt
-!!               WRITE(numout,*) 'pfv_hom1',(pfv_ho(ji,jj-1)) * r1_e1e2t(ji,jj) * pdt
+!!               WRITE(numout,*) 'pfv_ho',(pfv_ho(ji,jj,jl)) * r1_e1e2t(ji,jj) * pdt
+!!               WRITE(numout,*) 'pfv_hom1',(pfv_ho(ji,jj-1,jl)) * r1_e1e2t(ji,jj) * pdt
 !!            ENDIF
-         END DO
+            END DO
+         END DO
+
+         ! clem test
+         DO jj = 2, jpjm1
+            DO ji = 2, fs_jpim1   ! vector opt.
+               IF( ll_gurvan ) THEN
+                  zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                     &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
+               ELSE
+                  zzt(ji,jj,jl) = ( pt(ji,jj,jl) - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                     &                           - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) ) * pdt * r1_e1e2t(ji,jj)  &
+                     &                     + pt(ji,jj,jl) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                     &                     + pt(ji,jj,jl) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
+                     &         ) * tmask(ji,jj,1)
+               ENDIF
+               IF( zzt(ji,jj,jl) < -epsi20 ) THEN
+                  WRITE(numout,*) 'T<0 nonosc',zzt(ji,jj,jl)
+               ENDIF
+            END DO
+         END DO
+
       END DO
 
-      ! clem test
-      DO jj = 2, jpjm1
-         DO ji = 2, fs_jpim1   ! vector opt.
-            IF( ll_gurvan ) THEN
-               zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                  &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj) ) * tmask(ji,jj,1)
-            ELSE
-               zzt(ji,jj) = ( pt(ji,jj) - ( pfu_ho(ji,jj) - pfu_ho(ji-1,jj) ) * pdt * r1_e1e2t(ji,jj)  &
-                  &                     - ( pfv_ho(ji,jj) - pfv_ho(ji,jj-1) ) * pdt * r1_e1e2t(ji,jj)  &
-                  &                     + pt(ji,jj) * pdt * ( pu(ji,jj) - pu(ji-1,jj) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                  &                     + pt(ji,jj) * pdt * ( pv(ji,jj) - pv(ji,jj-1) ) * r1_e1e2t(ji,jj) * (1.-pamsk) &
-                  &         ) * tmask(ji,jj,1)
-            ENDIF
-            IF( zzt(ji,jj) < -epsi20 ) THEN
-               WRITE(numout,*) 'T<0 nonosc',zzt(ji,jj)
-            ENDIF
-         END DO
-      END DO
-      
       !
       !
@@ -1562,90 +1694,94 @@
       !! **  Purpose :   compute flux limiter 
       !!----------------------------------------------------------------------
-      REAL(wp)                     , INTENT(in   )           ::   pdt          ! tracer time-step
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   pu           ! ice i-velocity => u*e2
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   puc          ! ice i-velocity *A => u*e2*a
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   pt           ! ice tracer
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(inout)           ::   pfu_ho       ! high order flux
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ), OPTIONAL ::   pfu_ups      ! upstream flux
+      REAL(wp)                   , INTENT(in   )           ::   pdt          ! tracer time-step
+      REAL(wp), DIMENSION (:,:  ), INTENT(in   )           ::   pu           ! ice i-velocity => u*e2
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   )           ::   puc          ! ice i-velocity *A => u*e2*a
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   )           ::   pt           ! ice tracer
+      REAL(wp), DIMENSION (:,:,:), INTENT(inout)           ::   pfu_ho       ! high order flux
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   ), OPTIONAL ::   pfu_ups      ! upstream flux
       !
       REAL(wp) ::   Cr, Rjm, Rj, Rjp, uCFL, zpsi, zh3, zlimiter, Rr
-      INTEGER  ::   ji, jj    ! dummy loop indices
-      REAL(wp), DIMENSION (jpi,jpj) ::   zslpx       ! tracer slopes 
-      !!----------------------------------------------------------------------
-      !
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            zslpx(ji,jj) = ( pt(ji+1,jj) - pt(ji,jj) ) * umask(ji,jj,1)
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
+      REAL(wp), DIMENSION (jpi,jpj,jpl) ::   zslpx       ! tracer slopes 
+      !!----------------------------------------------------------------------
+      !
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zslpx(ji,jj,jl) = ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) * umask(ji,jj,1)
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( zslpx, 'U', -1.)   ! lateral boundary cond.
+      CALL lbc_lnk( 'icedyn_adv_umx', zslpx, 'U', -1.)   ! lateral boundary cond.
       
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            uCFL = pdt * ABS( pu(ji,jj) ) * r1_e1e2t(ji,jj)
-
-            Rjm = zslpx(ji-1,jj)
-            Rj  = zslpx(ji  ,jj)
-            Rjp = zslpx(ji+1,jj)
-
-            IF( PRESENT(pfu_ups) ) THEN
-
-               IF( pu(ji,jj) > 0. ) THEN   ;   Rr = Rjm
-               ELSE                        ;   Rr = Rjp
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               uCFL = pdt * ABS( pu(ji,jj) ) * r1_e1e2t(ji,jj)
+               
+               Rjm = zslpx(ji-1,jj,jl)
+               Rj  = zslpx(ji  ,jj,jl)
+               Rjp = zslpx(ji+1,jj,jl)
+
+               IF( PRESENT(pfu_ups) ) THEN
+
+                  IF( pu(ji,jj) > 0. ) THEN   ;   Rr = Rjm
+                  ELSE                        ;   Rr = Rjp
+                  ENDIF
+
+                  zh3 = pfu_ho(ji,jj,jl) - pfu_ups(ji,jj,jl)     
+                  IF( Rj > 0. ) THEN
+                     zlimiter =  MAX( 0., MIN( zh3, MAX(-Rr * 0.5 * ABS(pu(ji,jj)),  &
+                        &        MIN( 2. * Rr * 0.5 * ABS(pu(ji,jj)),  zh3,  1.5 * Rj * 0.5 * ABS(pu(ji,jj)) ) ) ) )
+                  ELSE
+                     zlimiter = -MAX( 0., MIN(-zh3, MAX( Rr * 0.5 * ABS(pu(ji,jj)),  &
+                        &        MIN(-2. * Rr * 0.5 * ABS(pu(ji,jj)), -zh3, -1.5 * Rj * 0.5 * ABS(pu(ji,jj)) ) ) ) )
+                  ENDIF
+                  pfu_ho(ji,jj,jl) = pfu_ups(ji,jj,jl) + zlimiter
+
+               ELSE
+                  IF( Rj /= 0. ) THEN
+                     IF( pu(ji,jj) > 0. ) THEN   ;   Cr = Rjm / Rj
+                     ELSE                        ;   Cr = Rjp / Rj
+                     ENDIF
+                  ELSE
+                     Cr = 0.
+                     !IF( pu(ji,jj) > 0. ) THEN   ;   Cr = Rjm * 1.e20
+                     !ELSE                        ;   Cr = Rjp * 1.e20
+                     !ENDIF
+                  ENDIF
+
+                  ! -- superbee --
+                  zpsi = MAX( 0., MAX( MIN(1.,2.*Cr), MIN(2.,Cr) ) )
+                  ! -- van albada 2 --
+                  !!zpsi = 2.*Cr / (Cr*Cr+1.)
+
+                  ! -- sweby (with beta=1) --
+                  !!zpsi = MAX( 0., MAX( MIN(1.,1.*Cr), MIN(1.,Cr) ) )
+                  ! -- van Leer --
+                  !!zpsi = ( Cr + ABS(Cr) ) / ( 1. + ABS(Cr) )
+                  ! -- ospre --
+                  !!zpsi = 1.5 * ( Cr*Cr + Cr ) / ( Cr*Cr + Cr + 1. )
+                  ! -- koren --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( (1.+2*Cr)/3., 2. ) ) )
+                  ! -- charm --
+                  !IF( Cr > 0. ) THEN   ;   zpsi = Cr * (3.*Cr + 1.) / ( (Cr + 1.) * (Cr + 1.) )
+                  !ELSE                 ;   zpsi = 0.
+                  !ENDIF
+                  ! -- van albada 1 --
+                  !!zpsi = (Cr*Cr + Cr) / (Cr*Cr +1)
+                  ! -- smart --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, 4. ) ) )
+                  ! -- umist --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, MIN(0.75+0.25*Cr, 2. ) ) ) )
+
+                  ! high order flux corrected by the limiter
+                  pfu_ho(ji,jj,jl) = pfu_ho(ji,jj,jl) - ABS( pu(ji,jj) ) * ( (1.-zpsi) + uCFL*zpsi ) * Rj * 0.5
+
                ENDIF
-
-               zh3 = pfu_ho(ji,jj) - pfu_ups(ji,jj)     
-               IF( Rj > 0. ) THEN
-                  zlimiter =  MAX( 0., MIN( zh3, MAX(-Rr * 0.5 * ABS(puc(ji,jj)),  &
-                     &        MIN( 2. * Rr * 0.5 * ABS(puc(ji,jj)),  zh3,  1.5 * Rj * 0.5 * ABS(puc(ji,jj)) ) ) ) )
-               ELSE
-                  zlimiter = -MAX( 0., MIN(-zh3, MAX( Rr * 0.5 * ABS(puc(ji,jj)),  &
-                     &        MIN(-2. * Rr * 0.5 * ABS(puc(ji,jj)), -zh3, -1.5 * Rj * 0.5 * ABS(puc(ji,jj)) ) ) ) )
-               ENDIF
-               pfu_ho(ji,jj) = pfu_ups(ji,jj) + zlimiter
-               
-            ELSE
-               IF( Rj /= 0. ) THEN
-                  IF( pu(ji,jj) > 0. ) THEN   ;   Cr = Rjm / Rj
-                  ELSE                        ;   Cr = Rjp / Rj
-                  ENDIF
-               ELSE
-                  Cr = 0.
-                  !IF( pu(ji,jj) > 0. ) THEN   ;   Cr = Rjm * 1.e20
-                  !ELSE                        ;   Cr = Rjp * 1.e20
-                  !ENDIF
-               ENDIF
-               
-               ! -- superbee --
-               zpsi = MAX( 0., MAX( MIN(1.,2.*Cr), MIN(2.,Cr) ) )
-               ! -- van albada 2 --
-               !!zpsi = 2.*Cr / (Cr*Cr+1.)
-
-               ! -- sweby (with beta=1) --
-               !!zpsi = MAX( 0., MAX( MIN(1.,1.*Cr), MIN(1.,Cr) ) )
-               ! -- van Leer --
-               !!zpsi = ( Cr + ABS(Cr) ) / ( 1. + ABS(Cr) )
-               ! -- ospre --
-               !!zpsi = 1.5 * ( Cr*Cr + Cr ) / ( Cr*Cr + Cr + 1. )
-               ! -- koren --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( (1.+2*Cr)/3., 2. ) ) )
-               ! -- charm --
-               !IF( Cr > 0. ) THEN   ;   zpsi = Cr * (3.*Cr + 1.) / ( (Cr + 1.) * (Cr + 1.) )
-               !ELSE                 ;   zpsi = 0.
-               !ENDIF
-               ! -- van albada 1 --
-               !!zpsi = (Cr*Cr + Cr) / (Cr*Cr +1)
-               ! -- smart --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, 4. ) ) )
-               ! -- umist --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, MIN(0.75+0.25*Cr, 2. ) ) ) )
-
-               ! high order flux corrected by the limiter
-               pfu_ho(ji,jj) = pfu_ho(ji,jj) - ABS( puc(ji,jj) ) * ( (1.-zpsi) + uCFL*zpsi ) * Rj * 0.5
-
-            ENDIF
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( pfu_ho, 'U', -1.)   ! lateral boundary cond.
+      CALL lbc_lnk( 'icedyn_adv_umx', pfu_ho, 'U', -1.)   ! lateral boundary cond.
       !
    END SUBROUTINE limiter_x
@@ -1657,91 +1793,95 @@
       !! **  Purpose :   compute flux limiter 
       !!----------------------------------------------------------------------
-      REAL(wp)                     , INTENT(in   )           ::   pdt          ! tracer time-step
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   pv           ! ice i-velocity => u*e2
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   pvc          ! ice i-velocity *A => u*e2*a
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   )           ::   pt           ! ice tracer
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(inout)           ::   pfv_ho       ! high order flux
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ), OPTIONAL ::   pfv_ups      ! upstream flux
+      REAL(wp)                   , INTENT(in   )           ::   pdt          ! tracer time-step
+      REAL(wp), DIMENSION (:,:  ), INTENT(in   )           ::   pv           ! ice i-velocity => u*e2
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   )           ::   pvc          ! ice i-velocity *A => u*e2*a
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   )           ::   pt           ! ice tracer
+      REAL(wp), DIMENSION (:,:,:), INTENT(inout)           ::   pfv_ho       ! high order flux
+      REAL(wp), DIMENSION (:,:,:), INTENT(in   ), OPTIONAL ::   pfv_ups      ! upstream flux
       !
       REAL(wp) ::   Cr, Rjm, Rj, Rjp, vCFL, zpsi, zh3, zlimiter, Rr
-      INTEGER  ::   ji, jj    ! dummy loop indices
-      REAL(wp), DIMENSION (jpi,jpj) ::   zslpy       ! tracer slopes 
-      !!----------------------------------------------------------------------
-      !
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            zslpy(ji,jj) = ( pt(ji,jj+1) - pt(ji,jj) ) * vmask(ji,jj,1)
+      INTEGER  ::   ji, jj, jl    ! dummy loop indices
+      REAL(wp), DIMENSION (jpi,jpj,jpl) ::   zslpy       ! tracer slopes 
+      !!----------------------------------------------------------------------
+      !
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zslpy(ji,jj,jl) = ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) * vmask(ji,jj,1)
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( zslpy, 'V', -1.)   ! lateral boundary cond.
-      
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            vCFL = pdt * ABS( pv(ji,jj) ) * r1_e1e2t(ji,jj)
-
-            Rjm = zslpy(ji,jj-1)
-            Rj  = zslpy(ji,jj  )
-            Rjp = zslpy(ji,jj+1)
-
-            IF( PRESENT(pfv_ups) ) THEN
-
-               IF( pv(ji,jj) > 0. ) THEN   ;   Rr = Rjm
-               ELSE                        ;   Rr = Rjp
+      CALL lbc_lnk( 'icedyn_adv_umx', zslpy, 'V', -1.)   ! lateral boundary cond.
+
+      DO jl = 1, jpl
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               vCFL = pdt * ABS( pv(ji,jj) ) * r1_e1e2t(ji,jj)
+
+               Rjm = zslpy(ji,jj-1,jl)
+               Rj  = zslpy(ji,jj  ,jl)
+               Rjp = zslpy(ji,jj+1,jl)
+
+               IF( PRESENT(pfv_ups) ) THEN
+
+                  IF( pv(ji,jj) > 0. ) THEN   ;   Rr = Rjm
+                  ELSE                        ;   Rr = Rjp
+                  ENDIF
+
+                  zh3 = pfv_ho(ji,jj,jl) - pfv_ups(ji,jj,jl)     
+                  IF( Rj > 0. ) THEN
+                     zlimiter =  MAX( 0., MIN( zh3, MAX(-Rr * 0.5 * ABS(pv(ji,jj)),  &
+                        &        MIN( 2. * Rr * 0.5 * ABS(pv(ji,jj)),  zh3,  1.5 * Rj * 0.5 * ABS(pv(ji,jj)) ) ) ) )
+                  ELSE
+                     zlimiter = -MAX( 0., MIN(-zh3, MAX( Rr * 0.5 * ABS(pv(ji,jj)),  &
+                        &        MIN(-2. * Rr * 0.5 * ABS(pv(ji,jj)), -zh3, -1.5 * Rj * 0.5 * ABS(pv(ji,jj)) ) ) ) )
+                  ENDIF
+                  pfv_ho(ji,jj,jl) = pfv_ups(ji,jj,jl) + zlimiter
+
+               ELSE
+
+                  IF( Rj /= 0. ) THEN
+                     IF( pv(ji,jj) > 0. ) THEN   ;   Cr = Rjm / Rj
+                     ELSE                        ;   Cr = Rjp / Rj
+                     ENDIF
+                  ELSE
+                     Cr = 0.
+                     !IF( pv(ji,jj) > 0. ) THEN   ;   Cr = Rjm * 1.e20
+                     !ELSE                        ;   Cr = Rjp * 1.e20
+                     !ENDIF
+                  ENDIF
+
+                  ! -- superbee --
+                  zpsi = MAX( 0., MAX( MIN(1.,2.*Cr), MIN(2.,Cr) ) )
+                  ! -- van albada 2 --
+                  !!zpsi = 2.*Cr / (Cr*Cr+1.)
+
+                  ! -- sweby (with beta=1) --
+                  !!zpsi = MAX( 0., MAX( MIN(1.,1.*Cr), MIN(1.,Cr) ) )
+                  ! -- van Leer --
+                  !!zpsi = ( Cr + ABS(Cr) ) / ( 1. + ABS(Cr) )
+                  ! -- ospre --
+                  !!zpsi = 1.5 * ( Cr*Cr + Cr ) / ( Cr*Cr + Cr + 1. )
+                  ! -- koren --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( (1.+2*Cr)/3., 2. ) ) )
+                  ! -- charm --
+                  !IF( Cr > 0. ) THEN   ;   zpsi = Cr * (3.*Cr + 1.) / ( (Cr + 1.) * (Cr + 1.) )
+                  !ELSE                 ;   zpsi = 0.
+                  !ENDIF
+                  ! -- van albada 1 --
+                  !!zpsi = (Cr*Cr + Cr) / (Cr*Cr +1)
+                  ! -- smart --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, 4. ) ) )
+                  ! -- umist --
+                  !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, MIN(0.75+0.25*Cr, 2. ) ) ) )
+
+                  ! high order flux corrected by the limiter
+                  pfv_ho(ji,jj,jl) = pfv_ho(ji,jj,jl) - ABS( pv(ji,jj) ) * ( (1.-zpsi) + vCFL*zpsi ) * Rj * 0.5
+
                ENDIF
-
-               zh3 = pfv_ho(ji,jj) - pfv_ups(ji,jj)     
-               IF( Rj > 0. ) THEN
-                  zlimiter =  MAX( 0., MIN( zh3, MAX(-Rr * 0.5 * ABS(pvc(ji,jj)),  &
-                     &        MIN( 2. * Rr * 0.5 * ABS(pvc(ji,jj)),  zh3,  1.5 * Rj * 0.5 * ABS(pvc(ji,jj)) ) ) ) )
-               ELSE
-                  zlimiter = -MAX( 0., MIN(-zh3, MAX( Rr * 0.5 * ABS(pvc(ji,jj)),  &
-                     &        MIN(-2. * Rr * 0.5 * ABS(pvc(ji,jj)), -zh3, -1.5 * Rj * 0.5 * ABS(pvc(ji,jj)) ) ) ) )
-               ENDIF
-               pfv_ho(ji,jj) = pfv_ups(ji,jj) + zlimiter
-
-            ELSE
-
-               IF( Rj /= 0. ) THEN
-                  IF( pv(ji,jj) > 0. ) THEN   ;   Cr = Rjm / Rj
-                  ELSE                        ;   Cr = Rjp / Rj
-                  ENDIF
-               ELSE
-                  Cr = 0.
-                  !IF( pv(ji,jj) > 0. ) THEN   ;   Cr = Rjm * 1.e20
-                  !ELSE                        ;   Cr = Rjp * 1.e20
-                  !ENDIF
-               ENDIF
-
-               ! -- superbee --
-               zpsi = MAX( 0., MAX( MIN(1.,2.*Cr), MIN(2.,Cr) ) )
-               ! -- van albada 2 --
-               !!zpsi = 2.*Cr / (Cr*Cr+1.)
-
-               ! -- sweby (with beta=1) --
-               !!zpsi = MAX( 0., MAX( MIN(1.,1.*Cr), MIN(1.,Cr) ) )
-               ! -- van Leer --
-               !!zpsi = ( Cr + ABS(Cr) ) / ( 1. + ABS(Cr) )
-               ! -- ospre --
-               !!zpsi = 1.5 * ( Cr*Cr + Cr ) / ( Cr*Cr + Cr + 1. )
-               ! -- koren --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( (1.+2*Cr)/3., 2. ) ) )
-               ! -- charm --
-               !IF( Cr > 0. ) THEN   ;   zpsi = Cr * (3.*Cr + 1.) / ( (Cr + 1.) * (Cr + 1.) )
-               !ELSE                 ;   zpsi = 0.
-               !ENDIF
-               ! -- van albada 1 --
-               !!zpsi = (Cr*Cr + Cr) / (Cr*Cr +1)
-               ! -- smart --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, 4. ) ) )
-               ! -- umist --
-               !!zpsi = MAX( 0., MIN( 2.*Cr, MIN( 0.25+0.75*Cr, MIN(0.75+0.25*Cr, 2. ) ) ) )
-
-               ! high order flux corrected by the limiter
-               pfv_ho(ji,jj) = pfv_ho(ji,jj) - ABS( pvc(ji,jj) ) * ( (1.-zpsi) + vCFL*zpsi ) * Rj * 0.5
-
-            ENDIF
+            END DO
          END DO
       END DO
-      CALL lbc_lnk( pfv_ho, 'V', -1.)   ! lateral boundary cond.
+      CALL lbc_lnk( 'icedyn_adv_umx', pfv_ho, 'V', -1.)   ! lateral boundary cond.
       !
    END SUBROUTINE limiter_y
Index: /NEMO/trunk/src/ICE/icedyn_rdgrft.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedyn_rdgrft.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedyn_rdgrft.F90	(revision 10425)
@@ -91,6 +91,6 @@
          &      ze_i_2d(jpij,nlay_i,jpl), ze_s_2d(jpij,nlay_s,jpl), STAT=ice_dyn_rdgrft_alloc )
 
-      IF( lk_mpp                    )   CALL mpp_sum ( ice_dyn_rdgrft_alloc )
-      IF( ice_dyn_rdgrft_alloc /= 0 )   CALL ctl_warn( 'ice_dyn_rdgrft_alloc: failed to allocate arrays' )
+      CALL mpp_sum ( 'icedyn_rdgrft', ice_dyn_rdgrft_alloc )
+      IF( ice_dyn_rdgrft_alloc /= 0 )   CALL ctl_stop( 'STOP',  'ice_dyn_rdgrft_alloc: failed to allocate arrays'  )
       !
    END FUNCTION ice_dyn_rdgrft_alloc
@@ -269,5 +269,5 @@
             !
             iter = iter + 1
-            IF( iter  >  jp_itermax )    CALL ctl_warn( 'icedyn_rdgrft: non-converging ridging scheme' )
+            IF( iter  >  jp_itermax )    CALL ctl_stop( 'STOP',  'icedyn_rdgrft: non-converging ridging scheme'  )
             !
          END DO
@@ -793,5 +793,5 @@
             END DO
          END DO
-         CALL lbc_lnk( strength, 'T', 1. )
+         CALL lbc_lnk( 'icedyn_rdgrft', strength, 'T', 1. )
          !
       CASE( 2 )               !--- Temporal smoothing
@@ -814,5 +814,5 @@
             END DO
          END DO
-         CALL lbc_lnk( strength, 'T', 1. )
+         CALL lbc_lnk( 'icedyn_rdgrft', strength, 'T', 1. )
          !
       END SELECT
Index: /NEMO/trunk/src/ICE/icedyn_rhg_evp.F90
===================================================================
--- /NEMO/trunk/src/ICE/icedyn_rhg_evp.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icedyn_rhg_evp.F90	(revision 10425)
@@ -146,5 +146,5 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zds                             ! shear
       REAL(wp), DIMENSION(jpi,jpj) ::   zs1, zs2, zs12                  ! stress tensor components
-      REAL(wp), DIMENSION(jpi,jpj) ::   zu_ice, zv_ice, zresr           ! check convergence
+!!$      REAL(wp), DIMENSION(jpi,jpj) ::   zu_ice, zv_ice, zresr           ! check convergence
       REAL(wp), DIMENSION(jpi,jpj) ::   zsshdyn                         ! array used for the calculation of ice surface slope:
       !                                                                 !    ocean surface (ssh_m) if ice is not embedded
@@ -193,5 +193,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zfmask, 'F', 1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', zfmask, 'F', 1._wp )
 
       ! Lateral boundary conditions on velocity (modify zfmask)
@@ -220,5 +220,5 @@
          ENDIF
       END DO
-      CALL lbc_lnk( zfmask, 'F', 1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', zfmask, 'F', 1._wp )
 
       !------------------------------------------------------------------------------!
@@ -322,5 +322,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zmf, 'T', 1., zdt_m, 'T', 1. )
+      CALL lbc_lnk_multi( 'icedyn_rhg_evp', zmf, 'T', 1., zdt_m, 'T', 1. )
       !
       !                                  !== Landfast ice parameterization ==!
@@ -343,5 +343,5 @@
             END DO
          END DO
-         CALL lbc_lnk( tau_icebfr(:,:), 'T', 1. )
+         CALL lbc_lnk( 'icedyn_rhg_evp', tau_icebfr(:,:), 'T', 1. )
          !
       ELSEIF( ln_landfast_home ) THEN          !-- Home made
@@ -370,10 +370,12 @@
       DO jter = 1 , nn_nevp                           !    loop over jter    !
          !                                            !----------------------!        
-         IF(ln_ctl) THEN   ! Convergence test
-            DO jj = 1, jpjm1
-               zu_ice(:,jj) = u_ice(:,jj) ! velocity at previous time step
-               zv_ice(:,jj) = v_ice(:,jj)
-            END DO
-         ENDIF
+         l_full_nf_update = jter == nn_nevp   ! false: disable full North fold update (performances) for iter = 1 to nn_nevp-1
+         !
+!!$         IF(ln_ctl) THEN   ! Convergence test
+!!$            DO jj = 1, jpjm1
+!!$               zu_ice(:,jj) = u_ice(:,jj) ! velocity at previous time step
+!!$               zv_ice(:,jj) = v_ice(:,jj)
+!!$            END DO
+!!$         ENDIF
 
          ! --- divergence, tension & shear (Appendix B of Hunke & Dukowicz, 2002) --- !
@@ -388,5 +390,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zds, 'F', 1. )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zds, 'F', 1. )
 
          DO jj = 2, jpj    ! loop to jpi,jpj to avoid making a communication for zs1,zs2,zs12
@@ -432,5 +434,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zp_delt, 'T', 1. )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zp_delt, 'T', 1. )
 
          DO jj = 1, jpjm1
@@ -527,5 +529,5 @@
                END DO
             END DO
-            CALL lbc_lnk( v_ice, 'V', -1. )
+            CALL lbc_lnk( 'icedyn_rhg_evp', v_ice, 'V', -1. )
             !
 #if defined key_agrif
@@ -575,5 +577,5 @@
                END DO
             END DO
-            CALL lbc_lnk( u_ice, 'U', -1. )
+            CALL lbc_lnk( 'icedyn_rhg_evp', u_ice, 'U', -1. )
             !
 #if defined key_agrif
@@ -625,5 +627,5 @@
                END DO
             END DO
-            CALL lbc_lnk( u_ice, 'U', -1. )
+            CALL lbc_lnk( 'icedyn_rhg_evp', u_ice, 'U', -1. )
             !
 #if defined key_agrif
@@ -673,5 +675,5 @@
                END DO
             END DO
-            CALL lbc_lnk( v_ice, 'V', -1. )
+            CALL lbc_lnk( 'icedyn_rhg_evp', v_ice, 'V', -1. )
             !
 #if defined key_agrif
@@ -682,12 +684,12 @@
             !
          ENDIF
-         
-         IF(ln_ctl) THEN   ! Convergence test
-            DO jj = 2 , jpjm1
-               zresr(:,jj) = MAX( ABS( u_ice(:,jj) - zu_ice(:,jj) ), ABS( v_ice(:,jj) - zv_ice(:,jj) ) )
-            END DO
-            zresm = MAXVAL( zresr( 1:jpi, 2:jpjm1 ) )
-            IF( lk_mpp )   CALL mpp_max( zresm )   ! max over the global domain
-         ENDIF
+
+!!$         IF(ln_ctl) THEN   ! Convergence test
+!!$            DO jj = 2 , jpjm1
+!!$               zresr(:,jj) = MAX( ABS( u_ice(:,jj) - zu_ice(:,jj) ), ABS( v_ice(:,jj) - zv_ice(:,jj) ) )
+!!$            END DO
+!!$            zresm = MAXVAL( zresr( 1:jpi, 2:jpjm1 ) )
+!!$            CALL mpp_max( 'icedyn_rhg_evp', zresm )   ! max over the global domain
+!!$         ENDIF
          !
          !                                                ! ==================== !
@@ -738,8 +740,8 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( pshear_i, 'T', 1., pdivu_i, 'T', 1., pdelta_i, 'T', 1. )
+      CALL lbc_lnk_multi( 'icedyn_rhg_evp', pshear_i, 'T', 1., pdivu_i, 'T', 1., pdelta_i, 'T', 1. )
       
       ! --- Store the stress tensor for the next time step --- !
-      CALL lbc_lnk_multi( zs1, 'T', 1., zs2, 'T', 1., zs12, 'F', 1. )
+      CALL lbc_lnk_multi( 'icedyn_rhg_evp', zs1, 'T', 1., zs2, 'T', 1., zs12, 'F', 1. )
       pstress1_i (:,:) = zs1 (:,:)
       pstress2_i (:,:) = zs2 (:,:)
@@ -785,5 +787,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zsig1, 'T', 1., zsig2, 'T', 1., zsig3, 'T', 1. )
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zsig1, 'T', 1., zsig2, 'T', 1., zsig3, 'T', 1. )
          !
          IF( iom_use('isig1') )   CALL iom_put( "isig1" , zsig1 )
@@ -842,10 +844,10 @@
          END DO
          
-         CALL lbc_lnk_multi( zdiag_sig1   , 'T',  1., zdiag_sig2   , 'T',  1.,   &
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_sig1   , 'T',  1., zdiag_sig2   , 'T',  1.,   &
             &                zdiag_dssh_dx, 'U', -1., zdiag_dssh_dy, 'V', -1.,   &
             &                zdiag_corstrx, 'U', -1., zdiag_corstry, 'V', -1.,   & 
             &                zdiag_intstrx, 'U', -1., zdiag_intstry, 'V', -1.    )
                   
-         CALL lbc_lnk_multi( zdiag_utau_oi  , 'U', -1., zdiag_vtau_oi  , 'V', -1.,   &
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_utau_oi  , 'U', -1., zdiag_vtau_oi  , 'V', -1.,   &
             &                zdiag_xmtrp_ice, 'U', -1., zdiag_xmtrp_snw, 'U', -1.,   &
             &                zdiag_xatrp    , 'U', -1., zdiag_ymtrp_ice, 'V', -1.,   &
Index: /NEMO/trunk/src/ICE/iceforcing.F90
===================================================================
--- /NEMO/trunk/src/ICE/iceforcing.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/iceforcing.F90	(revision 10425)
@@ -83,5 +83,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( utau_ice, 'U', -1., vtau_ice, 'V', -1. )
+         CALL lbc_lnk_multi( 'iceforcing', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
       ENDIF
       !
Index: /NEMO/trunk/src/ICE/iceistate.F90
===================================================================
--- /NEMO/trunk/src/ICE/iceistate.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/iceistate.F90	(revision 10425)
@@ -414,4 +414,6 @@
       u_ice (:,:) = 0._wp
       v_ice (:,:) = 0._wp
+      ! fields needed for ice_dyn_adv_umx
+      l_split_advumx(1) = .FALSE.
       !
       !----------------------------------------------
@@ -483,5 +485,5 @@
 !!clem: output of initial state should be written here but it is impossible because
 !!      the ocean and ice are in the same file
-!!      CALL dia_wri_state( 'output.init', nit000 )
+!!      CALL dia_wri_state( 'output.init' )
       !
    END SUBROUTINE ice_istate
Index: /NEMO/trunk/src/ICE/icerst.F90
===================================================================
--- /NEMO/trunk/src/ICE/icerst.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icerst.F90	(revision 10425)
@@ -69,8 +69,5 @@
             IF(lwp) THEN
                WRITE(numout,*)
-               SELECT CASE ( jprstlib )
-               CASE DEFAULT
-                  WRITE(numout,*) '             open ice restart NetCDF file: ',TRIM(clpath)//clname
-               END SELECT
+               WRITE(numout,*) '             open ice restart NetCDF file: ',TRIM(clpath)//clname
                IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN
                   WRITE(numout,*) '             kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp
@@ -80,5 +77,5 @@
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kiolib = jprstlib, kdlev = jpl )
+            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kdlev = jpl )
             lrst_ice = .TRUE.
          ENDIF
@@ -98,5 +95,5 @@
       INTEGER, INTENT(in) ::   kt     ! number of iteration
       !!
-      INTEGER ::   jk ,jl   ! dummy loop indices
+      INTEGER ::   jk    ! dummy loop indices
       INTEGER ::   iter
       CHARACTER(len=25) ::   znam
@@ -118,4 +115,5 @@
       CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) )      ! time-step 
       CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter   , wp ) )      ! date
+      CALL iom_delay_rst( 'WRITE', 'ICE', numriw )   ! save only ice delayed global communication variables
 
       ! Prognostic variables
@@ -169,8 +167,7 @@
       !! ** purpose  :   read restart file
       !!----------------------------------------------------------------------
-      INTEGER           ::   jk, jl
+      INTEGER           ::   jk
       LOGICAL           ::   llok
       INTEGER           ::   id1            ! local integer
-      INTEGER           ::   jlibalt = jprstlib
       CHARACTER(len=25) ::   znam
       CHARACTER(len=2)  ::   zchar, zchar1
@@ -185,5 +182,5 @@
       ENDIF
 
-      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kiolib = jprstlib, kdlev = jpl )
+      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kdlev = jpl )
 
       CALL iom_get( numrir, 'nn_fsbc', zfice )
@@ -236,4 +233,7 @@
       CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice )
       CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice )
+
+      CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
+
       ! fields needed for Met Office (Jules) coupling
       IF( ln_cpl ) THEN
Index: /NEMO/trunk/src/ICE/icestp.F90
===================================================================
--- /NEMO/trunk/src/ICE/icestp.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icestp.F90	(revision 10425)
@@ -241,5 +241,5 @@
       ierr = ierr + ice1D_alloc      ()      ! thermodynamics
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'icestp', ierr )
       IF( ierr /= 0 )   CALL ctl_stop('STOP', 'ice_init : unable to allocate ice arrays')
       !
Index: /NEMO/trunk/src/ICE/icethd.F90
===================================================================
--- /NEMO/trunk/src/ICE/icethd.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icethd.F90	(revision 10425)
@@ -126,5 +126,5 @@
          END DO
       ENDIF
-      CALL lbc_lnk( zfric, 'T',  1. )
+      CALL lbc_lnk( 'icethd', zfric, 'T',  1. )
       !
       !--------------------------------------------------------------------!
@@ -212,6 +212,4 @@
          END DO
 
-         IF( lk_mpp )         CALL mpp_ini_ice( npti , numout )
-
          IF( npti > 0 ) THEN  ! If there is no ice, do nothing.
             !                                                                
@@ -250,5 +248,4 @@
             !                                                       ! --- & Move to 2D arrays --- !
             !
-            IF( lk_mpp )      CALL mpp_comm_free( ncomm_ice ) !RB necessary ??
          ENDIF
          !
Index: /NEMO/trunk/src/ICE/icethd_do.F90
===================================================================
--- /NEMO/trunk/src/ICE/icethd_do.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icethd_do.F90	(revision 10425)
@@ -189,5 +189,5 @@
          END DO 
          ! 
-         CALL lbc_lnk_multi( zvrel, 'T', 1., ht_i_new, 'T', 1.  )
+         CALL lbc_lnk_multi( 'icethd_do', zvrel, 'T', 1., ht_i_new, 'T', 1.  )
 
       ENDIF
Index: /NEMO/trunk/src/ICE/icethd_zdf_bl99.F90
===================================================================
--- /NEMO/trunk/src/ICE/icethd_zdf_bl99.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icethd_zdf_bl99.F90	(revision 10425)
@@ -83,5 +83,7 @@
       INTEGER, DIMENSION(jpij) ::   jm_min    ! reference number of top equation
       INTEGER, DIMENSION(jpij) ::   jm_max    ! reference number of bottom equation
-      !
+
+      LOGICAL, DIMENSION(jpij) ::   l_T_converged   ! true when T converges (per grid point)
+!
       REAL(wp) ::   zg1s      =  2._wp        ! for the tridiagonal system
       REAL(wp) ::   zg1       =  2._wp        !
@@ -113,4 +115,5 @@
       REAL(wp), DIMENSION(jpij,nlay_s)     ::   ztsb        ! Temporary temperature in the snow to check the convergence
       REAL(wp), DIMENSION(jpij,0:nlay_i)   ::   ztcond_i    ! Ice thermal conductivity
+      REAL(wp), DIMENSION(jpij,0:nlay_i)   ::   ztcond_i_cp ! copy
       REAL(wp), DIMENSION(jpij,0:nlay_i)   ::   zradtr_i    ! Radiation transmitted through the ice
       REAL(wp), DIMENSION(jpij,0:nlay_i)   ::   zradab_i    ! Radiation absorbed in the ice
@@ -201,8 +204,12 @@
       !
       iconv    = 0          ! number of iterations
-      zdti_max = 1000._wp   ! maximal value of error on all points
-      !
+      !
+      l_T_converged(:) = .FALSE.
       !                                                          !============================!
-      DO WHILE ( zdti_max > zdti_bnd .AND. iconv < iconv_max )   ! Iterative procedure begins !
+      ! Convergence calculated until all sub-domain grid points have converged
+      ! Calculations keep going for all grid points until sub-domain convergence (vectorisation optimisation)
+      ! but values are not taken into account (results independant of MPI partitioning)
+      !
+      DO WHILE ( ( .NOT. ALL (l_T_converged(1:npti)) ) .AND. iconv < iconv_max )   ! Iterative procedure begins !
          !                                                       !============================!
          iconv = iconv + 1
@@ -217,11 +224,11 @@
             !
             DO ji = 1, npti
-               ztcond_i(ji,0)      = rcnd_i + zbeta * sz_i_1d(ji,1)      / MIN( -epsi10, t_i_1d(ji,1) - rt0 )
-               ztcond_i(ji,nlay_i) = rcnd_i + zbeta * sz_i_1d(ji,nlay_i) / MIN( -epsi10, t_bo_1d(ji)  - rt0 )
+               ztcond_i_cp(ji,0)      = rcnd_i + zbeta * sz_i_1d(ji,1)      / MIN( -epsi10, t_i_1d(ji,1) - rt0 )
+               ztcond_i_cp(ji,nlay_i) = rcnd_i + zbeta * sz_i_1d(ji,nlay_i) / MIN( -epsi10, t_bo_1d(ji)  - rt0 )
             END DO
             DO jk = 1, nlay_i-1
                DO ji = 1, npti
-                  ztcond_i(ji,jk) = rcnd_i + zbeta * 0.5_wp * ( sz_i_1d(ji,jk) + sz_i_1d(ji,jk+1) ) /  &
-                     &                       MIN( -epsi10, 0.5_wp * (t_i_1d(ji,jk) + t_i_1d(ji,jk+1)) - rt0 )
+                  ztcond_i_cp(ji,jk) = rcnd_i + zbeta * 0.5_wp * ( sz_i_1d(ji,jk) + sz_i_1d(ji,jk+1) ) /  &
+                     &                         MIN( -epsi10, 0.5_wp * (t_i_1d(ji,jk) + t_i_1d(ji,jk+1)) - rt0 )
                END DO
             END DO
@@ -230,19 +237,25 @@
             !
             DO ji = 1, npti
-               ztcond_i(ji,0)      = rcnd_i + 0.09_wp  *  sz_i_1d(ji,1)      / MIN( -epsi10, t_i_1d(ji,1) - rt0 )  &
-                  &                         - 0.011_wp * ( t_i_1d(ji,1) - rt0 )
-               ztcond_i(ji,nlay_i) = rcnd_i + 0.09_wp  *  sz_i_1d(ji,nlay_i) / MIN( -epsi10, t_bo_1d(ji)  - rt0 )  &
-                  &                         - 0.011_wp * ( t_bo_1d(ji) - rt0 )
+               ztcond_i_cp(ji,0)      = rcnd_i + 0.09_wp  *  sz_i_1d(ji,1)      / MIN( -epsi10, t_i_1d(ji,1) - rt0 )  &
+                  &                           - 0.011_wp * ( t_i_1d(ji,1) - rt0 )
+               ztcond_i_cp(ji,nlay_i) = rcnd_i + 0.09_wp  *  sz_i_1d(ji,nlay_i) / MIN( -epsi10, t_bo_1d(ji)  - rt0 )  &
+                  &                           - 0.011_wp * ( t_bo_1d(ji) - rt0 )
             END DO
             DO jk = 1, nlay_i-1
                DO ji = 1, npti
-                  ztcond_i(ji,jk) = rcnd_i + 0.09_wp  *   0.5_wp * ( sz_i_1d(ji,jk) + sz_i_1d(ji,jk+1) ) /        &
-                     &                      MIN( -epsi10, 0.5_wp * ( t_i_1d (ji,jk) + t_i_1d (ji,jk+1) ) - rt0 )  &
-                     &                     - 0.011_wp * ( 0.5_wp * ( t_i_1d (ji,jk) + t_i_1d (ji,jk+1) ) - rt0 )
+                  ztcond_i_cp(ji,jk) = rcnd_i + 0.09_wp  *   0.5_wp * ( sz_i_1d(ji,jk) + sz_i_1d(ji,jk+1) ) /        &
+                     &                        MIN( -epsi10, 0.5_wp * ( t_i_1d (ji,jk) + t_i_1d (ji,jk+1) ) - rt0 )  &
+                     &                       - 0.011_wp * ( 0.5_wp * ( t_i_1d (ji,jk) + t_i_1d (ji,jk+1) ) - rt0 )
                END DO
             END DO
             !
          ENDIF
-         ztcond_i(1:npti,:) = MAX( zkimin, ztcond_i(1:npti,:) )        
+
+         ! Variable used after iterations
+         ! Value must be frozen after convergence for MPP independance reason
+         DO ji = 1, npti
+            IF ( .NOT. l_T_converged(ji) ) &
+               ztcond_i(ji,:) = MAX( zkimin, ztcond_i_cp(ji,:) )        
+         END DO
          !
          !--- G(he) : enhancement of thermal conductivity in mono-category case
@@ -270,26 +283,35 @@
          !-----------------
          !--- Snow
+         ! Variable used after iterations
+         ! Value must be frozen after convergence for MPP independance reason
          DO jk = 0, nlay_s-1
             DO ji = 1, npti
-               zkappa_s(ji,jk) = zghe(ji) * rn_cnd_s * z1_h_s(ji)
+               IF ( .NOT. l_T_converged(ji) ) &
+                  zkappa_s(ji,jk) = zghe(ji) * rn_cnd_s * z1_h_s(ji)
             END DO
          END DO
          DO ji = 1, npti   ! Snow-ice interface
-            zfac = 0.5_wp * ( ztcond_i(ji,0) * zh_s(ji) + rn_cnd_s * zh_i(ji) )
-            IF( zfac > epsi10 ) THEN
-               zkappa_s(ji,nlay_s) = zghe(ji) * rn_cnd_s * ztcond_i(ji,0) / zfac
-            ELSE
-               zkappa_s(ji,nlay_s) = 0._wp
+            IF ( .NOT. l_T_converged(ji) ) THEN
+               zfac = 0.5_wp * ( ztcond_i(ji,0) * zh_s(ji) + rn_cnd_s * zh_i(ji) )
+               IF( zfac > epsi10 ) THEN
+                  zkappa_s(ji,nlay_s) = zghe(ji) * rn_cnd_s * ztcond_i(ji,0) / zfac
+               ELSE
+                  zkappa_s(ji,nlay_s) = 0._wp
+               ENDIF
             ENDIF
          END DO
 
          !--- Ice
+         ! Variable used after iterations
+         ! Value must be frozen after convergence for MPP independance reason
          DO jk = 0, nlay_i
             DO ji = 1, npti
-               zkappa_i(ji,jk) = zghe(ji) * ztcond_i(ji,jk) * z1_h_i(ji)
+               IF ( .NOT. l_T_converged(ji) ) &
+                  zkappa_i(ji,jk) = zghe(ji) * ztcond_i(ji,jk) * z1_h_i(ji)
             END DO
          END DO
          DO ji = 1, npti   ! Snow-ice interface
-            zkappa_i(ji,0) = zkappa_s(ji,nlay_s) * isnow(ji) + zkappa_i(ji,0) * ( 1._wp - isnow(ji) )
+            IF ( .NOT. l_T_converged(ji) ) &
+               zkappa_i(ji,0) = zkappa_s(ji,nlay_s) * isnow(ji) + zkappa_i(ji,0) * ( 1._wp - isnow(ji) )
          END DO
          !
@@ -326,5 +348,8 @@
             ! update of the non solar flux according to the update in T_su
             DO ji = 1, npti
-               qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( t_su_1d(ji) - ztsub(ji) )
+               ! Variable used after iterations
+               ! Value must be frozen after convergence for MPP independance reason
+               IF ( .NOT. l_T_converged(ji) ) &
+                  qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( t_su_1d(ji) - ztsub(ji) )
             END DO
 
@@ -496,5 +521,8 @@
             ! ice temperatures
             DO ji = 1, npti
-               t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
+               ! Variable used after iterations
+               ! Value must be frozen after convergence for MPP independance reason
+               IF ( .NOT. l_T_converged(ji) ) &
+                  t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
             END DO
 
@@ -502,18 +530,23 @@
                DO ji = 1, npti
                   jk = jm - nlay_s - 1
-                  t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
+                  IF ( .NOT. l_T_converged(ji) ) &
+                     t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
                END DO
             END DO
 
             DO ji = 1, npti
-               ! snow temperatures      
-               IF( h_s_1d(ji) > 0._wp ) THEN
-                  t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) ) / zdiagbis(ji,nlay_s+1)
-               ENDIF
-               ! surface temperature
-               ztsub(ji) = t_su_1d(ji)
-               IF( t_su_1d(ji) < rt0 ) THEN
-                  t_su_1d(ji) = ( zindtbis(ji,jm_min(ji)) - ztrid(ji,jm_min(ji),3) *  &
-                     &          ( isnow(ji) * t_s_1d(ji,1) + ( 1._wp - isnow(ji) ) * t_i_1d(ji,1) ) ) / zdiagbis(ji,jm_min(ji))
+               ! Variables used after iterations
+               ! Value must be frozen after convergence for MPP independance reason
+               IF ( .NOT. l_T_converged(ji) ) THEN
+                  ! snow temperatures      
+                  IF( h_s_1d(ji) > 0._wp ) THEN
+                     t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) ) / zdiagbis(ji,nlay_s+1)
+                  ENDIF
+                  ! surface temperature
+                  ztsub(ji) = t_su_1d(ji)
+                  IF( t_su_1d(ji) < rt0 ) THEN
+                     t_su_1d(ji) = ( zindtbis(ji,jm_min(ji)) - ztrid(ji,jm_min(ji),3) *  &
+                        &          ( isnow(ji) * t_s_1d(ji,1) + ( 1._wp - isnow(ji) ) * t_i_1d(ji,1) ) ) / zdiagbis(ji,jm_min(ji))
+                  ENDIF
                ENDIF
             END DO
@@ -524,29 +557,28 @@
             ! check that nowhere it has started to melt
             ! zdti_max is a measure of error, it has to be under zdti_bnd
-            zdti_max = 0._wp
-            DO ji = 1, npti
-               t_su_1d(ji) = MAX( MIN( t_su_1d(ji) , rt0 ) , rt0 - 100._wp )
-               zdti_max    = MAX( zdti_max, ABS( t_su_1d(ji) - ztsub(ji) ) )     
-            END DO
-
-            DO jk = 1, nlay_s
-               DO ji = 1, npti
-                  t_s_1d(ji,jk) = MAX( MIN( t_s_1d(ji,jk), rt0 ), rt0 - 100._wp )
-                  zdti_max      = MAX( zdti_max, ABS( t_s_1d(ji,jk) - ztsb(ji,jk) ) )
-               END DO
-            END DO
-
-            DO jk = 1, nlay_i
-               DO ji = 1, npti
-                  ztmelts       = -rTmlt * sz_i_1d(ji,jk) + rt0 
-                  t_i_1d(ji,jk) =  MAX( MIN( t_i_1d(ji,jk), ztmelts ), rt0 - 100._wp )
-                  zdti_max      =  MAX( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
-               END DO
-            END DO
-
-            ! Compute spatial maximum over all errors
-            ! note that this could be optimized substantially by iterating only the non-converging points
-            IF( lk_mpp ) CALL mpp_max( zdti_max, kcom=ncomm_ice )
-         !
+
+            DO ji = 1, npti
+
+               zdti_max = 0._wp
+
+               IF ( .NOT. l_T_converged(ji) ) THEN
+                  t_su_1d(ji) = MAX( MIN( t_su_1d(ji) , rt0 ) , rt0 - 100._wp )
+                  zdti_max    = MAX( zdti_max, ABS( t_su_1d(ji) - ztsub(ji) ) )
+
+                  t_s_1d(ji,1:nlay_s) = MAX( MIN( t_s_1d(ji,1:nlay_s), rt0 ), rt0 - 100._wp )
+                  zdti_max = MAX ( zdti_max , MAXVAL( ABS( t_s_1d(ji,1:nlay_s) - ztsb(ji,1:nlay_s) ) ) )
+
+                  DO jk = 1, nlay_i
+                     ztmelts       = -rTmlt * sz_i_1d(ji,jk) + rt0
+                     t_i_1d(ji,jk) =  MAX( MIN( t_i_1d(ji,jk), ztmelts ), rt0 - 100._wp )
+                     zdti_max      =  MAX( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
+                  END DO
+
+                  IF ( zdti_max < zdti_bnd ) l_T_converged(ji) = .TRUE.
+
+               ENDIF
+
+            END DO
+
          !----------------------------------------!
          !                                        !
@@ -670,12 +702,17 @@
             
             ! ice temperatures
-           DO ji = 1, npti
-               t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
+            DO ji = 1, npti
+               ! Variable used after iterations
+               ! Value must be frozen after convergence for MPP independance reason
+               IF ( .NOT. l_T_converged(ji) ) &
+                  t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
             END DO
 
             DO jm = nlay_i + nlay_s, nlay_s + 2, -1
                DO ji = 1, npti
-                  jk = jm - nlay_s - 1
-                  t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
+                  IF ( .NOT. l_T_converged(ji) ) THEN
+                     jk = jm - nlay_s - 1
+                     t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
+                  ENDIF
                END DO
             END DO
@@ -683,6 +720,10 @@
             ! snow temperatures      
             DO ji = 1, npti
-               IF( h_s_1d(ji) > 0._wp ) THEN
-                  t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) ) / zdiagbis(ji,nlay_s+1)
+               ! Variable used after iterations
+               ! Value must be frozen after convergence for MPP independance reason
+               IF ( .NOT. l_T_converged(ji) ) THEN
+                  IF( h_s_1d(ji) > 0._wp ) THEN
+                     t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) ) / zdiagbis(ji,nlay_s+1)
+                  ENDIF
                ENDIF
             END DO
@@ -693,24 +734,25 @@
             ! check that nowhere it has started to melt
             ! zdti_max is a measure of error, it has to be under zdti_bnd
-            zdti_max = 0._wp
-
-            DO jk = 1, nlay_s
-               DO ji = 1, npti
-                  t_s_1d(ji,jk) = MAX( MIN( t_s_1d(ji,jk), rt0 ), rt0 - 100._wp )
-                  zdti_max = MAX( zdti_max, ABS( t_s_1d(ji,jk) - ztsb(ji,jk) ) )
-               END DO
-            END DO
-            
-            DO jk = 1, nlay_i
-               DO ji = 1, npti
-                  ztmelts       = -rTmlt * sz_i_1d(ji,jk) + rt0 
-                  t_i_1d(ji,jk) =  MAX( MIN( t_i_1d(ji,jk), ztmelts ), rt0 - 100._wp )
-                  zdti_max      =  MAX( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
-               END DO
-            END DO
-
-            ! Compute spatial maximum over all errors
-            ! note that this could be optimized substantially by iterating only the non-converging points
-            IF( lk_mpp )   CALL mpp_max( zdti_max, kcom=ncomm_ice )
+
+            DO ji = 1, npti
+
+               zdti_max = 0._wp
+
+               IF ( .NOT. l_T_converged(ji) ) THEN
+                  ! t_s
+                  t_s_1d(ji,1:nlay_s) = MAX( MIN( t_s_1d(ji,1:nlay_s), rt0 ), rt0 - 100._wp )
+                  zdti_max = MAX ( zdti_max , MAXVAL( ABS( t_s_1d(ji,1:nlay_s) - ztsb(ji,1:nlay_s) ) ) )
+                  ! t_i
+                  DO jk = 0, nlay_i
+                     ztmelts       = -rTmlt * sz_i_1d(ji,jk) + rt0 
+                     t_i_1d(ji,jk) =  MAX( MIN( t_i_1d(ji,jk), ztmelts ), rt0 - 100._wp )
+                     zdti_max      =  MAX ( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
+                  END DO
+
+                  IF ( zdti_max < zdti_bnd ) l_T_converged(ji) = .TRUE.
+
+               ENDIF
+
+            END DO
 
          ENDIF ! k_jules
Index: /NEMO/trunk/src/ICE/iceupdate.F90
===================================================================
--- /NEMO/trunk/src/ICE/iceupdate.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/iceupdate.F90	(revision 10425)
@@ -59,6 +59,6 @@
       ALLOCATE( utau_oce(jpi,jpj), vtau_oce(jpi,jpj), tmod_io(jpi,jpj), STAT=ice_update_alloc )
       !
-      IF( lk_mpp                )   CALL mpp_sum( ice_update_alloc )
-      IF( ice_update_alloc /= 0 )   CALL ctl_warn('ice_update_alloc: failed to allocate arrays')
+      CALL mpp_sum( 'iceupdate', ice_update_alloc )
+      IF( ice_update_alloc /= 0 )   CALL ctl_stop( 'STOP', 'ice_update_alloc: failed to allocate arrays' )
       !
    END FUNCTION ice_update_alloc
@@ -350,5 +350,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( taum, 'T', 1., tmod_io, 'T', 1. )
+         CALL lbc_lnk_multi( 'iceupdate', taum, 'T', 1., tmod_io, 'T', 1. )
          !
          utau_oce(:,:) = utau(:,:)                    !* save the air-ocean stresses at ice time-step
@@ -374,5 +374,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( utau, 'U', -1., vtau, 'V', -1. )   ! lateral boundary condition
+      CALL lbc_lnk_multi( 'iceupdate', utau, 'U', -1., vtau, 'V', -1. )   ! lateral boundary condition
       !
       IF( ln_timing )   CALL timing_stop('ice_update_tau')
Index: /NEMO/trunk/src/ICE/icewri.F90
===================================================================
--- /NEMO/trunk/src/ICE/icewri.F90	(revision 10424)
+++ /NEMO/trunk/src/ICE/icewri.F90	(revision 10425)
@@ -141,5 +141,5 @@
            END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL lbc_lnk( 'icewri', z2d, 'T', 1. )
          IF( iom_use('icevel') )   CALL iom_put( "icevel" , z2d )
 
@@ -191,11 +191,11 @@
          ELSEWHERE               ;   zmsk00(:,:) = 0.
          END WHERE 
-         zdiag_area_nh = glob_sum( at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
-         zdiag_volu_nh = glob_sum( vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
+         zdiag_area_nh = glob_sum( 'icewri', at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
+         zdiag_volu_nh = glob_sum( 'icewri', vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
          !
          WHERE( ff_t > 0._wp .AND. at_i > 0.15 )   ; zmsk00(:,:) = 1.0e-12
          ELSEWHERE                                 ; zmsk00(:,:) = 0.
          END WHERE 
-         zdiag_extt_nh = glob_sum( zmsk00(:,:) * e1e2t(:,:) )
+         zdiag_extt_nh = glob_sum( 'icewri', zmsk00(:,:) * e1e2t(:,:) )
          !
          IF( iom_use('NH_icearea') )   CALL iom_put( "NH_icearea" ,  zdiag_area_nh )
@@ -210,11 +210,11 @@
          ELSEWHERE            ; zmsk00(:,:) = 0.
          END WHERE 
-         zdiag_area_sh = glob_sum( at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) ) 
-         zdiag_volu_sh = glob_sum( vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
+         zdiag_area_sh = glob_sum( 'icewri', at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) ) 
+         zdiag_volu_sh = glob_sum( 'icewri', vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
          !
          WHERE( ff_t < 0._wp .AND. at_i > 0.15 ); zmsk00(:,:) = 1.0e-12
          ELSEWHERE                              ; zmsk00(:,:) = 0.
          END WHERE 
-         zdiag_extt_sh = glob_sum( zmsk00(:,:) * e1e2t(:,:) )
+         zdiag_extt_sh = glob_sum( 'icewri', zmsk00(:,:) * e1e2t(:,:) )
          !
          IF( iom_use('SH_icearea') ) CALL iom_put( "SH_icearea", zdiag_area_sh )
@@ -234,5 +234,5 @@
 
  
-   SUBROUTINE ice_wri_state( kt, kid, kh_i )
+   SUBROUTINE ice_wri_state( kid )
       !!---------------------------------------------------------------------
       !!                 ***  ROUTINE ice_wri_state  ***
@@ -245,63 +245,29 @@
       !! History :   4.0  !  2013-06  (C. Rousset)
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt               ! ocean time-step index
-      INTEGER, INTENT( in ) ::   kid , kh_i
-      INTEGER               ::   nz_i, jl
-      REAL(wp), DIMENSION(jpl) ::   jcat
+      INTEGER, INTENT( in ) ::   kid 
       !!----------------------------------------------------------------------
       !
-      DO jl = 1, jpl
-         jcat(jl) = REAL(jl)
-      END DO
-      
-      CALL histvert( kid, "ncatice", "Ice Categories","", jpl, jcat, nz_i, "up")
-
-      CALL histdef( kid, "sithic", "Ice thickness"          , "m"      , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "siconc", "Ice concentration"      , "%"      , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "sitemp", "Ice temperature"        , "C"      , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "sivelu", "i-Ice speed "           , "m/s"    , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "sivelv", "j-Ice speed "           , "m/s"    , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sistru", "i-Wind stress over ice" , "Pa"     , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "sistrv", "j-Wind stress over ice" , "Pa"     , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sisflx", "Solar flx over ocean"   , "W/m2"   , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sinflx", "NonSolar flx over ocean", "W/m2"   , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "snwpre", "Snow precipitation"     , "kg/m2/s", jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sisali", "Ice salinity"           , "PSU"    , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sivolu", "Ice volume"             , "m"      , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "sidive", "Ice divergence"         , "10-8s-1", jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "si_amp", "Melt pond fraction"     , "%"      , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "si_vmp", "Melt pond volume"       ,  "m"     , jpi,jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      !
-      CALL histdef( kid, "sithicat", "Ice thickness"        , "m"      , jpi,jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "siconcat", "Ice concentration"    , "%"      , jpi,jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "sisalcat", "Ice salinity"         , ""       , jpi,jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "snthicat", "Snw thickness"        , "m"      , jpi,jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
-
-      CALL histend( kid, snc4set )   ! end of the file definition
-
-      CALL histwrite( kid, "sithic", kt, hm_i          , jpi*jpj, (/1/) )    
-      CALL histwrite( kid, "siconc", kt, at_i          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sitemp", kt, tm_i - rt0    , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sivelu", kt, u_ice         , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sivelv", kt, v_ice         , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sistru", kt, utau_ice      , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sistrv", kt, vtau_ice      , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sisflx", kt, qsr           , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sinflx", kt, qns           , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "snwpre", kt, sprecip       , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sisali", kt, sm_i          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sivolu", kt, vt_i          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "sidive", kt, divu_i*1.0e8  , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "si_amp", kt, at_ip         , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "si_vmp", kt, vt_ip         , jpi*jpj, (/1/) )
-      !
-      CALL histwrite( kid, "sithicat", kt, h_i         , jpi*jpj*jpl, (/1/) )    
-      CALL histwrite( kid, "siconcat", kt, a_i         , jpi*jpj*jpl, (/1/) )    
-      CALL histwrite( kid, "sisalcat", kt, s_i         , jpi*jpj*jpl, (/1/) )    
-      CALL histwrite( kid, "snthicat", kt, h_s         , jpi*jpj*jpl, (/1/) )    
-
-      !! The file is closed in dia_wri_state (ocean routine)
-      !! CALL histclo( kid )
-      !
+      !! The file is open in dia_wri_state (ocean routine)
+
+      CALL iom_rstput( 0, 0, kid, 'sithic', hm_i         )   ! Ice thickness
+      CALL iom_rstput( 0, 0, kid, 'siconc', at_i         )   ! Ice concentration
+      CALL iom_rstput( 0, 0, kid, 'sitemp', tm_i - rt0   )   ! Ice temperature
+      CALL iom_rstput( 0, 0, kid, 'sivelu', u_ice        )   ! i-Ice speed
+      CALL iom_rstput( 0, 0, kid, 'sivelv', v_ice        )   ! j-Ice speed
+      CALL iom_rstput( 0, 0, kid, 'sistru', utau_ice     )   ! i-Wind stress over ice
+      CALL iom_rstput( 0, 0, kid, 'sistrv', vtau_ice     )   ! i-Wind stress over ice
+      CALL iom_rstput( 0, 0, kid, 'sisflx', qsr          )   ! Solar flx over ocean
+      CALL iom_rstput( 0, 0, kid, 'sinflx', qns          )   ! NonSolar flx over ocean
+      CALL iom_rstput( 0, 0, kid, 'snwpre', sprecip      )   ! Snow precipitation
+      CALL iom_rstput( 0, 0, kid, 'sisali', sm_i         )   ! Ice salinity
+      CALL iom_rstput( 0, 0, kid, 'sivolu', vt_i         )   ! Ice volume
+      CALL iom_rstput( 0, 0, kid, 'sidive', divu_i*1.0e8 )   ! Ice divergence
+      CALL iom_rstput( 0, 0, kid, 'si_amp', at_ip        )   ! Melt pond fraction
+      CALL iom_rstput( 0, 0, kid, 'si_vmp', vt_ip        )   ! Melt pond volume
+      CALL iom_rstput( 0, 0, kid, 'sithicat', h_i        )   ! Ice thickness
+      CALL iom_rstput( 0, 0, kid, 'siconcat', a_i        )   ! Ice concentration
+      CALL iom_rstput( 0, 0, kid, 'sisalcat', s_i        )   ! Ice salinity
+      CALL iom_rstput( 0, 0, kid, 'snthicat', h_s        )   ! Snw thickness
+
     END SUBROUTINE ice_wri_state
 
Index: /NEMO/trunk/src/NST/agrif_oce.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/NST/agrif_oce.F90	(revision 10425)
@@ -22,5 +22,5 @@
    !                                              !!* Namelist namagrif: AGRIF parameters
    LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !:
-   INTEGER , PUBLIC, PARAMETER ::   nn_sponge_len = 1  !: Sponge width (in number of parent grid points)
+   INTEGER , PUBLIC, PARAMETER ::   nn_sponge_len = 2  !: Sponge width (in number of parent grid points)
    REAL(wp), PUBLIC ::   rn_sponge_tra = 2800.     !: sponge coeff. for tracers
    REAL(wp), PUBLIC ::   rn_sponge_dyn = 2800.     !: sponge coeff. for dynamics
Index: /NEMO/trunk/src/NST/agrif_oce_sponge.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_oce_sponge.F90	(revision 10424)
+++ /NEMO/trunk/src/NST/agrif_oce_sponge.F90	(revision 10425)
@@ -164,6 +164,6 @@
             END DO
          END DO
-         CALL lbc_lnk( fsaht_spu, 'U', 1. )   ! Lateral boundary conditions
-         CALL lbc_lnk( fsaht_spv, 'V', 1. )
+         CALL lbc_lnk( 'agrif_oce_sponge', fsaht_spu, 'U', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( 'agrif_oce_sponge', fsaht_spv, 'V', 1. )
          
          spongedoneT = .TRUE.
@@ -181,6 +181,6 @@
             END DO
          END DO
-         CALL lbc_lnk( fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
-         CALL lbc_lnk( fsahm_spf, 'F', 1. )
+         CALL lbc_lnk( 'agrif_oce_sponge', fsahm_spt, 'T', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( 'agrif_oce_sponge', fsahm_spf, 'F', 1. )
          
          spongedoneU = .TRUE.
Index: /NEMO/trunk/src/NST/agrif_user.F90
===================================================================
--- /NEMO/trunk/src/NST/agrif_user.F90	(revision 10424)
+++ /NEMO/trunk/src/NST/agrif_user.F90	(revision 10425)
@@ -280,5 +280,5 @@
          CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
          !
-         IF (lk_mpp) CALL mpp_sum( kindic_agr )
+         CALL mpp_sum( 'agrif_user', kindic_agr )
          IF( kindic_agr /= 0 ) THEN
             CALL ctl_stop('Child Bathymetry is not correct near boundaries.')
Index: /NEMO/trunk/src/OCE/ASM/asmbkg.F90
===================================================================
--- /NEMO/trunk/src/OCE/ASM/asmbkg.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ASM/asmbkg.F90	(revision 10425)
@@ -85,5 +85,5 @@
             !
             !                                      ! Define the output file        
-            CALL iom_open( c_asmbkg, inum, ldwrt = .TRUE., kiolib = jprstlib)
+            CALL iom_open( c_asmbkg, inum, ldwrt = .TRUE. )
             !
             IF( nitbkg_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
@@ -123,5 +123,5 @@
             !
             !                                      ! Define the output file        
-            CALL iom_open( c_asmdin, inum, ldwrt = .TRUE., kiolib = jprstlib)
+            CALL iom_open( c_asmdin, inum, ldwrt = .TRUE. )
             !
             IF( nitdin_r == nit000 - 1 ) THEN      ! Treat special case when nitbkg = 0
Index: /NEMO/trunk/src/OCE/ASM/asminc.F90
===================================================================
--- /NEMO/trunk/src/OCE/ASM/asminc.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ASM/asminc.F90	(revision 10425)
@@ -421,5 +421,5 @@
                   END DO
                END DO
-               CALL lbc_lnk( zhdiv, 'T', 1. )   ! lateral boundary cond. (no sign change)
+               CALL lbc_lnk( 'asminc', zhdiv, 'T', 1. )   ! lateral boundary cond. (no sign change)
                !
                DO jj = 2, jpjm1
Index: /NEMO/trunk/src/OCE/BDY/bdy_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdy_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdy_oce.F90	(revision 10425)
@@ -12,5 +12,4 @@
    !!----------------------------------------------------------------------
    USE par_oce         ! ocean parameters
-   USE lib_mpp         ! distributed memory computing
 
    IMPLICIT NONE
@@ -148,5 +147,5 @@
    FUNCTION bdy_oce_alloc()
       !!----------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn, mpp_sum
+      USE lib_mpp, ONLY: ctl_stop, mpp_sum
       !
       INTEGER :: bdy_oce_alloc
@@ -161,6 +160,6 @@
       bdyvmask(:,:) = 1._wp
       ! 
-      IF( lk_mpp             )   CALL mpp_sum ( bdy_oce_alloc )
-      IF( bdy_oce_alloc /= 0 )   CALL ctl_warn('bdy_oce_alloc: failed to allocate arrays.')
+      CALL mpp_sum ( 'bdy_oce', bdy_oce_alloc )
+      IF( bdy_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'bdy_oce_alloc: failed to allocate arrays.' )
       !
    END FUNCTION bdy_oce_alloc
Index: /NEMO/trunk/src/OCE/BDY/bdydyn2d.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdydyn2d.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdydyn2d.F90	(revision 10425)
@@ -109,6 +109,6 @@
          pva2d(ii,ij) = ( pva2d(ii,ij) + zwgt * ( dta%v2d(jb) - pva2d(ii,ij) ) ) * vmask(ii,ij,1)
       END DO 
-      CALL lbc_bdy_lnk( pua2d, 'U', -1., ib_bdy ) 
-      CALL lbc_bdy_lnk( pva2d, 'V', -1., ib_bdy)   ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy ) 
+      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy)   ! Boundary points should be updated
       !
    END SUBROUTINE bdy_dyn2d_frs
@@ -169,5 +169,5 @@
       END DO
 
-      CALL lbc_bdy_lnk( spgu(:,:), 'T', 1., ib_bdy )
+      CALL lbc_bdy_lnk( 'bdydyn2d', spgu(:,:), 'T', 1., ib_bdy )
       !
       igrd = 2      ! Flather bc on u-velocity; 
@@ -207,6 +207,6 @@
          pva2d(ii,ij) = zforc + (1._wp - z1_2*zflag) * zcorr * vmask(ii,ij,1)
       END DO
-      CALL lbc_bdy_lnk( pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
-      CALL lbc_bdy_lnk( pva2d, 'V', -1., ib_bdy )   !
+      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy )   !
       !
    END SUBROUTINE bdy_dyn2d_fla
@@ -243,6 +243,6 @@
       CALL bdy_orlanski_2d( idx, igrd, pvb2d, pva2d, dta%v2d, ll_npo )
       !
-      CALL lbc_bdy_lnk( pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
-      CALL lbc_bdy_lnk( pva2d, 'V', -1., ib_bdy )   !
+      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy )   !
       !
    END SUBROUTINE bdy_dyn2d_orlanski
@@ -291,5 +291,5 @@
 
          ! Boundary points should be updated
-         CALL lbc_bdy_lnk( zssh(:,:), 'T', 1., ib_bdy )
+         CALL lbc_bdy_lnk( 'bdydyn2d', zssh(:,:), 'T', 1., ib_bdy )
       END DO
 
Index: /NEMO/trunk/src/OCE/BDY/bdydyn3d.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdydyn3d.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdydyn3d.F90	(revision 10425)
@@ -97,6 +97,6 @@
          END DO
       END DO
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
-      CALL lbc_bdy_lnk( va, 'V', -1., ib_bdy )   
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
+      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
       !
       IF( kt == nit000 )   CLOSE( unit = 102 )
@@ -144,6 +144,6 @@
          END DO
       END DO
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
-      CALL lbc_bdy_lnk( va, 'V', -1., ib_bdy )   
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
+      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
       !
       IF( kt == nit000 )   CLOSE( unit = 102 )
@@ -187,5 +187,5 @@
       END DO
       !
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )   ;   CALL lbc_bdy_lnk( va, 'V', -1.,ib_bdy )   ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ;   CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1.,ib_bdy )   ! Boundary points should be updated
       !
       IF( kt == nit000 )   CLOSE( unit = 102 )
@@ -234,6 +234,6 @@
          END DO
       END DO 
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( va, 'V', -1., ib_bdy )   
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
       !
       IF( kt == nit000 )   CLOSE( unit = 102 )
@@ -270,6 +270,6 @@
       CALL bdy_orlanski_3d( idx, igrd, vb, va, dta%v3d, ll_npo )
       !
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( va, 'V', -1., ib_bdy )   
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
       !
    END SUBROUTINE bdy_dyn3d_orlanski
@@ -319,5 +319,5 @@
       END DO
       !
-      CALL lbc_lnk_multi( ua, 'U', -1.,  va, 'V', -1. )   ! Boundary points should be updated
+      CALL lbc_lnk_multi( 'bdydyn3d', ua, 'U', -1.,  va, 'V', -1. )   ! Boundary points should be updated
       !
       IF( ln_timing )   CALL timing_stop('bdy_dyn3d_dmp')
@@ -351,6 +351,6 @@
       CALL bdy_nmn( idx, igrd, va )
       !
-      CALL lbc_bdy_lnk( ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( va, 'V', -1., ib_bdy )
+      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
+      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )
       !
    END SUBROUTINE bdy_dyn3d_nmn
Index: /NEMO/trunk/src/OCE/BDY/bdyice.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdyice.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdyice.F90	(revision 10425)
@@ -135,7 +135,7 @@
          ENDDO
       ENDDO
-      CALL lbc_bdy_lnk( a_i(:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( h_i(:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( h_s(:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', a_i(:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', h_i(:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', h_s(:,:,:), 'T', 1., jbdy )
 
       DO jl = 1, jpl
@@ -244,19 +244,19 @@
       END DO ! jl
 
-      CALL lbc_bdy_lnk( a_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( h_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( h_s (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( oa_i(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( a_ip(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( v_ip(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( s_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( t_su(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( v_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( v_s (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( sv_i(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( t_s (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( e_s (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( t_i (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( e_i (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', a_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', h_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', h_s (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', oa_i(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', a_ip(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', v_ip(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', s_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', t_su(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', v_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', v_s (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', sv_i(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', t_s (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', e_s (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', t_i (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( 'bdyice', e_i (:,:,:,:), 'T', 1., jbdy )
       !      
    END SUBROUTINE bdy_ice_frs
@@ -317,5 +317,5 @@
                   !
                END DO
-               CALL lbc_bdy_lnk( u_ice(:,:), 'U', -1., jbdy )
+               CALL lbc_bdy_lnk( 'bdyice', u_ice(:,:), 'U', -1., jbdy )
                !
             CASE ( 'V' )
@@ -340,5 +340,5 @@
                   !
                END DO
-               CALL lbc_bdy_lnk( v_ice(:,:), 'V', -1., jbdy )
+               CALL lbc_bdy_lnk( 'bdyice', v_ice(:,:), 'V', -1., jbdy )
                !
             END SELECT
Index: /NEMO/trunk/src/OCE/BDY/bdyini.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdyini.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdyini.F90	(revision 10425)
@@ -1133,5 +1133,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
+      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
 
       ! bdy masks are now set to zero on boundary points:
@@ -1169,6 +1169,6 @@
 
       ! Lateral boundary conditions
-      CALL lbc_lnk( zfmask, 'F', 1. ) 
-      CALL lbc_lnk_multi( bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
+      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. ) 
+      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
       DO ib_bdy = 1, nb_bdy       ! Indices and directions of rim velocity components
 
@@ -1203,10 +1203,8 @@
             END DO
             IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagu calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp2,*) ' ========== '
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ENDIF 
          END DO
@@ -1238,10 +1236,8 @@
             END DO
             IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagv calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp2,*) ' ========== '
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ENDIF 
          END DO
@@ -1280,5 +1276,5 @@
          END DO
          !
-         IF( lk_mpp )   CALL mpp_sum( bdysurftot )      ! sum over the global domain
+         CALL mpp_sum( 'bdyini', bdysurftot )      ! sum over the global domain
       END IF   
       !
@@ -1376,19 +1372,15 @@
                      icorns(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpisft(ib2)==jpiwob(ib1)).AND.(jpjwft(ib1)==jpjsob(ib2))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisft(ib2), jpjwft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                        &                                     jpisft(ib2), jpjwft(ib1)
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
+                        &                                        ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop+1
+                     WRITE(ctmp1,*) ' E R R O R : Check South and West Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
+                        &                                         ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1412,19 +1404,15 @@
                      icorns(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjeft(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisdt(ib2), jpjeft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                        &                                     jpisdt(ib2), jpjeft(ib1)
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                        &                                        ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Check South and East Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1448,19 +1436,15 @@
                      icornn(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpjwdt(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpiwob(ib1))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpinft(ib2), jpjwdt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), &
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), &
                      &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
+                     WRITE(ctmp1,*) ' E R R O R : Check North and West Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
                      &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1484,19 +1468,15 @@
                      icornn(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjedt(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpindt(ib2), jpjedt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Check North and East Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1520,13 +1500,11 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF (ztestmask(1)==1) THEN 
             IF (icornw(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1538,9 +1516,7 @@
          IF (ztestmask(2)==1) THEN
             IF (icornw(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1564,13 +1540,11 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF (ztestmask(1)==1) THEN
             IF (icorne(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1 
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1582,9 +1556,7 @@
          IF (ztestmask(2)==1) THEN
             IF (icorne(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1608,19 +1580,15 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icorns(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
       END DO
@@ -1638,19 +1606,15 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            WRITE(ctmp2,*) ' ==========  does not start on land'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icornn(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            WRITE(ctmp2,*) ' ==========  does not end on land'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
       END DO
@@ -1691,8 +1655,7 @@
       !
       IF( itest>0 ) THEN
-         IF(lwp) WRITE(numout,*) ' E R R O R : Segments ', ib1, 'and ', ib2
-         IF(lwp) WRITE(numout,*) ' ==========  have different open bdy schemes'                                                  
-         IF(lwp) WRITE(numout,*)
-         nstop = nstop + 1
+         WRITE(ctmp1,*) ' E R R O R : Segments ', ib1, 'and ', ib2
+         WRITE(ctmp2,*) ' ==========  have different open bdy schemes'                                                  
+         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
       ENDIF
       !
Index: /NEMO/trunk/src/OCE/BDY/bdytra.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdytra.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdytra.F90	(revision 10425)
@@ -71,5 +71,5 @@
             END SELECT
             ! Boundary points should be updated
-            CALL lbc_bdy_lnk( tsa(:,:,:,jn), 'T', 1., ib_bdy )
+            CALL lbc_bdy_lnk( 'bdytra', tsa(:,:,:,jn), 'T', 1., ib_bdy )
             ! 
          END DO
Index: /NEMO/trunk/src/OCE/BDY/bdyvol.F90
===================================================================
--- /NEMO/trunk/src/OCE/BDY/bdyvol.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/BDY/bdyvol.F90	(revision 10425)
@@ -85,7 +85,7 @@
 !!gm replace these lines :
       z_cflxemp = SUM ( ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:) ) / rau0
-      IF( lk_mpp )   CALL mpp_sum( z_cflxemp )     ! sum over the global domain
+      CALL mpp_sum( 'bdyvol', z_cflxemp )     ! sum over the global domain
 !!gm   by :
-!!gm      z_cflxemp = glob_sum(  ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
+!!gm      z_cflxemp = glob_sum(  'bdyvol', ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
 !!gm
 
@@ -114,5 +114,5 @@
          !
       END DO
-      IF( lk_mpp )   CALL mpp_sum( zubtpecor )   ! sum over the global domain
+      CALL mpp_sum( 'bdyvol', zubtpecor )   ! sum over the global domain
 
       ! The normal velocity correction
@@ -148,5 +148,5 @@
          !
       END DO
-      IF( lk_mpp )   CALL mpp_sum( ztranst )   ! sum over the global domain
+      CALL mpp_sum( 'bdyvol', ztranst )   ! sum over the global domain
  
       ! Check the cumulated transport through unstructured OBC once barotropic velocities corrected
Index: /NEMO/trunk/src/OCE/C1D/dyndmp.F90
===================================================================
--- /NEMO/trunk/src/OCE/C1D/dyndmp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/C1D/dyndmp.F90	(revision 10425)
@@ -57,5 +57,5 @@
       ALLOCATE( utrdmp(jpi,jpj,jpk), vtrdmp(jpi,jpj,jpk), resto_uv(jpi,jpj,jpk), STAT= dyn_dmp_alloc )
       !
-      IF( lk_mpp            )   CALL mpp_sum ( dyn_dmp_alloc )
+      CALL mpp_sum ( 'dyndmp', dyn_dmp_alloc )
       IF( dyn_dmp_alloc > 0 )   CALL ctl_warn('dyn_dmp_alloc: allocation of arrays failed')
       !
Index: /NEMO/trunk/src/OCE/CRS/crsdomwri.F90
===================================================================
--- /NEMO/trunk/src/OCE/CRS/crsdomwri.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/CRS/crsdomwri.F90	(revision 10425)
@@ -69,5 +69,5 @@
       !                            ! ============================
       !
-      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
+      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE. )
  
       CALL iom_rstput( 0, 0, inum, 'tmask', tmask_crs, ktype = jp_i1 )    ! land-sea mask
Index: /NEMO/trunk/src/OCE/CRS/crsfld.F90
===================================================================
--- /NEMO/trunk/src/OCE/CRS/crsfld.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/CRS/crsfld.F90	(revision 10425)
@@ -164,5 +164,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'T', 1. )
+         CALL lbc_lnk( 'crsfld', z3d, 'T', 1. )
          !
          CALL crs_dom_ope( z3d, 'VOL', 'T', tmask, zt_crs, p_e12=e1e2t, p_e3=ze3t, psgn=1.0 )
Index: /NEMO/trunk/src/OCE/CRS/crslbclnk.F90
===================================================================
--- /NEMO/trunk/src/OCE/CRS/crslbclnk.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/CRS/crslbclnk.F90	(revision 10425)
@@ -55,6 +55,6 @@
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( pt3d1, cd_type1, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( pt3d1, cd_type1, psgn        , pval=zval  )
+      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, cd_mpp, pval=zval  )
+      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn        , pval=zval  )
       ENDIF
       !
@@ -92,6 +92,6 @@
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( pt2d, cd_type, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( pt2d, cd_type, psgn        , pval=zval  )
+      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, cd_mpp, pval=zval  )
+      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn        , pval=zval  )
       ENDIF
       !
Index: /NEMO/trunk/src/OCE/DIA/diaar5.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diaar5.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diaar5.F90	(revision 10425)
@@ -56,6 +56,6 @@
       ALLOCATE( area(jpi,jpj), thick0(jpi,jpj) , sn0(jpi,jpj,jpk) , STAT=dia_ar5_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( dia_ar5_alloc )
-      IF( dia_ar5_alloc /= 0 )   CALL ctl_warn('dia_ar5_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'diaar5', dia_ar5_alloc )
+      IF( dia_ar5_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dia_ar5_alloc: failed to allocate arrays' )
       !
    END FUNCTION dia_ar5_alloc
@@ -95,5 +95,5 @@
          !                                         ! total volume of liquid seawater
          zvolssh = SUM( zarea_ssh(:,:) ) 
-         IF( lk_mpp )   CALL mpp_sum( zvolssh )
+         CALL mpp_sum( 'diaar5', zvolssh )
          zvol = vol0 + zvolssh
       
@@ -130,5 +130,5 @@
          !                                         
          zarho = SUM( area(:,:) * zbotpres(:,:) ) 
-         IF( lk_mpp )   CALL mpp_sum( zarho )
+         CALL mpp_sum( 'diaar5', zarho )
          zssh_steric = - zarho / area_tot
          CALL iom_put( 'sshthster', zssh_steric )
@@ -156,5 +156,5 @@
          !    
          zarho = SUM( area(:,:) * zbotpres(:,:) ) 
-         IF( lk_mpp )   CALL mpp_sum( zarho )
+         CALL mpp_sum( 'diaar5', zarho )
          zssh_steric = - zarho / area_tot
          CALL iom_put( 'sshsteric', zssh_steric )
@@ -194,6 +194,6 @@
          ENDIF
          IF( lk_mpp ) THEN  
-            CALL mpp_sum( ztemp )
-            CALL mpp_sum( zsal  )
+            CALL mpp_sum( 'diaar5', ztemp )
+            CALL mpp_sum( 'diaar5', zsal  )
          END IF
          !
@@ -245,5 +245,5 @@
          ENDIF
 !!gm useless lbc_lnk since the computation above is performed over 1:jpi & 1:jpj
-!!gm           CALL lbc_lnk( zpe, 'T', 1._wp)         
+!!gm           CALL lbc_lnk( 'diaar5', zpe, 'T', 1._wp)         
           CALL iom_put( 'tnpeo', zpe )
           DEALLOCATE( zpe )
@@ -285,5 +285,5 @@
          END DO
        END DO
-       CALL lbc_lnk( z2d, 'U', -1. )
+       CALL lbc_lnk( 'diaar5', z2d, 'U', -1. )
        IF( cptr == 'adv' ) THEN
           IF( ktra == jp_tem ) CALL iom_put( "uadv_heattr" , rau0_rcp * z2d )  ! advective heat transport in i-direction
@@ -303,5 +303,5 @@
           END DO
        END DO
-       CALL lbc_lnk( z2d, 'V', -1. )
+       CALL lbc_lnk( 'diaar5', z2d, 'V', -1. )
        IF( cptr == 'adv' ) THEN
           IF( ktra == jp_tem ) CALL iom_put( "vadv_heattr" , rau0_rcp * z2d )  ! advective heat transport in j-direction
@@ -342,5 +342,5 @@
          area(:,:) = e1e2t(:,:) * tmask_i(:,:)
 
-         area_tot = SUM( area(:,:) )   ;   IF( lk_mpp )   CALL mpp_sum( area_tot )
+         area_tot = SUM( area(:,:) )   ;   CALL mpp_sum( 'diaar5', area_tot )
 
          vol0        = 0._wp
@@ -350,5 +350,5 @@
             thick0(:,:) = thick0(:,:) +    tmask_i(:,:) * tmask(:,:,jk) * e3t_0(:,:,jk)
          END DO
-         IF( lk_mpp )   CALL mpp_sum( vol0 )
+         CALL mpp_sum( 'diaar5', vol0 )
 
          IF( iom_use( 'sshthster' ) ) THEN
Index: /NEMO/trunk/src/OCE/DIA/diacfl.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diacfl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diacfl.F90	(revision 10425)
@@ -54,7 +54,7 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      INTEGER :: ji, jj, jk   ! dummy loop indices
-      REAL(wp)::   z2dt, zCu_max, zCv_max, zCw_max       ! local scalars
-      INTEGER , DIMENSION(3)           ::   iloc_u , iloc_v , iloc_w , iloc   ! workspace
+      INTEGER                ::   ji, jj, jk                            ! dummy loop indices
+      REAL(wp)               ::   z2dt, zCu_max, zCv_max, zCw_max       ! local scalars
+      INTEGER , DIMENSION(3) ::   iloc_u , iloc_v , iloc_w , iloc       ! workspace
 !!gm this does not work      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zCu_cfl, zCv_cfl, zCw_cfl         ! workspace
       !!----------------------------------------------------------------------
@@ -80,7 +80,7 @@
       !                    ! calculate maximum values and locations
       IF( lk_mpp ) THEN
-         CALL mpp_maxloc( zCu_cfl, umask, zCu_max, iloc_u(1), iloc_u(2), iloc_u(3) )
-         CALL mpp_maxloc( zCv_cfl, vmask, zCv_max, iloc_v(1), iloc_v(2), iloc_v(3) )
-         CALL mpp_maxloc( zCw_cfl, wmask, zCw_max, iloc_w(1), iloc_w(2), iloc_w(3) )
+         CALL mpp_maxloc( 'diacfl', zCu_cfl, umask, zCu_max, iloc_u )
+         CALL mpp_maxloc( 'diacfl', zCv_cfl, vmask, zCv_max, iloc_v )
+         CALL mpp_maxloc( 'diacfl', zCw_cfl, wmask, zCw_max, iloc_w )
       ELSE
          iloc = MAXLOC( ABS( zcu_cfl(:,:,:) ) )
Index: /NEMO/trunk/src/OCE/DIA/diadct.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diadct.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diadct.F90	(revision 10425)
@@ -115,5 +115,5 @@
 
      diadct_alloc = MAXVAL( ierr ) 
-     IF( diadct_alloc /= 0 )   CALL ctl_warn('diadct_alloc: failed to allocate arrays') 
+     IF( diadct_alloc /= 0 )   CALL ctl_stop( 'STOP', 'diadct_alloc: failed to allocate arrays' ) 
  
   END FUNCTION diadct_alloc 
@@ -258,5 +258,5 @@
               DO jsec=1,nb_sec ; zsum(jsec,:,:) = secs(jsec)%transport(:,:) ; ENDDO
               zwork(:)= RESHAPE(zsum(:,:,:), ish )
-              CALL mpp_sum(zwork, ish(1))
+              CALL mpp_sum('diadct', zwork, ish(1))
               zsum(:,:,:)= RESHAPE(zwork,ish2)
               DO jsec=1,nb_sec ; secs(jsec)%transport(:,:) = zsum(jsec,:,:) ; ENDDO
Index: /NEMO/trunk/src/OCE/DIA/diaharm.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diaharm.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diaharm.F90	(revision 10425)
@@ -22,4 +22,5 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE timing          ! preformance summary
+   USE lib_mpp           ! MPP library
 
    IMPLICIT NONE
@@ -126,7 +127,7 @@
       !
       IF (nb_ana > jpmax_harmo) THEN
-        IF(lwp) WRITE(numout,*) ' E R R O R dia_harm_init : nb_ana must be lower than jpmax_harmo, stop'
-        IF(lwp) WRITE(numout,*) ' jpmax_harmo= ', jpmax_harmo
-        nstop = nstop + 1
+         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//TRIM(clname)//', var:'//TRIM(cdvar)
+         WRITE(ctmp2,*) ' jpmax_harmo= ', jpmax_harmo
+         CALL ctl_stop( 'dia_harm_init', ctmp1, ctmp2 )
       ENDIF
 
Index: /NEMO/trunk/src/OCE/DIA/diahsb.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diahsb.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diahsb.F90	(revision 10425)
@@ -91,16 +91,16 @@
       ! 1 - Trends due to forcing !
       ! ------------------------- !
-      z_frc_trd_v = r1_rau0 * glob_sum( - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) )   ! volume fluxes
-      z_frc_trd_t =           glob_sum( sbc_tsc(:,:,jp_tem) * surf(:,:) )                       ! heat fluxes
-      z_frc_trd_s =           glob_sum( sbc_tsc(:,:,jp_sal) * surf(:,:) )                       ! salt fluxes
+      z_frc_trd_v = r1_rau0 * glob_sum( 'diahsb', - ( emp(:,:) - rnf(:,:) + fwfisf(:,:) ) * surf(:,:) )   ! volume fluxes
+      z_frc_trd_t =           glob_sum( 'diahsb', sbc_tsc(:,:,jp_tem) * surf(:,:) )                       ! heat fluxes
+      z_frc_trd_s =           glob_sum( 'diahsb', sbc_tsc(:,:,jp_sal) * surf(:,:) )                       ! salt fluxes
       !                    !  Add runoff    heat & salt input
-      IF( ln_rnf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( rnf_tsc(:,:,jp_tem) * surf(:,:) )
-      IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( rnf_tsc(:,:,jp_sal) * surf(:,:) )
+      IF( ln_rnf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( 'diahsb', rnf_tsc(:,:,jp_tem) * surf(:,:) )
+      IF( ln_rnf_sal)   z_frc_trd_s = z_frc_trd_s + glob_sum( 'diahsb', rnf_tsc(:,:,jp_sal) * surf(:,:) )
       !                    ! Add ice shelf heat & salt input
-      IF( ln_isf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( risf_tsc(:,:,jp_tem) * surf(:,:) )
+      IF( ln_isf    )   z_frc_trd_t = z_frc_trd_t + glob_sum( 'diahsb', risf_tsc(:,:,jp_tem) * surf(:,:) )
       !                    ! Add penetrative solar radiation
-      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( qsr     (:,:) * surf(:,:) )
+      IF( ln_traqsr )   z_frc_trd_t = z_frc_trd_t + r1_rau0_rcp * glob_sum( 'diahsb', qsr     (:,:) * surf(:,:) )
       !                    ! Add geothermal heat flux
-      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t +               glob_sum( qgh_trd0(:,:) * surf(:,:) )
+      IF( ln_trabbc )   z_frc_trd_t = z_frc_trd_t +               glob_sum( 'diahsb', qgh_trd0(:,:) * surf(:,:) )
       !
       IF( ln_linssh ) THEN
@@ -116,6 +116,6 @@
             z2d1(:,:) = surf(:,:) * wn(:,:,1) * tsb(:,:,1,jp_sal)
          END IF
-         z_wn_trd_t = - glob_sum( z2d0 ) 
-         z_wn_trd_s = - glob_sum( z2d1 )
+         z_wn_trd_t = - glob_sum( 'diahsb', z2d0 ) 
+         z_wn_trd_s = - glob_sum( 'diahsb', z2d1 )
       ENDIF
 
@@ -135,5 +135,5 @@
 
       !                    ! volume variation (calculated with ssh)
-      zdiff_v1 = glob_sum_full( surf(:,:)*sshn(:,:) - surf_ini(:,:)*ssh_ini(:,:) )
+      zdiff_v1 = glob_sum_full( 'diahsb', surf(:,:)*sshn(:,:) - surf_ini(:,:)*ssh_ini(:,:) )
 
       !                    ! heat & salt content variation (associated with ssh)
@@ -150,20 +150,20 @@
             z2d1(:,:) = surf(:,:) * ( tsn(:,:,1,jp_sal) * sshn(:,:) - ssh_sc_loc_ini(:,:) ) 
          END IF
-         z_ssh_hc = glob_sum_full( z2d0 ) 
-         z_ssh_sc = glob_sum_full( z2d1 ) 
-      ENDIF
-      !
-      DO jk = 1, jpkm1     ! volume variation (calculated with scale factors)
+         z_ssh_hc = glob_sum_full( 'diahsb', z2d0 ) 
+         z_ssh_sc = glob_sum_full( 'diahsb', z2d1 ) 
+      ENDIF
+      !
+      DO jk = 1, jpkm1           ! volume variation (calculated with scale factors)
          zwrk(:,:,jk) = ( surf(:,:)*e3t_n(:,:,jk) - surf_ini(:,:)*e3t_ini(:,:,jk) ) * tmask(:,:,jk)
       END DO
-      zdiff_v2 = glob_sum_full( zwrk(:,:,:) )
+      zdiff_v2 = glob_sum_full( 'diahsb', zwrk(:,:,:) )
       DO jk = 1, jpkm1           ! heat content variation
          zwrk(:,:,jk) = ( surf(:,:)*e3t_n(:,:,jk)*tsn(:,:,jk,jp_tem) - surf_ini(:,:)*hc_loc_ini(:,:,jk) ) * tmask(:,:,jk)
       END DO
-      zdiff_hc = glob_sum_full( zwrk(:,:,:) )
+      zdiff_hc = glob_sum_full( 'diahsb', zwrk(:,:,:) )
       DO jk = 1, jpkm1           ! salt content variation
          zwrk(:,:,jk) = ( surf(:,:)*e3t_n(:,:,jk)*tsn(:,:,jk,jp_sal) - surf_ini(:,:)*sc_loc_ini(:,:,jk) ) * tmask(:,:,jk)
       END DO
-      zdiff_sc = glob_sum_full( zwrk(:,:,:) )
+      zdiff_sc = glob_sum_full( 'diahsb', zwrk(:,:,:) )
 
       ! ------------------------ !
@@ -187,9 +187,9 @@
          zwrk(:,:,jk) = surf(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk)
       END DO
-      zvol_tot = glob_sum_full( zwrk(:,:,:) )
+      zvol_tot = glob_sum_full( 'diahsb', zwrk(:,:,:) )
 
 !!gm to be added ?
 !      IF( ln_linssh ) THEN            ! fixed volume, add the ssh contribution
-!        zvol_tot = zvol_tot + glob_sum( surf(:,:) * sshn(:,:) )
+!        zvol_tot = zvol_tot + glob_sum( 'diahsb', surf(:,:) * sshn(:,:) )
 !      ENDIF
 !!gm end
@@ -409,6 +409,6 @@
       ! 2 - Time independant variables and file opening !
       ! ----------------------------------------------- !
-      surf(:,:) = e1e2t(:,:) * tmask_i(:,:)     ! masked surface grid cell area
-      surf_tot  = glob_sum( surf(:,:) )         ! total ocean surface area
+      surf(:,:) = e1e2t(:,:) * tmask_i(:,:)               ! masked surface grid cell area
+      surf_tot  = glob_sum( 'diahsb', surf(:,:) )         ! total ocean surface area
 
       IF( ln_bdy ) CALL ctl_warn( 'dia_hsb_init: heat/salt budget does not consider open boundary fluxes' )         
Index: /NEMO/trunk/src/OCE/DIA/diahth.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diahth.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diahth.F90	(revision 10425)
@@ -54,6 +54,6 @@
       ALLOCATE( hth(jpi,jpj), hd20(jpi,jpj), hd28(jpi,jpj), htc3(jpi,jpj), STAT=dia_hth_alloc )
       !
-      IF( lk_mpp           )   CALL mpp_sum ( dia_hth_alloc )
-      IF(dia_hth_alloc /= 0)   CALL ctl_warn('dia_hth_alloc: failed to allocate arrays.')
+      CALL mpp_sum ( 'diahth', dia_hth_alloc )
+      IF(dia_hth_alloc /= 0)   CALL ctl_stop( 'STOP', 'dia_hth_alloc: failed to allocate arrays.' )
       !
    END FUNCTION dia_hth_alloc
@@ -123,5 +123,5 @@
                &      zthick(jpi,jpj),  &
                &      zdelr(jpi,jpj), STAT=ji)
-            IF( lk_mpp  )   CALL mpp_sum(ji)
+            CALL mpp_sum('diahth', ji)
             IF( ji /= 0 )   CALL ctl_stop( 'STOP', 'dia_hth : unable to allocate standard ocean arrays' )
          END IF
Index: /NEMO/trunk/src/OCE/DIA/diaptr.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diaptr.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diaptr.F90	(revision 10425)
@@ -549,5 +549,5 @@
          !
       dia_ptr_alloc = MAXVAL( ierr )
-      IF(lk_mpp)   CALL mpp_sum( dia_ptr_alloc )
+      CALL mpp_sum( 'diaptr', dia_ptr_alloc )
       !
    END FUNCTION dia_ptr_alloc
@@ -595,5 +595,5 @@
       ENDIF
 #if defined key_mpp_mpi
-      IF(lk_mpp)   CALL mpp_sum( p_fval, ijpj, ncomm_znl)
+      CALL mpp_sum( 'diaptr', p_fval, ijpj, ncomm_znl)
 #endif
       !
@@ -638,5 +638,5 @@
       ENDIF
 #if defined key_mpp_mpi
-      CALL mpp_sum( p_fval, ijpj, ncomm_znl )
+      CALL mpp_sum( 'diaptr', p_fval, ijpj, ncomm_znl )
 #endif
       ! 
@@ -696,5 +696,5 @@
       ish(1) = ijpjjpk  ;   ish2(1) = jpj   ;   ish2(2) = jpk
       zwork(1:ijpjjpk) = RESHAPE( p_fval, ish )
-      CALL mpp_sum( zwork, ijpjjpk, ncomm_znl )
+      CALL mpp_sum( 'diaptr', zwork, ijpjjpk, ncomm_znl )
       p_fval(:,:) = RESHAPE( zwork, ish2 )
 #endif
Index: /NEMO/trunk/src/OCE/DIA/diawri.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 10425)
@@ -52,4 +52,5 @@
 
 #if defined key_si3
+   USE ice 
    USE icewri 
 #endif
@@ -119,5 +120,5 @@
       ! Output the initial state and forcings
       IF( ninist == 1 ) THEN                       
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -181,5 +182,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
          CALL iom_put( "taubot", z2d )           
       ENDIF
@@ -237,5 +238,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
          CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
          z2d(:,:) = SQRT( z2d(:,:) )
@@ -281,5 +282,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'T', 1. )
          CALL iom_put( "eken", z3d )                 ! kinetic energy
       ENDIF
@@ -307,5 +308,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
          CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
       ENDIF
@@ -320,5 +321,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
          CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
       ENDIF
@@ -342,5 +343,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
          CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
       ENDIF
@@ -355,5 +356,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
          CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
       ENDIF
@@ -368,5 +369,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
          CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
       ENDIF
@@ -380,5 +381,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
          CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
       ENDIF
@@ -410,5 +411,5 @@
          !
       dia_wri_alloc = MAXVAL(ierr)
-      IF( lk_mpp )   CALL mpp_sum( dia_wri_alloc )
+      CALL mpp_sum( 'diawri', dia_wri_alloc )
       !
    END FUNCTION dia_wri_alloc
@@ -445,5 +446,5 @@
       !
       IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -519,5 +520,5 @@
             !! that routine is called from nemogcm, so do it here immediately before its needed
             ALLOCATE( ndex_bT(jpi*jpj*nclasses), STAT=ierror )
-            IF( lk_mpp )   CALL mpp_sum( ierror )
+            CALL mpp_sum( 'diawri', ierror )
             IF( ierror /= 0 ) THEN
                CALL ctl_stop('dia_wri: failed to allocate iceberg diagnostic array')
@@ -868,5 +869,5 @@
 #endif
 
-   SUBROUTINE dia_wri_state( cdfile_name, kt )
+   SUBROUTINE dia_wri_state( cdfile_name )
       !!---------------------------------------------------------------------
       !!                 ***  ROUTINE dia_wri_state  ***
@@ -882,158 +883,56 @@
       !!----------------------------------------------------------------------
       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
+      !!
+      INTEGER :: inum
       !!----------------------------------------------------------------------
       ! 
-      ! 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(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
+
+#if defined key_si3
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
+#else
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+#endif
+
+      CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature
+      CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity
+      CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height
+      CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
+      CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
+      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
       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
-      !
+         CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahtv', ahtv              )    ! aht at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL iom_rstput( 0, 0, inum,  'ahmt', ahmt              )    ! ahmt at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahmf', ahmf              )    ! ahmf at v-point
+      ENDIF
+      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
+      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
+      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
+      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
+      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
+      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL iom_rstput( 0, 0, inum, 'vovvldep', gdept_n        )    !  T-cell depth 
+         CALL iom_rstput( 0, 0, inum, 'vovvle3t', e3t_n          )    !  T-cell thickness  
+      END IF
       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
-
+         CALL iom_rstput( 0, 0, inum, 'sdzocrtx', usd            )    ! now StokesDrift i-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdmecrty', vsd            )    ! now StokesDrift j-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
+      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 )
+         CALL ice_wri_state( inum )
+      ENDIF
 #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
+      !
+      CALL iom_close( inum )
       ! 
    END SUBROUTINE dia_wri_state
Index: /NEMO/trunk/src/OCE/DOM/closea.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/closea.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/closea.F90	(revision 10425)
@@ -118,5 +118,5 @@
             ! number of closed seas = global maximum value in closea_mask field
             jncs = maxval(closea_mask(:,:))
-            IF( lk_mpp ) CALL mpp_max(jncs)
+            CALL mpp_max('closea', jncs)
             IF( jncs > 0 ) THEN
                IF( lwp ) WRITE(numout,*) 'Number of closed seas : ',jncs
@@ -146,5 +146,5 @@
                ! number of closed seas rnf mappings = global maximum in closea_mask_rnf field
                jncsr = maxval(closea_mask_rnf(:,:))
-               IF( lk_mpp ) CALL mpp_max(jncsr)
+               CALL mpp_max('closea', jncsr)
                IF( jncsr > 0 ) THEN
                   IF( lwp ) WRITE(numout,*) 'Number of closed seas rnf mappings : ',jncsr
@@ -166,5 +166,5 @@
                ! number of closed seas empmr mappings = global maximum value in closea_mask_empmr field
                jncse = maxval(closea_mask_empmr(:,:))
-               IF( lk_mpp ) CALL mpp_max(jncse)
+               CALL mpp_max('closea', jncse)
                IF( jncse > 0 ) THEN 
                   IF( lwp ) WRITE(numout,*) 'Number of closed seas empmr mappings : ',jncse
@@ -237,5 +237,5 @@
          surfe(:) = 0.e0_wp
          !
-         surf(jncs+1) = glob_sum( e1e2t(:,:) )   ! surface of the global ocean
+         surf(jncs+1) = glob_sum( 'closea', e1e2t(:,:) )   ! surface of the global ocean
          !
          !                                        ! surface areas of closed seas 
@@ -243,5 +243,5 @@
             ztmp2d(:,:) = 0.e0_wp
             WHERE( closea_mask(:,:) == jc ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:)
-            surf(jc) = glob_sum( ztmp2d(:,:) )
+            surf(jc) = glob_sum( 'closea', ztmp2d(:,:) )
          END DO
          !
@@ -254,5 +254,5 @@
                ztmp2d(:,:) = 0.e0_wp
                WHERE( closea_mask_rnf(:,:) == jcr .and. closea_mask(:,:) == 0 ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:)
-               surfr(jcr) = glob_sum( ztmp2d(:,:) )
+               surfr(jcr) = glob_sum( 'closea', ztmp2d(:,:) )
             END DO
          ENDIF
@@ -263,5 +263,5 @@
                ztmp2d(:,:) = 0.e0_wp
                WHERE( closea_mask_empmr(:,:) == jce .and. closea_mask(:,:) == 0 ) ztmp2d(:,:) = e1e2t(:,:) * tmask_i(:,:)
-               surfe(jce) = glob_sum( ztmp2d(:,:) )
+               surfe(jce) = glob_sum( 'closea', ztmp2d(:,:) )
             END DO
          ENDIF
@@ -301,5 +301,5 @@
          ztmp2d(:,:) = 0.e0_wp
          WHERE( closea_mask(:,:) == jc ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:)
-         zfwf(jc) = glob_sum( ztmp2d(:,:) )
+         zfwf(jc) = glob_sum( 'closea', ztmp2d(:,:) )
       END DO
       zfwf_total = SUM(zfwf)
@@ -316,5 +316,5 @@
             ztmp2d(:,:) = 0.e0_wp
             WHERE( closea_mask_rnf(:,:) == jcr .and. closea_mask(:,:) > 0 ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:)
-            zfwfr(jcr) = glob_sum( ztmp2d(:,:) )
+            zfwfr(jcr) = glob_sum( 'closea', ztmp2d(:,:) )
             !
             ! The following if avoids the redistribution of the round off
@@ -345,5 +345,5 @@
             ztmp2d(:,:) = 0.e0_wp
             WHERE( closea_mask_empmr(:,:) == jce .and. closea_mask(:,:) > 0 ) ztmp2d(:,:) = e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:)
-            zfwfe(jce) = glob_sum( ztmp2d(:,:) )
+            zfwfe(jce) = glob_sum( 'closea', ztmp2d(:,:) )
             !
             ! The following if avoids the redistribution of the round off
@@ -396,5 +396,5 @@
       emp (:,:) = emp (:,:) * tmask(:,:,1)
       !
-      CALL lbc_lnk( emp , 'T', 1._wp )
+      CALL lbc_lnk( 'closea', emp , 'T', 1._wp )
       !
    END SUBROUTINE sbc_clo
Index: /NEMO/trunk/src/OCE/DOM/domain.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/domain.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/domain.F90	(revision 10425)
@@ -469,5 +469,5 @@
       !! ** Method  :   compute and print extrema of masked scale factors
       !!----------------------------------------------------------------------
-      INTEGER ::   iimi1, ijmi1, iimi2, ijmi2, iima1, ijma1, iima2, ijma2
+      INTEGER, DIMENSION(2) ::   imi1, imi2, ima1, ima2
       INTEGER, DIMENSION(2) ::   iloc   ! 
       REAL(wp) ::   ze1min, ze1max, ze2min, ze2max
@@ -475,8 +475,8 @@
       !
       IF(lk_mpp) THEN
-         CALL mpp_minloc( e1t(:,:), tmask_i(:,:), ze1min, iimi1,ijmi1 )
-         CALL mpp_minloc( e2t(:,:), tmask_i(:,:), ze2min, iimi2,ijmi2 )
-         CALL mpp_maxloc( e1t(:,:), tmask_i(:,:), ze1max, iima1,ijma1 )
-         CALL mpp_maxloc( e2t(:,:), tmask_i(:,:), ze2max, iima2,ijma2 )
+         CALL mpp_minloc( 'domain', e1t(:,:), tmask_i(:,:), ze1min, imi1 )
+         CALL mpp_minloc( 'domain', e2t(:,:), tmask_i(:,:), ze2min, imi2 )
+         CALL mpp_maxloc( 'domain', e1t(:,:), tmask_i(:,:), ze1max, ima1 )
+         CALL mpp_maxloc( 'domain', e2t(:,:), tmask_i(:,:), ze2max, ima2 )
       ELSE
          ze1min = MINVAL( e1t(:,:), mask = tmask_i(:,:) == 1._wp )    
@@ -486,15 +486,15 @@
          !
          iloc  = MINLOC( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
-         iimi1 = iloc(1) + nimpp - 1
-         ijmi1 = iloc(2) + njmpp - 1
+         imi1(1) = iloc(1) + nimpp - 1
+         imi1(2) = iloc(2) + njmpp - 1
          iloc  = MINLOC( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
-         iimi2 = iloc(1) + nimpp - 1
-         ijmi2 = iloc(2) + njmpp - 1
+         imi2(1) = iloc(1) + nimpp - 1
+         imi2(2) = iloc(2) + njmpp - 1
          iloc  = MAXLOC( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
-         iima1 = iloc(1) + nimpp - 1
-         ijma1 = iloc(2) + njmpp - 1
+         ima1(1) = iloc(1) + nimpp - 1
+         ima1(2) = iloc(2) + njmpp - 1
          iloc  = MAXLOC( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
-         iima2 = iloc(1) + nimpp - 1
-         ijma2 = iloc(2) + njmpp - 1
+         ima2(1) = iloc(1) + nimpp - 1
+         ima2(2) = iloc(2) + njmpp - 1
       ENDIF
       IF(lwp) THEN
@@ -502,8 +502,8 @@
          WRITE(numout,*) 'dom_ctl : extrema of the masked scale factors'
          WRITE(numout,*) '~~~~~~~'
-         WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, iima1, ijma1
-         WRITE(numout,"(14x,'e1t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1min, iimi1, ijmi1
-         WRITE(numout,"(14x,'e2t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2max, iima2, ijma2
-         WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, iimi2, ijmi2
+         WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, ima1(1), ima1(2)
+         WRITE(numout,"(14x,'e1t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1min, imi1(1), imi1(2)
+         WRITE(numout,"(14x,'e2t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2max, ima2(1), ima2(2)
+         WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, imi2(1), imi2(2)
       ENDIF
       !
@@ -553,10 +553,8 @@
                                           !- or they may be present as global attributes 
                                           !- (netcdf only)  
-         IF( iom_file(inum)%iolib == jpnf90 ) THEN
-            CALL iom_getatt( inum, 'cn_cfg', cd_cfg )  ! returns   !  if not found
-            CALL iom_getatt( inum, 'nn_cfg', kk_cfg )  ! returns -999 if not found
-            IF( TRIM(cd_cfg) == '!') cd_cfg = 'UNKNOWN'
-            IF( kk_cfg == -999     ) kk_cfg = -9999999
-         ENDIF
+         CALL iom_getatt( inum, 'cn_cfg', cd_cfg )  ! returns   !  if not found
+         CALL iom_getatt( inum, 'nn_cfg', kk_cfg )  ! returns -999 if not found
+         IF( TRIM(cd_cfg) == '!') cd_cfg = 'UNKNOWN'
+         IF( kk_cfg == -999     ) kk_cfg = -9999999
          !
       ENDIF
@@ -608,5 +606,5 @@
       !         
       clnam = cn_domcfg_out  ! filename (configuration information)
-      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
+      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE. )
       
       !
@@ -693,8 +691,6 @@
       !
       ! Add some global attributes ( netcdf only )
-      IF( iom_file(inum)%iolib == jpnf90 ) THEN
-         CALL iom_putatt( inum, 'nn_cfg', nn_cfg )
-         CALL iom_putatt( inum, 'cn_cfg', TRIM(cn_cfg) )
-      ENDIF
+      CALL iom_putatt( inum, 'nn_cfg', nn_cfg )
+      CALL iom_putatt( inum, 'cn_cfg', TRIM(cn_cfg) )
       !
       !                                ! ============================
Index: /NEMO/trunk/src/OCE/DOM/dommsk.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/dommsk.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/dommsk.F90	(revision 10425)
@@ -145,5 +145,5 @@
 !SF  add here lbc_lnk: bug not still understood : cause now domain configuration is read !
 !!gm I don't understand why...  
-      CALL lbc_lnk( tmask  , 'T', 1._wp )      ! Lateral boundary conditions
+      CALL lbc_lnk( 'dommsk', tmask  , 'T', 1._wp )      ! Lateral boundary conditions
 
      ! Mask corrections for bdy (read in mppini2)
@@ -183,5 +183,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( umask, 'U', 1., vmask, 'V', 1., fmask, 'F', 1. )      ! Lateral boundary conditions
+      CALL lbc_lnk_multi( 'dommsk', umask, 'U', 1., vmask, 'V', 1., fmask, 'F', 1. )      ! Lateral boundary conditions
  
       ! Ocean/land mask at wu-, wv- and w points    (computed from tmask)
@@ -283,5 +283,5 @@
          DEALLOCATE( zwf )
          !
-         CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
+         CALL lbc_lnk( 'dommsk', fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
          !
          ! CAUTION : The fmask may be further modified in dyn_vor_init ( dynvor.F90 ) depending on ln_vorlat
Index: /NEMO/trunk/src/OCE/DOM/domngb.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/domngb.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/domngb.F90	(revision 10425)
@@ -67,5 +67,6 @@
       
       IF( lk_mpp ) THEN  
-         CALL mpp_minloc( zdist(:,:), zmask, zmini, kii, kjj)
+         CALL mpp_minloc( 'domngb', zdist(:,:), zmask, zmini, iloc)
+         kii = iloc(1) ; kjj = iloc(2)
       ELSE
          iloc(:) = MINLOC( zdist(:,:), mask = zmask(:,:) == 1.e0 )
Index: /NEMO/trunk/src/OCE/DOM/domvvl.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/domvvl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/domvvl.F90	(revision 10425)
@@ -79,6 +79,6 @@
             &      dtilde_e3t_a(jpi,jpj,jpk) , un_td  (jpi,jpj,jpk)     , vn_td  (jpi,jpj,jpk)     ,   &
             &      STAT = dom_vvl_alloc        )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
          un_td = 0._wp
          vn_td = 0._wp
@@ -86,6 +86,6 @@
       IF( ln_vvl_ztilde ) THEN
          ALLOCATE( frq_rst_e3t(jpi,jpj) , frq_rst_hdv(jpi,jpj) , hdiv_lf(jpi,jpj,jpk) , STAT= dom_vvl_alloc )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
       ENDIF
       !
@@ -410,5 +410,5 @@
          !                       ! d - thickness diffusion transport: boundary conditions
          !                             (stored for tracer advction and continuity equation)
-         CALL lbc_lnk_multi( un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
+         CALL lbc_lnk_multi( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
 
          ! 4 - Time stepping of baroclinic scale factors
@@ -421,5 +421,5 @@
             z2dt = 2.0_wp * rdt
          ENDIF
-         CALL lbc_lnk( tilde_e3t_a(:,:,:), 'T', 1._wp )
+         CALL lbc_lnk( 'domvvl', tilde_e3t_a(:,:,:), 'T', 1._wp )
          tilde_e3t_a(:,:,:) = tilde_e3t_b(:,:,:) + z2dt * tmask(:,:,:) * tilde_e3t_a(:,:,:)
 
@@ -431,12 +431,12 @@
          END DO
          z_tmax = MAXVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_max( z_tmax )                 ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                 ! max over the global domain
          z_tmin = MINVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_min( z_tmin )                 ! min over the global domain
+         CALL mpp_min( 'domvvl', z_tmin )                 ! min over the global domain
          ! - ML - test: for the moment, stop simulation for too large e3_t variations
          IF( ( z_tmax >  rn_zdef_max ) .OR. ( z_tmin < - rn_zdef_max ) ) THEN
             IF( lk_mpp ) THEN
-               CALL mpp_maxloc( ze3t, tmask, z_tmax, ijk_max(1), ijk_max(2), ijk_max(3) )
-               CALL mpp_minloc( ze3t, tmask, z_tmin, ijk_min(1), ijk_min(2), ijk_min(3) )
+               CALL mpp_maxloc( 'domvvl', ze3t, tmask, z_tmax, ijk_max )
+               CALL mpp_minloc( 'domvvl', ze3t, tmask, z_tmin, ijk_min )
             ELSE
                ijk_max = MAXLOC( ze3t(:,:,:) )
@@ -452,5 +452,5 @@
                WRITE(numout, *) 'MIN( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmin
                WRITE(numout, *) 'at i, j, k=', ijk_min            
-               CALL ctl_warn('MAX( ABS( tilde_e3t_a(:,:,:) ) / e3t_0(:,:,:) ) too high')
+               CALL ctl_stop( 'STOP', 'MAX( ABS( tilde_e3t_a(:,:,: ) ) / e3t_0(:,:,:) ) too high')
             ENDIF
          ENDIF
@@ -495,5 +495,5 @@
          IF ( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
             z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( zht(:,:) ) )
-            IF( lk_mpp ) CALL mpp_max( z_tmax )                             ! max over the global domain
+            CALL mpp_max( 'domvvl', z_tmax )                             ! max over the global domain
             IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(SUM(tilde_e3t_a))) =', z_tmax
          END IF
@@ -504,5 +504,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshn(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshn-SUM(e3t_n))) =', z_tmax
          !
@@ -512,5 +512,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + ssha(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+ssha-SUM(e3t_a))) =', z_tmax
          !
@@ -520,17 +520,17 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshb(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshb-SUM(e3t_b))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshb(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshb))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshn(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshn))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( ssha(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ssha))) =', z_tmax
       END IF
@@ -713,5 +713,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'U', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'U', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3u_0(:,:,:)
          !
@@ -726,5 +726,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'V', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'V', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3v_0(:,:,:)
          !
@@ -740,5 +740,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'F', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'F', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3f_0(:,:,:)
          !
Index: /NEMO/trunk/src/OCE/DOM/domwri.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/domwri.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/domwri.F90	(revision 10425)
@@ -72,5 +72,5 @@
       !                                  !  create 'mesh_mask.nc' file
       !                                  ! ============================
-      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
+      CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE. )
       !
       !                                                         ! global domain size
@@ -210,5 +210,5 @@
       !
       puniq(:,:) = ztstref(:,:)                   ! default definition
-      CALL lbc_lnk( puniq, cdgrd, 1. )            ! apply boundary conditions
+      CALL lbc_lnk( 'domwri', puniq, cdgrd, 1. )            ! apply boundary conditions
       lldbl(:,:,1) = puniq(:,:) == ztstref(:,:)   ! check which values have been changed 
       !
@@ -271,5 +271,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zx1, 'T', 1. )
+      CALL lbc_lnk( 'domwri', zx1, 'T', 1. )
       !
       IF( PRESENT( px1 ) )    px1 = zx1
@@ -277,5 +277,5 @@
       zrxmax = MAXVAL( zx1 )
       !
-      IF( lk_mpp )   CALL mpp_max( zrxmax ) ! max over the global domain
+      CALL mpp_max( 'domwri', zrxmax ) ! max over the global domain
       !
       IF(lwp) THEN
Index: /NEMO/trunk/src/OCE/DOM/domzgr.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/domzgr.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/domzgr.F90	(revision 10425)
@@ -307,10 +307,10 @@
       END DO
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
-      zk(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   miku(:,:) = MAX( NINT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mikv(:,:) = MAX( NINT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk( zk, 'F', 1. )   ;   mikf(:,:) = MAX( NINT( zk(:,:) ), 1 )
-      !
-      zk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   mbku(:,:) = MAX( NINT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mbkv(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk( 'domzgr', zk, 'U', 1. )   ;   miku(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk( 'domzgr', zk, 'V', 1. )   ;   mikv(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk( 'domzgr', zk, 'F', 1. )   ;   mikf(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      !
+      zk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk( 'domzgr', zk, 'U', 1. )   ;   mbku(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk( 'domzgr', zk, 'V', 1. )   ;   mbkv(:,:) = MAX( NINT( zk(:,:) ), 1 )
       !
    END SUBROUTINE zgr_top_bot
Index: /NEMO/trunk/src/OCE/DOM/iscplhsb.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/iscplhsb.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/iscplhsb.F90	(revision 10425)
@@ -206,5 +206,5 @@
 
       ! build array of total problematic point on each cpu (share to each cpu)
-      CALL mpp_max(inpts,jpnij) 
+      CALL mpp_max('iscplhsb', inpts,jpnij) 
 
       ! size of the new variable
@@ -243,12 +243,12 @@
       ! build array of total problematic point on each cpu (share to each cpu)
       ! point coordinates
-      CALL mpp_max(zlat ,npts)
-      CALL mpp_max(zlon ,npts)
-      CALL mpp_max(izpts,npts)
+      CALL mpp_max('iscplhsb', zlat ,npts)
+      CALL mpp_max('iscplhsb', zlon ,npts)
+      CALL mpp_max('iscplhsb', izpts,npts)
 
       ! correction values 
-      CALL mpp_max(zcorr_vol,npts)
-      CALL mpp_max(zcorr_sal,npts)
-      CALL mpp_max(zcorr_tem,npts)
+      CALL mpp_max('iscplhsb', zcorr_vol,npts)
+      CALL mpp_max('iscplhsb', zcorr_sal,npts)
+      CALL mpp_max('iscplhsb', zcorr_tem,npts)
 
       ! put correction term in the closest cell          
Index: /NEMO/trunk/src/OCE/DOM/iscplini.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/iscplini.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/iscplini.F90	(revision 10425)
@@ -48,5 +48,5 @@
       ALLOCATE( htsc_iscpl(jpi,jpj,jpk,jpts) , hdiv_iscpl(jpi,jpj,jpk) , STAT=iscpl_alloc )
          !
-      IF( lk_mpp          )   CALL mpp_sum ( iscpl_alloc )
+      CALL mpp_sum ( 'iscplini', iscpl_alloc )
       IF( iscpl_alloc > 0 )   CALL ctl_warn('iscpl_alloc: allocation of arrays failed')
    END FUNCTION iscpl_alloc
Index: /NEMO/trunk/src/OCE/DOM/iscplrst.F90
===================================================================
--- /NEMO/trunk/src/OCE/DOM/iscplrst.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DOM/iscplrst.F90	(revision 10425)
@@ -82,5 +82,5 @@
          cfile='correction'
          cfile = TRIM( cfile )
-         CALL iom_open  ( cfile, inum0, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open  ( cfile, inum0, ldwrt = .TRUE. )
          CALL iom_rstput( 0, 0, inum0, 'vol_cor', hdiv_iscpl(:,:,:) )
          CALL iom_rstput( 0, 0, inum0, 'tem_cor', htsc_iscpl(:,:,:,jp_tem) )
@@ -175,5 +175,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( sshn, 'T', 1., zsmask1, 'T', 1. )
+         CALL lbc_lnk_multi( 'iscplrst', sshn, 'T', 1., zsmask1, 'T', 1. )
          zssh0   = sshn
          zsmask0 = zsmask1
@@ -344,5 +344,5 @@
           END DO
           
-          CALL lbc_lnk_multi( tsn(:,:,:,jp_tem), 'T', 1., tsn(:,:,:,jp_sal), 'T', 1., ztmask1, 'T', 1.)
+          CALL lbc_lnk_multi( 'iscplrst', tsn(:,:,:,jp_tem), 'T', 1., tsn(:,:,:,jp_sal), 'T', 1., ztmask1, 'T', 1.)
 
           ! update
Index: /NEMO/trunk/src/OCE/DYN/divhor.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/divhor.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/divhor.F90	(revision 10425)
@@ -104,5 +104,5 @@
       IF( ln_iscpl .AND. ln_hsb )   CALL iscpl_div( hdivn ) !==  ice sheet  ==!   (update hdivn field)
       !
-      CALL lbc_lnk( hdivn, 'T', 1. )   !   (no sign change)
+      CALL lbc_lnk( 'divhor', hdivn, 'T', 1. )   !   (no sign change)
       !
       IF( ln_timing )   CALL timing_stop('div_hor')
Index: /NEMO/trunk/src/OCE/DYN/dynadv_ubs.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynadv_ubs.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynadv_ubs.F90	(revision 10425)
@@ -123,5 +123,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zlu_uu(:,:,:,1), 'U', 1. , zlu_uv(:,:,:,1), 'U', 1.,  &
+      CALL lbc_lnk_multi( 'dynadv_ubs', zlu_uu(:,:,:,1), 'U', 1. , zlu_uv(:,:,:,1), 'U', 1.,  &
                       &   zlu_uu(:,:,:,2), 'U', 1. , zlu_uv(:,:,:,2), 'U', 1.,  & 
                       &   zlv_vv(:,:,:,1), 'V', 1. , zlv_vu(:,:,:,1), 'V', 1.,  &
Index: /NEMO/trunk/src/OCE/DYN/dynhpg.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynhpg.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynhpg.F90	(revision 10425)
@@ -490,5 +490,5 @@
            END DO
         END DO
-        CALL lbc_lnk_multi( zcpx, 'U', 1., zcpy, 'V', 1. )
+        CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1., zcpy, 'V', 1. )
       END IF
 
@@ -723,5 +723,5 @@
            END DO
         END DO
-        CALL lbc_lnk_multi( zcpx, 'U', 1., zcpy, 'V', 1. )
+        CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1., zcpy, 'V', 1. )
       END IF
 
@@ -883,5 +883,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( rho_k, 'W', 1., rho_i, 'U', 1., rho_j, 'V', 1. )
+      CALL lbc_lnk_multi( 'dynhpg', rho_k, 'W', 1., rho_i, 'U', 1., rho_j, 'V', 1. )
 
       ! ---------------
@@ -1016,5 +1016,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zcpx, 'U', 1., zcpy, 'V', 1. )
+         CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1., zcpy, 'V', 1. )
       ENDIF
 
@@ -1102,5 +1102,5 @@
       END DO
 
-      CALL lbc_lnk_multi (zsshu_n, 'U', 1., zsshv_n, 'V', 1. )
+      CALL lbc_lnk_multi ('dynhpg', zsshu_n, 'U', 1., zsshv_n, 'V', 1. )
 
       DO jj = 2, jpjm1
Index: /NEMO/trunk/src/OCE/DYN/dynkeg.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynkeg.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynkeg.F90	(revision 10425)
@@ -158,5 +158,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zhke, 'T', 1. )
+         CALL lbc_lnk( 'dynkeg', zhke, 'T', 1. )
          !
       END SELECT
Index: /NEMO/trunk/src/OCE/DYN/dynldf_iso.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynldf_iso.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynldf_iso.F90	(revision 10425)
@@ -136,5 +136,5 @@
          END DO
          ! Lateral boundary conditions on the slopes
-         CALL lbc_lnk_multi( uslp , 'U', -1., vslp , 'V', -1., wslpi, 'W', -1., wslpj, 'W', -1. )
+         CALL lbc_lnk_multi( 'dynldf_iso', uslp , 'U', -1., vslp , 'V', -1., wslpi, 'W', -1., wslpj, 'W', -1. )
          !
        ENDIF
Index: /NEMO/trunk/src/OCE/DYN/dynldf_lap_blp.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynldf_lap_blp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynldf_lap_blp.F90	(revision 10425)
@@ -136,5 +136,5 @@
       CALL dyn_ldf_lap( kt, pub, pvb, zulap, zvlap, 1 )   ! rotated laplacian applied to ptb (output in zlap)
       !
-      CALL lbc_lnk_multi( zulap, 'U', -1., zvlap, 'V', -1. )             ! Lateral boundary conditions
+      CALL lbc_lnk_multi( 'dynldf_lap_blp', zulap, 'U', -1., zvlap, 'V', -1. )             ! Lateral boundary conditions
       !
       CALL dyn_ldf_lap( kt, zulap, zvlap, pua, pva, 2 )   ! rotated laplacian applied to zlap (output in pta)
Index: /NEMO/trunk/src/OCE/DYN/dynnxt.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynnxt.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynnxt.F90	(revision 10425)
@@ -144,5 +144,5 @@
 # endif
       !
-      CALL lbc_lnk_multi( ua, 'U', -1., va, 'V', -1. )     !* local domain boundaries
+      CALL lbc_lnk_multi( 'dynnxt', ua, 'U', -1., va, 'V', -1. )     !* local domain boundaries
       !
       !                                !* BDY open boundaries
Index: /NEMO/trunk/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynspg_ts.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynspg_ts.F90	(revision 10425)
@@ -112,6 +112,6 @@
       dyn_spg_ts_alloc = MAXVAL( ierr(:) )
       !
-      IF( lk_mpp                )   CALL mpp_sum( dyn_spg_ts_alloc )
-      IF( dyn_spg_ts_alloc /= 0 )   CALL ctl_warn('dyn_spg_ts_alloc: failed to allocate arrays')
+      CALL mpp_sum( 'dynspg_ts', dyn_spg_ts_alloc )
+      IF( dyn_spg_ts_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dyn_spg_ts_alloc: failed to allocate arrays' )
       !
    END FUNCTION dyn_spg_ts_alloc
@@ -262,5 +262,5 @@
                END DO
             END SELECT
-            CALL lbc_lnk( zwz, 'F', 1._wp )
+            CALL lbc_lnk( 'dynspg_ts', zwz, 'F', 1._wp )
             !
             ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
@@ -330,5 +330,5 @@
                END DO
             END DO
-            CALL lbc_lnk( zhf, 'F', 1._wp )
+            CALL lbc_lnk( 'dynspg_ts', zhf, 'F', 1._wp )
             ! JC: TBC. hf should be greater than 0 
             DO jj = 1, jpj
@@ -711,4 +711,7 @@
       DO jn = 1, icycle                             !  sub-time-step loop  !
          !                                          ! ==================== !
+         !
+         l_full_nf_update = jn == icycle   ! false: disable full North fold update (performances) for jn = 1 to icycle-1
+         !                                                !  ------------------
          !                                                !* Update the forcing (BDY and tides)
          !                                                !  ------------------
@@ -777,5 +780,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( zwx, 'U', 1._wp, zwy, 'V', 1._wp )
+            CALL lbc_lnk_multi( 'dynspg_ts', zwx, 'U', 1._wp, zwy, 'V', 1._wp )
             !
             zhup2_e(:,:) = hu_0(:,:) + zwx(:,:)                ! Ocean depth at U- and V-points
@@ -872,5 +875,5 @@
          ssha_e(:,:) = (  sshn_e(:,:) - rdtbt * ( zssh_frc(:,:) + zhdiv(:,:) )  ) * ssmask(:,:)
          
-         CALL lbc_lnk( ssha_e, 'T',  1._wp )
+         CALL lbc_lnk( 'dynspg_ts', ssha_e, 'T',  1._wp )
 
          ! Duplicate sea level across open boundaries (this is only cosmetic if linssh=T)
@@ -892,5 +895,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp )
+            CALL lbc_lnk_multi( 'dynspg_ts', zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp )
          ENDIF   
          !                                 
@@ -1160,5 +1163,5 @@
          ENDIF
          !                                             !* domain lateral boundary
-         CALL lbc_lnk_multi( ua_e, 'U', -1._wp, va_e , 'V', -1._wp )
+         CALL lbc_lnk_multi( 'dynspg_ts', ua_e, 'U', -1._wp, va_e , 'V', -1._wp )
          !
          !                                                 ! open boundaries
@@ -1246,5 +1249,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
+         CALL lbc_lnk_multi( 'dynspg_ts', zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
          !
          DO jk=1,jpkm1
@@ -1481,5 +1484,5 @@
       !
       zcmax = MAXVAL( zcu(:,:) )
-      IF( lk_mpp )   CALL mpp_max( zcmax )
+      CALL mpp_max( 'dynspg_ts', zcmax )
 
       ! Estimate number of iterations to satisfy a max courant number= rn_bt_cmax
Index: /NEMO/trunk/src/OCE/DYN/dynvor.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/dynvor.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/dynvor.F90	(revision 10425)
@@ -212,5 +212,6 @@
       INTEGER  ::   ji, jj, jk           ! dummy loop indices
       REAL(wp) ::   zx1, zy1, zx2, zy2   ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj) ::   zwx, zwy, zwz, zwt   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zwx, zwy, zwt   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz             ! 3D workspace
       !!----------------------------------------------------------------------
       !
@@ -221,30 +222,58 @@
       ENDIF
       !
+      !
+      SELECT CASE( kvor )                 !==  volume weighted vorticity considered  ==!
+      CASE ( np_RVO )                           !* relative vorticity
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zwz(ji,jj,jk) = (  e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)  &
+                     &             - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
+                  END DO
+               END DO
+            ENDIF
+         END DO
+
+         CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
+
+      CASE ( np_CRV )                           !* Coriolis + relative vorticity
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1                          ! relative vorticity
+                  zwz(ji,jj,jk) = (   e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)   &
+                     &              - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)   ) * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
+                  END DO
+               END DO
+            ENDIF
+         END DO
+
+         CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
+
+      END SELECT
+
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         !
+      !                                                ! ===============
+
          SELECT CASE( kvor )                 !==  volume weighted vorticity considered  ==!
          CASE ( np_COR )                           !* Coriolis (planetary vorticity)
             zwt(:,:) = ff_t(:,:) * e1e2t(:,:)*e3t_n(:,:,jk)
          CASE ( np_RVO )                           !* relative vorticity
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zwz(ji,jj) = (  e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)  &
-                     &          - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
-               END DO
-            END DO
-            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
-                  END DO
-               END DO
-            ENDIF
-            CALL lbc_lnk( zwz, 'F', 1. )
             DO jj = 2, jpj
                DO ji = 2, jpi   ! vector opt.
-                  zwt(ji,jj) = r1_4 * (   zwz(ji-1,jj  ) + zwz(ji,jj  )   &
-                     &                  + zwz(ji-1,jj-1) + zwz(ji,jj-1)   ) * e1e2t(ji,jj)*e3t_n(ji,jj,jk)
+                  zwt(ji,jj) = r1_4 * (   zwz(ji-1,jj  ,jk) + zwz(ji,jj  ,jk)   &
+                     &                  + zwz(ji-1,jj-1,jk) + zwz(ji,jj-1,jk) ) * e1e2t(ji,jj)*e3t_n(ji,jj,jk)
                END DO
             END DO
@@ -257,22 +286,8 @@
             END DO
          CASE ( np_CRV )                           !* Coriolis + relative vorticity
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1                          ! relative vorticity
-                  zwz(ji,jj) = (   e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk)   &
-                     &           - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk)   ) * r1_e1e2f(ji,jj)
-               END DO
-            END DO
-            IF( ln_dynvor_msk ) THEN                     ! mask/unmask relative vorticity 
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
-                  END DO
-               END DO
-            ENDIF
-            CALL lbc_lnk( zwz, 'F', 1. )
             DO jj = 2, jpj
                DO ji = 2, jpi   ! vector opt.
-                  zwt(ji,jj) = (  ff_t(ji,jj) + r1_4 * ( zwz(ji-1,jj  ) + zwz(ji,jj  )    &
-                     &                                 + zwz(ji-1,jj-1) + zwz(ji,jj-1) )  ) * e1e2t(ji,jj)*e3t_n(ji,jj,jk)
+                  zwt(ji,jj) = (  ff_t(ji,jj) + r1_4 * ( zwz(ji-1,jj  ,jk) + zwz(ji,jj  ,jk)    &
+                     &                                 + zwz(ji-1,jj-1,jk) + zwz(ji,jj-1,jk) )  ) * e1e2t(ji,jj)*e3t_n(ji,jj,jk)
                END DO
             END DO
@@ -548,6 +563,7 @@
       REAL(wp) ::   zua, zva     ! local scalars
       REAL(wp) ::   zmsk, ze3f   ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj) ::   zwx , zwy , zwz , z1_e3f
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztnw, ztne, ztsw, ztse
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zwx , zwy , z1_e3f
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztnw, ztne, ztsw, ztse
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz
       !!----------------------------------------------------------------------
       !
@@ -591,5 +607,5 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ff_f(ji,jj) * z1_e3f(ji,jj)
+                  zwz(ji,jj,jk) = ff_f(ji,jj) * z1_e3f(ji,jj)
                END DO
             END DO
@@ -597,6 +613,6 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ( e2v(ji+1,jj  ) * pvn(ji+1,jj,jk) - e2v(ji,jj) * pvn(ji,jj,jk)  &
-                     &         - e1u(ji  ,jj+1) * pun(ji,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) * r1_e1e2f(ji,jj)*z1_e3f(ji,jj)
+                  zwz(ji,jj,jk) = ( e2v(ji+1,jj  ) * pvn(ji+1,jj,jk) - e2v(ji,jj) * pvn(ji,jj,jk)  &
+                     &            - e1u(ji  ,jj+1) * pun(ji,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) * r1_e1e2f(ji,jj)*z1_e3f(ji,jj)
                END DO
             END DO
@@ -604,6 +620,6 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = (   ( pvn(ji+1,jj,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
-                     &           - ( pun(ji,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
+                  zwz(ji,jj,jk) = (   ( pvn(ji+1,jj,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
+                     &              - ( pun(ji,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
                END DO
             END DO
@@ -611,7 +627,7 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = (  ff_f(ji,jj) + (  e2v(ji+1,jj  ) * pvn(ji+1,jj,jk) - e2v(ji,jj) * pvn(ji,jj,jk)      &
-                     &                           - e1u(ji  ,jj+1) * pun(ji,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  )   &
-                     &                        * r1_e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
+                  zwz(ji,jj,jk) = (  ff_f(ji,jj) + (  e2v(ji+1,jj  ) * pvn(ji+1,jj,jk) - e2v(ji,jj) * pvn(ji,jj,jk)      &
+                     &                              - e1u(ji  ,jj+1) * pun(ji,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  )   &
+                     &                           * r1_e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
                END DO
             END DO
@@ -619,6 +635,6 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = (   ff_f(ji,jj) + ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
-                     &                         - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
+                  zwz(ji,jj,jk) = (   ff_f(ji,jj) + ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
+                     &                            - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
                END DO
             END DO
@@ -630,10 +646,13 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+                  zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
                END DO
             END DO
          ENDIF
-         !
-         CALL lbc_lnk( zwz, 'F', 1. )
+      END DO                                           !   End of slab
+         !
+      CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
+
+      DO jk = 1, jpkm1                                 ! Horizontal slab
          !
          !                                   !==  horizontal fluxes  ==!
@@ -645,15 +664,15 @@
          ztne(1,:) = 0   ;   ztnw(1,:) = 0   ;   ztse(1,:) = 0   ;   ztsw(1,:) = 0
          DO ji = 2, jpi          ! split in 2 parts due to vector opt.
-               ztne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
-               ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
-               ztse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
-               ztsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+               ztne(ji,jj) = zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk)
+               ztnw(ji,jj) = zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk)
+               ztse(ji,jj) = zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk)
+               ztsw(ji,jj) = zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk)
          END DO
          DO jj = 3, jpj
             DO ji = fs_2, jpi   ! vector opt. ok because we start at jj = 3
-               ztne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
-               ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
-               ztse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
-               ztsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+               ztne(ji,jj) = zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk)
+               ztnw(ji,jj) = zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk)
+               ztse(ji,jj) = zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk)
+               ztsw(ji,jj) = zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk)
             END DO
          END DO
@@ -701,6 +720,7 @@
       REAL(wp) ::   zua, zva       ! local scalars
       REAL(wp) ::   zmsk, z1_e3t   ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj) ::   zwx , zwy , zwz
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztnw, ztne, ztsw, ztse
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zwx , zwy 
+      REAL(wp), DIMENSION(jpi,jpj)     ::   ztnw, ztne, ztsw, ztse
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zwz
       !!----------------------------------------------------------------------
       !
@@ -720,5 +740,5 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ff_f(ji,jj)
+                  zwz(ji,jj,jk) = ff_f(ji,jj)
                END DO
             END DO
@@ -726,7 +746,7 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = (  e2v(ji+1,jj  ) * pvn(ji+1,jj  ,jk) - e2v(ji,jj) * pvn(ji,jj,jk)    &
-                     &          - e1u(ji  ,jj+1) * pun(ji  ,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) &
-                     &       * r1_e1e2f(ji,jj)
+                  zwz(ji,jj,jk) = (  e2v(ji+1,jj  ) * pvn(ji+1,jj  ,jk) - e2v(ji,jj) * pvn(ji,jj,jk)    &
+                     &             - e1u(ji  ,jj+1) * pun(ji  ,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) &
+                     &          * r1_e1e2f(ji,jj)
                END DO
             END DO
@@ -734,6 +754,6 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
-                     &       - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)
+                  zwz(ji,jj,jk) = ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
+                     &          - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)
                END DO
             END DO
@@ -741,7 +761,7 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = (  ff_f(ji,jj) + (  e2v(ji+1,jj  ) * pvn(ji+1,jj  ,jk) - e2v(ji,jj) * pvn(ji,jj,jk)    &
-                     &                           - e1u(ji  ,jj+1) * pun(ji  ,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) &
-                     &                      * r1_e1e2f(ji,jj)    )
+                  zwz(ji,jj,jk) = (  ff_f(ji,jj) + (  e2v(ji+1,jj  ) * pvn(ji+1,jj  ,jk) - e2v(ji,jj) * pvn(ji,jj,jk)    &
+                     &                              - e1u(ji  ,jj+1) * pun(ji  ,jj+1,jk) + e1u(ji,jj) * pun(ji,jj,jk)  ) &
+                     &                         * r1_e1e2f(ji,jj)    )
                END DO
             END DO
@@ -749,6 +769,6 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ff_f(ji,jj) + ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
-                     &                     - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)
+                  zwz(ji,jj,jk) = ff_f(ji,jj) + ( pvn(ji+1,jj  ,jk) + pvn(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj)   &
+                     &                        - ( pun(ji  ,jj+1,jk) + pun(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj)
                END DO
             END DO
@@ -760,12 +780,15 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+                  zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk)
                END DO
             END DO
          ENDIF
-         !
-         CALL lbc_lnk( zwz, 'F', 1. )
-         !
-         !                                   !==  horizontal fluxes  ==!
+      END DO
+      !
+      CALL lbc_lnk( 'dynvor', zwz, 'F', 1. )
+      !
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+
+      !                                   !==  horizontal fluxes  ==!
          zwx(:,:) = e2u(:,:) * e3u_n(:,:,jk) * pun(:,:,jk)
          zwy(:,:) = e1v(:,:) * e3v_n(:,:,jk) * pvn(:,:,jk)
@@ -776,16 +799,16 @@
          DO ji = 2, jpi          ! split in 2 parts due to vector opt.
                z1_e3t = 1._wp / e3t_n(ji,jj,jk)
-               ztne(ji,jj) = ( zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1) ) * z1_e3t
-               ztnw(ji,jj) = ( zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  ) ) * z1_e3t
-               ztse(ji,jj) = ( zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1) ) * z1_e3t
-               ztsw(ji,jj) = ( zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  ) ) * z1_e3t
+               ztne(ji,jj) = ( zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) ) * z1_e3t
+               ztnw(ji,jj) = ( zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) ) * z1_e3t
+               ztse(ji,jj) = ( zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) ) * z1_e3t
+               ztsw(ji,jj) = ( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) ) * z1_e3t
          END DO
          DO jj = 3, jpj
             DO ji = fs_2, jpi   ! vector opt. ok because we start at jj = 3
                z1_e3t = 1._wp / e3t_n(ji,jj,jk)
-               ztne(ji,jj) = ( zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1) ) * z1_e3t
-               ztnw(ji,jj) = ( zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  ) ) * z1_e3t
-               ztse(ji,jj) = ( zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1) ) * z1_e3t
-               ztsw(ji,jj) = ( zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  ) ) * z1_e3t
+               ztne(ji,jj) = ( zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) ) * z1_e3t
+               ztnw(ji,jj) = ( zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) + zwz(ji  ,jj  ,jk) ) * z1_e3t
+               ztse(ji,jj) = ( zwz(ji  ,jj  ,jk) + zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) ) * z1_e3t
+               ztsw(ji,jj) = ( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj-1,jk) + zwz(ji-1,jj  ,jk) ) * z1_e3t
             END DO
          END DO
@@ -863,5 +886,5 @@
          END DO
          !
-         CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
+         CALL lbc_lnk( 'dynvor', fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
          !
       ENDIF
@@ -903,5 +926,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( di_e2u_2, 'T', -1. , dj_e1v_2, 'T', -1. )   ! Lateral boundary conditions
+            CALL lbc_lnk_multi( 'dynvor', di_e2u_2, 'T', -1. , dj_e1v_2, 'T', -1. )   ! Lateral boundary conditions
             !
          CASE DEFAULT                        !* F-point metric term :   pre-compute di(e2u)/(2*e1e2f) and dj(e1v)/(2*e1e2f)
@@ -913,5 +936,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( di_e2v_2e1e2f, 'F', -1. , dj_e1u_2e1e2f, 'F', -1. )   ! Lateral boundary conditions
+            CALL lbc_lnk_multi( 'dynvor', di_e2v_2e1e2f, 'F', -1. , dj_e1u_2e1e2f, 'F', -1. )   ! Lateral boundary conditions
          END SELECT
          !
Index: /NEMO/trunk/src/OCE/DYN/sshwzv.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/sshwzv.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/sshwzv.F90	(revision 10425)
@@ -112,5 +112,5 @@
       IF ( .NOT.ln_dynspg_ts ) THEN
          IF( ln_bdy ) THEN
-            CALL lbc_lnk( ssha, 'T', 1. )    ! Not sure that's necessary
+            CALL lbc_lnk( 'sshwzv', ssha, 'T', 1. )    ! Not sure that's necessary
             CALL bdy_ssh( ssha )             ! Duplicate sea level across open boundaries
          ENDIF
@@ -176,5 +176,5 @@
             END DO
          END DO
-         CALL lbc_lnk(zhdiv, 'T', 1.)  ! - ML - Perhaps not necessary: not used for horizontal "connexions"
+         CALL lbc_lnk('sshwzv', zhdiv, 'T', 1.)  ! - ML - Perhaps not necessary: not used for horizontal "connexions"
          !                             ! Is it problematic to have a wrong vertical velocity in boundary cells?
          !                             ! Same question holds for hdivn. Perhaps just for security
Index: /NEMO/trunk/src/OCE/DYN/wet_dry.F90
===================================================================
--- /NEMO/trunk/src/OCE/DYN/wet_dry.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/DYN/wet_dry.F90	(revision 10425)
@@ -241,7 +241,7 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zwdlmtu, 'U', 1., zwdlmtv, 'V', 1. )
-         !
-         IF( lk_mpp )   CALL mpp_max(jflag)   !max over the global domain
+         CALL lbc_lnk_multi( 'wet_dry', zwdlmtu, 'U', 1., zwdlmtv, 'V', 1. )
+         !
+         CALL mpp_max('wet_dry', jflag)   !max over the global domain
          !
          IF( jflag == 0 )   EXIT
@@ -257,6 +257,6 @@
       !
 !!gm TO BE SUPPRESSED ?  these lbc_lnk are useless since zwdlmtu and zwdlmtv are defined everywhere !
-      CALL lbc_lnk_multi( un  , 'U', -1., vn  , 'V', -1. )
-      CALL lbc_lnk_multi( un_b, 'U', -1., vn_b, 'V', -1. )
+      CALL lbc_lnk_multi( 'wet_dry', un  , 'U', -1., vn  , 'V', -1. )
+      CALL lbc_lnk_multi( 'wet_dry', un_b, 'U', -1., vn_b, 'V', -1. )
 !!gm
       !
@@ -370,7 +370,7 @@
          END DO  ! jj loop
          !
-         CALL lbc_lnk_multi( zwdlmtu, 'U', 1., zwdlmtv, 'V', 1. )
-         !
-         IF(lk_mpp) CALL mpp_max(jflag)   !max over the global domain
+         CALL lbc_lnk_multi( 'wet_dry', zwdlmtu, 'U', 1., zwdlmtv, 'V', 1. )
+         !
+         CALL mpp_max('wet_dry', jflag)   !max over the global domain
          !
          IF(jflag == 0)   EXIT
@@ -382,5 +382,5 @@
       !
 !!gm THIS lbc_lnk is useless since it is already done at the end of the jk1-loop
-      CALL lbc_lnk_multi( zflxu, 'U', -1., zflxv, 'V', -1. )
+      CALL lbc_lnk_multi( 'wet_dry', zflxu, 'U', -1., zflxv, 'V', -1. )
 !!gm end
       !
Index: /NEMO/trunk/src/OCE/FLO/flo_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/flo_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/FLO/flo_oce.F90	(revision 10425)
@@ -64,6 +64,6 @@
          &      tpifl(jpnfl)    , tpjfl(jpnfl)  , tpkfl(jpnfl)   , STAT=flo_oce_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( flo_oce_alloc )
-      IF( flo_oce_alloc /= 0 )   CALL ctl_warn('flo_oce_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'flo_oce', flo_oce_alloc )
+      IF( flo_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'flo_oce_alloc: failed to allocate arrays' )
    END FUNCTION flo_oce_alloc
 
Index: /NEMO/trunk/src/OCE/FLO/floblk.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/floblk.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/FLO/floblk.F90	(revision 10425)
@@ -330,10 +330,10 @@
       
       ! synchronisation
-      IF( lk_mpp )   CALL mpp_sum( zgifl , jpnfl )   ! sums over the global domain
-      IF( lk_mpp )   CALL mpp_sum( zgjfl , jpnfl )
-      IF( lk_mpp )   CALL mpp_sum( zgkfl , jpnfl )
-      IF( lk_mpp )   CALL mpp_sum( zagefl, jpnfl )
-      IF( lk_mpp )   CALL mpp_sum( iil   , jpnfl )
-      IF( lk_mpp )   CALL mpp_sum( ijl   , jpnfl )
+      CALL mpp_sum( 'floblk', zgifl , jpnfl )   ! sums over the global domain
+      CALL mpp_sum( 'floblk', zgjfl , jpnfl )
+      CALL mpp_sum( 'floblk', zgkfl , jpnfl )
+      CALL mpp_sum( 'floblk', zagefl, jpnfl )
+      CALL mpp_sum( 'floblk', iil   , jpnfl )
+      CALL mpp_sum( 'floblk', ijl   , jpnfl )
       
       ! Test to know if a  float hasn't integrated enought time
Index: /NEMO/trunk/src/OCE/FLO/flodom.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/flodom.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/FLO/flodom.F90	(revision 10425)
@@ -193,6 +193,6 @@
       !----------------------------------------------
       IF( lk_mpp )   THEN 
-         CALL mpp_sum(ihtest,jpnfl)
-         CALL mpp_sum(ivtest,jpnfl)
+         CALL mpp_sum('flodom', ihtest,jpnfl)
+         CALL mpp_sum('flodom', ivtest,jpnfl)
       ENDIF
       DO jfl = kfl_start,kfl_end
@@ -252,6 +252,6 @@
       ! The sum of all the arrays zgifl, zgjfl, zgkfl give 3 arrays with the positions of all the floats.
       IF( lk_mpp )   THEN 
-         CALL mpp_sum( zgjfl, ifl )   ! sums over the global domain
-         CALL mpp_sum( zgkfl, ifl )
+         CALL mpp_sum( 'flodom', zgjfl, ifl )   ! sums over the global domain
+         CALL mpp_sum( 'flodom', zgkfl, ifl )
       ENDIF
             
@@ -451,6 +451,6 @@
                 zgifl(jpnfl) , zgjfl(jpnfl) , zgkfl(jpnfl)   , STAT=flo_dom_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( flo_dom_alloc )
-      IF( flo_dom_alloc /= 0 )   CALL ctl_warn('flo_dom_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'flodom', flo_dom_alloc )
+      IF( flo_dom_alloc /= 0 )   CALL ctl_stop( 'STOP', 'flo_dom_alloc: failed to allocate arrays' )
    END FUNCTION flo_dom_alloc
 
Index: /NEMO/trunk/src/OCE/FLO/florst.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/florst.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/FLO/florst.F90	(revision 10425)
@@ -39,6 +39,6 @@
       ALLOCATE( iperproc(jpnij), STAT=flo_rst_alloc )
       !  
-      IF( lk_mpp             )   CALL mpp_sum ( flo_rst_alloc )
-      IF( flo_rst_alloc /= 0 )   CALL ctl_warn('flo_rst_alloc: failed to allocate arrays.')
+      CALL mpp_sum ( 'florst', flo_rst_alloc )
+      IF( flo_rst_alloc /= 0 )   CALL ctl_stop( 'STOP', 'flo_rst_alloc: failed to allocate arrays.' )
    END FUNCTION flo_rst_alloc
 
@@ -109,5 +109,5 @@
                ENDIF
             END DO
-            CALL mpp_sum( iperproc, jpnij )
+            CALL mpp_sum( 'florst', iperproc, jpnij )
             !
             IF(lwp) THEN
Index: /NEMO/trunk/src/OCE/FLO/flowri.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/flowri.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/FLO/flowri.F90	(revision 10425)
@@ -51,6 +51,6 @@
                 zlon(jpnfl) , zlat(jpnfl) , zdep(jpnfl) , STAT=flo_wri_alloc)
       !  
-      IF( lk_mpp             )   CALL mpp_sum ( flo_wri_alloc )
-      IF( flo_wri_alloc /= 0 )   CALL ctl_warn('flo_wri_alloc: failed to allocate arrays.')
+      CALL mpp_sum ( 'flowri', flo_wri_alloc )
+      IF( flo_wri_alloc /= 0 )   CALL ctl_stop( 'STOP', 'flo_wri_alloc: failed to allocate arrays.' )
    END FUNCTION flo_wri_alloc
 
@@ -153,10 +153,10 @@
       !Only proc 0 writes all positions : SUM of positions on all procs
       IF( lk_mpp ) THEN
-         CALL mpp_sum( zlon, jpnfl )   ! sums over the global domain
-         CALL mpp_sum( zlat, jpnfl )   ! sums over the global domain
-         CALL mpp_sum( zdep, jpnfl )   ! sums over the global domain
-         CALL mpp_sum( ztem, jpnfl )   ! sums over the global domain
-         CALL mpp_sum( zsal, jpnfl )   ! sums over the global domain
-         CALL mpp_sum( zrho, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', zlon, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', zlat, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', zdep, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', ztem, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', zsal, jpnfl )   ! sums over the global domain
+         CALL mpp_sum( 'flowri', zrho, jpnfl )   ! sums over the global domain
       ENDIF
 
Index: /NEMO/trunk/src/OCE/ICB/icb_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 10425)
@@ -190,5 +190,5 @@
       icb_alloc = icb_alloc + ill
 
-      IF( lk_mpp        )   CALL mpp_sum ( icb_alloc )
+      CALL mpp_sum ( 'icb_oce', icb_alloc )
       IF( icb_alloc > 0 )   CALL ctl_warn('icb_alloc: allocation of arrays failed')
       !
Index: /NEMO/trunk/src/OCE/ICB/icbclv.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbclv.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icbclv.F90	(revision 10425)
@@ -174,7 +174,7 @@
       !
       DO jn = 1, nclasses
-         CALL lbc_lnk( berg_grid%stored_ice(:,:,jn), 'T', 1._wp )
+         CALL lbc_lnk( 'icbclv', berg_grid%stored_ice(:,:,jn), 'T', 1._wp )
       END DO
-      CALL lbc_lnk( berg_grid%stored_heat, 'T', 1._wp )
+      CALL lbc_lnk( 'icbclv', berg_grid%stored_heat, 'T', 1._wp )
       !
       IF( nn_verbose_level > 0 .AND. icntmax > 1 )   WRITE(numicb,*) 'icb_clv: icnt=', icnt,' on', narea
Index: /NEMO/trunk/src/OCE/ICB/icbdia.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbdia.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icbdia.F90	(revision 10425)
@@ -161,5 +161,5 @@
          rsumbuf(2) = bergs_mass_start
          rsumbuf(3) = bits_mass_start
-         CALL mpp_sum( rsumbuf(1:3), 3 )
+         CALL mpp_sum( 'icbdia', rsumbuf(1:3), 3 )
          floating_mass_start = rsumbuf(1)
          bergs_mass_start = rsumbuf(2)
@@ -236,5 +236,5 @@
             rsumbuf(23) = zgrdd_bits_mass
             !
-            CALL mpp_sum( rsumbuf(1:23), 23)
+            CALL mpp_sum( 'icbdia', rsumbuf(1:23), 23)
             !
             stored_end                = rsumbuf( 1)
@@ -269,5 +269,5 @@
                nsumbuf(4+ik) = nbergs_calved_by_class(ik)
             END DO
-            CALL mpp_sum( nsumbuf(1:nclasses+4), nclasses+4 )
+            CALL mpp_sum( 'icbdia', nsumbuf(1:nclasses+4), nclasses+4 )
             !
             nbergs_end        = nsumbuf(1)
@@ -436,9 +436,9 @@
       IF( kt == nit000 ) THEN
          stored_start = SUM( berg_grid%stored_ice(:,:,:) )
-         IF( lk_mpp ) CALL mpp_sum( stored_start )
+         CALL mpp_sum( 'icbdia', stored_start )
          WRITE(numicb,'(a,es13.6,a)')   'icb_dia_income: initial stored mass=',stored_start,' kg'
          !
          stored_heat_start = SUM( berg_grid%stored_heat(:,:) )
-         IF( lk_mpp ) CALL mpp_sum( stored_heat_start )
+         CALL mpp_sum( 'icbdia', stored_heat_start )
          WRITE(numicb,'(a,es13.6,a)')    'icb_dia_income: initial stored heat=',stored_heat_start,' J'
       ENDIF
Index: /NEMO/trunk/src/OCE/ICB/icbini.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 10425)
@@ -114,6 +114,6 @@
          END DO
       END DO
-      CALL lbc_lnk( src_calving_hflx, 'T', 1._wp )
-      CALL lbc_lnk( src_calving     , 'T', 1._wp )
+      CALL lbc_lnk( 'icbini', src_calving_hflx, 'T', 1._wp )
+      CALL lbc_lnk( 'icbini', src_calving     , 'T', 1._wp )
 
       ! work out interior of processor from exchange array
@@ -335,5 +335,5 @@
       !
       ibergs = icb_utl_count()
-      IF( lk_mpp ) CALL mpp_sum(ibergs)
+      CALL mpp_sum('icbini', ibergs)
       WRITE(numicb,'(a,i6,a)') 'diamonds, icb_ini_gen: ',ibergs,' were generated'
       !
Index: /NEMO/trunk/src/OCE/ICB/icblbc.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icblbc.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icblbc.F90	(revision 10425)
@@ -551,5 +551,5 @@
             this => this%next
          ENDDO ! WHILE
-         CALL mpp_sum(i)
+         CALL mpp_sum('icblbc', i)
          IF( i .GT. 0 ) THEN
             WRITE( numicb,'(a,i4)') 'send_bergs_to_other_pes: # of bergs outside computational domain = ',i
Index: /NEMO/trunk/src/OCE/ICB/icbrst.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 10425)
@@ -141,6 +141,6 @@
       IF( lk_mpp ) THEN
          ! Only mpp_sum ibergs_in_file if we are reading from multiple restart files. 
-         IF( INDEX(iom_file(ncid)%name,'icebergs.nc' ) .EQ. 0 ) CALL mpp_sum(ibergs_in_file)
-         CALL mpp_sum(jn)
+         IF( INDEX(iom_file(ncid)%name,'icebergs.nc' ) .EQ. 0 ) CALL mpp_sum('icbrst', ibergs_in_file)
+         CALL mpp_sum('icbrst', jn)
       ENDIF
       IF( lwp )   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_read: there were',ibergs_in_file,   &
@@ -164,5 +164,5 @@
       ENDIF
       IF( lk_mpp ) THEN
-         CALL mpp_sum(ibase_err)
+         CALL mpp_sum('icbrst', ibase_err)
       ENDIF
       IF( ibase_err > 0 ) THEN
@@ -171,5 +171,5 @@
          ! all future icebergs numbers will be greater than the current global maximum
          IF( lk_mpp ) THEN
-            CALL mpp_max(imax_icb)
+            CALL mpp_max('icbrst', imax_icb)
          ENDIF
          num_bergs(1) = imax_icb - jpnij + narea
@@ -404,5 +404,5 @@
             WRITE(numout,'(2(a,i5))') 'icebergs, icb_rst_write: # bergs =',jn,' on PE',narea-1
          IF( lk_mpp ) THEN
-            CALL mpp_sum(jn)
+            CALL mpp_sum('icbrst', jn)
          ENDIF
          IF(lwp)   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_write: ', jn,   &
Index: /NEMO/trunk/src/OCE/ICB/icbutl.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbutl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ICB/icbutl.F90	(revision 10425)
@@ -78,11 +78,11 @@
       va_e(:,:) = 0._wp   ;   va_e(1:jpi,1:jpj) = vtau (:,:) * vmask(:,:,1) ! maybe mask useless because mask applied in sbcblk
       !
-      CALL lbc_lnk_icb( uo_e, 'U', -1._wp, 1, 1 )
-      CALL lbc_lnk_icb( vo_e, 'V', -1._wp, 1, 1 )
-      CALL lbc_lnk_icb( ff_e, 'F', +1._wp, 1, 1 )
-      CALL lbc_lnk_icb( ua_e, 'U', -1._wp, 1, 1 )
-      CALL lbc_lnk_icb( va_e, 'V', -1._wp, 1, 1 )
-      CALL lbc_lnk_icb( fr_e, 'T', +1._wp, 1, 1 )
-      CALL lbc_lnk_icb( tt_e, 'T', +1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', uo_e, 'U', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', vo_e, 'V', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', ff_e, 'F', +1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', ua_e, 'U', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', va_e, 'V', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', fr_e, 'T', +1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', tt_e, 'T', +1._wp, 1, 1 )
 #if defined key_si3
       hicth(:,:) = 0._wp ;  hicth(1:jpi,1:jpj) = hm_i (:,:)  
@@ -94,7 +94,7 @@
       ssh_e(:,:) = 0._wp ;  ssh_e(1:jpi, 1:jpj) = zssh_lead_m(:,:) * tmask(:,:,1)
       !
-      CALL lbc_lnk_icb( hicth, 'T', +1._wp, 1, 1 )
-      CALL lbc_lnk_icb( ui_e , 'U', -1._wp, 1, 1 )
-      CALL lbc_lnk_icb( vi_e , 'V', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', hicth, 'T', +1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', ui_e , 'U', -1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', vi_e , 'V', -1._wp, 1, 1 )
 #else
       ssh_e(:,:) = 0._wp ;  ssh_e(1:jpi, 1:jpj) = ssh_m(:,:) * tmask(:,:,1)
@@ -111,5 +111,5 @@
       ssh_e(0,jpj+1)     = ssh_e(1,jpj)
       ssh_e(jpi+1,jpj+1) = ssh_e(jpi,jpj)
-      CALL lbc_lnk_icb( ssh_e, 'T', +1._wp, 1, 1 )
+      CALL lbc_lnk_icb( 'icbutl', ssh_e, 'T', +1._wp, 1, 1 )
       !
    END SUBROUTINE icb_utl_copy
@@ -661,5 +661,5 @@
       ibergs = icb_utl_count()
       inbergs = ibergs
-      IF( lk_mpp )   CALL mpp_sum(inbergs)
+      CALL mpp_sum('icbutl', inbergs)
       IF( ibergs > 0 )   WRITE(numicb,'(a," there are",i5," bergs out of",i6," on PE ",i4)')   &
          &                                  cd_label, ibergs, inbergs, narea
Index: /NEMO/trunk/src/OCE/IOM/in_out_manager.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 10425)
@@ -122,4 +122,5 @@
    INTEGER ::   numtime         =   -1      !: logical unit for timing
    INTEGER ::   numout          =    6      !: logical unit for output print; Set to stdout to ensure any
+   INTEGER ::   numnul          =   -1      !: logical unit for /dev/null
       !                                     !  early output can be collected; do not change
    INTEGER ::   numnam_ref      =   -1      !: logical unit for reference namelist
Index: /NEMO/trunk/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/IOM/iom.F90	(revision 10425)
@@ -58,5 +58,5 @@
 #endif
    PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get
-   PUBLIC iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_put
+   PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_delay_rst, iom_put
    PUBLIC iom_use, iom_context_finalize
 
@@ -75,8 +75,8 @@
    END INTERFACE
    INTERFACE iom_getatt
-      MODULE PROCEDURE iom_g0d_iatt, iom_g0d_ratt, iom_g0d_catt
+      MODULE PROCEDURE iom_g0d_iatt, iom_g1d_iatt, iom_g0d_ratt, iom_g1d_ratt, iom_g0d_catt
    END INTERFACE
    INTERFACE iom_putatt
-      MODULE PROCEDURE iom_p0d_iatt, iom_p0d_ratt, iom_p0d_catt
+      MODULE PROCEDURE iom_p0d_iatt, iom_p1d_iatt, iom_p0d_ratt, iom_p1d_ratt, iom_p0d_catt
    END INTERFACE
    INTERFACE iom_rstput
@@ -286,9 +286,6 @@
 !Warn if variable is not in defined in rst_wfields
    IF(.NOT.llis_set) THEN
-      IF(lwp) THEN
-         write(numout,cform_err)
-         write(numout,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
-      ENDIF
-        nstop = nstop + 1
+      WRITE(ctmp1,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
+      CALL ctl_stop( 'iom_set_rstw_var_active:', ctmp1 )
    ENDIF
 #else
@@ -518,6 +515,6 @@
 
         IF( i-1 > max_rst_fields) THEN
-        IF(lwp) write(numout,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
-        nstop = nstop + 1
+           WRITE(ctmp1,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
+           CALL ctl_stop( 'iom_set_rst_vars:', ctmp1 )
         ENDIF
    END SUBROUTINE iom_set_rst_vars
@@ -634,5 +631,5 @@
 
 
-   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, kdlev )
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -644,5 +641,4 @@
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
       INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
-      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90) 
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
@@ -659,5 +655,4 @@
       LOGICAL               ::   llstop    ! local definition of ldstop
       LOGICAL               ::   lliof     ! local definition of ldiof
-      INTEGER               ::   iolib     ! library do we use to open the file
       INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
       INTEGER               ::   iln, ils  ! lengths of character
@@ -692,8 +687,4 @@
       ELSE                         ;   llstop = .TRUE.
       ENDIF
-      ! what library do we use to open the file?
-      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
-      ELSE                         ;   iolib = jpnf90
-      ENDIF
       ! are we using interpolation on the fly?
       IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof
@@ -713,9 +704,5 @@
       ENDIF
       ! which suffix should we use?
-      SELECT CASE (iolib)
-      CASE (jpnf90   ) ;   clsuffix = '.nc'
-      CASE DEFAULT     ;   clsuffix = ''
-         CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
-      END SELECT
+      clsuffix = '.nc'
       ! Add the suffix if needed
       iln = LEN_TRIM(clname)
@@ -802,9 +789,5 @@
       ENDIF
       IF( istop == nstop ) THEN   ! no error within this routine
-         SELECT CASE (iolib)
-         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, kdlev = kdlev )
-         CASE DEFAULT
-            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
-         END SELECT
+         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev )
       ENDIF
       !
@@ -839,9 +822,5 @@
          DO jf = i_s, i_e
             IF( iom_file(jf)%nfid > 0 ) THEN
-               SELECT CASE (iom_file(jf)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
-               CASE DEFAULT
-                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_close( jf )
                iom_file(jf)%nfid       = 0          ! free the id 
                IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed
@@ -896,12 +875,8 @@
                iiv = iiv + 1
                IF( iiv <= jpmax_vars ) THEN
-                  SELECT CASE (iom_file(kiomid)%iolib)
-                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz, kndims )
-                  CASE DEFAULT
-                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-                  END SELECT
+                  iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims )
                ELSE
                   CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
-                        &                         'increase the parameter jpmax_vars')
+                        &                      'increase the parameter jpmax_vars')
                ENDIF
                IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' ) 
@@ -962,9 +937,5 @@
                                     &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , &
                                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
-               CASE DEFAULT
-                  CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_get( kiomid, idvar, pvar, itime )
             ENDIF
          ENDIF
@@ -976,6 +947,6 @@
          CALL iom_swap( TRIM(cxios_context) )
 #else
-         nstop = nstop + 1 
-         clinfo = 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         CALL ctl_stop( 'iom_g0d', ctmp1 )
 #endif
       ENDIF
@@ -1122,12 +1093,4 @@
             IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
             IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
-         ENDIF
-         IF( luse_jattr ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   
-                ! Ok
-            CASE DEFAULT    
-               CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-            END SELECT
          ENDIF
 
@@ -1301,10 +1264,5 @@
             ENDIF
       
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
-               &                                         pv_r1d, pv_r2d, pv_r3d )
-            CASE DEFAULT
-               CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-            END SELECT
+            CALL iom_nf90_get( kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d )
 
             IF( istop == nstop ) THEN   ! no additional errors until this point...
@@ -1313,9 +1271,9 @@
                !--- overlap areas and extra hallows (mpp)
                IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
-                  CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+                  CALL lbc_lnk( 'iom', pv_r2d,'Z',-999.,'no0' )
                ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
                   ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
                   IF( icnt(3) == inlev ) THEN
-                     CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+                     CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
                   ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
                      DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
@@ -1342,5 +1300,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r3d)
             IF(idom /= jpdom_unknown ) then
-                CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+                CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
             ENDIF
          ELSEIF( PRESENT(pv_r2d) ) THEN
@@ -1349,5 +1307,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r2d)
             IF(idom /= jpdom_unknown ) THEN
-                CALL lbc_lnk(pv_r2d,'Z',-999.,'no0')
+                CALL lbc_lnk('iom', pv_r2d,'Z',-999.,'no0')
             ENDIF
          ELSEIF( PRESENT(pv_r1d) ) THEN
@@ -1364,6 +1322,6 @@
 !some final adjustments
       ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
-      IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
-      IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
+      IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( 'iom', pv_r2d,'Z',1. )
+      IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( 'iom', pv_r3d,'Z',1. )
 
       !--- Apply scale_factor and offset
@@ -1422,9 +1380,5 @@
                IF( iom_file(kiomid)%luld(idvar) ) THEN
                   IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN
-                     SELECT CASE (iom_file(kiomid)%iolib)
-                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
-                     CASE DEFAULT
-                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-                     END SELECT
+                     CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
                   ELSE
                      WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
@@ -1444,136 +1398,137 @@
    END SUBROUTINE iom_gettime
 
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_chkatt
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_chkatt( kiomid, cdatt, llok, ksize, cdvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
+      LOGICAL         , INTENT(  out)                 ::   llok      ! Error code
+      INTEGER         , INTENT(  out), OPTIONAL       ::   ksize     ! Size of the attribute array
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_chkatt( kiomid, cdatt, llok, ksize=ksize, cdvar=cdvar )
+      ENDIF
+      !
+   END SUBROUTINE iom_chkatt
 
    !!----------------------------------------------------------------------
    !!                   INTERFACE iom_getatt
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_g0d_iatt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      INTEGER         , INTENT(  out)                 ::   pvar      ! read field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g0d_iatt( kiomid, cdatt, katt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER               , INTENT(  out)           ::   katt0d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_g0d_iatt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_iatt
 
-   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      REAL(wp)        , INTENT(  out)                 ::   pvar      ! written field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g1d_iatt( kiomid, cdatt, katt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER, DIMENSION(:) , INTENT(  out)           ::   katt1d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_g1d_iatt
+
+   SUBROUTINE iom_g0d_ratt( kiomid, cdatt, patt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp)              , INTENT(  out)           ::   patt0d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_ratt
 
-   SUBROUTINE iom_g0d_catt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      CHARACTER(len=*), INTENT(  out)                 ::   pvar      ! written field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_g1d_ratt( kiomid, cdatt, patt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp), DIMENSION(:), INTENT(  out)           ::   patt1d    ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_getatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_g1d_ratt
+   
+   SUBROUTINE iom_g0d_catt( kiomid, cdatt, cdatt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      CHARACTER(len=*)      , INTENT(  out)           ::   cdatt0d   ! read field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_getatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_g0d_catt
+
 
    !!----------------------------------------------------------------------
    !!                   INTERFACE iom_putatt
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_p0d_iatt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      INTEGER         , INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p0d_iatt( kiomid, cdatt, katt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER               , INTENT(in   )           ::   katt0d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_p0d_iatt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt0d =  katt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_iatt
 
-   SUBROUTINE iom_p0d_ratt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      REAL(wp)        , INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p1d_iatt( kiomid, cdatt, katt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      INTEGER, DIMENSION(:) , INTENT(in   )           ::   katt1d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT    
-               CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  katt1d =  katt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_p1d_iatt
+
+   SUBROUTINE iom_p0d_ratt( kiomid, cdatt, patt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp)              , INTENT(in   )           ::   patt0d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt0d =  patt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_ratt
 
-   SUBROUTINE iom_p0d_catt( kiomid, cdatt, pvar, cdvar )
-      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
-      CHARACTER(len=*), INTENT(in   )                 ::   pvar      ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! Name of the variable
+   SUBROUTINE iom_p1d_ratt( kiomid, cdatt, patt1d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      REAL(wp), DIMENSION(:), INTENT(in   )           ::   patt1d    ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
       !
       IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) THEN
-            SELECT CASE (iom_file(kiomid)%iolib)
-            CASE (jpnf90   )   ;   IF( PRESENT(cdvar) ) THEN
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar )
-                                   ELSE
-                                      CALL iom_nf90_putatt( kiomid, cdatt, pvar )
-                                   ENDIF
-            CASE DEFAULT
-               CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' )
-            END SELECT
-         ENDIF
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt,  patt1d =  patt1d, cdvar=cdvar )
+      ENDIF
+   END SUBROUTINE iom_p1d_ratt
+   
+   SUBROUTINE iom_p0d_catt( kiomid, cdatt, cdatt0d, cdvar )
+      INTEGER               , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt     ! Name of the attribute
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt0d   ! written field
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar     ! Name of the variable
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 )   CALL iom_nf90_putatt( kiomid, cdatt, cdatt0d = cdatt0d, cdvar=cdvar )
       ENDIF
    END SUBROUTINE iom_p0d_catt
+
 
    !!----------------------------------------------------------------------
@@ -1604,9 +1559,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
             ENDIF
          ENDIF
@@ -1638,9 +1589,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
             ENDIF
          ENDIF
@@ -1672,9 +1619,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
             ENDIF
          ENDIF
@@ -1706,9 +1649,5 @@
             IF( iom_file(kiomid)%nfid > 0 ) THEN
                ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
-               SELECT CASE (iom_file(kiomid)%iolib)
-               CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
-               CASE DEFAULT     
-                  CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
-               END SELECT
+               CALL iom_nf90_rstput( kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
             ENDIF
          ENDIF
@@ -1716,4 +1655,50 @@
    END SUBROUTINE iom_rp3d
 
+
+  SUBROUTINE iom_delay_rst( cdaction, cdcpnt, kncid )
+      !!---------------------------------------------------------------------
+      !!   Routine iom_delay_rst: used read/write restart related to mpp_delay
+      !!
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   ) ::   cdaction        !
+      CHARACTER(len=*), INTENT(in   ) ::   cdcpnt
+      INTEGER         , INTENT(in   ) ::   kncid
+      !
+      INTEGER  :: ji
+      INTEGER  :: indim
+      LOGICAL  :: llattexist
+      REAL(wp), ALLOCATABLE, DIMENSION(:) ::   zreal1d
+      !!---------------------------------------------------------------------
+      !
+      !                                      ===================================
+      IF( TRIM(cdaction) == 'READ' ) THEN   ! read restart related to mpp_delay !
+         !                                   ===================================
+         DO ji = 1, nbdelay
+            IF ( c_delaycpnt(ji) == cdcpnt ) THEN
+               CALL iom_chkatt( kncid, 'DELAY_'//c_delaylist(ji), llattexist, indim )
+               IF( llattexist )  THEN
+                  ALLOCATE( todelay(ji)%z1d(indim) )
+                  CALL iom_getatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) )
+                  ndelayid(ji) = 0   ! set to 0 to specify that the value was read in the restart
+               ENDIF
+           ENDIF
+         END DO
+         !                                   ====================================
+      ELSE                                  ! write restart related to mpp_delay !
+         !                                   ====================================
+         DO ji = 1, nbdelay   ! save only ocean delayed global communication variables
+            IF ( c_delaycpnt(ji) == cdcpnt ) THEN
+               IF( ASSOCIATED(todelay(ji)%z1d) ) THEN
+                  CALL mpp_delay_rcv(ji)   ! make sure %z1d is received
+                  CALL iom_putatt( kncid, 'DELAY_'//c_delaylist(ji), todelay(ji)%z1d(:) )
+               ENDIF
+            ENDIF
+         END DO
+         !
+      ENDIF
+      
+   END SUBROUTINE iom_delay_rst
+  
+   
 
    !!----------------------------------------------------------------------
@@ -1971,6 +1956,6 @@
          SELECT CASE ( cdgrd )
          CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
-         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. )
-         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
+         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( 'iom', zmask, 'U', 1. )
+         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( 'iom', zmask, 'V', 1. )
          CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
          END SELECT
@@ -2015,5 +2000,5 @@
       !
       z_fld(:,:) = 1._wp
-      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold
+      CALL lbc_lnk( 'iom', z_fld, cdgrd, -1. )    ! Working array for location of northfold
       !
       ! Cell vertices that can be defined
@@ -2033,6 +2018,6 @@
       ! Cell vertices on boundries
       DO jn = 1, 4
-         CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
-         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
       END DO
       !
Index: /NEMO/trunk/src/OCE/IOM/iom_def.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 10425)
@@ -23,8 +23,4 @@
    INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only
    INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !: 
-
-   INTEGER, PARAMETER, PUBLIC ::   jpnf90      = 101      !: Use nf90 library
-
-   INTEGER, PARAMETER, PUBLIC ::   jprstlib  = jpnf90     !: restarts io library
 
    INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
@@ -55,5 +51,4 @@
       CHARACTER(LEN=240)                        ::   name     !: name of the file
       INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
-      INTEGER                                   ::   iolib    !: library used to read the file (jpnf90 or new formats,
                                                               !: jpioipsl option has been removed)
       INTEGER                                   ::   nvars    !: number of identified varibles in the file
Index: /NEMO/trunk/src/OCE/IOM/iom_nf90.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 10425)
@@ -30,14 +30,8 @@
 
    PUBLIC iom_nf90_open  , iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput
-   PUBLIC iom_nf90_getatt, iom_nf90_putatt
+   PUBLIC iom_nf90_chkatt, iom_nf90_getatt, iom_nf90_putatt
 
    INTERFACE iom_nf90_get
       MODULE PROCEDURE iom_nf90_g0d, iom_nf90_g123d
-   END INTERFACE
-   INTERFACE iom_nf90_getatt
-      MODULE PROCEDURE iom_nf90_giatt, iom_nf90_gratt, iom_nf90_gcatt
-   END INTERFACE
-   INTERFACE iom_nf90_putatt
-      MODULE PROCEDURE iom_nf90_piatt, iom_nf90_pratt, iom_nf90_pcatt
    END INTERFACE
    INTERFACE iom_nf90_rstput
@@ -129,14 +123,12 @@
                CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo)
             ENDIF
-            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL, idmy                     ), clinfo)
+            CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL,                   idmy ), clinfo)
             ! define dimensions
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x'      , kdompar(1,1)  , idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y'      , kdompar(2,1)  , idmy ), clinfo)
-            IF( PRESENT(kdlev) ) THEN
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'numcat' , ilevels    , idmy ), clinfo)
-            ELSE
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev', ilevels    , idmy ), clinfo)
-            ENDIF
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo)
+            CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',            jpk, idmy ), clinfo)
             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
+            IF( PRESENT(kdlev) )   &
+               CALL iom_nf90_check(NF90_DEF_DIM( if90id,    'numcat',          kdlev, idmy ), clinfo)
             ! global attributes
             CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
@@ -165,5 +157,4 @@
          iom_file(kiomid)%name   = TRIM(cdname)
          iom_file(kiomid)%nfid   = if90id
-         iom_file(kiomid)%iolib  = jpnf90
          iom_file(kiomid)%nvars  = 0
          iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
@@ -329,13 +320,10 @@
    END SUBROUTINE iom_nf90_g123d
 
-   !!----------------------------------------------------------------------
-   !!                   INTERFACE iom_nf90_getatt
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE iom_nf90_giatt( kiomid, cdatt, pv_i0d, cdvar)
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_giatt  ***
-      !!
-      !! ** Purpose : read an integer attribute with NF90
+
+   SUBROUTINE iom_nf90_chkatt( kiomid, cdatt, llok, ksize, cdvar )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_chkatt  ***
+      !!
+      !! ** Purpose : check existence of attribute with NF90
       !!              (either a global attribute (default) or a variable
       !!               attribute if optional variable name is supplied (cdvar))
@@ -343,7 +331,54 @@
       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file
       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name
-      INTEGER         , INTENT(  out) ::   pv_i0d   ! read field
+      LOGICAL         , INTENT(  out) ::   llok     ! error code
+      INTEGER         , INTENT(  out), OPTIONAL     &
+                      &               ::   ksize    ! attribute size
       CHARACTER(len=*), INTENT(in   ), OPTIONAL     &
                       &               ::   cdvar    ! name of the variable
+      !
+      INTEGER                         ::   if90id   ! temporary integer
+      INTEGER                         ::   isize    ! temporary integer
+      INTEGER                         ::   ivarid   ! NetCDF variable Id
+      !---------------------------------------------------------------------
+      !
+      if90id = iom_file(kiomid)%nfid
+      IF( PRESENT(cdvar) ) THEN
+         ! check the variable exists in the file
+         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
+         IF( llok ) &
+            ! check the variable has the attribute required
+            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt, len=isize ) == nf90_noerr
+      ELSE
+         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt, len=isize ) == nf90_noerr
+      ENDIF
+      !
+      IF( PRESENT(ksize) ) ksize = isize
+      !
+      IF( .not. llok) &
+         CALL ctl_warn('iom_nf90_chkatt: no attribute '//cdatt//' found')
+      !
+   END SUBROUTINE iom_nf90_chkatt
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_nf90_getatt
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE iom_nf90_getatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_getatt  ***
+      !!
+      !! ** Purpose : read an attribute with NF90
+      !!              (either a global attribute (default) or a variable
+      !!               attribute if optional variable name is supplied (cdvar))
+      !!-----------------------------------------------------------------------
+      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name
+      INTEGER               , INTENT(  out), OPTIONAL ::   katt0d   ! read scalar integer
+      INTEGER, DIMENSION(:) , INTENT(  out), OPTIONAL ::   katt1d   ! read 1d array integer
+      REAL(wp)              , INTENT(  out), OPTIONAL ::   patt0d   ! read scalar  real
+      REAL(wp), DIMENSION(:), INTENT(  out), OPTIONAL ::   patt1d   ! read 1d array real
+      CHARACTER(len=*)      , INTENT(  out), OPTIONAL ::   cdatt0d  ! read character
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable
       !
       INTEGER                         ::   if90id   ! temporary integer
@@ -361,5 +396,5 @@
             llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
          ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
+            CALL ctl_warn('iom_nf90_getatt: no variable '//TRIM(cdvar)//' found')
          ENDIF
       ELSE
@@ -369,272 +404,91 @@
       !
       IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo)
+         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+         IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt0d), clinfo)
+         IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  katt1d), clinfo)
+         IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt0d), clinfo)
+         IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values =  patt1d), clinfo)
+         IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values = cdatt0d), clinfo)
       ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_i0d = -999
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_giatt
-
-
-   SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_gratt  ***
-      !!
-      !! ** Purpose : read a real attribute with NF90
+         CALL ctl_warn('iom_nf90_getatt: no attribute '//TRIM(cdatt)//' found')
+         IF(PRESENT( katt0d))    katt0d    = -999
+         IF(PRESENT( katt1d))    katt1d(:) = -999
+         IF(PRESENT( patt0d))    patt0d    = -999._wp
+         IF(PRESENT( patt1d))    patt1d(:) = -999._wp
+         IF(PRESENT(cdatt0d))   cdatt0d    = '!'
+      ENDIF
+      !
+   END SUBROUTINE iom_nf90_getatt
+
+
+   SUBROUTINE iom_nf90_putatt( kiomid, cdatt, katt0d, katt1d, patt0d, patt1d, cdatt0d, cdvar)
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_nf90_putatt  ***
+      !!
+      !! ** Purpose : write an attribute with NF90
       !!              (either a global attribute (default) or a variable
       !!               attribute if optional variable name is supplied (cdvar))
       !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      REAL(wp)                  , INTENT(  out) ::   pv_r0d   ! read field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
+      INTEGER               , INTENT(in   )           ::   kiomid   ! Identifier of the file
+      CHARACTER(len=*)      , INTENT(in   )           ::   cdatt    ! attribute name
+      INTEGER               , INTENT(in   ), OPTIONAL ::   katt0d   ! read scalar integer
+      INTEGER, DIMENSION(:) , INTENT(in   ), OPTIONAL ::   katt1d   ! read 1d array integer
+      REAL(wp)              , INTENT(in   ), OPTIONAL ::   patt0d   ! read scalar  real
+      REAL(wp), DIMENSION(:), INTENT(in   ), OPTIONAL ::   patt1d   ! read 1d array real
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdatt0d  ! read character
+      CHARACTER(len=*)      , INTENT(in   ), OPTIONAL ::   cdvar    ! name of the variable
+      !
+      INTEGER                         ::   if90id   ! temporary integer
+      INTEGER                         ::   ivarid   ! NetCDF variable Id
+      INTEGER                         ::   isize    ! Attribute size
+      INTEGER                         ::   itype    ! Attribute type
+      LOGICAL                         ::   llok     ! temporary logical
+      LOGICAL                         ::   llatt     ! temporary logical
+      LOGICAL                         ::   lldata   ! temporary logical
+      CHARACTER(LEN=100)              ::   clinfo   ! info character
       !---------------------------------------------------------------------
       !
       if90id = iom_file(kiomid)%nfid
       IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( llok ) THEN
-            ! check the variable has the attribute required
-            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
-         ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
+         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! is the variable in the file?
+         IF( .NOT. llok ) THEN
+            CALL ctl_warn('iom_nf90_putatt: no variable '//TRIM(cdvar)//' found'   &
+               &        , '                 no attribute '//cdatt//' written' )
+            RETURN
          ENDIF
       ELSE
-         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
          ivarid = NF90_GLOBAL
       ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo)
-      ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_r0d = -999._wp
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_gratt
-
-
-   SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_gcatt  ***
-      !!
-      !! ** Purpose : read a character attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      CHARACTER(len=*)          , INTENT(  out) ::   pv_c0d   ! read field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( llok ) THEN
-            ! check the variable has the attribute required
-            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr
-         ELSE
-            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr
-         ivarid = NF90_GLOBAL
-      ENDIF
-!
-      IF( llok) THEN
-         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gcatt: '//TRIM(cdatt)
-         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo)
-      ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found')
-         pv_c0d = '!'
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_gcatt
-
-
-   !!----------------------------------------------------------------------
-   !!                   INTERFACE iom_nf90_putatt
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE iom_nf90_piatt( kiomid, cdatt, pv_i0d, cdvar)
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_piatt  ***
-      !!
-      !! ** Purpose : write an integer attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name
-      INTEGER         , INTENT(in   ) ::   pv_i0d   ! write field
-      CHARACTER(len=*), INTENT(in   ), OPTIONAL     &
-                      &               ::   cdvar    ! name of the variable
-      !
-      INTEGER                         ::   if90id   ! temporary integer
-      INTEGER                         ::   ivarid   ! NetCDF variable Id
-      LOGICAL                         ::   llok     ! temporary logical
-      LOGICAL                         ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100)              ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
+      llatt = NF90_Inquire_attribute(if90id, ivarid, cdatt, len = isize, xtype = itype ) == nf90_noerr
+      !
+      ! trick: irec used to know if the file is in define mode or not
+      lldata = iom_file(kiomid)%irec /= -1   ! default: go back in define mode if in data mode
+      IF( lldata .AND. llatt ) THEN          ! attribute already there. Do we really need to go back in define mode?
+         ! do we have the appropriate type?
+         IF(PRESENT( katt0d) .OR. PRESENT( katt1d))   llok = itype == NF90_INT
+         IF(PRESENT( patt0d) .OR. PRESENT( patt1d))   llok = itype == NF90_DOUBLE
+         IF(PRESENT(cdatt0d)                      )   llok = itype == NF90_CHAR
+         ! and do we have the appropriate size?
+         IF(PRESENT( katt0d))   llok = llok .AND. isize == 1
+         IF(PRESENT( katt1d))   llok = llok .AND. isize == SIZE(katt1d)
+         IF(PRESENT( patt0d))   llok = llok .AND. isize == 1
+         IF(PRESENT( patt1d))   llok = llok .AND. isize == SIZE(patt1d)
+         IF(PRESENT(cdatt0d))   llok = llok .AND. isize == LEN_TRIM(cdatt0d)
          !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_piatt
-
-
-   SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_pratt  ***
-      !!
-      !! ** Purpose : write a real attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      REAL(wp)                  , INTENT(in   ) ::   pv_r0d   ! write field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      LOGICAL            ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
-         !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_pratt
-
-
-   SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar )
-      !!-----------------------------------------------------------------------
-      !!                  ***  ROUTINE  iom_nf90_pcatt  ***
-      !!
-      !! ** Purpose : write a character attribute with NF90
-      !!              (either a global attribute (default) or a variable
-      !!               attribute if optional variable name is supplied (cdvar))
-      !!-----------------------------------------------------------------------
-      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name
-      CHARACTER(len=*)          , INTENT(in   ) ::   pv_c0d   ! write field
-      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable
-      !
-      INTEGER            ::   if90id   ! temporary integer
-      INTEGER            ::   ivarid   ! NetCDF variable Id
-      LOGICAL            ::   llok     ! temporary logical
-      LOGICAL            ::   lenddef  ! temporary logical
-      CHARACTER(LEN=100) ::   clinfo   ! info character
-      !---------------------------------------------------------------------
-      !
-      if90id = iom_file(kiomid)%nfid
-      lenddef = .false.
-      IF( PRESENT(cdvar) ) THEN
-         ! check the variable exists in the file
-         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr
-         IF( .NOT. llok ) THEN
-            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found')
-         ENDIF
-      ELSE
-         llok = .true.
-         ivarid = NF90_GLOBAL
-      ENDIF
-      !
-      IF( llok) THEN
-         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt)
-         IF( iom_file(kiomid)%irec /= -1 ) THEN   
-            ! trick: irec used to know if the file is in define mode or not
-            ! if it is not then temporarily put it into define mode
-            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)
-            lenddef = .true.
-         ENDIF
-         !
-         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo)
-         !
-         IF( lenddef ) THEN   
-            ! file was in data mode on entry; put it back in that mode
-            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)
-         ENDIF
-      ELSE
-         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written')
-      ENDIF
-      !
-   END SUBROUTINE iom_nf90_pcatt
+         lldata = .NOT. llok
+      ENDIF
+      !
+      clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)
+      IF(lldata)   CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo)   ! leave data mode to define mode
+      !
+      IF(PRESENT( katt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt0d) , clinfo)
+      IF(PRESENT( katt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       katt1d) , clinfo)
+      IF(PRESENT( patt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt0d) , clinfo)
+      IF(PRESENT( patt1d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values =       patt1d) , clinfo)
+      IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values = trim(cdatt0d)), clinfo)
+      !
+      IF(lldata)   CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo)   ! leave define mode to data mode
+      !
+   END SUBROUTINE iom_nf90_putatt
 
 
@@ -693,5 +547,5 @@
       INTEGER, DIMENSION(4) :: idimid               ! dimensions id
       CHARACTER(LEN=256)    :: clinfo               ! info character
-      CHARACTER(LEN= 12), DIMENSION(4) :: cltmp     ! temporary character
+      CHARACTER(LEN= 12), DIMENSION(5) :: cltmp     ! temporary character
       INTEGER               :: if90id               ! nf90 file identifier
       INTEGER               :: idmy                 ! dummy variable
@@ -704,4 +558,5 @@
       !                                             ! when appropriate (currently chunking is applied to 4d fields only)
       INTEGER               :: idlv                 ! local variable
+      INTEGER               :: idim3                ! id of the third dimension
       !---------------------------------------------------------------------
       !
@@ -717,9 +572,5 @@
          ENDIF
          ! define the dimension variables if it is not already done
-         IF(iom_file(kiomid)%nlev == jpk ) THEN
-          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /)
-         ELSE
-          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'numcat      ', 'time_counter' /)
-         ENDIF
+         cltmp = (/ 'nav_lon', 'nav_lat', 'nav_lev', 'time_counter', 'numcat' /)
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
          CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
@@ -729,6 +580,13 @@
          iom_file(kiomid)%nvars       = 4
          iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
-         iom_file(kiomid)%cn_var(1:4) = cltmp
-         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)  
+         iom_file(kiomid)%cn_var(1:4) = cltmp(1:4)
+         iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
+         IF( NF90_INQ_DIMID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN   ! add a 5th variable corresponding to the 5th dimension
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(5)), NF90_FLOAT , (/ 5 /), iom_file(kiomid)%nvid(5) ), clinfo)
+            iom_file(kiomid)%nvars     = 5
+            iom_file(kiomid)%luld(5)   = .FALSE.
+            iom_file(kiomid)%cn_var(5) = cltmp(5)
+            iom_file(kiomid)%ndims(5)  = 1
+         ENDIF
          ! trick: defined to 0 to say that dimension variables are defined but not yet written
          iom_file(kiomid)%dimsz(1, 1)  = 0   
@@ -752,15 +610,23 @@
          ! variable definition
          IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
-         ELSEIF( PRESENT(pv_r1d) ) THEN   ;   idims = 2   ;   idimid(1:idims) = (/    3,4/)
+         ELSEIF( PRESENT(pv_r1d) ) THEN
+            IF( SIZE(pv_r1d,1) == jpk ) THEN   ;   idim3 = 3
+            ELSE                               ;   idim3 = 5
+            ENDIF
+                                              idims = 2   ;   idimid(1:idims) = (/idim3,4/)
          ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
-         ELSEIF( PRESENT(pv_r3d) ) THEN   ;   idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
+         ELSEIF( PRESENT(pv_r3d) ) THEN
+            IF( SIZE(pv_r3d,3) == jpk ) THEN   ;   idim3 = 3
+            ELSE                               ;   idim3 = 5
+            ENDIF
+                                              idims = 4   ;   idimid(1:idims) = (/1,2,idim3,4/)
          ENDIF
          IF( PRESENT(ktype) ) THEN   ! variable external type
             SELECT CASE (ktype)
-            CASE (jp_r8)  ;   itype = NF90_DOUBLE
-            CASE (jp_r4)  ;   itype = NF90_FLOAT
-            CASE (jp_i4)  ;   itype = NF90_INT
-            CASE (jp_i2)  ;   itype = NF90_SHORT
-            CASE (jp_i1)  ;   itype = NF90_BYTE
+            CASE (jp_r8)   ;   itype = NF90_DOUBLE
+            CASE (jp_r4)   ;   itype = NF90_FLOAT
+            CASE (jp_i4)   ;   itype = NF90_INT
+            CASE (jp_i2)   ;   itype = NF90_SHORT
+            CASE (jp_i1)   ;   itype = NF90_BYTE
             CASE DEFAULT   ;   CALL ctl_stop( TRIM(clinfo)//' unknown variable type' )
             END SELECT
@@ -834,10 +700,7 @@
                CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lat'     , idmy )         , clinfo )
                CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo )
-               IF(iom_file(kiomid)%nlev == jpk ) THEN 
-                  !NEMO
-                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo )
-                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo )
-               ELSE
-                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'numcat'     , idmy ), clinfo)
+               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo )
+               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo )
+               IF( NF90_INQ_VARID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN
                   CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, (/ (idlv, idlv = 1,iom_file(kiomid)%nlev) /)), clinfo )
                ENDIF
Index: /NEMO/trunk/src/OCE/IOM/restart.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/restart.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/IOM/restart.F90	(revision 10425)
@@ -28,4 +28,5 @@
    USE iom             ! I/O module
    USE diurnal_bulk
+   USE lib_mpp         ! distribued memory computing library
 
    IMPLICIT NONE
@@ -97,8 +98,5 @@
                WRITE(numout,*)
                IF(.NOT.lwxios) THEN
-                  SELECT CASE ( jprstlib )
-                  CASE DEFAULT         ;   WRITE(numout,*)                            &
-                      '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
-                  END SELECT
+                  WRITE(numout,*) '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
                   IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
                   IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
@@ -109,5 +107,5 @@
             !
             IF(.NOT.lwxios) THEN
-               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib )
+               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. )
             ELSE
 #if defined key_iomput
@@ -137,5 +135,5 @@
       !!                   ***  ROUTINE rstwrite  ***
       !!                     
-      !! ** Purpose :   Write restart fields in the format corresponding to jprstlib
+      !! ** Purpose :   Write restart fields in NetCDF format
       !!
       !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
@@ -146,4 +144,5 @@
                      IF(lwxios) CALL iom_swap(      cwxios_context          )
                      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step
+                     CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
 
       IF ( .NOT. ln_diurnal_only ) THEN
@@ -197,10 +196,9 @@
       !!                   ***  ROUTINE rst_read_open  ***
       !! 
-      !! ** Purpose :   Open read files for restart (format fixed by jprstlib )
+      !! ** Purpose :   Open read files for NetCDF restart
       !! 
       !! ** 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
@@ -210,7 +208,5 @@
          IF(lwp) THEN                                             ! Contol prints
             WRITE(numout,*)
-            SELECT CASE ( jprstlib )
-            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
-            END SELECT
+            WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
             IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
             WRITE(numout,*) '~~~~~~~~'
@@ -219,5 +215,5 @@
          clpath = TRIM(cn_ocerst_indir)
          IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt )
+         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror )
 ! 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
@@ -246,5 +242,5 @@
       !!                   ***  ROUTINE rst_read  ***
       !! 
-      !! ** Purpose :   Read files for restart (format fixed by jprstlib )
+      !! ** Purpose :   Read files for NetCDF restart
       !! 
       !! ** Method  :   Read in restart.nc file fields which are necessary for restart
@@ -263,4 +259,6 @@
       ENDIF
 
+      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
+      
       ! Diurnal DSST 
       IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
Index: /NEMO/trunk/src/OCE/LBC/lbc_lnk_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbc_lnk_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbc_lnk_generic.h90	(revision 10425)
@@ -46,9 +46,10 @@
 
 #if defined MULTI
-   SUBROUTINE ROUTINE_LNK( ptab, cd_nat, psgn, kfld, cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, cd_mpp, pval )
       INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
 #else
-   SUBROUTINE ROUTINE_LNK( ptab, cd_nat, psgn      , cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , cd_mpp, pval )
 #endif
+      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
       CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
@@ -77,10 +78,5 @@
       ! ------------------------------- !
       !
-      IF( PRESENT( cd_mpp ) ) THEN     !==  halos filled with inner values  ==!
-         !
-         ! only fill the overlap area and extra allows 
-         ! this is in mpp case. In this module, just do nothing
-         !
-      ELSE                             !==  standard close or cyclic treatment  ==!
+      IF( .NOT. PRESENT( cd_mpp ) ) THEN  !==  standard close or cyclic treatment  ==!
          !
          DO jf = 1, ipf                   ! number of arrays to be treated
Index: /NEMO/trunk/src/OCE/LBC/lbc_lnk_multi_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 10425)
@@ -14,8 +14,10 @@
 #   define PTR_ptab              pt4d
 #endif
-   SUBROUTINE ROUTINE_MULTI( pt1, cdna1, psgn1, pt2, cdna2, psgn2, pt3, cdna3, psgn3   &
+   SUBROUTINE ROUTINE_MULTI( cdname                                                    &
+      &                    , 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)
       !!---------------------------------------------------------------------
+      CHARACTER(len=*)   ,                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
       ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) ::   pt1     ! arrays on which the lbc is applied
       ARRAY_TYPE(:,:,:,:), OPTIONAL, TARGET, INTENT(inout) ::   pt2  ,  pt3  , pt4  , pt5  , pt6  , pt7  , pt8  , pt9
@@ -48,5 +50,5 @@
       IF( PRESENT(psgn9) )   CALL ROUTINE_LOAD( pt9, cdna9, psgn9, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
       !
-      CALL lbc_lnk_ptr( ptab_ptr, cdna_ptr, psgn_ptr, kfld, cd_mpp, pval )
+      CALL lbc_lnk_ptr( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, cd_mpp, pval )
       !
    END SUBROUTINE ROUTINE_MULTI
Index: /NEMO/trunk/src/OCE/LBC/lbc_nfd_ext_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 10425)
@@ -106,5 +106,5 @@
                      ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-1-jh,:,:,jf)
                   END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(1,ipj-1-jh,:,:,jf)
+                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-1-jh,:,:,jf)
                END DO
             CASE ( 'V' )                               ! V-point
@@ -125,5 +125,5 @@
                      ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
                   END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(1,ipj-2-jh,:,:,jf)
+                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-2-jh,:,:,jf)
                END DO
                DO ji = jpiglo/2+1, jpiglo-1
Index: /NEMO/trunk/src/OCE/LBC/lbc_nfd_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbc_nfd_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbc_nfd_generic.h90	(revision 10425)
@@ -129,5 +129,5 @@
                   ARRAY_IN(ji,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-1,:,:,jf)
                END DO
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(1,ipj-1,:,:,jf)
+               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(jpiglo-2,ipj-1,:,:,jf)
             CASE ( 'V' )                               ! V-point
                DO ji = 1, jpiglo
@@ -144,5 +144,5 @@
                   ARRAY_IN(ji,ipj  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2,:,:,jf)
                END DO
-               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(1,ipj-2,:,:,jf)
+               ARRAY_IN(jpiglo,ipj,:,:,jf) = SGN_IN(jf)   * ARRAY_IN(jpiglo-2,ipj-2,:,:,jf)
                DO ji = jpiglo/2+1, jpiglo-1
                   iju = jpiglo-ji
Index: /NEMO/trunk/src/OCE/LBC/lbc_nfd_nogather_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 10425)
@@ -8,6 +8,4 @@
 #      define K_SIZE(ptab)             1
 #      define L_SIZE(ptab)             1
-#      define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_2D),INTENT(inout)::ptab2(f)
-#      define ARRAY2_IN(i,j,k,l,f)     ptab2(f)%pt2d(i,j)
 #   endif
 #   if defined DIM_3d
@@ -16,6 +14,4 @@
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
 #      define L_SIZE(ptab)             1
-#      define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_3D),INTENT(inout)::ptab2(f)
-#      define ARRAY2_IN(i,j,k,l,f)     ptab2(f)%pt3d(i,j,k)
 #   endif
 #   if defined DIM_4d
@@ -24,7 +20,8 @@
 #      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
 #      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#      define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_4D),INTENT(inout)::ptab2(f)
-#      define ARRAY2_IN(i,j,k,l,f)     ptab2(f)%pt4d(i,j,k,l)
-#   endif
+#   endif
+#   define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_4D),INTENT(inout)::ptab2(f)
+#   define J_SIZE(ptab2)            SIZE(ptab2(1)%pt4d,2)
+#   define ARRAY2_IN(i,j,k,l,f)     ptab2(f)%pt4d(i,j,k,l)
 #else
 !                          !==  IN: ptab is an array  ==!
@@ -36,5 +33,4 @@
 #      define K_SIZE(ptab)          1
 #      define L_SIZE(ptab)          1
-#      define ARRAY2_IN(i,j,k,l,f)  ptab2(i,j)
 #   endif
 #   if defined DIM_3d
@@ -42,5 +38,4 @@
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          1
-#      define ARRAY2_IN(i,j,k,l,f)  ptab2(i,j,k)
 #   endif
 #   if defined DIM_4d
@@ -48,6 +43,7 @@
 #      define K_SIZE(ptab)          SIZE(ptab,3)
 #      define L_SIZE(ptab)          SIZE(ptab,4)
-#      define ARRAY2_IN(i,j,k,l,f)  ptab2(i,j,k,l)
-#   endif
+#   endif
+#   define ARRAY2_IN(i,j,k,l,f)  ptab2(i,j,k,l)
+#   define J_SIZE(ptab2)             SIZE(ptab2,2)
 #   define ARRAY_TYPE(i,j,k,l,f)     REAL(wp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
 #   define ARRAY2_TYPE(i,j,k,l,f)    REAL(wp),INTENT(inout)::ARRAY2_IN(i,j,k,l,f)
@@ -69,17 +65,28 @@
       INTEGER  ::    ji,  jj,   jk,     jl,   jh,  jf   ! dummy loop indices
       INTEGER  ::   ipi, ipj,  ipk,    ipl,  ipf        ! dimension of the input array
-      INTEGER  ::   ijt, iju, ijpj, ijpjm1, ijta, ijua, jia, startloop, endloop
+      INTEGER  ::   ijt, iju, ijpj, ijpjp1, ijta, ijua, jia, startloop, endloop
+      LOGICAL  ::   l_fast_exchanges
       !!----------------------------------------------------------------------
-      ipk = K_SIZE(ptab)   ! 3rd dimension
+      ipj = J_SIZE(ptab2)  ! 2nd dimension of input array
+      ipk = K_SIZE(ptab)   ! 3rd dimension of output array
       ipl = L_SIZE(ptab)   ! 4th    -
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
+      ! Security check for further developments
+      IF ( ipf > 1 ) THEN
+        write(6,*) 'lbc_nfd_nogather: multiple fields not allowed. Revise implementation' 
+        write(6,*) 'You should not be there...' 
+        STOP
+      ENDIF
       !
-      SELECT CASE ( jpni )
-      CASE ( 1 )     ;   ijpj = nlcj      ! 1 proc only  along the i-direction
-      CASE DEFAULT   ;   ijpj = 4         ! several proc along the i-direction
-      END SELECT
-      ijpjm1 = ijpj-1
-      !
+      ijpj   = 1    ! index of first modified line 
+      ijpjp1 = 2    ! index + 1
+      
+      ! 2nd dimension determines exchange speed
+      IF (ipj == 1 ) THEN
+        l_fast_exchanges = .TRUE.
+      ELSE
+        l_fast_exchanges = .FALSE.
+      ENDIF
       !
       DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
@@ -96,32 +103,40 @@
                ENDIF
                !
-               DO ji = startloop, nlci
-                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                  ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj-2,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = startloop, nlci
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF( nimpp == 1 ) THEN
-                  ARRAY_IN(1,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(3,ijpj-2,:,:,jf)
-               ENDIF
-               !
-               IF( nimpp >= jpiglo/2+1 ) THEN
-                  startloop = 1
-               ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
-                  startloop = jpiglo/2+1 - nimpp + 1
-               ELSE
-                  startloop = nlci + 1
-               ENDIF
-               IF( startloop <= nlci ) THEN
-                  DO ji = startloop, nlci
-                     ijt  = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                     jia  = ji + nimpp - 1
-                     ijta = jpiglo - jia + 2
-                     IF( ijta >= startloop+nimpp-1 .AND. ijta < jia ) THEN
-                        ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(ijta-nimpp+1,ijpjm1,:,:,jf)
-                     ELSE
-                        ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpjm1,:,:,jf)
-                     ENDIF
-                  END DO
-               ENDIF
-               !
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     ARRAY_IN(1,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(3,nlcj-2,jk,jl,jf)
+                  END DO; END DO
+               ENDIF
+               !
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  IF( nimpp >= jpiglo/2+1 ) THEN
+                     startloop = 1
+                  ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
+                     startloop = jpiglo/2+1 - nimpp + 1
+                  ELSE
+                     startloop = nlci + 1
+                  ENDIF
+                  IF( startloop <= nlci ) THEN
+                     DO jl = 1, ipl; DO jk = 1, ipk
+                        DO ji = startloop, nlci
+                           ijt  = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
+                           jia  = ji + nimpp - 1
+                           ijta = jpiglo - jia + 2
+                           IF( ijta >= startloop+nimpp-1 .AND. ijta < jia ) THEN
+                              ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ijta-nimpp+1,nlcj-1,jk,jl,jf)
+                           ELSE
+                              ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpjp1,jk,jl,jf)
+                           ENDIF
+                        END DO
+                     END DO; END DO
+                  ENDIF
+               ENDIF
+
             CASE ( 'U' )                                     ! U-point
                IF( nimpp + nlci - 1 /= jpiglo ) THEN
@@ -130,38 +145,44 @@
                   endloop = nlci - 1
                ENDIF
-               DO ji = 1, endloop
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                        ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj-2,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF (nimpp .eq. 1) THEN
-                        ARRAY_IN(   1  ,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(    2   ,ijpj-2,:,:,jf)
+                  ARRAY_IN(1,nlcj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2,nlcj-2,:,:,jf)
                ENDIF
                IF((nimpp + nlci - 1) .eq. jpiglo) THEN
-                        ARRAY_IN(nlci,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,ijpj-2,:,:,jf)
-               ENDIF
-               !
-               IF( nimpp + nlci - 1 /= jpiglo ) THEN
-                  endloop = nlci
-               ELSE
-                  endloop = nlci - 1
-               ENDIF
-               IF( nimpp >= jpiglo/2 ) THEN
-                  startloop = 1
-                  ELSEIF( ( nimpp+nlci-1 >= jpiglo/2 ) .AND. ( nimpp < jpiglo/2 ) ) THEN
-                  startloop = jpiglo/2 - nimpp + 1
-               ELSE
-                  startloop = endloop + 1
-               ENDIF
-               IF( startloop <= endloop ) THEN
-               DO ji = startloop, endloop
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                  jia = ji + nimpp - 1
-                  ijua = jpiglo - jia + 1
-                  IF( ijua >= startloop+nimpp-1 .AND. ijua < jia ) THEN
-                           ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(ijua-nimpp+1,ijpjm1,:,:,jf)
-                  ELSE
-                           ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjm1,:,:,jf)
-                  ENDIF
-               END DO
+                  ARRAY_IN(nlci,nlcj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,nlcj-2,:,:,jf)
+               ENDIF
+               !
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  IF( nimpp + nlci - 1 /= jpiglo ) THEN
+                     endloop = nlci
+                  ELSE
+                     endloop = nlci - 1
+                  ENDIF
+                  IF( nimpp >= jpiglo/2 ) THEN
+                     startloop = 1
+                     ELSEIF( ( nimpp+nlci-1 >= jpiglo/2 ) .AND. ( nimpp < jpiglo/2 ) ) THEN
+                     startloop = jpiglo/2 - nimpp + 1
+                  ELSE
+                     startloop = endloop + 1
+                  ENDIF
+                  IF( startloop <= endloop ) THEN
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     DO ji = startloop, endloop
+                        iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                        jia = ji + nimpp - 1
+                        ijua = jpiglo - jia + 1
+                        IF( ijua >= startloop+nimpp-1 .AND. ijua < jia ) THEN
+                           ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ijua-nimpp+1,nlcj-1,jk,jl,jf)
+                        ELSE
+                           ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjp1,jk,jl,jf)
+                        ENDIF
+                     END DO
+                  END DO; END DO
+                  ENDIF
                ENDIF
                !
@@ -172,11 +193,20 @@
                  startloop = 2
                ENDIF
-               DO ji = startloop, nlci
-                 ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                        ARRAY_IN(ji,ijpj-1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj-2,:,:,jf)
-                        ARRAY_IN(ji,ijpj  ,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj-3,:,:,jf)
-               END DO
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     DO ji = startloop, nlci
+                        ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
+                        ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpjp1,jk,jl,jf)
+                     END DO
+                  END DO; END DO
+               ENDIF
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = startloop, nlci
+                     ijt=jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF (nimpp .eq. 1) THEN
-                        ARRAY_IN(1,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(3,ijpj-3,:,:,jf)
+                  ARRAY_IN(1,nlcj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(3,nlcj-3,:,:,jf)
                ENDIF
             CASE ( 'F' )                                     ! F-point
@@ -186,29 +216,29 @@
                   endloop = nlci - 1
                ENDIF
-               DO ji = 1, endloop
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                        ARRAY_IN(ji,ijpj-1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj-2,:,:,jf)
-                        ARRAY_IN(ji,ijpj  ,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj-3,:,:,jf)
-               END DO
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     DO ji = 1, endloop
+                        iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                        ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjp1,jk,jl,jf)
+                     END DO
+                  END DO; END DO
+               ENDIF
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF (nimpp .eq. 1) THEN
-                        ARRAY_IN(   1  ,ijpj  ,:,:,jf) = SGN_IN(jf) * ARRAY_IN(    2   ,ijpj-3,:,:,jf)
-                        ARRAY_IN(   1  ,ijpj-1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(    2   ,ijpj-2,:,:,jf)
+                  ARRAY_IN(1,nlcj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2,nlcj-3,:,:,jf)
+                  IF ( .NOT. l_fast_exchanges ) &
+                     ARRAY_IN(1,nlcj-1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2,nlcj-2,:,:,jf)
                ENDIF
                IF((nimpp + nlci - 1) .eq. jpiglo) THEN
-                        ARRAY_IN(nlci,ijpj  ,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,ijpj-3,:,:,jf)
-                        ARRAY_IN(nlci,ijpj-1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,ijpj-2,:,:,jf) 
-               ENDIF
-               !
-            CASE ( 'I' )                                     ! ice U-V point (I-point)
-               IF( nimpp /= 1 ) THEN
-                  startloop = 1
-               ELSE
-                  startloop = 3
-                  ARRAY_IN(2,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(3,ijpjm1,:,:,jf)
-               ENDIF
-               DO ji = startloop, nlci
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 5
-                  ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjm1,:,:,jf)
-               END DO
+                  ARRAY_IN(nlci,nlcj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,nlcj-3,:,:,jf)
+                  IF ( .NOT. l_fast_exchanges ) &
+                     ARRAY_IN(nlci,nlcj-1,:,:,jf) = SGN_IN(jf) * ARRAY_IN(nlci-1,nlcj-2,:,:,jf)
+               ENDIF
+               !
             END SELECT
             !
@@ -217,8 +247,10 @@
             SELECT CASE ( NAT_IN(jf) )
             CASE ( 'T' , 'W' )                               ! T-, W-point
-               DO ji = 1, nlci
-                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                        ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj-1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, nlci
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                !
             CASE ( 'U' )                                     ! U-point
@@ -228,30 +260,40 @@
                   endloop = nlci - 1
                ENDIF
-               DO ji = 1, endloop
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
-                        ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj-1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF((nimpp + nlci - 1) .eq. jpiglo) THEN
-                        ARRAY_IN(nlci,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(1,ijpj-1,:,:,jf)
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     ARRAY_IN(nlci,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(nlci-2,nlcj-1,jk,jl,jf)
+                  END DO; END DO
                ENDIF
                !
             CASE ( 'V' )                                     ! V-point
-               DO ji = 1, nlci
-                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                        ARRAY_IN(ji,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj-2,:,:,jf)
-               END DO
-                  !
-               IF( nimpp >= jpiglo/2+1 ) THEN
-                  startloop = 1
-               ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
-                  startloop = jpiglo/2+1 - nimpp + 1
-               ELSE
-                  startloop = nlci + 1
-               ENDIF
-               IF( startloop <= nlci ) THEN
-               DO ji = startloop, nlci
-                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
-                          ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpjm1,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, nlci
+                     ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                     ARRAY_IN(ji,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
+
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  IF( nimpp >= jpiglo/2+1 ) THEN
+                     startloop = 1
+                  ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
+                     startloop = jpiglo/2+1 - nimpp + 1
+                  ELSE
+                     startloop = nlci + 1
+                  ENDIF
+                  IF( startloop <= nlci ) THEN
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     DO ji = startloop, nlci
+                        ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 3
+                        ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,ijpjp1,jk,jl,jf)
+                     END DO
+                  END DO; END DO
+                  ENDIF
                ENDIF
                !
@@ -262,46 +304,38 @@
                   endloop = nlci - 1
                ENDIF
-               DO ji = 1, endloop
-                  iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
-                        ARRAY_IN(ji,ijpj ,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj-2,:,:,jf)
-               END DO
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
+                     ARRAY_IN(ji,nlcj ,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpj,jk,jl,jf)
+                  END DO
+               END DO; END DO
                IF((nimpp + nlci - 1) .eq. jpiglo) THEN
-                        ARRAY_IN(nlci,ijpj,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(1,ijpj-2,:,:,jf)
-               ENDIF
-               !
-               IF( nimpp + nlci - 1 /= jpiglo ) THEN
-                  endloop = nlci
-               ELSE
-                  endloop = nlci - 1
-               ENDIF
-               IF( nimpp >= jpiglo/2+1 ) THEN
-                  startloop = 1
-               ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
-                  startloop = jpiglo/2+1 - nimpp + 1
-               ELSE
-                  startloop = endloop + 1
-               ENDIF
-               IF( startloop <= endloop ) THEN
-                  DO ji = startloop, endloop
-                      iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
-                      ARRAY_IN(ji,ijpjm1,:,:,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjm1,:,:,jf)
-                  END DO
-               ENDIF
-               !
-            CASE ( 'I' )                                  ! ice U-V point (I-point)
-               IF( nimpp /= 1 ) THEN
-                  startloop = 1
-               ELSE
-                  startloop = 2
-               ENDIF
-               IF( nimpp + nlci - 1 /= jpiglo ) THEN
-                  endloop = nlci
-               ELSE
-                  endloop = nlci - 1
-               ENDIF
-               DO ji = startloop , endloop
-                  ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                  ARRAY_IN(ji,ijpj,:,:,jf) = 0.5 * (ARRAY_IN(ji,ijpjm1,:,:,jf) + SGN_IN(jf) * ARRAY2_IN(ijt,ijpjm1,:,:,jf))
-               END DO
+                  DO jl = 1, ipl; DO jk = 1, ipk
+                     ARRAY_IN(nlci,nlcj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(nlci-2,nlcj-2,jk,jl,jf)
+                  END DO; END DO
+               ENDIF
+               !
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  IF( nimpp + nlci - 1 /= jpiglo ) THEN
+                     endloop = nlci
+                  ELSE
+                     endloop = nlci - 1
+                  ENDIF
+                  IF( nimpp >= jpiglo/2+1 ) THEN
+                     startloop = 1
+                  ELSEIF( nimpp+nlci-1 >= jpiglo/2+1 .AND. nimpp < jpiglo/2+1 ) THEN
+                     startloop = jpiglo/2+1 - nimpp + 1
+                  ELSE
+                     startloop = endloop + 1
+                  ENDIF
+                  IF( startloop <= endloop ) THEN
+                     DO jl = 1, ipl; DO jk = 1, ipk
+                        DO ji = startloop, endloop
+                           iju = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 2
+                           ARRAY_IN(ji,nlcj-1,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,ijpjp1,jk,jl,jf)
+                        END DO
+                     END DO; END DO
+                  ENDIF
+               ENDIF
                !
             END SELECT
@@ -309,14 +343,5 @@
          CASE DEFAULT                           ! *  closed : the code probably never go through
             !
-            SELECT CASE ( NAT_IN(jf))
-            CASE ( 'T' , 'U' , 'V' , 'W' )                 ! T-, U-, V-, W-points
-               ARRAY_IN(:, 1  ,:,:,jf) = 0._wp
-               ARRAY_IN(:,ijpj,:,:,jf) = 0._wp
-            CASE ( 'F' )                                   ! F-point
-               ARRAY_IN(:,ijpj,:,:,jf) = 0._wp
-            CASE ( 'I' )                                   ! ice U-V point
-               ARRAY_IN(:, 1  ,:,:,jf) = 0._wp
-               ARRAY_IN(:,ijpj,:,:,jf) = 0._wp
-            END SELECT
+            WRITE(*,*) 'lbc_nfd_nogather_generic: You should not have seen this print! error?', npolj
             !
          END SELECT     !  npolj
@@ -328,4 +353,5 @@
 #undef NAT_IN
 #undef SGN_IN
+#undef J_SIZE
 #undef K_SIZE
 #undef L_SIZE
Index: /NEMO/trunk/src/OCE/LBC/lbclnk.F90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbclnk.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbclnk.F90	(revision 10425)
@@ -179,16 +179,18 @@
    !!----------------------------------------------------------------------
    
-   SUBROUTINE lbc_bdy_lnk_4d( pt4d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pt4d      ! 4D array on which the lbc is applied
-      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt4d grid-points
-      REAL(wp)                    , INTENT(in   ) ::   psgn      ! sign used across north fold 
-      INTEGER                     , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
-      !!----------------------------------------------------------------------
-      CALL lbc_lnk_4d( pt4d, cd_type, psgn)
+   SUBROUTINE lbc_bdy_lnk_4d( cdname, pt4d, cd_type, psgn, ib_bdy )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*)          , INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pt4d      ! 3D array on which the lbc is applied
+      CHARACTER(len=1)          , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
+      REAL(wp)                  , INTENT(in   ) ::   psgn      ! sign used across north fold 
+      INTEGER                   , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
+      !!----------------------------------------------------------------------
+      CALL lbc_lnk_4d( cdname, pt4d, cd_type, psgn)
    END SUBROUTINE lbc_bdy_lnk_4d
 
-   SUBROUTINE lbc_bdy_lnk_3d( pt3d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
+   SUBROUTINE lbc_bdy_lnk_3d( cdname, pt3d, cd_type, psgn, ib_bdy )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*)          , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pt3d      ! 3D array on which the lbc is applied
       CHARACTER(len=1)          , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
@@ -196,10 +198,11 @@
       INTEGER                   , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
       !!----------------------------------------------------------------------
-      CALL lbc_lnk_3d( pt3d, cd_type, psgn)
+      CALL lbc_lnk_3d( cdname, pt3d, cd_type, psgn)
    END SUBROUTINE lbc_bdy_lnk_3d
 
 
-   SUBROUTINE lbc_bdy_lnk_2d( pt2d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
+   SUBROUTINE lbc_bdy_lnk_2d( cdname, pt2d, cd_type, psgn, ib_bdy )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*)        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d      ! 3D array on which the lbc is applied
       CHARACTER(len=1)        , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
@@ -207,5 +210,5 @@
       INTEGER                 , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
       !!----------------------------------------------------------------------
-      CALL lbc_lnk_2d( pt2d, cd_type, psgn)
+      CALL lbc_lnk_2d( cdname, pt2d, cd_type, psgn)
    END SUBROUTINE lbc_bdy_lnk_2d
 
@@ -213,6 +216,7 @@
 !!gm  This routine should be removed with an optional halos size added in argument of generic routines
 
-   SUBROUTINE lbc_lnk_2d_icb( pt2d, cd_type, psgn, ki, kj )
-      !!----------------------------------------------------------------------
+   SUBROUTINE lbc_lnk_2d_icb( cdname, pt2d, cd_type, psgn, ki, kj )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*)        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d      ! 2D array on which the lbc is applied
       CHARACTER(len=1)        , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
@@ -220,5 +224,5 @@
       INTEGER                 , INTENT(in   ) ::   ki, kj    ! sizes of extra halo (not needed in non-mpp)
       !!----------------------------------------------------------------------
-      CALL lbc_lnk_2d( pt2d, cd_type, psgn )
+      CALL lbc_lnk_2d( cdname, pt2d, cd_type, psgn )
    END SUBROUTINE lbc_lnk_2d_icb
 !!gm end
Index: /NEMO/trunk/src/OCE/LBC/lbcnfd.F90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lbcnfd.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lbcnfd.F90	(revision 10425)
@@ -32,7 +32,7 @@
    INTERFACE lbc_nfd_nogather
 !                        ! Currently only 4d array version is needed
-!     MODULE PROCEDURE   lbc_nfd_nogather_2d    , lbc_nfd_nogather_3d
-      MODULE PROCEDURE   lbc_nfd_nogather_4d
-!     MODULE PROCEDURE   lbc_nfd_nogather_2d_ptr, lbc_nfd_nogather_3d_ptr
+     MODULE PROCEDURE   lbc_nfd_nogather_2d    , lbc_nfd_nogather_3d
+     MODULE PROCEDURE   lbc_nfd_nogather_4d
+     MODULE PROCEDURE   lbc_nfd_nogather_2d_ptr, lbc_nfd_nogather_3d_ptr
 !     MODULE PROCEDURE   lbc_nfd_nogather_4d_ptr
    END INTERFACE
@@ -125,27 +125,27 @@
    !                       !==  2D array and array of 2D pointer  ==!
    !
-!#  define DIM_2d
-!#     define ROUTINE_NFD           lbc_nfd_nogather_2d
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     define MULTI
-!#     define ROUTINE_NFD           lbc_nfd_nogather_2d_ptr
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     undef MULTI
-!#  undef DIM_2d
+#  define DIM_2d
+#     define ROUTINE_NFD           lbc_nfd_nogather_2d
+#     include "lbc_nfd_nogather_generic.h90"
+#     undef ROUTINE_NFD
+#     define MULTI
+#     define ROUTINE_NFD           lbc_nfd_nogather_2d_ptr
+#     include "lbc_nfd_nogather_generic.h90"
+#     undef ROUTINE_NFD
+#     undef MULTI
+#  undef DIM_2d
    !
    !                       !==  3D array and array of 3D pointer  ==!
    !
-!#  define DIM_3d
-!#     define ROUTINE_NFD           lbc_nfd_nogather_3d
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     define MULTI
-!#     define ROUTINE_NFD           lbc_nfd_nogather_3d_ptr
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     undef MULTI
-!#  undef DIM_3d
+#  define DIM_3d
+#     define ROUTINE_NFD           lbc_nfd_nogather_3d
+#     include "lbc_nfd_nogather_generic.h90"
+#     undef ROUTINE_NFD
+#     define MULTI
+#     define ROUTINE_NFD           lbc_nfd_nogather_3d_ptr
+#     include "lbc_nfd_nogather_generic.h90"
+#     undef ROUTINE_NFD
+#     undef MULTI
+#  undef DIM_3d
    !
    !                       !==  4D array and array of 4D pointer  ==!
Index: /NEMO/trunk/src/OCE/LBC/lib_mpp.F90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/lib_mpp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/lib_mpp.F90	(revision 10425)
@@ -64,10 +64,10 @@
 
    INTERFACE mpp_nfd
-      MODULE PROCEDURE   mpp_nfd_2d      , mpp_nfd_3d      , mpp_nfd_4d
+      MODULE PROCEDURE   mpp_nfd_2d    , mpp_nfd_3d    , mpp_nfd_4d
       MODULE PROCEDURE   mpp_nfd_2d_ptr, mpp_nfd_3d_ptr, mpp_nfd_4d_ptr
    END INTERFACE
 
    ! Interface associated to the mpp_lnk_... routines is defined in lbclnk
-   PUBLIC   mpp_lnk_2d      , mpp_lnk_3d      , mpp_lnk_4d
+   PUBLIC   mpp_lnk_2d    , mpp_lnk_3d    , mpp_lnk_4d
    PUBLIC   mpp_lnk_2d_ptr, mpp_lnk_3d_ptr, mpp_lnk_4d_ptr
    !
@@ -83,11 +83,9 @@
    PUBLIC   mpp_lbc_north_icb
    PUBLIC   mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc
-   PUBLIC   mpp_max_multiple
+   PUBLIC   mpp_delay_max, mpp_delay_sum, mpp_delay_rcv
    PUBLIC   mppscatter, mppgather
-   PUBLIC   mpp_ini_ice, mpp_ini_znl
-   PUBLIC   mppsize
+   PUBLIC   mpp_ini_znl
    PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines
    PUBLIC   mpp_lnk_bdy_2d, mpp_lnk_bdy_3d, mpp_lnk_bdy_4d
-   PUBLIC   mpprank
    
    !! * Interfaces
@@ -111,7 +109,4 @@
       MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
    END INTERFACE
-   INTERFACE mpp_max_multiple
-      MODULE PROCEDURE mppmax_real_multiple
-   END INTERFACE
 
    !! ========================= !!
@@ -126,6 +121,6 @@
    INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
 
-   INTEGER ::   mppsize        ! number of process
-   INTEGER ::   mpprank        ! process number  [ 0 - size-1 ]
+   INTEGER, PUBLIC ::   mppsize        ! number of process
+   INTEGER, PUBLIC ::   mpprank        ! process number  [ 0 - size-1 ]
 !$AGRIF_DO_NOT_TREAT
    INTEGER, PUBLIC ::   mpi_comm_oce   ! opa local communicator
@@ -133,12 +128,4 @@
 
    INTEGER :: MPI_SUMDD
-
-   ! variables used in case of sea-ice
-   INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice (public so that it can be freed in icethd)
-   INTEGER         ::   ngrp_iworld     !  group ID for the world processors (for rheology)
-   INTEGER         ::   ngrp_ice        !  group ID for the ice processors (for rheology)
-   INTEGER         ::   ndim_rank_ice   !  number of 'ice' processors
-   INTEGER         ::   n_ice_root      !  number (in the comm_ice) of proc 0 in the ice comm
-   INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_ice     ! dimension ndim_rank_ice
 
    ! variables used for zonal integration
@@ -164,4 +151,33 @@
    INTEGER         , PUBLIC ::   nn_buffer          !: size of the buffer in case of mpi_bsend
 
+   ! Communications summary report
+   CHARACTER(len=128), DIMENSION(:), ALLOCATABLE ::   crname_lbc                   !: names of lbc_lnk calling routines
+   CHARACTER(len=128), DIMENSION(:), ALLOCATABLE ::   crname_glb                   !: names of global comm  calling routines
+   INTEGER, PUBLIC                               ::   ncom_stp = 0                 !: copy of time step # istp
+   INTEGER, PUBLIC                               ::   ncom_fsbc = 1                !: copy of sbc time step # nn_fsbc
+   INTEGER, PUBLIC                               ::   ncom_dttrc = 1               !: copy of top time step # nn_dttrc
+   INTEGER, PUBLIC                               ::   ncom_freq                    !: frequency of comm diagnostic
+   INTEGER, PUBLIC , DIMENSION(:,:), ALLOCATABLE ::   ncomm_sequence               !: size of communicated arrays (halos)
+   INTEGER, PARAMETER, PUBLIC                    ::   ncom_rec_max = 2000          !: max number of communication record
+   INTEGER, PUBLIC                               ::   n_sequence_lbc = 0           !: # of communicated arraysvia lbc
+   INTEGER, PUBLIC                               ::   n_sequence_glb = 0           !: # of global communications
+   INTEGER, PUBLIC                               ::   numcom = -1                  !: logical unit for communicaton report
+   LOGICAL, PUBLIC                               ::   l_full_nf_update = .TRUE.    !: logical for a full (2lines) update of bc at North fold report
+   INTEGER,                    PARAMETER, PUBLIC ::   nbdelay = 2       !: number of delayed operations
+   !: name (used as id) of allreduce-delayed operations
+   CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ 'cflice', 'fwb' /)
+   !: component name where the allreduce-delayed operation is performed
+   CHARACTER(len=3),  DIMENSION(nbdelay), PUBLIC ::   c_delaycpnt = (/ 'ICE'   , 'OCE' /)
+   TYPE, PUBLIC ::   DELAYARR
+      REAL(   wp), POINTER, DIMENSION(:) ::  z1d => NULL()
+      COMPLEX(wp), POINTER, DIMENSION(:) ::  y1d => NULL()
+   END TYPE DELAYARR
+   TYPE( DELAYARR ), DIMENSION(nbdelay), PUBLIC  ::   todelay              
+   INTEGER,          DIMENSION(nbdelay), PUBLIC  ::   ndelayid = -1     !: mpi request id of the delayed operations
+
+   ! timing summary report
+   REAL(wp), DIMENSION(2), PUBLIC ::  waiting_time = 0._wp
+   REAL(wp)              , PUBLIC ::  compute_time = 0._wp, elapsed_time = 0._wp
+   
    REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE ::   tampon   ! buffer in case of bsend
 
@@ -214,16 +230,4 @@
       WRITE(ldtxt(ii),*) '      size exported buffer   nn_buffer   = ', nn_buffer,' bytes';   ii = ii + 1
       !
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
-         jpni  = Agrif_Parent(jpni )
-         jpnj  = Agrif_Parent(jpnj )
-         jpnij = Agrif_Parent(jpnij)
-      ENDIF
-#endif
-      !
-      IF( jpnij < 1 ) THEN         ! If jpnij is not specified in namelist then we calculate it
-         jpnij = jpni * jpnj       ! this means there will be no land cutting out.
-      ENDIF
-
       IF( jpni < 1 .OR. jpnj < 1  ) THEN
          WRITE(ldtxt(ii),*) '      jpni, jpnj and jpnij will be calculated automatically' ;   ii = ii + 1
@@ -231,5 +235,4 @@
          WRITE(ldtxt(ii),*) '      processor grid extent in i         jpni = ',jpni       ;   ii = ii + 1
          WRITE(ldtxt(ii),*) '      processor grid extent in j         jpnj = ',jpnj       ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '      number of local domains           jpnij = ',jpnij      ;   ii = ii + 1
       ENDIF
 
@@ -264,4 +267,5 @@
          !
       ELSEIF ( PRESENT(localComm) .AND. .NOT. mpi_was_called ) THEN
+         WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1
          WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1
          WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1
@@ -574,4 +578,144 @@
    END SUBROUTINE mppscatter
 
+   
+   SUBROUTINE mpp_delay_sum( cdname, cdelay, y_in, pout, ldlast, kcom )
+     !!----------------------------------------------------------------------
+      !!                   ***  routine mpp_delay_sum  ***
+      !!
+      !! ** Purpose :   performed delayed mpp_sum, the result is received on next call
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   )               ::   cdname  ! name of the calling subroutine
+      CHARACTER(len=*), INTENT(in   )               ::   cdelay  ! name (used as id) of the delayed operation
+      COMPLEX(wp),      INTENT(in   ), DIMENSION(:) ::   y_in
+      REAL(wp),         INTENT(  out), DIMENSION(:) ::   pout
+      LOGICAL,          INTENT(in   )               ::   ldlast  ! true if this is the last time we call this routine
+      INTEGER,          INTENT(in   ), OPTIONAL     ::   kcom
+      !!
+      INTEGER ::   ji, isz
+      INTEGER ::   idvar
+      INTEGER ::   ierr, ilocalcomm
+      COMPLEX(wp), ALLOCATABLE, DIMENSION(:) ::   ytmp
+      !!----------------------------------------------------------------------
+      ilocalcomm = mpi_comm_oce
+      IF( PRESENT(kcom) )   ilocalcomm = kcom
+
+      isz = SIZE(y_in)
+      
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ld_glb = .TRUE. )
+
+      idvar = -1
+      DO ji = 1, nbdelay
+         IF( TRIM(cdelay) == TRIM(c_delaylist(ji)) ) idvar = ji
+      END DO
+      IF ( idvar == -1 )   CALL ctl_stop( 'STOP',' mpp_delay_sum : please add a new delayed exchange for '//TRIM(cdname) )
+
+      IF ( ndelayid(idvar) == 0 ) THEN         ! first call    with restart: %z1d defined in iom_delay_rst
+         !                                       --------------------------
+         IF ( SIZE(todelay(idvar)%z1d) /= isz ) THEN                  ! Check dimension coherence
+            IF(lwp) WRITE(numout,*) ' WARNING: the nb of delayed variables in restart file is not the model one'
+            DEALLOCATE(todelay(idvar)%z1d)
+            ndelayid(idvar) = -1                                      ! do as if we had no restart
+         ELSE
+            ALLOCATE(todelay(idvar)%y1d(isz))
+            todelay(idvar)%y1d(:) = CMPLX(todelay(idvar)%z1d(:), 0., wp)   ! create %y1d, complex variable needed by mpi_sumdd
+         END IF
+      ENDIF
+      
+      IF( ndelayid(idvar) == -1 ) THEN         ! first call without restart: define %y1d and %z1d from y_in with blocking allreduce
+         !                                       --------------------------
+         ALLOCATE(todelay(idvar)%z1d(isz), todelay(idvar)%y1d(isz))   ! allocate also %z1d as used for the restart
+         CALL mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ierr )   ! get %y1d
+         todelay(idvar)%z1d(:) = REAL(todelay(idvar)%y1d(:), wp)      ! define %z1d from %y1d
+      ENDIF
+
+      IF( ndelayid(idvar) > 0 )   CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
+
+      ! send back pout from todelay(idvar)%z1d defined at previous call
+      pout(:) = todelay(idvar)%z1d(:)
+
+      ! send y_in into todelay(idvar)%y1d with a non-blocking communication
+      CALL mpi_iallreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ndelayid(idvar), ierr )
+
+   END SUBROUTINE mpp_delay_sum
+
+   
+   SUBROUTINE mpp_delay_max( cdname, cdelay, p_in, pout, ldlast, kcom )
+      !!----------------------------------------------------------------------
+      !!                   ***  routine mpp_delay_max  ***
+      !!
+      !! ** Purpose :   performed delayed mpp_max, the result is received on next call
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   )                 ::   cdname  ! name of the calling subroutine
+      CHARACTER(len=*), INTENT(in   )                 ::   cdelay  ! name (used as id) of the delayed operation
+      REAL(wp),         INTENT(in   ), DIMENSION(:)   ::   p_in    ! 
+      REAL(wp),         INTENT(  out), DIMENSION(:)   ::   pout    ! 
+      LOGICAL,          INTENT(in   )                 ::   ldlast  ! true if this is the last time we call this routine
+      INTEGER,          INTENT(in   ), OPTIONAL       ::   kcom
+      !!
+      INTEGER ::   ji, isz
+      INTEGER ::   idvar
+      INTEGER ::   ierr, ilocalcomm
+      !!----------------------------------------------------------------------
+      ilocalcomm = mpi_comm_oce
+      IF( PRESENT(kcom) )   ilocalcomm = kcom
+
+      isz = SIZE(p_in)
+
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ld_glb = .TRUE. )
+
+      idvar = -1
+      DO ji = 1, nbdelay
+         IF( TRIM(cdelay) == TRIM(c_delaylist(ji)) ) idvar = ji
+      END DO
+      IF ( idvar == -1 )   CALL ctl_stop( 'STOP',' mpp_delay_max : please add a new delayed exchange for '//TRIM(cdname) )
+
+      IF ( ndelayid(idvar) == 0 ) THEN         ! first call    with restart: %z1d defined in iom_delay_rst
+         !                                       --------------------------
+         IF ( SIZE(todelay(idvar)%z1d) /= isz ) THEN                  ! Check dimension coherence
+            IF(lwp) WRITE(numout,*) ' WARNING: the nb of delayed variables in restart file is not the model one'
+            DEALLOCATE(todelay(idvar)%z1d)
+            ndelayid(idvar) = -1                                      ! do as if we had no restart
+         END IF
+      ENDIF
+
+      IF( ndelayid(idvar) == -1 ) THEN         ! first call without restart: define %z1d from p_in with a blocking allreduce
+         !                                       --------------------------
+         ALLOCATE(todelay(idvar)%z1d(isz))
+         CALL mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ierr )   ! get %z1d
+      ENDIF
+
+      IF( ndelayid(idvar) > 0 )   CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
+
+      ! send back pout from todelay(idvar)%z1d defined at previous call
+      pout(:) = todelay(idvar)%z1d(:)
+
+      ! send p_in into todelay(idvar)%z1d with a non-blocking communication
+      CALL mpi_iallreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ndelayid(idvar), ierr )
+
+   END SUBROUTINE mpp_delay_max
+
+   
+   SUBROUTINE mpp_delay_rcv( kid )
+      !!----------------------------------------------------------------------
+      !!                   ***  routine mpp_delay_rcv  ***
+      !!
+      !! ** Purpose :  force barrier for delayed mpp (needed for restart) 
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER,INTENT(in   )      ::  kid 
+      INTEGER ::   ierr
+      !!----------------------------------------------------------------------
+      IF( ndelayid(kid) /= -2 ) THEN  
+         IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
+         CALL mpi_wait( ndelayid(kid), MPI_STATUS_IGNORE, ierr )                        ! make sure todelay(kid) is received
+         IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
+         IF( ASSOCIATED(todelay(kid)%y1d) )   todelay(kid)%z1d(:) = REAL(todelay(kid)%y1d(:), wp)  ! define %z1d from %y1d
+         ndelayid(kid) = -2   ! add flag to know that mpi_wait was already called on kid
+      ENDIF
+   END SUBROUTINE mpp_delay_rcv
+
+   
    !!----------------------------------------------------------------------
    !!    ***  mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real  ***
@@ -579,58 +723,31 @@
    !!----------------------------------------------------------------------
    !!
-   SUBROUTINE mppmax_a_int( ktab, kdim, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER , INTENT(in   )                  ::   kdim   ! size of array
-      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array
-      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom   !
-      INTEGER :: ierror, ilocalcomm   ! temporary integer
-      INTEGER, DIMENSION(kdim) ::   iwork
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_max, ilocalcomm, ierror )
-      ktab(:) = iwork(:)
-   END SUBROUTINE mppmax_a_int
-   !!
-   SUBROUTINE mppmax_int( ktab, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(inout)           ::   ktab   ! ???
-      INTEGER, INTENT(in   ), OPTIONAL ::   kcom   ! ???
-      INTEGER ::   ierror, iwork, ilocalcomm   ! temporary integer
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_max, ilocalcomm, ierror )
-      ktab = iwork
-   END SUBROUTINE mppmax_int
-   !!
-   SUBROUTINE mppmax_a_real( ptab, kdim, kcom )
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(kdim), INTENT(inout) ::   ptab
-      INTEGER                  , INTENT(in   ) ::   kdim
-      INTEGER , OPTIONAL       , INTENT(in   ) ::   kcom
-      INTEGER :: ierror, ilocalcomm
-      REAL(wp), DIMENSION(kdim) ::  zwork
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_max, ilocalcomm, ierror )
-      ptab(:) = zwork(:)
-   END SUBROUTINE mppmax_a_real
-   !!
-   SUBROUTINE mppmax_real( ptab, kcom )
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(inout)           ::   ptab   ! ???
-      INTEGER , INTENT(in   ), OPTIONAL ::   kcom   ! ???
-      INTEGER  ::   ierror, ilocalcomm
-      REAL(wp) ::   zwork
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom!
-      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_max, ilocalcomm, ierror )
-      ptab = zwork
-   END SUBROUTINE mppmax_real
-
-
+#  define OPERATION_MAX
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmax_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmax_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmax_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmax_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_MAX
    !!----------------------------------------------------------------------
    !!    ***  mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real  ***
@@ -638,59 +755,31 @@
    !!----------------------------------------------------------------------
    !!
-   SUBROUTINE mppmin_a_int( ktab, kdim, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER , INTENT( in  )                  ::   kdim   ! size of array
-      INTEGER , INTENT(inout), DIMENSION(kdim) ::   ktab   ! input array
-      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom   ! input array
-      !!
-      INTEGER ::   ierror, ilocalcomm   ! temporary integer
-      INTEGER, DIMENSION(kdim) ::   iwork
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_min, ilocalcomm, ierror )
-      ktab(:) = iwork(:)
-   END SUBROUTINE mppmin_a_int
-   !!
-   SUBROUTINE mppmin_int( ktab, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(inout) ::   ktab      ! ???
-      INTEGER , INTENT( in  ), OPTIONAL        ::   kcom        ! input array
-      !!
-      INTEGER ::  ierror, iwork, ilocalcomm
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_min, ilocalcomm, ierror )
-      ktab = iwork
-   END SUBROUTINE mppmin_int
-   !!
-   SUBROUTINE mppmin_a_real( ptab, kdim, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER , INTENT(in   )                  ::   kdim
-      REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
-      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom
-      INTEGER :: ierror, ilocalcomm
-      REAL(wp), DIMENSION(kdim) ::   zwork
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_min, ilocalcomm, ierror )
-      ptab(:) = zwork(:)
-   END SUBROUTINE mppmin_a_real
-   !!
-   SUBROUTINE mppmin_real( ptab, kcom )
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(inout)           ::   ptab        !
-      INTEGER , INTENT(in   ), OPTIONAL :: kcom
-      INTEGER  ::   ierror, ilocalcomm
-      REAL(wp) ::   zwork
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_min, ilocalcomm, ierror )
-      ptab = zwork
-   END SUBROUTINE mppmin_real
-
+#  define OPERATION_MIN
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmin_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmin_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmin_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmin_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_MIN
 
    !!----------------------------------------------------------------------
@@ -700,261 +789,77 @@
    !!----------------------------------------------------------------------
    !!
-   SUBROUTINE mppsum_a_int( ktab, kdim )
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in   )                   ::   kdim   ! ???
-      INTEGER, INTENT(inout), DIMENSION (kdim) ::   ktab   ! ???
-      INTEGER :: ierror
-      INTEGER, DIMENSION (kdim) ::  iwork
-      !!----------------------------------------------------------------------
-      CALL mpi_allreduce( ktab, iwork, kdim, mpi_integer, mpi_sum, mpi_comm_oce, ierror )
-      ktab(:) = iwork(:)
-   END SUBROUTINE mppsum_a_int
+#  define OPERATION_SUM
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_SUM
+
+#  define OPERATION_SUM_DD
+#  define COMPLEX_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_realdd
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_realdd
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef COMPLEX_TYPE
+#  undef OPERATION_SUM_DD
+
+   !!----------------------------------------------------------------------
+   !!    ***  mpp_minloc2d, mpp_minloc3d, mpp_maxloc2d, mpp_maxloc3d
+   !!   
+   !!----------------------------------------------------------------------
    !!
-   SUBROUTINE mppsum_int( ktab )
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(inout) ::   ktab
-      INTEGER :: ierror, iwork
-      !!----------------------------------------------------------------------
-      CALL mpi_allreduce( ktab, iwork, 1, mpi_integer, mpi_sum, mpi_comm_oce, ierror )
-      ktab = iwork
-   END SUBROUTINE mppsum_int
-   !!
-   SUBROUTINE mppsum_a_real( ptab, kdim, kcom )
-      !!-----------------------------------------------------------------------
-      INTEGER                  , INTENT(in   ) ::   kdim   ! size of ptab
-      REAL(wp), DIMENSION(kdim), INTENT(inout) ::   ptab   ! input array
-      INTEGER , OPTIONAL       , INTENT(in   ) ::   kcom   ! specific communicator
-      INTEGER  ::   ierror, ilocalcomm    ! local integer
-      REAL(wp) ::   zwork(kdim)           ! local workspace
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_sum, ilocalcomm, ierror )
-      ptab(:) = zwork(:)
-   END SUBROUTINE mppsum_a_real
-   !!
-   SUBROUTINE mppsum_real( ptab, kcom )
-      !!-----------------------------------------------------------------------
-      REAL(wp)          , INTENT(inout)           ::   ptab   ! input scalar
-      INTEGER , OPTIONAL, INTENT(in   ) ::   kcom
-      INTEGER  ::   ierror, ilocalcomm
-      REAL(wp) ::   zwork
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL mpi_allreduce( ptab, zwork, 1, mpi_double_precision, mpi_sum, ilocalcomm, ierror )
-      ptab = zwork
-   END SUBROUTINE mppsum_real
-   !!
-   SUBROUTINE mppsum_realdd( ytab, kcom )
-      !!-----------------------------------------------------------------------
-      COMPLEX(wp)          , INTENT(inout) ::   ytab    ! input scalar
-      INTEGER    , OPTIONAL, INTENT(in   ) ::   kcom
-      INTEGER     ::   ierror, ilocalcomm
-      COMPLEX(wp) ::   zwork
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL MPI_ALLREDUCE( ytab, zwork, 1, MPI_DOUBLE_COMPLEX, MPI_SUMDD, ilocalcomm, ierror )
-      ytab = zwork
-   END SUBROUTINE mppsum_realdd
-   !!
-   SUBROUTINE mppsum_a_realdd( ytab, kdim, kcom )
-      !!----------------------------------------------------------------------
-      INTEGER                     , INTENT(in   ) ::   kdim   ! size of ytab
-      COMPLEX(wp), DIMENSION(kdim), INTENT(inout) ::   ytab   ! input array
-      INTEGER    , OPTIONAL       , INTENT(in   ) ::   kcom
-      INTEGER:: ierror, ilocalcomm    ! local integer
-      COMPLEX(wp), DIMENSION(kdim) :: zwork     ! temporary workspace
-      !!-----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      CALL MPI_ALLREDUCE( ytab, zwork, kdim, MPI_DOUBLE_COMPLEX, MPI_SUMDD, ilocalcomm, ierror )
-      ytab(:) = zwork(:)
-   END SUBROUTINE mppsum_a_realdd
-   
-
-   SUBROUTINE mppmax_real_multiple( pt1d, kdim, kcom  )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mppmax_real  ***
-      !!
-      !! ** Purpose :   Maximum across processor of each element of a 1D arrays
-      !!
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(kdim), INTENT(inout) ::   pt1d   ! 1D arrays
-      INTEGER                  , INTENT(in   ) ::   kdim
-      INTEGER , OPTIONAL       , INTENT(in   ) ::   kcom   ! local communicator
-      !!
-      INTEGER  ::   ierror, ilocalcomm
-      REAL(wp), DIMENSION(kdim) ::  zwork
-      !!----------------------------------------------------------------------
-      ilocalcomm = mpi_comm_oce
-      IF( PRESENT(kcom) )   ilocalcomm = kcom
-      !
-      CALL mpi_allreduce( pt1d, zwork, kdim, mpi_double_precision, mpi_max, ilocalcomm, ierror )
-      pt1d(:) = zwork(:)
-      !
-   END SUBROUTINE mppmax_real_multiple
-
-
-   SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki,kj )
-      !!------------------------------------------------------------------------
-      !!             ***  routine mpp_minloc  ***
-      !!
-      !! ** Purpose :   Compute the global minimum of an array ptab
-      !!              and also give its global position
-      !!
-      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
-      !!
-      !!--------------------------------------------------------------------------
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   ptab    ! Local 2D array
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pmask   ! Local mask
-      REAL(wp)                     , INTENT(  out) ::   pmin    ! Global minimum of ptab
-      INTEGER                      , INTENT(  out) ::   ki, kj  ! index of minimum in global frame
-      !
-      INTEGER :: ierror
-      INTEGER , DIMENSION(2)   ::   ilocs
-      REAL(wp) ::   zmin   ! local minimum
-      REAL(wp), DIMENSION(2,1) ::   zain, zaout
-      !!-----------------------------------------------------------------------
-      !
-      zmin  = MINVAL( ptab(:,:) , mask= pmask == 1._wp )
-      ilocs = MINLOC( ptab(:,:) , mask= pmask == 1._wp )
-      !
-      ki = ilocs(1) + nimpp - 1
-      kj = ilocs(2) + njmpp - 1
-      !
-      zain(1,:)=zmin
-      zain(2,:)=ki+10000.*kj
-      !
-      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OCE,ierror)
-      !
-      pmin = zaout(1,1)
-      kj = INT(zaout(2,1)/10000.)
-      ki = INT(zaout(2,1) - 10000.*kj )
-      !
-   END SUBROUTINE mpp_minloc2d
-
-
-   SUBROUTINE mpp_minloc3d( ptab, pmask, pmin, ki, kj ,kk)
-      !!------------------------------------------------------------------------
-      !!             ***  routine mpp_minloc  ***
-      !!
-      !! ** Purpose :   Compute the global minimum of an array ptab
-      !!              and also give its global position
-      !!
-      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
-      !!
-      !!--------------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   ptab         ! Local 2D array
-      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pmask        ! Local mask
-      REAL(wp)                  , INTENT(  out) ::   pmin         ! Global minimum of ptab
-      INTEGER                   , INTENT(  out) ::   ki, kj, kk   ! index of minimum in global frame
-      !
-      INTEGER  ::   ierror
-      REAL(wp) ::   zmin     ! local minimum
-      INTEGER , DIMENSION(3)   ::   ilocs
-      REAL(wp), DIMENSION(2,1) ::   zain, zaout
-      !!-----------------------------------------------------------------------
-      !
-      zmin  = MINVAL( ptab(:,:,:) , mask= pmask == 1._wp )
-      ilocs = MINLOC( ptab(:,:,:) , mask= pmask == 1._wp )
-      !
-      ki = ilocs(1) + nimpp - 1
-      kj = ilocs(2) + njmpp - 1
-      kk = ilocs(3)
-      !
-      zain(1,:) = zmin
-      zain(2,:) = ki + 10000.*kj + 100000000.*kk
-      !
-      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MINLOC,MPI_COMM_OCE,ierror)
-      !
-      pmin = zaout(1,1)
-      kk   = INT( zaout(2,1) / 100000000. )
-      kj   = INT( zaout(2,1) - kk * 100000000. ) / 10000
-      ki   = INT( zaout(2,1) - kk * 100000000. -kj * 10000. )
-      !
-   END SUBROUTINE mpp_minloc3d
-
-
-   SUBROUTINE mpp_maxloc2d( ptab, pmask, pmax, ki, kj )
-      !!------------------------------------------------------------------------
-      !!             ***  routine mpp_maxloc  ***
-      !!
-      !! ** Purpose :   Compute the global maximum of an array ptab
-      !!              and also give its global position
-      !!
-      !! ** Method  :   Use MPI_ALLREDUCE with MPI_MINLOC
-      !!
-      !!--------------------------------------------------------------------------
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   ptab     ! Local 2D array
-      REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pmask    ! Local mask
-      REAL(wp)                     , INTENT(  out) ::   pmax     ! Global maximum of ptab
-      INTEGER                      , INTENT(  out) ::   ki, kj   ! index of maximum in global frame
-      !!
-      INTEGER  :: ierror
-      INTEGER, DIMENSION (2)   ::   ilocs
-      REAL(wp) :: zmax   ! local maximum
-      REAL(wp), DIMENSION(2,1) ::   zain, zaout
-      !!-----------------------------------------------------------------------
-      !
-      zmax  = MAXVAL( ptab(:,:) , mask= pmask == 1._wp )
-      ilocs = MAXLOC( ptab(:,:) , mask= pmask == 1._wp )
-      !
-      ki = ilocs(1) + nimpp - 1
-      kj = ilocs(2) + njmpp - 1
-      !
-      zain(1,:) = zmax
-      zain(2,:) = ki + 10000. * kj
-      !
-      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OCE,ierror)
-      !
-      pmax = zaout(1,1)
-      kj   = INT( zaout(2,1) / 10000.     )
-      ki   = INT( zaout(2,1) - 10000.* kj )
-      !
-   END SUBROUTINE mpp_maxloc2d
-
-
-   SUBROUTINE mpp_maxloc3d( ptab, pmask, pmax, ki, kj, kk )
-      !!------------------------------------------------------------------------
-      !!             ***  routine mpp_maxloc  ***
-      !!
-      !! ** Purpose :  Compute the global maximum of an array ptab
-      !!              and also give its global position
-      !!
-      !! ** Method : Use MPI_ALLREDUCE with MPI_MINLOC
-      !!
-      !!--------------------------------------------------------------------------
-      REAL(wp), DIMENSION (:,:,:), INTENT(in   ) ::   ptab         ! Local 2D array
-      REAL(wp), DIMENSION (:,:,:), INTENT(in   ) ::   pmask        ! Local mask
-      REAL(wp)                   , INTENT(  out) ::   pmax         ! Global maximum of ptab
-      INTEGER                    , INTENT(  out) ::   ki, kj, kk   ! index of maximum in global frame
-      !
-      INTEGER  ::   ierror   ! local integer
-      REAL(wp) ::   zmax     ! local maximum
-      REAL(wp), DIMENSION(2,1) ::   zain, zaout
-      INTEGER , DIMENSION(3)   ::   ilocs
-      !!-----------------------------------------------------------------------
-      !
-      zmax  = MAXVAL( ptab(:,:,:) , mask= pmask == 1._wp )
-      ilocs = MAXLOC( ptab(:,:,:) , mask= pmask == 1._wp )
-      !
-      ki = ilocs(1) + nimpp - 1
-      kj = ilocs(2) + njmpp - 1
-      kk = ilocs(3)
-      !
-      zain(1,:) = zmax
-      zain(2,:) = ki + 10000.*kj + 100000000.*kk
-      !
-      CALL MPI_ALLREDUCE( zain,zaout, 1, MPI_2DOUBLE_PRECISION,MPI_MAXLOC,MPI_COMM_OCE,ierror)
-      !
-      pmax = zaout(1,1)
-      kk   = INT( zaout(2,1) / 100000000. )
-      kj   = INT( zaout(2,1) - kk * 100000000. ) / 10000
-      ki   = INT( zaout(2,1) - kk * 100000000. -kj * 10000. )
-      !
-   END SUBROUTINE mpp_maxloc3d
-
+#  define OPERATION_MINLOC
+#  define DIM_2d
+#     define ROUTINE_LOC           mpp_minloc2d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_2d
+#  define DIM_3d
+#     define ROUTINE_LOC           mpp_minloc3d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_3d
+#  undef OPERATION_MINLOC
+
+#  define OPERATION_MAXLOC
+#  define DIM_2d
+#     define ROUTINE_LOC           mpp_maxloc2d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_2d
+#  define DIM_3d
+#     define ROUTINE_LOC           mpp_maxloc3d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_3d
+#  undef OPERATION_MAXLOC
 
    SUBROUTINE mppsync()
@@ -973,5 +878,5 @@
 
 
-   SUBROUTINE mppstop
+   SUBROUTINE mppstop( ldfinal, ld_force_abort ) 
       !!----------------------------------------------------------------------
       !!                  ***  routine mppstop  ***
@@ -980,9 +885,21 @@
       !!
       !!----------------------------------------------------------------------
+      LOGICAL, OPTIONAL, INTENT(in) :: ldfinal    ! source process number
+      LOGICAL, OPTIONAL, INTENT(in) :: ld_force_abort    ! source process number
+      LOGICAL ::   llfinal, ll_force_abort
       INTEGER ::   info
       !!----------------------------------------------------------------------
-      !
-      CALL mppsync
-      CALL mpi_finalize( info )
+      llfinal = .FALSE.
+      IF( PRESENT(ldfinal) ) llfinal = ldfinal
+      ll_force_abort = .FALSE.
+      IF( PRESENT(ld_force_abort) ) ll_force_abort = ld_force_abort
+      !
+      IF(ll_force_abort) THEN
+         CALL mpi_abort( MPI_COMM_WORLD )
+      ELSE
+         CALL mppsync
+         CALL mpi_finalize( info )
+      ENDIF
+      IF( .NOT. llfinal ) STOP 123456
       !
    END SUBROUTINE mppstop
@@ -999,87 +916,4 @@
       !
    END SUBROUTINE mpp_comm_free
-
-
-   SUBROUTINE mpp_ini_ice( pindic, kumout )
-      !!----------------------------------------------------------------------
-      !!               ***  routine mpp_ini_ice  ***
-      !!
-      !! ** Purpose :   Initialize special communicator for ice areas
-      !!      condition together with global variables needed in the ddmpp folding
-      !!
-      !! ** Method  : - Look for ice processors in ice routines
-      !!              - Put their number in nrank_ice
-      !!              - Create groups for the world processors and the ice processors
-      !!              - Create a communicator for ice processors
-      !!
-      !! ** output
-      !!      njmppmax = njmpp for northern procs
-      !!      ndim_rank_ice = number of processors with ice
-      !!      nrank_ice (ndim_rank_ice) = ice processors
-      !!      ngrp_iworld = group ID for the world processors
-      !!      ngrp_ice = group ID for the ice processors
-      !!      ncomm_ice = communicator for the ice procs.
-      !!      n_ice_root = number (in the world) of proc 0 in the ice comm.
-      !!
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   pindic
-      INTEGER, INTENT(in) ::   kumout   ! ocean.output logical unit
-      !!
-      INTEGER :: jjproc
-      INTEGER :: ii, ierr
-      INTEGER, ALLOCATABLE, DIMENSION(:) ::   kice
-      INTEGER, ALLOCATABLE, DIMENSION(:) ::   zwork
-      !!----------------------------------------------------------------------
-      !
-      ALLOCATE( kice(jpnij), zwork(jpnij), STAT=ierr )
-      IF( ierr /= 0 ) THEN
-         WRITE(kumout, cform_err)
-         WRITE(kumout,*) 'mpp_ini_ice : failed to allocate 2, 1D arrays (jpnij in length)'
-         CALL mppstop
-      ENDIF
-
-      ! Look for how many procs with sea-ice
-      !
-      kice = 0
-      DO jjproc = 1, jpnij
-         IF( jjproc == narea .AND. pindic .GT. 0 )   kice(jjproc) = 1
-      END DO
-      !
-      zwork = 0
-      CALL MPI_ALLREDUCE( kice, zwork, jpnij, mpi_integer, mpi_sum, mpi_comm_oce, ierr )
-      ndim_rank_ice = SUM( zwork )
-
-      ! Allocate the right size to nrank_north
-      IF( ALLOCATED ( nrank_ice ) )   DEALLOCATE( nrank_ice )
-      ALLOCATE( nrank_ice(ndim_rank_ice) )
-      !
-      ii = 0
-      nrank_ice = 0
-      DO jjproc = 1, jpnij
-         IF( zwork(jjproc) == 1) THEN
-            ii = ii + 1
-            nrank_ice(ii) = jjproc -1
-         ENDIF
-      END DO
-
-      ! Create the world group
-      CALL MPI_COMM_GROUP( mpi_comm_oce, ngrp_iworld, ierr )
-
-      ! Create the ice group from the world group
-      CALL MPI_GROUP_INCL( ngrp_iworld, ndim_rank_ice, nrank_ice, ngrp_ice, ierr )
-
-      ! Create the ice communicator , ie the pool of procs with sea-ice
-      CALL MPI_COMM_CREATE( mpi_comm_oce, ngrp_ice, ncomm_ice, ierr )
-
-      ! Find proc number in the world of proc 0 in the north
-      ! The following line seems to be useless, we just comment & keep it as reminder
-      ! CALL MPI_GROUP_TRANSLATE_RANKS(ngrp_ice,1,0,ngrp_iworld,n_ice_root,ierr)
-      !
-      CALL MPI_GROUP_FREE(ngrp_ice, ierr)
-      CALL MPI_GROUP_FREE(ngrp_iworld, ierr)
-
-      DEALLOCATE(kice, zwork)
-      !
-   END SUBROUTINE mpp_ini_ice
 
 
@@ -1175,5 +1009,5 @@
          l_znl_root = .FALSE.
          kwork (1) = nimpp
-         CALL mpp_min ( kwork(1), kcom = ncomm_znl)
+         CALL mpp_min ( 'lib_mpp', kwork(1), kcom = ncomm_znl)
          IF ( nimpp == kwork(1)) l_znl_root = .TRUE.
       END IF
@@ -1384,7 +1218,11 @@
       !
       itaille = jpimax * ( ipj + 2*kextj )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
       CALL MPI_ALLGATHER( znorthloc_e(1,1-kextj)    , itaille, MPI_DOUBLE_PRECISION,    &
          &                znorthgloio_e(1,1-kextj,1), itaille, MPI_DOUBLE_PRECISION,    &
          &                ncomm_north, ierr )
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
       !
       DO jr = 1, ndim_rank_north            ! recover the global north array
@@ -1418,5 +1256,5 @@
 
 
-   SUBROUTINE mpp_lnk_2d_icb( pt2d, cd_type, psgn, kexti, kextj )
+   SUBROUTINE mpp_lnk_2d_icb( cdname, pt2d, cd_type, psgn, kexti, kextj )
       !!----------------------------------------------------------------------
       !!                  ***  routine mpp_lnk_2d_icb  ***
@@ -1440,4 +1278,5 @@
       !!                    nono   : number for local neighboring processors
       !!----------------------------------------------------------------------
+      CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(wp), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
       CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
@@ -1459,4 +1298,5 @@
       iprecj = nn_hls + kextj
 
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, 1, 1, 1, ld_lbc = .TRUE. )
 
       ! 1. standard boundary treatment
@@ -1510,4 +1350,6 @@
       !                           ! Migrations
       imigr = ipreci * ( jpj + 2*kextj )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
       SELECT CASE ( nbondi )
@@ -1529,4 +1371,6 @@
       END SELECT
       !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
       !                           ! Write Dirichlet lateral conditions
       iihom = jpi - nn_hls
@@ -1563,4 +1407,6 @@
       !                           ! Migrations
       imigr = iprecj * ( jpi + 2*kexti )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
       SELECT CASE ( nbondj )
@@ -1582,4 +1428,6 @@
       END SELECT
       !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
       !                           ! Write Dirichlet lateral conditions
       ijhom = jpj - nn_hls
@@ -1602,4 +1450,126 @@
       !
    END SUBROUTINE mpp_lnk_2d_icb
+
+
+   SUBROUTINE mpp_report( cdname, kpk, kpl, kpf, ld_lbc, ld_glb )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_report  ***
+      !!
+      !! ** Purpose :   report use of mpp routines per time-setp
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),           INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      INTEGER         , OPTIONAL, INTENT(in   ) ::   kpk, kpl, kpf
+      LOGICAL         , OPTIONAL, INTENT(in   ) ::   ld_lbc, ld_glb
+      !!
+      LOGICAL ::   ll_lbc, ll_glb
+      INTEGER ::    ji,  jj,  jk,  jh, jf   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      ll_lbc = .FALSE.
+      IF( PRESENT(ld_lbc) ) ll_lbc = ld_lbc
+      ll_glb = .FALSE.
+      IF( PRESENT(ld_glb) ) ll_glb = ld_glb
+      !
+      ! find the smallest common frequency: default = frequency product, if multiple, choose the larger of the 2 frequency
+      IF( ncom_dttrc /= 1 )   CALL ctl_stop( 'STOP', 'mpp_report, ncom_dttrc /= 1 not coded...' ) 
+      ncom_freq = ncom_fsbc
+      !
+      IF ( ncom_stp == nit000+ncom_freq ) THEN   ! avoid to count extra communications in potential initializations at nit000
+         IF( ll_lbc ) THEN
+            IF( .NOT. ALLOCATED(ncomm_sequence) ) ALLOCATE( ncomm_sequence(ncom_rec_max,2) )
+            IF( .NOT. ALLOCATED(    crname_lbc) ) ALLOCATE(     crname_lbc(ncom_rec_max  ) )
+            n_sequence_lbc = n_sequence_lbc + 1
+            IF( n_sequence_lbc > ncom_rec_max ) CALL ctl_stop( 'STOP', 'lib_mpp, increase ncom_rec_max' )   ! deadlock
+            crname_lbc(n_sequence_lbc) = cdname     ! keep the name of the calling routine
+            ncomm_sequence(n_sequence_lbc,1) = kpk*kpl   ! size of 3rd and 4th dimensions
+            ncomm_sequence(n_sequence_lbc,2) = kpf       ! number of arrays to be treated (multi)
+         ENDIF
+         IF( ll_glb ) THEN
+            IF( .NOT. ALLOCATED(crname_glb) ) ALLOCATE( crname_glb(ncom_rec_max) )
+            n_sequence_glb = n_sequence_glb + 1
+            IF( n_sequence_glb > ncom_rec_max ) CALL ctl_stop( 'STOP', 'lib_mpp, increase ncom_rec_max' )   ! deadlock
+            crname_glb(n_sequence_glb) = cdname     ! keep the name of the calling routine
+         ENDIF
+      ELSE IF ( ncom_stp == nit000+2*ncom_freq ) THEN
+         CALL ctl_opn( numcom, 'communication_report.txt', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
+         WRITE(numcom,*) ' '
+         WRITE(numcom,*) ' ------------------------------------------------------------'
+         WRITE(numcom,*) ' Communication pattern report (second oce+sbc+top time step):'
+         WRITE(numcom,*) ' ------------------------------------------------------------'
+         WRITE(numcom,*) ' '
+         WRITE(numcom,'(A,I4)') ' Exchanged halos : ', n_sequence_lbc
+         jj = 0; jk = 0; jf = 0; jh = 0
+         DO ji = 1, n_sequence_lbc
+            IF ( ncomm_sequence(ji,1) .GT. 1 ) jk = jk + 1
+            IF ( ncomm_sequence(ji,2) .GT. 1 ) jf = jf + 1
+            IF ( ncomm_sequence(ji,1) .GT. 1 .AND. ncomm_sequence(ji,2) .GT. 1 ) jj = jj + 1
+            jh = MAX (jh, ncomm_sequence(ji,1)*ncomm_sequence(ji,2))
+         END DO
+         WRITE(numcom,'(A,I3)') ' 3D Exchanged halos : ', jk
+         WRITE(numcom,'(A,I3)') ' Multi arrays exchanged halos : ', jf
+         WRITE(numcom,'(A,I3)') '   from which 3D : ', jj
+         WRITE(numcom,'(A,I10)') ' Array max size : ', jh*jpi*jpj
+         WRITE(numcom,*) ' '
+         WRITE(numcom,*) ' lbc_lnk called'
+         jj = 1
+         DO ji = 2, n_sequence_lbc
+            IF( crname_lbc(ji-1) /= crname_lbc(ji) ) THEN
+               WRITE(numcom,'(A, I4, A, A)') ' - ', jj,' times by subroutine ', TRIM(crname_lbc(ji-1))
+               jj = 0
+            END IF
+            jj = jj + 1 
+         END DO
+         WRITE(numcom,'(A, I4, A, A)') ' - ', jj,' times by subroutine ', TRIM(crname_lbc(n_sequence_lbc))
+         WRITE(numcom,*) ' '
+         IF ( n_sequence_glb > 0 ) THEN
+            WRITE(numcom,'(A,I4)') ' Global communications : ', n_sequence_glb
+            jj = 1
+            DO ji = 2, n_sequence_glb
+               IF( crname_glb(ji-1) /= crname_glb(ji) ) THEN
+                  WRITE(numcom,'(A, I4, A, A)') ' - ', jj,' times by subroutine ', TRIM(crname_glb(ji-1))
+                  jj = 0
+               END IF
+               jj = jj + 1 
+            END DO
+            WRITE(numcom,'(A, I4, A, A)') ' - ', jj,' times by subroutine ', TRIM(crname_glb(n_sequence_glb))
+            DEALLOCATE(crname_glb)
+         ELSE
+            WRITE(numcom,*) ' No MPI global communication '
+         ENDIF
+         WRITE(numcom,*) ' '
+         WRITE(numcom,*) ' -----------------------------------------------'
+         WRITE(numcom,*) ' '
+         DEALLOCATE(ncomm_sequence)
+         DEALLOCATE(crname_lbc)
+      ENDIF
+   END SUBROUTINE mpp_report
+
+   
+   SUBROUTINE tic_tac (ld_tic, ld_global)
+
+    LOGICAL,           INTENT(IN) :: ld_tic
+    LOGICAL, OPTIONAL, INTENT(IN) :: ld_global
+    REAL(wp), DIMENSION(2), SAVE :: tic_wt
+    REAL(wp),               SAVE :: tic_ct = 0._wp
+    INTEGER :: ii
+
+    IF( ncom_stp <= nit000 ) RETURN
+    IF( ncom_stp == nitend ) RETURN
+    ii = 1
+    IF( PRESENT( ld_global ) ) THEN
+       IF( ld_global ) ii = 2
+    END IF
+    
+    IF ( ld_tic ) THEN
+       tic_wt(ii) = MPI_Wtime()                                                    ! start count tic->tac (waiting time)
+       IF ( tic_ct > 0.0_wp ) compute_time = compute_time + MPI_Wtime() - tic_ct   ! cumulate count tac->tic
+    ELSE
+       waiting_time(ii) = waiting_time(ii) + MPI_Wtime() - tic_wt(ii)              ! cumulate count tic->tac
+       tic_ct = MPI_Wtime()                                                        ! start count tac->tic (waiting time)
+    ENDIF
+    
+   END SUBROUTINE tic_tac
+
    
 #else
@@ -1610,5 +1580,5 @@
 
    INTERFACE mpp_sum
-      MODULE PROCEDURE mpp_sum_a2s, mpp_sum_as, mpp_sum_ai, mpp_sum_s, mpp_sum_i, mppsum_realdd, mppsum_a_realdd
+      MODULE PROCEDURE mppsum_int, mppsum_a_int, mppsum_real, mppsum_a_real, mppsum_realdd, mppsum_a_realdd
    END INTERFACE
    INTERFACE mpp_max
@@ -1624,12 +1594,18 @@
       MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
    END INTERFACE
-   INTERFACE mpp_max_multiple
-      MODULE PROCEDURE mppmax_real_multiple
-   END INTERFACE
 
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.      !: mpp flag
    LOGICAL, PUBLIC            ::   ln_nnogather          !: namelist control of northfold comms (needed here in case "key_mpp_mpi" is not used)
-   INTEGER :: ncomm_ice
    INTEGER, PUBLIC            ::   mpi_comm_oce          ! opa local communicator
+
+   INTEGER, PARAMETER, PUBLIC               ::   nbdelay = 0   ! make sure we don't enter loops: DO ji = 1, nbdelay
+   CHARACTER(len=32), DIMENSION(1), PUBLIC  ::   c_delaylist = 'empty'
+   CHARACTER(len=32), DIMENSION(1), PUBLIC  ::   c_delaycpnt = 'empty'
+   TYPE ::   DELAYARR
+      REAL(   wp), POINTER, DIMENSION(:) ::  z1d => NULL()
+      COMPLEX(wp), POINTER, DIMENSION(:) ::  y1d => NULL()
+   END TYPE DELAYARR
+   TYPE( DELAYARR ), DIMENSION(1), PUBLIC  ::   todelay              
+   INTEGER,  PUBLIC, DIMENSION(1)           ::   ndelayid = -1
    !!----------------------------------------------------------------------
 CONTAINS
@@ -1654,138 +1630,181 @@
    END SUBROUTINE mppsync
 
-   SUBROUTINE mpp_sum_as( parr, kdim, kcom )      ! Dummy routine
-      REAL   , DIMENSION(:) :: parr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mpp_sum_as: You should not have seen this print! error?', kdim, parr(1), kcom
-   END SUBROUTINE mpp_sum_as
-
-   SUBROUTINE mpp_sum_a2s( parr, kdim, kcom )      ! Dummy routine
-      REAL   , DIMENSION(:,:) :: parr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mpp_sum_a2s: You should not have seen this print! error?', kdim, parr(1,1), kcom
-   END SUBROUTINE mpp_sum_a2s
-
-   SUBROUTINE mpp_sum_ai( karr, kdim, kcom )      ! Dummy routine
-      INTEGER, DIMENSION(:) :: karr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mpp_sum_ai: You should not have seen this print! error?', kdim, karr(1), kcom
-   END SUBROUTINE mpp_sum_ai
-
-   SUBROUTINE mpp_sum_s( psca, kcom )            ! Dummy routine
-      REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mpp_sum_s: You should not have seen this print! error?', psca, kcom
-   END SUBROUTINE mpp_sum_s
-
-   SUBROUTINE mpp_sum_i( kint, kcom )            ! Dummy routine
-      integer               :: kint
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mpp_sum_i: You should not have seen this print! error?', kint, kcom
-   END SUBROUTINE mpp_sum_i
-
-   SUBROUTINE mppsum_realdd( ytab, kcom )
-      COMPLEX(wp), INTENT(inout)         :: ytab    ! input scalar
-      INTEGER , INTENT( in  ), OPTIONAL :: kcom
-      WRITE(*,*) 'mppsum_realdd: You should not have seen this print! error?', ytab
-   END SUBROUTINE mppsum_realdd
-
-   SUBROUTINE mppsum_a_realdd( ytab, kdim, kcom )
-      INTEGER , INTENT( in )                        ::   kdim      ! size of ytab
-      COMPLEX(wp), DIMENSION(kdim), INTENT( inout ) ::   ytab      ! input array
-      INTEGER , INTENT( in  ), OPTIONAL :: kcom
-      WRITE(*,*) 'mppsum_a_realdd: You should not have seen this print! error?', kdim, ytab(1), kcom
-   END SUBROUTINE mppsum_a_realdd
-
-   SUBROUTINE mppmax_a_real( parr, kdim, kcom )
-      REAL   , DIMENSION(:) :: parr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmax_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
-   END SUBROUTINE mppmax_a_real
-
-   SUBROUTINE mppmax_real( psca, kcom )
-      REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmax_real: You should not have seen this print! error?', psca, kcom
-   END SUBROUTINE mppmax_real
-
-   SUBROUTINE mppmin_a_real( parr, kdim, kcom )
-      REAL   , DIMENSION(:) :: parr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmin_a_real: You should not have seen this print! error?', kdim, parr(1), kcom
-   END SUBROUTINE mppmin_a_real
-
-   SUBROUTINE mppmin_real( psca, kcom )
-      REAL                  :: psca
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmin_real: You should not have seen this print! error?', psca, kcom
-   END SUBROUTINE mppmin_real
-
-   SUBROUTINE mppmax_a_int( karr, kdim ,kcom)
-      INTEGER, DIMENSION(:) :: karr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmax_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
-   END SUBROUTINE mppmax_a_int
-
-   SUBROUTINE mppmax_int( kint, kcom)
-      INTEGER               :: kint
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmax_int: You should not have seen this print! error?', kint, kcom
-   END SUBROUTINE mppmax_int
-
-   SUBROUTINE mppmin_a_int( karr, kdim, kcom )
-      INTEGER, DIMENSION(:) :: karr
-      INTEGER               :: kdim
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmin_a_int: You should not have seen this print! error?', kdim, karr(1), kcom
-   END SUBROUTINE mppmin_a_int
-
-   SUBROUTINE mppmin_int( kint, kcom )
-      INTEGER               :: kint
-      INTEGER, OPTIONAL     :: kcom
-      WRITE(*,*) 'mppmin_int: You should not have seen this print! error?', kint, kcom
-   END SUBROUTINE mppmin_int
-
-   SUBROUTINE mpp_minloc2d( ptab, pmask, pmin, ki, kj )
-      REAL                   :: pmin
-      REAL , DIMENSION (:,:) :: ptab, pmask
-      INTEGER :: ki, kj
-      WRITE(*,*) 'mpp_minloc2d: You should not have seen this print! error?', pmin, ki, kj, ptab(1,1), pmask(1,1)
-   END SUBROUTINE mpp_minloc2d
-
-   SUBROUTINE mpp_minloc3d( ptab, pmask, pmin, ki, kj, kk )
-      REAL                     :: pmin
-      REAL , DIMENSION (:,:,:) :: ptab, pmask
-      INTEGER :: ki, kj, kk
-      WRITE(*,*) 'mpp_minloc3d: You should not have seen this print! error?', pmin, ki, kj, kk, ptab(1,1,1), pmask(1,1,1)
-   END SUBROUTINE mpp_minloc3d
-
-   SUBROUTINE mpp_maxloc2d( ptab, pmask, pmax, ki, kj )
-      REAL                   :: pmax
-      REAL , DIMENSION (:,:) :: ptab, pmask
-      INTEGER :: ki, kj
-      WRITE(*,*) 'mpp_maxloc2d: You should not have seen this print! error?', pmax, ki, kj, ptab(1,1), pmask(1,1)
-   END SUBROUTINE mpp_maxloc2d
-
-   SUBROUTINE mpp_maxloc3d( ptab, pmask, pmax, ki, kj, kk )
-      REAL                     :: pmax
-      REAL , DIMENSION (:,:,:) :: ptab, pmask
-      INTEGER :: ki, kj, kk
-      WRITE(*,*) 'mpp_maxloc3d: You should not have seen this print! error?', pmax, ki, kj, kk, ptab(1,1,1), pmask(1,1,1)
-   END SUBROUTINE mpp_maxloc3d
-
-   SUBROUTINE mppstop
+   !!----------------------------------------------------------------------
+   !!    ***  mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real  ***
+   !!   
+   !!----------------------------------------------------------------------
+   !!
+#  define OPERATION_MAX
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmax_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmax_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmax_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmax_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_MAX
+   !!----------------------------------------------------------------------
+   !!    ***  mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real  ***
+   !!   
+   !!----------------------------------------------------------------------
+   !!
+#  define OPERATION_MIN
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmin_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmin_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppmin_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppmin_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_MIN
+
+   !!----------------------------------------------------------------------
+   !!    ***  mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real  ***
+   !!   
+   !!   Global sum of 1D array or a variable (integer, real or complex)
+   !!----------------------------------------------------------------------
+   !!
+#  define OPERATION_SUM
+#  define INTEGER_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_int
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef INTEGER_TYPE
+!
+#  define REAL_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_real
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef REAL_TYPE
+#  undef OPERATION_SUM
+
+#  define OPERATION_SUM_DD
+#  define COMPLEX_TYPE
+#  define DIM_0d
+#     define ROUTINE_ALLREDUCE           mppsum_realdd
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_0d
+#  define DIM_1d
+#     define ROUTINE_ALLREDUCE           mppsum_a_realdd
+#     include "mpp_allreduce_generic.h90"
+#     undef ROUTINE_ALLREDUCE
+#  undef DIM_1d
+#  undef COMPLEX_TYPE
+#  undef OPERATION_SUM_DD
+
+   !!----------------------------------------------------------------------
+   !!    ***  mpp_minloc2d, mpp_minloc3d, mpp_maxloc2d, mpp_maxloc3d
+   !!   
+   !!----------------------------------------------------------------------
+   !!
+#  define OPERATION_MINLOC
+#  define DIM_2d
+#     define ROUTINE_LOC           mpp_minloc2d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_2d
+#  define DIM_3d
+#     define ROUTINE_LOC           mpp_minloc3d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_3d
+#  undef OPERATION_MINLOC
+
+#  define OPERATION_MAXLOC
+#  define DIM_2d
+#     define ROUTINE_LOC           mpp_maxloc2d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_2d
+#  define DIM_3d
+#     define ROUTINE_LOC           mpp_maxloc3d
+#     include "mpp_loc_generic.h90"
+#     undef ROUTINE_LOC
+#  undef DIM_3d
+#  undef OPERATION_MAXLOC
+
+   SUBROUTINE mpp_delay_sum( cdname, cdelay, y_in, pout, ldlast, kcom )
+      CHARACTER(len=*), INTENT(in   )               ::   cdname  ! name of the calling subroutine
+      CHARACTER(len=*), INTENT(in   )               ::   cdelay  ! name (used as id) of the delayed operation
+      COMPLEX(wp),      INTENT(in   ), DIMENSION(:) ::   y_in
+      REAL(wp),         INTENT(  out), DIMENSION(:) ::   pout
+      LOGICAL,          INTENT(in   )               ::   ldlast  ! true if this is the last time we call this routine
+      INTEGER,          INTENT(in   ), OPTIONAL     ::   kcom
+      !
+      pout(:) = REAL(y_in(:), wp)
+   END SUBROUTINE mpp_delay_sum
+
+   SUBROUTINE mpp_delay_max( cdname, cdelay, p_in, pout, ldlast, kcom )
+      CHARACTER(len=*), INTENT(in   )               ::   cdname  ! name of the calling subroutine
+      CHARACTER(len=*), INTENT(in   )               ::   cdelay  ! name (used as id) of the delayed operation
+      REAL(wp),         INTENT(in   ), DIMENSION(:) ::   p_in
+      REAL(wp),         INTENT(  out), DIMENSION(:) ::   pout
+      LOGICAL,          INTENT(in   )               ::   ldlast  ! true if this is the last time we call this routine
+      INTEGER,          INTENT(in   ), OPTIONAL     ::   kcom
+      !
+      pout(:) = p_in(:)
+   END SUBROUTINE mpp_delay_max
+
+   SUBROUTINE mpp_delay_rcv( kid )
+      INTEGER,INTENT(in   )      ::  kid 
+      WRITE(*,*) 'mpp_delay_rcv: You should not have seen this print! error?', kid
+   END SUBROUTINE mpp_delay_rcv
+   
+   SUBROUTINE mppstop( ldfinal, ld_force_abort )
+      LOGICAL, OPTIONAL, INTENT(in) :: ldfinal    ! source process number
+      LOGICAL, OPTIONAL, INTENT(in) :: ld_force_abort    ! source process number
       STOP      ! non MPP case, just stop the run
    END SUBROUTINE mppstop
-
-   SUBROUTINE mpp_ini_ice( kcom, knum )
-      INTEGER :: kcom, knum
-      WRITE(*,*) 'mpp_ini_ice: You should not have seen this print! error?', kcom, knum
-   END SUBROUTINE mpp_ini_ice
 
    SUBROUTINE mpp_ini_znl( knum )
@@ -1799,11 +1818,4 @@
    END SUBROUTINE mpp_comm_free
    
-   SUBROUTINE mppmax_real_multiple( ptab, kdim , kcom  )
-      REAL, DIMENSION(:) ::   ptab   ! 
-      INTEGER            ::   kdim   ! 
-      INTEGER, OPTIONAL  ::   kcom   ! 
-      WRITE(*,*) 'mppmax_real_multiple: You should not have seen this print! error?', ptab(1), kdim
-   END SUBROUTINE mppmax_real_multiple
-
 #endif
 
@@ -1825,17 +1837,20 @@
       !
       nstop = nstop + 1
-      IF(lwp) THEN
-         WRITE(numout,cform_err)
-         IF( PRESENT(cd1 ) )   WRITE(numout,*) cd1
-         IF( PRESENT(cd2 ) )   WRITE(numout,*) cd2
-         IF( PRESENT(cd3 ) )   WRITE(numout,*) cd3
-         IF( PRESENT(cd4 ) )   WRITE(numout,*) cd4
-         IF( PRESENT(cd5 ) )   WRITE(numout,*) cd5
-         IF( PRESENT(cd6 ) )   WRITE(numout,*) cd6
-         IF( PRESENT(cd7 ) )   WRITE(numout,*) cd7
-         IF( PRESENT(cd8 ) )   WRITE(numout,*) cd8
-         IF( PRESENT(cd9 ) )   WRITE(numout,*) cd9
-         IF( PRESENT(cd10) )   WRITE(numout,*) cd10
-      ENDIF
+
+      ! force to open ocean.output file
+      IF( numout == 6 ) CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+       
+      WRITE(numout,cform_err)
+      IF( PRESENT(cd1 ) )   WRITE(numout,*) TRIM(cd1)
+      IF( PRESENT(cd2 ) )   WRITE(numout,*) TRIM(cd2)
+      IF( PRESENT(cd3 ) )   WRITE(numout,*) TRIM(cd3)
+      IF( PRESENT(cd4 ) )   WRITE(numout,*) TRIM(cd4)
+      IF( PRESENT(cd5 ) )   WRITE(numout,*) TRIM(cd5)
+      IF( PRESENT(cd6 ) )   WRITE(numout,*) TRIM(cd6)
+      IF( PRESENT(cd7 ) )   WRITE(numout,*) TRIM(cd7)
+      IF( PRESENT(cd8 ) )   WRITE(numout,*) TRIM(cd8)
+      IF( PRESENT(cd9 ) )   WRITE(numout,*) TRIM(cd9)
+      IF( PRESENT(cd10) )   WRITE(numout,*) TRIM(cd10)
+
                                CALL FLUSH(numout    )
       IF( numstp     /= -1 )   CALL FLUSH(numstp    )
@@ -1844,6 +1859,6 @@
       !
       IF( cd1 == 'STOP' ) THEN
-         IF(lwp) WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
-         CALL mppstop()
+         WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
+         CALL mppstop(ld_force_abort = .true.)
       ENDIF
       !
@@ -1866,14 +1881,14 @@
       IF(lwp) THEN
          WRITE(numout,cform_war)
-         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
-         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
-         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
-         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
-         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
-         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
-         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
-         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
-         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
-         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) TRIM(cd1)
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) TRIM(cd2)
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) TRIM(cd3)
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) TRIM(cd4)
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) TRIM(cd5)
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) TRIM(cd6)
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) TRIM(cd7)
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) TRIM(cd8)
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) TRIM(cd9)
+         IF( PRESENT(cd10) ) WRITE(numout,*) TRIM(cd10)
       ENDIF
       CALL FLUSH(numout)
@@ -1916,14 +1931,19 @@
       knum=get_unit()
 #endif
+      IF( TRIM(cdfile) == '/dev/null' )   clfile = TRIM(cdfile)   ! force the use of /dev/null
       !
       iost=0
-      IF( cdacce(1:6) == 'DIRECT' )  THEN
-         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
+      IF( cdacce(1:6) == 'DIRECT' )  THEN         ! cdacce has always more than 6 characters
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh         , ERR=100, IOSTAT=iost )
+      ELSE IF( TRIM(cdstat) == 'APPEND' )  THEN   ! cdstat can have less than 6 characters
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS='UNKNOWN', POSITION='APPEND', ERR=100, IOSTAT=iost )
       ELSE
-         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
-      ENDIF
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat                      , ERR=100, IOSTAT=iost )
+      ENDIF
+      IF( iost /= 0 .AND. TRIM(clfile) == '/dev/null' ) &   ! for windows
+         &  OPEN(UNIT=knum,FILE='NUL', FORM=cdform, ACCESS=cdacce, STATUS=cdstat                      , ERR=100, IOSTAT=iost )   
       IF( iost == 0 ) THEN
          IF(ldwp) THEN
-            WRITE(kout,*) '     file   : ', clfile,' open ok'
+            WRITE(kout,*) '     file   : ', TRIM(clfile),' open ok'
             WRITE(kout,*) '     unit   = ', knum
             WRITE(kout,*) '     status = ', cdstat
@@ -1937,5 +1957,5 @@
          IF(ldwp) THEN
             WRITE(kout,*)
-            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
+            WRITE(kout,*) ' ===>>>> : bad opening file: ', TRIM(clfile)
             WRITE(kout,*) ' =======   ===  '
             WRITE(kout,*) '           unit   = ', knum
@@ -1948,5 +1968,5 @@
          ELSE  !!! Force writing to make sure we get the information - at least once - in this violent STOP!!
             WRITE(*,*)
-            WRITE(*,*) ' ===>>>> : bad opening file: ', clfile
+            WRITE(*,*) ' ===>>>> : bad opening file: ', TRIM(clfile)
             WRITE(*,*) ' =======   ===  '
             WRITE(*,*) '           unit   = ', knum
Index: /NEMO/trunk/src/OCE/LBC/mpp_allreduce_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mpp_allreduce_generic.h90	(revision 10425)
+++ /NEMO/trunk/src/OCE/LBC/mpp_allreduce_generic.h90	(revision 10425)
@@ -0,0 +1,82 @@
+!                          !==  IN: ptab is an array  ==!
+#   if defined REAL_TYPE
+#      define ARRAY_TYPE(i)    REAL(wp)         , INTENT(inout) ::   ARRAY_IN(i)
+#      define TMP_TYPE(i)      REAL(wp)         , ALLOCATABLE   ::   work(i)
+#      define MPI_TYPE mpi_double_precision
+#   endif
+#   if defined INTEGER_TYPE
+#      define ARRAY_TYPE(i)    INTEGER          , INTENT(inout) ::   ARRAY_IN(i)
+#      define TMP_TYPE(i)      INTEGER          , ALLOCATABLE   ::   work(i)
+#      define MPI_TYPE mpi_integer
+#   endif
+#   if defined COMPLEX_TYPE
+#      define ARRAY_TYPE(i)    COMPLEX          , INTENT(inout) ::   ARRAY_IN(i)
+#      define TMP_TYPE(i)      COMPLEX          , ALLOCATABLE   ::   work(i)
+#      define MPI_TYPE mpi_double_complex
+#   endif
+#   if defined DIM_0d
+#      define ARRAY_IN(i)   ptab
+#      define I_SIZE(ptab)          1
+#   endif
+#   if defined DIM_1d
+#      define ARRAY_IN(i)   ptab(i)
+#      define I_SIZE(ptab)          SIZE(ptab,1)
+#   endif
+#   if defined OPERATION_MAX
+#      define MPI_OPERATION mpi_max
+#   endif
+#   if defined OPERATION_MIN
+#      define MPI_OPERATION mpi_min
+#   endif
+#   if defined OPERATION_SUM
+#      define MPI_OPERATION mpi_sum
+#   endif
+#   if defined OPERATION_SUM_DD
+#      define MPI_OPERATION mpi_sumdd
+#   endif
+
+   SUBROUTINE ROUTINE_ALLREDUCE( cdname, ptab, kdim, kcom )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
+      ARRAY_TYPE(:)   ! array or pointer of arrays on which the boundary condition is applied
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kdim        ! optional pointer dimension
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kcom        ! optional communicator
+#if defined key_mpp_mpi
+      !
+      INTEGER :: ipi, ii, ierr
+      INTEGER :: ierror, ilocalcomm
+      TMP_TYPE(:)
+      !!-----------------------------------------------------------------------
+      !
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ld_glb = .TRUE. )
+      !
+      ilocalcomm = mpi_comm_oce
+      IF( PRESENT(kcom) )   ilocalcomm = kcom
+      !
+      IF( PRESENT(kdim) ) then
+         ipi = kdim
+      ELSE
+         ipi = I_SIZE(ptab)   ! 1st dimension
+      ENDIF
+      !
+      ALLOCATE(work(ipi))
+      IF( ln_timing ) CALL tic_tac(.TRUE., ld_global = .TRUE.)
+      CALL mpi_allreduce( ARRAY_IN(:), work, ipi, MPI_TYPE, MPI_OPERATION, ilocalcomm, ierror )
+      IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
+      DO ii = 1, ipi
+         ARRAY_IN(ii) = work(ii)
+      ENDDO
+      DEALLOCATE(work)
+#else
+      ! nothing to do if non-mpp case
+      RETURN
+#endif
+
+   END SUBROUTINE ROUTINE_ALLREDUCE
+
+#undef ARRAY_TYPE
+#undef ARRAY_IN
+#undef I_SIZE
+#undef MPI_OPERATION
+#undef TMP_TYPE
+#undef MPI_TYPE
Index: /NEMO/trunk/src/OCE/LBC/mpp_bdy_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mpp_bdy_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/mpp_bdy_generic.h90	(revision 10425)
@@ -21,5 +21,5 @@
 #   endif
 
-   SUBROUTINE ROUTINE_BDY( ptab, cd_nat, psgn      , kb_bdy )
+   SUBROUTINE ROUTINE_BDY( cdname, ptab, cd_nat, psgn      , kb_bdy )
       !!----------------------------------------------------------------------
       !!                  ***  routine mpp_lnk_bdy_3d  ***
@@ -42,4 +42,5 @@
       !!
       !!----------------------------------------------------------------------
+      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       ARRAY_TYPE(:,:,:,:,:)   ! array or pointer of arrays on which the boundary condition is applied
       CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
@@ -61,4 +62,6 @@
       ipl = L_SIZE(ptab)   ! 4th    -
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
+      !
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
       !      
       ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2),   &
@@ -132,4 +135,6 @@
          imigr = nn_hls * jpj * ipk * ipl
          !
+         IF( ln_timing ) CALL tic_tac(.TRUE.)
+         !
          SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )
          CASE ( -1 )
@@ -150,4 +155,6 @@
          END SELECT
          !
+         IF( ln_timing ) CALL tic_tac(.FALSE.)
+         !
          !                           ! Write Dirichlet lateral conditions
          iihom = nlci-nn_hls
@@ -205,4 +212,6 @@
          imigr = nn_hls * jpi * ipk * ipl
          !
+         IF( ln_timing ) CALL tic_tac(.TRUE.)
+         ! 
          SELECT CASE ( nbondj_bdy(IBD_IN(jf)) )
          CASE ( -1 )
@@ -222,4 +231,6 @@
             IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
          END SELECT
+         !
+         IF( ln_timing ) CALL tic_tac(.FALSE.)
          !
          !                           ! Write Dirichlet lateral conditions
Index: /NEMO/trunk/src/OCE/LBC/mpp_lnk_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/mpp_lnk_generic.h90	(revision 10425)
@@ -46,10 +46,11 @@
 
 #if defined MULTI
-   SUBROUTINE ROUTINE_LNK( ptab, cd_nat, psgn, kfld, cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, cd_mpp, pval )
       INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
 #else
-   SUBROUTINE ROUTINE_LNK( ptab, cd_nat, psgn      , cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , cd_mpp, pval )
 #endif
       ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
+      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
       REAL(wp)                    , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
@@ -61,4 +62,5 @@
       INTEGER  ::   imigr, iihom, ijhom          ! local integers
       INTEGER  ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER  ::   ierr
       REAL(wp) ::   zland
       INTEGER , DIMENSION(MPI_STATUS_SIZE)      ::   ml_stat        ! for key_mpi_isend
@@ -71,6 +73,5 @@
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
-      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)  )
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
       !
       IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
@@ -82,26 +83,5 @@
       ! ------------------------------- !
       !
-      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  ==!
+      IF( .NOT. PRESENT( cd_mpp ) ) THEN     !==  standard close or cyclic treatment  ==!
          !
          DO jf = 1, ipf                      ! number of arrays to be treated
@@ -132,6 +112,20 @@
       ! we play with the neigbours AND the row number because of the periodicity
       !
+      IF( ABS(nbondi) == 1 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,1), zt3we(jpj,nn_hls,ipk,ipl,ipf,1) )
+      IF(     nbondi  == 0 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2) )
+      !
       SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+      CASE ( -1 )
+         iihom = nlci-nreci
+         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
+      CASE ( 0 )
          iihom = nlci-nreci
          DO jf = 1, ipf
@@ -145,13 +139,25 @@
             END DO
          END DO
-      END SELECT
-      !
+      CASE ( 1 )
+         iihom = nlci-nreci
+         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
+      END SELECT
       !                           ! Migrations
-      imigr = nn_hls * jpj * ipk * ipl * ipf
+      imigr = nn_hls * jpj * ipk * ipl * ipf      
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
       SELECT CASE ( nbondi )
       CASE ( -1 )
          CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
+         CALL mpprecv( 1, zt3ew(1,1,1,1,1,1), imigr, noea )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
       CASE ( 0 )
@@ -164,7 +170,9 @@
       CASE ( 1 )
          CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
+         CALL mpprecv( 2, zt3we(1,1,1,1,1,1), imigr, nowe )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
       END SELECT
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
       !
       !                           ! Write Dirichlet lateral conditions
@@ -177,5 +185,5 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,1)
                   END DO
                END DO
@@ -198,10 +206,12 @@
                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
+                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,1)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      !
+      IF( nbondi /= 2 ) DEALLOCATE( zt3ew, zt3we )
 
       ! 3. North and south directions
@@ -209,5 +219,20 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( ABS(nbondj) == 1 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,1), zt3sn(jpi,nn_hls,ipk,ipl,ipf,1) )
+      IF(     nbondj  == 0 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2) )
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         ijhom = nlcj-nrecj
+         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
+      CASE ( 0 )
          ijhom = nlcj-nrecj
          DO jf = 1, ipf
@@ -221,13 +246,26 @@
             END DO
          END DO
-      ENDIF
+      CASE ( 1 )
+         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
+      END SELECT
       !
       !                           ! Migrations
       imigr = nn_hls * jpi * ipk * ipl * ipf
       !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      ! 
       SELECT CASE ( nbondj )
       CASE ( -1 )
          CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
+         CALL mpprecv( 3, zt3ns(1,1,1,1,1,1), imigr, nono )
          IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err )
       CASE ( 0 )
@@ -240,8 +278,9 @@
       CASE ( 1 )
          CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
+         CALL mpprecv( 4, zt3sn(1,1,1,1,1,1), imigr, noso )
          IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
       END SELECT
       !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
       !                           ! Write Dirichlet lateral conditions
       ijhom = nlcj-nn_hls
@@ -253,5 +292,5 @@
                DO jk = 1, ipk
                   DO jh = 1, nn_hls
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
+                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,1)
                   END DO
                END DO
@@ -274,10 +313,12 @@
                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
+                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,1)
+                  END DO
+               END DO
+            END DO
+         END DO
+      END SELECT
+      !
+      IF( nbondj /= 2 ) DEALLOCATE( zt3ns, zt3sn )
 
       ! 4. north fold treatment
@@ -293,6 +334,4 @@
       ENDIF
       !
-      DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we )
-      !
    END SUBROUTINE ROUTINE_LNK
 
Index: /NEMO/trunk/src/OCE/LBC/mpp_loc_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mpp_loc_generic.h90	(revision 10425)
+++ /NEMO/trunk/src/OCE/LBC/mpp_loc_generic.h90	(revision 10425)
@@ -0,0 +1,99 @@
+                          !==  IN: ptab is an array  ==!
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)        , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define MASK_TYPE(i,j,k)     REAL(wp)        , INTENT(in   ) ::   MASK_IN(i,j,k)
+#   if defined DIM_2d
+#      define ARRAY_IN(i,j,k)   ptab(i,j)
+#      define MASK_IN(i,j,k)    pmask(i,j)
+#      define INDEX_TYPE(k)        INTEGER         , INTENT(  out) ::   kindex(2)
+#      define K_SIZE(ptab)      1
+#   endif
+#   if defined DIM_3d
+#      define ARRAY_IN(i,j,k)   ptab(i,j,k)
+#      define MASK_IN(i,j,k)    pmask(i,j,k)
+#      define INDEX_TYPE(k)        INTEGER         , INTENT(  out) ::   kindex(3)
+#      define K_SIZE(ptab)      SIZE(ptab,3)
+#   endif
+#   if defined OPERATION_MAXLOC
+#      define MPI_OPERATION mpi_maxloc
+#      define LOC_OPERATION MAXLOC
+#   endif
+#   if defined OPERATION_MINLOC
+#      define MPI_OPERATION mpi_minloc
+#      define LOC_OPERATION MINLOC
+#   endif
+
+   SUBROUTINE ROUTINE_LOC( cdname, ptab, pmask, pmin, kindex )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   ) ::   cdname  ! name of the calling subroutine
+      ARRAY_TYPE(:,:,:)                            ! array on which loctrans operation is applied
+      MASK_TYPE(:,:,:)                             ! local mask
+      REAL(wp)        , INTENT(  out) ::   pmin    ! Global minimum of ptab
+      INDEX_TYPE(:)                                ! index of minimum in global frame
+# if defined key_mpp_mpi
+      !
+      INTEGER  ::   ierror, ii, idim
+      INTEGER  ::   index0
+      REAL(wp) ::   zmin     ! local minimum
+      INTEGER , DIMENSION(:), ALLOCATABLE  ::   ilocs
+      REAL(wp), DIMENSION(2,1) ::   zain, zaout
+      !!-----------------------------------------------------------------------
+      !
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ld_glb = .TRUE. )
+      !
+      idim = SIZE(kindex)
+      ALLOCATE ( ilocs(idim) )
+      !
+      ilocs = LOC_OPERATION( ARRAY_IN(:,:,:) , mask= MASK_IN(:,:,:) == 1._wp )
+      zmin  = ARRAY_IN(ilocs(1),ilocs(2),ilocs(3))
+      !
+      kindex(1) = ilocs(1) + nimpp - 1
+#  if defined DIM_2d || defined DIM_3d    /* avoid warning when kindex has 1 element */
+      kindex(2) = ilocs(2) + njmpp - 1
+#  endif
+#  if defined DIM_3d                      /* avoid warning when kindex has 2 elements */
+      kindex(3) = ilocs(3)
+#  endif
+      ! 
+      DEALLOCATE (ilocs)
+      !
+      index0 = kindex(1)-1   ! 1d index starting at 0
+#  if defined DIM_2d || defined DIM_3d   /* avoid warning when kindex has 1 element */
+      index0 = index0 + jpiglo * (kindex(2)-1)
+#  endif
+#  if defined DIM_3d                     /* avoid warning when kindex has 2 elements */
+      index0 = index0 + jpiglo * jpjglo * (kindex(3)-1)
+#  endif
+      zain(1,:) = zmin
+      zain(2,:) = REAL(index0, wp)
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE., ld_global = .TRUE.)
+      CALL MPI_ALLREDUCE( zain, zaout, 1, MPI_2DOUBLE_PRECISION, MPI_OPERATION ,MPI_COMM_OCE, ierror)
+      IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
+      !
+      pmin      = zaout(1,1)
+      index0    = NINT( zaout(2,1) )
+#  if defined DIM_3d                     /* avoid warning when kindex has 2 elements */
+      kindex(3) = index0 / (jpiglo*jpjglo)
+      index0    = index0 - kindex(3) * (jpiglo*jpjglo)
+#  endif
+#  if defined DIM_2d || defined DIM_3d   /* avoid warning when kindex has 1 element */
+      kindex(2) = index0 / jpiglo
+      index0 = index0 - kindex(2) * jpiglo
+#  endif
+      kindex(1) = index0
+      kindex(:) = kindex(:) + 1   ! start indices at 1
+#else
+      kindex = 0 ; pmin = 0.
+      WRITE(*,*) 'ROUTINE_LOC: You should not have seen this print! error?'
+#endif
+
+   END SUBROUTINE ROUTINE_LOC
+
+#undef ARRAY_TYPE
+#undef MAX_TYPE
+#undef ARRAY_IN
+#undef MASK_IN
+#undef K_SIZE
+#undef MPI_OPERATION
+#undef LOC_OPERATION
+#undef INDEX_TYPE
Index: /NEMO/trunk/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mpp_nfd_generic.h90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/mpp_nfd_generic.h90	(revision 10425)
@@ -56,5 +56,5 @@
       INTEGER  ::   ipi, ipj, ipk, ipl, ipf         ! dimension of the input array
       INTEGER  ::   imigr, iihom, ijhom             ! local integers
-      INTEGER  ::   ierr, itaille, ilci, ildi, ilei, iilb
+      INTEGER  ::   ierr, ibuffsize, ilci, ildi, ilei, iilb
       INTEGER  ::   ij, iproc
       INTEGER, DIMENSION (jpmaxngh)       ::   ml_req_nf   ! for mpi_isend when avoiding mpi_allgather
@@ -62,5 +62,10 @@
       INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat     ! for mpi_isend when avoiding mpi_allgather
       !                                                    ! Workspace for message transfers avoiding mpi_allgather
-      REAL(wp), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   ztab, ztabl, ztabr
+      INTEGER                             ::   ipf_j       ! sum of lines for all multi fields
+      INTEGER                             ::   js          ! counter
+      INTEGER, DIMENSION(:,:),          ALLOCATABLE ::   jj_s  ! position of sent lines
+      INTEGER, DIMENSION(:),            ALLOCATABLE ::   ipj_s ! number of sent lines
+      REAL(wp), DIMENSION(:,:,:)      , ALLOCATABLE ::   ztabl
+      REAL(wp), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   ztab, ztabr
       REAL(wp), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   znorthloc, zfoldwk      
       REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   znorthgloio
@@ -71,55 +76,90 @@
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
-      ipj   = 4            ! 2nd dimension of message transfers (last j-lines)
-      !
-      ALLOCATE( znorthloc(jpimax,4,ipk,ipl,ipf) )
-      !
-      znorthloc(:,:,:,:,:) = 0._wp
-      !
-      DO jf = 1, ipf                ! put in znorthloc the last ipj j-lines of ptab
-         DO jl = 1, ipl
-            DO jk = 1, ipk
-               DO jj = nlcj - ipj +1, nlcj
-                  ij = jj - nlcj + ipj
-                  znorthloc(1:jpi,ij,jk,jl,jf) = ARRAY_IN(1:jpi,jj,jk,jl,jf)
+      IF( l_north_nogather ) THEN      !==  ????  ==!
+
+         ALLOCATE(ipj_s(ipf))
+
+         ipj      = 2            ! Max 2nd dimension of message transfers (last two j-line only)
+         ipj_s(:) = 1            ! Real 2nd dimension of message transfers (depending on perf requirement)
+                                 ! by default, only one line is exchanged
+
+         ALLOCATE( jj_s(ipf,2) )
+
+         ! re-define number of exchanged lines :
+         !  must be two during the first two time steps
+         !  to correct possible incoherent values on North fold lines from restart 
+
+         !!!!!!!!! temporary switch off this optimisation ==> force TRUE !!!!!!!!
+         l_full_nf_update = .TRUE.
+
+         ! Two lines update (slower but necessary to avoid different values ion identical grid points
+         IF ( l_full_nf_update .OR.                          &    ! if coupling fields
+              ( ncom_stp == nit000 .AND. .NOT. ln_rstart ) ) &    ! at first time step, if not restart
+            ipj_s(:) = 2
+
+         ! Index of modifying lines in input
+         DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
+            !
+            SELECT CASE ( npolj )
+            !
+            CASE ( 3, 4 )                       ! *  North fold  T-point pivot
+               !
+               SELECT CASE ( NAT_IN(jf) )
+               !
+               CASE ( 'T' , 'W' ,'U' )                            ! T-, U-, W-point
+                  jj_s(jf,1) = nlcj - 2 ;  jj_s(jf,2) = nlcj - 1
+               CASE ( 'V' , 'F' )                                 ! V-, F-point
+                  jj_s(jf,1) = nlcj - 3 ;  jj_s(jf,2) = nlcj - 2
+               END SELECT
+            !
+            CASE ( 5, 6 )                        ! *  North fold  F-point pivot
+               SELECT CASE ( NAT_IN(jf) )
+               !
+               CASE ( 'T' , 'W' ,'U' )                            ! T-, U-, W-point
+                  jj_s(jf,1) = nlcj - 1      
+                  ipj_s(jf) = 1                  ! need only one line anyway
+               CASE ( 'V' , 'F' )                                 ! V-, F-point
+                  jj_s(jf,1) = nlcj - 2 ;  jj_s(jf,2) = nlcj - 1
+               END SELECT
+            !
+            END SELECT
+            !
+         ENDDO
+         ! 
+         ipf_j = sum (ipj_s(:))      ! Total number of lines to be exchanged
+         !
+         ALLOCATE( znorthloc(jpimax,ipf_j,ipk,ipl,1) )
+         !
+         js = 0
+         DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
+            DO jj = 1, ipj_s(jf)
+               js = js + 1
+               DO jl = 1, ipl
+                  DO jk = 1, ipk
+                     znorthloc(1:jpi,js,jk,jl,1) = ARRAY_IN(1:jpi,jj_s(jf,jj),jk,jl,jf)
+                  END DO
                END DO
             END DO
          END DO
-      END DO
-      !
-      !
-      itaille = jpimax * ipj * ipk * ipl * ipf
-      !
-      IF( l_north_nogather ) THEN      !==  ????  ==!
-         ALLOCATE( zfoldwk(jpimax,4,ipk,ipl,ipf) )
-         ALLOCATE( ztabl(jpimax   ,4,ipk,ipl,ipf) , ztabr(jpimax*jpmaxngh,4,ipk,ipl,ipf) ) 
-         !
+         !
+         ibuffsize = jpimax * ipf_j * ipk * ipl
+         !
+         ALLOCATE( zfoldwk(jpimax,ipf_j,ipk,ipl,1) )
+         ALLOCATE( ztabr(jpimax*jpmaxngh,ipj,ipk,ipl,ipf) ) 
          ! when some processors of the north fold are suppressed, 
          ! values of ztab* arrays corresponding to these suppressed domain won't be defined 
          ! and we need a default definition to 0.
          ! a better test should be: a testing if "suppressed land-processors" belongs to the north-pole folding
-         IF ( jpni*jpnj /= jpnij ) THEN
-            ztabr(:,:,:,:,:) = 0._wp
-            ztabl(:,:,:,:,:) = 0._wp
-         END IF
-         !
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jj = nlcj-ipj+1, nlcj          ! First put local values into the global array
-                     ij = jj - nlcj + ipj
-                     DO ji = nfsloop, nfeloop
-                        ztabl(ji,ij,jk,jl,jf) = ARRAY_IN(ji,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO
-            END DO
-         END DO
+         IF ( jpni*jpnj /= jpnij ) ztabr(:,:,:,:,:) = 0._wp
+         !
+         ! start waiting time measurement
+         IF( ln_timing ) CALL tic_tac(.TRUE.)
          !
          DO jr = 1, nsndto
             IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
-              CALL mppsend( 5, znorthloc, itaille, nfipproc(isendto(jr),jpnj), ml_req_nf(jr) )
+               CALL mppsend( 5, znorthloc, ibuffsize, nfipproc(isendto(jr),jpnj), ml_req_nf(jr) )
             ENDIF
          END DO
+         !
          DO jr = 1,nsndto
             iproc = nfipproc(isendto(jr),jpnj)
@@ -134,28 +174,26 @@
             ENDIF
             IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
-              CALL mpprecv(5, zfoldwk, itaille, iproc)
-               DO jf = 1, ipf
+               CALL mpprecv(5, zfoldwk, ibuffsize, iproc)
+               js = 0
+               DO jf = 1, ipf ; DO jj = 1, ipj_s(jf)
+                  js = js + 1
                   DO jl = 1, ipl
                      DO jk = 1, ipk
-                        DO jj = 1, ipj
-                           DO ji = ildi, ilei
-                              ztabr(iilb+ji,jj,jk,jl,jf) = zfoldwk(ji,jj,jk,jl,jf)
-                           END DO
+                        DO ji = ildi, ilei
+                           ztabr(iilb+ji,jj,jk,jl,jf) = zfoldwk(ji,js,jk,jl,1)
                         END DO
                      END DO
                   END DO
-               END DO
+               END DO; END DO
             ELSE IF( iproc == narea-1 ) THEN
-               DO jf = 1, ipf
+               DO jf = 1, ipf ; DO jj = 1, ipj_s(jf)
                   DO jl = 1, ipl
                      DO jk = 1, ipk
-                        DO jj = 1, ipj
-                           DO ji = ildi, ilei
-                              ztabr(iilb+ji,jj,jk,jl,jf) = ARRAY_IN(ji,nlcj-ipj+jj,jk,jl,jf)
-                           END DO
+                        DO ji = ildi, ilei
+                           ztabr(iilb+ji,jj,jk,jl,jf) = ARRAY_IN(ji,jj_s(jf,jj),jk,jl,jf)
                         END DO
                      END DO
                   END DO
-               END DO
+               END DO; END DO
             ENDIF
          END DO
@@ -164,18 +202,32 @@
                IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
                   CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )
-               ENDIF    
+               ENDIF
             END DO
          ENDIF
+         !
+         IF( ln_timing ) CALL tic_tac(.FALSE.)
+         !
+         ! North fold boundary condition
+         !
          DO jf = 1, ipf
-            CALL lbc_nfd_nogather( ztabl(:,:,:,:,jf), ztabr(:,:,:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )   ! North fold boundary condition
-         END DO
-         DO jf = 1, ipf
+            CALL lbc_nfd_nogather(ARRAY_IN(:,:,:,:,jf), ztabr(:,1:ipj_s(jf),:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )
+         END DO
+         !
+         DEALLOCATE( zfoldwk )
+         DEALLOCATE( ztabr ) 
+         DEALLOCATE( jj_s ) 
+         DEALLOCATE( ipj_s ) 
+      ELSE                             !==  ????  ==!
+         !
+         ipj   = 4            ! 2nd dimension of message transfers (last j-lines)
+         !
+         ALLOCATE( znorthloc(jpimax,ipj,ipk,ipl,ipf) )
+         !
+         DO jf = 1, ipf                ! put in znorthloc the last ipj j-lines of ptab
             DO jl = 1, ipl
                DO jk = 1, ipk
-                  DO jj = nlcj-ipj+1, nlcj             ! Scatter back to ARRAY_IN
+                  DO jj = nlcj - ipj +1, nlcj
                      ij = jj - nlcj + ipj
-                     DO ji= 1, nlci
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ztabl(ji,ij,jk,jl,jf)
-                     END DO
+                     znorthloc(1:jpi,ij,jk,jl,jf) = ARRAY_IN(1:jpi,jj,jk,jl,jf)
                   END DO
                END DO
@@ -183,9 +235,8 @@
          END DO
          !
-         DEALLOCATE( zfoldwk )
-         DEALLOCATE( ztabl, ztabr ) 
-      ELSE                             !==  ????  ==!
-         ALLOCATE( ztab       (jpiglo,4,ipk,ipl,ipf     ) )
-         ALLOCATE( znorthgloio(jpimax,4,ipk,ipl,ipf,jpni) )
+         ibuffsize = jpimax * ipj * ipk * ipl * ipf
+         !
+         ALLOCATE( ztab       (jpiglo,ipj,ipk,ipl,ipf     ) )
+         ALLOCATE( znorthgloio(jpimax,ipj,ipk,ipl,ipf,jpni) )
          !
          ! when some processors of the north fold are suppressed,
@@ -193,8 +244,13 @@
          ! and we need a default definition to 0.
          ! a better test should be: a testing if "suppressed land-processors" belongs to the north-pole folding
-         IF ( jpni*jpnj /= jpnij ) ztab(:,:,:,:,:)=0._wp
-         !
-         CALL MPI_ALLGATHER( znorthloc  , itaille, MPI_DOUBLE_PRECISION,                &
-            &                znorthgloio, itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+         IF ( jpni*jpnj /= jpnij ) ztab(:,:,:,:,:) = 0._wp
+         !
+         ! start waiting time measurement
+         IF( ln_timing ) CALL tic_tac(.TRUE.)
+         CALL MPI_ALLGATHER( znorthloc  , ibuffsize, MPI_DOUBLE_PRECISION,                &
+            &                znorthgloio, ibuffsize, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
+         !
+         ! stop waiting time measurement
+         IF( ln_timing ) CALL tic_tac(.FALSE.)
          !
          DO jr = 1, ndim_rank_north         ! recover the global north array
Index: /NEMO/trunk/src/OCE/LBC/mppini.F90
===================================================================
--- /NEMO/trunk/src/OCE/LBC/mppini.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LBC/mppini.F90	(revision 10425)
@@ -36,4 +36,7 @@
    PUBLIC mpp_init       ! called by opa.F90
 
+   INTEGER :: numbot = -1  ! 'bottom_level' local logical unit
+   INTEGER :: numbdy = -1  ! 'bdy_msk'      local logical unit
+   
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -136,13 +139,16 @@
       !!----------------------------------------------------------------------
       INTEGER ::   ji, jj, jn, jproc, jarea   ! dummy loop indices
+      INTEGER ::   inijmin
+      INTEGER ::   i2add
       INTEGER ::   inum                       ! local logical unit
-      INTEGER ::   idir, ifreq, icont, isurf  ! local integers
+      INTEGER ::   idir, ifreq, icont         ! local integers
       INTEGER ::   ii, il1, ili, imil         !   -       -
       INTEGER ::   ij, il2, ilj, ijm1         !   -       -
       INTEGER ::   iino, ijno, iiso, ijso     !   -       -
       INTEGER ::   iiea, ijea, iiwe, ijwe     !   -       -
-      INTEGER ::   iresti, irestj, iarea0     !   -       -
-      INTEGER ::   ierr                       ! local logical unit
-      REAL(wp)::   zidom, zjdom               ! local scalars
+      INTEGER ::   iarea0                     !   -       -
+      INTEGER ::   ierr, ios                  ! 
+      INTEGER ::   inbi, inbj, iimax,  ijmax, icnt1, icnt2
+      LOGICAL ::   llbest
       INTEGER, ALLOCATABLE, DIMENSION(:)     ::   iin, ii_nono, ii_noea          ! 1D workspace
       INTEGER, ALLOCATABLE, DIMENSION(:)     ::   ijn, ii_noso, ii_nowe          !  -     -
@@ -151,15 +157,100 @@
       INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   ilei, ildi, iono, ioea         !  -     -
       INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   ilej, ildj, ioso, iowe         !  -     -
-      INTEGER, DIMENSION(jpiglo,jpjglo) ::   imask   ! 2D global domain workspace
-      !!----------------------------------------------------------------------
-
+      LOGICAL, ALLOCATABLE, DIMENSION(:,:) ::   llisoce                        !  -     -
+      NAMELIST/nambdy/ ln_bdy, nb_bdy, ln_coords_file, cn_coords_file,           &
+           &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
+           &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &  
+           &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
+           &             cn_ice, nn_ice_dta,                                     &
+           &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
+           &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
+      !!----------------------------------------------------------------------
+
+      ! do we need to take into account bdy_msk?
+      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist : BDY
+      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist (mppini)', lwp )
+      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist : BDY
+      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist (mppini)', lwp )
+      !
+      IF(               ln_read_cfg ) CALL iom_open( cn_domcfg,    numbot )
+      IF( ln_bdy .AND. ln_mask_file ) CALL iom_open( cn_mask_file, numbdy )
+      !
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !
       ! If dimensions of processor grid weren't specified in the namelist file
       ! then we calculate them here now that we have our communicator size
-      IF( jpni < 1 .OR. jpnj < 1 )   CALL mpp_init_partition( mppsize )
-      !
-#if defined key_agrif
-      IF( jpnij /= jpni*jpnj ) CALL ctl_stop( 'STOP', 'Cannot remove land proc with AGRIF' )
-#endif
-      !
+      IF( jpni < 1 .OR. jpnj < 1 ) THEN
+         CALL mpp_init_bestpartition( mppsize, jpni, jpnj )
+         llbest = .TRUE.
+      ELSE
+         CALL mpp_init_bestpartition( mppsize, inbi, inbj, icnt2 )
+         CALL mpp_basic_decomposition( jpni, jpnj, jpimax, jpjmax )
+         CALL mpp_basic_decomposition( inbi, inbj,  iimax,  ijmax )
+         IF( iimax*ijmax < jpimax*jpjmax ) THEN
+            llbest = .FALSE.
+            icnt1 = jpni*jpnj - mppsize
+            WRITE(ctmp1,9000) '   The chosen domain decomposition ', jpni, ' x ', jpnj, ' with ', icnt1, ' land sub-domains'
+            WRITE(ctmp2,9000) '   has larger MPI subdomains (jpi = ', jpimax, ', jpj = ', jpjmax, ', jpi*jpj = ', jpimax*jpjmax, ')'
+            WRITE(ctmp3,9000) '   than the following domain decompostion ', inbi, ' x ', inbj, ' with ', icnt2, ' land sub-domains'
+            WRITE(ctmp4,9000) '   which MPI subdomains size is jpi = ', iimax, ', jpj = ', ijmax, ', jpi*jpj = ', iimax*ijmax, ' '
+            CALL ctl_warn( 'mpp_init:', '~~~~~~~~ ', ctmp1, ctmp2, ctmp3, ctmp4, ' ', '    --- YOU ARE WASTING CPU... ---', ' ' )
+         ELSE
+            llbest = .TRUE.
+         ENDIF
+      ENDIF
+      
+      ! look for land mpi subdomains...
+      ALLOCATE( llisoce(jpni,jpnj) )
+      CALL mpp_init_isoce( jpni, jpnj, llisoce )
+      inijmin = COUNT( llisoce )   ! number of oce subdomains
+
+      IF( mppsize < inijmin ) THEN
+         WRITE(ctmp1,9001) '   With this specified domain decomposition: jpni = ', jpni, ' jpnj = ', jpnj
+         WRITE(ctmp2,9002) '   we can eliminate only ', jpni*jpnj - inijmin, ' land mpi subdomains therefore '
+         WRITE(ctmp3,9001) '   the number of ocean mpi subdomains (', inijmin,') exceed the number of MPI processes:', mppsize
+         WRITE(ctmp4,*) '   ==>>> There is the list of best domain decompositions you should use: '
+         CALL ctl_stop( 'mpp_init:', '~~~~~~~~ ', ctmp1, ctmp2, ctmp3, ctmp4 )
+         CALL mpp_init_bestpartition( mppsize, ldlist = .TRUE. )   ! must be done by all core
+         CALL ctl_stop( 'STOP' )
+      ENDIF
+
+      IF( mppsize > jpni*jpnj ) THEN
+         WRITE(ctmp1,9003) '   The number of mpi processes: ', mppsize
+         WRITE(ctmp2,9003) '   exceeds the maximum number of subdomains (ocean+land) = ', jpni*jpnj
+         WRITE(ctmp3,9001) '   defined by the following domain decomposition: jpni = ', jpni, ' jpnj = ', jpnj
+         WRITE(ctmp4,*) '   ==>>> There is the list of best domain decompositions you should use: '
+         CALL ctl_stop( 'mpp_init:', '~~~~~~~~ ', ctmp1, ctmp2, ctmp3, ctmp4 )
+         CALL mpp_init_bestpartition( mppsize, ldlist = .TRUE. )   ! must be done by all core
+         CALL ctl_stop( 'STOP' )
+      ENDIF
+
+      jpnij = mppsize   ! force jpnij definition <-- remove as much land subdomains as needed to reach this condition
+      IF( mppsize > inijmin ) THEN
+         WRITE(ctmp1,9003) '   The number of mpi processes: ', mppsize
+         WRITE(ctmp2,9003) '   exceeds the maximum number of ocean subdomains = ', inijmin
+         WRITE(ctmp3,9002) '   we suppressed ', jpni*jpnj - mppsize, ' land subdomains '
+         WRITE(ctmp4,9002) '   BUT we had to keep ', mppsize - inijmin, ' land subdomains that are useless...'
+         CALL ctl_warn( 'mpp_init:', '~~~~~~~~ ', ctmp1, ctmp2, ctmp3, ctmp4, ' ', '    --- YOU ARE WASTING CPU... ---', ' ' )
+      ELSE   ! mppsize = inijmin
+         IF(lwp) THEN
+            IF(llbest) WRITE(numout,*) 'mpp_init: You use an optimal domain decomposition'
+            WRITE(numout,*) '~~~~~~~~ '
+            WRITE(numout,9003) '   Number of mpi processes: ', mppsize
+            WRITE(numout,9003) '   Number of ocean subdomains = ', inijmin
+            WRITE(numout,9003) '   Number of suppressed land subdomains = ', jpni*jpnj - inijmin
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
+9000  FORMAT (a, i4, a, i4, a, i7, a)
+9001  FORMAT (a, i4, a, i4)
+9002  FORMAT (a, i4, a)
+9003  FORMAT (a, i5)
+
+      IF( numbot /= -1 )   CALL iom_close( numbot )
+      IF( numbdy /= -1 )   CALL iom_close( numbdy )
+    
       ALLOCATE(  nfiimpp(jpni,jpnj), nfipproc(jpni,jpnj), nfilcit(jpni,jpnj) ,    &
          &       nimppt(jpnij) , ibonit(jpnij) , nlcit(jpnij) , nlcjt(jpnij) ,    &
@@ -173,8 +264,7 @@
          &       ilej(jpni,jpnj), ildj(jpni,jpnj), ioso(jpni,jpnj), iowe(jpni,jpnj),   &
          &       STAT=ierr )
-      CALL mpp_sum( ierr )
+      CALL mpp_sum( 'mppini', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'mpp_init: unable to allocate standard ocean arrays' )
       
-      !
 #if defined key_agrif
       IF( .NOT. Agrif_Root() ) THEN       ! AGRIF children: specific setting (cf. agrif_user.F90)
@@ -186,88 +276,26 @@
       ENDIF
 #endif
-
-#if defined key_nemocice_decomp
-      jpimax = ( nx_global+2-2*nn_hls + (jpni-1) ) / jpni + 2*nn_hls    ! first  dim.
-      jpjmax = ( ny_global+2-2*nn_hls + (jpnj-1) ) / jpnj + 2*nn_hls    ! second dim. 
-#else
-      jpimax = ( jpiglo - 2*nn_hls + (jpni-1) ) / jpni + 2*nn_hls    ! first  dim.
-      jpjmax = ( jpjglo - 2*nn_hls + (jpnj-1) ) / jpnj + 2*nn_hls    ! second dim.
-#endif
-
-      !
-      IF ( jpni * jpnj == jpnij ) THEN    ! regular domain lay out over processors
-         imask(:,:) = 1               
-      ELSEIF ( jpni*jpnj > jpnij ) THEN   ! remove land-only processor (i.e. where imask(:,:)=0)
-         CALL mpp_init_mask( imask )   
-      ELSE                                ! error
-         CALL ctl_stop( 'mpp_init: jpnij > jpni x jpnj. Check namelist setting!' )
-      ENDIF
-      !
-      !  1. Dimension arrays for subdomains
+      !
+      !  2. Index arrays for subdomains
       ! -----------------------------------
-      !  Computation of local domain sizes ilci() ilcj()
-      !  These dimensions depend on global sizes jpni,jpnj and jpiglo,jpjglo
-      !  The subdomains are squares lesser than or equal to the global
-      !  dimensions divided by the number of processors minus the overlap array.
       !
       nreci = 2 * nn_hls
       nrecj = 2 * nn_hls
-      iresti = 1 + MOD( jpiglo - nreci -1 , jpni )
-      irestj = 1 + MOD( jpjglo - nrecj -1 , jpnj )
-      !
-      !  Need to use jpimax and jpjmax here since jpi and jpj not yet defined
-#if defined key_nemocice_decomp
-      ! Change padding to be consistent with CICE
-      ilci(1:jpni-1      ,:) = jpimax
-      ilci(jpni          ,:) = jpiglo - (jpni - 1) * (jpimax - nreci)
-      !
-      ilcj(:,      1:jpnj-1) = jpjmax
-      ilcj(:,          jpnj) = jpjglo - (jpnj - 1) * (jpjmax - nrecj)
-#else
-      ilci(1:iresti      ,:) = jpimax
-      ilci(iresti+1:jpni ,:) = jpimax-1
-
-      ilcj(:,      1:irestj) = jpjmax
-      ilcj(:, irestj+1:jpnj) = jpjmax-1
-#endif
-      !
-      zidom = nreci + sum(ilci(:,1) - nreci )
-      zjdom = nrecj + sum(ilcj(1,:) - nrecj )
+      CALL mpp_basic_decomposition( jpni, jpnj, jpimax, jpjmax, iimppt, ijmppt, ilci, ilcj )
+      nfiimpp(:,:) = iimppt(:,:)
+      nfilcit(:,:) = ilci(:,:)
       !
       IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*) 'mpp_init : MPI Message Passing MPI - domain lay out over processors'
-         WRITE(numout,*) '~~~~~~~~ '
+         WRITE(numout,*) 'MPI Message Passing MPI - domain lay out over processors'
+         WRITE(numout,*)
          WRITE(numout,*) '   defines mpp subdomains'
-         WRITE(numout,*) '      iresti = ', iresti, ' jpni = ', jpni  
-         WRITE(numout,*) '      irestj = ', irestj, ' jpnj = ', jpnj
+         WRITE(numout,*) '      jpni = ', jpni  
+         WRITE(numout,*) '      jpnj = ', jpnj
          WRITE(numout,*)
-         WRITE(numout,*) '      sum ilci(i,1) = ', zidom, ' jpiglo = ', jpiglo
-         WRITE(numout,*) '      sum ilcj(1,j) = ', zjdom, ' jpjglo = ', jpjglo
-      ENDIF
-
-      !  2. Index arrays for subdomains
-      ! -------------------------------
-      iimppt(:,:) =  1
-      ijmppt(:,:) =  1
-      ipproc(:,:) = -1
-      !
-      IF( jpni > 1 ) THEN
-         DO jj = 1, jpnj
-            DO ji = 2, jpni
-               iimppt(ji,jj) = iimppt(ji-1,jj) + ilci(ji-1,jj) - nreci
-            END DO
-         END DO
-      ENDIF
-      nfiimpp(:,:) = iimppt(:,:)
-      !
-      IF( jpnj > 1 )THEN
-         DO jj = 2, jpnj
-            DO ji = 1, jpni
-               ijmppt(ji,jj) = ijmppt(ji,jj-1) + ilcj(ji,jj-1) - nrecj
-            END DO
-         END DO
-      ENDIF
-
+         WRITE(numout,*) '      sum ilci(i,1) = ', sum(ilci(:,1)), ' jpiglo = ', jpiglo
+         WRITE(numout,*) '      sum ilcj(1,j) = ', sum(ilcj(1,:)), ' jpjglo = ', jpjglo
+      ENDIF
+     
       ! 3. Subdomain description in the Regular Case
       ! --------------------------------------------
@@ -277,6 +305,6 @@
       l_Jperio = jpnj == 1 .AND. (jperio == 2 .OR. jperio == 7)
       
-      icont = -1
       DO jarea = 1, jpni*jpnj
+         !
          iarea0 = jarea - 1
          ii = 1 + MOD(iarea0,jpni)
@@ -334,13 +362,17 @@
          ENDIF
          !
-         ! Check wet points over the entire domain to preserve the MPI communication stencil
-         isurf = 0
-         DO jj = 1, ilj
-            DO  ji = 1, ili
-               IF( imask(ji+iimppt(ii,ij)-1, jj+ijmppt(ii,ij)-1) == 1)   isurf = isurf+1
-            END DO
-         END DO
-         !
-         IF( isurf /= 0 ) THEN
+      END DO
+
+      ! 4. deal with land subdomains
+      ! ----------------------------
+      !
+      ! specify which subdomains are oce subdomains; other are land subdomains
+      ipproc(:,:) = -1
+      icont = -1
+      DO jarea = 1, jpni*jpnj
+         iarea0 = jarea - 1
+         ii = 1 + MOD(iarea0,jpni)
+         ij = 1 +     iarea0/jpni
+         IF( llisoce(ii,ij) ) THEN
             icont = icont + 1
             ipproc(ii,ij) = icont
@@ -349,16 +381,71 @@
          ENDIF
       END DO
-      !
+      ! if needed add some land subdomains to reach jpnij active subdomains
+      i2add = jpnij - inijmin
+      DO jarea = 1, jpni*jpnj
+         iarea0 = jarea - 1
+         ii = 1 + MOD(iarea0,jpni)
+         ij = 1 +     iarea0/jpni
+         IF( .NOT. llisoce(ii,ij) .AND. i2add > 0 ) THEN
+            icont = icont + 1
+            ipproc(ii,ij) = icont
+            iin(icont+1) = ii
+            ijn(icont+1) = ij
+            i2add = i2add - 1
+         ENDIF
+      END DO
       nfipproc(:,:) = ipproc(:,:)
 
-      ! Check potential error
-      IF( icont+1 /= jpnij ) THEN
-         WRITE(ctmp1,*) ' jpni =',jpni,' jpnj =',jpnj
-         WRITE(ctmp2,*) ' jpnij =',jpnij, '< jpni x jpnj' 
-         WRITE(ctmp3,*) ' ***********, mpp_init2 finds jpnij=',icont+1
-         CALL ctl_stop( 'STOP', 'mpp_init: Eliminate land processors algorithm', '', ctmp1, ctmp2, '', ctmp3 )
-      ENDIF
-
-      ! 4. Subdomain print
+      ! neighbour treatment: change ibondi, ibondj if next to a land zone
+      DO jarea = 1, jpni*jpnj
+         ii = 1 + MOD( jarea-1  , jpni )
+         ij = 1 +     (jarea-1) / jpni
+         ! land-only area with an active n neigbour
+         IF ( ipproc(ii,ij) == -1 .AND. 0 <= iono(ii,ij) .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN
+            iino = 1 + MOD( iono(ii,ij) , jpni )                    ! ii index of this n neigbour
+            ijno = 1 +      iono(ii,ij) / jpni                      ! ij index of this n neigbour
+            ! In case of north fold exchange: I am the n neigbour of my n neigbour!! (#1057)
+            ! --> for northern neighbours of northern row processors (in case of north-fold)
+            !     need to reverse the LOGICAL direction of communication 
+            idir = 1                                           ! we are indeed the s neigbour of this n neigbour
+            IF( ij == jpnj .AND. ijno == jpnj )   idir = -1    ! both are on the last row, we are in fact the n neigbour
+            IF( ibondj(iino,ijno) == idir     )   ibondj(iino,ijno) =   2     ! this n neigbour had only a s/n neigbour -> no more
+            IF( ibondj(iino,ijno) == 0        )   ibondj(iino,ijno) = -idir   ! this n neigbour had both, n-s neighbours -> keep 1
+         ENDIF
+         ! land-only area with an active s neigbour
+         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioso(ii,ij) .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN
+            iiso = 1 + MOD( ioso(ii,ij) , jpni )                    ! ii index of this s neigbour
+            ijso = 1 +      ioso(ii,ij) / jpni                      ! ij index of this s neigbour
+            IF( ibondj(iiso,ijso) == -1 )   ibondj(iiso,ijso) = 2   ! this s neigbour had only a n neigbour    -> no more neigbour
+            IF( ibondj(iiso,ijso) ==  0 )   ibondj(iiso,ijso) = 1   ! this s neigbour had both, n-s neighbours -> keep s neigbour
+         ENDIF
+         ! land-only area with an active e neigbour
+         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioea(ii,ij) .AND. ioea(ii,ij) <= jpni*jpnj-1 ) THEN
+            iiea = 1 + MOD( ioea(ii,ij) , jpni )                    ! ii index of this e neigbour
+            ijea = 1 +      ioea(ii,ij) / jpni                      ! ij index of this e neigbour
+            IF( ibondi(iiea,ijea) == 1 )   ibondi(iiea,ijea) =  2   ! this e neigbour had only a w neigbour    -> no more neigbour
+            IF( ibondi(iiea,ijea) == 0 )   ibondi(iiea,ijea) = -1   ! this e neigbour had both, e-w neighbours -> keep e neigbour
+         ENDIF
+         ! land-only area with an active w neigbour
+         IF( ipproc(ii,ij) == -1 .AND. 0 <= iowe(ii,ij) .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN
+            iiwe = 1 + MOD( iowe(ii,ij) , jpni )                    ! ii index of this w neigbour
+            ijwe = 1 +      iowe(ii,ij) / jpni                      ! ij index of this w neigbour
+            IF( ibondi(iiwe,ijwe) == -1 )   ibondi(iiwe,ijwe) = 2   ! this w neigbour had only a e neigbour    -> no more neigbour
+            IF( ibondi(iiwe,ijwe) ==  0 )   ibondi(iiwe,ijwe) = 1   ! this w neigbour had both, e-w neighbours -> keep w neigbour
+         ENDIF
+      END DO
+
+      ! Update il[de][ij] according to modified ibond[ij]
+      ! ----------------------
+      DO jproc = 1, jpnij
+         ii = iin(jproc)
+         ij = ijn(jproc)
+         IF( ibondi(ii,ij) == -1 .OR. ibondi(ii,ij) == 2 ) ildi(ii,ij) =  1
+         IF( ibondi(ii,ij) ==  1 .OR. ibondi(ii,ij) == 2 ) ilei(ii,ij) = ilci(ii,ij)
+         IF( ibondj(ii,ij) == -1 .OR. ibondj(ii,ij) == 2 ) ildj(ii,ij) =  1
+         IF( ibondj(ii,ij) ==  1 .OR. ibondj(ii,ij) == 2 ) ilej(ii,ij) = ilcj(ii,ij)
+      END DO
+      
+      ! 5. Subdomain print
       ! ------------------
       IF(lwp) THEN
@@ -385,55 +472,4 @@
  9404    FORMAT('           *  '   ,20('      ',i3,'   *   ') )
       ENDIF
-
-      ! 5. neighbour treatment: change ibondi, ibondj if next to a land zone
-      ! ----------------------
-      DO jarea = 1, jpni*jpnj
-         ii = 1 + MOD( jarea-1  , jpni )
-         ij = 1 +     (jarea-1) / jpni
-         ! land-only area with an active n neigbour
-         IF ( ipproc(ii,ij) == -1 .AND. 0 <= iono(ii,ij) .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN
-            iino = 1 + MOD( iono(ii,ij) , jpni )                    ! ii index of this n neigbour
-            ijno = 1 +      iono(ii,ij) / jpni                      ! ij index of this n neigbour
-            ! In case of north fold exchange: I am the n neigbour of my n neigbour!! (#1057)
-            ! --> for northern neighbours of northern row processors (in case of north-fold)
-            !     need to reverse the LOGICAL direction of communication 
-            idir = 1                                           ! we are indeed the s neigbour of this n neigbour
-            IF( ij == jpnj .AND. ijno == jpnj )   idir = -1    ! both are on the last row, we are in fact the n neigbour
-            IF( ibondj(iino,ijno) == idir     )   ibondj(iino,ijno) =   2     ! this n neigbour had only a s/n neigbour -> no more
-            IF( ibondj(iino,ijno) == 0        )   ibondj(iino,ijno) = -idir   ! this n neigbour had both, n-s neighbours -> keep 1
-         ENDIF
-         ! land-only area with an active s neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioso(ii,ij) .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN
-            iiso = 1 + MOD( ioso(ii,ij) , jpni )                    ! ii index of this s neigbour
-            ijso = 1 +      ioso(ii,ij) / jpni                      ! ij index of this s neigbour
-            IF( ibondj(iiso,ijso) == -1 )   ibondj(iiso,ijso) = 2   ! this s neigbour had only a n neigbour    -> no more neigbour
-            IF( ibondj(iiso,ijso) ==  0 )   ibondj(iiso,ijso) = 1   ! this s neigbour had both, n-s neighbours -> keep s neigbour
-         ENDIF
-         ! land-only area with an active e neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioea(ii,ij) .AND. ioea(ii,ij) <= jpni*jpnj-1 ) THEN
-            iiea = 1 + MOD( ioea(ii,ij) , jpni )                    ! ii index of this e neigbour
-            ijea = 1 +      ioea(ii,ij) / jpni                      ! ij index of this e neigbour
-            IF( ibondi(iiea,ijea) == 1 )   ibondi(iiea,ijea) =  2   ! this e neigbour had only a w neigbour    -> no more neigbour
-            IF( ibondi(iiea,ijea) == 0 )   ibondi(iiea,ijea) = -1   ! this e neigbour had both, e-w neighbours -> keep e neigbour
-         ENDIF
-         ! land-only area with an active w neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= iowe(ii,ij) .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN
-            iiwe = 1 + MOD( iowe(ii,ij) , jpni )                    ! ii index of this w neigbour
-            ijwe = 1 +      iowe(ii,ij) / jpni                      ! ij index of this w neigbour
-            IF( ibondi(iiwe,ijwe) == -1 )   ibondi(iiwe,ijwe) = 2   ! this w neigbour had only a e neigbour    -> no more neigbour
-            IF( ibondi(iiwe,ijwe) ==  0 )   ibondi(iiwe,ijwe) = 1   ! this w neigbour had both, e-w neighbours -> keep w neigbour
-         ENDIF
-      END DO
-
-      ! Update il[de][ij] according to modified ibond[ij]
-      ! ----------------------
-      DO jproc = 1, jpnij
-         ii = iin(jproc)
-         ij = ijn(jproc)
-         IF( ibondi(ii,ij) == -1 .OR. ibondi(ii,ij) == 2 ) ildi(ii,ij) =  1
-         IF( ibondi(ii,ij) ==  1 .OR. ibondi(ii,ij) == 2 ) ilei(ii,ij) = ilci(ii,ij)
-         IF( ibondj(ii,ij) == -1 .OR. ibondj(ii,ij) == 2 ) ildj(ii,ij) =  1
-         IF( ibondj(ii,ij) ==  1 .OR. ibondj(ii,ij) == 2 ) ilej(ii,ij) = ilcj(ii,ij)
-      END DO
          
       ! just to save nono etc for all proc
@@ -516,5 +552,4 @@
          njmppt(jproc) = ijmppt(ii,ij) 
       END DO
-      nfilcit(:,:) = ilci(:,:)
 
       ! Save processor layout in ascii file
@@ -610,68 +645,425 @@
          &       iimppt, ijmppt, ibondi, ibondj, ipproc, ipolj,   &
          &       ilci, ilcj, ilei, ilej, ildi, ildj,              &
-         &       iono, ioea, ioso, iowe)
+         &       iono, ioea, ioso, iowe, llisoce)
       !
     END SUBROUTINE mpp_init
 
 
-    SUBROUTINE mpp_init_mask( kmask )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE mpp_init_mask  ***
-      !!
-      !! ** Purpose : Read relevant bathymetric information in a global array
-      !!              in order to provide a land/sea mask used for the elimination
+    SUBROUTINE mpp_basic_decomposition( knbi, knbj, kimax, kjmax, kimppt, kjmppt, klci, klcj)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_basic_decomposition  ***
+      !!                    
+      !! ** Purpose :   Lay out the global domain over processors.
+      !!
+      !! ** Method  :   Global domain is distributed in smaller local domains.
+      !!
+      !! ** Action : - set for all knbi*knbj domains:
+      !!                    kimppt     : longitudinal index
+      !!                    kjmppt     : latitudinal  index
+      !!                    klci       : first dimension
+      !!                    klcj       : second dimension
+      !!----------------------------------------------------------------------
+      INTEGER,                                 INTENT(in   ) ::   knbi, knbj
+      INTEGER,                                 INTENT(  out) ::   kimax, kjmax
+      INTEGER, DIMENSION(knbi,knbj), OPTIONAL, INTENT(  out) ::   kimppt, kjmppt
+      INTEGER, DIMENSION(knbi,knbj), OPTIONAL, INTENT(  out) ::   klci, klcj
+      !
+      INTEGER ::   ji, jj
+      INTEGER ::   iresti, irestj
+      INTEGER ::   ireci, irecj
+      !!----------------------------------------------------------------------
+      !
+#if defined key_nemocice_decomp
+      kimax = ( nx_global+2-2*nn_hls + (knbi-1) ) / knbi + 2*nn_hls    ! first  dim.
+      kjmax = ( ny_global+2-2*nn_hls + (knbj-1) ) / knbj + 2*nn_hls    ! second dim. 
+#else
+      kimax = ( jpiglo - 2*nn_hls + (knbi-1) ) / knbi + 2*nn_hls    ! first  dim.
+      kjmax = ( jpjglo - 2*nn_hls + (knbj-1) ) / knbj + 2*nn_hls    ! second dim.
+#endif
+      IF( .NOT. PRESENT(kimppt) ) RETURN
+      !
+      !  1. Dimension arrays for subdomains
+      ! -----------------------------------
+      !  Computation of local domain sizes klci() klcj()
+      !  These dimensions depend on global sizes knbi,knbj and jpiglo,jpjglo
+      !  The subdomains are squares lesser than or equal to the global
+      !  dimensions divided by the number of processors minus the overlap array.
+      !
+      ireci = 2 * nn_hls
+      irecj = 2 * nn_hls
+      iresti = 1 + MOD( jpiglo - ireci -1 , knbi )
+      irestj = 1 + MOD( jpjglo - irecj -1 , knbj )
+      !
+      !  Need to use kimax and kjmax here since jpi and jpj not yet defined
+#if defined key_nemocice_decomp
+      ! Change padding to be consistent with CICE
+      klci(1:knbi-1      ,:) = kimax
+      klci(knbi          ,:) = jpiglo - (knbi - 1) * (kimax - nreci)
+      klcj(:,      1:knbj-1) = kjmax
+      klcj(:,          knbj) = jpjglo - (knbj - 1) * (kjmax - nrecj)
+#else
+      klci(1:iresti      ,:) = kimax
+      klci(iresti+1:knbi ,:) = kimax-1
+      klcj(:,      1:irestj) = kjmax
+      klcj(:, irestj+1:knbj) = kjmax-1
+#endif
+
+      !  2. Index arrays for subdomains
+      ! -------------------------------
+      kimppt(:,:) = 1
+      kjmppt(:,:) = 1
+      !
+      IF( knbi > 1 ) THEN
+         DO jj = 1, knbj
+            DO ji = 2, knbi
+               kimppt(ji,jj) = kimppt(ji-1,jj) + klci(ji-1,jj) - ireci
+            END DO
+         END DO
+      ENDIF
+      !
+      IF( knbj > 1 )THEN
+         DO jj = 2, knbj
+            DO ji = 1, knbi
+               kjmppt(ji,jj) = kjmppt(ji,jj-1) + klcj(ji,jj-1) - irecj
+            END DO
+         END DO
+      ENDIF
+      
+   END SUBROUTINE mpp_basic_decomposition
+
+
+   SUBROUTINE mpp_init_bestpartition( knbij, knbi, knbj, knbcnt, ldlist )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE mpp_init_bestpartition  ***
+      !!
+      !! ** Purpose :
+      !!
+      !! ** Method  :
+      !!----------------------------------------------------------------------
+      INTEGER,           INTENT(in   ) ::   knbij         ! total number if subdomains               (knbi*knbj)
+      INTEGER, OPTIONAL, INTENT(  out) ::   knbi, knbj    ! number if subdomains along i and j (knbi and knbj)
+      INTEGER, OPTIONAL, INTENT(  out) ::   knbcnt        ! number of land subdomains
+      LOGICAL, OPTIONAL, INTENT(in   ) ::   ldlist        ! .true.: print the list the best domain decompositions (with land)
+      !
+      INTEGER :: ji, jj, ii, iitarget
+      INTEGER :: iszitst, iszjtst
+      INTEGER :: isziref, iszjref
+      INTEGER :: inbij, iszij
+      INTEGER :: inbimax, inbjmax, inbijmax
+      INTEGER :: isz0, isz1
+      INTEGER, DIMENSION(  :), ALLOCATABLE :: indexok
+      INTEGER, DIMENSION(  :), ALLOCATABLE :: inbi0, inbj0, inbij0   ! number of subdomains along i,j
+      INTEGER, DIMENSION(  :), ALLOCATABLE :: iszi0, iszj0, iszij0   ! max size of the subdomains along i,j
+      INTEGER, DIMENSION(  :), ALLOCATABLE :: inbi1, inbj1, inbij1   ! number of subdomains along i,j
+      INTEGER, DIMENSION(  :), ALLOCATABLE :: iszi1, iszj1, iszij1   ! max size of the subdomains along i,j
+      LOGICAL :: llist
+      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: llmsk2d                 ! max size of the subdomains along i,j
+      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: llisoce              !  -     -
+      REAL(wp)::   zpropland
+      !!----------------------------------------------------------------------
+      !
+      llist = .FALSE.
+      IF( PRESENT(ldlist) ) llist = ldlist
+
+      CALL mpp_init_landprop( zpropland )                      ! get the proportion of land point over the gloal domain
+      inbij = NINT( REAL(knbij, wp) / ( 1.0 - zpropland ) )    ! define the largest possible value for jpni*jpnj
+      !
+      IF( llist ) THEN   ;   inbijmax = inbij*2
+      ELSE               ;   inbijmax = inbij
+      ENDIF
+      !
+      ALLOCATE(inbi0(inbijmax),inbj0(inbijmax),iszi0(inbijmax),iszj0(inbijmax))
+      !
+      inbimax = 0
+      inbjmax = 0
+      isziref = jpiglo*jpjglo+1
+      iszjref = jpiglo*jpjglo+1
+      !
+      ! get the list of knbi that gives a smaller jpimax than knbi-1
+      ! get the list of knbj that gives a smaller jpjmax than knbj-1
+      DO ji = 1, inbijmax      
+#if defined key_nemocice_decomp
+         iszitst = ( nx_global+2-2*nn_hls + (ji-1) ) / ji + 2*nn_hls    ! first  dim.
+#else
+         iszitst = ( jpiglo - 2*nn_hls + (ji-1) ) / ji + 2*nn_hls
+#endif
+         IF( iszitst < isziref ) THEN
+            isziref = iszitst
+            inbimax = inbimax + 1
+            inbi0(inbimax) = ji
+            iszi0(inbimax) = isziref
+         ENDIF
+#if defined key_nemocice_decomp
+         iszjtst = ( ny_global+2-2*nn_hls + (ji-1) ) / ji + 2*nn_hls    ! first  dim.
+#else
+         iszjtst = ( jpjglo - 2*nn_hls + (ji-1) ) / ji + 2*nn_hls
+#endif
+         IF( iszjtst < iszjref ) THEN
+            iszjref = iszjtst
+            inbjmax = inbjmax + 1
+            inbj0(inbjmax) = ji
+            iszj0(inbjmax) = iszjref
+         ENDIF
+      END DO
+
+      ! combine these 2 lists to get all possible knbi*knbj <  inbijmax
+      ALLOCATE( llmsk2d(inbimax,inbjmax) )
+      DO jj = 1, inbjmax
+         DO ji = 1, inbimax
+            IF ( inbi0(ji) * inbj0(jj) <= inbijmax ) THEN   ;   llmsk2d(ji,jj) = .TRUE.
+            ELSE                                            ;   llmsk2d(ji,jj) = .FALSE.
+            ENDIF
+         END DO
+      END DO
+      isz1 = COUNT(llmsk2d)
+      ALLOCATE( inbi1(isz1), inbj1(isz1), iszi1(isz1), iszj1(isz1) )
+      ii = 0
+      DO jj = 1, inbjmax
+         DO ji = 1, inbimax
+            IF( llmsk2d(ji,jj) .EQV. .TRUE. ) THEN
+               ii = ii + 1
+               inbi1(ii) = inbi0(ji)
+               inbj1(ii) = inbj0(jj)
+               iszi1(ii) = iszi0(ji)
+               iszj1(ii) = iszj0(jj)
+            END IF
+         END DO
+      END DO
+      DEALLOCATE( inbi0, inbj0, iszi0, iszj0 )
+      DEALLOCATE( llmsk2d )
+
+      ALLOCATE( inbij1(isz1), iszij1(isz1) )
+      inbij1(:) = inbi1(:) * inbj1(:)
+      iszij1(:) = iszi1(:) * iszj1(:)
+
+      ! if therr is no land and no print
+      IF( .NOT. llist .AND. numbot == -1 .AND. numbdy == -1 ) THEN
+         ! get the smaller partition which gives the smallest subdomain size
+         ii = MINLOC(inbij1, mask = iszij1 == MINVAL(iszij1), dim = 1)
+         knbi = inbi1(ii)
+         knbj = inbj1(ii)
+         IF(PRESENT(knbcnt))   knbcnt = 0
+         DEALLOCATE( inbi1, inbj1, inbij1, iszi1, iszj1, iszij1 )
+         RETURN
+      ENDIF
+
+      ! extract only the partitions which reduce the subdomain size in comparison with smaller partitions
+      ALLOCATE( indexok(isz1) )                                 ! to store indices of the best partitions
+      isz0 = 0                                                  ! number of best partitions     
+      inbij = 1                                                 ! start with the min value of inbij1 => 1
+      iszij = jpiglo*jpjglo+1                                   ! default: larger than global domain
+      DO WHILE( inbij <= inbijmax )                             ! if we did not reach the max of inbij1
+         ii = MINLOC(iszij1, mask = inbij1 == inbij, dim = 1)   ! warning: send back the first occurence if multiple results
+         IF ( iszij1(ii) < iszij ) THEN
+            isz0 = isz0 + 1
+            indexok(isz0) = ii
+            iszij = iszij1(ii)
+         ENDIF
+         inbij = MINVAL(inbij1, mask = inbij1 > inbij)   ! warning: return largest integer value if mask = .false. everywhere
+      END DO
+      DEALLOCATE( inbij1, iszij1 )
+
+      ! keep only the best partitions (sorted by increasing order of subdomains number and decreassing subdomain size)
+      ALLOCATE( inbi0(isz0), inbj0(isz0), iszi0(isz0), iszj0(isz0) )
+      DO ji = 1, isz0
+         ii = indexok(ji)
+         inbi0(ji) = inbi1(ii)
+         inbj0(ji) = inbj1(ii)
+         iszi0(ji) = iszi1(ii)
+         iszj0(ji) = iszj1(ii)
+      END DO
+      DEALLOCATE( indexok, inbi1, inbj1, iszi1, iszj1 )
+
+      IF( llist ) THEN  ! we print about 21 best partitions
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,         *) '                  For your information:'
+            WRITE(numout,'(a,i5,a)') '  list of the best partitions around ',   knbij, ' mpi processes'
+            WRITE(numout,         *) '  --------------------------------------', '-----', '--------------'
+            WRITE(numout,*)
+         END IF
+         iitarget = MINLOC( inbi0(:)*inbj0(:), mask = inbi0(:)*inbj0(:) >= knbij, dim = 1 )
+         DO ji = MAX(1,iitarget-10), MIN(isz0,iitarget+10)
+            ALLOCATE( llisoce(inbi0(ji), inbj0(ji)) )
+            CALL mpp_init_isoce( inbi0(ji), inbj0(ji), llisoce ) ! Warning: must be call by all cores (call mpp_sum)
+            inbij = COUNT(llisoce)
+            DEALLOCATE( llisoce )
+            IF(lwp) WRITE(numout,'(a, i5, a, i5, a, i4, a, i4, a, i9, a, i5, a, i5, a)')    &
+               &     'nb_cores ' , inbij,' oce + ', inbi0(ji)*inbj0(ji) - inbij             &
+               &                                , ' land ( ', inbi0(ji),' x ', inbj0(ji),   &
+               & ' ), nb_points ', iszi0(ji)*iszj0(ji),' ( ', iszi0(ji),' x ', iszj0(ji),' )'
+         END DO
+         DEALLOCATE( inbi0, inbj0, iszi0, iszj0 )
+         RETURN
+      ENDIF
+      
+      DEALLOCATE( iszi0, iszj0 )
+      inbij = inbijmax + 1        ! default: larger than possible
+      ii = isz0+1                 ! start from the end of the list (smaller subdomains)
+      DO WHILE( inbij > knbij )   ! while the number of ocean subdomains exceed the number of procs
+         ii = ii -1 
+         ALLOCATE( llisoce(inbi0(ii), inbj0(ii)) )
+         CALL mpp_init_isoce( inbi0(ii), inbj0(ii), llisoce )            ! must be done by all core
+         inbij = COUNT(llisoce)
+         DEALLOCATE( llisoce )
+      END DO
+      knbi = inbi0(ii)
+      knbj = inbj0(ii)
+      IF(PRESENT(knbcnt))   knbcnt = knbi * knbj - inbij
+      DEALLOCATE( inbi0, inbj0 )
+      !
+   END SUBROUTINE mpp_init_bestpartition
+   
+   
+   SUBROUTINE mpp_init_landprop( propland )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init_landprop  ***
+      !!
+      !! ** Purpose : the the proportion of land points in the surface land-sea mask
+      !!
+      !! ** Method  : read iproc strips (of length jpiglo) of the land-sea mask
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(  out) :: propland    ! proportion of land points (between 0 and 1)
+      !
+      INTEGER, DIMENSION(jpni*jpnj) ::   kusedom_1d
+      INTEGER :: inboce 
+      INTEGER :: iproc, idiv, ijsz
+      INTEGER :: ijstr, ijend, ijcnt
+      LOGICAL, ALLOCATABLE, DIMENSION(:,:) ::   lloce
+      !!----------------------------------------------------------------------
+      ! do nothing if there is no land-sea mask
+      IF( numbot == -1 .and. numbdy == -1 ) THEN
+         propland = 0.
+         RETURN
+      ENDIF
+
+      ! number of processes reading the bathymetry file 
+      iproc = MINVAL( (/mppsize, jpjglo/2, 100/) )  ! read a least 2 lines, no more that 100 processes reading at the same time
+      
+      ! we want to read iproc strips of the land-sea mask. -> pick up iproc processes among mppsize processes
+      IF( iproc == 1 ) THEN   ;   idiv = mppsize
+      ELSE                    ;   idiv = ( mppsize - 1 ) / ( iproc - 1 )
+      ENDIF
+      ijsz = jpjglo / iproc
+      IF( narea <= MOD(jpjglo,iproc) ) ijsz = ijsz + 1
+      
+      IF( MOD( narea-1, idiv ) == 0 .AND. (idiv /= 1 .OR. narea <= iproc ) ) THEN
+         !
+         ijstr = (narea-1)*(jpjglo/iproc) + MIN(narea-1, MOD(jpjglo,iproc)) + 1
+         ijend = ijstr + ijsz - 1
+         ijcnt = ijend - ijstr + 1
+         !
+         ALLOCATE( lloce(jpiglo, ijcnt) )   ! allocate the strip
+         CALL mpp_init_readbot_strip( ijstr, ijcnt, lloce )
+         inboce = COUNT(lloce)
+         DEALLOCATE(lloce)
+         !
+      ELSE
+         inboce = 0
+      ENDIF
+      CALL mpp_sum( 'mppini', inboce )
+      !
+      propland = REAL( jpiglo*jpjglo - inboce, wp ) / REAL( jpiglo*jpjglo, wp ) 
+      !
+   END SUBROUTINE mpp_init_landprop
+   
+   
+   SUBROUTINE mpp_init_isoce( knbi, knbj, ldisoce )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init_nboce  ***
+      !!
+      !! ** Purpose : check for a mpi domain decomposition knbi x knbj which
+      !!              subdomains contain at least 1 ocean point
+      !!
+      !! ** Method  : read knbj strips (of length jpiglo) of the land-sea mask
+      !!----------------------------------------------------------------------
+      INTEGER,                       INTENT(in   ) ::   knbi, knbj
+      LOGICAL, DIMENSION(knbi,knbj), INTENT(  out) ::   ldisoce   ! 
+      !
+      INTEGER, DIMENSION(knbi,knbj) ::   inboce
+      INTEGER, DIMENSION(knbi*knbj) ::   inboce_1d
+      INTEGER :: idiv, i2read, inj
+      INTEGER :: iimax, ijmax
+      INTEGER :: ji,jj
+      LOGICAL, ALLOCATABLE, DIMENSION(:,:) ::   lloce
+      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   iimppt, ilci
+      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   ijmppt, ilcj
+      !!----------------------------------------------------------------------
+      ! do nothing if there is no land-sea mask
+      IF( numbot == -1 .AND. numbdy == -1 ) THEN
+         ldisoce(:,:) = .TRUE.
+         RETURN
+      ENDIF
+
+      ! we want to read knbj strips of the land-sea mask. -> pick up knbj processes among mppsize processes
+      IF( knbj == 1 ) THEN   ;   idiv = mppsize
+      ELSE                   ;   idiv = ( mppsize - 1 ) / ( knbj - 1 )
+      ENDIF
+      inboce(:,:) = 0
+      IF( MOD( narea-1, idiv ) == 0 .AND. (idiv /= 1 .OR. narea <= knbj ) ) THEN
+         !
+         ALLOCATE( iimppt(knbi,knbj), ijmppt(knbi,knbj), ilci(knbi,knbj), ilcj(knbi,knbj) )
+         CALL mpp_basic_decomposition( knbi, knbj, iimax, ijmax, iimppt, ijmppt, ilci, ilcj )
+         !
+         i2read = knbj / mppsize    ! strip number to be read by this process
+         IF( ( narea - 1 ) / idiv < MOD(knbj,mppsize) ) i2read = i2read + 1
+         DO jj = 1, i2read
+            ! strip number to be read (from 1 to knbj)
+            inj = ( narea - 1 ) * ( knbj / mppsize ) + MIN( MOD(knbj,mppsize), ( narea - 1 ) / idiv ) + jj
+            ALLOCATE( lloce(jpiglo, ilcj(1,inj)) )                              ! allocate the strip
+            CALL mpp_init_readbot_strip( ijmppt(1,inj), ilcj(1,inj), lloce )   ! read the strip
+            DO  ji = 1, knbi
+               inboce(ji,inj) = COUNT( lloce(iimppt(ji,1):iimppt(ji,1)+ilci(ji,1)-1,:) )
+            END DO
+            DEALLOCATE(lloce)
+         END DO
+         !
+         DEALLOCATE(iimppt, ijmppt, ilci, ilcj)
+         !
+      ENDIF
+      
+      inboce_1d = RESHAPE(inboce, (/ knbi*knbj /))
+      CALL mpp_sum( 'mppini', inboce_1d )
+      inboce = RESHAPE(inboce_1d, (/knbi, knbj/))
+      ldisoce = inboce /= 0
+      !
+   END SUBROUTINE mpp_init_isoce
+   
+   
+   SUBROUTINE mpp_init_readbot_strip( kjstr, kjcnt, ldoce )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE mpp_init_readbot_strip  ***
+      !!
+      !! ** Purpose : Read relevant bathymetric information in order to
+      !!              provide a land/sea mask used for the elimination
       !!              of land domains, in an mpp computation.
       !!
-      !! ** Method  : Read the namelist ln_zco and ln_isfcav in namelist namzgr
-      !!              in order to choose the correct bathymetric information
-      !!              (file and variables)  
-      !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(jpiglo,jpjglo), INTENT(out) ::   kmask   ! global domain 
-  
-      INTEGER :: inum   !: logical unit for configuration file
-      INTEGER :: ios    !: iostat error flag
-      INTEGER ::  ijstartrow                   ! temporary integers
-      REAL(wp), DIMENSION(jpiglo,jpjglo) ::   zbot, zbdy          ! global workspace
-      REAL(wp) ::   zidom , zjdom          ! local scalars
-      NAMELIST/nambdy/ ln_bdy, nb_bdy, ln_coords_file, cn_coords_file,           &
-           &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
-           &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &  
-           &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
-           &             cn_ice, nn_ice_dta,                                     &
-           &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
-           &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
-      !!----------------------------------------------------------------------
-      ! 0. initialisation
-      ! -----------------
-      CALL iom_open( cn_domcfg, inum )
-      !
-      ! ocean bottom level
-      CALL iom_get( inum, jpdom_unknown, 'bottom_level' , zbot , lrowattr=ln_use_jattr )  ! nb of ocean T-points
-      !
-      CALL iom_close( inum )
-      !
-      ! 2D ocean mask (=1 if at least one level of the water column is ocean, =0 otherwise)
-      WHERE( zbot(:,:) > 0 )   ;   kmask(:,:) = 1
-      ELSEWHERE                ;   kmask(:,:) = 0
-      END WHERE
-  
-      ! Adjust kmask with bdy_msk if it exists
-  
-      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist : BDY
-      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist (mppini)', lwp )
-      !
-      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist : BDY
-      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist (mppini)', lwp )
-
-      IF( ln_bdy .AND. ln_mask_file ) THEN
-         CALL iom_open( cn_mask_file, inum )
-         CALL iom_get ( inum, jpdom_unknown, 'bdy_msk', zbdy )
-         CALL iom_close( inum )
-         WHERE ( zbdy(:,:) <= 0. ) kmask = 0
-      ENDIF
-      !
-   END SUBROUTINE mpp_init_mask
+      !! ** Method  : read stipe of size (jpiglo,...)
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in   ) :: kjstr       ! 
+      INTEGER                         , INTENT(in   ) :: kjcnt       ! 
+      LOGICAL, DIMENSION(jpiglo,kjcnt), INTENT(  out) :: ldoce       ! 
+      !
+      INTEGER                           ::   inumsave                     ! local logical unit
+      REAL(wp), DIMENSION(jpiglo,kjcnt) ::   zbot, zbdy 
+      !!----------------------------------------------------------------------
+      !
+      inumsave = numout   ;   numout = numnul   !   redirect all print to /dev/null
+      !
+      IF( numbot /= -1 ) THEN
+         CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/1,kjstr/), kcount = (/jpiglo, kjcnt/) )
+      ELSE
+         zbot(:,:) = 1.   ! put a non-null value
+      ENDIF
+
+       IF( numbdy /= -1 ) THEN   ! Adjust  with bdy_msk if it exists    
+         CALL iom_get ( numbdy, jpdom_unknown, 'bdy_msk', zbdy, kstart = (/1,kjstr/), kcount = (/jpiglo, kjcnt/) )
+         zbot(:,:) = zbot(:,:) * zbdy(:,:)
+      ENDIF
+      !
+      ldoce = zbot > 0.
+      numout = inumsave
+      !
+   END SUBROUTINE mpp_init_readbot_strip
 
 
@@ -720,116 +1112,4 @@
       !
    END SUBROUTINE mpp_init_ioipsl  
-
-
-   SUBROUTINE mpp_init_partition( num_pes )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE mpp_init_partition  ***
-      !!
-      !! ** Purpose :
-      !!
-      !! ** Method  :
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   num_pes   ! The number of MPI processes we have
-      !
-      INTEGER, PARAMETER :: nfactmax = 20
-      INTEGER :: nfact ! The no. of factors returned
-      INTEGER :: ierr  ! Error flag
-      INTEGER :: ji
-      INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value
-      INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors
-      !!----------------------------------------------------------------------
-      !
-      ierr = 0
-      !
-      CALL factorise( ifact, nfactmax, nfact, num_pes, ierr )
-      !
-      IF( nfact <= 1 ) THEN
-         WRITE (numout, *) 'WARNING: factorisation of number of PEs failed'
-         WRITE (numout, *) '       : using grid of ',num_pes,' x 1'
-         jpnj = 1
-         jpni = num_pes
-      ELSE
-         ! Search through factors for the pair that are closest in value
-         mindiff = 1000000
-         imin    = 1
-         DO ji = 1, nfact-1, 2
-            idiff = ABS( ifact(ji) - ifact(ji+1) )
-            IF( idiff < mindiff ) THEN
-               mindiff = idiff
-               imin = ji
-            ENDIF
-         END DO
-         jpnj = ifact(imin)
-         jpni = ifact(imin + 1)
-      ENDIF
-      !
-      jpnij = jpni*jpnj
-      !
-   END SUBROUTINE mpp_init_partition
-
-
-   SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE factorise  ***
-      !!
-      !! ** Purpose :   return the prime factors of n.
-      !!                knfax factors are returned in array kfax which is of
-      !!                maximum dimension kmaxfax.
-      !! ** Method  :
-      !!----------------------------------------------------------------------
-      INTEGER                    , INTENT(in   ) ::   kn, kmaxfax
-      INTEGER                    , INTENT(  out) ::   kerr, knfax
-      INTEGER, DIMENSION(kmaxfax), INTENT(  out) ::   kfax
-      !
-      INTEGER :: ifac, jl, inu
-      INTEGER, PARAMETER :: ntest = 14
-      INTEGER, DIMENSION(ntest) ::   ilfax
-      !!----------------------------------------------------------------------
-      !
-      ! lfax contains the set of allowed factors.
-      ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)
-      !
-      ! Clear the error flag and initialise output vars
-      kerr  = 0
-      kfax  = 1
-      knfax = 0
-      !
-      IF( kn /= 1 ) THEN      ! Find the factors of n
-         !
-         ! nu holds the unfactorised part of the number.
-         ! knfax holds the number of factors found.
-         ! l points to the allowed factor list.
-         ! ifac holds the current factor.
-         !
-         inu   = kn
-         knfax = 0
-         !
-         DO jl = ntest, 1, -1
-            !
-            ifac = ilfax(jl)
-            IF( ifac > inu )   CYCLE
-            !
-            ! Test whether the factor will divide.
-            !
-            IF( MOD(inu,ifac) == 0 ) THEN
-               !
-               knfax = knfax + 1            ! Add the factor to the list
-               IF( knfax > kmaxfax ) THEN
-                  kerr = 6
-                  write (*,*) 'FACTOR: insufficient space in factor array ', knfax
-                  return
-               ENDIF
-               kfax(knfax) = ifac
-               ! Store the other factor that goes with this one
-               knfax = knfax + 1
-               kfax(knfax) = inu / ifac
-               !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax)
-            ENDIF
-            !
-         END DO
-         !
-      ENDIF
-      !
-   END SUBROUTINE factorise
 
 
@@ -896,5 +1176,5 @@
    END SUBROUTINE mpp_init_nfdcom
 
-   
+
 #endif
 
Index: /NEMO/trunk/src/OCE/LDF/ldfc1d_c2d.F90
===================================================================
--- /NEMO/trunk/src/OCE/LDF/ldfc1d_c2d.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LDF/ldfc1d_c2d.F90	(revision 10425)
@@ -87,5 +87,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pah2, 'F', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( 'ldfc1d_c2d', pah2, 'F', 1. )   ! Lateral boundary conditions
          !
       CASE( 'TRA' )                     ! U- and V-points (zdep1 & 2 are an approximation in zps-coord.)
@@ -101,5 +101,5 @@
          END DO
          ! Lateral boundary conditions
-         CALL lbc_lnk_multi( pah1, 'U', 1. , pah2, 'V', 1. )   
+         CALL lbc_lnk_multi( 'ldfc1d_c2d', pah1, 'U', 1. , pah2, 'V', 1. )   
          !
       CASE DEFAULT                        ! error
Index: /NEMO/trunk/src/OCE/LDF/ldfdyn.F90
===================================================================
--- /NEMO/trunk/src/OCE/LDF/ldfdyn.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LDF/ldfdyn.F90	(revision 10425)
@@ -399,5 +399,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( ahmt, 'T', 1.,  ahmf, 'F', 1. )
+         CALL lbc_lnk_multi( 'ldfdyn', ahmt, 'T', 1.,  ahmf, 'F', 1. )
          !
          !
@@ -477,5 +477,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( ahmt, 'T', 1. , ahmf, 'F', 1. )
+         CALL lbc_lnk_multi( 'ldfdyn', ahmt, 'T', 1. , ahmf, 'F', 1. )
          !
       END SELECT
Index: /NEMO/trunk/src/OCE/LDF/ldfslp.F90
===================================================================
--- /NEMO/trunk/src/OCE/LDF/ldfslp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LDF/ldfslp.F90	(revision 10425)
@@ -232,5 +232,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zwz, 'U', -1.,  zww, 'V', -1. )      ! lateral boundary conditions
+      CALL lbc_lnk_multi( 'ldfslp', zwz, 'U', -1.,  zww, 'V', -1. )      ! lateral boundary conditions
       !
       !                                            !* horizontal Shapiro filter
@@ -314,5 +314,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zwz, 'T', -1.,  zww, 'T', -1. )      ! lateral boundary conditions
+      CALL lbc_lnk_multi( 'ldfslp', zwz, 'T', -1.,  zww, 'T', -1. )      ! lateral boundary conditions
       !
       !                                           !* horizontal Shapiro filter
@@ -363,5 +363,5 @@
       ! IV. Lateral boundary conditions
       ! ===============================
-      CALL lbc_lnk_multi( uslp , 'U', -1. , vslp , 'V', -1. , wslpi, 'W', -1., wslpj, 'W', -1. )
+      CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1. , vslp , 'V', -1. , wslpi, 'W', -1., wslpj, 'W', -1. )
 
       IF(ln_ctl) THEN
@@ -611,5 +611,5 @@
       wslp2(:,:,1) = 0._wp                ! force the surface wslp to zero
 
-      CALL lbc_lnk( wslp2, 'W', 1. )      ! lateral boundary confition on wslp2 only   ==>>> gm : necessary ? to be checked
+      CALL lbc_lnk( 'ldfslp', wslp2, 'W', 1. )      ! lateral boundary confition on wslp2 only   ==>>> gm : necessary ? to be checked
       !
       IF( ln_timing )   CALL timing_stop('ldf_slp_triad')
@@ -725,5 +725,5 @@
       END DO
       !!gm this lbc_lnk should be useless....
-      CALL lbc_lnk_multi( uslpml , 'U', -1. , vslpml , 'V', -1. , wslpiml, 'W', -1. , wslpjml, 'W', -1. ) 
+      CALL lbc_lnk_multi( 'ldfslp', uslpml , 'U', -1. , vslpml , 'V', -1. , wslpiml, 'W', -1. , wslpjml, 'W', -1. ) 
       !
    END SUBROUTINE ldf_slp_mxl
@@ -793,5 +793,5 @@
 !               END DO
 !            END DO
-!            CALL lbc_lnk_multi( uslp , 'U', -1. ; CALL lbc_lnk( vslp , 'V', -1.,  wslpi, 'W', -1.,  wslpj, 'W', -1. )
+!            CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1. ; CALL lbc_lnk( 'ldfslp', vslp , 'V', -1.,  wslpi, 'W', -1.,  wslpj, 'W', -1. )
 !!gm         ENDIF
       ENDIF
Index: /NEMO/trunk/src/OCE/LDF/ldftra.F90
===================================================================
--- /NEMO/trunk/src/OCE/LDF/ldftra.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/LDF/ldftra.F90	(revision 10425)
@@ -707,5 +707,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zaeiw(:,:), 'W', 1. )       ! lateral boundary condition
+      CALL lbc_lnk( 'ldftra', zaeiw(:,:), 'W', 1. )       ! lateral boundary condition
       !               
       DO jj = 2, jpjm1                          !== aei at u- and v-points  ==!
@@ -715,5 +715,5 @@
          END DO 
       END DO 
-      CALL lbc_lnk_multi( paeiu(:,:,1), 'U', 1. , paeiv(:,:,1), 'V', 1. )      ! lateral boundary condition
+      CALL lbc_lnk_multi( 'ldftra', paeiu(:,:,1), 'U', 1. , paeiv(:,:,1), 'V', 1. )      ! lateral boundary condition
 
       DO jk = 2, jpkm1                          !==  deeper values equal the surface one  ==!
@@ -821,5 +821,5 @@
 !!gm     to be redesigned....   
       !                                                  !==  eiv stream function: output  ==!
-      CALL lbc_lnk_multi( psi_uw, 'U', -1. , psi_vw, 'V', -1. )
+      CALL lbc_lnk_multi( 'ldftra', psi_uw, 'U', -1. , psi_vw, 'V', -1. )
       !
 !!gm      CALL iom_put( "psi_eiv_uw", psi_uw )                 ! output
@@ -848,5 +848,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zw3d, 'T', 1. )      ! lateral boundary condition
+      CALL lbc_lnk( 'ldftra', zw3d, 'T', 1. )      ! lateral boundary condition
       CALL iom_put( "woce_eiv", zw3d )
       !
@@ -865,6 +865,6 @@
            END DO
         END DO
-        CALL lbc_lnk( zw2d, 'U', -1. )
-        CALL lbc_lnk( zw3d, 'U', -1. )
+        CALL lbc_lnk( 'ldftra', zw2d, 'U', -1. )
+        CALL lbc_lnk( 'ldftra', zw3d, 'U', -1. )
         CALL iom_put( "ueiv_heattr"  , zztmp * zw2d )                  ! heat transport in i-direction
         CALL iom_put( "ueiv_heattr3d", zztmp * zw3d )                  ! heat transport in i-direction
@@ -881,5 +881,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zw2d, 'V', -1. )
+      CALL lbc_lnk( 'ldftra', zw2d, 'V', -1. )
       CALL iom_put( "veiv_heattr", zztmp * zw2d )                  !  heat transport in j-direction
       CALL iom_put( "veiv_heattr", zztmp * zw3d )                  !  heat transport in j-direction
@@ -900,6 +900,6 @@
            END DO
         END DO
-        CALL lbc_lnk( zw2d, 'U', -1. )
-        CALL lbc_lnk( zw3d, 'U', -1. )
+        CALL lbc_lnk( 'ldftra', zw2d, 'U', -1. )
+        CALL lbc_lnk( 'ldftra', zw3d, 'U', -1. )
         CALL iom_put( "ueiv_salttr", zztmp * zw2d )                  ! salt transport in i-direction
         CALL iom_put( "ueiv_salttr3d", zztmp * zw3d )                  ! salt transport in i-direction
@@ -916,5 +916,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zw2d, 'V', -1. )
+      CALL lbc_lnk( 'ldftra', zw2d, 'V', -1. )
       CALL iom_put( "veiv_salttr", zztmp * zw2d )                  !  salt transport in j-direction
       CALL iom_put( "veiv_salttr", zztmp * zw3d )                  !  salt transport in j-direction
Index: /NEMO/trunk/src/OCE/OBS/obs_averg_h2d.F90
===================================================================
--- /NEMO/trunk/src/OCE/OBS/obs_averg_h2d.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/OBS/obs_averg_h2d.F90	(revision 10425)
@@ -616,6 +616,6 @@
          
          IF(lk_mpp) THEN
-            CALL mpp_min( ze1min )
-            CALL mpp_min( ze2min )
+            CALL mpp_min( 'obs_averg_h2d', ze1min )
+            CALL mpp_min( 'obs_averg_h2d', ze2min )
          ENDIF
 
Index: /NEMO/trunk/src/OCE/OBS/obs_readmdt.F90
===================================================================
--- /NEMO/trunk/src/OCE/OBS/obs_readmdt.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/OBS/obs_readmdt.F90	(revision 10425)
@@ -220,7 +220,7 @@
       END DO
 
-      IF( lk_mpp)   CALL mpp_sum( zeta1 )
-      IF( lk_mpp)   CALL mpp_sum( zeta2 )
-      IF( lk_mpp)   CALL mpp_sum( zarea )
+      CALL mpp_sum( 'obs_readmdt', zeta1 )
+      CALL mpp_sum( 'obs_readmdt', zeta2 )
+      CALL mpp_sum( 'obs_readmdt', zarea )
       
       zcorr_mdt    = zeta1 / zarea
Index: /NEMO/trunk/src/OCE/OBS/obs_write.F90
===================================================================
--- /NEMO/trunk/src/OCE/OBS/obs_write.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/OBS/obs_write.F90	(revision 10425)
@@ -592,6 +592,6 @@
 
          CALL obs_mpp_sum_integer( inumgoodobs, inumgoodobsmpp )
-         CALL mpp_sum(zsumx)
-         CALL mpp_sum(zsumx2)
+         CALL mpp_sum('obs_write', zsumx)
+         CALL mpp_sum('obs_write', zsumx2)
 
          IF (lwp) THEN
Index: /NEMO/trunk/src/OCE/SBC/cpl_oasis3.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/cpl_oasis3.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/cpl_oasis3.F90	(revision 10425)
@@ -456,5 +456,7 @@
          !--- Fill the overlap areas and extra hallows (mpp)
          !--- check periodicity conditions (all cases)
-         IF( .not. llfisrt )   CALL lbc_lnk( pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn )   
+         IF( .not. llfisrt ) THEN
+            CALL lbc_lnk( 'cpl_oasis3', pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn )   
+         ENDIF
  
       ENDDO
Index: /NEMO/trunk/src/OCE/SBC/fldread.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/fldread.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/fldread.F90	(revision 10425)
@@ -669,8 +669,8 @@
                IF( sdjf%ln_tint ) THEN
                   CALL iom_get( sdjf%num, sdjf%clvar, sdjf%fdta(2,2,1,2), sdjf%nrec_a(1) )
-                  CALL lbc_lnk( sdjf%fdta(:,:,1,2),'Z',1. )
+                  CALL lbc_lnk( 'fldread', sdjf%fdta(:,:,1,2),'Z',1. )
                ELSE
                   CALL iom_get( sdjf%num, sdjf%clvar, sdjf%fnow(2,2,1  ), sdjf%nrec_a(1) )
-                  CALL lbc_lnk( sdjf%fnow(:,:,1  ),'Z',1. )
+                  CALL lbc_lnk( 'fldread', sdjf%fnow(:,:,1  ),'Z',1. )
                ENDIF
             ELSE
@@ -683,8 +683,8 @@
                IF( sdjf%ln_tint ) THEN
                   CALL iom_get( sdjf%num, jpdom_unknown, sdjf%clvar, sdjf%fdta(2,2,:,2), sdjf%nrec_a(1) )
-                  CALL lbc_lnk( sdjf%fdta(:,:,:,2),'Z',1. )
+                  CALL lbc_lnk( 'fldread', sdjf%fdta(:,:,:,2),'Z',1. )
                ELSE
                   CALL iom_get( sdjf%num, jpdom_unknown, sdjf%clvar, sdjf%fnow(2,2,:  ), sdjf%nrec_a(1) )
-                  CALL lbc_lnk( sdjf%fnow(:,:,:  ),'Z',1. )
+                  CALL lbc_lnk( 'fldread', sdjf%fnow(:,:,:  ),'Z',1. )
                ENDIF
             ELSE
Index: /NEMO/trunk/src/OCE/SBC/geo2ocean.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/geo2ocean.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/geo2ocean.F90	(revision 10425)
@@ -152,5 +152,5 @@
          &      gsinv(jpi,jpj), gcosv(jpi,jpj),   &  
          &      gsinf(jpi,jpj), gcosf(jpi,jpj), STAT=ierr )
-      IF(lk_mpp)   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'geo2ocean', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'angle: unable to allocate arrays' )
       !
@@ -276,5 +276,5 @@
       ! =========================== !
       !           ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
-      CALL lbc_lnk_multi( gcost, 'T', -1., gsint, 'T', -1., gcosu, 'U', -1., gsinu, 'U', -1., & 
+      CALL lbc_lnk_multi( 'geo2ocean', gcost, 'T', -1., gsint, 'T', -1., gcosu, 'U', -1., gsinu, 'U', -1., & 
                       &   gcosv, 'V', -1., gsinv, 'V', -1., gcosf, 'F', -1., gsinf, 'F', -1.  )
       !
@@ -304,5 +304,5 @@
          ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
             &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
-         IF( lk_mpp    )   CALL mpp_sum( ierr )
+         CALL mpp_sum( 'geo2ocean', ierr )
          IF( ierr /= 0 )   CALL ctl_stop('geo2oce: unable to allocate arrays' )
       ENDIF
@@ -381,5 +381,5 @@
          ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) ,   &
             &      gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr )
-         IF( lk_mpp    )   CALL mpp_sum( ierr )
+         CALL mpp_sum( 'geo2ocean', ierr )
          IF( ierr /= 0 )   CALL ctl_stop('oce2geo: unable to allocate arrays' )
       ENDIF
Index: /NEMO/trunk/src/OCE/SBC/sbc_ice.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbc_ice.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbc_ice.F90	(revision 10425)
@@ -150,5 +150,5 @@
 
       sbc_ice_alloc = MAXVAL( ierr )
-      IF( lk_mpp            )   CALL mpp_sum ( sbc_ice_alloc )
+      CALL mpp_sum ( 'sbc_ice', sbc_ice_alloc )
       IF( sbc_ice_alloc > 0 )   CALL ctl_warn('sbc_ice_alloc: allocation of arrays failed')
    END FUNCTION sbc_ice_alloc
@@ -197,5 +197,5 @@
       ALLOCATE( snwice_mass(jpi,jpj) , snwice_mass_b(jpi,jpj), snwice_fmass(jpi,jpj) , STAT=ierr(1) )
       sbc_ice_alloc = MAXVAL( ierr )
-      IF( lk_mpp            )   CALL mpp_sum ( sbc_ice_alloc )
+      CALL mpp_sum ( 'sbc_ice', sbc_ice_alloc )
       IF( sbc_ice_alloc > 0 )   CALL ctl_warn('sbc_ice_alloc: allocation of arrays failed')
    END FUNCTION sbc_ice_alloc
Index: /NEMO/trunk/src/OCE/SBC/sbc_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbc_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbc_oce.F90	(revision 10425)
@@ -186,5 +186,5 @@
          !
       sbc_oce_alloc = MAXVAL( ierr )
-      IF( lk_mpp            )   CALL mpp_sum ( sbc_oce_alloc )
+      CALL mpp_sum ( 'sbc_oce', sbc_oce_alloc )
       IF( sbc_oce_alloc > 0 )   CALL ctl_warn('sbc_oce_alloc: allocation of arrays failed')
       !
@@ -216,5 +216,5 @@
          END DO
       END DO
-      CALL lbc_lnk( wndm(:,:) , 'T', 1. )
+      CALL lbc_lnk( 'sbc_oce', wndm(:,:) , 'T', 1. )
       !
    END SUBROUTINE sbc_tau2wnd
Index: /NEMO/trunk/src/OCE/SBC/sbcapr.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcapr.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcapr.F90	(revision 10425)
@@ -94,5 +94,5 @@
       !
       IF( ln_ref_apr ) THEN                        !* Compute whole inner domain mean masked ocean surface
-         tarea = glob_sum( e1e2t(:,:) )
+         tarea = glob_sum( 'sbcapr', e1e2t(:,:) )
          IF(lwp) WRITE(numout,*) '         Variable ref. Patm computed over a ocean surface of ', tarea*1e-6, 'km2'
       ELSE
@@ -141,5 +141,5 @@
          !
          !                                                  !* update the reference atmospheric pressure (if necessary)
-         IF( ln_ref_apr )   rn_pref = glob_sum( sf_apr(1)%fnow(:,:,1) * e1e2t(:,:) ) / tarea
+         IF( ln_ref_apr )   rn_pref = glob_sum( 'sbcapr', sf_apr(1)%fnow(:,:,1) * e1e2t(:,:) ) / tarea
          !
          !                                                  !* Patm related forcing at kt
Index: /NEMO/trunk/src/OCE/SBC/sbcblk.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcblk.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcblk.F90	(revision 10425)
@@ -147,6 +147,6 @@
          &      cdn_oce(jpi,jpj), chn_oce(jpi,jpj), cen_oce(jpi,jpj), STAT=sbc_blk_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( sbc_blk_alloc )
-      IF( sbc_blk_alloc /= 0 )   CALL ctl_warn('sbc_blk_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'sbcblk', sbc_blk_alloc )
+      IF( sbc_blk_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sbc_blk_alloc: failed to allocate arrays' )
    END FUNCTION sbc_blk_alloc
 
@@ -236,5 +236,5 @@
       !Activated wave module but neither drag nor stokes drift activated
          IF ( .NOT.(ln_cdgw .OR. ln_sdw .OR. ln_tauwoc .OR. ln_stcor ) )   THEN
-            CALL ctl_warn( 'Ask for wave coupling but ln_cdgw=F, ln_sdw=F, ln_tauwoc=F, ln_stcor=F')
+            CALL ctl_stop( 'STOP',  'Ask for wave coupling but ln_cdgw=F, ln_sdw=F, ln_tauwoc=F, ln_stcor=F' )
       !drag coefficient read from wave model definable only with mfs bulk formulae and core 
          ELSEIF (ln_cdgw .AND. .NOT. ln_NCAR )       THEN       
@@ -407,5 +407,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zwnd_i, 'T', -1., zwnd_j, 'T', -1. )
+      CALL lbc_lnk_multi( 'sbcblk', zwnd_i, 'T', -1., zwnd_j, 'T', -1. )
       ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
       wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   &
@@ -485,5 +485,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( utau, 'U', -1., vtau, 'V', -1. )
+      CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1., vtau, 'V', -1. )
 
       !  Turbulent fluxes over ocean
@@ -727,5 +727,5 @@
          END DO
       END DO
-      CALL lbc_lnk( wndm_ice, 'T',  1. )
+      CALL lbc_lnk( 'sbcblk', wndm_ice, 'T',  1. )
       !
       ! Make ice-atm. drag dependent on ice concentration
@@ -761,5 +761,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( utau_ice, 'U', -1., vtau_ice, 'V', -1. )
+      CALL lbc_lnk_multi( 'sbcblk', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
       !
       !
@@ -1186,5 +1186,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( Cd, 'T',  1., Ch, 'T', 1. )
+      CALL lbc_lnk_multi( 'sbcblk', Cd, 'T',  1., Ch, 'T', 1. )
       !
    END SUBROUTINE Cdn10_Lupkes2015
Index: /NEMO/trunk/src/OCE/SBC/sbccpl.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbccpl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbccpl.F90	(revision 10425)
@@ -224,5 +224,5 @@
 
       sbc_cpl_alloc = MAXVAL( ierr )
-      IF( lk_mpp            )   CALL mpp_sum ( sbc_cpl_alloc )
+      CALL mpp_sum ( 'sbccpl', sbc_cpl_alloc )
       IF( sbc_cpl_alloc > 0 )   CALL ctl_warn('sbc_cpl_alloc: allocation of arrays failed')
       !
@@ -1162,5 +1162,5 @@
                   END DO
                END DO
-               CALL lbc_lnk_multi( frcv(jpr_otx1)%z3(:,:,1), 'U',  -1., frcv(jpr_oty1)%z3(:,:,1), 'V',  -1. )
+               CALL lbc_lnk_multi( 'sbccpl', frcv(jpr_otx1)%z3(:,:,1), 'U',  -1., frcv(jpr_oty1)%z3(:,:,1), 'V',  -1. )
             ENDIF
             llnewtx = .TRUE.
@@ -1189,5 +1189,5 @@
                END DO
             END DO
-            CALL lbc_lnk( frcv(jpr_taum)%z3(:,:,1), 'T', 1. )
+            CALL lbc_lnk( 'sbccpl', frcv(jpr_taum)%z3(:,:,1), 'T', 1. )
             llnewtau = .TRUE.
          ELSE
@@ -1570,5 +1570,5 @@
          END SELECT
          IF( srcv(jpr_itx1)%clgrid /= 'U' ) THEN 
-            CALL lbc_lnk_multi( p_taui, 'U',  -1., p_tauj, 'V',  -1. )
+            CALL lbc_lnk_multi( 'sbccpl', p_taui, 'U',  -1., p_tauj, 'V',  -1. )
          ENDIF
          
@@ -2335,5 +2335,5 @@
                   END DO
                END DO
-               CALL lbc_lnk_multi( zitx1, 'T', -1., zity1, 'T', -1. )
+               CALL lbc_lnk_multi( 'sbccpl', zitx1, 'T', -1., zity1, 'T', -1. )
             CASE( 'mixed oce-ice'        )      ! Ocean and Ice on C-grid ==> T
                DO jj = 2, jpjm1
@@ -2346,5 +2346,5 @@
                END DO
             END SELECT
-            CALL lbc_lnk_multi( zotx1, ssnd(jps_ocx1)%clgrid, -1.,  zoty1, ssnd(jps_ocy1)%clgrid, -1. )
+            CALL lbc_lnk_multi( 'sbccpl', zotx1, ssnd(jps_ocx1)%clgrid, -1.,  zoty1, ssnd(jps_ocy1)%clgrid, -1. )
             !
          ENDIF
@@ -2418,5 +2418,5 @@
                 END DO
              END DO
-             CALL lbc_lnk_multi( zitx1, 'T', -1.,  zity1, 'T', -1. ) 
+             CALL lbc_lnk_multi( 'sbccpl', zitx1, 'T', -1.,  zity1, 'T', -1. ) 
           CASE( 'mixed oce-ice'        )      ! Ocean and Ice on C-grid ==> T  
              DO jj = 2, jpjm1 
@@ -2429,5 +2429,5 @@
              END DO
           END SELECT
-         CALL lbc_lnk_multi( zotx1, ssnd(jps_ocxw)%clgrid, -1., zoty1, ssnd(jps_ocyw)%clgrid, -1. ) 
+         CALL lbc_lnk_multi( 'sbccpl', zotx1, ssnd(jps_ocxw)%clgrid, -1., zoty1, ssnd(jps_ocyw)%clgrid, -1. ) 
          ! 
          ! 
Index: /NEMO/trunk/src/OCE/SBC/sbcdcy.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcdcy.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcdcy.F90	(revision 10425)
@@ -44,6 +44,6 @@
             &      rtmd(jpi,jpj) , rdawn(jpi,jpj) , rdusk(jpi,jpj) , rscal(jpi,jpj) , STAT=sbc_dcy_alloc )
             !
-         IF( lk_mpp             )   CALL mpp_sum ( sbc_dcy_alloc )
-         IF( sbc_dcy_alloc /= 0 )   CALL ctl_warn('sbc_dcy_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'sbcdcy', sbc_dcy_alloc )
+         IF( sbc_dcy_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sbc_dcy_alloc: failed to allocate arrays' )
       END FUNCTION sbc_dcy_alloc
 
Index: /NEMO/trunk/src/OCE/SBC/sbcflx.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcflx.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcflx.F90	(revision 10425)
@@ -157,5 +157,5 @@
          END DO
          taum(:,:) = taum(:,:) * tmask(:,:,1) ; wndm(:,:) = wndm(:,:) * tmask(:,:,1)
-         CALL lbc_lnk( taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( wndm(:,:), 'T', 1. )
+         CALL lbc_lnk( 'sbcflx', taum(:,:), 'T', 1. )   ;   CALL lbc_lnk( 'sbcflx', wndm(:,:), 'T', 1. )
 
          IF( nitend-nit000 <= 100 .AND. lwp ) THEN                ! control print (if less than 100 time-step asked)
Index: /NEMO/trunk/src/OCE/SBC/sbcfwb.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcfwb.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcfwb.F90	(revision 10425)
@@ -71,4 +71,6 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   ztmsk_neg, ztmsk_pos, z_wgt ! 2D workspaces
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   ztmsk_tospread, zerp_cor    !   -      -
+      REAL(wp)   ,DIMENSION(1) ::   z_fwfprv  
+      COMPLEX(wp),DIMENSION(1) ::   y_fwfnow  
       !!----------------------------------------------------------------------
       !
@@ -86,5 +88,5 @@
          IF( kn_fwb == 3 .AND. ln_isfcav    )   CALL ctl_stop( 'sbc_fwb: nn_fwb = 3 with ln_isfcav = .TRUE. not working, we stop ' )
          !
-         area = glob_sum( e1e2t(:,:) * tmask(:,:,1))           ! interior global domain surface
+         area = glob_sum( 'sbcfwb', e1e2t(:,:) * tmask(:,:,1))           ! interior global domain surface
          ! isf cavities are excluded because it can feedback to the melting with generation of inhibition of plumes
          ! and in case of no melt, it can generate HSSW.
@@ -102,7 +104,9 @@
          !
          IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN
-            z_fwf = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area   ! sum over the global domain
-            zcoef = z_fwf * rcp
-            emp(:,:) = emp(:,:) - z_fwf              * tmask(:,:,1)
+            y_fwfnow(1) = local_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) )
+            CALL mpp_delay_sum( 'sbcfwb', 'fwb', y_fwfnow(:), z_fwfprv(:), kt == nitend - nn_fsbc + 1 )
+            z_fwfprv(1) = z_fwfprv(1) / area
+            zcoef = z_fwfprv(1) * rcp
+            emp(:,:) = emp(:,:) - z_fwfprv(1)        * tmask(:,:,1)
             qns(:,:) = qns(:,:) + zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction
          ENDIF
@@ -127,5 +131,5 @@
             a_fwb_b = a_fwb                           ! mean sea level taking into account the ice+snow
                                                       ! sum over the global domain
-            a_fwb   = glob_sum( e1e2t(:,:) * ( sshn(:,:) + snwice_mass(:,:) * r1_rau0 ) )
+            a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( sshn(:,:) + snwice_mass(:,:) * r1_rau0 ) )
             a_fwb   = a_fwb * 1.e+3 / ( area * rday * 365. )     ! convert in Kg/m3/s = mm/s
 !!gm        !                                                      !!bug 365d year 
@@ -154,23 +158,22 @@
             WHERE( erp < 0._wp )   ztmsk_pos = 0._wp
             ztmsk_neg(:,:) = tmask_i(:,:) - ztmsk_pos(:,:)
-            !
-            zsurf_neg = glob_sum( e1e2t(:,:)*ztmsk_neg(:,:) )  ! Area filled by <0 and >0 erp 
-            zsurf_pos = glob_sum( e1e2t(:,:)*ztmsk_pos(:,:) )
             !                                                  ! fwf global mean (excluding ocean to ice/snow exchanges) 
-            z_fwf     = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area
+            z_fwf     = glob_sum( 'sbcfwb', e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area
             !            
             IF( z_fwf < 0._wp ) THEN         ! spread out over >0 erp area to increase evaporation
-                zsurf_tospread      = zsurf_pos
-                ztmsk_tospread(:,:) = ztmsk_pos(:,:)
+               zsurf_pos = glob_sum( 'sbcfwb', e1e2t(:,:)*ztmsk_pos(:,:) )
+               zsurf_tospread      = zsurf_pos
+               ztmsk_tospread(:,:) = ztmsk_pos(:,:)
             ELSE                             ! spread out over <0 erp area to increase precipitation
-                zsurf_tospread      = zsurf_neg
-                ztmsk_tospread(:,:) = ztmsk_neg(:,:)
+               zsurf_neg = glob_sum( 'sbcfwb', e1e2t(:,:)*ztmsk_neg(:,:) )  ! Area filled by <0 and >0 erp 
+               zsurf_tospread      = zsurf_neg
+               ztmsk_tospread(:,:) = ztmsk_neg(:,:)
             ENDIF
             !
-            zsum_fwf   = glob_sum( e1e2t(:,:) * z_fwf )         ! fwf global mean over <0 or >0 erp area
+            zsum_fwf   = glob_sum( 'sbcfwb', e1e2t(:,:) * z_fwf )         ! fwf global mean over <0 or >0 erp area
 !!gm :  zsum_fwf   = z_fwf * area   ???  it is right?  I think so....
             z_fwf_nsrf =  zsum_fwf / ( zsurf_tospread + rsmall )
             !                                                  ! weight to respect erp field 2D structure 
-            zsum_erp   = glob_sum( ztmsk_tospread(:,:) * erp(:,:) * e1e2t(:,:) )
+            zsum_erp   = glob_sum( 'sbcfwb', ztmsk_tospread(:,:) * erp(:,:) * e1e2t(:,:) )
             z_wgt(:,:) = ztmsk_tospread(:,:) * erp(:,:) / ( zsum_erp + rsmall )
             !                                                  ! final correction term to apply
@@ -178,5 +181,5 @@
             !
 !!gm   ===>>>>  lbc_lnk should be useless as all the computation is done over the whole domain !
-            CALL lbc_lnk( zerp_cor, 'T', 1. )
+            CALL lbc_lnk( 'sbcfwb', zerp_cor, 'T', 1. )
             !
             emp(:,:) = emp(:,:) + zerp_cor(:,:)
Index: /NEMO/trunk/src/OCE/SBC/sbcice_cice.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcice_cice.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcice_cice.F90	(revision 10425)
@@ -100,5 +100,5 @@
       !!----------------------------------------------------------------------
       ALLOCATE( png(jpi,jpj,jpnij), STAT=sbc_ice_cice_alloc )
-      IF( lk_mpp                 )   CALL mpp_sum ( sbc_ice_cice_alloc )
+      CALL mpp_sum ( 'sbcice_cice', sbc_ice_cice_alloc )
       IF( sbc_ice_cice_alloc > 0 )   CALL ctl_warn('sbc_ice_cice_alloc: allocation of arrays failed.')
    END FUNCTION sbc_ice_cice_alloc
@@ -217,5 +217,5 @@
       ENDDO
 
-      CALL lbc_lnk_multi( fr_iu , 'U', 1.,  fr_iv , 'V', 1. )
+      CALL lbc_lnk_multi( 'sbcice_cice', fr_iu , 'U', 1.,  fr_iv , 'V', 1. )
 
       ! set the snow+ice mass
@@ -513,5 +513,5 @@
          ENDDO
       ENDDO
-      CALL lbc_lnk( ss_iou , 'U', -1. )
+      CALL lbc_lnk( 'sbcice_cice', ss_iou , 'U', -1. )
 
 ! y comp of ocean-ice stress 
@@ -525,5 +525,5 @@
          ENDDO
       ENDDO
-      CALL lbc_lnk( ss_iov , 'V', -1. )
+      CALL lbc_lnk( 'sbcice_cice', ss_iov , 'V', -1. )
 
 ! x and y comps of surface stress
@@ -578,5 +578,5 @@
       fmmflx(:,:) = ztmp1(:,:) !!Joakim edit
       
-      CALL lbc_lnk_multi( emp , 'T', 1., sfx , 'T', 1. )
+      CALL lbc_lnk_multi( 'sbcice_cice', emp , 'T', 1., sfx , 'T', 1. )
 
 ! Solar penetrative radiation and non solar surface heat flux
@@ -604,5 +604,5 @@
 #endif
       qsr(:,:)=qsr(:,:)+ztmp1(:,:)
-      CALL lbc_lnk( qsr , 'T', 1. )
+      CALL lbc_lnk( 'sbcice_cice', qsr , 'T', 1. )
 
       DO jj=1,jpj
@@ -619,5 +619,5 @@
       qns(:,:)=qns(:,:)+nfrzmlt(:,:)+ztmp1(:,:)
 
-      CALL lbc_lnk( qns , 'T', 1. )
+      CALL lbc_lnk( 'sbcice_cice', qns , 'T', 1. )
 
 ! Prepare for the following CICE time-step
@@ -639,5 +639,5 @@
       ENDDO
 
-      CALL lbc_lnk_multi( fr_iu , 'U', 1., fr_iv , 'V', 1. )
+      CALL lbc_lnk_multi( 'sbcice_cice', fr_iu , 'U', 1., fr_iv , 'V', 1. )
 
       ! set the snow+ice mass
@@ -863,5 +863,5 @@
 !     A. Ensure all haloes are filled in NEMO field (pn)
 
-      CALL lbc_lnk( pn , cd_type, psgn )
+      CALL lbc_lnk( 'sbcice_cice', pn , cd_type, psgn )
 
 #if defined key_nemocice_decomp
@@ -1040,5 +1040,5 @@
 !     D. Ensure all haloes are filled in pn
 
-      CALL lbc_lnk( pn , cd_type, psgn )
+      CALL lbc_lnk( 'sbcice_cice', pn , cd_type, psgn )
 
    END SUBROUTINE cice2nemo
Index: /NEMO/trunk/src/OCE/SBC/sbcisf.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcisf.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcisf.F90	(revision 10425)
@@ -157,5 +157,5 @@
 
          ! lbclnk
-         CALL lbc_lnk_multi( risf_tsc(:,:,jp_tem), 'T', 1., risf_tsc(:,:,jp_sal), 'T', 1., fwfisf,'T', 1., qisf, 'T', 1.)
+         CALL lbc_lnk_multi( 'sbcisf', risf_tsc(:,:,jp_tem), 'T', 1., risf_tsc(:,:,jp_sal), 'T', 1., fwfisf,'T', 1., qisf, 'T', 1.)
          ! output
          IF( iom_use('iceshelf_cea') )   CALL iom_put( 'iceshelf_cea', -fwfisf(:,:)                      )   ! isf mass flux
@@ -244,6 +244,6 @@
                &    STAT= sbc_isf_alloc )
          !
-         IF( lk_mpp             )   CALL mpp_sum ( sbc_isf_alloc )
-         IF( sbc_isf_alloc /= 0 )   CALL ctl_warn('sbc_isf_alloc: failed to allocate arrays.')
+         CALL mpp_sum ( 'sbcisf', sbc_isf_alloc )
+         IF( sbc_isf_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sbc_isf_alloc: failed to allocate arrays.' )
          !
       ENDIF
@@ -721,5 +721,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( pgt, 'T', 1., pgs, 'T', 1.)
+         CALL lbc_lnk_multi( 'sbcisf', pgt, 'T', 1., pgs, 'T', 1.)
       END SELECT
       !
@@ -778,5 +778,5 @@
             END DO
          END DO
-         CALL lbc_lnk(pvarout,'T',-1.)
+         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
       
       CASE ( 'V' ) ! compute V in the top boundary layer at T- point 
@@ -810,5 +810,5 @@
             END DO
          END DO
-         CALL lbc_lnk(pvarout,'T',-1.)
+         CALL lbc_lnk('sbcisf', pvarout,'T',-1.)
 
       CASE ( 'T' ) ! compute T in the top boundary layer at T- point 
Index: /NEMO/trunk/src/OCE/SBC/sbcmod.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcmod.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcmod.F90	(revision 10425)
@@ -115,4 +115,7 @@
       IF(lwm) WRITE( numond, namsbc )
       !
+#if defined key_mpp_mpi
+      ncom_fsbc = nn_fsbc    ! make nn_fsbc available for lib_mpp
+#endif
       !                             !* overwrite namelist parameter using CPP key information
 #if defined key_agrif
@@ -440,5 +443,5 @@
          ! icebergs may advect into haloes during the icb step and alter emp.
          ! A lbc_lnk is necessary here to ensure restartability (#2113)
-         IF( .NOT. ln_passive_mode ) CALL lbc_lnk( emp, 'T', 1. ) ! ensure restartability with icebergs
+         IF( .NOT. ln_passive_mode ) CALL lbc_lnk( 'sbcmod', emp, 'T', 1. ) ! ensure restartability with icebergs
       ENDIF
 
@@ -457,5 +460,5 @@
 !!$!RBbug do not understand why see ticket 667
 !!$!clem: it looks like it is necessary for the north fold (in certain circumstances). Don't know why.
-!!$      CALL lbc_lnk( emp, 'T', 1. )
+!!$      CALL lbc_lnk( 'sbcmod', emp, 'T', 1. )
       !
       IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
Index: /NEMO/trunk/src/OCE/SBC/sbcrnf.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcrnf.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcrnf.F90	(revision 10425)
@@ -83,5 +83,5 @@
          &      rnf_tsc_b(jpi,jpj,jpts) , rnf_tsc (jpi,jpj,jpts) , STAT=sbc_rnf_alloc )
          !
-      IF( lk_mpp            )   CALL mpp_sum ( sbc_rnf_alloc )
+      CALL mpp_sum ( 'sbcrnf', sbc_rnf_alloc )
       IF( sbc_rnf_alloc > 0 )   CALL ctl_warn('sbc_rnf_alloc: allocation of arrays failed')
    END FUNCTION sbc_rnf_alloc
@@ -423,5 +423,5 @@
          IF( nn_rnf_depth_file == 1 ) THEN      !  save  output nb levels for runoff
             IF(lwp) WRITE(numout,*) '   ==>>>   create runoff depht file'
-            CALL iom_open  ( TRIM( sn_dep_rnf%clname ), inum, ldwrt = .TRUE., kiolib = jprstlib )
+            CALL iom_open  ( TRIM( sn_dep_rnf%clname ), inum, ldwrt = .TRUE. )
             CALL iom_rstput( 0, 0, inum, 'rodepth', h_rnf )
             CALL iom_close ( inum )
Index: /NEMO/trunk/src/OCE/SBC/sbcssm.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcssm.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcssm.F90	(revision 10425)
@@ -18,4 +18,5 @@
    USE sbcapr         ! surface boundary condition: atmospheric pressure
    USE eosbn2         ! equation of state and related derivatives
+   USE traqsr, ONLY: ln_traqsr
    !
    USE in_out_manager ! I/O manager
@@ -253,4 +254,6 @@
       ENDIF
       !
+      IF( .NOT. ln_traqsr )   fraqsr_1lev(:,:) = 1._wp   ! default definition: qsr 100% in the fisrt level 
+      !
       IF( lwxios.AND.nn_fsbc > 1 ) THEN
          CALL iom_set_rstw_var_active('nn_fsbc')
Index: /NEMO/trunk/src/OCE/SBC/sbcwave.F90
===================================================================
--- /NEMO/trunk/src/OCE/SBC/sbcwave.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/SBC/sbcwave.F90	(revision 10425)
@@ -215,5 +215,5 @@
       ENDIF
 
-      CALL lbc_lnk_multi( usd, 'U', -1., vsd, 'V', -1. )
+      CALL lbc_lnk_multi( 'sbcwave', usd, 'U', -1., vsd, 'V', -1. )
 
       !
@@ -240,5 +240,5 @@
 #endif
       !
-      CALL lbc_lnk( ze3divh, 'T', 1. )
+      CALL lbc_lnk( 'sbcwave', ze3divh, 'T', 1. )
       !
       IF( ln_linssh ) THEN   ;   ik = 1   ! none zero velocity through the sea surface
@@ -301,5 +301,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( utau(:,:), 'U', -1. , vtau(:,:), 'V', -1. , taum(:,:) , 'T', -1. )
+         CALL lbc_lnk_multi( 'sbcwave', utau(:,:), 'U', -1. , vtau(:,:), 'V', -1. , taum(:,:) , 'T', -1. )
       ENDIF
       !
Index: /NEMO/trunk/src/OCE/STO/stopar.F90
===================================================================
--- /NEMO/trunk/src/OCE/STO/stopar.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/STO/stopar.F90	(revision 10425)
@@ -172,5 +172,5 @@
           ! Apply horizontal Laplacian filter to w
           DO jflt = 1, sto2d_flt(jsto)
-            CALL lbc_lnk( sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
+            CALL lbc_lnk( 'stopar', sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
             CALL sto_par_flt( sto2d(:,:,jsto) )
           END DO
@@ -195,5 +195,5 @@
 
         ! Lateral boundary conditions on sto2d
-        CALL lbc_lnk( sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
+        CALL lbc_lnk( 'stopar', sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
       END DO
       !
@@ -210,5 +210,5 @@
              ! Apply horizontal Laplacian filter to w
              DO jflt = 1, sto3d_flt(jsto)
-               CALL lbc_lnk( sto3d(:,:,jk,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
+               CALL lbc_lnk( 'stopar', sto3d(:,:,jk,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
                CALL sto_par_flt( sto3d(:,:,jk,jsto) )
              END DO
@@ -233,5 +233,5 @@
          END DO
          ! Lateral boundary conditions on sto3d
-         CALL lbc_lnk( sto3d(:,:,:,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
+         CALL lbc_lnk( 'stopar', sto3d(:,:,:,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
       END DO
       !
@@ -642,5 +642,5 @@
          ! Apply horizontal Laplacian filter to w
          DO jflt = 1, sto2d_flt(jsto)
-            CALL lbc_lnk( sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
+            CALL lbc_lnk( 'stopar', sto2d(:,:,jsto), sto2d_typ(jsto), sto2d_sgn(jsto) )
             CALL sto_par_flt( sto2d(:,:,jsto) )
          END DO
@@ -659,5 +659,5 @@
             ! Apply horizontal Laplacian filter to w
             DO jflt = 1, sto3d_flt(jsto)
-               CALL lbc_lnk( sto3d(:,:,jk,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
+               CALL lbc_lnk( 'stopar', sto3d(:,:,jk,jsto), sto3d_typ(jsto), sto3d_sgn(jsto) )
                CALL sto_par_flt( sto3d(:,:,jk,jsto) )
             END DO
@@ -701,5 +701,5 @@
 
          ! Open the restart file
-         CALL iom_open( cn_storst_in, numstor, kiolib = jprstlib )
+         CALL iom_open( cn_storst_in, numstor )
 
          ! Get stochastic parameters from restart file:
@@ -806,5 +806,5 @@
             ENDIF
             ! open the restart file
-            CALL iom_open( clname, numstow, ldwrt = .TRUE., kiolib = jprstlib )
+            CALL iom_open( clname, numstow, ldwrt = .TRUE. )
          ENDIF
          ENDIF
Index: /NEMO/trunk/src/OCE/STO/stopts.F90
===================================================================
--- /NEMO/trunk/src/OCE/STO/stopts.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/STO/stopts.F90	(revision 10425)
@@ -54,5 +54,5 @@
 
       DO jts = 1, jpts
-        CALL lbc_lnk( pts(:,:,:,jts), 'T' , 1._wp )
+        CALL lbc_lnk( 'stopts', pts(:,:,:,jts), 'T' , 1._wp )
       ENDDO
 
@@ -123,5 +123,5 @@
       DO jdof = 1, nn_sto_eos
          DO jts = 1, jpts
-            CALL lbc_lnk( pts_ran(:,:,:,jts,jdof), 'T' , 1._wp )
+            CALL lbc_lnk( 'stopts', pts_ran(:,:,:,jts,jdof), 'T' , 1._wp )
          END DO
       END DO
Index: /NEMO/trunk/src/OCE/TRA/eosbn2.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/eosbn2.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/eosbn2.F90	(revision 10425)
@@ -533,5 +533,5 @@
          END DO
          !
-         CALL lbc_lnk( prd, 'T', 1. )                    ! Lateral boundary conditions
+         CALL lbc_lnk( 'eosbn2', prd, 'T', 1. )                    ! Lateral boundary conditions
          !
       CASE( np_seos )                !==  simplified EOS  ==!
@@ -553,5 +553,5 @@
          END DO
          !
-         CALL lbc_lnk( prd, 'T', 1. )                    ! Lateral boundary conditions
+         CALL lbc_lnk( 'eosbn2', prd, 'T', 1. )                    ! Lateral boundary conditions
          !
       END SELECT
@@ -664,7 +664,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_3d:', ctmp1 )
          !
       END SELECT
@@ -756,5 +755,5 @@
          END DO
          !                            ! Lateral boundary conditions
-         CALL lbc_lnk_multi( pab(:,:,jp_tem), 'T', 1. , pab(:,:,jp_sal), 'T', 1. )                    
+         CALL lbc_lnk_multi( 'eosbn2', pab(:,:,jp_tem), 'T', 1. , pab(:,:,jp_sal), 'T', 1. )                    
          !
       CASE( np_seos )                  !==  simplified EOS  ==!
@@ -776,10 +775,9 @@
          END DO
          !                            ! Lateral boundary conditions
-         CALL lbc_lnk_multi( pab(:,:,jp_tem), 'T', 1. , pab(:,:,jp_sal), 'T', 1. )                    
+         CALL lbc_lnk_multi( 'eosbn2', pab(:,:,jp_tem), 'T', 1. , pab(:,:,jp_sal), 'T', 1. )                    
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_2d:', ctmp1 )
          !
       END SELECT
@@ -879,7 +877,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_0d:', ctmp1 )
          !
       END SELECT
@@ -1040,7 +1037,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_fzp_2d:', ctmp1 )
          !
       END SELECT      
@@ -1087,7 +1083,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_fzp_0d:', ctmp1 )
          !
       END SELECT
@@ -1213,7 +1208,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_pen:', ctmp1 )
          !
       END SELECT
Index: /NEMO/trunk/src/OCE/TRA/traadv_cen.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traadv_cen.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traadv_cen.F90	(revision 10425)
@@ -123,5 +123,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( ztu, 'U', -1. , ztv, 'V', -1. )   ! Lateral boundary cond.
+            CALL lbc_lnk_multi( 'traadv_cen', ztu, 'U', -1. , ztv, 'V', -1. )   ! Lateral boundary cond.
             !
             DO jk = 1, jpkm1                       ! Horizontal advective fluxes
Index: /NEMO/trunk/src/OCE/TRA/traadv_fct.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traadv_fct.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traadv_fct.F90	(revision 10425)
@@ -169,5 +169,4 @@
             END DO
          END DO
-         CALL lbc_lnk( zwi, 'T', 1. )  ! Lateral boundary conditions on zwi  (unchanged sign)
          !                
          IF( l_trd .OR. l_hst )  THEN             ! trend diagnostics (contribution of upstream fluxes)
@@ -208,5 +207,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( zltu, 'T', 1. , zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk_multi( 'traadv_fct', zltu, 'T', 1. , zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
             !
             DO jk = 1, jpkm1                 ! Horizontal advective fluxes
@@ -233,5 +232,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( ztu, 'U', -1. , ztv, 'V', -1. )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk_multi( 'traadv_fct', ztu, 'U', -1. , ztv, 'V', -1. )   ! Lateral boundary cond. (unchanged sgn)
             !
             DO jk = 1, jpkm1                 ! Horizontal advective fluxes
@@ -279,5 +278,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( zwx, 'U', -1. , zwy, 'V', -1.,  zwz, 'W',  1. )
+         CALL lbc_lnk_multi( 'traadv_fct', zwi, 'T', 1., zwx, 'U', -1. , zwy, 'V', -1.,  zwz, 'W',  1. )
          !
          !        !==  monotonicity algorithm  ==!
@@ -399,5 +398,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( zbetup, 'T', 1. , zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
+      CALL lbc_lnk_multi( 'traadv_fct', zbetup, 'T', 1. , zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
 
       ! 3. monotonic flux in the i & j direction (paa & pbb)
@@ -425,5 +424,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( paa, 'U', -1. , pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
+      CALL lbc_lnk_multi( 'traadv_fct', paa, 'U', -1. , pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
       !
    END SUBROUTINE nonosc
Index: /NEMO/trunk/src/OCE/TRA/traadv_mus.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traadv_mus.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traadv_mus.F90	(revision 10425)
@@ -140,5 +140,5 @@
          END DO
          ! lateral boundary conditions   (changed sign)
-         CALL lbc_lnk_multi( zwx, 'U', -1. , zwy, 'V', -1. )
+         CALL lbc_lnk_multi( 'traadv_mus', zwx, 'U', -1. , zwy, 'V', -1. )
          !                                !-- Slopes of tracer
          zslpx(:,:,jpk) = 0._wp                 ! bottom values
@@ -188,5 +188,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zwx, 'U', -1. , zwy, 'V', -1. )   ! lateral boundary conditions   (changed sign)
+         CALL lbc_lnk_multi( 'traadv_mus', zwx, 'U', -1. , zwy, 'V', -1. )   ! lateral boundary conditions   (changed sign)
          !
          DO jk = 1, jpkm1                 !-- Tracer advective trend
Index: /NEMO/trunk/src/OCE/TRA/traadv_qck.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traadv_qck.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traadv_qck.F90	(revision 10425)
@@ -150,5 +150,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zfc(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1. )   ! Lateral boundary conditions 
+         CALL lbc_lnk_multi( 'traadv_qck', zfc(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1. )   ! Lateral boundary conditions 
          
          !
@@ -176,5 +176,5 @@
          END DO 
          !--- Lateral boundary conditions 
-         CALL lbc_lnk_multi( zfu(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1., zfc(:,:,:), 'T', 1.,  zwx(:,:,:), 'T', 1. )
+         CALL lbc_lnk_multi( 'traadv_qck', zfu(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1., zfc(:,:,:), 'T', 1.,  zwx(:,:,:), 'T', 1. )
 
          !--- QUICKEST scheme
@@ -189,5 +189,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zfu(:,:,:), 'T', 1. )      ! Lateral boundary conditions 
+         CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1. )      ! Lateral boundary conditions 
 
          !
@@ -207,5 +207,5 @@
          END DO
          !
-         CALL lbc_lnk( zwx(:,:,:), 'T', 1. ) ! Lateral boundary conditions
+         CALL lbc_lnk( 'traadv_qck', zwx(:,:,:), 'T', 1. ) ! Lateral boundary conditions
          !
          ! Computation of the trend
@@ -265,5 +265,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( zfc(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1. )   ! Lateral boundary conditions 
+         CALL lbc_lnk_multi( 'traadv_qck', zfc(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1. )   ! Lateral boundary conditions 
 
          
@@ -294,5 +294,5 @@
 
          !--- Lateral boundary conditions 
-         CALL lbc_lnk_multi( zfu(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1., zfc(:,:,:), 'T', 1., zwy(:,:,:), 'T', 1. )
+         CALL lbc_lnk_multi( 'traadv_qck', zfu(:,:,:), 'T', 1. , zfd(:,:,:), 'T', 1., zfc(:,:,:), 'T', 1., zwy(:,:,:), 'T', 1. )
 
          !--- QUICKEST scheme
@@ -307,5 +307,5 @@
             END DO
          END DO
-         CALL lbc_lnk( zfu(:,:,:), 'T', 1. )    !--- Lateral boundary conditions 
+         CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1. )    !--- Lateral boundary conditions 
          !
          ! Tracer flux on the x-direction
@@ -324,5 +324,5 @@
          END DO
          !
-         CALL lbc_lnk( zwy(:,:,:), 'T', 1. ) ! Lateral boundary conditions
+         CALL lbc_lnk( 'traadv_qck', zwy(:,:,:), 'T', 1. ) ! Lateral boundary conditions
          !
          ! Computation of the trend
Index: /NEMO/trunk/src/OCE/TRA/traadv_ubs.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traadv_ubs.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traadv_ubs.F90	(revision 10425)
@@ -141,5 +141,5 @@
             !                                    
          END DO         
-         CALL lbc_lnk( zltu, 'T', 1. )   ;    CALL lbc_lnk( zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
+         CALL lbc_lnk( 'traadv_ubs', zltu, 'T', 1. )   ;    CALL lbc_lnk( 'traadv_ubs', zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
          !    
          DO jk = 1, jpkm1        !==  Horizontal advective fluxes  ==!     (UBS)
@@ -226,5 +226,5 @@
                END DO
             END DO
-            CALL lbc_lnk( zti, 'T', 1. )      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
+            CALL lbc_lnk( 'traadv_ubs', zti, 'T', 1. )      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
             !
             !                          !*  anti-diffusive flux : high order minus low order
Index: /NEMO/trunk/src/OCE/TRA/trabbc.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/trabbc.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/trabbc.F90	(revision 10425)
@@ -92,5 +92,5 @@
       END DO
       !
-      CALL lbc_lnk( tsa(:,:,:,jp_tem) , 'T', 1. )
+      CALL lbc_lnk( 'trabbc', tsa(:,:,:,jp_tem) , 'T', 1. )
       !
       IF( l_trdtra ) THEN        ! Send the trend for diagnostics
Index: /NEMO/trunk/src/OCE/TRA/trabbl.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/trabbl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/trabbl.F90	(revision 10425)
@@ -84,5 +84,5 @@
          &      e3u_bbl_0(jpi,jpj) , e3v_bbl_0(jpi,jpj) ,                                    STAT=tra_bbl_alloc )
          !
-      IF( lk_mpp            )   CALL mpp_sum ( tra_bbl_alloc )
+      CALL mpp_sum ( 'trabbl', tra_bbl_alloc )
       IF( tra_bbl_alloc > 0 )   CALL ctl_warn('tra_bbl_alloc: allocation of arrays failed.')
    END FUNCTION tra_bbl_alloc
@@ -123,5 +123,5 @@
             &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
          ! lateral boundary conditions ; just need for outputs
-         CALL lbc_lnk_multi( ahu_bbl, 'U', 1. , ahv_bbl, 'V', 1. )
+         CALL lbc_lnk_multi( 'trabbl', ahu_bbl, 'U', 1. , ahv_bbl, 'V', 1. )
          CALL iom_put( "ahu_bbl", ahu_bbl )   ! bbl diffusive flux i-coef
          CALL iom_put( "ahv_bbl", ahv_bbl )   ! bbl diffusive flux j-coef
@@ -136,5 +136,5 @@
             &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=           ' Sa: ', mask2=tmask, clinfo3='tra' )
          ! lateral boundary conditions ; just need for outputs
-         CALL lbc_lnk_multi( utr_bbl, 'U', 1. , vtr_bbl, 'V', 1. )
+         CALL lbc_lnk_multi( 'trabbl', utr_bbl, 'U', 1. , vtr_bbl, 'V', 1. )
          CALL iom_put( "uoce_bbl", utr_bbl )  ! bbl i-transport
          CALL iom_put( "voce_bbl", vtr_bbl )  ! bbl j-transport
@@ -525,5 +525,5 @@
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk
       zmbku(:,:) = REAL( mbku_d(:,:), wp )   ;     zmbkv(:,:) = REAL( mbkv_d(:,:), wp )  
-      CALL lbc_lnk_multi( zmbku,'U',1., zmbkv,'V',1.) 
+      CALL lbc_lnk_multi( 'trabbl', zmbku,'U',1., zmbkv,'V',1.) 
       mbku_d(:,:) = MAX( INT( zmbku(:,:) ), 1 ) ;  mbkv_d(:,:) = MAX( NINT( zmbkv(:,:) ), 1 )
       !
@@ -548,5 +548,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( e3u_bbl_0, 'U', 1. , e3v_bbl_0, 'V', 1. )      ! lateral boundary conditions
+      CALL lbc_lnk_multi( 'trabbl', e3u_bbl_0, 'U', 1. , e3v_bbl_0, 'V', 1. )      ! lateral boundary conditions
       !
       !                             !* masked diffusive flux coefficients
Index: /NEMO/trunk/src/OCE/TRA/tradmp.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/tradmp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/tradmp.F90	(revision 10425)
@@ -66,5 +66,5 @@
       ALLOCATE( resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
       !
-      IF( lk_mpp            )   CALL mpp_sum ( tra_dmp_alloc )
+      CALL mpp_sum ( 'tradmp', tra_dmp_alloc )
       IF( tra_dmp_alloc > 0 )   CALL ctl_warn('tra_dmp_alloc: allocation of arrays failed')
       !
Index: /NEMO/trunk/src/OCE/TRA/traldf_lap_blp.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traldf_lap_blp.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traldf_lap_blp.F90	(revision 10425)
@@ -213,5 +213,5 @@
       END SELECT
       !
-      CALL lbc_lnk( zlap(:,:,:,:) , 'T', 1. )     ! Lateral boundary conditions (unchanged sign)
+      CALL lbc_lnk( 'traldf_lap_blp', zlap(:,:,:,:) , 'T', 1. )     ! Lateral boundary conditions (unchanged sign)
       !                                               ! Partial top/bottom cell: GRADh( zlap )  
       IF( ln_isfcav .AND. ln_zps ) THEN   ;   CALL zps_hde_isf( kt, kjpt, zlap, zglu, zglv, zgui, zgvi )  ! both top & bottom
Index: /NEMO/trunk/src/OCE/TRA/traldf_triad.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traldf_triad.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traldf_triad.F90	(revision 10425)
@@ -98,5 +98,5 @@
       IF( .NOT.ALLOCATED(zdkt3d) )  THEN
          ALLOCATE( zdkt3d(jpi,jpj,0:1) , STAT=ierr )
-         IF( lk_mpp   )   CALL mpp_sum ( ierr )
+         CALL mpp_sum ( 'traldf_triad', ierr )
          IF( ierr > 0 )   CALL ctl_stop('STOP', 'tra_ldf_triad: unable to allocate arrays')
       ENDIF
Index: /NEMO/trunk/src/OCE/TRA/tramle.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/tramle.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/tramle.F90	(revision 10425)
@@ -321,5 +321,5 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( rfu, 'U', 1. , rfv, 'V', 1. )
+            CALL lbc_lnk_multi( 'tramle', rfu, 'U', 1. , rfv, 'V', 1. )
             !
          ELSEIF( nn_mle == 1 ) THEN           ! MLE array allocation & initialisation
Index: /NEMO/trunk/src/OCE/TRA/tranpc.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/tranpc.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/tranpc.F90	(revision 10425)
@@ -309,5 +309,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( tsa(:,:,:,jp_tem), 'T', 1., tsa(:,:,:,jp_sal), 'T', 1. )
+         CALL lbc_lnk_multi( 'tranpc', tsa(:,:,:,jp_tem), 'T', 1., tsa(:,:,:,jp_sal), 'T', 1. )
          !
          IF( lwp .AND. l_LB_debug ) THEN
Index: /NEMO/trunk/src/OCE/TRA/tranxt.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/tranxt.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/tranxt.F90	(revision 10425)
@@ -107,5 +107,5 @@
 #endif
       !                                              ! local domain boundaries  (T-point, unchanged sign)
-      CALL lbc_lnk_multi( tsa(:,:,:,jp_tem), 'T', 1., tsa(:,:,:,jp_sal), 'T', 1. )
+      CALL lbc_lnk_multi( 'tranxt', tsa(:,:,:,jp_tem), 'T', 1., tsa(:,:,:,jp_sal), 'T', 1. )
       !
       IF( ln_bdy )   CALL bdy_tra( kt )  ! BDY open boundaries
@@ -163,5 +163,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( tsb(:,:,:,jp_tem), 'T', 1., tsb(:,:,:,jp_sal), 'T', 1., &
+         CALL lbc_lnk_multi( 'tranxt', tsb(:,:,:,jp_tem), 'T', 1., tsb(:,:,:,jp_sal), 'T', 1., &
                   &          tsn(:,:,:,jp_tem), 'T', 1., tsn(:,:,:,jp_sal), 'T', 1., &
                   &          tsa(:,:,:,jp_tem), 'T', 1., tsa(:,:,:,jp_sal), 'T', 1.  )
Index: /NEMO/trunk/src/OCE/TRA/traqsr.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/traqsr.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/traqsr.F90	(revision 10425)
@@ -275,5 +275,5 @@
          END DO
       END DO
-      CALL lbc_lnk( fraqsr_1lev(:,:), 'T', 1._wp )
+      CALL lbc_lnk( 'traqsr', fraqsr_1lev(:,:), 'T', 1._wp )
       !
       IF( iom_use('qsr3d') ) THEN      ! output the shortwave Radiation distribution
Index: /NEMO/trunk/src/OCE/TRA/trazdf.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/trazdf.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/trazdf.F90	(revision 10425)
@@ -92,5 +92,5 @@
          END DO
 !!gm this should be moved in trdtra.F90 and done on all trends
-         CALL lbc_lnk_multi( ztrdt, 'T', 1. , ztrds, 'T', 1. )
+         CALL lbc_lnk_multi( 'trazdf', ztrdt, 'T', 1. , ztrds, 'T', 1. )
 !!gm
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
Index: /NEMO/trunk/src/OCE/TRA/zpshde.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRA/zpshde.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRA/zpshde.F90	(revision 10425)
@@ -144,7 +144,7 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( pgtu(:,:,jn), 'U', -1. , pgtv(:,:,jn), 'V', -1. )   ! Lateral boundary cond.
-         !
       END DO
+      !
+      CALL lbc_lnk_multi( 'zpshde', pgtu(:,:,:), 'U', -1. , pgtv(:,:,:), 'V', -1. )   ! Lateral boundary cond.
       !                
       IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
@@ -183,5 +183,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( pgru , 'U', -1. , pgrv , 'V', -1. )   ! Lateral boundary conditions
+         CALL lbc_lnk_multi( 'zpshde', pgru , 'U', -1. , pgrv , 'V', -1. )   ! Lateral boundary conditions
          !
       END IF
@@ -305,7 +305,7 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( pgtu(:,:,jn), 'U', -1. , pgtv(:,:,jn), 'V', -1. )   ! Lateral boundary cond.
-         !
       END DO
+      !
+      CALL lbc_lnk_multi( 'zpshde', pgtu(:,:,:), 'U', -1. , pgtv(:,:,:), 'V', -1. )   ! Lateral boundary cond.
 
       ! horizontal derivative of density anomalies (rd)
@@ -353,5 +353,5 @@
          END DO
 
-         CALL lbc_lnk_multi( pgru , 'U', -1. , pgrv , 'V', -1. )   ! Lateral boundary conditions
+         CALL lbc_lnk_multi( 'zpshde', pgru , 'U', -1. , pgrv , 'V', -1. )   ! Lateral boundary conditions
          !
       END IF
@@ -406,5 +406,5 @@
          !
       END DO
-      CALL lbc_lnk_multi( pgtui(:,:,:), 'U', -1. , pgtvi(:,:,:), 'V', -1. )   ! Lateral boundary cond.
+      CALL lbc_lnk_multi( 'zpshde', pgtui(:,:,:), 'U', -1. , pgtvi(:,:,:), 'V', -1. )   ! Lateral boundary cond.
 
       IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
@@ -449,5 +449,5 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( pgrui, 'U', -1. , pgrvi, 'V', -1. )   ! Lateral boundary conditions
+         CALL lbc_lnk_multi( 'zpshde', pgrui, 'U', -1. , pgrvi, 'V', -1. )   ! Lateral boundary conditions
          !
       END IF  
Index: /NEMO/trunk/src/OCE/TRD/trddyn.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trddyn.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trddyn.F90	(revision 10425)
@@ -129,5 +129,5 @@
                                  END DO
                               END DO
-                              CALL lbc_lnk_multi( z3dx, 'U', -1., z3dy, 'V', -1. )
+                              CALL lbc_lnk_multi( 'trddyn', z3dx, 'U', -1., z3dy, 'V', -1. )
                               CALL iom_put( "utrd_udx", z3dx  )
                               CALL iom_put( "vtrd_vdy", z3dy  )
@@ -165,5 +165,5 @@
 !                                 END DO
 !                              END DO
-!                              CALL lbc_lnk_multi( z3dx, 'U', -1., z3dy, 'V', -1. )
+!                              CALL lbc_lnk_multi( 'trddyn', z3dx, 'U', -1., z3dy, 'V', -1. )
 !                              CALL iom_put( "utrd_bfr", z3dx )
 !                              CALL iom_put( "vtrd_bfr", z3dy )
Index: /NEMO/trunk/src/OCE/TRD/trdglo.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdglo.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdglo.F90	(revision 10425)
@@ -249,8 +249,8 @@
          ! ---------------------------------
          IF( lk_mpp ) THEN
-            CALL mpp_sum( peke )
-            CALL mpp_sum( umo , jptot_dyn )
-            CALL mpp_sum( vmo , jptot_dyn )
-            CALL mpp_sum( hke , jptot_dyn )
+            CALL mpp_sum( 'trdglo', peke )
+            CALL mpp_sum( 'trdglo', umo , jptot_dyn )
+            CALL mpp_sum( 'trdglo', vmo , jptot_dyn )
+            CALL mpp_sum( 'trdglo', hke , jptot_dyn )
          ENDIF
 
@@ -392,8 +392,8 @@
          ! -------------------------------
          IF( lk_mpp ) THEN
-            CALL mpp_sum( tmo, jptot_tra )   
-            CALL mpp_sum( smo, jptot_tra )
-            CALL mpp_sum( t2 , jptot_tra )
-            CALL mpp_sum( s2 , jptot_tra )
+            CALL mpp_sum( 'trdglo', tmo, jptot_tra )   
+            CALL mpp_sum( 'trdglo', smo, jptot_tra )
+            CALL mpp_sum( 'trdglo', t2 , jptot_tra )
+            CALL mpp_sum( 'trdglo', s2 , jptot_tra )
          ENDIF
 
@@ -526,5 +526,5 @@
          tvolt = tvolt + SUM( e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk) * tmask_i(:,:) )
       END DO
-      IF( lk_mpp )   CALL mpp_sum( tvolt )   ! sum over the global domain
+      CALL mpp_sum( 'trdglo', tvolt )   ! sum over the global domain
 
       IF(lwp) WRITE(numout,*) '                total ocean volume at T-point   tvolt = ',tvolt
@@ -546,6 +546,6 @@
          END DO
       END DO
-      IF( lk_mpp )   CALL mpp_sum( tvolu )   ! sums over the global domain
-      IF( lk_mpp )   CALL mpp_sum( tvolv )
+      CALL mpp_sum( 'trdglo', tvolu )   ! sums over the global domain
+      CALL mpp_sum( 'trdglo', tvolv )
 
       IF(lwp) THEN
Index: /NEMO/trunk/src/OCE/TRD/trdken.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdken.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdken.F90	(revision 10425)
@@ -54,6 +54,6 @@
       ALLOCATE( bu(jpi,jpj,jpk) , bv(jpi,jpj,jpk) , r1_bt(jpi,jpj,jpk) , STAT= trd_ken_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( trd_ken_alloc )
-      IF( trd_ken_alloc /= 0 )   CALL ctl_warn('trd_ken_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'trdken', trd_ken_alloc )
+      IF( trd_ken_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trd_ken_alloc: failed to allocate arrays' )
    END FUNCTION trd_ken_alloc
 
@@ -88,5 +88,5 @@
       !!----------------------------------------------------------------------
       !
-      CALL lbc_lnk_multi( putrd, 'U', -1. , pvtrd, 'V', -1. )      ! lateral boundary conditions
+      CALL lbc_lnk_multi( 'trdken', putrd, 'U', -1. , pvtrd, 'V', -1. )      ! lateral boundary conditions
       !
       nkstp = kt
Index: /NEMO/trunk/src/OCE/TRD/trdmxl.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdmxl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdmxl.F90	(revision 10425)
@@ -81,5 +81,5 @@
       ALLOCATE( ndextrd1(jpi*jpj) , STAT=trd_mxl_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( trd_mxl_alloc )
+      CALL mpp_sum ( 'trdmxl', trd_mxl_alloc )
       IF( trd_mxl_alloc /= 0 )   CALL ctl_warn('trd_mxl_alloc: failed to allocate array ndextrd1')
    END FUNCTION trd_mxl_alloc
@@ -152,5 +152,5 @@
 !!gm to be put juste before the output !
 !      ! Lateral boundary conditions
-!      CALL lbc_lnk_multi( tmltrd(:,:,jl), 'T', 1. , smltrd(:,:,jl), 'T', 1. )
+!      CALL lbc_lnk_multi( 'trdmxl', tmltrd(:,:,jl), 'T', 1. , smltrd(:,:,jl), 'T', 1. )
 !!gm end
 
@@ -470,5 +470,5 @@
          !-- Lateral boundary conditions
          !         ... temperature ...                    ... salinity ...
-         CALL lbc_lnk_multi( ztmltot , 'T', 1., zsmltot , 'T', 1., &
+         CALL lbc_lnk_multi( 'trdmxl', ztmltot , 'T', 1., zsmltot , 'T', 1., &
                   &          ztmlres , 'T', 1., zsmlres , 'T', 1., &
                   &          ztmlatf , 'T', 1., zsmlatf , 'T', 1. )
@@ -521,8 +521,8 @@
          !-- Lateral boundary conditions
          !         ... temperature ...                    ... salinity ...
-         CALL lbc_lnk_multi( ztmltot2, 'T', 1., zsmltot2, 'T', 1., &
+         CALL lbc_lnk_multi( 'trdmxl', ztmltot2, 'T', 1., zsmltot2, 'T', 1., &
                   &          ztmlres2, 'T', 1., zsmlres2, 'T', 1. )
          !
-         CALL lbc_lnk_multi( ztmltrd2(:,:,:), 'T', 1., zsmltrd2(:,:,:), 'T', 1. ) ! /  in the NetCDF trends file
+         CALL lbc_lnk_multi( 'trdmxl', ztmltrd2(:,:,:), 'T', 1., zsmltrd2(:,:,:), 'T', 1. ) ! /  in the NetCDF trends file
          
          ! III.3 Time evolution array swap
Index: /NEMO/trunk/src/OCE/TRD/trdmxl_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdmxl_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdmxl_oce.F90	(revision 10425)
@@ -127,6 +127,6 @@
       !
       trdmxl_oce_alloc = MAXVAL( ierr )
-      IF( lk_mpp                )   CALL mpp_sum ( trdmxl_oce_alloc )
-      IF( trdmxl_oce_alloc /= 0 )   CALL ctl_warn('trdmxl_oce_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'trdmxl_oce', trdmxl_oce_alloc )
+      IF( trdmxl_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trdmxl_oce_alloc: failed to allocate arrays' )
       !
    END FUNCTION trdmxl_oce_alloc
Index: /NEMO/trunk/src/OCE/TRD/trdmxl_rst.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdmxl_rst.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdmxl_rst.F90	(revision 10425)
@@ -61,7 +61,5 @@
          IF(lwp) THEN
             WRITE(numout,*)
-            SELECT CASE ( jprstlib )
-            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart_mxl NetCDF file: '//clname
-            END SELECT
+            WRITE(numout,*) '             open ocean restart_mxl NetCDF file: '//clname
             IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp
             ELSE                          ;   WRITE(numout,*) '             kt = '             , kt,' date= ', ndastp
@@ -69,5 +67,5 @@
          ENDIF
 
-         CALL iom_open( TRIM(clpath)//TRIM(clname), nummxlw, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clpath)//TRIM(clname), nummxlw, ldwrt = .TRUE. )
       ENDIF
 
@@ -133,5 +131,4 @@
       CHARACTER (len=35) :: charout
       INTEGER ::   jk         ! loop indice
-      INTEGER ::   jlibalt = jprstlib
       LOGICAL ::   llok
       CHARACTER(LEN=256)  ::   clpath   ! full path to restart file
@@ -146,5 +143,5 @@
       clpath = TRIM(cn_ocerst_indir)
       IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-      CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_in), inum, kiolib = jlibalt ) 
+      CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_in), inum ) 
 
       IF( ln_trdmxl_instant ) THEN 
Index: /NEMO/trunk/src/OCE/TRD/trdpen.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdpen.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdpen.F90	(revision 10425)
@@ -50,6 +50,6 @@
       ALLOCATE( rab_pe(jpi,jpj,jpk,jpts) , STAT= trd_pen_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( trd_pen_alloc )
-      IF( trd_pen_alloc /= 0 )   CALL ctl_warn( 'trd_pen_alloc: failed to allocate arrays' )
+      CALL mpp_sum ( 'trdpen', trd_pen_alloc )
+      IF( trd_pen_alloc /= 0 )   CALL ctl_stop( 'STOP',  'trd_pen_alloc: failed to allocate arrays'  )
    END FUNCTION trd_pen_alloc
 
Index: /NEMO/trunk/src/OCE/TRD/trdtra.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdtra.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdtra.F90	(revision 10425)
@@ -55,6 +55,6 @@
       ALLOCATE( trdtx(jpi,jpj,jpk) , trdty(jpi,jpj,jpk) , trdt(jpi,jpj,jpk) , avt_evd(jpi,jpj,jpk), STAT= trd_tra_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( trd_tra_alloc )
-      IF( trd_tra_alloc /= 0 )   CALL ctl_warn('trd_tra_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'trdtra', trd_tra_alloc )
+      IF( trd_tra_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trd_tra_alloc: failed to allocate arrays' )
    END FUNCTION trd_tra_alloc
 
Index: /NEMO/trunk/src/OCE/TRD/trdvor.F90
===================================================================
--- /NEMO/trunk/src/OCE/TRD/trdvor.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/TRD/trdvor.F90	(revision 10425)
@@ -73,6 +73,6 @@
          &      ndexvor1  (jpi*jpj)                                ,   STAT= trd_vor_alloc )
          !
-      IF( lk_mpp             )   CALL mpp_sum ( trd_vor_alloc )
-      IF( trd_vor_alloc /= 0 )   CALL ctl_warn('trd_vor_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'trdvor', trd_vor_alloc )
+      IF( trd_vor_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trd_vor_alloc: failed to allocate arrays' )
    END FUNCTION trd_vor_alloc
 
@@ -161,5 +161,5 @@
 
       zudpvor(:,:) = 0._wp                 ;   zvdpvor(:,:) = 0._wp                    ! Initialisation
-      CALL lbc_lnk_multi( putrdvor, 'U', -1. , pvtrdvor, 'V', -1. )      ! lateral boundary condition
+      CALL lbc_lnk_multi( 'trdvor', putrdvor, 'U', -1. , pvtrdvor, 'V', -1. )      ! lateral boundary condition
       
 
@@ -250,5 +250,5 @@
       zvdpvor(:,:) = 0._wp
       !                            ! lateral boundary condition on input momentum trends
-      CALL lbc_lnk_multi( putrdvor, 'U', -1. , pvtrdvor, 'V', -1. )
+      CALL lbc_lnk_multi( 'trdvor', putrdvor, 'U', -1. , pvtrdvor, 'V', -1. )
 
       !  =====================================
@@ -395,5 +395,5 @@
 
          ! Boundary conditions
-         CALL lbc_lnk_multi( vor_avrtot, 'F', 1. , vor_avrres, 'F', 1. )
+         CALL lbc_lnk_multi( 'trdvor', vor_avrtot, 'F', 1. , vor_avrres, 'F', 1. )
 
 
Index: /NEMO/trunk/src/OCE/USR/usrdef_fmask.F90
===================================================================
--- /NEMO/trunk/src/OCE/USR/usrdef_fmask.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/USR/usrdef_fmask.F90	(revision 10425)
@@ -143,5 +143,5 @@
       ENDIF
       !
-      CALL lbc_lnk( pfmsk, 'F', 1._wp )      ! Lateral boundary conditions on fmask
+      CALL lbc_lnk( 'usrdef_fmask', pfmsk, 'F', 1._wp )      ! Lateral boundary conditions on fmask
       !
    END SUBROUTINE usr_def_fmask
Index: /NEMO/trunk/src/OCE/USR/usrdef_sbc.F90
===================================================================
--- /NEMO/trunk/src/OCE/USR/usrdef_sbc.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/USR/usrdef_sbc.F90	(revision 10425)
@@ -132,6 +132,6 @@
       END DO
 
-      zsumemp = GLOB_SUM( emp  (:,:)   ) 
-      zsurf   = GLOB_SUM( tmask(:,:,1) ) 
+      zsumemp = GLOB_SUM( 'usrdef_sbc', emp  (:,:)   ) 
+      zsurf   = GLOB_SUM( 'usrdef_sbc', tmask(:,:,1) ) 
       zsumemp = zsumemp / zsurf         ! Default GYRE configuration
 
@@ -186,5 +186,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( taum(:,:), 'T', 1. , wndm(:,:), 'T', 1. )
+      CALL lbc_lnk_multi( 'usrdef_sbc', taum(:,:), 'T', 1. , wndm(:,:), 'T', 1. )
 
       ! ---------------------------------- !
Index: /NEMO/trunk/src/OCE/USR/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/src/OCE/USR/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/USR/usrdef_zgr.F90	(revision 10425)
@@ -202,5 +202,5 @@
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
       !
-      CALL lbc_lnk( z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
       !
       k_bot(:,:) = NINT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
Index: /NEMO/trunk/src/OCE/ZDF/zdf_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdf_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdf_oce.F90	(revision 10425)
@@ -69,5 +69,5 @@
          &      avmb(jpk)         , avtb(jpk)          , avtb_2d(jpi,jpj) , STAT = zdf_oce_alloc )
          !
-      IF( zdf_oce_alloc /= 0 )   CALL ctl_warn('zdf_oce_alloc: failed to allocate arrays')
+      IF( zdf_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'zdf_oce_alloc: failed to allocate arrays' )
       !
    END FUNCTION zdf_oce_alloc
Index: /NEMO/trunk/src/OCE/ZDF/zdfgls.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdfgls.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdfgls.F90	(revision 10425)
@@ -119,6 +119,6 @@
          &      zwall (jpi,jpj,jpk) , ustar2_top (jpi,jpj) , ustar2_bot(jpi,jpj) , STAT= zdf_gls_alloc )
          !
-      IF( lk_mpp             )   CALL mpp_sum ( zdf_gls_alloc )
-      IF( zdf_gls_alloc /= 0 )   CALL ctl_warn('zdf_gls_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'zdfgls', zdf_gls_alloc )
+      IF( zdf_gls_alloc /= 0 )   CALL ctl_stop( 'STOP', 'zdf_gls_alloc: failed to allocate arrays' )
    END FUNCTION zdf_gls_alloc
 
Index: /NEMO/trunk/src/OCE/ZDF/zdfiwm.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdfiwm.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdfiwm.F90	(revision 10425)
@@ -64,6 +64,6 @@
       &         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')
+      CALL mpp_sum ( 'zdfiwm', zdf_iwm_alloc )
+      IF( zdf_iwm_alloc /= 0 )   CALL ctl_stop( 'STOP', 'zdf_iwm_alloc: failed to allocate arrays' )
    END FUNCTION zdf_iwm_alloc
 
@@ -122,5 +122,5 @@
       !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zztmp        ! scalar workspace
+      REAL(wp) ::   zztmp, ztmp1, ztmp2        ! scalar workspace
       REAL(wp), DIMENSION(jpi,jpj)     ::   zfact       ! Used for vertical structure
       REAL(wp), DIMENSION(jpi,jpj)     ::   zhdep       ! Ocean depth
@@ -157,8 +157,15 @@
 !!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) )
-
+         DO jj = 1, jpj             
+            DO ji = 1, jpi
+               IF ( zfact(ji,jj) == 0._wp .OR. wmask(ji,jj,jk) == 0._wp ) THEN   ! optimization
+                  zemx_iwm(ji,jj,jk) = 0._wp
+               ELSE
+                  zemx_iwm(ji,jj,jk) = zfact(ji,jj) * (  EXP( ( gde3w_n(ji,jj,jk  ) - zhdep(ji,jj) ) / hcri_iwm(ji,jj) )     &
+                       &                               - EXP( ( gde3w_n(ji,jj,jk-1) - zhdep(ji,jj) ) / hcri_iwm(ji,jj) ) )   &
+                       &                            / ( gde3w_n(ji,jj,jk) - gde3w_n(ji,jj,jk-1) )
+               ENDIF
+            END DO
+         END DO
 !!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
@@ -234,8 +241,15 @@
       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(:,:) )  )
+      DO jk = 2, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( rn2(ji,jj,jk) <= 0._wp .OR. wmask(ji,jj,jk) == 0._wp ) THEN   ! optimization
+                  zweight(ji,jj,jk) = 0._wp
+               ELSE
+                  zweight(ji,jj,jk) = rn2(ji,jj,jk) * hbot_iwm(ji,jj)    &
+                     &   * (  EXP( -zwkb(ji,jj,jk) / hbot_iwm(ji,jj) ) - EXP( -zwkb(ji,jj,jk-1) / hbot_iwm(ji,jj) )  )
+               ENDIF
+            END DO
+         END DO
       END DO
       !
@@ -305,5 +319,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( zztmp )
+         CALL mpp_sum( 'zdfiwm', zztmp )
          zztmp = rau0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 
          !
@@ -322,10 +336,14 @@
       !      
       IF( ln_tsdiff ) THEN          !* Option for differential mixing of salinity and temperature
+         ztmp1 = 0.505_wp + 0.495_wp * TANH( 0.92_wp * ( LOG10( 1.e-20_wp ) - 0.60_wp ) )
          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)
+                  ztmp2 = zReb(ji,jj,jk) * 5._wp * r1_6
+                  IF ( ztmp2 > 1.e-20_wp .AND. wmask(ji,jj,jk) == 1._wp ) THEN
+                     zav_ratio(ji,jj,jk) = 0.505_wp + 0.495_wp * TANH( 0.92_wp * ( LOG10(ztmp2) - 0.60_wp ) )
+                  ELSE
+                     zav_ratio(ji,jj,jk) = ztmp1 * wmask(ji,jj,jk)
+                  ENDIF
                END DO
             END DO
@@ -463,7 +481,7 @@
       ecri_iwm(:,:) = ecri_iwm(:,:) * ssmask(:,:)
 
-      zbot = glob_sum( e1e2t(:,:) * ebot_iwm(:,:) )
-      zpyc = glob_sum( e1e2t(:,:) * epyc_iwm(:,:) )
-      zcri = glob_sum( e1e2t(:,:) * ecri_iwm(:,:) )
+      zbot = glob_sum( 'zdfiwm', e1e2t(:,:) * ebot_iwm(:,:) )
+      zpyc = glob_sum( 'zdfiwm', e1e2t(:,:) * epyc_iwm(:,:) )
+      zcri = glob_sum( 'zdfiwm', e1e2t(:,:) * ecri_iwm(:,:) )
       IF(lwp) THEN
          WRITE(numout,*) '      High-mode wave-breaking energy:             ', zbot * 1.e-12_wp, 'TW'
Index: /NEMO/trunk/src/OCE/ZDF/zdfmxl.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdfmxl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdfmxl.F90	(revision 10425)
@@ -50,6 +50,6 @@
          ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), STAT= zdf_mxl_alloc )
          !
-         IF( lk_mpp             )   CALL mpp_sum ( zdf_mxl_alloc )
-         IF( zdf_mxl_alloc /= 0 )   CALL ctl_warn('zdf_mxl_alloc: failed to allocate arrays.')
+         CALL mpp_sum ( 'zdfmxl', zdf_mxl_alloc )
+         IF( zdf_mxl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl_alloc: failed to allocate arrays.' )
          !
       ENDIF
Index: /NEMO/trunk/src/OCE/ZDF/zdfosm.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdfosm.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdfosm.F90	(revision 10425)
@@ -118,5 +118,5 @@
           &   etmean(jpi,jpj,jpk),  STAT= zdf_osm_alloc )
      IF( zdf_osm_alloc /= 0 )   CALL ctl_warn('zdf_osm_alloc: failed to allocate zdf_osm arrays')
-     IF( lk_mpp             )   CALL mpp_sum ( zdf_osm_alloc )
+     CALL mpp_sum ( 'zdfosm', zdf_osm_alloc )
    END FUNCTION zdf_osm_alloc
 
@@ -1287,5 +1287,5 @@
 
        ! Lateral boundary conditions on zvicos (sign unchanged), needed to caclulate viscosities on u and v grids
-       CALL lbc_lnk( zviscos(:,:,:), 'W', 1. )
+       CALL lbc_lnk( 'zdfosm', zviscos(:,:,:), 'W', 1. )
 
        ! GN 25/8: need to change tmask --> wmask
@@ -1300,5 +1300,5 @@
      END DO
       ! Lateral boundary conditions on ghamu and ghamv, currently on W-grid  (sign unchanged), needed to caclulate gham[uv] on u and v grids
-     CALL lbc_lnk_multi( p_avt, 'W', 1. , p_avm, 'W', 1.,   &
+     CALL lbc_lnk_multi( 'zdfosm', p_avt, 'W', 1. , p_avm, 'W', 1.,   &
       &                  ghamu, 'W', 1. , ghamv, 'W', 1. )
        DO jk = 2, jpkm1
@@ -1318,5 +1318,5 @@
         ! Lateral boundary conditions on final outputs for gham[ts],  on W-grid  (sign unchanged)
         ! Lateral boundary conditions on final outputs for gham[uv],  on [UV]-grid  (sign unchanged)
-        CALL lbc_lnk_multi( ghamt, 'W', 1. , ghams, 'W', 1.,   &
+        CALL lbc_lnk_multi( 'zdfosm', ghamt, 'W', 1. , ghams, 'W', 1.,   &
          &                  ghamu, 'U', 1. , ghamv, 'V', 1. )
 
@@ -1359,5 +1359,5 @@
       END IF
       ! Lateral boundary conditions on p_avt  (sign unchanged)
-      CALL lbc_lnk( p_avt(:,:,:), 'W', 1. )
+      CALL lbc_lnk( 'zdfosm', p_avt(:,:,:), 'W', 1. )
       !
    END SUBROUTINE zdf_osm
Index: /NEMO/trunk/src/OCE/ZDF/zdfphy.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdfphy.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdfphy.F90	(revision 10425)
@@ -300,13 +300,13 @@
       !                                         !* Lateral boundary conditions (sign unchanged)
       IF( l_zdfsh2 ) THEN
-         CALL lbc_lnk_multi( avm_k, 'W', 1. , avt_k, 'W', 1.,   &
+         CALL lbc_lnk_multi( 'zdfphy', avm_k, 'W', 1. , avt_k, 'W', 1.,   &
             &                avm  , 'W', 1. , avt  , 'W', 1. , avs , 'W', 1. )
       ELSE
-         CALL lbc_lnk_multi( avm  , 'W', 1. , avt  , 'W', 1. , avs , 'W', 1. )
+         CALL lbc_lnk_multi( 'zdfphy', avm  , 'W', 1. , avt  , 'W', 1. , avs , 'W', 1. )
       ENDIF
       !
       IF( l_zdfdrg ) THEN     ! drag  have been updated (non-linear cases)
-         IF( ln_isfcav ) THEN   ;  CALL lbc_lnk_multi( rCdU_top, 'T', 1. , rCdU_bot, 'T', 1. )   ! top & bot drag
-         ELSE                   ;  CALL lbc_lnk      ( rCdU_bot, 'T', 1. )                       ! bottom drag only
+         IF( ln_isfcav ) THEN   ;  CALL lbc_lnk_multi( 'zdfphy', rCdU_top, 'T', 1. , rCdU_bot, 'T', 1. )   ! top & bot drag
+         ELSE                   ;  CALL lbc_lnk      ( 'zdfphy', rCdU_bot, 'T', 1. )                       ! bottom drag only
          ENDIF
       ENDIF
@@ -331,5 +331,5 @@
      ALLOCATE(     wi(jpi,jpj,jpk), Cu_adv(jpi,jpj,jpk),  STAT= zdf_phy_alloc )
      IF( zdf_phy_alloc /= 0 )   CALL ctl_warn('zdf_phy_alloc: failed to allocate ln_zad_Aimp=T required arrays')
-     IF( lk_mpp             )   CALL mpp_sum ( zdf_phy_alloc )
+     CALL mpp_sum ( 'zdfphy', zdf_phy_alloc )
    END FUNCTION zdf_phy_alloc
 
Index: /NEMO/trunk/src/OCE/ZDF/zdftke.F90
===================================================================
--- /NEMO/trunk/src/OCE/ZDF/zdftke.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/ZDF/zdftke.F90	(revision 10425)
@@ -103,6 +103,6 @@
       ALLOCATE( htau(jpi,jpj) , dissl(jpi,jpj,jpk) , apdlr(jpi,jpj,jpk) ,   STAT= zdf_tke_alloc )
       !
-      IF( lk_mpp             )   CALL mpp_sum ( zdf_tke_alloc )
-      IF( zdf_tke_alloc /= 0 )   CALL ctl_warn('zdf_tke_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'zdftke', zdf_tke_alloc )
+      IF( zdf_tke_alloc /= 0 )   CALL ctl_stop( 'STOP', 'zdf_tke_alloc: failed to allocate arrays' )
       !
    END FUNCTION zdf_tke_alloc
@@ -202,5 +202,5 @@
       REAL(wp) ::   zzd_up, zzd_lw             !   -         -
       INTEGER , DIMENSION(jpi,jpj)     ::   imlc
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zhlc
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zhlc, zfr_i
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zpelc, zdiag, zd_up, zd_lw
       !!--------------------------------------------------------------------
@@ -290,14 +290,23 @@
          END DO
          zcof = 0.016 / SQRT( zrhoa * zcdrag )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zus  = zcof * SQRT( taum(ji,jj) )           ! Stokes drift
+               zfr_i(ji,jj) = ( 1._wp - 4._wp * fr_i(ji,jj) ) * zus * zus * zus * tmask(ji,jj,1) ! zus > 0. ok
+               IF (zfr_i(ji,jj) < 0. ) zfr_i(ji,jj) = 0.
+            END DO
+         END DO         
          DO jk = 2, jpkm1         !* TKE Langmuir circulation source term added to en
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zus  = zcof * SQRT( taum(ji,jj) )           ! Stokes drift
-                  !                                           ! vertical velocity due to LC
-                  zind = 0.5 - SIGN( 0.5, pdepw(ji,jj,jk) - zhlc(ji,jj) )
-                  zwlc = zind * rn_lc * zus * SIN( rpi * pdepw(ji,jj,jk) / zhlc(ji,jj) )
-                  !                                           ! TKE Langmuir circulation source term
-                  en(ji,jj,jk) = en(ji,jj,jk) + rdt * MAX(0.,1._wp - 4.*fr_i(ji,jj) ) * ( zwlc * zwlc * zwlc )   &
-                     &                              / zhlc(ji,jj) * wmask(ji,jj,jk) * tmask(ji,jj,1)
+                  IF ( zfr_i(ji,jj) /= 0. ) THEN               
+                     ! vertical velocity due to LC   
+                     IF ( pdepw(ji,jj,jk) - zhlc(ji,jj) < 0 .AND. wmask(ji,jj,jk) /= 0. ) THEN
+                        !                                           ! vertical velocity due to LC
+                        zwlc = rn_lc * SIN( rpi * pdepw(ji,jj,jk) / zhlc(ji,jj) )   ! warning: optimization: zus^3 is in zfr_i
+                        !                                           ! TKE Langmuir circulation source term
+                        en(ji,jj,jk) = en(ji,jj,jk) + rdt * zfr_i(ji,jj) * ( zwlc * zwlc * zwlc ) / zhlc(ji,jj)
+                     ENDIF
+                  ENDIF
                END DO
             END DO
Index: /NEMO/trunk/src/OCE/lib_fortran.F90
===================================================================
--- /NEMO/trunk/src/OCE/lib_fortran.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/lib_fortran.F90	(revision 10425)
@@ -21,4 +21,5 @@
    USE in_out_manager  ! I/O manager
    USE lib_mpp         ! distributed memory computing
+   USE lbclnk          ! ocean lateral boundary conditions
 
    IMPLICIT NONE
@@ -27,4 +28,6 @@
    PUBLIC   glob_sum      ! used in many places (masked with tmask_i)
    PUBLIC   glob_sum_full ! used in many places (masked with tmask_h, ie only over the halos)
+   PUBLIC   local_sum     ! used in trcrad, local operation before glob_sum_delay
+   PUBLIC   sum3x3        ! used in trcrad, do a sum over 3x3 boxes
    PUBLIC   DDPDD         ! also used in closea module
    PUBLIC   glob_min, glob_max
@@ -34,15 +37,20 @@
 
    INTERFACE glob_sum
-      MODULE PROCEDURE glob_sum_1d, glob_sum_2d, glob_sum_3d, &
-         &             glob_sum_2d_a, glob_sum_3d_a
+      MODULE PROCEDURE glob_sum_1d, glob_sum_2d, glob_sum_3d
    END INTERFACE
    INTERFACE glob_sum_full
       MODULE PROCEDURE glob_sum_full_2d, glob_sum_full_3d
    END INTERFACE
+   INTERFACE local_sum
+      MODULE PROCEDURE local_sum_2d, local_sum_3d
+   END INTERFACE
+   INTERFACE sum3x3
+      MODULE PROCEDURE sum3x3_2d, sum3x3_3d
+   END INTERFACE
    INTERFACE glob_min
-      MODULE PROCEDURE glob_min_2d, glob_min_3d,glob_min_2d_a, glob_min_3d_a 
+      MODULE PROCEDURE glob_min_2d, glob_min_3d
    END INTERFACE
    INTERFACE glob_max
-      MODULE PROCEDURE glob_max_2d, glob_max_3d,glob_max_2d_a, glob_max_3d_a 
+      MODULE PROCEDURE glob_max_2d, glob_max_3d
    END INTERFACE
 
@@ -62,378 +70,230 @@
 CONTAINS
 
-   ! --- SUM ---
-   FUNCTION glob_sum_1d( ptab, kdim )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_1d ***
-      !!
-      !! ** Purpose : perform a sum in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      INTEGER , INTENT(in) :: kdim
-      REAL(wp), INTENT(in), DIMENSION(kdim) ::   ptab
-      REAL(wp)                              ::   glob_sum_1d   ! global sum
-      !!
+#  define GLOBSUM_CODE
+
+#     define DIM_1d
+#     define FUNCTION_GLOBSUM           glob_sum_1d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBSUM
+#     undef DIM_1d
+
+#     define DIM_2d
+#     define OPERATION_GLOBSUM
+#     define FUNCTION_GLOBSUM           glob_sum_2d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBSUM
+#     undef OPERATION_GLOBSUM
+#     define OPERATION_FULL_GLOBSUM
+#     define FUNCTION_GLOBSUM           glob_sum_full_2d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBSUM
+#     undef OPERATION_FULL_GLOBSUM
+#     undef DIM_2d
+
+#     define DIM_3d
+#     define OPERATION_GLOBSUM
+#     define FUNCTION_GLOBSUM           glob_sum_3d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBSUM
+#     undef OPERATION_GLOBSUM
+#     define OPERATION_FULL_GLOBSUM
+#     define FUNCTION_GLOBSUM           glob_sum_full_3d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBSUM
+#     undef OPERATION_FULL_GLOBSUM
+#     undef DIM_3d
+
+#  undef GLOBSUM_CODE
+
+
+#  define GLOBMINMAX_CODE
+
+#     define DIM_2d
+#     define OPERATION_GLOBMIN
+#     define FUNCTION_GLOBMINMAX           glob_min_2d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBMINMAX
+#     undef OPERATION_GLOBMIN
+#     define OPERATION_GLOBMAX
+#     define FUNCTION_GLOBMINMAX           glob_max_2d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBMINMAX
+#     undef OPERATION_GLOBMAX
+#     undef DIM_2d
+
+#     define DIM_3d
+#     define OPERATION_GLOBMIN
+#     define FUNCTION_GLOBMINMAX           glob_min_3d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBMINMAX
+#     undef OPERATION_GLOBMIN
+#     define OPERATION_GLOBMAX
+#     define FUNCTION_GLOBMINMAX           glob_max_3d
+#     include "lib_fortran_generic.h90"
+#     undef FUNCTION_GLOBMINMAX
+#     undef OPERATION_GLOBMAX
+#     undef DIM_3d
+#  undef GLOBMINMAX_CODE
+
+!                          ! FUNCTION local_sum !
+
+   FUNCTION local_sum_2d( ptab )
+      !!----------------------------------------------------------------------
+      REAL(wp),  INTENT(in   ) ::   ptab(:,:) ! array on which operation is applied
+      COMPLEX(wp)              ::  local_sum_2d
+      !
+      !!-----------------------------------------------------------------------
+      !
       COMPLEX(wp)::   ctmp
       REAL(wp)   ::   ztmp
-      INTEGER    ::   ji   ! dummy loop indices
-      !!-----------------------------------------------------------------------
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO ji = 1, kdim
-         ztmp =  ptab(ji)
-         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-         END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_1d = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_1d
-
-   FUNCTION glob_sum_2d( ptab )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_2d ***
-      !!
-      !! ** Purpose : perform a sum in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab
-      REAL(wp)                             ::   glob_sum_2d   ! global masked sum
-      !!
-      COMPLEX(wp)::   ctmp
-      REAL(wp)   ::   ztmp
-      INTEGER    ::   ji, jj   ! dummy loop indices
-      !!-----------------------------------------------------------------------
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jj = 1, jpj
-         DO ji =1, jpi
-         ztmp =  ptab(ji,jj) * tmask_i(ji,jj)
-         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+      INTEGER    ::   ji, jj    ! dummy loop indices
+      INTEGER    ::   ipi, ipj  ! dimensions
+      !!-----------------------------------------------------------------------
+      !
+      ipi = SIZE(ptab,1)   ! 1st dimension
+      ipj = SIZE(ptab,2)   ! 2nd dimension
+      !
+      ctmp = CMPLX( 0.e0, 0.e0, wp )   ! warning ctmp is cumulated
+
+      DO jj = 1, ipj
+         DO ji = 1, ipi
+            ztmp =  ptab(ji,jj) * tmask_i(ji,jj)
+            CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
          END DO
       END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_2d = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_2d
-
-
-   FUNCTION glob_sum_3d( ptab )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_3d ***
-      !!
-      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab
-      REAL(wp)                               ::   glob_sum_3d   ! global masked sum
-      !!
+      !
+      local_sum_2d = ctmp
+       
+   END FUNCTION local_sum_2d
+
+   FUNCTION local_sum_3d( ptab )
+      !!----------------------------------------------------------------------
+      REAL(wp),  INTENT(in   ) ::   ptab(:,:,:) ! array on which operation is applied
+      COMPLEX(wp)              ::  local_sum_3d
+      !
+      !!-----------------------------------------------------------------------
+      !
       COMPLEX(wp)::   ctmp
       REAL(wp)   ::   ztmp
       INTEGER    ::   ji, jj, jk   ! dummy loop indices
-      INTEGER    ::   ijpk ! local variables: size of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab,3)
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jk = 1, ijpk
+      INTEGER    ::   ipi, ipj, ipk    ! dimensions
+      !!-----------------------------------------------------------------------
+      !
+      ipi = SIZE(ptab,1)   ! 1st dimension
+      ipj = SIZE(ptab,2)   ! 2nd dimension
+      ipk = SIZE(ptab,3)   ! 3rd dimension
+      !
+      ctmp = CMPLX( 0.e0, 0.e0, wp )   ! warning ctmp is cumulated
+
+      DO jk = 1, ipk
+        DO jj = 1, ipj
+          DO ji = 1, ipi
+             ztmp =  ptab(ji,jj,jk) * tmask_i(ji,jj)
+             CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+          END DO
+        END DO
+      END DO
+      !
+      local_sum_3d = ctmp
+       
+   END FUNCTION local_sum_3d
+
+!                          ! FUNCTION sum3x3 !
+
+   SUBROUTINE sum3x3_2d( p2d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  routine sum3x3_2d  ***
+      !!
+      !! ** Purpose : sum over 3x3 boxes
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION (:,:), INTENT(inout) ::   p2d
+      !
+      INTEGER ::   ji, ji2, jj, jj2     ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      IF( SIZE(p2d,1) /= jpi ) CALL ctl_stop( 'STOP', 'wrong call of sum3x3_2d, the first dimension is not equal to jpi' ) 
+      IF( SIZE(p2d,2) /= jpj ) CALL ctl_stop( 'STOP', 'wrong call of sum3x3_2d, the second dimension is not equal to jpj' ) 
+      !
+      DO jj = 1, jpj
+         DO ji = 1, jpi 
+            IF( MOD(mig(ji), 3) == 1 .AND. MOD(mjg(jj), 3) == 1 ) THEN   ! bottom left corber of a 3x3 box
+               ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
+               jj2 = MIN(mjg(jj)+2, jpjglo) - njmpp + 1                  ! upper position of the box
+               IF( ji2 <= jpi .AND. jj2 <= jpj ) THEN                    ! the box is fully included in the local mpi domain
+                  p2d(ji:ji2,jj:jj2) = SUM(p2d(ji:ji2,jj:jj2))
+               ENDIF
+            ENDIF
+         END DO
+      END DO
+      CALL lbc_lnk( 'lib_fortran', p2d, 'T', 1. )
+      IF( nbondi /= -1 ) THEN
+         IF( MOD(mig(    1), 3) == 1 )   p2d(    1,:) = p2d(    2,:)
+         IF( MOD(mig(    1), 3) == 2 )   p2d(    2,:) = p2d(    1,:)
+      ENDIF
+      IF( nbondi /=  1 ) THEN
+         IF( MOD(mig(jpi-2), 3) == 1 )   p2d(  jpi,:) = p2d(jpi-1,:)
+         IF( MOD(mig(jpi-2), 3) == 0 )   p2d(jpi-1,:) = p2d(  jpi,:)
+      ENDIF
+      IF( nbondj /= -1 ) THEN
+         IF( MOD(mjg(    1), 3) == 1 )   p2d(:,    1) = p2d(:,    2)
+         IF( MOD(mjg(    1), 3) == 2 )   p2d(:,    2) = p2d(:,    1)
+      ENDIF
+      IF( nbondj /=  1 ) THEN
+         IF( MOD(mjg(jpj-2), 3) == 1 )   p2d(:,  jpj) = p2d(:,jpj-1)
+         IF( MOD(mjg(jpj-2), 3) == 0 )   p2d(:,jpj-1) = p2d(:,  jpj)
+      ENDIF
+      CALL lbc_lnk( 'lib_fortran', p2d, 'T', 1. )
+
+   END SUBROUTINE sum3x3_2d
+
+   SUBROUTINE sum3x3_3d( p3d )
+      !!-----------------------------------------------------------------------
+      !!                  ***  routine sum3x3_3d  ***
+      !!
+      !! ** Purpose : sum over 3x3 boxes
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION (:,:,:), INTENT(inout) ::   p3d
+      !
+      INTEGER ::   ji, ji2, jj, jj2, jn     ! dummy loop indices
+      INTEGER ::   ipn                      ! Third dimension size
+      !!----------------------------------------------------------------------
+      !
+      IF( SIZE(p3d,1) /= jpi ) CALL ctl_stop( 'STOP', 'wrong call of sum3x3_3d, the first dimension is not equal to jpi' ) 
+      IF( SIZE(p3d,2) /= jpj ) CALL ctl_stop( 'STOP', 'wrong call of sum3x3_3d, the second dimension is not equal to jpj' ) 
+      ipn = SIZE(p3d,3)
+      !
+      DO jn = 1, ipn
          DO jj = 1, jpj
-            DO ji =1, jpi
-            ztmp =  ptab(ji,jj,jk) * tmask_i(ji,jj)
-            CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+            DO ji = 1, jpi 
+               IF( MOD(mig(ji), 3) == 1 .AND. MOD(mjg(jj), 3) == 1 ) THEN   ! bottom left corber of a 3x3 box
+                  ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
+                  jj2 = MIN(mjg(jj)+2, jpjglo) - njmpp + 1                  ! upper position of the box
+                  IF( ji2 <= jpi .AND. jj2 <= jpj ) THEN                    ! the box is fully included in the local mpi domain
+                     p3d(ji:ji2,jj:jj2,jn) = SUM(p3d(ji:ji2,jj:jj2,jn))
+                  ENDIF
+               ENDIF
             END DO
          END DO
       END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_3d = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_3d
-
-
-   FUNCTION glob_sum_2d_a( ptab1, ptab2 )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_2d_a ***
-      !!
-      !! ** Purpose : perform a sum on two 2D arrays in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab1, ptab2
-      REAL(wp)                             ::   glob_sum_2d_a   ! global masked sum
-      !!
-      COMPLEX(wp)::   ctmp
-      REAL(wp)   ::   ztmp
-      INTEGER    ::   ji, jj   ! dummy loop indices
-      !!-----------------------------------------------------------------------
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jj = 1, jpj
-         DO ji =1, jpi
-         ztmp =  ptab1(ji,jj) * tmask_i(ji,jj)
-         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-         ztmp =  ptab2(ji,jj) * tmask_i(ji,jj)
-         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-         END DO
-      END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_2d_a = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_2d_a
-
-
-   FUNCTION glob_sum_3d_a( ptab1, ptab2 )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_3d_a ***
-      !!
-      !! ** Purpose : perform a sum on two 3D array in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab1, ptab2
-      REAL(wp)                               ::   glob_sum_3d_a   ! global masked sum
-      !!
-      COMPLEX(wp)::   ctmp
-      REAL(wp)   ::   ztmp
-      INTEGER    ::   ji, jj, jk   ! dummy loop indices
-      INTEGER    ::   ijpk ! local variables: size of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab1,3)
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jk = 1, ijpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ztmp =  ptab1(ji,jj,jk) * tmask_i(ji,jj)
-               CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-               ztmp =  ptab2(ji,jj,jk) * tmask_i(ji,jj)
-               CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-            END DO
-         END DO    
-      END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_3d_a = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_3d_a   
-
-   FUNCTION glob_sum_full_2d( ptab )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_full_2d ***
-      !!
-      !! ** Purpose : perform a sum in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab
-      REAL(wp)                             ::   glob_sum_full_2d   ! global sum (nomask)
-      !!
-      COMPLEX(wp)::   ctmp
-      REAL(wp)   ::   ztmp
-      INTEGER    ::   ji, jj   ! dummy loop indices
-      !!-----------------------------------------------------------------------
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jj = 1, jpj
-         DO ji =1, jpi
-         ztmp =  ptab(ji,jj) * tmask_h(ji,jj) 
-         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-         END DO
-      END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_full_2d = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_full_2d
-
-   FUNCTION glob_sum_full_3d( ptab )
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_full_3d ***
-      !!
-      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine
-      !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab
-      REAL(wp)                               ::   glob_sum_full_3d   ! global sum (nomask)
-      !!
-      COMPLEX(wp)::   ctmp
-      REAL(wp)   ::   ztmp
-      INTEGER    ::   ji, jj, jk   ! dummy loop indices
-      INTEGER    ::   ijpk ! local variables: size of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab,3)
-      !
-      ztmp = 0.e0
-      ctmp = CMPLX( 0.e0, 0.e0, wp )
-      DO jk = 1, ijpk
-         DO jj = 1, jpj
-            DO ji =1, jpi
-            ztmp =  ptab(ji,jj,jk) * tmask_h(ji,jj)
-            CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
-            END DO
-         END DO
-      END DO
-      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
-      glob_sum_full_3d = REAL(ctmp,wp)
-      !
-   END FUNCTION glob_sum_full_3d
-
-   ! --- MIN ---
-   FUNCTION glob_min_2d( ptab ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_min_2D  ***
-      !!
-      !! ** Purpose : perform a masked min on the inner global domain of a 2D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab          ! input 2D array
-      REAL(wp)                             ::   glob_min_2d   ! global masked min
-      !!-----------------------------------------------------------------------
-      !
-      glob_min_2d = MINVAL( ptab(:,:)*tmask_i(:,:) )
-      IF( lk_mpp )   CALL mpp_min( glob_min_2d )
-      !
-   END FUNCTION glob_min_2d
- 
-   FUNCTION glob_min_3d( ptab ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_min_3D  ***
-      !!
-      !! ** Purpose : perform a masked min on the inner global domain of a 3D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab          ! input 3D array
-      REAL(wp)                               ::   glob_min_3d   ! global masked min
-      !!
-      INTEGER :: jk
-      INTEGER :: ijpk ! local variable: size of the 3d dimension of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab,3)
-      !
-      glob_min_3d = MINVAL( ptab(:,:,1)*tmask_i(:,:) )
-      DO jk = 2, ijpk
-         glob_min_3d = MIN( glob_min_3d, MINVAL( ptab(:,:,jk)*tmask_i(:,:) ) )
-      END DO
-      IF( lk_mpp )   CALL mpp_min( glob_min_3d )
-      !
-   END FUNCTION glob_min_3d
-
-
-   FUNCTION glob_min_2d_a( ptab1, ptab2 ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_min_2D _a ***
-      !!
-      !! ** Purpose : perform a masked min on the inner global domain of two 2D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab1, ptab2    ! input 2D array
-      REAL(wp)            , DIMENSION(2)   ::   glob_min_2d_a   ! global masked min
-      !!-----------------------------------------------------------------------
-      !             
-      glob_min_2d_a(1) = MINVAL( ptab1(:,:)*tmask_i(:,:) )
-      glob_min_2d_a(2) = MINVAL( ptab2(:,:)*tmask_i(:,:) )
-      IF( lk_mpp )   CALL mpp_min( glob_min_2d_a, 2 )
-      !
-   END FUNCTION glob_min_2d_a
- 
- 
-   FUNCTION glob_min_3d_a( ptab1, ptab2 ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_min_3D_a ***
-      !!
-      !! ** Purpose : perform a masked min on the inner global domain of two 3D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab1, ptab2    ! input 3D array
-      REAL(wp)            , DIMENSION(2)     ::   glob_min_3d_a   ! global masked min
-      !!
-      INTEGER :: jk
-      INTEGER :: ijpk ! local variable: size of the 3d dimension of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab1,3)
-      !
-      glob_min_3d_a(1) = MINVAL( ptab1(:,:,1)*tmask_i(:,:) )
-      glob_min_3d_a(2) = MINVAL( ptab2(:,:,1)*tmask_i(:,:) )
-      DO jk = 2, ijpk
-         glob_min_3d_a(1) = MIN( glob_min_3d_a(1), MINVAL( ptab1(:,:,jk)*tmask_i(:,:) ) )
-         glob_min_3d_a(2) = MIN( glob_min_3d_a(2), MINVAL( ptab2(:,:,jk)*tmask_i(:,:) ) )
-      END DO
-      IF( lk_mpp )   CALL mpp_min( glob_min_3d_a, 2 )
-      !
-   END FUNCTION glob_min_3d_a
-
-   ! --- MAX ---
-   FUNCTION glob_max_2d( ptab ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_max_2D  ***
-      !!
-      !! ** Purpose : perform a masked max on the inner global domain of a 2D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab          ! input 2D array
-      REAL(wp)                             ::   glob_max_2d   ! global masked max
-      !!-----------------------------------------------------------------------
-      !
-      glob_max_2d = MAXVAL( ptab(:,:)*tmask_i(:,:) )
-      IF( lk_mpp )   CALL mpp_max( glob_max_2d )
-      !
-   END FUNCTION glob_max_2d
- 
-   FUNCTION glob_max_3d( ptab ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_max_3D  ***
-      !!
-      !! ** Purpose : perform a masked max on the inner global domain of a 3D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab          ! input 3D array
-      REAL(wp)                               ::   glob_max_3d   ! global masked max
-      !!
-      INTEGER :: jk
-      INTEGER :: ijpk ! local variable: size of the 3d dimension of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab,3)
-      !
-      glob_max_3d = MAXVAL( ptab(:,:,1)*tmask_i(:,:) )
-      DO jk = 2, ijpk
-         glob_max_3d = MAX( glob_max_3d, MAXVAL( ptab(:,:,jk)*tmask_i(:,:) ) )
-      END DO
-      IF( lk_mpp )   CALL mpp_max( glob_max_3d )
-      !
-   END FUNCTION glob_max_3d
-
-
-   FUNCTION glob_max_2d_a( ptab1, ptab2 ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_max_2D _a ***
-      !!
-      !! ** Purpose : perform a masked max on the inner global domain of two 2D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab1, ptab2    ! input 2D array
-      REAL(wp)            , DIMENSION(2)   ::   glob_max_2d_a   ! global masked max
-      !!-----------------------------------------------------------------------
-      !             
-      glob_max_2d_a(1) = MAXVAL( ptab1(:,:)*tmask_i(:,:) )
-      glob_max_2d_a(2) = MAXVAL( ptab2(:,:)*tmask_i(:,:) )
-      IF( lk_mpp )   CALL mpp_max( glob_max_2d_a, 2 )
-      !
-   END FUNCTION glob_max_2d_a
- 
- 
-   FUNCTION glob_max_3d_a( ptab1, ptab2 ) 
-      !!-----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_max_3D_a ***
-      !!
-      !! ** Purpose : perform a masked max on the inner global domain of two 3D array
-      !!-----------------------------------------------------------------------
-      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab1, ptab2    ! input 3D array
-      REAL(wp)            , DIMENSION(2)     ::   glob_max_3d_a   ! global masked max
-      !!
-      INTEGER :: jk
-      INTEGER :: ijpk ! local variable: size of the 3d dimension of ptab
-      !!-----------------------------------------------------------------------
-      !
-      ijpk = SIZE(ptab1,3)
-      !
-      glob_max_3d_a(1) = MAXVAL( ptab1(:,:,1)*tmask_i(:,:) )
-      glob_max_3d_a(2) = MAXVAL( ptab2(:,:,1)*tmask_i(:,:) )
-      DO jk = 2, ijpk
-         glob_max_3d_a(1) = MAX( glob_max_3d_a(1), MAXVAL( ptab1(:,:,jk)*tmask_i(:,:) ) )
-         glob_max_3d_a(2) = MAX( glob_max_3d_a(2), MAXVAL( ptab2(:,:,jk)*tmask_i(:,:) ) )
-      END DO
-      IF( lk_mpp )   CALL mpp_max( glob_max_3d_a, 2 )
-      !
-   END FUNCTION glob_max_3d_a
+      CALL lbc_lnk( 'lib_fortran', p3d, 'T', 1. )
+      IF( nbondi /= -1 ) THEN
+         IF( MOD(mig(    1), 3) == 1 )   p3d(    1,:,:) = p3d(    2,:,:)
+         IF( MOD(mig(    1), 3) == 2 )   p3d(    2,:,:) = p3d(    1,:,:)
+      ENDIF
+      IF( nbondi /=  1 ) THEN
+         IF( MOD(mig(jpi-2), 3) == 1 )   p3d(  jpi,:,:) = p3d(jpi-1,:,:)
+         IF( MOD(mig(jpi-2), 3) == 0 )   p3d(jpi-1,:,:) = p3d(  jpi,:,:)
+      ENDIF
+      IF( nbondj /= -1 ) THEN
+         IF( MOD(mjg(    1), 3) == 1 )   p3d(:,    1,:) = p3d(:,    2,:)
+         IF( MOD(mjg(    1), 3) == 2 )   p3d(:,    2,:) = p3d(:,    1,:)
+      ENDIF
+      IF( nbondj /=  1 ) THEN
+         IF( MOD(mjg(jpj-2), 3) == 1 )   p3d(:,  jpj,:) = p3d(:,jpj-1,:)
+         IF( MOD(mjg(jpj-2), 3) == 0 )   p3d(:,jpj-1,:) = p3d(:,  jpj,:)
+      ENDIF
+      CALL lbc_lnk( 'lib_fortran', p3d, 'T', 1. )
+
+   END SUBROUTINE sum3x3_3d
 
 
Index: /NEMO/trunk/src/OCE/lib_fortran_generic.h90
===================================================================
--- /NEMO/trunk/src/OCE/lib_fortran_generic.h90	(revision 10425)
+++ /NEMO/trunk/src/OCE/lib_fortran_generic.h90	(revision 10425)
@@ -0,0 +1,139 @@
+#if defined GLOBSUM_CODE
+!                          ! FUNCTION FUNCTION_GLOBSUM !
+#   if defined DIM_1d
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)                 , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define ARRAY_IN(i,j,k)   ptab(i)
+#      define ARRAY2_IN(i,j,k)  ptab2(i)
+#      define J_SIZE(ptab)      1
+#      define K_SIZE(ptab)      1
+#      define MASK_ARRAY(i,j)   1.
+#   endif
+#   if defined DIM_2d
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)                 , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define ARRAY_IN(i,j,k)   ptab(i,j)
+#      define ARRAY2_IN(i,j,k)  ptab2(i,j)
+#      define J_SIZE(ptab)      SIZE(ptab,2)
+#      define K_SIZE(ptab)      1
+#   endif
+#   if defined DIM_3d
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)                 , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define ARRAY_IN(i,j,k)   ptab(i,j,k)
+#      define ARRAY2_IN(i,j,k)  ptab2(i,j,k)
+#      define J_SIZE(ptab)      SIZE(ptab,2)
+#      define K_SIZE(ptab)      SIZE(ptab,3)
+#   endif
+#   if defined OPERATION_GLOBSUM
+#      define MASK_ARRAY(i,j)   tmask_i(i,j)
+#   endif
+#   if defined OPERATION_FULL_GLOBSUM
+#      define MASK_ARRAY(i,j)   tmask_h(i,j)
+#   endif
+
+   FUNCTION FUNCTION_GLOBSUM( cdname, ptab )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),  INTENT(in   ) ::   cdname  ! name of the calling subroutine
+      ARRAY_TYPE(:,:,:)                             ! array on which operation is applied
+      REAL(wp)   ::  FUNCTION_GLOBSUM
+      !
+      !!-----------------------------------------------------------------------
+      !
+      REAL(wp)                              ::   FUNCTION_GLOB_OP   ! global sum
+      !!
+      COMPLEX(wp)::   ctmp
+      REAL(wp)   ::   ztmp
+      INTEGER    ::   ji, jj, jk   ! dummy loop indices
+      INTEGER    ::   ipi, ipj, ipk    ! dimensions
+      !!-----------------------------------------------------------------------
+      !
+      ipi = SIZE(ptab,1)   ! 1st dimension
+      ipj = J_SIZE(ptab)   ! 2nd dimension
+      ipk = K_SIZE(ptab)   ! 3rd dimension
+      !
+      ctmp = CMPLX( 0.e0, 0.e0, wp )   ! warning ctmp is cumulated
+   
+      DO jk = 1, ipk
+        DO jj = 1, ipj
+          DO ji = 1, ipi
+             ztmp =  ARRAY_IN(ji,jj,jk) * MASK_ARRAY(ji,jj)
+             CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+          END DO
+        END DO
+      END DO
+      CALL mpp_sum( cdname, ctmp )   ! sum over the global domain
+      FUNCTION_GLOBSUM = REAL(ctmp,wp)
+
+   END FUNCTION FUNCTION_GLOBSUM
+
+#undef ARRAY_TYPE
+#undef ARRAY2_TYPE
+#undef ARRAY_IN
+#undef ARRAY2_IN
+#undef J_SIZE
+#undef K_SIZE
+#undef MASK_ARRAY
+!
+# endif
+#if defined GLOBMINMAX_CODE
+!                          ! FUNCTION FUNCTION_GLOBMINMAX !
+#   if defined DIM_2d
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)                 , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define ARRAY_IN(i,j,k)   ptab(i,j)
+#      define ARRAY2_IN(i,j,k)  ptab2(i,j)
+#      define K_SIZE(ptab)      1
+#   endif
+#   if defined DIM_3d
+#      define ARRAY_TYPE(i,j,k)    REAL(wp)                 , INTENT(in   ) ::   ARRAY_IN(i,j,k)
+#      define ARRAY_IN(i,j,k)   ptab(i,j,k)
+#      define ARRAY2_IN(i,j,k)  ptab2(i,j,k)
+#      define K_SIZE(ptab)      SIZE(ptab,3)
+#   endif
+#   if defined OPERATION_GLOBMIN
+#      define SCALAR_OPERATION min
+#      define ARRAY_OPERATION minval
+#      define MPP_OPERATION mpp_min
+#   endif
+#   if defined OPERATION_GLOBMAX
+#      define SCALAR_OPERATION max
+#      define ARRAY_OPERATION maxval
+#      define MPP_OPERATION mpp_max
+#   endif
+
+   FUNCTION FUNCTION_GLOBMINMAX( cdname, ptab )
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),  INTENT(in   ) ::   cdname  ! name of the calling subroutine
+      ARRAY_TYPE(:,:,:)                             ! array on which operation is applied
+      REAL(wp)   ::  FUNCTION_GLOBMINMAX
+      !
+      !!-----------------------------------------------------------------------
+      !
+      REAL(wp)                              ::   FUNCTION_GLOB_OP   ! global sum
+      !!
+      COMPLEX(wp)::   ctmp
+      REAL(wp)   ::   ztmp
+      INTEGER    ::   jk       ! dummy loop indices
+      INTEGER    ::   ipk      ! dimensions
+      !!-----------------------------------------------------------------------
+      !
+      ipk = K_SIZE(ptab)   ! 3rd dimension
+      !
+      ztmp = ARRAY_OPERATION( ARRAY_IN(:,:,1)*tmask_i(:,:) )
+      DO jk = 2, ipk
+         ztmp = SCALAR_OPERATION(ztmp, ARRAY_OPERATION( ARRAY_IN(:,:,jk)*tmask_i(:,:) ))
+      ENDDO
+
+      CALL MPP_OPERATION( cdname, ztmp)
+
+      FUNCTION_GLOBMINMAX = ztmp
+
+
+   END FUNCTION FUNCTION_GLOBMINMAX
+
+#undef ARRAY_TYPE
+#undef ARRAY2_TYPE
+#undef ARRAY_IN
+#undef ARRAY2_IN
+#undef K_SIZE
+#undef SCALAR_OPERATION
+#undef ARRAY_OPERATION
+#undef MPP_OPERATION
+# endif
Index: /NEMO/trunk/src/OCE/module_example
===================================================================
--- /NEMO/trunk/src/OCE/module_example	(revision 10424)
+++ /NEMO/trunk/src/OCE/module_example	(revision 10425)
@@ -63,6 +63,6 @@
       ALLOCATE( array(jpi,jpj,jpk) , STAT= exa_mpl_alloc )   ! Module array                                                                
       !
-      IF( lk_mpp             )   CALL mpp_sum ( exa_mpl_alloc )
-      IF( exa_mpl_alloc /= 0 )   CALL ctl_warn('exa_mpl_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'module_example', exa_mpl_alloc )
+      IF( exa_mpl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'exa_mpl_alloc: failed to allocate arrays' )
       !
    END FUNCTION exa_mpl_alloc
@@ -127,5 +127,5 @@
       END SELECT
       !
-      CALL lbc_lnk( avm, 'T', 1. )              ! Lateral boundary conditions (unchanged sign)
+      CALL lbc_lnk( 'module_example', avm, 'T', 1. )              ! Lateral boundary conditions (unchanged sign)
       !
    END SUBROUTINE exa_mpl
@@ -176,5 +176,5 @@
       !                              ! Parameter control
       IF( ln_opt      )   CALL ctl_stop( 'exa_mpl_init: this work and option xxx are incompatible'   )
-      IF( nn_opt == 2 )   CALL ctl_warn( 'exa_mpl_init: this work and option yyy may cause problems' )
+      IF( nn_opt == 2 )   CALL ctl_stop( 'STOP',  'exa_mpl_init: this work and option yyy may cause problems'  )
       !
    END SUBROUTINE exa_mpl_init
Index: /NEMO/trunk/src/OCE/nemogcm.F90
===================================================================
--- /NEMO/trunk/src/OCE/nemogcm.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/nemogcm.F90	(revision 10425)
@@ -102,4 +102,8 @@
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
 
+#if defined key_mpp_mpi
+   INCLUDE 'mpif.h'
+#endif
+
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -144,5 +148,5 @@
       ! check that all process are still there... If some process have an error,
       ! they will never enter in step and other processes will wait until the end of the cpu time!
-      IF( lk_mpp )   CALL mpp_max( nstop )
+      CALL mpp_max( 'nemogcm', nstop )
 
       IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
@@ -184,4 +188,9 @@
          !
          DO WHILE( istp <= nitend .AND. nstop == 0 )
+#if defined key_mpp_mpi
+            ncom_stp = istp
+            IF ( istp == ( nit000 + 1 ) ) elapsed_time = MPI_Wtime()
+            IF ( istp ==         nitend ) elapsed_time = MPI_Wtime() - elapsed_time
+#endif
             CALL stp        ( istp ) 
             istp = istp + 1
@@ -225,7 +234,11 @@
 #else
       IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
-      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop        ! end mpp communications
-      ENDIF
-#endif
+      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop( ldfinal = .TRUE. )   ! end mpp communications
+      ENDIF
+#endif
+      !
+      IF( nstop == 0 ) THEN   ;   STOP 0
+      ELSE                    ;   STOP 999
+      ENDIF
       !
    END SUBROUTINE nemo_gcm
@@ -340,10 +353,10 @@
          WRITE(numout,*)
          DO ji = 1, SIZE(cltxt)
-            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) cltxt(ji)    ! control print of mynode
+            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
          END DO
          WRITE(numout,*)
          WRITE(numout,*)
          DO ji = 1, SIZE(cltxt2)
-            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) cltxt2(ji)   ! control print of domain size
+            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
          END DO
          !
@@ -351,4 +364,7 @@
          !
       ENDIF
+      ! open /dev/null file to be able to supress output write easily
+      CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+      !
       !                                      ! Domain decomposition
       CALL mpp_init                          ! MPP
@@ -543,5 +559,6 @@
       !
       IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
-         &                                                'Compile with key_nosignedzero enabled' )
+         &                                                'Compile with key_nosignedzero enabled:',   &
+         &                                                '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' )
       !
 #if defined key_agrif
@@ -612,5 +629,5 @@
 #endif 
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'nemogcm', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
       !
Index: /NEMO/trunk/src/OCE/oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/oce.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/oce.F90	(revision 10425)
@@ -115,5 +115,5 @@
          !
       oce_alloc = MAXVAL( ierr )
-      IF( oce_alloc /= 0 )   CALL ctl_warn('oce_alloc: failed to allocate arrays')
+      IF( oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'oce_alloc: failed to allocate arrays' )
       !
    END FUNCTION oce_alloc
Index: /NEMO/trunk/src/OCE/stpctl.F90
===================================================================
--- /NEMO/trunk/src/OCE/stpctl.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/stpctl.F90	(revision 10425)
@@ -34,4 +34,5 @@
 
    INTEGER  ::   idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus
+   LOGICAL  ::   lsomeoce
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -50,5 +51,5 @@
       !!              - Print it each 50 time steps
       !!              - Stop the run IF problem encountered by setting indic=-3
-      !!                Problems checked: |ssh| maximum larger than 20 m
+      !!                Problems checked: |ssh| maximum larger than 10 m
       !!                                  |U|   maximum larger than 10 m/s 
       !!                                  negative sea surface salinity
@@ -61,12 +62,8 @@
       INTEGER, INTENT(inout) ::   kindic   ! error indicator
       !!
-      INTEGER  ::   ji, jj, jk             ! dummy loop indices
-      INTEGER  ::   iih, ijh               ! local integers
-      INTEGER  ::   iiu, iju, iku          !   -       -
-      INTEGER  ::   iis1, ijs1, iks1       !   -       -
-      INTEGER  ::   iis2, ijs2, iks2       !   -       -
-      REAL(wp) ::   zzz                    ! local real 
-      INTEGER , DIMENSION(3) ::   ilocu, ilocs1, ilocs2
-      INTEGER , DIMENSION(2) ::   iloch
+      INTEGER                ::   ji, jj, jk          ! dummy loop indices
+      INTEGER, DIMENSION(2)  ::   ih                  ! min/max loc indices
+      INTEGER, DIMENSION(3)  ::   iu, is1, is2        ! min/max loc indices
+      REAL(wp)               ::   zzz                 ! local real 
       REAL(wp), DIMENSION(9) ::   zmax
       CHARACTER(len=20) :: clname
@@ -78,9 +75,8 @@
          WRITE(numout,*) '~~~~~~~'
          !                                ! open time.step file
-         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
          !                                ! open run.stat file
-         CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-
-         IF( lwm ) THEN
+         IF( ln_ctl .AND. lwm ) THEN
+            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
             clname = 'run.stat.nc'
             IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
@@ -98,10 +94,10 @@
             ENDIF
             istatus = NF90_ENDDEF(idrun)
+            zmax(8:9) = 0._wp    ! initialise to zero in case ln_zad_Aimp option is not in use
          ENDIF
-         zmax(8:9) = 0._wp    ! initialise to zero in case ln_zad_Aimp option is not in use
-         
       ENDIF
+      IF( kt == nit000 )   lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0
       !
-      IF(lwp) THEN                        !==  current time step  ==!   ("time.step" file)
+      IF(lwm) THEN                        !==  current time step  ==!   ("time.step" file)
          WRITE ( numstp, '(1x, i8)' )   kt
          REWIND( numstp )
@@ -125,61 +121,11 @@
       ENDIF
       !
-      IF( lk_mpp ) THEN
-         CALL mpp_max_multiple( zmax(:), 9 )    ! max over the global domain
-         !
+      IF( ln_ctl ) THEN
+         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
          nstop = NINT( zmax(7) )                 ! nstop indicator sheared among all local domains
       ENDIF
-      !
-      IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
-         WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ',   zmax(1), ' |U| max: ', zmax(2),   &
-            &                                     ' S min: '    , - zmax(3), ' S max: ', zmax(4)
-      ENDIF
-      !
-      IF (  zmax(1) >   20._wp .OR.   &                    ! too large sea surface height ( > 20 m )
-         &  zmax(2) >   10._wp .OR.   &                    ! too large velocity ( > 10 m/s)
-         &  zmax(3) >=   0._wp .OR.   &                    ! negative or zero sea surface salinity
-         &  zmax(4) >= 100._wp .OR.   &                    ! too large sea surface salinity ( > 100 )
-         &  zmax(4) <    0._wp .OR.   &                    ! too large sea surface salinity (keep this line for sea-ice)
-         &  ISNAN( zmax(1) + zmax(2) + zmax(3) )  ) THEN   ! NaN encounter in the tests
-         IF( lk_mpp ) THEN
-            CALL mpp_maxloc( ABS(sshn)        , ssmask(:,:)  , zzz, iih , ijh        )
-            CALL mpp_maxloc( ABS(un)          , umask (:,:,:), zzz, iiu , iju , iku  )
-            CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis1, ijs1, iks1 )
-            CALL mpp_maxloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis2, ijs2, iks2 )
-         ELSE
-            iloch  = MINLOC( ABS( sshn(:,:)   )                               )
-            ilocu  = MAXLOC( ABS( un  (:,:,:) )                               )
-            ilocs1 = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )
-            ilocs2 = MAXLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )
-            iih  = iloch (1) + nimpp - 1   ;   ijh  = iloch (2) + njmpp - 1
-            iiu  = ilocu (1) + nimpp - 1   ;   iju  = ilocu (2) + njmpp - 1   ;   iku  = ilocu (3)
-            iis1 = ilocs1(1) + nimpp - 1   ;   ijs1 = ilocs1(2) + njmpp - 1   ;   iks1 = ilocs1(3)
-            iis2 = ilocs2(1) + nimpp - 1   ;   ijs2 = ilocs2(2) + njmpp - 1   ;   iks2 = ilocs2(3)
-         ENDIF
-         IF(lwp) THEN
-            WRITE(numout,cform_err)
-            WRITE(numout,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
-            WRITE(numout,*) ' ======= '
-            WRITE(numout,9100) kt,   zmax(1), iih , ijh
-            WRITE(numout,9200) kt,   zmax(2), iiu , iju , iku
-            WRITE(numout,9300) kt, - zmax(3), iis1, ijs1, iks1
-            WRITE(numout,9400) kt,   zmax(4), iis2, ijs2, iks2
-            WRITE(numout,*)
-            WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
-         ENDIF
-         kindic = -3
-         !
-         nstop = nstop + 1                            ! increase nstop by 1 (on all local domains)
-         CALL dia_wri_state( 'output.abort', kt )     ! create an output.abort file
-         !
-      ENDIF
-9100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5)
-9200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5)
-9300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j k: ',3i5)
-9400  FORMAT (' kt=',i8,'   S     max: ',1pg11.4,', at  i j k: ',3i5)
-      !
-      !                                            !==  run statistics  ==!   ("run.stat" file)
-      IF(lwp) WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4)
-      IF( lwm ) THEN
+      !                                   !==  run statistics  ==!   ("run.stat" files)
+      IF( ln_ctl .AND. lwm ) THEN
+         WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4)
          istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
          istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
@@ -195,5 +141,48 @@
          IF( kt == nitend         ) istatus = NF90_CLOSE(idrun)
       END IF
+      !                                   !==  error handling  ==!
+      IF( ( ln_ctl .OR. lsomeoce ) .AND. (   &             ! have use mpp_max (because ln_ctl=.T.) or contains some ocean points
+         &  zmax(1) >   20._wp .OR.   &                    ! too large sea surface height ( > 20 m )
+         &  zmax(2) >   10._wp .OR.   &                    ! too large velocity ( > 10 m/s)
+         &  zmax(3) >=   0._wp .OR.   &                    ! negative or zero sea surface salinity
+         &  zmax(4) >= 100._wp .OR.   &                    ! too large sea surface salinity ( > 100 )
+         &  zmax(4) <    0._wp .OR.   &                    ! too large sea surface salinity (keep this line for sea-ice)
+         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN   ! NaN encounter in the tests
+         IF( lk_mpp .AND. ln_ctl ) THEN
+            CALL mpp_maxloc( 'stpctl', ABS(sshn)        , ssmask(:,:)  , zzz, ih  )
+            CALL mpp_maxloc( 'stpctl', ABS(un)          , umask (:,:,:), zzz, iu  )
+            CALL mpp_minloc( 'stpctl', tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, is1 )
+            CALL mpp_maxloc( 'stpctl', tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, is2 )
+         ELSE
+            ih(:)  = MAXLOC( ABS( sshn(:,:)   )                              ) + (/ nimpp - 1, njmpp - 1    /)
+            iu(:)  = MAXLOC( ABS( un  (:,:,:) )                              ) + (/ nimpp - 1, njmpp - 1, 0 /)
+            is1(:) = MINLOC( tsn(:,:,:,jp_sal), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
+            is2(:) = MAXLOC( tsn(:,:,:,jp_sal), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
+         ENDIF
+         
+         WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
+         WRITE(ctmp2,9100) kt,   zmax(1), ih(1) , ih(2)
+         WRITE(ctmp3,9200) kt,   zmax(2), iu(1) , iu(2) , iu(3)
+         WRITE(ctmp4,9300) kt, - zmax(3), is1(1), is1(2), is1(3)
+         WRITE(ctmp5,9400) kt,   zmax(4), is2(1), is2(2), is2(3)
+         WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort.nc file'
+         
+         CALL dia_wri_state( 'output.abort' )     ! create an output.abort file
+         
+         IF( .NOT. ln_ctl ) THEN
+            WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea
+            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ctmp6 )
+         ELSE
+            CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6, ' ' )
+         ENDIF
+
+         kindic = -3
+         !
+      ENDIF
       !
+9100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5)
+9200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5)
+9300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j k: ',3i5)
+9400  FORMAT (' kt=',i8,'   S     max: ',1pg11.4,', at  i j k: ',3i5)
 9500  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16)
       !
Index: /NEMO/trunk/src/OCE/timing.F90
===================================================================
--- /NEMO/trunk/src/OCE/timing.F90	(revision 10424)
+++ /NEMO/trunk/src/OCE/timing.F90	(revision 10425)
@@ -38,5 +38,7 @@
    TYPE timer
       CHARACTER(LEN=20)  :: cname
-   	  REAL(wp)  :: t_cpu, t_clock, tsum_cpu, tsum_clock, tmax_cpu, tmax_clock, tmin_cpu, tmin_clock, tsub_cpu, tsub_clock
+      CHARACTER(LEN=20)  :: surname
+      INTEGER :: rank
+      REAL(wp)  :: t_cpu, t_clock, tsum_cpu, tsum_clock, tmax_cpu, tmax_clock, tmin_cpu, tmin_clock, tsub_cpu, tsub_clock
       INTEGER :: ncount, ncount_max, ncount_rate  
       INTEGER :: niter
@@ -49,7 +51,7 @@
    TYPE alltimer
       CHARACTER(LEN=20), DIMENSION(:), POINTER :: cname => NULL()
-   	  REAL(wp), DIMENSION(:), POINTER :: tsum_cpu   => NULL()
-   	  REAL(wp), DIMENSION(:), POINTER :: tsum_clock => NULL()
-   	  INTEGER, DIMENSION(:), POINTER :: niter => NULL()
+      REAL(wp), DIMENSION(:), POINTER :: tsum_cpu   => NULL()
+      REAL(wp), DIMENSION(:), POINTER :: tsum_clock => NULL()
+      INTEGER, DIMENSION(:), POINTER :: niter => NULL()
       TYPE(alltimer), POINTER :: next => NULL()
       TYPE(alltimer), POINTER :: prev => NULL()
@@ -58,4 +60,6 @@
    TYPE(timer), POINTER :: s_timer_root => NULL()
    TYPE(timer), POINTER :: s_timer      => NULL()
+   TYPE(timer), POINTER :: s_timer_old      => NULL()
+
    TYPE(timer), POINTER :: s_wrk        => NULL()
    REAL(wp) :: t_overclock, t_overcpu
@@ -90,14 +94,18 @@
       CHARACTER(len=*), INTENT(in) :: cdinfo
       !
-       
-      ! Create timing structure at first call
-      IF( .NOT. l_initdone ) THEN
-         CALL timing_ini_var(cdinfo)
+       IF(ASSOCIATED(s_timer) ) s_timer_old => s_timer
+       !
+      ! Create timing structure at first call of the routine 
+       CALL timing_ini_var(cdinfo)
+   !   write(*,*) 'after inivar ', s_timer%cname
+
+      ! ici timing_ini_var a soit retrouve s_timer et fait return soit ajoute un maillon
+      ! maintenant on regarde si le call d'avant corrsspond a un parent ou si il est ferme
+      IF( .NOT. s_timer_old%l_tdone ) THEN      
+         s_timer%parent_section => s_timer_old
       ELSE
-         s_timer => s_timer_root
-         DO WHILE( TRIM(s_timer%cname) /= TRIM(cdinfo) ) 
-            IF( ASSOCIATED(s_timer%next) ) s_timer => s_timer%next
-         END DO
-      ENDIF         
+         s_timer%parent_section => NULL()
+      ENDIF    
+
       s_timer%l_tdone = .FALSE.
       s_timer%niter = s_timer%niter + 1
@@ -114,4 +122,6 @@
       CALL SYSTEM_CLOCK(COUNT = s_timer%ncount)
 #endif
+!      write(*,*) 'end of start ', s_timer%cname
+
       !
    END SUBROUTINE timing_start
@@ -127,5 +137,5 @@
       !
       INTEGER  :: ifinal_count, iperiods    
-      REAL(wp) :: zcpu_end, zmpitime
+      REAL(wp) :: zcpu_end, zmpitime,zcpu_raw,zclock_raw
       !
       s_wrk => NULL()
@@ -140,30 +150,38 @@
       CALL CPU_TIME( zcpu_end )
 
-      s_timer => s_timer_root
-      DO WHILE( TRIM(s_timer%cname) /= TRIM(cdinfo) ) 
-         IF( ASSOCIATED(s_timer%next) ) s_timer => s_timer%next
-      END DO
+!!$      IF(associated(s_timer%parent_section))then
+!!$        write(*,*) s_timer%cname,' <-- ', s_timer%parent_section%cname
+!!$      ENDIF  
+
+ !     No need to search ... : s_timer has the last value defined in start
+ !     s_timer => s_timer_root
+ !     DO WHILE( TRIM(s_timer%cname) /= TRIM(cdinfo) ) 
+ !        IF( ASSOCIATED(s_timer%next) ) s_timer => s_timer%next
+ !     END DO
  
       ! CPU time correction
-      s_timer%t_cpu  = zcpu_end - s_timer%t_cpu - t_overcpu - s_timer%tsub_cpu
-  
+      zcpu_raw = zcpu_end - s_timer%t_cpu - t_overcpu ! total time including child
+      s_timer%t_cpu  = zcpu_raw - s_timer%tsub_cpu
+  !    IF(s_timer%cname==trim('lbc_lnk_2d'))  write(*,*) s_timer%tsub_cpu,zcpu_end
+
       ! clock time correction
 #if defined key_mpp_mpi
-      s_timer%t_clock = zmpitime - s_timer%t_clock - t_overclock - s_timer%tsub_clock
+      zclock_raw = zmpitime - s_timer%t_clock - t_overclock ! total time including child
+      s_timer%t_clock = zclock_raw - t_overclock - s_timer%tsub_clock
 #else
       iperiods = ifinal_count - s_timer%ncount
       IF( ifinal_count < s_timer%ncount )  &
-          iperiods = iperiods + s_timer%ncount_max 
-      s_timer%t_clock  = REAL(iperiods) / s_timer%ncount_rate - t_overclock - s_timer%tsub_clock
+         iperiods = iperiods + s_timer%ncount_max 
+         zclock_raw = REAL(iperiods) / s_timer%ncount_rate !- t_overclock   
+         s_timer%t_clock  = zclock_raw - s_timer%tsub_clock
 #endif
+ !     IF(s_timer%cname==trim('lbc_lnk_2d')) write(*,*) zclock_raw , s_timer%tsub_clock
       
       ! Correction of parent section
       IF( .NOT. PRESENT(csection) ) THEN
-         s_wrk => s_timer
-         DO WHILE ( ASSOCIATED(s_wrk%parent_section ) )
-            s_wrk => s_wrk%parent_section
-            s_wrk%tsub_cpu   = s_wrk%tsub_cpu   + s_timer%t_cpu 
-            s_wrk%tsub_clock = s_wrk%tsub_clock + s_timer%t_clock              
-         END DO
+         IF ( ASSOCIATED(s_timer%parent_section ) ) THEN
+            s_timer%parent_section%tsub_cpu   = zcpu_raw   + s_timer%parent_section%tsub_cpu 
+            s_timer%parent_section%tsub_clock = zclock_raw + s_timer%parent_section%tsub_clock             
+         ENDIF
       ENDIF
             
@@ -186,4 +204,10 @@
       s_timer%l_tdone = .TRUE.
       !
+      !
+      ! we come back
+      IF ( ASSOCIATED(s_timer%parent_section ) ) s_timer => s_timer%parent_section
+     
+!      write(*,*) 'end of stop ', s_timer%cname
+
    END SUBROUTINE timing_stop
  
@@ -211,5 +235,5 @@
          WRITE(numtime,*) '                             NEMO team'
          WRITE(numtime,*) '                  Ocean General Circulation Model'
-         WRITE(numtime,*) '                        version 4.0  (2018) '
+         WRITE(numtime,*) '                        version 3.6  (2015) '
          WRITE(numtime,*)
          WRITE(numtime,*) '                        Timing Informations '
@@ -263,7 +287,11 @@
       TYPE(timer), POINTER :: s_temp
       INTEGER :: idum, iperiods, icode
+      INTEGER :: ji
       LOGICAL :: ll_ord, ll_averep
       CHARACTER(len=120) :: clfmt            
-      
+      REAL(wp), DIMENSION(:), ALLOCATABLE ::   timing_glob
+      REAL(wp) ::   zsypd   ! simulated years per day (Balaji 2017)
+      REAL(wp) ::   zperc, ztot
+
       ll_averep = .TRUE.
     
@@ -292,5 +320,5 @@
       END DO
       idum = nsize
-      IF(lk_mpp) CALL mpp_sum(idum)
+      CALL mpp_sum('timing', idum)
       IF( idum/jpnij /= nsize ) THEN
          IF( lwriter ) WRITE(numtime,*) '        ===> W A R N I N G: '
@@ -340,4 +368,31 @@
       &       ctime(2)(1:2), ctime(2)(3:4), ctime(2)(5:6),   &
       &       czone(1:3),    czone(4:5)
+
+#if defined key_mpp_mpi
+      ALLOCATE(timing_glob(4*jpnij), stat=icode)
+      CALL MPI_GATHER( (/compute_time, waiting_time(1), waiting_time(2), elapsed_time/),   &
+         &             4, MPI_DOUBLE_PRECISION, timing_glob, 4, MPI_DOUBLE_PRECISION, 0, MPI_COMM_OCE, icode)
+      IF( narea == 1 ) THEN
+         WRITE(numtime,*) ' '
+         WRITE(numtime,*) ' Report on time spent on waiting MPI messages '
+         WRITE(numtime,*) '    total timing measured between nit000+1 and nitend-1 '
+         WRITE(numtime,*) '    warning: includes restarts writing time if output before nitend... '
+         WRITE(numtime,*) ' '
+         DO ji = 1, jpnij
+            ztot = SUM( timing_glob(4*ji-3:4*ji-1) )
+            WRITE(numtime,'(A28,F11.6,            A34,I8)') 'Computing       time : ',timing_glob(4*ji-3), ' on MPI rank : ', ji
+            IF ( ztot /= 0. ) zperc = timing_glob(4*ji-2) / ztot * 100.
+            WRITE(numtime,'(A28,F11.6,A2, F4.1,A3,A25,I8)') 'Waiting lbc_lnk time : ',timing_glob(4*ji-2)   &
+               &                                                         , ' (',      zperc,' %)',   ' on MPI rank : ', ji
+            IF ( ztot /= 0. ) zperc = timing_glob(4*ji-1) / ztot * 100.
+            WRITE(numtime,'(A28,F11.6,A2, F4.1,A3,A25,I8)') 'Waiting  global time : ',timing_glob(4*ji-1)   &
+               &                                                         , ' (',      zperc,' %)',   ' on MPI rank : ', ji
+            zsypd = rn_rdt * REAL(nitend-nit000-1, wp) / (timing_glob(4*ji) * 365.)
+            WRITE(numtime,'(A28,F11.6,A7,F10.3,A2,A15,I8)') 'Total           time : ',timing_glob(4*ji  )   &
+               &                                                         , ' (SYPD: ', zsypd, ')',   ' on MPI rank : ', ji
+         END DO
+      ENDIF
+      DEALLOCATE(timing_glob)
+#endif      
 
       IF( lwriter ) CLOSE(numtime) 
@@ -459,4 +514,5 @@
          sl_timer_ave_root%next => NULL()
          sl_timer_ave_root%prev => NULL()
+         ALLOCATE(sl_timer_ave)
          sl_timer_ave => sl_timer_ave_root            
       ENDIF 
@@ -490,6 +546,4 @@
          s_timer => s_timer%next
       END DO      
-
-         WRITE(*,*) 'ARPDBG: timing: done gathers'
       
       IF( narea == 1 ) THEN    
@@ -514,6 +568,4 @@
             sl_timer_glob => sl_timer_glob%next                                
          END DO
-
-         WRITE(*,*) 'ARPDBG: timing: done computing stats'
       
          ! reorder the averaged list by CPU time      
@@ -567,9 +619,4 @@
       ENDIF
       !
-      DEALLOCATE(sl_timer_glob_root%cname     , &
-                 sl_timer_glob_root%tsum_cpu  , &
-                 sl_timer_glob_root%tsum_clock, &
-                 sl_timer_glob_root%niter)
-      !
       DEALLOCATE(sl_timer_glob_root)
       !                  
@@ -676,14 +723,39 @@
          s_timer => s_timer_root
          !
+         ALLOCATE(s_wrk)
          s_wrk => NULL()
-         
+         !
+         ALLOCATE(s_timer_old)
+         s_timer_old%cname       = cdinfo
+         s_timer_old%t_cpu      = 0._wp
+         s_timer_old%t_clock    = 0._wp
+         s_timer_old%tsum_cpu   = 0._wp
+         s_timer_old%tsum_clock = 0._wp
+         s_timer_old%tmax_cpu   = 0._wp
+         s_timer_old%tmax_clock = 0._wp
+         s_timer_old%tmin_cpu   = 0._wp
+         s_timer_old%tmin_clock = 0._wp
+         s_timer_old%tsub_cpu   = 0._wp
+         s_timer_old%tsub_clock = 0._wp
+         s_timer_old%ncount      = 0
+         s_timer_old%ncount_rate = 0
+         s_timer_old%ncount_max  = 0
+         s_timer_old%niter       = 0
+         s_timer_old%l_tdone  = .TRUE.
+         s_timer_old%next => NULL()
+         s_timer_old%prev => NULL()
+
       ELSE
          s_timer => s_timer_root
          ! case of already existing area (typically inside a loop)
+   !         write(*,*) 'in ini_var for routine : ', cdinfo
          DO WHILE( ASSOCIATED(s_timer) ) 
-            IF( TRIM(s_timer%cname) .EQ. TRIM(cdinfo) ) RETURN
+            IF( TRIM(s_timer%cname) .EQ. TRIM(cdinfo) ) THEN
+ !             write(*,*) 'in ini_var for routine : ', cdinfo,' we return'           
+               RETURN ! cdinfo is already in the chain
+            ENDIF
             s_timer => s_timer%next
          END DO
-         
+
          ! end of the chain
          s_timer => s_timer_root
@@ -691,6 +763,10 @@
             s_timer => s_timer%next
          END DO
-          
-         ALLOCATE(s_timer%next)      
+
+    !     write(*,*) 'after search', s_timer%cname
+         ! cdinfo is not part of the chain so we add it with initialisation          
+          ALLOCATE(s_timer%next)
+    !     write(*,*) 'after allocation of next'
+  
          s_timer%next%cname       = cdinfo
          s_timer%next%t_cpu      = 0._wp
@@ -713,17 +789,7 @@
          s_timer%next%next => NULL()
          s_timer => s_timer%next
-
-         ! are we inside a section
-         s_wrk => s_timer%prev
-         ll_section = .FALSE.
-         DO WHILE( ASSOCIATED(s_wrk) .AND. .NOT. ll_section )
-            IF( .NOT. s_wrk%l_tdone ) THEN
-               ll_section = .TRUE.
-               s_timer%parent_section => s_wrk 
-            ENDIF
-            s_wrk => s_wrk%prev
-         END DO 
-      ENDIF         
-      !
+      ENDIF 
+      !    write(*,*) 'after allocation'
+     !
    END SUBROUTINE timing_ini_var
 
@@ -738,5 +804,5 @@
 !      IF(lwp) WRITE(numout,*) 'timing_reset : instrumented routines for timing'
 !      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-!      CALL timing_list(s_timer_root)
+      CALL timing_list(s_timer_root)
 !      WRITE(numout,*)
       !
Index: /NEMO/trunk/src/OFF/dtadyn.F90
===================================================================
--- /NEMO/trunk/src/OFF/dtadyn.F90	(revision 10424)
+++ /NEMO/trunk/src/OFF/dtadyn.F90	(revision 10425)
@@ -404,6 +404,6 @@
       hrnf_max = MAXVAL( h_rnf(:,:) )
       IF( lk_mpp )  THEN
-         CALL mpp_max( nkrnf_max )                 ! max over the  global domain
-         CALL mpp_max( hrnf_max )                 ! max over the  global domain
+         CALL mpp_max( 'dtadyn', nkrnf_max )                 ! max over the  global domain
+         CALL mpp_max( 'dtadyn', hrnf_max )                 ! max over the  global domain
       ENDIF
       IF(lwp) WRITE(numout,*) ' '
Index: /NEMO/trunk/src/OFF/nemogcm.F90
===================================================================
--- /NEMO/trunk/src/OFF/nemogcm.F90	(revision 10424)
+++ /NEMO/trunk/src/OFF/nemogcm.F90	(revision 10425)
@@ -95,5 +95,5 @@
       ! check that all process are still there... If some process have an error,
       ! they will never enter in step and other processes will wait until the end of the cpu time!
-      IF( lk_mpp )   CALL mpp_max( nstop )
+      CALL mpp_max( 'nemogcm', nstop )
 
       !                            !-----------------------!
@@ -441,5 +441,5 @@
       ierr = ierr + trc_oce_alloc()          ! shared TRC / TRA arrays
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'nemogcm', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
       !
@@ -481,5 +481,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( kt == nit000 .AND. lwp ) THEN
+      IF( kt == nit000 .AND. lwm ) THEN
          WRITE(numout,*)
          WRITE(numout,*) 'stp_ctl : time-stepping control'
@@ -489,6 +489,6 @@
       ENDIF
       !
-      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
-      IF(lwp) REWIND( numstp )                       ! --------------------------
+      IF(lwm) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
+      IF(lwm) REWIND( numstp )                       ! --------------------------
       !
    END SUBROUTINE stp_ctl
Index: /NEMO/trunk/src/SAO/nemogcm.F90
===================================================================
--- /NEMO/trunk/src/SAO/nemogcm.F90	(revision 10424)
+++ /NEMO/trunk/src/SAO/nemogcm.F90	(revision 10425)
@@ -372,5 +372,5 @@
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'nemogcm', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc : unable to allocate standard ocean arrays' )
       !
Index: /NEMO/trunk/src/SAS/diawri.F90
===================================================================
--- /NEMO/trunk/src/SAS/diawri.F90	(revision 10424)
+++ /NEMO/trunk/src/SAS/diawri.F90	(revision 10425)
@@ -39,4 +39,5 @@
    USE ioipsl
 #if defined key_si3
+   USE ice
    USE icewri
 #endif
@@ -93,5 +94,5 @@
       ! Output the initial state and forcings
       IF( ninist == 1 ) THEN
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -109,5 +110,5 @@
       !
       ALLOCATE( ndex_hT(jpi*jpj), ndex_hU(jpi*jpj), ndex_hV(jpi*jpj), STAT=dia_wri_alloc )
-      IF( lk_mpp )   CALL mpp_sum( dia_wri_alloc )
+      CALL mpp_sum( 'diawri', dia_wri_alloc )
       !
    END FUNCTION dia_wri_alloc
@@ -142,5 +143,5 @@
       ! Output the initial state and forcings
       IF( ninist == 1 ) THEN                       
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -329,5 +330,5 @@
 #endif
 
-   SUBROUTINE dia_wri_state( cdfile_name, kt )
+   SUBROUTINE dia_wri_state( cdfile_name )
       !!---------------------------------------------------------------------
       !!                 ***  ROUTINE dia_wri_state  ***
@@ -343,93 +344,39 @@
       !!----------------------------------------------------------------------
       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
+      !!
+      INTEGER :: inum
       !!----------------------------------------------------------------------
       ! 
-      IF( ln_timing )   CALL timing_start('dia_wri_state')
-
-      ! 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, "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(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
 
 #if defined key_si3
-      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + lim but no-ice in child grid
-         CALL ice_wri_state( kt, id_i, nh_i )
-      ENDIF
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
 #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, "sowaflup", kt, emp              , 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
-
-      ! 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 )
-      ENDIF
-#endif
-      !
-      IF( ln_timing )   CALL timing_stop('dia_wri_state')
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+#endif
+
+      CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature
+      CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity
+      CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height
+      CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
+      CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
+      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
+      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
+      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
+      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
+      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
+      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
+      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
+ 
+#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( inum )
+      ENDIF
+#endif
+      !
+      CALL iom_close( inum )
       !
    END SUBROUTINE dia_wri_state
Index: /NEMO/trunk/src/SAS/nemogcm.F90
===================================================================
--- /NEMO/trunk/src/SAS/nemogcm.F90	(revision 10424)
+++ /NEMO/trunk/src/SAS/nemogcm.F90	(revision 10425)
@@ -94,5 +94,5 @@
       ! check that all process are still there... If some process have an error,
       ! they will never enter in step and other processes will wait until the end of the cpu time!
-      IF( lk_mpp )   CALL mpp_max( nstop )
+      CALL mpp_max( 'nemogcm', nstop )
 
       IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
@@ -486,5 +486,5 @@
       ierr = ierr + bdy_oce_alloc()          ! bdy masks (incl. initialization)
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'nemogcm', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
       !
Index: /NEMO/trunk/src/SAS/step.F90
===================================================================
--- /NEMO/trunk/src/SAS/step.F90	(revision 10424)
+++ /NEMO/trunk/src/SAS/step.F90	(revision 10425)
@@ -121,5 +121,5 @@
       IF( indic < 0  )  THEN
                              CALL ctl_stop( 'step: indic < 0' )
-                             CALL dia_wri_state( 'output.abort', kstp )
+                             CALL dia_wri_state( 'output.abort' )
       ENDIF
       IF( kstp == nit000   ) CALL iom_close( numror )     ! close input  ocean restart file
Index: /NEMO/trunk/src/SAS/stpctl.F90
===================================================================
--- /NEMO/trunk/src/SAS/stpctl.F90	(revision 10424)
+++ /NEMO/trunk/src/SAS/stpctl.F90	(revision 10425)
@@ -32,4 +32,5 @@
 
    INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus
+   LOGICAL  ::   lsomeoce
    !!----------------------------------------------------------------------
    !! NEMO/SAS 4.0 , NEMO Consortium (2018)
@@ -57,4 +58,5 @@
       !!
       REAL(wp), DIMENSION(3) ::   zmax
+      CHARACTER(len=20) :: clname
       !!----------------------------------------------------------------------
 
@@ -64,9 +66,10 @@
          WRITE(numout,*) '~~~~~~~'
          !                                ! open time.step file
-         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
          !                                ! open run.stat file
-         CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-
-         IF( lwm ) THEN
+         IF( ln_ctl .AND. lwm ) THEN
+            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+            clname = 'run.stat.nc'
+            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
             istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun )
             istatus = NF90_DEF_DIM( idrun, 'time'     , NF90_UNLIMITED, idtime )
@@ -76,27 +79,21 @@
             istatus = NF90_ENDDEF(idrun)
          ENDIF
-         
       ENDIF
+      IF( kt == nit000 )   lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0
       !
-      IF(lwp) THEN                        !==  current time step  ==!   ("time.step" file)
+      IF(lwm) THEN                        !==  current time step  ==!   ("time.step" file)
          WRITE ( numstp, '(1x, i8)' )   kt
          REWIND( numstp )
       ENDIF
       !                                   !==  test of extrema  ==!
-      zmax(1) = MAXVAL(      vt_i (:,:) )                                           ! max ice thickness
-      zmax(2) = MAXVAL( ABS( u_ice(:,:) ) )                                         ! max ice velocity (zonal only)
-      zmax(3) = MAXVAL(     -tm_i (:,:)+273.15_wp , mask = ssmask(:,:) == 1._wp )   ! min ice temperature
-      !
-      IF( lk_mpp ) THEN
-         CALL mpp_max_multiple( zmax(:), 3 )    ! max over the global domain
-      ENDIF
-      !
-      IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
-         WRITE(numout,*) ' ==>> time-step= ', kt, ' vt_i max: ',  zmax(1), ' |u_ice| max: ', zmax(2), ' tm_i min: ', -zmax(3)
-      ENDIF
-
+      IF( ln_ctl ) THEN   ! must be done by all processes because of the mpp_max
+         zmax(1) = MAXVAL(      vt_i (:,:) )                                           ! max ice thickness
+         zmax(2) = MAXVAL( ABS( u_ice(:,:) ) )                                         ! max ice velocity (zonal only)
+         zmax(3) = MAXVAL(     -tm_i (:,:)+273.15_wp , mask = ssmask(:,:) == 1._wp )   ! min ice temperature
+         CALL mpp_max( "stpctl", zmax )                                   ! max over the global domain
+      END IF
       !                                            !==  run statistics  ==!   ("run.stat" file)
-      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
-      IF( lwm ) THEN
+      IF( ln_ctl .AND. lwm ) THEN
+         IF(lwp) WRITE(numrun,9500) kt, zmax(1), zmax(2), - zmax(3)
          istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
          istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
@@ -106,5 +103,5 @@
       END IF
       !
-9400  FORMAT(' it :', i8, '    vt_i_max: ', D23.16, ' |u|_max: ', D23.16,' tm_i_min: ', D23.16)
+9500  FORMAT(' it :', i8, '    vt_i_max: ', D23.16, ' |u|_max: ', D23.16,' tm_i_min: ', D23.16)
       !
    END SUBROUTINE stp_ctl
Index: /NEMO/trunk/src/TOP/C14/trcwri_c14.F90
===================================================================
--- /NEMO/trunk/src/TOP/C14/trcwri_c14.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/C14/trcwri_c14.F90	(revision 10425)
@@ -96,22 +96,22 @@
     
       IF( iom_use("AtmC14") ) THEN
-         zarea = glob_sum( e1e2t(:,:) )           ! global ocean surface
-         ztemp = glob_sum( c14sbc(:,:) * e1e2t(:,:) )
+         zarea = glob_sum( 'trcwri_c14', e1e2t(:,:) )           ! global ocean surface
+         ztemp = glob_sum( 'trcwri_c14', c14sbc(:,:) * e1e2t(:,:) )
          ztemp = ( ztemp / zarea - 1._wp ) * 1000._wp
          CALL iom_put( "AtmC14" , ztemp )   ! Global atmospheric DeltaC14 [permil]
       ENDIF
       IF( iom_use("K_C14") ) THEN
-         ztemp = glob_sum ( exch_c14(:,:) * e1e2t(:,:) )
+         ztemp = glob_sum ( 'trcwri_c14', exch_c14(:,:) * e1e2t(:,:) )
          ztemp = rsiyea * ztemp / zarea
          CALL iom_put( "K_C14" , ztemp )   ! global mean exchange velocity for C14/C ratio [m/yr]
       ENDIF
       IF( iom_use("K_CO2") ) THEN
-         zarea = glob_sum( e1e2t(:,:) )           ! global ocean surface
-         ztemp = glob_sum ( exch_co2(:,:) * e1e2t(:,:) )
+         zarea = glob_sum( 'trcwri_c14', e1e2t(:,:) )           ! global ocean surface
+         ztemp = glob_sum ( 'trcwri_c14', exch_co2(:,:) * e1e2t(:,:) )
          ztemp = 360000._wp * ztemp / zarea       ! cm/h units: directly comparable with literature
          CALL iom_put( "K_CO2", ztemp )  !  global mean CO2 piston velocity [cm/hr]
       ENDIF
       IF( iom_use("C14Inv") ) THEN
-         ztemp = glob_sum( trn(:,:,:,jp_c14) * cvol(:,:,:) )
+         ztemp = glob_sum( 'trcwri_c14', trn(:,:,:,jp_c14) * cvol(:,:,:) )
          ztemp = atomc14 * xdicsur * ztemp
          CALL iom_put( "C14Inv", ztemp )  !  Radiocarbon ocean inventory [10^26 atoms]
Index: /NEMO/trunk/src/TOP/CFC/trcsms_cfc.F90
===================================================================
--- /NEMO/trunk/src/TOP/CFC/trcsms_cfc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/CFC/trcsms_cfc.F90	(revision 10425)
@@ -310,5 +310,5 @@
          &      STAT=trc_sms_cfc_alloc )
          !
-      IF( trc_sms_cfc_alloc /= 0 ) CALL ctl_warn('trc_sms_cfc_alloc : failed to allocate arrays.')
+      IF( trc_sms_cfc_alloc /= 0 ) CALL ctl_stop( 'STOP', 'trc_sms_cfc_alloc : failed to allocate arrays.' )
       !
    END FUNCTION trc_sms_cfc_alloc
Index: /NEMO/trunk/src/TOP/MY_TRC/trcsms_my_trc.F90
===================================================================
--- /NEMO/trunk/src/TOP/MY_TRC/trcsms_my_trc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/MY_TRC/trcsms_my_trc.F90	(revision 10425)
@@ -81,5 +81,5 @@
       trc_sms_my_trc_alloc = 0      ! set to zero if no array to be allocated
       !
-      IF( trc_sms_my_trc_alloc /= 0 ) CALL ctl_warn('trc_sms_my_trc_alloc : failed to allocate arrays')
+      IF( trc_sms_my_trc_alloc /= 0 ) CALL ctl_stop( 'STOP', 'trc_sms_my_trc_alloc : failed to allocate arrays' )
       !
    END FUNCTION trc_sms_my_trc_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P2Z/p2zbio.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 10425)
@@ -341,6 +341,6 @@
       !
       IF( lk_iomput ) THEN
-         CALL lbc_lnk( zw2d(:,:,:),'T', 1. )
-         CALL lbc_lnk_multi( zw3d(:,:,:,1),'T', 1., zw3d(:,:,:,2),'T', 1., zw3d(:,:,:,3),'T', 1. )
+         CALL lbc_lnk( 'p2zbio', zw2d(:,:,:),'T', 1. )
+         CALL lbc_lnk_multi( 'p2zbio', zw3d(:,:,:,1),'T', 1., zw3d(:,:,:,2),'T', 1., zw3d(:,:,:,3),'T', 1. )
          ! Save diagnostics
          CALL iom_put( "TNO3PHY", zw2d(:,:,1) )
Index: /NEMO/trunk/src/TOP/PISCES/P2Z/p2zexp.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P2Z/p2zexp.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P2Z/p2zexp.F90	(revision 10425)
@@ -113,5 +113,5 @@
       END DO
 
-      CALL lbc_lnk( sedpocn, 'T', 1. )
+      CALL lbc_lnk( 'p2zexp', sedpocn, 'T', 1. )
  
       ! Oa & Ek: diagnostics depending on jpdia2d !          left as example
@@ -229,6 +229,6 @@
          END DO
       END DO
-      CALL lbc_lnk( cmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
-      areacot = glob_sum( e1e2t(:,:) * cmask(:,:) )
+      CALL lbc_lnk( 'p2zexp', cmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
+      areacot = glob_sum( 'p2zexp', e1e2t(:,:) * cmask(:,:) )
       !
       IF( ln_rsttr ) THEN
@@ -248,5 +248,5 @@
       ALLOCATE( cmask(jpi,jpj) , dminl(jpi,jpj) , dmin3(jpi,jpj,jpk), &
          &      sedpocb(jpi,jpj) , sedpocn(jpi,jpj),   STAT=p2z_exp_alloc )
-      IF( p2z_exp_alloc /= 0 ) CALL ctl_warn('p2z_exp_alloc : failed to allocate arrays.')
+      IF( p2z_exp_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p2z_exp_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p2z_exp_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zche.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zche.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zche.F90	(revision 10425)
@@ -823,5 +823,5 @@
       p4z_che_alloc = MAXVAL( ierr )
       !
-      IF( p4z_che_alloc /= 0 )   CALL ctl_warn('p4z_che_alloc : failed to allocate arrays.')
+      IF( p4z_che_alloc /= 0 )   CALL ctl_stop( 'STOP', 'p4z_che_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p4z_che_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zflx.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zflx.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zflx.F90	(revision 10425)
@@ -172,7 +172,9 @@
       END DO
 
-      t_oce_co2_flx     = glob_sum( oce_co2(:,:) )                    !  Total Flux of Carbon
+      IF( iom_use("tcflx") .OR. iom_use("tcflxcum") .OR. kt == nitrst   &
+         &                 .OR. (ln_check_mass .AND. kt == nitend) )    &
+         t_oce_co2_flx  = glob_sum( 'p4zflx', oce_co2(:,:) )                    !  Total Flux of Carbon
       t_oce_co2_flx_cum = t_oce_co2_flx_cum + t_oce_co2_flx       !  Cumulative Total Flux of Carbon
-!      t_atm_co2_flx     = glob_sum( satmco2(:,:) * e1e2t(:,:) )       ! Total atmospheric pCO2
+!      t_atm_co2_flx     = glob_sum( 'p4zflx', satmco2(:,:) * e1e2t(:,:) )       ! Total atmospheric pCO2
       t_atm_co2_flx     =  atcco2      ! Total atmospheric pCO2
  
@@ -205,6 +207,6 @@
            CALL iom_put( "Dpo2"  , zw2d )
          ENDIF
-         IF( iom_use( "tcflx" ) )  CALL iom_put( "tcflx"    , t_oce_co2_flx * rfact2r )   ! molC/s
-         CALL iom_put( "tcflxcum" , t_oce_co2_flx_cum )      ! molC
+         CALL iom_put( "tcflx"    , t_oce_co2_flx * rfact2r )   ! molC/s
+         CALL iom_put( "tcflxcum" , t_oce_co2_flx_cum       )   ! molC
          !
          DEALLOCATE( zw2d )
@@ -376,5 +378,5 @@
       ALLOCATE( satmco2(jpi,jpj), patm(jpi,jpj), STAT=p4z_flx_alloc )
       !
-      IF( p4z_flx_alloc /= 0 )   CALL ctl_warn('p4z_flx_alloc : failed to allocate arrays')
+      IF( p4z_flx_alloc /= 0 )   CALL ctl_stop( 'STOP', 'p4z_flx_alloc : failed to allocate arrays' )
       !
    END FUNCTION p4z_flx_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zlim.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zlim.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zlim.F90	(revision 10425)
@@ -293,5 +293,5 @@
       !!                     ***  ROUTINE p5z_lim_alloc  ***
       !!----------------------------------------------------------------------
-      USE lib_mpp , ONLY: ctl_warn
+      USE lib_mpp , ONLY: ctl_stop
       !!----------------------------------------------------------------------
 
@@ -306,5 +306,5 @@
          &      xlimsi  (jpi,jpj,jpk), STAT=p4z_lim_alloc )
       !
-      IF( p4z_lim_alloc /= 0 ) CALL ctl_warn('p4z_lim_alloc : failed to allocate arrays.')
+      IF( p4z_lim_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p4z_lim_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p4z_lim_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zopt.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 10425)
@@ -463,5 +463,5 @@
                 ekg(jpi,jpj,jpk), STAT= p4z_opt_alloc  ) 
       !
-      IF( p4z_opt_alloc /= 0 ) CALL ctl_warn('p4z_opt_alloc : failed to allocate arrays.')
+      IF( p4z_opt_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p4z_opt_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p4z_opt_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zprod.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 10425)
@@ -340,5 +340,5 @@
     ! Total primary production per year
     IF( iom_use( "tintpp" ) .OR. ( ln_check_mass .AND. kt == nitend .AND. knt == nrdttrc )  )  &
-         & tpp = glob_sum( ( zprorcan(:,:,:) + zprorcad(:,:,:) ) * cvol(:,:,:) )
+         & tpp = glob_sum( 'p4zprod', ( zprorcan(:,:,:) + zprorcad(:,:,:) ) * cvol(:,:,:) )
 
     IF( lk_iomput ) THEN
@@ -529,5 +529,5 @@
       ALLOCATE( quotan(jpi,jpj,jpk), quotad(jpi,jpj,jpk), STAT = p4z_prod_alloc )
       !
-      IF( p4z_prod_alloc /= 0 ) CALL ctl_warn('p4z_prod_alloc : failed to allocate arrays.')
+      IF( p4z_prod_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p4z_prod_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p4z_prod_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zrem.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zrem.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zrem.F90	(revision 10425)
@@ -363,5 +363,5 @@
       ALLOCATE( denitr(jpi,jpj,jpk), STAT=p4z_rem_alloc )
       !
-      IF( p4z_rem_alloc /= 0 )   CALL ctl_warn('p4z_rem_alloc: failed to allocate arrays')
+      IF( p4z_rem_alloc /= 0 )   CALL ctl_stop( 'STOP', 'p4z_rem_alloc: failed to allocate arrays' )
       !
    END FUNCTION p4z_rem_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsbc.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 10425)
@@ -368,5 +368,5 @@
                ztimes_riv = 1._wp / REAL(ntimes_riv, wp) 
                DO jm = 1, ntimes_riv
-                  rivinput(ifpr) = rivinput(ifpr) + glob_sum( zriver(:,:,jm) * tmask(:,:,1) * ztimes_riv ) 
+                  rivinput(ifpr) = rivinput(ifpr) + glob_sum( 'p4zsbc', zriver(:,:,jm) * tmask(:,:,1) * ztimes_riv ) 
                END DO
                DEALLOCATE( zriver)
@@ -449,5 +449,5 @@
          END DO
          !
-         CALL lbc_lnk( zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
+         CALL lbc_lnk( 'p4zsbc', zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
          !
          DO jk = 1, jpk
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsed.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsed.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsed.F90	(revision 10425)
@@ -504,5 +504,5 @@
       ALLOCATE( nitrpot(jpi,jpj,jpk), sdenit(jpi,jpj), STAT=p4z_sed_alloc )
       !
-      IF( p4z_sed_alloc /= 0 )   CALL ctl_warn('p4z_sed_alloc: failed to allocate arrays')
+      IF( p4z_sed_alloc /= 0 )   CALL ctl_stop( 'STOP', 'p4z_sed_alloc: failed to allocate arrays' )
       !
    END FUNCTION p4z_sed_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsink.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsink.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsink.F90	(revision 10425)
@@ -127,5 +127,5 @@
      ! Total carbon export per year
      IF( iom_use( "tcexp" ) .OR. ( ln_check_mass .AND. kt == nitend .AND. knt == nrdttrc )  )  &
-        &   t_oce_co2_exp = glob_sum( ( sinking(:,:,ik100) + sinking2(:,:,ik100) ) * e1e2t(:,:) * tmask(:,:,1) )
+        &   t_oce_co2_exp = glob_sum( 'p4zsink', ( sinking(:,:,ik100) + sinking2(:,:,ik100) ) * e1e2t(:,:) * tmask(:,:,1) )
      !
      IF( lk_iomput ) THEN
@@ -220,5 +220,5 @@
       !
       p4z_sink_alloc = MAXVAL( ierr )
-      IF( p4z_sink_alloc /= 0 ) CALL ctl_warn('p4z_sink_alloc : failed to allocate arrays.')
+      IF( p4z_sink_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p4z_sink_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p4z_sink_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsms.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 10425)
@@ -361,10 +361,10 @@
             !                                                ! --------------------------- !
             ! set total alkalinity, phosphate, nitrate & silicate
-            zarea          = 1._wp / glob_sum( cvol(:,:,:) ) * 1e6              
-
-            zalksumn = glob_sum( trn(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
-            zpo4sumn = glob_sum( trn(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
-            zno3sumn = glob_sum( trn(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
-            zsilsumn = glob_sum( trn(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
+            zarea          = 1._wp / glob_sum( 'p4zsms', cvol(:,:,:) ) * 1e6              
+
+            zalksumn = glob_sum( 'p4zsms', trn(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
+            zpo4sumn = glob_sum( 'p4zsms', trn(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
+            zno3sumn = glob_sum( 'p4zsms', trn(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
+            zsilsumn = glob_sum( 'p4zsms', trn(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
  
             IF(lwp) WRITE(numout,*) '       TALKN mean : ', zalksumn
@@ -382,8 +382,8 @@
             !
             IF( .NOT. ln_top_euler ) THEN
-               zalksumb = glob_sum( trb(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
-               zpo4sumb = glob_sum( trb(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
-               zno3sumb = glob_sum( trb(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
-               zsilsumb = glob_sum( trb(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
+               zalksumb = glob_sum( 'p4zsms', trb(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
+               zpo4sumb = glob_sum( 'p4zsms', trb(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
+               zno3sumb = glob_sum( 'p4zsms', trb(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
+               zsilsumb = glob_sum( 'p4zsms', trb(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
  
                IF(lwp) WRITE(numout,*) ' '
@@ -449,5 +449,5 @@
         ENDIF
         !
-        no3budget = glob_sum( zwork(:,:,:) * cvol(:,:,:)  )  
+        no3budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )  
         no3budget = no3budget / areatot
         CALL iom_put( "pno3tot", no3budget )
@@ -467,5 +467,5 @@
         ENDIF
         !
-        po4budget = glob_sum( zwork(:,:,:) * cvol(:,:,:)  )  
+        po4budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )  
         po4budget = po4budget / areatot
         CALL iom_put( "ppo4tot", po4budget )
@@ -475,5 +475,5 @@
          zwork(:,:,:) =  trn(:,:,:,jpsil) + trn(:,:,:,jpgsi) + trn(:,:,:,jpdsi) 
          !
-         silbudget = glob_sum( zwork(:,:,:) * cvol(:,:,:)  )  
+         silbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )  
          silbudget = silbudget / areatot
          CALL iom_put( "psiltot", silbudget )
@@ -483,5 +483,5 @@
          zwork(:,:,:) =  trn(:,:,:,jpno3) * rno3 + trn(:,:,:,jptal) + trn(:,:,:,jpcal) * 2.              
          !
-         alkbudget = glob_sum( zwork(:,:,:) * cvol(:,:,:)  )         !
+         alkbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )         !
          alkbudget = alkbudget / areatot
          CALL iom_put( "palktot", alkbudget )
@@ -493,5 +493,5 @@
             &         + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) )  * ferat3    
          !
-         ferbudget = glob_sum( zwork(:,:,:) * cvol(:,:,:)  )  
+         ferbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )  
          ferbudget = ferbudget / areatot
          CALL iom_put( "pfertot", ferbudget )
@@ -502,16 +502,16 @@
       ! --------------------------------------------------------------------------------
       IF( iom_use( "tnfix" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
-         znitrpottot  = glob_sum ( nitrpot(:,:,:) * nitrfix * cvol(:,:,:) )
+         znitrpottot  = glob_sum ( 'p4zsms', nitrpot(:,:,:) * nitrfix * cvol(:,:,:) )
          CALL iom_put( "tnfix"  , znitrpottot * xfact3 )  ! Global  nitrogen fixation molC/l  to molN/m3 
       ENDIF
       !
       IF( iom_use( "tdenit" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
-         zrdenittot = glob_sum ( denitr(:,:,:) * rdenit * xnegtr(:,:,:) * cvol(:,:,:) )
-         zsdenittot = glob_sum ( sdenit(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+         zrdenittot = glob_sum ( 'p4zsms', denitr(:,:,:) * rdenit * xnegtr(:,:,:) * cvol(:,:,:) )
+         zsdenittot = glob_sum ( 'p4zsms', sdenit(:,:) * e1e2t(:,:) * tmask(:,:,1) )
          CALL iom_put( "tdenit" , ( zrdenittot + zsdenittot ) * xfact3 )  ! Total denitrification molC/l to molN/m3 
       ENDIF
       !
       IF( ln_check_mass .AND. kt == nitend ) THEN   ! Compute the budget of NO3, ALK, Si, Fer
-         t_atm_co2_flx  = t_atm_co2_flx / glob_sum( e1e2t(:,:) )
+         t_atm_co2_flx  = t_atm_co2_flx / glob_sum( 'p4zsms', e1e2t(:,:) )
          t_oce_co2_flx  = t_oce_co2_flx         * xfact1 * (-1 )
          tpp            = tpp           * 1000. * xfact1
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p5zlim.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p5zlim.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p5zlim.F90	(revision 10425)
@@ -535,5 +535,5 @@
       !!                     ***  ROUTINE p5z_lim_alloc  ***
       !!----------------------------------------------------------------------
-      USE lib_mpp , ONLY: ctl_warn
+      USE lib_mpp , ONLY: ctl_stop
       INTEGER ::   ierr(2)        ! Local variables
       !!----------------------------------------------------------------------
@@ -559,5 +559,5 @@
       p5z_lim_alloc = MAXVAL( ierr )
       !
-      IF( p5z_lim_alloc /= 0 ) CALL ctl_warn('p5z_lim_alloc : failed to allocate arrays.')
+      IF( p5z_lim_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p5z_lim_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p5z_lim_alloc
Index: /NEMO/trunk/src/TOP/PISCES/P4Z/p5zprod.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/P4Z/p5zprod.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/P4Z/p5zprod.F90	(revision 10425)
@@ -462,5 +462,5 @@
     ! Total primary production per year
     IF( iom_use( "tintpp" ) .OR. ( ln_check_mass .AND. kt == nitend .AND. knt == nrdttrc )  )  &
-      & tpp = glob_sum( ( zprorcan(:,:,:) + zprorcad(:,:,:) + zprorcap(:,:,:) ) * cvol(:,:,:) )
+      & tpp = glob_sum( 'p5zprod', ( zprorcan(:,:,:) + zprorcad(:,:,:) + zprorcap(:,:,:) ) * cvol(:,:,:) )
 
     IF( lk_iomput ) THEN
@@ -624,5 +624,5 @@
       ALLOCATE( zdaylen(jpi,jpj), STAT = p5z_prod_alloc )
       !
-      IF( p5z_prod_alloc /= 0 ) CALL ctl_warn('p5z_prod_alloc : failed to allocate arrays.')
+      IF( p5z_prod_alloc /= 0 ) CALL ctl_stop( 'STOP', 'p5z_prod_alloc : failed to allocate arrays.' )
       !
    END FUNCTION p5z_prod_alloc
Index: /NEMO/trunk/src/TOP/PISCES/SED/sed.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/SED/sed.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/SED/sed.F90	(revision 10425)
@@ -154,5 +154,5 @@
       !!                    *** ROUTINE sed_alloc ***
       !!-------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_stop
       !!-------------------------------------------------------------------
       !
@@ -166,5 +166,5 @@
          &      mol_wgt(jpsol),                                           STAT=sed_alloc )
 
-      IF( sed_alloc /= 0 )   CALL ctl_warn('sed_alloc: failed to allocate arrays')
+      IF( sed_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sed_alloc: failed to allocate arrays' )
       !
    END FUNCTION sed_alloc
Index: /NEMO/trunk/src/TOP/PISCES/SED/sed_oce.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/SED/sed_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/SED/sed_oce.F90	(revision 10425)
@@ -25,10 +25,10 @@
       !!                    *** ROUTINE sed_alloc ***
       !!-------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_stop
       !!-------------------------------------------------------------------
       !
       ALLOCATE( profsed(jpksed) , profsedw(jpksed) , STAT=sed_oce_alloc )
 
-      IF( sed_oce_alloc /= 0 )   CALL ctl_warn('sed_oce_alloc: failed to allocate arrays')
+      IF( sed_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sed_oce_alloc: failed to allocate arrays' )
       !
    END FUNCTION sed_oce_alloc
Index: /NEMO/trunk/src/TOP/PISCES/SED/sedadv.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/SED/sedadv.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/SED/sedadv.F90	(revision 10425)
@@ -436,5 +436,5 @@
       &         ckpor(jpksed) ,           STAT = sed_adv_alloc )
       !
-      IF( sed_adv_alloc /= 0 ) CALL ctl_warn('sed_adv_alloc : failed to allocate arrays.')
+      IF( sed_adv_alloc /= 0 ) CALL ctl_stop( 'STOP', 'sed_adv_alloc : failed to allocate arrays.' )
       !
    END FUNCTION sed_adv_alloc
Index: /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90	(revision 10425)
@@ -78,5 +78,5 @@
          IF(lwp) WRITE(numsed,*) &
              '             open sed restart.output NetCDF file: ',TRIM(clpath)//clname
-         CALL iom_open( TRIM(clpath)//TRIM(clname), numrsw, ldwrt = .TRUE., kiolib = jprstlib, kdlev = jpksed )
+         CALL iom_open( TRIM(clpath)//TRIM(clname), numrsw, ldwrt = .TRUE., kdlev = jpksed )
          lrst_sed = .TRUE.
       ENDIF
@@ -105,5 +105,4 @@
       CHARACTER(len = 20) ::   cltra
       CHARACTER(LEN=20)   ::   name1
-      INTEGER             ::   jlibalt = jprstlib
       LOGICAL             ::   llok
       !--------------------------------------------------------------------
@@ -338,5 +337,4 @@
       CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
       !
-      INTEGER  ::  jlibalt = jprstlib
       LOGICAL  ::  llok
       REAL(wp) ::  zkt, zrdttrc1
@@ -353,5 +351,5 @@
 
          IF( ln_rst_sed ) THEN
-            CALL iom_open( TRIM(cn_sedrst_indir)//'/'//cn_sedrst_in, numrsr, kiolib = jlibalt )
+            CALL iom_open( TRIM(cn_sedrst_indir)//'/'//cn_sedrst_in, numrsr )
             CALL iom_get ( numrsr, 'kt', zkt )   ! last time-step of previous run
 
Index: /NEMO/trunk/src/TOP/PISCES/sms_pisces.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/sms_pisces.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/sms_pisces.F90	(revision 10425)
@@ -131,5 +131,5 @@
       !!        *** ROUTINE sms_pisces_alloc ***
       !!----------------------------------------------------------------------
-      USE lib_mpp , ONLY: ctl_warn
+      USE lib_mpp , ONLY: ctl_stop
       INTEGER ::   ierr(10)        ! Local variables
       !!----------------------------------------------------------------------
@@ -186,5 +186,5 @@
       sms_pisces_alloc = MAXVAL( ierr )
       !
-      IF( sms_pisces_alloc /= 0 )   CALL ctl_warn('sms_pisces_alloc: failed to allocate arrays') 
+      IF( sms_pisces_alloc /= 0 )   CALL ctl_stop( 'STOP', 'sms_pisces_alloc: failed to allocate arrays' ) 
       !
    END FUNCTION sms_pisces_alloc
Index: /NEMO/trunk/src/TOP/PISCES/trcini_pisces.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/trcini_pisces.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/PISCES/trcini_pisces.F90	(revision 10425)
@@ -118,5 +118,5 @@
       ierr = ierr +  p4z_rem_alloc()
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'trcini_pisces', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'pisces_alloc: unable to allocate PISCES arrays' )
       !
@@ -311,5 +311,5 @@
       ierr = ierr + p2z_exp_alloc()
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'trcini_pisces', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'p2z_ini: unable to allocate LOBSTER arrays' )
 
Index: /NEMO/trunk/src/TOP/TRP/trcnxt.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trcnxt.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trcnxt.F90	(revision 10425)
@@ -97,5 +97,5 @@
 #endif
       ! Update after tracer on domain lateral boundaries
-      CALL lbc_lnk( tra(:,:,:,:), 'T', 1. )   
+      CALL lbc_lnk( 'trcnxt', tra(:,:,:,:), 'T', 1. )   
 
       IF( ln_bdy )  CALL trc_bdy( kt )
@@ -164,5 +164,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( trb(:,:,:,:), 'T', 1._wp, trn(:,:,:,:), 'T', 1._wp, tra(:,:,:,:), 'T', 1._wp )
+         CALL lbc_lnk_multi( 'trcnxt', trb(:,:,:,:), 'T', 1._wp, trn(:,:,:,:), 'T', 1._wp, tra(:,:,:,:), 'T', 1._wp )
       ENDIF
       !
Index: /NEMO/trunk/src/TOP/TRP/trcrad.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trcrad.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trcrad.F90	(revision 10425)
@@ -19,4 +19,5 @@
    USE trdtra
    USE prtctl_trc          ! Print control for debbuging
+   USE lib_fortran
 
    IMPLICIT NONE
@@ -27,4 +28,5 @@
 
    LOGICAL , PUBLIC ::   ln_trcrad           !: flag to artificially correct negative concentrations
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE::   gainmass
 
    !!----------------------------------------------------------------------
@@ -104,4 +106,7 @@
          ENDIF
       ENDIF
+      !
+      ALLOCATE( gainmass(jptra,2) )
+      gainmass(:,:) = 0.
       !
    END SUBROUTINE trc_rad_ini
@@ -129,73 +134,47 @@
       CHARACTER( len = 1), OPTIONAL          , INTENT(in   ) ::   cpreserv           ! flag to preserve content or not
       !
-      INTEGER ::   ji, jj, jk, jn     ! dummy loop indices
-      LOGICAL ::   lldebug = .FALSE.           ! local logical
-      REAL(wp)::   ztrcorb, ztrmasb, zs2rdt    ! temporary scalars
-      REAL(wp)::   zcoef  , ztrcorn, ztrmasn   !    -         -
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrdb, ztrtrdn   ! workspace arrays
-      !!----------------------------------------------------------------------
-      !
-      IF( l_trdtrc )   ALLOCATE( ztrtrdb(jpi,jpj,jpk), ztrtrdn(jpi,jpj,jpk) )
+      INTEGER ::   ji, ji2, jj, jj2, jk, jn     ! dummy loop indices
+      INTEGER ::   icnt
+      LOGICAL ::   lldebug = .FALSE.            ! local logical
+      REAL(wp)::   zcoef, zs2rdt, ztotmass
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrneg, ztrpos
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd   ! workspace arrays
+      !!----------------------------------------------------------------------
+      !
+      IF( l_trdtrc )   ALLOCATE( ztrtrd(jpi,jpj,jpk) )
+      zs2rdt = 1. / ( 2. * rdt * REAL( nn_dttrc, wp ) )
       !
       IF( PRESENT( cpreserv )  ) THEN     !==  total tracer concentration is preserved  ==!
          !
-         DO jn = jp_sms0, jp_sms1
-            !
-            ztrcorb = 0._wp   ;   ztrmasb = 0._wp
-            ztrcorn = 0._wp   ;   ztrmasn = 0._wp
-            !
-            IF( l_trdtrc ) THEN
-               ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
-               ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
-            ENDIF
-            !                                                         ! sum over the global domain 
-            ztrcorb = glob_sum( MIN( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:) )
-            ztrcorn = glob_sum( MIN( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:) )
-            !
-            ztrmasb = glob_sum( MAX( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:) )
-            ztrmasn = glob_sum( MAX( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:) )
-            !
-            IF( ztrcorb /= 0 ) THEN
-               zcoef = 1. + ztrcorb / ztrmasb
-               DO jk = 1, jpkm1
-                  ptrb(:,:,jk,jn) = MAX( 0., ptrb(:,:,jk,jn) )
-                  ptrb(:,:,jk,jn) = ptrb(:,:,jk,jn) * zcoef * tmask(:,:,jk)
-               END DO
-            ENDIF
-            !
-            IF( ztrcorn /= 0 ) THEN
-               zcoef = 1. + ztrcorn / ztrmasn
-               DO jk = 1, jpkm1
-                  ptrn(:,:,jk,jn) = MAX( 0., ptrn(:,:,jk,jn) )
-                  ptrn(:,:,jk,jn) = ptrn(:,:,jk,jn) * zcoef * tmask(:,:,jk)
-               END DO
-            ENDIF
-            !
-            IF( l_trdtrc ) THEN
-               !
-               zs2rdt = 1. / ( 2. * rdt )
-               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
-               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
-               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrdb )       ! Asselin-like trend handling
-               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrdn )       ! standard     trend handling
-              !
-            ENDIF
-            !
-         END DO
-         !
-      ELSE                                !==  total CFC content is NOT strictly preserved  ==!
-         !
-         DO jn = jp_sms0, jp_sms1  
-            !
-            IF( l_trdtrc ) THEN
-               ztrtrdb(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
-               ztrtrdn(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
-            ENDIF
+         ALLOCATE( ztrneg(1:jpi,1:jpj,jp_sms0:jp_sms1), ztrpos(1:jpi,1:jpj,jp_sms0:jp_sms1) )
+
+         DO jn = jp_sms0, jp_sms1
+            ztrneg(:,:,jn) = SUM( MIN( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the negative values
+            ztrpos(:,:,jn) = SUM( MAX( 0., ptrb(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the positive values
+         END DO
+         CALL sum3x3( ztrneg )
+         CALL sum3x3( ztrpos )
+         
+         DO jn = jp_sms0, jp_sms1
+            !
+            IF( l_trdtrc )   ztrtrd(:,:,:) = ptrb(:,:,:,jn)                            ! save input trb for trend computation           
             !
             DO jk = 1, jpkm1
                DO jj = 1, jpj
                   DO ji = 1, jpi
-                     ptrn(ji,jj,jk,jn) = MAX( 0. , ptrn(ji,jj,jk,jn) )
-                     ptrb(ji,jj,jk,jn) = MAX( 0. , ptrb(ji,jj,jk,jn) )
+                     IF( ztrneg(ji,jj,jn) /= 0. ) THEN                                 ! if negative values over the 3x3 box
+                        !
+                        ptrb(ji,jj,jk,jn) = ptrb(ji,jj,jk,jn) * tmask(ji,jj,jk)   ! really needed?
+                        IF( ptrb(ji,jj,jk,jn) < 0. ) ptrb(ji,jj,jk,jn) = 0.       ! supress negative values
+                        IF( ptrb(ji,jj,jk,jn) > 0. ) THEN                         ! use positive values to compensate mass gain
+                           zcoef = 1. + ztrneg(ji,jj,jn) / ztrpos(ji,jj,jn)       ! ztrpos > 0 as ptrb > 0
+                           ptrb(ji,jj,jk,jn) = ptrb(ji,jj,jk,jn) * zcoef
+                           IF( zcoef < 0. ) THEN                                  ! if the compensation exceed the positive value
+                              gainmass(jn,1) = gainmass(jn,1) - ptrb(ji,jj,jk,jn) * cvol(ji,jj,jk)   ! we are adding mass...
+                              ptrb(ji,jj,jk,jn) = 0.                              ! limit the compensation to keep positive value
+                           ENDIF
+                        ENDIF
+                        !
+                     ENDIF
                   END DO
                END DO
@@ -203,11 +182,93 @@
             !
             IF( l_trdtrc ) THEN
-               !
-               zs2rdt = 1. / ( 2. * rdt * REAL( nn_dttrc, wp ) )
-               ztrtrdb(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrdb(:,:,:) ) * zs2rdt
-               ztrtrdn(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrdn(:,:,:) ) * zs2rdt 
-               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrdb )       ! Asselin-like trend handling
-               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrdn )       ! standard     trend handling
-              !
+               ztrtrd(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt
+               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling
+            ENDIF
+            !
+         END DO
+ 
+         IF( kt == nitend ) THEN
+            CALL mpp_sum( 'trcrad', gainmass(:,1) )
+            DO jn = jp_sms0, jp_sms1
+               IF( gainmass(jn,1) > 0. ) THEN
+                  ztotmass = glob_sum( 'trcrad', ptrb(:,:,:,jn) * cvol(:,:,:) )
+                  IF(lwp) WRITE(numout, '(a, i2, a, D23.16, a, D23.16)') 'trcrad ptrb, traceur ', jn  &
+                     &        , ' total mass : ', ztotmass, ', mass gain : ',  gainmass(jn,1)
+               END IF
+            END DO
+         ENDIF
+
+         DO jn = jp_sms0, jp_sms1
+            ztrneg(:,:,jn) = SUM( MIN( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the negative values
+            ztrpos(:,:,jn) = SUM( MAX( 0., ptrn(:,:,:,jn) ) * cvol(:,:,:), dim = 3 )   ! sum of the positive values
+         END DO
+         CALL sum3x3( ztrneg )
+         CALL sum3x3( ztrpos )
+         
+         DO jn = jp_sms0, jp_sms1
+            !
+            IF( l_trdtrc )   ztrtrd(:,:,:) = ptrn(:,:,:,jn)                            ! save input trb for trend computation
+            !
+            DO jk = 1, jpkm1
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     IF( ztrneg(ji,jj,jn) /= 0. ) THEN                                 ! if negative values over the 3x3 box
+                        !
+                        ptrn(ji,jj,jk,jn) = ptrn(ji,jj,jk,jn) * tmask(ji,jj,jk)   ! really needed?
+                        IF( ptrn(ji,jj,jk,jn) < 0. ) ptrn(ji,jj,jk,jn) = 0.       ! supress negative values
+                        IF( ptrn(ji,jj,jk,jn) > 0. ) THEN                         ! use positive values to compensate mass gain
+                           zcoef = 1. + ztrneg(ji,jj,jn) / ztrpos(ji,jj,jn)       ! ztrpos > 0 as ptrb > 0
+                           ptrn(ji,jj,jk,jn) = ptrn(ji,jj,jk,jn) * zcoef
+                           IF( zcoef < 0. ) THEN                                  ! if the compensation exceed the positive value
+                              gainmass(jn,2) = gainmass(jn,2) - ptrn(ji,jj,jk,jn) * cvol(ji,jj,jk)   ! we are adding mass...
+                              ptrn(ji,jj,jk,jn) = 0.                              ! limit the compensation to keep positive value
+                           ENDIF
+                        ENDIF
+                        !
+                     ENDIF
+                  END DO
+               END DO
+            END DO
+            !
+            IF( l_trdtrc ) THEN
+               ztrtrd(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt
+               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrd )       ! standard     trend handling
+            ENDIF
+            !
+         END DO
+ 
+         IF( kt == nitend ) THEN
+            CALL mpp_sum( 'trcrad', gainmass(:,2) )
+            DO jn = jp_sms0, jp_sms1
+               IF( gainmass(jn,2) > 0. ) THEN
+                  ztotmass = glob_sum( 'trcrad', ptrn(:,:,:,jn) * cvol(:,:,:) )
+                  WRITE(numout, '(a, i2, a, D23.16, a, D23.16)') 'trcrad ptrn, traceur ', jn  &
+                     &        , ' total mass : ', ztotmass, ', mass gain : ',  gainmass(jn,1)
+               END IF
+            END DO
+         ENDIF
+
+         DEALLOCATE( ztrneg, ztrpos )
+         !
+      ELSE                                !==  total CFC content is NOT strictly preserved  ==!
+         !
+         DO jn = jp_sms0, jp_sms1  
+            !
+            IF( l_trdtrc )   ztrtrd(:,:,:) = ptrb(:,:,:,jn)                        ! save input trb for trend computation
+            !
+            WHERE( ptrb(:,:,:,jn) < 0. )   ptrb(:,:,:,jn) = 0.
+            !
+            IF( l_trdtrc ) THEN
+               ztrtrd(:,:,:) = ( ptrb(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt
+               CALL trd_tra( kt, 'TRC', jn, jptra_radb, ztrtrd )       ! Asselin-like trend handling
+            ENDIF
+            !
+            IF( l_trdtrc )   ztrtrd(:,:,:) = ptrn(:,:,:,jn)                        ! save input trn for trend computation
+            !
+            WHERE( ptrn(:,:,:,jn) < 0. )   ptrn(:,:,:,jn) = 0.
+            !
+            IF( l_trdtrc ) THEN
+               ztrtrd(:,:,:) = ( ptrn(:,:,:,jn) - ztrtrd(:,:,:) ) * zs2rdt
+               CALL trd_tra( kt, 'TRC', jn, jptra_radn, ztrtrd )       ! standard     trend handling
             ENDIF
             !
@@ -216,5 +277,5 @@
       ENDIF
       !
-      IF( l_trdtrc )  DEALLOCATE( ztrtrdb, ztrtrdn )
+      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
       !
    END SUBROUTINE trc_rad_sms
Index: /NEMO/trunk/src/TOP/TRP/trcsbc.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trcsbc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trcsbc.F90	(revision 10425)
@@ -113,9 +113,7 @@
 
       ! 0. initialization
-      DO jn = 1, jptra
-         !
-         IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
-         !
-         IF( nn_ice_tr == -1 ) THEN    ! No tracers in sea ice (null concentration in sea ice)
+      IF( nn_ice_tr == -1 ) THEN    ! No tracers in sea ice (null concentration in sea ice)
+         !
+         DO jn = 1, jptra
             DO jj = 2, jpj
                DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -123,5 +121,9 @@
                END DO
             END DO
-         ELSE
+         END DO
+         !
+       ELSE
+         !
+         DO jn = 1, jptra
             DO jj = 2, jpj
                DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -143,8 +145,13 @@
                END DO
             END DO
-         ENDIF
-         !
-         CALL lbc_lnk( sbc_trc(:,:,jn), 'T', 1. )
-         !                                       Concentration dilution effect on tracers due to evaporation & precipitation 
+         END DO
+      ENDIF
+      !
+      CALL lbc_lnk( 'trcsbc', sbc_trc(:,:,:), 'T', 1. )
+      !                                       Concentration dilution effect on tracers due to evaporation & precipitation 
+      DO jn = 1, jptra
+         !
+         IF( l_trdtrc )   ztrtrd(:,:,:) = tra(:,:,:,jn)  ! save trends
+         !
          DO jj = 2, jpj
             DO ji = fs_2, fs_jpim1   ! vector opt.
Index: /NEMO/trunk/src/TOP/TRP/trdmxl_trc.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trdmxl_trc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trdmxl_trc.F90	(revision 10425)
@@ -64,6 +64,6 @@
          &      ndextrd1(jpi*jpj), nidtrd(jptra), nh_t(jptra),  STAT=trd_mxl_trc_alloc)
          !
-      IF( lk_mpp                )   CALL mpp_sum ( trd_mxl_trc_alloc )
-      IF( trd_mxl_trc_alloc /=0 )   CALL ctl_warn('trd_mxl_trc_alloc: failed to allocate arrays')
+      CALL mpp_sum ( 'trdmxl_trc', trd_mxl_trc_alloc )
+      IF( trd_mxl_trc_alloc /=0 )   CALL ctl_stop( 'STOP', 'trd_mxl_trc_alloc: failed to allocate arrays' )
       !
    END FUNCTION trd_mxl_trc_alloc
@@ -290,5 +290,5 @@
             IF( ln_trdtrc(jn) ) THEN
                DO jl = 1, jpltrd_trc
-                  CALL lbc_lnk( tmltrd_trc(:,:,jl,jn), 'T', 1. )        ! lateral boundary conditions
+                  CALL lbc_lnk( 'trdmxl_trc', tmltrd_trc(:,:,jl,jn), 'T', 1. )        ! lateral boundary conditions
                END DO
             ENDIF
@@ -425,5 +425,5 @@
          !-- Lateral boundary conditions
                IF ( cn_cfg .NE. 'gyre' ) THEN
-                  CALL lbc_lnk_multi( ztmltot(:,:,jn) , 'T', 1. , ztmlres(:,:,jn) , 'T', 1., &
+                  CALL lbc_lnk_multi( 'trdmxl_trc', ztmltot(:,:,jn) , 'T', 1. , ztmlres(:,:,jn) , 'T', 1., &
                      &                ztmlatf(:,:,jn) , 'T', 1. , ztmlrad(:,:,jn) , 'T', 1. )
                ENDIF
@@ -476,7 +476,7 @@
          !-- Lateral boundary conditions 
                IF ( cn_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration    
-                  CALL lbc_lnk_multi( ztmltot2(:,:,jn), 'T', 1., ztmlres2(:,:,jn), 'T', 1. )
+                  CALL lbc_lnk_multi( 'trdmxl_trc', ztmltot2(:,:,jn), 'T', 1., ztmlres2(:,:,jn), 'T', 1. )
                   DO jl = 1, jpltrd_trc
-                     CALL lbc_lnk( ztmltrd2(:,:,jl,jn), 'T', 1. )       ! will be output in the NetCDF trends file
+                     CALL lbc_lnk( 'trdmxl_trc', ztmltrd2(:,:,jl,jn), 'T', 1. )       ! will be output in the NetCDF trends file
                   END DO
                ENDIF
@@ -776,14 +776,13 @@
 
       IF( ( lk_trdmxl_trc ) .AND. ( MOD( nitend-nittrc000+1, nn_trd_trc ) /= 0 ) ) THEN
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '                Your nitend parameter, nitend = ', nitend
-         WRITE(numout,*) '                is no multiple of the trends diagnostics frequency        '
-         WRITE(numout,*) '                          you defined, nn_trd_trc   = ', nn_trd_trc
-         WRITE(numout,*) '                This will not allow you to restart from this simulation.  '
-         WRITE(numout,*) '                You should reconsider this choice.                        ' 
-         WRITE(numout,*) 
-         WRITE(numout,*) '                N.B. the nitend parameter is also constrained to be a     '
-         WRITE(numout,*) '                multiple of the sea-ice frequency parameter (typically 5) '
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '                Your nitend parameter, nitend = ', nitend
+         WRITE(ctmp2,*) '                is no multiple of the trends diagnostics frequency        '
+         WRITE(ctmp3,*) '                          you defined, nn_trd_trc   = ', nn_trd_trc
+         WRITE(ctmp4,*) '                This will not allow you to restart from this simulation.  '
+         WRITE(ctmp5,*) '                You should reconsider this choice.                        ' 
+         WRITE(ctmp6,*) 
+         WRITE(ctmp7,*) '                N.B. the nitend parameter is also constrained to be a     '
+         WRITE(ctmp8,*) '                multiple of the sea-ice frequency parameter (typically 5) '
+         CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7, ctmp8 )
       ENDIF
 
@@ -795,14 +794,12 @@
 
       IF( ( ln_trcadv_muscl .OR. ln_trcadv_muscl2 ) .AND. .NOT. ln_trdmxl_trc_instant ) THEN
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '                Currently, you can NOT use simultaneously tracer MUSCL    '
-         WRITE(numout,*) '                advection and window averaged diagnostics of ML trends.   '
-         WRITE(numout,*) '                WHY? Everything in trdmxl_trc is coded for leap-frog, and '
-         WRITE(numout,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
-         WRITE(numout,*) '                that MUSCL is leap-frog for active tracers T/S).          '
-         WRITE(numout,*) '                In particuliar, entrainment trend would be FALSE. However '
-         WRITE(numout,*) '                this residual is correct for instantaneous ML diagnostics.'
-         WRITE(numout,*) 
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '                Currently, you can NOT use simultaneously tracer MUSCL    '
+         WRITE(ctmp2,*) '                advection and window averaged diagnostics of ML trends.   '
+         WRITE(ctmp3,*) '                WHY? Everything in trdmxl_trc is coded for leap-frog, and '
+         WRITE(ctmp4,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
+         WRITE(ctmp5,*) '                that MUSCL is leap-frog for active tracers T/S).          '
+         WRITE(ctmp6,*) '                In particuliar, entrainment trend would be FALSE. However '
+         WRITE(ctmp7,*) '                this residual is correct for instantaneous ML diagnostics.'
+         CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7 )
       ENDIF
 
Index: /NEMO/trunk/src/TOP/TRP/trdmxl_trc_rst.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trdmxl_trc_rst.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trdmxl_trc_rst.F90	(revision 10425)
@@ -54,5 +54,5 @@
          IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
          IF(lwp) WRITE(numout,*) '             open ocean restart_mld_trc NetCDF  'TRIM(clpath)//TRIM(clname)
-         CALL iom_open( TRIM(clpath)//TRIM(clname), nummldw_trc, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clpath)//TRIM(clname), nummldw_trc, ldwrt = .TRUE. )
       ENDIF
 
@@ -127,5 +127,4 @@
       CHARACTER (len=35) :: charout
       INTEGER ::  jk, jn, jl     ! loop indice
-      INTEGER ::  jlibalt = jprstlib
       LOGICAL ::  llok
       CHARACTER(LEN=256)  ::   clpath   ! full path to restart file
@@ -140,5 +139,5 @@
       clpath = TRIM(cn_trcrst_indir)
       IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-      CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_trc_in), inum, kiolib = jlibalt ) 
+      CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_trc_in), inum ) 
       
       IF( ln_trdmxl_trc_instant ) THEN 
Index: /NEMO/trunk/src/TOP/TRP/trdtrc_oce.F90
===================================================================
--- /NEMO/trunk/src/TOP/TRP/trdtrc_oce.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/TRP/trdtrc_oce.F90	(revision 10425)
@@ -117,5 +117,5 @@
       !!         *** ROUTINE trd_trc_oce_alloc ***
       !!----------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_stop
       INTEGER :: ierr(2)
       !!----------------------------------------------------------------------
@@ -146,5 +146,5 @@
       trd_trc_oce_alloc = MAXVAL(ierr)
       !
-      IF( trd_trc_oce_alloc /= 0 )   CALL ctl_warn('trd_trc_oce_alloc: failed to allocate arrays')
+      IF( trd_trc_oce_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trd_trc_oce_alloc: failed to allocate arrays' )
       !
 # if defined key_trdmxl_trc
Index: /NEMO/trunk/src/TOP/trc.F90
===================================================================
--- /NEMO/trunk/src/TOP/trc.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trc.F90	(revision 10425)
@@ -141,5 +141,5 @@
       !!                    *** ROUTINE trc_alloc ***
       !!-------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_stop
       !!-------------------------------------------------------------------
       INTEGER :: ierr(4)
@@ -166,5 +166,5 @@
       ! 
       trc_alloc = MAXVAL( ierr )
-      IF( trc_alloc /= 0 )   CALL ctl_warn('trc_alloc: failed to allocate arrays')
+      IF( trc_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trc_alloc: failed to allocate arrays' )
       !
    END FUNCTION trc_alloc
Index: /NEMO/trunk/src/TOP/trcbdy.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcbdy.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcbdy.F90	(revision 10425)
@@ -71,5 +71,5 @@
             END SELECT
             ! Boundary points should be updated
-            CALL lbc_bdy_lnk( tra(:,:,:,jn), 'T', 1., ib_bdy )
+            CALL lbc_bdy_lnk( 'trcbdy', tra(:,:,:,jn), 'T', 1., ib_bdy )
             !
          END DO
Index: /NEMO/trunk/src/TOP/trcini.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcini.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcini.F90	(revision 10425)
@@ -72,5 +72,5 @@
       CALL trc_ice_ini   ! Tracers in sea ice
       !
-      IF(lwp) CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
+      IF(lwm) CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
       !
       CALL trc_ini_state  !  passive tracers initialisation : from a restart or from clim
@@ -119,9 +119,9 @@
       END DO
       !                          ! total volume of the ocean 
-      areatot = glob_sum( cvol(:,:,:) )
+      areatot = glob_sum( 'trcini', cvol(:,:,:) )
       !
       trai(:) = 0._wp            ! initial content of all tracers
       DO jn = 1, jptra
-         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
+         trai(jn) = trai(jn) + glob_sum( 'trcini', trn(:,:,:,jn) * cvol(:,:,:)   )
       END DO
 
@@ -292,5 +292,5 @@
 #endif
       !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'trcini', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
       !
Index: /NEMO/trunk/src/TOP/trcnam.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcnam.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcnam.F90	(revision 10425)
@@ -23,4 +23,7 @@
    USE trdtrc_oce  !
    USE iom         ! I/O manager
+#if defined key_mpp_mpi
+   USE lib_mpp, ONLY: ncom_dttrc
+#endif
 
    IMPLICIT NONE
@@ -76,5 +79,5 @@
       ENDIF
       !
-      rdttrc = rdt * FLOAT( nn_dttrc )          ! passive tracer time-step
+      rdttrc = rdt * FLOAT( nn_dttrc )          ! passive tracer time-step      
       ! 
       IF(lwp) THEN                              ! control print
@@ -128,5 +131,9 @@
       ENDIF
       !
-    END SUBROUTINE trc_nam_run
+#if defined key_mpp_mpi
+      ncom_dttrc = nn_dttrc    ! make nn_fsbc available for lib_mpp
+#endif
+      !
+   END SUBROUTINE trc_nam_run
 
 
Index: /NEMO/trunk/src/TOP/trcrst.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcrst.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcrst.F90	(revision 10425)
@@ -23,4 +23,5 @@
    USE iom
    USE daymod
+   USE lib_mpp
    
    IMPLICIT NONE
@@ -87,5 +88,5 @@
          IF(lwp) WRITE(numout,*) &
              '             open trc restart.output NetCDF file: ',TRIM(clpath)//clname
-         CALL iom_open( TRIM(clpath)//TRIM(clname), numrtw, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clpath)//TRIM(clname), numrtw, ldwrt = .TRUE. )
          lrst_trc = .TRUE.
       ENDIF
@@ -116,4 +117,6 @@
       END DO
       !
+      CALL iom_delay_rst( 'READ', 'TOP', numrtr )   ! read only TOP delayed global communication variables
+      
    END SUBROUTINE trc_rst_read
 
@@ -127,5 +130,4 @@
       !!
       INTEGER  :: jn
-      REAL(wp) :: zarak0
       !!----------------------------------------------------------------------
       !
@@ -141,4 +143,6 @@
       END DO
       !
+      CALL iom_delay_rst( 'WRITE', 'TOP', numrtw )   ! save only TOP delayed global communication variables
+    
       IF( kt == nitrst ) THEN
           CALL trc_rst_stat            ! statistics
@@ -184,5 +188,4 @@
       CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
       !
-      INTEGER  ::  jlibalt = jprstlib
       LOGICAL  ::  llok
       REAL(wp) ::  zrdttrc1, zkt, zndastp, zdayfrac, ksecs, ktime
@@ -199,5 +202,5 @@
 
          IF( ln_rsttr ) THEN
-            CALL iom_open( TRIM(cn_trcrst_indir)//'/'//cn_trcrst_in, numrtr, kiolib = jlibalt )
+            CALL iom_open( TRIM(cn_trcrst_indir)//'/'//cn_trcrst_in, numrtr )
             CALL iom_get ( numrtr, 'kt', zkt )   ! last time-step of previous run
 
@@ -316,10 +319,10 @@
       !
       DO jn = 1, jptra
-         ztraf = glob_sum( trn(:,:,:,jn) * zvol(:,:,:) )
+         ztraf = glob_sum( 'trcrst', trn(:,:,:,jn) * zvol(:,:,:) )
          zmin  = MINVAL( trn(:,:,:,jn), mask= ((tmask*SPREAD(tmask_i,DIM=3,NCOPIES=jpk).NE.0.)) )
          zmax  = MAXVAL( trn(:,:,:,jn), mask= ((tmask*SPREAD(tmask_i,DIM=3,NCOPIES=jpk).NE.0.)) )
          IF( lk_mpp ) THEN
-            CALL mpp_min( zmin )      ! min over the global domain
-            CALL mpp_max( zmax )      ! max over the global domain
+            CALL mpp_min( 'trcrst', zmin )      ! min over the global domain
+            CALL mpp_max( 'trcrst', zmax )      ! max over the global domain
          END IF
          zmean  = ztraf / areatot
Index: /NEMO/trunk/src/TOP/trcstp.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcstp.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcstp.F90	(revision 10425)
@@ -20,4 +20,5 @@
    USE trdtrc_oce
    USE trdmxl_trc
+   USE sms_pisces,  ONLY : ln_check_mass
    !
    USE prtctl_trc     ! Print control for debbuging
@@ -73,5 +74,8 @@
             cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk)
          END DO
-         areatot         = glob_sum( cvol(:,:,:) )
+         IF ( ln_ctl .OR. kt == nitrst .OR. ( ln_check_mass .AND. kt == nitend )              &
+            & .OR. iom_use( "pno3tot" ) .OR. iom_use( "ppo4tot" ) .OR. iom_use( "psiltot" )   &
+            & .OR. iom_use( "palktot" ) .OR. iom_use( "pfertot" ) )                           &
+            &     areatot = glob_sum( 'trcstp', cvol(:,:,:) )
       ENDIF
       !
@@ -105,9 +109,11 @@
       ENDIF
       !
-      ztrai = 0._wp                                                   !  content of all tracers
-      DO jn = 1, jptra
-         ztrai = ztrai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
-      END DO
-      IF( lwp ) WRITE(numstr,9300) kt,  ztrai / areatot
+      IF (ln_ctl ) THEN
+         ztrai = 0._wp                                                   !  content of all tracers
+         DO jn = 1, jptra
+            ztrai = ztrai + glob_sum( 'trcstp', trn(:,:,:,jn) * cvol(:,:,:)   )
+         END DO
+         IF( lwm ) WRITE(numstr,9300) kt,  ztrai / areatot
+      ENDIF
 9300  FORMAT(i10,D23.16)
       !
Index: /NEMO/trunk/src/TOP/trcsub.F90
===================================================================
--- /NEMO/trunk/src/TOP/trcsub.F90	(revision 10424)
+++ /NEMO/trunk/src/TOP/trcsub.F90	(revision 10425)
@@ -308,5 +308,5 @@
 
       ierr =  trc_sub_alloc    ()
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
+      CALL mpp_sum( 'trcsub', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_sub_alloc : unable to allocate standard ocean arrays' )
 
@@ -510,5 +510,5 @@
          IF( ln_bdy ) THEN
             ssha(:,:) = ssha(:,:) * bdytmask(:,:)
-            CALL lbc_lnk( ssha, 'T', 1. ) 
+            CALL lbc_lnk( 'trcsub', ssha, 'T', 1. ) 
          ENDIF
       ENDIF
@@ -535,5 +535,5 @@
       !!                    *** ROUTINE trc_sub_alloc ***
       !!-------------------------------------------------------------------
-      USE lib_mpp, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_stop
       INTEGER ::  ierr(3)
       !!-------------------------------------------------------------------
@@ -577,5 +577,5 @@
       trc_sub_alloc = MAXVAL( ierr )
       !
-      IF( trc_sub_alloc /= 0 )   CALL ctl_warn('trc_sub_alloc: failed to allocate arrays')
+      IF( trc_sub_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trc_sub_alloc: failed to allocate arrays' )
       !
    END FUNCTION trc_sub_alloc
Index: /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025	(revision 10425)
@@ -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/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca1
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca1	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca1	(revision 10425)
@@ -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/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12	(revision 10425)
@@ -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/trunk/tests/BENCH/EXPREF/namelist_cfg_orca025_like
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 10425)
@@ -0,0 +1,223 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! 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   = .false.   !  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)
+  ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+/
+
+!
+!!======================================================================
+!!               ***  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)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
+!-----------------------------------------------------------------------
+   !                       !  type of penetration                        (default: NO selection)
+   ln_qsr_rgb  = .true.      !  RGB light penetration (Red-Green-Blue)
+   nn_chldta   =      0      !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&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/trunk/tests/BENCH/EXPREF/namelist_cfg_orca12_like
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 10425)
@@ -0,0 +1,219 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! 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   = .false.   !  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)
+  ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+/
+
+!
+!!======================================================================
+!!               ***  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)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
+!-----------------------------------------------------------------------
+   !                       !  type of penetration                        (default: NO selection)
+   ln_qsr_rgb  = .true.      !  RGB light penetration (Red-Green-Blue)
+   nn_chldta   =      0      !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&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/trunk/tests/BENCH/EXPREF/namelist_cfg_orca1_like
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 10425)
@@ -0,0 +1,222 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! 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   = .false.   !  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)
+  ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+/
+
+!
+!!======================================================================
+!!               ***  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)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
+!-----------------------------------------------------------------------
+   !                       !  type of penetration                        (default: NO selection)
+   ln_qsr_rgb  = .true.      !  RGB light penetration (Red-Green-Blue)
+   nn_chldta   =      0      !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&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/trunk/tests/BENCH/EXPREF/namelist_ice_cfg
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_ice_cfg	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_ice_cfg	(revision 10425)
@@ -0,0 +1,84 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! SI3 configuration namelist: Overwrites SHARED/namelist_ice_ref
+!!              1 - Generic parameters                 (nampar)
+!!              2 - Ice thickness discretization       (namitd)
+!!              3 - Ice dynamics                       (namdyn)
+!!              4 - Ice ridging/rafting                (namdyn_rdgrft)
+!!              5 - Ice rheology                       (namdyn_rhg)
+!!              6 - Ice advection                      (namdyn_adv)
+!!              7 - Ice surface forcing                (namforcing)
+!!              8 - Ice thermodynamics                 (namthd)
+!!              9 - Ice heat diffusion                 (namthd_zdf)
+!!             10 - Ice lateral melting                (namthd_da)
+!!             11 - Ice growth in open water           (namthd_do)
+!!             12 - Ice salinity                       (namthd_sal)
+!!             13 - Ice melt ponds                     (namthd_pnd)
+!!             14 - Ice initialization                 (namini)
+!!             15 - Ice/snow albedos                   (namalb)
+!!             16 - Ice diagnostics                    (namdia)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!------------------------------------------------------------------------------
+&nampar         !   Generic parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namitd         !   Ice discretization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn         !   Ice dynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rdgrft  !   Ice ridging/rafting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rhg     !   Ice rheology
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_adv     !   Ice advection
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namforcing     !   Ice surface forcing
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd         !   Ice thermodynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_zdf     !   Ice heat diffusion
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_da      !   Ice lateral melting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_do      !   Ice growth in open water
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_sal     !   Ice salinity
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
+!------------------------------------------------------------------------------
+/
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_ice_ref
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_ice_ref	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_ice_ref	(revision 10425)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ice_ref
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_cfg
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_cfg	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_cfg	(revision 10425)
@@ -0,0 +1,140 @@
+!-----------------------------------------------------------------------
+&nampismod     !  Model used 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisext     !   air-sea exchange
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisatm     !  Atmospheric prrssure 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisbio     !   biological parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zice     !   parameters for nutrient limitations for PISCES std  - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zice     !   parameters for nutrient limitations PISCES QUOTA    - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zquota   !   parameters for nutrient limitations PISCES quota    - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisopt     !   parameters for optics
+!-----------------------------------------------------------------------
+   ln_varpar   =  .false.   ! boolean for PAR variable
+/ 
+!-----------------------------------------------------------------------
+&namp4zprod    !   parameters for phytoplankton growth for PISCES std  - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zprod    !   parameters for phytoplankton growth for PISCES quota- ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zmort    !   parameters for phytoplankton sinks for PISCES std   - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zmort    !   parameters for phytoplankton sinks for PISCES quota - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zmes     !   parameters for mesozooplankton for PISCES std       - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zmes     !   parameters for mesozooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zzoo     !   parameters for microzooplankton for PISCES std      - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zzoo     !   parameters for microzooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisfer     !   parameters for iron chemistry
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------  
+&nampisrem     !   parameters for remineralization
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampispoc     !   parameters for organic particles
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampiscal     !   parameters for Calcite chemistry
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampissbc     !   parameters for inputs deposition
+!-----------------------------------------------------------------------
+   ln_dust     =  .false.   ! boolean for dust input from the atmosphere
+   ln_solub    =  .false.   ! boolean for variable solubility of atm. Iron
+   ln_river    =  .false.   ! boolean for river input of nutrients
+   ln_ndepo    =  .false.   ! boolean for atmospheric deposition of N
+   ln_ironsed  =  .false.   ! boolean for Fe input from sediments
+   ln_ironice  =  .false.   ! boolean for Fe input from sea ice
+   ln_hydrofe  =  .false.  ! boolean for from hydrothermal vents
+/
+!-----------------------------------------------------------------------
+&nampislig     !   Namelist parameters for ligands, nampislig
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisice     !   Prescribed sea ice tracers
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisdmp     !   Damping 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampismass    !   Mass conservation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobphy     !   biological parameters for phytoplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobnut     !   biological parameters for nutrients
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobzoo     !   biological parameters for zooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobdet     !   biological parameters for detritus
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobdom     !   biological parameters for DOM
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobsed     !   parameters from aphotic layers to sediment
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobrat     !   general coefficients
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobopt     !   optical parameters
+!-----------------------------------------------------------------------
+/
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_ref
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_ref	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_pisces_ref	(revision 10425)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_pisces_ref
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_ref
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_ref	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_ref	(revision 10425)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_cfg
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_cfg	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_cfg	(revision 10425)
@@ -0,0 +1,110 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_top_ref
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namtrc_run      !   run information
+!-----------------------------------------------------------------------
+   ln_top_euler  = .true.
+/
+!-----------------------------------------------------------------------
+&namtrc          !   tracers definition
+!-----------------------------------------------------------------------
+   jp_bgc        =  24
+!
+   ln_pisces     =  .true.
+   ln_my_trc     =  .false.
+   ln_age        =  .false.
+   ln_cfc11      =  .false.
+   ln_cfc12      =  .false.
+   ln_c14        =  .false.
+!
+   ln_trcdta     =  .false.  !  Initialisation from data input file (T) or not (F)
+!                 !           !                                          !             !
+!                 !    name   !           title of the field             !   units     ! initial data from file or not !
+!                 !           !                                          !             !
+   sn_tracer(1)   = 'DIC     ' , 'Dissolved inorganic Concentration      ',  'mol-C/L' ,  .true.
+   sn_tracer(2)   = 'Alkalini' , 'Total Alkalinity Concentration         ',  'eq/L '   ,  .true.
+   sn_tracer(3)   = 'O2      ' , 'Dissolved Oxygen Concentration         ',  'mol-C/L' ,  .true.
+   sn_tracer(4)   = 'CaCO3   ' , 'Calcite Concentration                  ',  'mol-C/L' ,  .false.
+   sn_tracer(5)   = 'PO4     ' , 'Phosphate Concentration                ',  'mol-C/L' ,  .true.
+   sn_tracer(6)   = 'POC     ' , 'Small organic carbon Concentration     ',  'mol-C/L' ,  .false.
+   sn_tracer(7)   = 'Si      ' , 'Silicate Concentration                 ',  'mol-C/L' ,  .true.
+   sn_tracer(8)   = 'PHY     ' , 'Nanophytoplankton Concentration        ',  'mol-C/L' ,  .false.
+   sn_tracer(9)   = 'ZOO     ' , 'Microzooplankton Concentration         ',  'mol-C/L' ,  .false.
+   sn_tracer(10)  = 'DOC     ' , 'Dissolved organic Concentration        ',  'mol-C/L' ,  .true.
+   sn_tracer(11)  = 'PHY2    ' , 'Diatoms Concentration                  ',  'mol-C/L' ,  .false.
+   sn_tracer(12)  = 'ZOO2    ' , 'Mesozooplankton Concentration          ',  'mol-C/L' ,  .false.
+   sn_tracer(13)  = 'DSi     ' , 'Diatoms Silicate Concentration         ',  'mol-C/L' ,  .false.
+   sn_tracer(14)  = 'Fer     ' , 'Dissolved Iron Concentration           ',  'mol-C/L' ,  .true.
+   sn_tracer(15)  = 'BFe     ' , 'Big iron particles Concentration       ',  'mol-C/L' ,  .false.
+   sn_tracer(16)  = 'GOC     ' , 'Big organic carbon Concentration       ',  'mol-C/L' ,  .false.
+   sn_tracer(17)  = 'SFe     ' , 'Small iron particles Concentration     ',  'mol-C/L' ,  .false.
+   sn_tracer(18)  = 'DFe     ' , 'Diatoms iron  Concentration            ',  'mol-C/L' ,  .false.
+   sn_tracer(19)  = 'GSi     ' , 'Sinking biogenic Silicate Concentration',  'mol-C/L' ,  .false.
+   sn_tracer(20)  = 'NFe     ' , 'Nano iron Concentration                ',  'mol-C/L' ,  .false.
+   sn_tracer(21)  = 'NCHL    ' , 'Nano chlorophyl Concentration          ',  'mol-C/L' ,  .false.
+   sn_tracer(22)  = 'DCHL    ' , 'Diatoms chlorophyl Concentration       ',  'mol-C/L' ,  .false.
+   sn_tracer(23)  = 'NO3     ' , 'Nitrates Concentration                 ',  'mol-C/L' ,  .true.
+   sn_tracer(24)  = 'NH4     ' , 'Ammonium Concentration                 ',  'mol-C/L' ,  .false.
+/
+!-----------------------------------------------------------------------
+&namage          !   AGE 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dta      !    Initialisation from data input file
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12        ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12        ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1         ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1         ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1         ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12        ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12        ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1         ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   rn_trfac(1)   =   1.0e-06  !  multiplicative factor
+   rn_trfac(2)   =   1.0e-06  !  -      -      -     -
+   rn_trfac(3)   =  44.6e-06  !  -      -      -     -
+   rn_trfac(5)   = 122.0e-06  !  -      -      -     -
+   rn_trfac(7)   =   1.0e-06  !  -      -      -     -
+   rn_trfac(10)  =   1.0      !  -      -      -     -
+   rn_trfac(14)  =   1.0      !  -      -      -     -
+   rn_trfac(23)  =   7.6e-06  !  -      -      -     -
+/
+!-----------------------------------------------------------------------
+&namtrc_adv      !   advection scheme for passive tracer                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_trcadv_mus =  .true.  !  MUSCL scheme
+      ln_mus_ups =  .false.         !  use upstream scheme near river mouths
+/
+!-----------------------------------------------------------------------
+&namtrc_ldf      !   lateral diffusion scheme for passive tracer        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_trcldf_tra   = .true.      !  use active tracer setting
+/
+!-----------------------------------------------------------------------
+&namtrc_rad      !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dmp      !   passive tracer newtonian damping   
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_ice      !    Representation of sea ice growth & melt effects
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_trd      !   diagnostics on tracer trends                       ('key_trdtrc')
+!----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------
+&namtrc_bc       !   data for boundary conditions
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------
+&namtrc_bdy      !   Setup of tracer boundary conditions
+!-----------------------------------------------------------------------
+/
Index: /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_ref
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_ref	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/namelist_top_ref	(revision 10425)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_top_ref
Index: /NEMO/trunk/tests/BENCH/EXPREF/sh_bench
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/sh_bench	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/sh_bench	(revision 10425)
@@ -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/trunk/tests/BENCH/EXPREF/submit_bench
===================================================================
--- /NEMO/trunk/tests/BENCH/EXPREF/submit_bench	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/EXPREF/submit_bench	(revision 10425)
@@ -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/trunk/tests/BENCH/MY_SRC/diawri.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/diawri.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/diawri.F90	(revision 10425)
@@ -0,0 +1,491 @@
+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 ice
+   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' )
+         ninist = 0
+      ENDIF
+
+      ! Output of initial vertical scale factor
+      CALL iom_put("e3t_0", e3t_0(:,:,:) )
+      CALL iom_put("e3u_0", e3u_0(:,:,:) )
+      CALL iom_put("e3v_0", e3v_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
+
+      IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
+         CALL dia_wri_state( 'output.init' )
+         ninist = 0
+      ENDIF
+
+   END SUBROUTINE dia_wri
+
+#endif
+
+   SUBROUTINE dia_wri_state( cdfile_name )
+      !!---------------------------------------------------------------------
+      !!                 ***  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 :: inum
+      !!----------------------------------------------------------------------
+      ! 
+      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 :', cdfile_name, '...nc'
+
+#if defined key_si3
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
+#else
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+#endif
+
+      CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature
+      CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity
+      CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height
+      CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
+      CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
+      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
+      IF( ALLOCATED(ahtu) ) THEN
+         CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahtv', ahtv              )    ! aht at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL iom_rstput( 0, 0, inum,  'ahmt', ahmt              )    ! ahmt at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahmf', ahmf              )    ! ahmf at v-point
+      ENDIF
+      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
+      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
+      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
+      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
+      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
+      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL iom_rstput( 0, 0, inum, 'vovvldep', gdept_n        )    !  T-cell depth 
+         CALL iom_rstput( 0, 0, inum, 'vovvle3t', e3t_n          )    !  T-cell thickness  
+      END IF
+      IF( ln_wave .AND. ln_sdw ) THEN
+         CALL iom_rstput( 0, 0, inum, 'sdzocrtx', usd            )    ! now StokesDrift i-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdmecrty', vsd            )    ! now StokesDrift j-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
+      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( inum )
+      ENDIF
+#endif
+      !
+      CALL iom_close( inum )
+      ! 
+   END SUBROUTINE dia_wri_state
+
+   !!======================================================================
+END MODULE diawri
Index: /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_hgr.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_hgr.F90	(revision 10425)
@@ -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/trunk/tests/BENCH/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 10425)
@@ -0,0 +1,93 @@
+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 lbclnk          ! lateral boundary conditions - mpp exchanges
+   !   
+   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
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      REAL(wp) ::   zfact
+      INTEGER  ::   ji, jj, jk
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : BENCH configuration, analytical definition of initial state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
+      !
+      ! define unique value on each point. z2d ranging from 0.05 to -0.05
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            z2d(ji,jj) = 0.1 * ( 0.5 - REAL( nimpp + ji - 1 + ( njmpp + jj - 2 ) * jpiglo, wp ) / REAL( jpiglo * jpjglo, wp ) )
+         ENDDO
+      ENDDO
+      !
+      ! sea level:
+      pssh(:,:) = z2d(:,:)                                                ! +/- 0.05 m
+      !
+      DO jk = 1, jpk
+         zfact = REAL(jk-1,wp) / REAL(jpk-1,wp)   ! 0 to 1 to add a basic stratification
+         ! temperature choosen to lead to 20% ice
+         pts(:,:,jk,jp_tem) = 2._wp - 0.1_wp * zfact + z2d(:,:) * 100._wp ! 2 to 1.9 +/- 5 degG
+         WHERE ( pts(:,:,jk,jp_tem) < -1.5_wp ) pts(:,:,jk,jp_tem) = -1.5_wp + z2d(:,:) * 0.2_wp  
+         ! salinity:  
+         pts(:,:,jk,jp_sal) = 30._wp + 1._wp * zfact + z2d(:,:)           ! 30 to 31 +/- 0.05 psu
+         ! velocities:
+         pu(:,:,jk) = z2d(:,:) * 0.1_wp                                   ! +/- 0.005  m/s
+         pv(:,:,jk) = z2d(:,:) * 0.01_wp                                  ! +/- 0.0005 m/s
+      ENDDO
+      !
+      CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )            ! apply boundary conditions
+      CALL lbc_lnk( 'usrdef_istate', pts, 'T',  1. )            ! apply boundary conditions
+      CALL lbc_lnk(  'usrdef_istate', pu, 'U', -1. )            ! apply boundary conditions
+      CALL lbc_lnk(  'usrdef_istate', pv, 'V', -1. )            ! apply boundary conditions
+      
+   END SUBROUTINE usr_def_istate
+
+   !!======================================================================
+END MODULE usrdef_istate
Index: /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 10425)
@@ -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/trunk/tests/BENCH/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_sbc.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_sbc.F90	(revision 10425)
@@ -0,0 +1,179 @@
+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 par_oce        ! ocean space and time domain
+   USE dom_oce        
+   USE oce             ! ocean dynamics and tracers
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ocean fields
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE lib_mpp         ! MPP library
+   USE lbclnk          ! lateral boundary conditions - mpp exchanges
+
+#if defined key_si3
+   USE ice, ONLY       : at_i_b, a_i_b
+#endif
+
+   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
+         !
+         utau_b(:,:) = 0._wp 
+         vtau_b(:,:) = 0._wp
+         emp_b (:,:) = 0._wp
+         sfx_b (:,:) = 0._wp
+         qns_b (:,:) = 0._wp
+         !
+      ENDIF
+      
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+   
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE usrdef_sbc_ice_tau  ***
+      !!
+      !! ** Purpose :   provide the surface boundary (momentum) condition over
+      !sea-ice
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      INTEGER  ::   ji, jj
+      !!---------------------------------------------------------------------
+#if defined key_si3
+      IF( kt==nit000 .AND. lwp)   WRITE(numout,*)' usrdef_sbc_ice : BENCH case: constant stress forcing'
+      !
+      ! define unique value on each point. z2d ranging from 0.05 to -0.05
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            z2d(ji,jj) = 0.1 * ( 0.5 - REAL( nimpp + ji - 1 + ( njmpp + jj - 2 ) * jpiglo, wp ) / REAL( jpiglo * jpjglo, wp ) )
+         ENDDO
+      ENDDO
+      utau_ice(:,:) = 0.1_wp +  z2d(:,:)
+      vtau_ice(:,:) = 0.1_wp +  z2d(:,:)
+
+      CALL lbc_lnk_multi( 'usrdef_sbc', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
+#endif
+      !
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+   
+   SUBROUTINE usrdef_sbc_ice_flx( kt, phs, phi )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE usrdef_sbc_ice_flx  ***
+      !!
+      !! ** Purpose :   provide the surface boundary (flux) condition over
+      !sea-ice
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phs    ! snow thickness
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phi    ! ice thickness
+      !!
+      REAL(wp) ::   zfr1, zfr2                 ! local variables
+      REAL(wp), DIMENSION(jpi,jpj) ::   zsnw   ! snw distribution after wind blowing
+      !!---------------------------------------------------------------------
+      !
+#if defined key_si3
+      IF( kt==nit000 .AND. lwp)   WRITE(numout,*)' usrdef_sbc_ice : BENCH case: NO flux forcing'
+      !
+      ! ocean variables (renaming)
+      emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
+      qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+
+      ! ice variables
+      alb_ice (:,:,:) = 0.7_wp  ! useless
+      qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      sprecip (:,:)   = 0._wp   ! uniform value for snow precip
+      evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
+
+      ! ice fields deduced from above
+      zsnw(:,:) = 1._wp
+      !!CALL lim_thd_snwblow( at_i_b, zsnw )  ! snow distribution over ice after
+      !wind blowing 
+      emp_ice  (:,:)   = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw(:,:)
+      emp_oce  (:,:)   = emp_oce(:,:) - sprecip(:,:) * (1._wp - zsnw(:,:) )
+      qevap_ice(:,:,:) =   0._wp
+      qprec_ice(:,:)   =   rhos * ( sst_m(:,:) * rcpi - rLfus ) * tmask(:,:,1) !  in J/m3
+      qemp_oce (:,:)   = - emp_oce(:,:) * sst_m(:,:) * rcp
+      qemp_ice (:,:)   =   sprecip(:,:) * zsnw * ( sst_m(:,:) * rcpi - rLfus ) * tmask(:,:,1) ! solid precip (only)
+
+      ! total fluxes
+      emp_tot (:,:) = emp_ice  + emp_oce
+      qns_tot (:,:) = at_i_b(:,:) * qns_oce(:,:) + SUM( a_i_b(:,:,:) * qns_ice(:,:,:), dim=3 ) + qemp_ice(:,:) + qemp_oce(:,:)
+      qsr_tot (:,:) = at_i_b(:,:) * qsr_oce(:,:) + SUM( a_i_b(:,:,:) * qsr_ice(:,:,:), dim=3 )
+
+      ! --- shortwave radiation transmitted below the surface (W/m2, see Grenfell Maykut 77) --- !
+      zfr1 = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )            ! transmission when hi>10cm
+      zfr2 = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )            ! zfr2 such that zfr1 + zfr2 to equal 1
+      !
+      WHERE    ( phs(:,:,:) <= 0._wp .AND. phi(:,:,:) <  0.1_wp )       ! linear decrease from hi=0 to 10cm  
+         qtr_ice_top(:,:,:) = qsr_ice(:,:,:) * ( zfr1 + zfr2 * ( 1._wp - phi(:,:,:) * 10._wp ) )
+      ELSEWHERE( phs(:,:,:) <= 0._wp .AND. phi(:,:,:) >= 0.1_wp )       ! constant (zfr1) when hi>10cm
+         qtr_ice_top(:,:,:) = qsr_ice(:,:,:) * zfr1
+      ELSEWHERE                                                         ! zero when hs>0
+         qtr_ice_top(:,:,:) = 0._wp 
+      END WHERE
+#endif
+
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -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/trunk/tests/BENCH/MY_SRC/zdfiwm.F90
===================================================================
--- /NEMO/trunk/tests/BENCH/MY_SRC/zdfiwm.F90	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/MY_SRC/zdfiwm.F90	(revision 10425)
@@ -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 )
+      !
+      CALL mpp_sum ( 'zdfiwm', zdf_iwm_alloc )
+      IF( zdf_iwm_alloc /= 0 )   CALL ctl_stop( 'STOP', '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
+         CALL mpp_sum( 'zdfiwm', 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(:,:) = 1.e-6
+      !
+!!$      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(:,:) = 1.e-6
+      !
+!!$      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(:,:) = 1.e-10
+      !
+!!$      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(:,:) = 100.
+      !
+!!$      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(:,:) = 100.
+
+      ebot_iwm(:,:) = ebot_iwm(:,:) * ssmask(:,:)
+      epyc_iwm(:,:) = epyc_iwm(:,:) * ssmask(:,:)
+      ecri_iwm(:,:) = ecri_iwm(:,:) * ssmask(:,:)
+
+      zbot = glob_sum( 'zdfiwm', e1e2t(:,:) * ebot_iwm(:,:) )
+      zpyc = glob_sum( 'zdfiwm', e1e2t(:,:) * epyc_iwm(:,:) )
+      zcri = glob_sum( 'zdfiwm', 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/trunk/tests/BENCH/cpp_BENCH.fcm
===================================================================
--- /NEMO/trunk/tests/BENCH/cpp_BENCH.fcm	(revision 10425)
+++ /NEMO/trunk/tests/BENCH/cpp_BENCH.fcm	(revision 10425)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys key_mpp_mpi key_si3 key_top
Index: /NEMO/trunk/tests/CANAL/MY_SRC/diawri.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/diawri.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/diawri.F90	(revision 10425)
@@ -52,4 +52,5 @@
 
 #if defined key_si3
+   USE ice 
    USE icewri 
 #endif
@@ -89,5 +90,4 @@
    !!   'key_iomput'                                        use IOM library
    !!----------------------------------------------------------------------
-
    INTEGER FUNCTION dia_wri_alloc()
       !
@@ -96,5 +96,5 @@
    END FUNCTION dia_wri_alloc
 
-
+   
    SUBROUTINE dia_wri( kt )
       !!---------------------------------------------------------------------
@@ -123,5 +123,5 @@
       ! Output the initial state and forcings
       IF( ninist == 1 ) THEN                       
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -129,6 +129,6 @@
       ! 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("e3u_0", e3u_0(:,:,:) )
+      CALL iom_put("e3v_0", e3v_0(:,:,:) )
       !
       CALL iom_put( "e3t" , e3t_n(:,:,:) )
@@ -185,5 +185,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
          CALL iom_put( "taubot", z2d )           
       ENDIF
@@ -244,5 +244,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'T', 1. )
          CALL iom_put( "salgrad2",  z3d )          ! square of module of sal gradient
          z3d(:,:,:) = SQRT( z3d(:,:,:) )
@@ -260,5 +260,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
          CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
          z2d(:,:) = SQRT( z2d(:,:) )
@@ -314,5 +314,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'T', 1. )
          CALL iom_put( "eken", z3d )                 ! kinetic energy
       ENDIF
@@ -335,5 +335,5 @@
          END DO
          
-         CALL lbc_lnk( z3d, 'T', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'T', 1. )
          CALL iom_put( "ke", z3d ) ! kinetic energy
 
@@ -363,5 +363,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'F', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'F', 1. )
          CALL iom_put( "relvor", z3d )                  ! relative vorticity
 
@@ -387,5 +387,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z3d, 'F', 1. )
+         CALL lbc_lnk( 'diawri', z3d, 'F', 1. )
          CALL iom_put( "potvor", z3d )                  ! potential vorticity
 
@@ -413,5 +413,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
          CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
       ENDIF
@@ -426,5 +426,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'U', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
          CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
       ENDIF
@@ -448,5 +448,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
          CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
       ENDIF
@@ -461,5 +461,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'V', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
          CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
       ENDIF
@@ -474,5 +474,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
          CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
       ENDIF
@@ -486,5 +486,5 @@
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', -1. )
+         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
          CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
       ENDIF
@@ -505,5 +505,5 @@
    !!   Default option                                  use IOIPSL  library
    !!----------------------------------------------------------------------
-   
+
    INTEGER FUNCTION dia_wri_alloc()
       !!----------------------------------------------------------------------
@@ -516,9 +516,9 @@
          !
       dia_wri_alloc = MAXVAL(ierr)
-      IF( lk_mpp )   CALL mpp_sum( dia_wri_alloc )
+      CALL mpp_sum( 'diawri', dia_wri_alloc )
       !
    END FUNCTION dia_wri_alloc
-  
-  
+
+   
    SUBROUTINE dia_wri( kt )
       !!---------------------------------------------------------------------
@@ -551,5 +551,5 @@
       !
       IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
-         CALL dia_wri_state( 'output.init', kt )
+         CALL dia_wri_state( 'output.init' )
          ninist = 0
       ENDIF
@@ -625,5 +625,5 @@
             !! that routine is called from nemogcm, so do it here immediately before its needed
             ALLOCATE( ndex_bT(jpi*jpj*nclasses), STAT=ierror )
-            IF( lk_mpp )   CALL mpp_sum( ierror )
+            CALL mpp_sum( 'diawri', ierror )
             IF( ierror /= 0 ) THEN
                CALL ctl_stop('dia_wri: failed to allocate iceberg diagnostic array')
@@ -974,5 +974,5 @@
 #endif
 
-   SUBROUTINE dia_wri_state( cdfile_name, kt )
+   SUBROUTINE dia_wri_state( cdfile_name )
       !!---------------------------------------------------------------------
       !!                 ***  ROUTINE dia_wri_state  ***
@@ -988,158 +988,56 @@
       !!----------------------------------------------------------------------
       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
+      !!
+      INTEGER :: inum
       !!----------------------------------------------------------------------
       ! 
-      ! 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(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
+
+#if defined key_si3
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
+#else
+     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+#endif
+
+      CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature
+      CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity
+      CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height
+      CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
+      CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
+      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
       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
-      !
+         CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahtv', ahtv              )    ! aht at v-point
+      ENDIF
+      IF( ALLOCATED(ahmt) ) THEN
+         CALL iom_rstput( 0, 0, inum,  'ahmt', ahmt              )    ! ahmt at u-point
+         CALL iom_rstput( 0, 0, inum,  'ahmf', ahmf              )    ! ahmf at v-point
+      ENDIF
+      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
+      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
+      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
+      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
+      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
+      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
+      IF(  .NOT.ln_linssh  ) THEN             
+         CALL iom_rstput( 0, 0, inum, 'vovvldep', gdept_n        )    !  T-cell depth 
+         CALL iom_rstput( 0, 0, inum, 'vovvle3t', e3t_n          )    !  T-cell thickness  
+      END IF
       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
-
+         CALL iom_rstput( 0, 0, inum, 'sdzocrtx', usd            )    ! now StokesDrift i-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdmecrty', vsd            )    ! now StokesDrift j-velocity
+         CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
+      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 )
+         CALL ice_wri_state( inum )
+      ENDIF
 #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
+      !
+      CALL iom_close( inum )
       ! 
    END SUBROUTINE dia_wri_state
Index: /NEMO/trunk/tests/CANAL/MY_SRC/domvvl.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/domvvl.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/domvvl.F90	(revision 10425)
@@ -79,6 +79,6 @@
             &      dtilde_e3t_a(jpi,jpj,jpk) , un_td  (jpi,jpj,jpk)     , vn_td  (jpi,jpj,jpk)     ,   &
             &      STAT = dom_vvl_alloc        )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
          un_td = 0._wp
          vn_td = 0._wp
@@ -86,6 +86,6 @@
       IF( ln_vvl_ztilde ) THEN
          ALLOCATE( frq_rst_e3t(jpi,jpj) , frq_rst_hdv(jpi,jpj) , hdiv_lf(jpi,jpj,jpk) , STAT= dom_vvl_alloc )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
       ENDIF
       !
@@ -147,4 +147,9 @@
       CALL dom_vvl_interpol( e3v_n(:,:,:), e3vw_n(:,:,:), 'VW' )  ! from V to UW
       CALL dom_vvl_interpol( e3v_b(:,:,:), e3vw_b(:,:,:), 'VW' )
+
+      ! We need to define e3[tuv]_a for AGRIF initialisation (should not be a problem for the restartability...)
+      e3t_a(:,:,:) = e3t_n(:,:,:)
+      e3u_a(:,:,:) = e3u_n(:,:,:)
+      e3v_a(:,:,:) = e3v_n(:,:,:)
       !
       !                    !==  depth of t and w-point  ==!   (set the isf depth as it is in the initial timestep)
@@ -229,11 +234,31 @@
                END DO
             END DO
-            IF( cn_cfg == "orca" .AND. nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
-               ii0 = 103   ;   ii1 = 111       
-               ij0 = 128   ;   ij1 = 135   ;   
-               frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
-               frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+            IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
+               IF( nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
+                  ii0 = 103   ;   ii1 = 111       
+                  ij0 = 128   ;   ij1 = 135   ;   
+                  frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
+                  frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+               ENDIF
             ENDIF
          ENDIF
+      ENDIF
+      !
+      IF(lwxios) THEN
+! define variables in restart file when writing with XIOS
+         CALL iom_set_rstw_var_active('e3t_b')
+         CALL iom_set_rstw_var_active('e3t_n')
+         !                                           ! ----------------------- !
+         IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
+            !                                        ! ----------------------- !
+            CALL iom_set_rstw_var_active('tilde_e3t_b')
+            CALL iom_set_rstw_var_active('tilde_e3t_n')
+         END IF
+         !                                           ! -------------!    
+         IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
+            !                                        ! ------------ !
+            CALL iom_set_rstw_var_active('hdiv_lf')
+         ENDIF
+         !
       ENDIF
       !
@@ -385,5 +410,5 @@
          !                       ! d - thickness diffusion transport: boundary conditions
          !                             (stored for tracer advction and continuity equation)
-         CALL lbc_lnk_multi( un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
+         CALL lbc_lnk_multi( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
 
          ! 4 - Time stepping of baroclinic scale factors
@@ -396,5 +421,5 @@
             z2dt = 2.0_wp * rdt
          ENDIF
-         CALL lbc_lnk( tilde_e3t_a(:,:,:), 'T', 1._wp )
+         CALL lbc_lnk( 'domvvl', tilde_e3t_a(:,:,:), 'T', 1._wp )
          tilde_e3t_a(:,:,:) = tilde_e3t_b(:,:,:) + z2dt * tmask(:,:,:) * tilde_e3t_a(:,:,:)
 
@@ -406,12 +431,12 @@
          END DO
          z_tmax = MAXVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_max( z_tmax )                 ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                 ! max over the global domain
          z_tmin = MINVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_min( z_tmin )                 ! min over the global domain
+         CALL mpp_min( 'domvvl', z_tmin )                 ! min over the global domain
          ! - ML - test: for the moment, stop simulation for too large e3_t variations
          IF( ( z_tmax >  rn_zdef_max ) .OR. ( z_tmin < - rn_zdef_max ) ) THEN
             IF( lk_mpp ) THEN
-               CALL mpp_maxloc( ze3t, tmask, z_tmax, ijk_max(1), ijk_max(2), ijk_max(3) )
-               CALL mpp_minloc( ze3t, tmask, z_tmin, ijk_min(1), ijk_min(2), ijk_min(3) )
+               CALL mpp_maxloc( 'domvvl', ze3t, tmask, z_tmax, ijk_max )
+               CALL mpp_minloc( 'domvvl', ze3t, tmask, z_tmin, ijk_min )
             ELSE
                ijk_max = MAXLOC( ze3t(:,:,:) )
@@ -427,5 +452,5 @@
                WRITE(numout, *) 'MIN( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmin
                WRITE(numout, *) 'at i, j, k=', ijk_min            
-               CALL ctl_warn('MAX( ABS( tilde_e3t_a(:,:,:) ) / e3t_0(:,:,:) ) too high')
+               CALL ctl_stop( 'STOP', 'MAX( ABS( tilde_e3t_a(:,:,: ) ) / e3t_0(:,:,:) ) too high')
             ENDIF
          ENDIF
@@ -470,5 +495,5 @@
          IF ( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
             z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( zht(:,:) ) )
-            IF( lk_mpp ) CALL mpp_max( z_tmax )                             ! max over the global domain
+            CALL mpp_max( 'domvvl', z_tmax )                             ! max over the global domain
             IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(SUM(tilde_e3t_a))) =', z_tmax
          END IF
@@ -479,5 +504,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshn(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshn-SUM(e3t_n))) =', z_tmax
          !
@@ -487,5 +512,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + ssha(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+ssha-SUM(e3t_a))) =', z_tmax
          !
@@ -495,17 +520,17 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshb(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshb-SUM(e3t_b))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshb(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshb))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshn(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshn))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( ssha(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ssha))) =', z_tmax
       END IF
@@ -688,5 +713,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'U', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'U', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3u_0(:,:,:)
          !
@@ -701,5 +726,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'V', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'V', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3v_0(:,:,:)
          !
@@ -715,5 +740,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'F', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'F', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3f_0(:,:,:)
          !
@@ -781,5 +806,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    )
+            CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn, ldxios = lrxios    )
             !
             id1 = iom_varid( numror, 'e3t_b', ldstop = .FALSE. )
@@ -792,6 +817,6 @@
             !                             ! --------- !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_autoglo, 'e3t_b', e3t_b(:,:,:) )
-               CALL iom_get( numror, jpdom_autoglo, 'e3t_n', e3t_n(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'e3t_b', e3t_b(:,:,:), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_autoglo, 'e3t_n', e3t_n(:,:,:), ldxios = lrxios )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : e3t_b and e3t_n found in restart files'
@@ -807,5 +832,5 @@
                IF(lwp) write(numout,*) 'e3t_n set equal to e3t_b.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_autoglo, 'e3t_b', e3t_b(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'e3t_b', e3t_b(:,:,:), ldxios = lrxios )
                e3t_n(:,:,:) = e3t_b(:,:,:)
                neuler = 0
@@ -814,5 +839,5 @@
                IF(lwp) write(numout,*) 'e3t_b set equal to e3t_n.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_autoglo, 'e3t_n', e3t_n(:,:,:) )
+               CALL iom_get( numror, jpdom_autoglo, 'e3t_n', e3t_n(:,:,:), ldxios = lrxios )
                e3t_b(:,:,:) = e3t_n(:,:,:)
                neuler = 0
@@ -839,6 +864,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
-                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
+                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lrxios )
+                  CALL iom_get( numror, jpdom_autoglo, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lrxios )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -849,5 +874,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_autoglo, 'hdiv_lf', hdiv_lf(:,:,:) )
+                     CALL iom_get( numror, jpdom_autoglo, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lrxios )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
@@ -929,21 +954,23 @@
          !                                   ! ===================
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
+         IF( lwxios ) CALL iom_swap(      cwxios_context          )
          !                                           ! --------- !
          !                                           ! all cases !
          !                                           ! --------- !
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t_b(:,:,:) )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:) )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t_b(:,:,:), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:), ldxios = lwxios )
          !                                           ! ----------------------- !
          IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
             !                                        ! ----------------------- !
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lwxios)
          END IF
          !                                           ! -------------!    
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
-            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:) )
-         ENDIF
-         !
+            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lwxios)
+         ENDIF
+         !
+         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
Index: /NEMO/trunk/tests/CANAL/MY_SRC/stpctl.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/stpctl.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/stpctl.F90	(revision 10425)
@@ -24,4 +24,5 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp         ! distributed memory computing
+   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables
    USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
 
@@ -32,5 +33,6 @@
    PUBLIC stp_ctl           ! routine called by step.F90
 
-   INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus
+   INTEGER  ::   idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus
+   LOGICAL  ::   lsomeoce
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -60,12 +62,10 @@
       INTEGER, INTENT(inout) ::   kindic   ! error indicator
       !!
-      INTEGER  ::   ji, jj, jk             ! dummy loop indices
-      INTEGER  ::   iih, ijh               ! local integers
-      INTEGER  ::   iiu, iju, iku          !   -       -
-      INTEGER  ::   iis, ijs, iks          !   -       -
-      REAL(wp) ::   zzz                    ! local real 
-      INTEGER , DIMENSION(3) ::   ilocu, ilocs
-      INTEGER , DIMENSION(2) ::   iloch
-      REAL(wp), DIMENSION(4) ::   zmax
+      INTEGER                ::   ji, jj, jk          ! dummy loop indices
+      INTEGER, DIMENSION(2)  ::   ih                  ! min/max loc indices
+      INTEGER, DIMENSION(3)  ::   iu, is1, is2        ! min/max loc indices
+      REAL(wp)               ::   zzz                 ! local real 
+      REAL(wp), DIMENSION(9) ::   zmax
+      CHARACTER(len=20) :: clname
       !!----------------------------------------------------------------------
       !
@@ -75,19 +75,29 @@
          WRITE(numout,*) '~~~~~~~'
          !                                ! open time.step file
-         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
          !                                ! open run.stat file
-         CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-
-         IF( lwm ) THEN
-            istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun )
+         IF( ln_ctl .AND. lwm ) THEN
+            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+            clname = 'run.stat.nc'
+            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
+            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun )
             istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )
             istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh )
-            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu )
+            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu   )
+            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids1  )
+            istatus = NF90_DEF_VAR( idrun,       's_max', NF90_DOUBLE, (/ idtime /), ids2  )
+            istatus = NF90_DEF_VAR( idrun,       't_min', NF90_DOUBLE, (/ idtime /), idt1  )
+            istatus = NF90_DEF_VAR( idrun,       't_max', NF90_DOUBLE, (/ idtime /), idt2  )
+            IF( ln_zad_Aimp ) THEN
+               istatus = NF90_DEF_VAR( idrun,   'abs_wi_max', NF90_DOUBLE, (/ idtime /), idw1  )
+               istatus = NF90_DEF_VAR( idrun,       'Cu_max', NF90_DOUBLE, (/ idtime /), idc1  )
+            ENDIF
             istatus = NF90_ENDDEF(idrun)
+            zmax(8:9) = 0._wp    ! initialise to zero in case ln_zad_Aimp option is not in use
          ENDIF
-         
       ENDIF
+      IF( kt == nit000 )   lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0
       !
-      IF(lwp) THEN                        !==  current time step  ==!   ("time.step" file)
+      IF(lwm) THEN                        !==  current time step  ==!   ("time.step" file)
          WRITE ( numstp, '(1x, i8)' )   kt
          REWIND( numstp )
@@ -101,67 +111,84 @@
       ENDIF
       zmax(2) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only)
-!     zmax(3) = MAXVAL( -tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   ! minus salinity max
-      zmax(3) = 0.0_wp
-      zmax(4) = REAL( nstop , wp )                                            ! stop indicator
-      !
-      IF( lk_mpp ) THEN
-         CALL mpp_max_multiple( zmax(:), 4 )    ! max over the global domain
-         !
-         nstop = INT( zmax(4) )                 ! nstop indicator sheared among all local domains
+      zmax(3) = MAXVAL( -tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   ! minus salinity max
+      zmax(4) = MAXVAL(  tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   !       salinity max
+      zmax(5) = MAXVAL( -tsn(:,:,:,jp_tem) , mask = tmask(:,:,:) == 1._wp )   ! minus temperature max
+      zmax(6) = MAXVAL(  tsn(:,:,:,jp_tem) , mask = tmask(:,:,:) == 1._wp )   !       temperature max
+      zmax(7) = REAL( nstop , wp )                                            ! stop indicator
+      IF( ln_zad_Aimp ) THEN
+         zmax(8) = MAXVAL(  ABS( wi(:,:,:) ) , mask = wmask(:,:,:) == 1._wp ) ! implicit vertical vel. max
+         zmax(9) = MAXVAL(   Cu_adv(:,:,:)   , mask = tmask(:,:,:) == 1._wp ) !       cell Courant no. max
       ENDIF
       !
-      IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
-         WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ',   zmax(1), ' |U| max: ', zmax(2)
+      IF( lk_mpp .AND. ln_ctl ) THEN
+         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
+         nstop = NINT( zmax(7) )                 ! nstop indicator sheared among all local domains
       ENDIF
-      !
-      IF (  zmax(1) >  50._wp .OR.   &                     ! too large sea surface height ( > 10 m)
-         &  zmax(2) >  20._wp .OR.   &                     ! too large velocity ( > 10 m/s)
-!!$         &  zmax(3) >=  0._wp .OR.   &                     ! negative or zero sea surface salinity
-         &  ISNAN( zmax(1) + zmax(2) + zmax(3) )  ) THEN   ! NaN encounter in the tests
-         IF( lk_mpp ) THEN
-            CALL mpp_maxloc( ABS(sshn)        , ssmask(:,:)  , zzz, iih, ijh )
-            CALL mpp_maxloc( ABS(un)          , umask (:,:,:), zzz, iiu, iju, iku )
-!           CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis, ijs, iks )
-         ELSE
-            iloch = MINLOC( ABS( sshn(:,:)   )                               )
-            ilocu = MAXLOC( ABS( un  (:,:,:) )                               )
-!           ilocs = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )
-            iih = iloch(1) + nimpp - 1   ;   ijh = iloch(2) + njmpp - 1
-            iiu = ilocu(1) + nimpp - 1   ;   iju = ilocu(2) + njmpp - 1   ;   iku = ilocu(3)
-!           iis = ilocs(1) + nimpp - 1   ;   ijs = ilocs(2) + njmpp - 1   ;   iks = ilocu(3)
-         ENDIF
-         IF(lwp) THEN
-            WRITE(numout,cform_err)
-            WRITE(numout,*) ' stp_ctl: |ssh| > 50 m   or   |U| > 20 m/s   or   NaN encounter in the tests'
-            WRITE(numout,*) ' ======= '
-            WRITE(numout,9100) kt,   zmax(1), iih, ijh
-            WRITE(numout,9200) kt,   zmax(2), iiu, iju, iku
-!!$            WRITE(numout,9300) kt, - zmax(3), iis, ijs, iks
-            WRITE(numout,*)
-            WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
-         ENDIF
-         kindic = -3
-         !
-         nstop = nstop + 1                            ! increase nstop by 1 (on all local domains)
-         CALL dia_wri_state( 'output.abort', kt )     ! create an output.abort file
-         !
-      ENDIF
-9100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5)
-9200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5)
-9300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j  : ',2i5)
-      !
-      !                                            !==  run statistics  ==!   ("run.stat" file)
-!     IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
-      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2)
-      IF( lwm ) THEN
+      !                                   !==  run statistics  ==!   ("run.stat" files)
+      IF( ln_ctl .AND. lwm ) THEN
+         WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4)
          istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
          istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
-!        istatus = NF90_PUT_VAR( idrun,   ids, (/-zmax(3)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  ids1, (/-zmax(3)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  ids2, (/ zmax(4)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  idt1, (/-zmax(5)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  idt2, (/ zmax(6)/), (/kt/), (/1/) )
+         IF( ln_zad_Aimp ) THEN
+            istatus = NF90_PUT_VAR( idrun,  idw1, (/ zmax(8)/), (/kt/), (/1/) )
+            istatus = NF90_PUT_VAR( idrun,  idc1, (/ zmax(9)/), (/kt/), (/1/) )
+         ENDIF
          IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun)
          IF( kt == nitend         ) istatus = NF90_CLOSE(idrun)
       END IF
+      !                                   !==  error handling  ==!
+      IF( ( ln_ctl .OR. lsomeoce ) .AND. (   &             ! have use mpp_max (because ln_ctl=.T.) or contains some ocean points
+         &  zmax(1) >   50._wp .OR.   &                    ! too large sea surface height ( > 50 m )
+         &  zmax(2) >   20._wp .OR.   &                    ! too large velocity ( > 20 m/s)
+         &  zmax(3) >= 100._wp .OR.   &                    ! too small sea surface salinity ( < -100 )
+         &  zmax(4) >= 100._wp .OR.   &                    ! too large sea surface salinity ( > 100 )
+         &  zmax(4) < -100._wp .OR.   &                    ! too large sea surface salinity (keep this line for sea-ice)
+         &  ISNAN( zmax(1) + zmax(2) + zmax(3) )  ) THEN   ! NaN encounter in the tests
+         IF( lk_mpp .AND. ln_ctl ) THEN
+            CALL mpp_maxloc( 'stpctl', ABS(sshn)        , ssmask(:,:)  , zzz, ih  )
+            CALL mpp_maxloc( 'stpctl', ABS(un)          , umask (:,:,:), zzz, iu  )
+            CALL mpp_minloc( 'stpctl', tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, is1 )
+            CALL mpp_maxloc( 'stpctl', tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, is2 )
+         ELSE
+            ih(:)  = MAXLOC( ABS( sshn(:,:)   )                              ) + (/ nimpp - 1, njmpp - 1    /)
+            iu(:)  = MAXLOC( ABS( un  (:,:,:) )                              ) + (/ nimpp - 1, njmpp - 1, 0 /)
+            is1(:) = MINLOC( tsn(:,:,:,jp_sal), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
+            is2(:) = MAXLOC( tsn(:,:,:,jp_sal), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
+         ENDIF
+         IF( numout == 6 )   &   ! force to open ocean.output file
+            CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+
+         WRITE(numout,cform_err)
+         WRITE(numout,*) ' stp_ctl: |ssh| > 50 m  or  |U| > 20 m/s  or  S <= -100  or  S >= 100  or  NaN encounter in the tests'
+         WRITE(numout,*) ' ======= '
+         IF( lk_mpp .AND. .NOT. ln_ctl ) WRITE(numout,*) 'E R R O R message from sub-domain: ', narea
+         WRITE(numout,9100) kt,   zmax(1), ih(1) , ih(2)
+         WRITE(numout,9200) kt,   zmax(2), iu(1) , iu(2) , iu(3)
+         WRITE(numout,9300) kt, - zmax(3), is1(1), is1(2), is1(3)
+         WRITE(numout,9400) kt,   zmax(4), is2(1), is2(2), is2(3)
+         WRITE(numout,*)
+         WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
+         
+         CALL dia_wri_state( 'output.abort' )     ! create an output.abort file
+         
+         IF( ln_ctl ) THEN
+            kindic = -3
+            nstop = nstop + 1                            ! increase nstop by 1 (on all local domains)
+         ELSE
+            CALL ctl_stop()
+            CALL mppstop(ld_force_abort = .true.)
+         ENDIF
+         !
+      ENDIF
       !
-!9400  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16)
-9400  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16)
+9100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5)
+9200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5)
+9300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j k: ',3i5)
+9400  FORMAT (' kt=',i8,'   S     max: ',1pg11.4,', at  i j k: ',3i5)
+9500  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16)
       !
    END SUBROUTINE stp_ctl
Index: /NEMO/trunk/tests/CANAL/MY_SRC/trazdf.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/trazdf.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/trazdf.F90	(revision 10425)
@@ -92,5 +92,5 @@
          END DO
 !!gm this should be moved in trdtra.F90 and done on all trends
-         CALL lbc_lnk_multi( ztrdt, 'T', 1. , ztrds, 'T', 1. )
+         CALL lbc_lnk_multi( 'trazdf', ztrdt, 'T', 1. , ztrds, 'T', 1. )
 !!gm
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
Index: /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 10425)
@@ -169,5 +169,5 @@
                END DO
             END DO
-            CALL lbc_lnk( pssh, 'T',  1. )
+            CALL lbc_lnk( 'usrdef_istate', pssh, 'T',  1. )
          END DO
          
@@ -293,8 +293,8 @@
          pssh(:,:) = pssh(:,:) + ( 0.1  * zrandom(:,:) - 0.05 )
       END IF
-      CALL lbc_lnk( pssh, 'T',  1. )
-      CALL lbc_lnk(  pts, 'T',  1. )
-      CALL lbc_lnk(   pu, 'U', -1. )
-      CALL lbc_lnk(   pv, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_istate', pssh, 'T',  1. )
+      CALL lbc_lnk(  'usrdef_istate', pts, 'T',  1. )
+      CALL lbc_lnk(   'usrdef_istate', pu, 'U', -1. )
+      CALL lbc_lnk(   'usrdef_istate', pv, 'V', -1. )
 
    END SUBROUTINE usr_def_istate
Index: /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -198,5 +198,5 @@
       CASE(1)
          zmaxlam = MAXVAL(glamt)
-         IF( lk_mpp )   CALL mpp_max( zmaxlam )                 ! max over the global domain
+         CALL mpp_max( 'usrdef_zgr', zmaxlam )                 ! max over the global domain
          zscl = rpi / zmaxlam
          z2d(:,:) = 0.5 * ( 1. - COS( glamt(:,:) * zscl ) )
@@ -204,5 +204,5 @@
       END SELECT
       !
-      CALL lbc_lnk( z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      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
Index: /NEMO/trunk/tests/CANAL/cpp_CANAL.fcm
===================================================================
--- /NEMO/trunk/tests/CANAL/cpp_CANAL.fcm	(revision 10424)
+++ /NEMO/trunk/tests/CANAL/cpp_CANAL.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_nosignedzero 
+ bld::tool::fppkeys key_iomput key_mpp_mpi 
Index: /NEMO/trunk/tests/ICEDYN/cpp_ICEDYN.fcm
===================================================================
--- /NEMO/trunk/tests/ICEDYN/cpp_ICEDYN.fcm	(revision 10424)
+++ /NEMO/trunk/tests/ICEDYN/cpp_ICEDYN.fcm	(revision 10425)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_agrif key_si3 key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_agrif key_si3 key_mpp_mpi key_iomput
Index: /NEMO/trunk/tests/ISOMIP/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/ISOMIP/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/ISOMIP/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -89,5 +89,5 @@
       ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
-      CALL lbc_lnk( z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
       zmsk(:,:) = NINT( z2d(:,:) )
       !
@@ -177,6 +177,6 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3v , 'V', 1._wp )   ;   CALL lbc_lnk( pe3vw, 'V', 1._wp )
-         CALL lbc_lnk( pe3f , 'F', 1._wp )
+         CALL lbc_lnk( 'usrdef_zgr', pe3v , 'V', 1._wp )   ;   CALL lbc_lnk( 'usrdef_zgr', pe3vw, 'V', 1._wp )
+         CALL lbc_lnk( 'usrdef_zgr', pe3f , 'F', 1._wp )
          DO jk = 1, jpk
             ! set to z-scale factor if zero (i.e. along closed boundaries) because of lbclnk
Index: /NEMO/trunk/tests/ISOMIP/cpp_ISOMIP.fcm
===================================================================
--- /NEMO/trunk/tests/ISOMIP/cpp_ISOMIP.fcm	(revision 10424)
+++ /NEMO/trunk/tests/ISOMIP/cpp_ISOMIP.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi key_nosignedzero 
+ bld::tool::fppkeys   key_iomput key_mpp_mpi 
Index: /NEMO/trunk/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -88,5 +88,5 @@
       ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
-      CALL lbc_lnk( z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
       k_top(:,:) = NINT( z2d(:,:) )
       !
Index: /NEMO/trunk/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm
===================================================================
--- /NEMO/trunk/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm	(revision 10424)
+++ /NEMO/trunk/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi key_nosignedzero
+ bld::tool::fppkeys   key_iomput key_mpp_mpi 
Index: /NEMO/trunk/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -93,5 +93,5 @@
          zhu(ji,:) = 0.5_wp * ( zht(ji,:) + zht(ji+1,:) )
       END DO
-      CALL lbc_lnk( zhu, 'U', 1. )     ! boundary condition: this mask the surrouding grid-points
+      CALL lbc_lnk( 'usrdef_zgr', zhu, 'U', 1. )     ! boundary condition: this mask the surrouding grid-points
       !                                ! ==>>>  set by hand non-zero value on first/last columns & rows 
       DO ji = mi0(1), mi1(1)              ! first row of global domain only
@@ -112,5 +112,5 @@
       ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
-      CALL lbc_lnk( z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
       k_top(:,:) = NINT( z2d(:,:) )
       !
Index: /NEMO/trunk/tests/OVERFLOW/cpp_OVERFLOW.fcm
===================================================================
--- /NEMO/trunk/tests/OVERFLOW/cpp_OVERFLOW.fcm	(revision 10424)
+++ /NEMO/trunk/tests/OVERFLOW/cpp_OVERFLOW.fcm	(revision 10425)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_mpp_mpi key_iomput key_nosignedzero
+bld::tool::fppkeys   key_mpp_mpi key_iomput 
Index: /NEMO/trunk/tests/VORTEX/MY_SRC/domvvl.F90
===================================================================
--- /NEMO/trunk/tests/VORTEX/MY_SRC/domvvl.F90	(revision 10424)
+++ /NEMO/trunk/tests/VORTEX/MY_SRC/domvvl.F90	(revision 10425)
@@ -79,6 +79,6 @@
             &      dtilde_e3t_a(jpi,jpj,jpk) , un_td  (jpi,jpj,jpk)     , vn_td  (jpi,jpj,jpk)     ,   &
             &      STAT = dom_vvl_alloc        )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
          un_td = 0._wp
          vn_td = 0._wp
@@ -86,6 +86,6 @@
       IF( ln_vvl_ztilde ) THEN
          ALLOCATE( frq_rst_e3t(jpi,jpj) , frq_rst_hdv(jpi,jpj) , hdiv_lf(jpi,jpj,jpk) , STAT= dom_vvl_alloc )
-         IF( lk_mpp             )   CALL mpp_sum ( dom_vvl_alloc )
-         IF( dom_vvl_alloc /= 0 )   CALL ctl_warn('dom_vvl_alloc: failed to allocate arrays')
+         CALL mpp_sum ( 'domvvl', dom_vvl_alloc )
+         IF( dom_vvl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'dom_vvl_alloc: failed to allocate arrays' )
       ENDIF
       !
@@ -234,9 +234,11 @@
                END DO
             END DO
-            IF( cn_cfg == "orca" .AND. nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
-               ii0 = 103   ;   ii1 = 111       
-               ij0 = 128   ;   ij1 = 135   ;   
-               frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
-               frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+            IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
+               IF( nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
+                  ii0 = 103   ;   ii1 = 111       
+                  ij0 = 128   ;   ij1 = 135   ;   
+                  frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
+                  frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+               ENDIF
             ENDIF
          ENDIF
@@ -408,5 +410,5 @@
          !                       ! d - thickness diffusion transport: boundary conditions
          !                             (stored for tracer advction and continuity equation)
-         CALL lbc_lnk_multi( un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
+         CALL lbc_lnk_multi( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
 
          ! 4 - Time stepping of baroclinic scale factors
@@ -419,5 +421,5 @@
             z2dt = 2.0_wp * rdt
          ENDIF
-         CALL lbc_lnk( tilde_e3t_a(:,:,:), 'T', 1._wp )
+         CALL lbc_lnk( 'domvvl', tilde_e3t_a(:,:,:), 'T', 1._wp )
          tilde_e3t_a(:,:,:) = tilde_e3t_b(:,:,:) + z2dt * tmask(:,:,:) * tilde_e3t_a(:,:,:)
 
@@ -429,12 +431,12 @@
          END DO
          z_tmax = MAXVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_max( z_tmax )                 ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                 ! max over the global domain
          z_tmin = MINVAL( ze3t(:,:,:) )
-         IF( lk_mpp )   CALL mpp_min( z_tmin )                 ! min over the global domain
+         CALL mpp_min( 'domvvl', z_tmin )                 ! min over the global domain
          ! - ML - test: for the moment, stop simulation for too large e3_t variations
          IF( ( z_tmax >  rn_zdef_max ) .OR. ( z_tmin < - rn_zdef_max ) ) THEN
             IF( lk_mpp ) THEN
-               CALL mpp_maxloc( ze3t, tmask, z_tmax, ijk_max(1), ijk_max(2), ijk_max(3) )
-               CALL mpp_minloc( ze3t, tmask, z_tmin, ijk_min(1), ijk_min(2), ijk_min(3) )
+               CALL mpp_maxloc( 'domvvl', ze3t, tmask, z_tmax, ijk_max )
+               CALL mpp_minloc( 'domvvl', ze3t, tmask, z_tmin, ijk_min )
             ELSE
                ijk_max = MAXLOC( ze3t(:,:,:) )
@@ -450,5 +452,5 @@
                WRITE(numout, *) 'MIN( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmin
                WRITE(numout, *) 'at i, j, k=', ijk_min            
-               CALL ctl_warn('MAX( ABS( tilde_e3t_a(:,:,:) ) / e3t_0(:,:,:) ) too high')
+               CALL ctl_stop( 'STOP', 'MAX( ABS( tilde_e3t_a(:,:,: ) ) / e3t_0(:,:,:) ) too high')
             ENDIF
          ENDIF
@@ -493,5 +495,5 @@
          IF ( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
             z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( zht(:,:) ) )
-            IF( lk_mpp ) CALL mpp_max( z_tmax )                             ! max over the global domain
+            CALL mpp_max( 'domvvl', z_tmax )                             ! max over the global domain
             IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(SUM(tilde_e3t_a))) =', z_tmax
          END IF
@@ -502,5 +504,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshn(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshn-SUM(e3t_n))) =', z_tmax
          !
@@ -510,5 +512,5 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + ssha(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+ssha-SUM(e3t_a))) =', z_tmax
          !
@@ -518,17 +520,17 @@
          END DO
          z_tmax = MAXVAL( tmask(:,:,1) * tmask_i(:,:) * ABS( ht_0(:,:) + sshb(:,:) - zht(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ht_0+sshb-SUM(e3t_b))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshb(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshb))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( sshn(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(sshn))) =', z_tmax
          !
          z_tmax = MAXVAL( tmask(:,:,1) *  ABS( ssha(:,:) ) )
-         IF( lk_mpp ) CALL mpp_max( z_tmax )                                ! max over the global domain
+         CALL mpp_max( 'domvvl', z_tmax )                                ! max over the global domain
          IF( lwp    ) WRITE(numout, *) kt,' MAXVAL(abs(ssha))) =', z_tmax
       END IF
@@ -711,5 +713,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'U', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'U', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3u_0(:,:,:)
          !
@@ -724,5 +726,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'V', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'V', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3v_0(:,:,:)
          !
@@ -738,5 +740,5 @@
             END DO
          END DO
-         CALL lbc_lnk( pe3_out(:,:,:), 'F', 1._wp )
+         CALL lbc_lnk( 'domvvl', pe3_out(:,:,:), 'F', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3f_0(:,:,:)
          !
Index: /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_istate.F90	(revision 10424)
+++ /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_istate.F90	(revision 10425)
@@ -136,6 +136,6 @@
       END DO
 
-      CALL lbc_lnk( pu, 'U', -1. )
-      CALL lbc_lnk( pv, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_istate', pu, 'U', -1. )
+      CALL lbc_lnk( 'usrdef_istate', pv, 'V', -1. )
       !   
    END SUBROUTINE usr_def_istate
Index: /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/VORTEX/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -192,5 +192,5 @@
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
       !
-      CALL lbc_lnk( z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      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
Index: /NEMO/trunk/tests/VORTEX/cpp_VORTEX.fcm
===================================================================
--- /NEMO/trunk/tests/VORTEX/cpp_VORTEX.fcm	(revision 10424)
+++ /NEMO/trunk/tests/VORTEX/cpp_VORTEX.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_nosignedzero key_agrif
+ bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif
Index: /NEMO/trunk/tests/WAD/MY_SRC/bdyini.F90
===================================================================
--- /NEMO/trunk/tests/WAD/MY_SRC/bdyini.F90	(revision 10424)
+++ /NEMO/trunk/tests/WAD/MY_SRC/bdyini.F90	(revision 10425)
@@ -1133,5 +1133,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
+      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
 
       ! bdy masks are now set to zero on boundary points:
@@ -1169,6 +1169,6 @@
 
       ! Lateral boundary conditions
-      CALL lbc_lnk( zfmask, 'F', 1. ) 
-      CALL lbc_lnk_multi( bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
+      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. ) 
+      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
       DO ib_bdy = 1, nb_bdy       ! Indices and directions of rim velocity components
 
@@ -1280,5 +1280,5 @@
          END DO
          !
-         IF( lk_mpp )   CALL mpp_sum( bdysurftot )      ! sum over the global domain
+         CALL mpp_sum( 'bdyini', bdysurftot )      ! sum over the global domain
       END IF   
       !
@@ -1520,5 +1520,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF (ztestmask(1)==1) THEN 
@@ -1564,5 +1564,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF (ztestmask(1)==1) THEN
@@ -1608,5 +1608,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
@@ -1638,5 +1638,5 @@
             END DO
          END DO
-         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
 
          IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
Index: /NEMO/trunk/tests/WAD/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/trunk/tests/WAD/MY_SRC/usrdef_zgr.F90	(revision 10424)
+++ /NEMO/trunk/tests/WAD/MY_SRC/usrdef_zgr.F90	(revision 10425)
@@ -234,5 +234,5 @@
          zhu(ji,:) = 0.5_wp * ( zht(ji,:) + zht(ji+1,:) )
       END DO
-      CALL lbc_lnk( zhu, 'U', 1. )     ! boundary condition: this mask the surrounding grid-points
+      CALL lbc_lnk( 'usrdef_zgr', zhu, 'U', 1. )     ! boundary condition: this mask the surrounding grid-points
       !                                ! ==>>>  set by hand non-zero value on first/last columns & rows 
       DO ji = mi0(1), mi1(1)              ! first row of global domain only
@@ -247,5 +247,5 @@
          zhv(:,jj) = 0.5_wp * ( zht(:,jj) + zht(:,jj+1) )
       END DO
-      CALL lbc_lnk( zhv, 'V', 1. )     ! boundary condition: this mask the surrounding grid-points
+      CALL lbc_lnk( 'usrdef_zgr', zhv, 'V', 1. )     ! boundary condition: this mask the surrounding grid-points
       DO jj = mj0(1), mj1(1)   ! first  row of global domain only
          zhv(:,jj) = zht(:,jj)
@@ -272,5 +272,5 @@
 
 
-      CALL lbc_lnk( z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
       k_top(:,:) = NINT( z2d(:,:) )
       !
@@ -311,13 +311,13 @@
            END DO      
          END DO      
-         CALL lbc_lnk( pdept, 'T', 1. )
-         CALL lbc_lnk( pdepw, 'T', 1. )
-         CALL lbc_lnk( pe3t , 'T', 1. )
-         CALL lbc_lnk( pe3w , 'T', 1. )
-         CALL lbc_lnk( pe3u , 'U', 1. )
-         CALL lbc_lnk( pe3uw, 'U', 1. )
-         CALL lbc_lnk( pe3f , 'F', 1. )
-         CALL lbc_lnk( pe3v , 'V', 1. )
-         CALL lbc_lnk( pe3vw, 'V', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pdept, 'T', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pdepw, 'T', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3t , 'T', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3w , 'T', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3u , 'U', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3uw, 'U', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3f , 'F', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3v , 'V', 1. )
+         CALL lbc_lnk( 'usrdef_zgr', pe3vw, 'V', 1. )
          WHERE( pe3t (:,:,:) == 0._wp )   pe3t (:,:,:) = 1._wp
          WHERE( pe3u (:,:,:) == 0._wp )   pe3u (:,:,:) = 1._wp
Index: /NEMO/trunk/tests/WAD/cpp_WAD.fcm
===================================================================
--- /NEMO/trunk/tests/WAD/cpp_WAD.fcm	(revision 10424)
+++ /NEMO/trunk/tests/WAD/cpp_WAD.fcm	(revision 10425)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi key_nosignedzero
+ bld::tool::fppkeys   key_iomput key_mpp_mpi 
Index: /NEMO/trunk/tests/demo_cfgs.txt
===================================================================
--- /NEMO/trunk/tests/demo_cfgs.txt	(revision 10424)
+++ /NEMO/trunk/tests/demo_cfgs.txt	(revision 10425)
@@ -7,3 +7,3 @@
 VORTEX OCE NST
 WAD OCE
-
+BENCH OCE ICE TOP
