Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg	(revision 6982)
@@ -20,5 +20,5 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
+   ln_read_cfg = .true.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
    !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg	(revision 6982)
@@ -9,11 +9,17 @@
    cn_exp      =  "ORCA2"  !  experience name
    nn_it000    =       1   !  first time step
-   nn_itend    =     300   !  last  time step (std 5475)
-/
-!-----------------------------------------------------------------------
-&namcfg        !   parameters of the configuration
-!-----------------------------------------------------------------------
-   cp_cfg      =  "orca"               !  name of the configuration
-   jp_cfg      =       2               !  resolution of the configuration
+   nn_itend    =    5475   !  last  time step (std 5475)
+/
+!-----------------------------------------------------------------------
+&namcfg     !   parameters of the configuration
+!-----------------------------------------------------------------------
+   ln_read_cfg = .true.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
+   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_write_cfg= .false.    !  (=T) create the domain configuration file
+   !
+   cp_cfg      =  "orca"   !  name of the configuration
+   jp_cfg      =       2   !  resolution of the configuration
+   ln_use_jattr = .false.  !  use (T) the file attribute: open_ocean_jstart, if present
+   !                       !  in netcdf input files, as the start j-row for reading
 /
 !-----------------------------------------------------------------------
@@ -21,20 +27,12 @@
 !-----------------------------------------------------------------------
    ln_zps      = .true.    !  z-coordinate - partial steps
-   ln_linssh   = .true.    !  linear free surface
 /
 !-----------------------------------------------------------------------
 &namdom        !   space and time domain (bathymetry, mesh, timestep)
 !-----------------------------------------------------------------------
-   ppsur       =   -4762.96143546300   !  ORCA r4, r2 and r05 coefficients
-   ppa0        =     255.58049070440   ! (default coefficients)
-   ppa1        =     245.58132232490   !
-   ppkth       =      21.43336197938   !
-   ppacr       =       3.0             !
-   ppdzmin     =  999999.              !  Minimum vertical spacing
-   pphmax      =  999999.              !  Maximum depth
-   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
-   ppa2        =  999999.              !  Double tanh function parameters
-   ppkth2      =  999999.              !
-   ppacr2      =  999999.              !
+   ln_linssh   = .false.   !  =T  linear free surface  ==>>  model level are fixed in time
+   !
+   nn_msh      =    0      !  create (>0) a mesh file or not (=0)
+   !
 /
 !-----------------------------------------------------------------------
@@ -119,6 +117,6 @@
    ln_traldf_lev   =  .false.  !  iso-level
    ln_traldf_hor   =  .false.  !  horizontal (geopotential)
-   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
-   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   ln_traldf_iso   =  .true.   !  iso-neutral (Standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (Triads   operator)
    !
    !		       	         !  iso-neutral options:        
@@ -132,7 +130,7 @@
    nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
    !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
-   !                                !   =  0           constant
-   !                                !   = 10 F(k)      =ldf_c1d
-   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
    !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
    !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
@@ -149,14 +147,13 @@
    nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
    !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
-   !                                !   =  0           constant
-   !                                !   = 10 F(k)      =ldf_c1d
-   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
    !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
    !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
-&namtra_dmp    !   tracer: T & S newtonian damping
-!-----------------------------------------------------------------------
-/
+&namtra_dmp    !   tracer: T & S newtonian damping                      (default: NO)
+!-----------------------------------------------------------------------
 !-----------------------------------------------------------------------
 &namdyn_adv    !   formulation of the momentum advection
@@ -177,7 +174,7 @@
 /
 !-----------------------------------------------------------------------
-&namdyn_spg    !   Surface pressure gradient
-!-----------------------------------------------------------------------
-   ln_dynspg_ts = .true.   !  Split-explicit free surface
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
 /
 !-----------------------------------------------------------------------
@@ -204,4 +201,6 @@
    rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
    rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
 /
 !-----------------------------------------------------------------------
@@ -234,9 +233,9 @@
 /
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobs       !  observation usage
+&namhsb       !  Heat and salt budgets                                  (default F)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage                                      ('key_diaobs')
 !-----------------------------------------------------------------------
 /
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg	(revision 6982)
@@ -16,5 +16,5 @@
    ln_read_cfg = .true.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
    !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
-   ln_write_cfg= .true.    !  (=T) create the domain configuration file
+   ln_write_cfg= .false.    !  (=T) create the domain configuration file
    !
    cp_cfg      =  "orca"   !  name of the configuration
@@ -33,5 +33,5 @@
    ln_linssh   = .false.   !  =T  linear free surface  ==>>  model level are fixed in time
    !
-   nn_msh      =    1      !  create (>0) a mesh file or not (=0)
+   nn_msh      =    0      !  create (>0) a mesh file or not (=0)
    !
 /
@@ -156,6 +156,4 @@
 &namtra_dmp    !   tracer: T & S newtonian damping                      (default: NO)
 !-----------------------------------------------------------------------
-   ln_tradmp   =  .false.   !  add a damping termn (T) or not (F)
-/
 !-----------------------------------------------------------------------
 &namdyn_adv    !   formulation of the momentum advection
@@ -174,6 +172,4 @@
 &namdyn_hpg    !   Hydrostatic pressure gradient option
 !-----------------------------------------------------------------------
-   ln_hpg_sco  = .true.    !  s-coordinate (standard jacobian formulation)
-   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
 /
 !-----------------------------------------------------------------------
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90	(revision 6982)
@@ -28,6 +28,9 @@
    !!             -   ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!            3.3.1! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
-   !!            3.4  ! 2011-11  (C. Harris) decomposition changes for running with CICE
-   !!                 ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening 
+   !!            3.4  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE) add nemo_northcomms
+   !!             -   ! 2011-11  (C. Harris) decomposition changes for running with CICE
+   !!            3.6  ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening 
+   !!             -   ! 2013-06  (I. Epicoco, S. Mocavero, CMCC) nemo_northcomms: setup avoiding MPI communication 
+   !!             -   ! 2014-12  (G. Madec) remove KPP scheme and cross-land advection (cla)
    !!----------------------------------------------------------------------
 
@@ -41,8 +44,8 @@
    !!   factorise      : calculate the factors of the no. of MPI processes
    !!----------------------------------------------------------------------
-   USE step_oce        ! module used in the ocean time stepping module
-   USE domcfg          ! domain configuration               (dom_cfg routine)
-   USE mppini          ! shared/distributed memory setting (mpp_init routine)
-   USE domain          ! domain initialization             (dom_init routine)
+   USE step_oce       ! module used in the ocean time stepping module (step.F90)
+   USE domcfg         ! domain configuration               (dom_cfg routine)
+   USE mppini         ! shared/distributed memory setting (mpp_init routine)
+   USE domain         ! domain initialization             (dom_init routine)
 #if defined key_nemocice_decomp
    USE ice_domain_size, only: nx_global, ny_global
@@ -56,5 +59,5 @@
    USE lib_mpp         ! distributed memory computing
 #if defined key_iomput
-   USE xios
+   USE xios           ! xIOserver
 #endif
    USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges 
@@ -74,5 +77,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -124,7 +127,6 @@
       NAMELIST/namctl/ ln_ctl, nn_print, nn_ictls, nn_ictle,   &
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
-         &             nn_bench, nn_timing
-      NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg,   &
-         &             jperio, ln_use_jattr
+         &             nn_timing, nn_diacfl
+      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
       !!----------------------------------------------------------------------
       !
@@ -153,17 +155,35 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
-! Force values for AGRIF zoom (cf. agrif_user.F90)
+!!gm      WRITE(clbug(3),*) ' after namelist namcfg read    nstop', nstop
+
+      !                             !--------------------------!
+      !                             !  Set global domain size  !   (control print return in cltxt2)
+      !                             !--------------------------!
+      IF( ln_read_cfg ) THEN              ! Read sizes in configuration "mesh_mask" file
+         CALL iom_open( 'domain_cfg', inum )
+         CALL iom_get( inum, 'jpiglo', ziglo  )   ;   jpiglo = INT( ziglo )
+         CALL iom_get( inum, 'jpjglo', zjglo  )   ;   jpjglo = INT( zjglo )
+         CALL iom_get( inum, 'jpkglo', zkglo  )   ;   jpkglo = INT( zkglo )
+         CALL iom_get( inum, 'jperio', zperio )   ;   jperio = INT( zperio )
+         CALL iom_close( inum )
+         WRITE(cltxt2(1),*)       
+         WRITE(cltxt2(2),*) 'domain_cfg : domain size read in "domain_cfg" file : jp(i,j,k)glo = ', jpiglo, jpjglo, jpkglo        
+         WRITE(cltxt2(3),*) '~~~~~~~~~~   lateral boudary type of the global domain      jperio= ', jperio
+         !        
+      ELSE                                ! user-defined namelist
+         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      jpk    = jpkglo
+      !
 #if defined key_agrif
-   IF( .NOT. Agrif_Root() ) THEN
-      jpiglo  = nbcellsx + 2 + 2*nbghostcells
-      jpjglo  = nbcellsy + 2 + 2*nbghostcells
-      jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
-      jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
-      jpidta  = jpiglo
-      jpjdta  = jpjglo
-      nperio  = 0
-      jperio  = 0
-      ln_use_jattr = .false.
-   ENDIF
+      IF( .NOT. Agrif_Root() ) THEN       ! AGRIF children: specific setting (cf. agrif_user.F90)
+         jpiglo  = nbcellsx + 2 + 2*nbghostcells
+         jpjglo  = nbcellsy + 2 + 2*nbghostcells
+         jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
+         jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
+         nperio  = 0
+         jperio  = 0
+         ln_use_jattr = .false.
+      ENDIF
 #endif
       !
@@ -208,9 +228,14 @@
          WRITE( numond, namctl )
          WRITE( numond, namcfg )
+         IF( .NOT.ln_read_cfg ) THEN
+            DO ji = 1, SIZE(clnam)
+               IF( TRIM(clnam (ji)) /= '' )   WRITE(numond, * ) clnam(ji)    ! namusr_def print
+            END DO
+         ENDIF
       ENDIF
 
       ! 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) )THEN
+      IF( jpni < 1 .OR. jpnj < 1 ) THEN
 #if   defined key_mpp_mpi
          IF( Agrif_Root() ) CALL nemo_partition(mppsize)
@@ -220,5 +245,5 @@
          jpnij = jpni*jpnj
 #endif
-      END IF
+      ENDIF
 
       ! Calculate domain dimensions given calculated jpni and jpnj
@@ -234,9 +259,12 @@
 #endif
       ENDIF
-         jpk = jpkdta                                             ! third dim
-         jpim1 = jpi-1                                            ! inner domain indices
-         jpjm1 = jpj-1                                            !   "           "
-         jpkm1 = jpk-1                                            !   "           "
-         jpij  = jpi*jpj                                          !  jpi x j
+
+!!gm ???    why here  it has already been done in line 301 !
+      jpk = jpkglo                                             ! third dim
+!!gm end
+      jpim1 = jpi-1                                            ! inner domain indices
+      jpjm1 = jpj-1                                            !   "           "
+      jpkm1 = jpk-1                                            !   "           "
+      jpij  = jpi*jpj                                          !  jpi x j
 
       IF(lwp) THEN                            ! open listing units
@@ -244,4 +272,13 @@
          CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
          !
+
+         DO ji = 1, SIZE(clbug)
+            IF( TRIM(clbug (ji)) /= '' )   WRITE(numout,*) clbug(ji)      ! bug print 
+         END DO
+         WRITE(numout,*)
+
+
+
+
          WRITE(numout,*)
          WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
@@ -311,5 +348,4 @@
          WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
          WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
-         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
          WRITE(numout,*) '      timing activated    (0/1)       nn_timing  = ', nn_timing
       ENDIF
@@ -322,5 +358,4 @@
       isplt     = nn_isplt
       jsplt     = nn_jsplt
-      nbench    = nn_bench
 
       IF(lwp) THEN                  ! control print
@@ -329,8 +364,7 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         WRITE(numout,*) '      configuration name              cp_cfg      = ', TRIM(cp_cfg)
-         WRITE(numout,*) '      configuration zoom name         cp_cfz      = ', TRIM(cp_cfz)
-         WRITE(numout,*) '      configuration resolution        jp_cfg      = ', jp_cfg
-         WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      read configuration definition files          ln_read_cfg = ', ln_read_cfg
+         WRITE(numout,*) '      configuration name                               cp_cfg  = ', TRIM(cp_cfg)
+         WRITE(numout,*) '      configuration resolution                         jp_cfg  = ', jp_cfg
          WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 6982)
@@ -6,13 +6,13 @@
    !! History :  OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
    !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
-   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
-   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1 
+   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
+   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1
    !!             -   ! 1992-06  (L.Terray)  coupling implementation
-   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice 
-   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, 
+   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice
+   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
    !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0
    !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
-   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model 
-   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP 
+   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model
+   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
    !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
@@ -25,8 +25,12 @@
    !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
    !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
-   !!            3.3  ! 2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface 
+   !!            3.3  ! 2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
    !!             -   ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!            3.3.1! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
-   !!            3.4  ! 2011-11  (C. Harris) decomposition changes for running with CICE
+   !!            3.4  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE) add nemo_northcomms
+   !!             -   ! 2011-11  (C. Harris) decomposition changes for running with CICE
+   !!            3.6  ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening 
+   !!             -   ! 2013-06  (I. Epicoco, S. Mocavero, CMCC) nemo_northcomms: setup avoiding MPI communication 
+   !!             -   ! 2014-12  (G. Madec) remove KPP scheme and cross-land advection (cla)
    !!----------------------------------------------------------------------
 
@@ -64,4 +68,5 @@
 #endif
    USE bdy_par
+   USE usrdef_nam     ! user defined configuration
 
    IMPLICIT NONE
@@ -74,5 +79,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -84,5 +89,5 @@
       !!                     ***  ROUTINE nemo_gcm  ***
       !!
-      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal 
+      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
       !!              curvilinear mesh on the sphere.
       !!
@@ -124,14 +129,21 @@
       !                            !-----------------------!
       istp = nit000
-        
+#if defined key_agrif
+      CALL Agrif_Regrid()
+#endif
+
       DO WHILE ( istp <= nitend .AND. nstop == 0 )
 #if defined key_agrif
-         CALL Agrif_Step( stp )           ! AGRIF: time stepping
+         CALL stp                         ! AGRIF: time stepping
 #else
-         CALL stp( istp )                 ! standard time stepping
+         IF ( .NOT. ln_diurnal_only ) THEN
+            CALL stp( istp )                 ! standard time stepping
+         ELSE
+            CALL stp_diurnal( istp )        ! time step only the diurnal SST
+         ENDIF 
 #endif
          istp = istp + 1
          IF( lk_mpp )   CALL mpp_max( nstop )
-      END DO
+         END DO
       !
       IF( ln_icebergs )   CALL icb_end( nitend )
@@ -157,6 +169,6 @@
       !
 #if defined key_iomput
-      CALL xios_finalize                ! end mpp communications with xios
-      IF( lk_oasis ) CALL cpl_finalize    ! end coupling and mpp communications with OASIS
+      CALL xios_finalize                  ! end mpp communications with xios
+      IF( lk_oasis )   CALL cpl_finalize  ! end coupling and mpp communications with OASIS
 #else
       IF( lk_oasis ) THEN 
@@ -176,18 +188,22 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER ::   ji            ! dummy loop indices
-      INTEGER ::   ilocal_comm   ! local integer      
-      INTEGER ::   ios
-      CHARACTER(len=80), DIMENSION(16) ::   cltxt
-      CHARACTER(len=80) ::   clname
+      INTEGER  ::   ji            ! dummy loop indices
+      INTEGER  ::   ilocal_comm   ! local integer
+      INTEGER  ::   ios, inum     !   -      -
+      REAL(wp) ::   ziglo, zjglo, zkglo, zperio   ! local scalars
+      CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam, clbug
+      CHARACTER(len=80)                 ::   clname
       !
       NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
-         &             nn_bench, nn_timing, nn_diacfl
-      NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg,   &
-         &             jperio, ln_use_jattr
-      !!----------------------------------------------------------------------
-      !
-      cltxt = ''
+         &             nn_timing, nn_diacfl
+      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
+      !!----------------------------------------------------------------------
+      !
+      cltxt  = ''
+      cltxt2 = ''
+      clnam  = ''  
+      clbug  = ''
+      cxios_context = 'nemo'
       !
       !                             ! Open reference namelist and configuration namelist files
@@ -221,17 +237,35 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
-! Force values for AGRIF zoom (cf. agrif_user.F90)
+!!gm      WRITE(clbug(3),*) ' after namelist namcfg read    nstop', nstop
+
+      !                             !--------------------------!
+      !                             !  Set global domain size  !   (control print return in cltxt2)
+      !                             !--------------------------!
+      IF( ln_read_cfg ) THEN              ! Read sizes in configuration "mesh_mask" file
+         CALL iom_open( 'domain_cfg', inum )
+         CALL iom_get( inum, 'jpiglo', ziglo  )   ;   jpiglo = INT( ziglo )
+         CALL iom_get( inum, 'jpjglo', zjglo  )   ;   jpjglo = INT( zjglo )
+         CALL iom_get( inum, 'jpkglo', zkglo  )   ;   jpkglo = INT( zkglo )
+         CALL iom_get( inum, 'jperio', zperio )   ;   jperio = INT( zperio )
+         CALL iom_close( inum )
+         WRITE(cltxt2(1),*)       
+         WRITE(cltxt2(2),*) 'domain_cfg : domain size read in "domain_cfg" file : jp(i,j,k)glo = ', jpiglo, jpjglo, jpkglo        
+         WRITE(cltxt2(3),*) '~~~~~~~~~~   lateral boudary type of the global domain      jperio= ', jperio
+         !        
+      ELSE                                ! user-defined namelist
+         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      jpk    = jpkglo
+      !
 #if defined key_agrif
-   IF( .NOT. Agrif_Root() ) THEN
-      jpiglo  = nbcellsx + 2 + 2*nbghostcells
-      jpjglo  = nbcellsy + 2 + 2*nbghostcells
-      jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
-      jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
-      jpidta  = jpiglo
-      jpjdta  = jpjglo
-      nperio  = 0
-      jperio  = 0
-      ln_use_jattr = .false.
-   ENDIF
+      IF( .NOT. Agrif_Root() ) THEN       ! AGRIF children: specific setting (cf. agrif_user.F90)
+         jpiglo  = nbcellsx + 2 + 2*nbghostcells
+         jpjglo  = nbcellsy + 2 + 2*nbghostcells
+         jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
+         jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
+         nperio  = 0
+         jperio  = 0
+         ln_use_jattr = .false.
+      ENDIF
 #endif
       !
@@ -273,11 +307,16 @@
          WRITE( numond, namctl )
          WRITE( numond, namcfg )
+         IF( .NOT.ln_read_cfg ) THEN
+            DO ji = 1, SIZE(clnam)
+               IF( TRIM(clnam (ji)) /= '' )   WRITE(numond, * ) clnam(ji)    ! namusr_def print
+            END DO
+         ENDIF
       ENDIF
 
       ! 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) )THEN
+      IF( jpni < 1 .OR. jpnj < 1 ) THEN
 #if   defined key_mpp_mpi
-         IF( Agrif_Root() ) CALL nemo_partition(mppsize)
+         IF( Agrif_Root() )   CALL nemo_partition( mppsize )
 #else
          jpni  = 1
@@ -285,5 +324,5 @@
          jpnij = jpni*jpnj
 #endif
-      END IF
+      ENDIF
 
       ! Calculate domain dimensions given calculated jpni and jpnj
@@ -299,9 +338,19 @@
 #endif
       ENDIF
-         jpk = jpkdta                                             ! third dim
-         jpim1 = jpi-1                                            ! inner domain indices
-         jpjm1 = jpj-1                                            !   "           "
-         jpkm1 = jpk-1                                            !   "           "
-         jpij  = jpi*jpj                                          !  jpi x j
+
+!!gm ???    why here  it has already been done in line 301 !
+      jpk = jpkglo                                             ! third dim
+!!gm end
+
+#if defined key_agrif
+      ! simple trick to use same vertical grid as parent but different number of levels: 
+      ! Save maximum number of levels in jpkglo, then define all vertical grids with this number.
+      ! Suppress once vertical online interpolation is ok
+      IF(.NOT.Agrif_Root())   jpkglo = Agrif_Parent( jpkglo )
+#endif
+      jpim1 = jpi-1                                            ! inner domain indices
+      jpjm1 = jpj-1                                            !   "           "
+      jpkm1 = jpk-1                                            !   "           "
+      jpij  = jpi*jpj                                          !  jpi x j
 
       IF(lwp) THEN                            ! open listing units
@@ -317,5 +366,5 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                  version 3.6  (2015) '
+         WRITE(numout,*) '                  version 3.7  (2015) '
          WRITE(numout,*) '             StandAlone Surface version (SAS) '
          WRITE(numout,*)
@@ -324,4 +373,11 @@
             IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) 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( cltxt2(ji) /= '' )   WRITE(numout,*) cltxt2(ji)     ! control print of domain size
+         END DO
+         !
          WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
          !
@@ -392,5 +448,5 @@
          WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
          WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
-         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
+         WRITE(numout,*) '      timing activated    (0/1)       nn_timing  = ', nn_timing
       ENDIF
       !
@@ -402,5 +458,4 @@
       isplt     = nn_isplt
       jsplt     = nn_jsplt
-      nbench    = nn_bench
 
       IF(lwp) THEN                  ! control print
@@ -409,8 +464,7 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         WRITE(numout,*) '      configuration name              cp_cfg      = ', TRIM(cp_cfg)
-         WRITE(numout,*) '      configuration zoom name         cp_cfz      = ', TRIM(cp_cfz)
-         WRITE(numout,*) '      configuration resolution        jp_cfg      = ', jp_cfg
-         WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      read configuration definition files          ln_read_cfg = ', ln_read_cfg
+         WRITE(numout,*) '      configuration name                               cp_cfg  = ', TRIM(cp_cfg)
+         WRITE(numout,*) '      configuration resolution                         jp_cfg  = ', jp_cfg
          WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
@@ -609,8 +663,8 @@
 
       ! Clear the error flag and initialise output vars
-      kerr = 0
-      kfax = 1
+      kerr  = 0
+      kfax  = 1
       knfax = 0
-
+      !
       ! Find the factors of n.
       IF( kn == 1 )   GOTO 20
@@ -620,8 +674,8 @@
       ! l points to the allowed factor list.
       ! ifac holds the current factor.
-
+      !
       inu   = kn
       knfax = 0
-
+      !
       DO jl = ntest, 1, -1
          !
@@ -647,5 +701,5 @@
          !
       END DO
-
+      !
    20 CONTINUE      ! Label 20 is the exit point from the factor search loop.
       !
@@ -653,4 +707,5 @@
 
 #if defined key_mpp_mpi
+
    SUBROUTINE nemo_northcomms
       !!======================================================================
@@ -666,14 +721,14 @@
       !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC) 
       !!----------------------------------------------------------------------
-
       INTEGER  ::   sxM, dxM, sxT, dxT, jn
       INTEGER  ::   njmppmax
-
+      !!----------------------------------------------------------------------
+      !
       njmppmax = MAXVAL( njmppt )
-    
+      !
       !initializes the north-fold communication variables
       isendto(:) = 0
-      nsndto = 0
-
+      nsndto     = 0
+      !
       !if I am a process in the north
       IF ( njmpp == njmppmax ) THEN
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_ORCA2_LIM_OBS.cfg
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_ORCA2_LIM_OBS.cfg	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_ORCA2_LIM_OBS.cfg	(revision 6982)
@@ -1,1 +1,1 @@
-ORCA2_LIM_nemo_v3.6.tar ORCA2_LIM_nemo_v3.6
+ORCA2_LIM_nemo_v3.7.tar ORCA2_LIM_nemo_v3.7
Index: branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_SAS.cfg
===================================================================
--- branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_SAS.cfg	(revision 6980)
+++ branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/SETTE/input_SAS.cfg	(revision 6982)
@@ -1,2 +1,2 @@
-ORCA2_LIM_nemo_v3.6.tar ORCA2_LIM_nemo_v3.6
+ORCA2_LIM_nemo_v3.7.tar ORCA2_LIM_nemo_v3.7
 INPUTS_SAS_v3.5.tar SAS 
