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 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg	(revision 7200)
@@ -20,10 +20,7 @@
 &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      =  "amm"    !  name of the configuration
-   jp_cfg      =     011   !  resolution of the configuration
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "AMM_R12_domcfg"     ! domain configuration filename
 /
 
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg	(revision 7200)
@@ -25,12 +25,8 @@
 &namcfg     !   parameters of the configuration   
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
    !
-   cp_cfg      = "default" !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg	(revision 7200)
@@ -22,12 +22,7 @@
 &namcfg     !   parameters of the configuration   
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "default" !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg	(revision 7200)
@@ -15,12 +15,7 @@
 &namcfg     !   parameters of the configuration   
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "default" !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg	(revision 7200)
@@ -15,12 +15,7 @@
 &namcfg     !   parameters of the configuration   
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "default" !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ISOMIP/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ISOMIP/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ISOMIP/EXP00/namelist_cfg	(revision 7200)
@@ -20,12 +20,7 @@
 &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      = "default" !  name of the configuration
-   jp_cfg      =      0    !  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
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ISOMIP_domcfg"      ! domain configuration filename
 /
 !-----------------------------------------------------------------------
@@ -33,5 +28,5 @@
 !-----------------------------------------------------------------------
    ln_linssh   = .true.    !  =T  linear free surface  ==>>  model level are fixed in time
- !  ln_isfcav   = .true.    !  ice shelf cavity
+   ln_isfcav   = .true.    !  ice shelf cavity
    !
    nn_msh      =    0      !  create (>0) a mesh file or not (=0)
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/EXP00/namelist_cfg	(revision 7200)
@@ -24,12 +24,7 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "lock"    !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 7200)
@@ -38,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,4 +51,6 @@
       !!----------------------------------------------------------------------
       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. 
@@ -66,4 +68,8 @@
       !
       WRITE( ldnam(:), namusr_def )
+      !
+      !
+      cd_cfg = 'LOCK_EXCHANGE'      ! name & resolution (not used)
+      cp_cfg = INT( rn_dx )
       !
       ! Global Domain size:  LOCK_EXCHANGE domain is 64 km x 3 grid-points x 20 m
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg	(revision 7200)
@@ -15,6 +15,7 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   cp_cfg      =  "default"             !  name of the configuration
-   jp_cfg      =      -1               !  resolution of the configuration
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "AGRIF_AGULHAS_domain_cfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
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 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg	(revision 7200)
@@ -14,12 +14,7 @@
 &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
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg	(revision 7200)
@@ -14,6 +14,7 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   cp_cfg      =  "default"             !  name of the configuration
-   jp_cfg      =      -1               !  resolution of the configuration
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "AGRIF_AGULHAS_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
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 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg	(revision 7200)
@@ -14,12 +14,7 @@
 &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
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg	(revision 7200)
@@ -17,6 +17,7 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   cp_cfg      =  "orca"               !  name of the configuration
-   jp_cfg      =       2               !  resolution of the configuration
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg	(revision 7200)
@@ -14,12 +14,7 @@
 &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
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg	(revision 7200)
@@ -13,8 +13,7 @@
 &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
-   cp_cfg      = "orca" !  name of the configuration
-   jp_cfg      =      2    !  resolution of the configuration
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg	(revision 7200)
@@ -14,12 +14,7 @@
 &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
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "ORCA_R2_domcfg"    ! domain configuration filename
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/EXP00/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/EXP00/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/EXP00/namelist_cfg	(revision 7200)
@@ -31,9 +31,4 @@
    !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "overflow" !  name of the configuration
-   jp_cfg      =      0    !  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
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/MY_SRC/usrdef_nam.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 7200)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,4 +52,6 @@
       !!----------------------------------------------------------------------
       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. 
@@ -67,4 +69,7 @@
       !
       WRITE( ldnam(:), namusr_def )
+      !
+      cd_cfg = 'OVERFLOW'           ! name & resolution (not used)
+      kk_cfg = INT( rn_dx )
       !
       ! Global Domain size:  OVERFLOW domain is  200 km x 3 grid-points x 2000 m
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 7200)
@@ -71,10 +71,11 @@
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
-   ln_read_cfg = .false.   !  (=T) read the domain configuration in 'domain_cfg.nc" file
-   !                       !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "domain_cfg"         ! domain configuration filename
+      !
    ln_write_cfg= .false.   !  (=T) create the domain configuration file
-   !
-   cp_cfg      = "default" !  name of the configuration
-   jp_cfg      =      0    !  resolution of the configuration
+      cn_domcfg_out = "domain_cfg_out" ! newly created domain configuration filename
+      !
    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
@@ -458,34 +459,34 @@
 &namberg       !   iceberg parameters                                   (default: No iceberg)
 !-----------------------------------------------------------------------
-      ln_icebergs              = .false.              ! iceberg floats or not
-      ln_bergdia               = .true.               ! Calculate budgets
-      nn_verbose_level         = 1                    ! Turn on more verbose output if level > 0
-      nn_verbose_write         = 15                   ! Timesteps between verbose messages
-      nn_sample_rate           = 1                    ! Timesteps between sampling for trajectory storage
-                                                      ! Initial mass required for an iceberg of each class
-      rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
-                                                      ! Proportion of calving mass to apportion to each class
-      rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
-                                                      ! Ratio between effective and real iceberg mass (non-dim)
-                                                      ! i.e. number of icebergs represented at a point
-      rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
-                                                      ! thickness of newly calved bergs (m)
-      rn_initial_thickness     = 40., 67., 133., 175., 250., 250., 250., 250., 250., 250.
-      rn_rho_bergs             = 850.                 ! Density of icebergs
-      rn_LoW_ratio             = 1.5                  ! Initial ratio L/W for newly calved icebergs
-      ln_operator_splitting    = .true.               ! Use first order operator splitting for thermodynamics
-      rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
-      rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
-      ln_passive_mode          = .false.              ! iceberg - ocean decoupling
-      nn_test_icebergs         =  10                  ! Create test icebergs of this class (-1 = no)
-                                                      ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
-      rn_test_box              = 108.0,  116.0, -66.0, -58.0
-      rn_speed_limit           = 0.                   ! CFL speed limit for a berg
-
-!            ! 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_icb =  'calving',       -1          , 'calvingmask',  .true.      , .true.  , 'yearly'  , ''       , ''       , ''
-
-      cn_dir = './'
+   ln_icebergs              = .false.              ! iceberg floats or not
+   ln_bergdia               = .true.               ! Calculate budgets
+   nn_verbose_level         = 1                    ! Turn on more verbose output if level > 0
+   nn_verbose_write         = 15                   ! Timesteps between verbose messages
+   nn_sample_rate           = 1                    ! Timesteps between sampling for trajectory storage
+                                                   ! Initial mass required for an iceberg of each class
+   rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
+                                                   ! Proportion of calving mass to apportion to each class
+   rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
+                                                   ! Ratio between effective and real iceberg mass (non-dim)
+                                                   ! i.e. number of icebergs represented at a point
+   rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
+                                                   ! thickness of newly calved bergs (m)
+   rn_initial_thickness     = 40., 67., 133., 175., 250., 250., 250., 250., 250., 250.
+   rn_rho_bergs             = 850.                 ! Density of icebergs
+   rn_LoW_ratio             = 1.5                  ! Initial ratio L/W for newly calved icebergs
+   ln_operator_splitting    = .true.               ! Use first order operator splitting for thermodynamics
+   rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
+   rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
+   ln_passive_mode          = .false.              ! iceberg - ocean decoupling
+   nn_test_icebergs         =  10                  ! Create test icebergs of this class (-1 = no)
+                                                   ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
+   rn_test_box              = 108.0,  116.0, -66.0, -58.0
+   rn_speed_limit           = 0.                   ! CFL speed limit for a berg
+
+!         ! 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_icb =  'calving',       -1          , 'calvingmask',  .true.      , .true.  , 'yearly'  , ''       , ''       , ''
+
+   cn_dir = './'
 /
 
@@ -519,42 +520,43 @@
 &nam_tide      !   tide parameters                                      ("key_tide")
 !-----------------------------------------------------------------------
-   ln_tide_pot   = .true.   !  use tidal potential forcing
-   ln_tide_ramp  = .false.  !
-   rdttideramp   =    0.    !
-   clname(1)     = 'DUMMY'  !  name of constituent - all tidal components must be set in namelist_cfg
+   ln_tide_pot = .true.    !  use tidal potential forcing
+   ln_tide_ramp= .false.   !
+   rdttideramp =    0.     !
+   clname(1)   = 'DUMMY'   !  name of constituent 
+   !                       !  all tidal components must be set in namelist_cfg
 /
 !-----------------------------------------------------------------------
 &nambdy        !  unstructured open boundaries                          ("key_bdy")
 !-----------------------------------------------------------------------
-    nb_bdy         = 0                    !  number of open boundary sets
-    ln_coords_file = .true.               !  =T : read bdy coordinates from file
-    cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
-    ln_mask_file   = .false.              !  =T : read mask from file
-    cn_mask_file   = ''                   !  name of mask file (if ln_mask_file=.TRUE.)
-    cn_dyn2d       = 'none'               !
-    nn_dyn2d_dta   =  0                   !  = 0, bdy data are equal to the initial state
-                                          !  = 1, bdy data are read in 'bdydata   .nc' files
-                                          !  = 2, use tidal harmonic forcing data from files
-                                          !  = 3, use external data AND tidal harmonic forcing
-    cn_dyn3d      =  'none'               !
-    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
-                                          !  = 1, bdy data are read in 'bdydata   .nc' files
-    cn_tra        =  'none'               !
-    nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
-                                          !  = 1, bdy data are read in 'bdydata   .nc' files
-    cn_ice_lim      =  'none'             !
-    nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
-                                          !  = 1, bdy data are read in 'bdydata   .nc' files
-    rn_ice_tem      = 270.                !  lim3 only: arbitrary temperature of incoming sea ice
-    rn_ice_sal      = 10.                 !  lim3 only:      --   salinity           --
-    rn_ice_age      = 30.                 !  lim3 only:      --   age                --
-
-    ln_tra_dmp    =.false.                !  open boudaries conditions for tracers
-    ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
-    rn_time_dmp   =  1.                   ! Damping time scale in days
-    rn_time_dmp_out =  1.                 ! Outflow damping time scale
-    nn_rimwidth   = 10                    !  width of the relaxation zone
-    ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
-    nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
+   nb_bdy         = 0                    !  number of open boundary sets
+   ln_coords_file = .true.               !  =T : read bdy coordinates from file
+   cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
+   ln_mask_file   = .false.              !  =T : read mask from file
+   cn_mask_file   = ''                   !  name of mask file (if ln_mask_file=.TRUE.)
+   cn_dyn2d       = 'none'               !
+   nn_dyn2d_dta   =  0                   !  = 0, bdy data are equal to the initial state
+      !                                  !  = 1, bdy data are read in 'bdydata   .nc' files
+      !                                  !  = 2, use tidal harmonic forcing data from files
+      !                                  !  = 3, use external data AND tidal harmonic forcing
+   cn_dyn3d      =  'none'               !
+   nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
+      !                                  !  = 1, bdy data are read in 'bdydata   .nc' files
+   cn_tra        =  'none'               !
+   nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+      !                                  !  = 1, bdy data are read in 'bdydata   .nc' files
+   cn_ice_lim      =  'none'             !
+   nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
+      !                                  !  = 1, bdy data are read in 'bdydata   .nc' files
+   rn_ice_tem      = 270.                !  lim3 only: arbitrary temperature of incoming sea ice
+   rn_ice_sal      = 10.                 !  lim3 only:      --   salinity           --
+   rn_ice_age      = 30.                 !  lim3 only:      --   age                --
+   !
+   ln_tra_dmp    =.false.                !  open boudaries conditions for tracers
+   ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
+   rn_time_dmp   =  1.                   ! Damping time scale in days
+   rn_time_dmp_out =  1.                 ! Outflow damping time scale
+   nn_rimwidth   = 10                    !  width of the relaxation zone
+   ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
+   nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
 /
 !-----------------------------------------------------------------------
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 7200)
@@ -479,5 +479,5 @@
 
       !! Fram Strait sea-ice transport (sea-ice + snow)  (in ORCA2 = 5 points)
-      IF( iom_use('fram_trans') .and. cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
+      IF( iom_use('fram_trans') .and. cn_cfg == "orca" .AND. nn_cfg == 2 ) THEN    ! ORCA R2 configuration
          DO jj = mj0(137), mj1(137) ! B grid
             IF( mj0(jj-1) >= nldj ) THEN
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 7200)
@@ -1,5 +1,5 @@
 #if defined key_agrif
 !!----------------------------------------------------------------------
-!! NEMO/NST 3.7 , NEMO Consortium (2015)
+!! NEMO/NST 3.7 , NEMO Consortium (2016)
 !! $Id$
 !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
@@ -18,5 +18,5 @@
    USE dom_oce
    USE nemogcm
-   !
+   !!
    IMPLICIT NONE
    !!----------------------------------------------------------------------
@@ -60,25 +60,26 @@
    USE tradmp
    USE bdy_par
-
-   IMPLICIT NONE
-   !!----------------------------------------------------------------------
-   ! 0. Initializations
-   !-------------------
-   IF( cp_cfg == 'orca' ) THEN
-      IF ( jp_cfg == 2 .OR. jp_cfg == 025 .OR. jp_cfg == 05 &
-            &                      .OR. jp_cfg == 4 ) THEN
-         jp_cfg = -1    ! set special value for jp_cfg on fine grids
-         cp_cfg = "default"
+   !!
+   IMPLICIT NONE
+   !!----------------------------------------------------------------------
+   !
+!!gm  I think this is now useless ...   nn_cfg & cn_cfg are set to -999999 and "UNKNOWN" 
+!!gm                                    when reading the AGRIF domain configuration file
+   IF( cn_cfg == 'orca' ) THEN
+      IF ( nn_cfg == 2 .OR. nn_cfg == 025 .OR. nn_cfg == 05  .OR. nn_cfg == 4 ) THEN
+         nn_cfg = -1    ! set special value for nn_cfg on fine grids
+         cn_cfg = "default"
       ENDIF
    ENDIF
-   ! Specific fine grid Initializations
-   ! no tracer damping on fine grids
-   ln_tradmp = .FALSE.
-   ! no open boundary on fine grids
-   lk_bdy = .FALSE.
-
-
-   CALL nemo_init  ! Initializations of each fine grid
-
+!!gm end
+
+   !                    !* Specific fine grid Initializations
+   ln_tradmp = .FALSE.        ! no tracer damping on fine grids
+   !
+   lk_bdy    = .FALSE.        ! no open boundary on fine grids
+
+   CALL nemo_init       !* Initializations of each fine grid
+
+   !                    !* Agrif initialization
    CALL agrif_nemo_init
    CALL Agrif_InitValues_cont_dom
@@ -88,5 +89,6 @@
 # if defined key_top
    CALL Agrif_InitValues_cont_top
-# endif      
+# endif
+   !
 END SUBROUTINE Agrif_initvalues
 
@@ -106,11 +108,10 @@
    USE agrif_opa_interp
    USE agrif_opa_sponge
-   !
-   IMPLICIT NONE
-   !
-   !!----------------------------------------------------------------------
-
+   !!
+   IMPLICIT NONE
+   !!----------------------------------------------------------------------
+   !
    ! Declaration of the type of variable which have to be interpolated
-   !---------------------------------------------------------------------
+   !
    CALL agrif_declare_var_dom
    !
@@ -127,4 +128,5 @@
    USE par_oce       
    USE oce
+   !!
    IMPLICIT NONE
    !!----------------------------------------------------------------------
@@ -174,5 +176,5 @@
    USE agrif_opa_interp
    USE agrif_opa_sponge
-   !
+   !!
    IMPLICIT NONE
    !
@@ -344,4 +346,5 @@
    USE oce
    USE agrif_oce
+   !!
    IMPLICIT NONE
    !!----------------------------------------------------------------------
@@ -482,7 +485,6 @@
    USE agrif_lim2_interp
    USE lib_mpp
-   !
-   IMPLICIT NONE
-   !
+   !!
+   IMPLICIT NONE
    !!----------------------------------------------------------------------
 
@@ -519,4 +521,5 @@
 END SUBROUTINE Agrif_InitValues_cont_lim2
 
+
 SUBROUTINE agrif_declare_var_lim2
    !!----------------------------------------------------------------------
@@ -527,5 +530,5 @@
    USE agrif_util
    USE ice_2
-
+   !!
    IMPLICIT NONE
    !!----------------------------------------------------------------------
@@ -583,5 +586,5 @@
    USE agrif_top_interp
    USE agrif_top_sponge
-   !
+   !!
    IMPLICIT NONE
    !
@@ -682,6 +685,7 @@
    USE dom_oce
    USE trc
-
-   IMPLICIT NONE
+   !!
+   IMPLICIT NONE
+   !!----------------------------------------------------------------------
 
    ! 1. Declaration of the type of variable which have to be interpolated
@@ -714,7 +718,6 @@
 SUBROUTINE Agrif_detect( kg, ksizex )
    !!----------------------------------------------------------------------
-   !!   *** ROUTINE Agrif_detect ***
-   !!----------------------------------------------------------------------
-   !
+   !!                      *** ROUTINE Agrif_detect ***
+   !!----------------------------------------------------------------------
    INTEGER, DIMENSION(2) :: ksizex
    INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg 
@@ -734,4 +737,5 @@
    USE in_out_manager
    USE lib_mpp
+   !!
    IMPLICIT NONE
    !
@@ -787,4 +791,5 @@
    !!----------------------------------------------------------------------
    USE dom_oce
+   !!
    IMPLICIT NONE
    !
@@ -801,4 +806,5 @@
 END SUBROUTINE Agrif_InvLoc
 
+
 SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax )
    !!----------------------------------------------------------------------
@@ -806,4 +812,5 @@
    !!----------------------------------------------------------------------
    USE par_oce
+   !!
    IMPLICIT NONE
    !
@@ -819,4 +826,5 @@
 END SUBROUTINE Agrif_get_proc_info
 
+
 SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost)
    !!----------------------------------------------------------------------
@@ -824,4 +832,5 @@
    !!----------------------------------------------------------------------
    USE par_oce
+   !!
    IMPLICIT NONE
    !
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 7200)
@@ -2,22 +2,27 @@
    !!======================================================================
    !!                       ***  MODULE nemogcm   ***
-   !! Off-line Ocean   : passive tracer evolution, dynamics read in files
+   !! OFF-line Ocean   : passive tracer evolution, dynamics read in files
    !!======================================================================
    !! History :  3.3  ! 2010-05  (C. Ethe)  Full reorganization of the off-line: phasing with the on-line
    !!            4.0  ! 2011-01  (C. Ethe, A. R. Porter, STFC Daresbury) dynamical allocation
+   !!            4.0  ! 2016-10  (C. Ethe, G. Madec, S. Flavoni)  domain configuration / user defined interface
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   nemo_gcm        : off-line: solve ocean tracer only
-   !!   nemo_init       : initialization of the nemo model
-   !!   nemo_ctl        : initialisation of algorithm flag 
-   !!   nemo_closefile  : close remaining files
+   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
+   !!   nemo_init     : initialization of the NEMO system
+   !!   nemo_ctl      : initialisation of the contol print
+   !!   nemo_closefile: close remaining open files
+   !!   nemo_alloc    : dynamical allocation
+   !!   nemo_partition: calculate MPP domain decomposition
+   !!   factorise     : calculate the factors of the no. of MPI processes
+   !!   istate_init   : ocean variables set to zero
+   !!   stp_ctl       : step control for OFF-line
    !!----------------------------------------------------------------------
    USE dom_oce         ! ocean space domain variables
    USE oce             ! dynamics and tracers variables
    USE c1d             ! 1D configuration
-   USE domcfg          ! domain configuration               (dom_cfg routine)
    USE domain          ! domain initialization from coordinate & bathymetry (dom_init routine)
-!   USE domrea          ! domain initialization from mesh_mask            (dom_init routine)
+   USE usrdef_nam     ! user defined configuration
    USE eosbn2          ! equation of state            (eos bn2 routine)
    !              ! ocean physics
@@ -35,4 +40,11 @@
    USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
    USE dtadyn          ! Lecture and interpolation of the dynamical fields
+   !              ! Passive tracers needs
+   USE trc             ! passive tracer : variables
+   USE trcnam          ! passive tracer : namelist
+   USE trcrst          ! passive tracer restart
+   USE diaptr          ! Need to initialise this as some variables are used in if statements later
+   USE sbc_oce  , ONLY : ln_rnf
+   USE sbcrnf          ! surface boundary condition : runoffs
    !              ! I/O & MPP
    USE iom             ! I/O library
@@ -48,13 +60,4 @@
    USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges
 
-   USE trc
-   USE trcnam
-   USE trcrst
-   USE diaptr         ! Need to initialise this as some variables are used in if statements later
-   USE sbc_oce, ONLY: ln_rnf
-   USE sbcrnf
-   USE usrdef_nam     ! user defined configuration
-
-
    IMPLICIT NONE
    PRIVATE
@@ -65,5 +68,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OFF 3.3 , NEMO Consortium (2010)
+   !! NEMO/OFF 4.0 , NEMO Consortium (2016)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -75,6 +78,6 @@
       !!                     ***  ROUTINE nemo_gcm  ***
       !!
-      !! ** Purpose :   nemo solves the primitive equations on an orthogonal
-      !!      curvilinear mesh on the sphere.
+      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
+      !!              curvilinear mesh on the sphere.
       !!
       !! ** Method  : - model general initialization
@@ -85,8 +88,10 @@
       !!              Madec, 2008, internal report, IPSL.
       !!----------------------------------------------------------------------
-      INTEGER :: istp, indic       ! time step index
-      !!----------------------------------------------------------------------
-
-      CALL nemo_init  ! Initializations
+      INTEGER :: istp, indic   ! time step index
+      !!----------------------------------------------------------------------
+
+      !                            !-----------------------!
+      CALL nemo_init               !==  Initialisations  ==!
+      !                            !-----------------------!
 
       ! check that all process are still there... If some process have an error,
@@ -121,7 +126,7 @@
       !                            !==  finalize the run  ==!
       !                            !------------------------!
-      IF(lwp) WRITE(numout,cform_aaa)                 ! Flag AAAAAAA
-
-      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
+      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
+      !
+      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
          WRITE(numout,cform_err)
          WRITE(numout,*) nstop, ' error have been found'
@@ -132,9 +137,9 @@
       CALL nemo_closefile
       !
-# if defined key_iomput
-      CALL xios_finalize             ! end mpp communications
-# else
-      IF( lk_mpp )   CALL mppstop       ! end mpp communications
-# endif
+#if defined key_iomput
+      CALL xios_finalize                     ! end mpp communications
+#else
+      IF( lk_mpp )   CALL mppstop            ! end mpp communications
+#endif
       !
    END SUBROUTINE nemo_gcm
@@ -143,20 +148,19 @@
    SUBROUTINE nemo_init
       !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE nemo_init ***
-      !!
-      !! ** Purpose :   initialization of the nemo model in off-line mode
-      !!----------------------------------------------------------------------
-      INTEGER ::   ji            ! dummy loop indices
-      INTEGER ::   ilocal_comm   ! local integer
-      INTEGER ::   ios, inum
-      REAL(wp) ::   ziglo, zjglo, zkglo, zperio   ! local scalars
+      !!                     ***  ROUTINE nemo_init  ***
+      !!
+      !! ** Purpose :   initialization of NEMO in off-line mode
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji            ! dummy loop indices
+      INTEGER  ::   ilocal_comm   ! local integer
+      INTEGER  ::   ios, inum     !   -      -
       CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
-      !!
-      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
-         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
+      !
+      NAMELIST/namctl/ ln_ctl   , nn_print, nn_ictls, nn_ictle,   &
+         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_timing, nn_diacfl
-
-      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
-      !!----------------------------------------------------------------------
+      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_write_cfg, cn_domcfg_out, ln_use_jattr
+      !!----------------------------------------------------------------------
+      !
       cltxt  = ''
       cltxt2 = ''
@@ -168,14 +172,13 @@
       CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
       !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints
       READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
       READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints
       READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
 903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
@@ -185,22 +188,12 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
-
       !                             !--------------------------!
       !                             !  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 = '
-         WRITE(cltxt2(3),*) '            ', jpiglo, jpjglo, jpkglo        
-         WRITE(cltxt2(1),*) '~~~~~~~~~~   lateral boudary type of the global domain jperio= ', jperio
-         !        
+      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
+         CALL domain_cfg ( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+         !
       ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
+         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
       ENDIF
       jpk    = jpkglo
@@ -224,28 +217,27 @@
       lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
 
-      IF(lwm) THEN
-         ! write merged namelists from earlier to output namelist now that the
-         ! file has been opened in call to mynode. nammpp has already been
-         ! written in mynode (if lk_mpp_mpi)
+      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
+         !                       ! now that the file has been opened in call to mynode. 
+         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
          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
+               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 
+      ! 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   defined key_mpp_mpi
-         CALL nemo_partition(mppsize)
+      IF( jpni < 1 .OR. jpnj < 1 ) THEN
+#if defined key_mpp_mpi
+         CALL nemo_partition( mppsize )
 #else
-         jpni = 1
-         jpnj = 1
+         jpni  = 1
+         jpnj  = 1
          jpnij = jpni*jpnj
 #endif
-      END IF
+      ENDIF
 
       ! Calculate domain dimensions given calculated jpni and jpnj
@@ -259,5 +251,4 @@
       jpij  = jpi*jpj                                          !  jpi x j
 
-
       IF(lwp) THEN                            ! open listing units
          !
@@ -268,23 +259,26 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                  version 3.6  (2015) '
+         WRITE(numout,*) '                  version 3.7  (2016) '
          WRITE(numout,*)
          WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt) 
-            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
+         DO ji = 1, SIZE(cltxt)
+            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) cltxt(ji)    ! control print of mynode
          END DO
-         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
+         WRITE(numout,*)
+         WRITE(numout,*)
+         DO ji = 1, SIZE(cltxt2)
+            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) cltxt2(ji)   ! control print of domain size
+         END DO
+         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
 
-      ! Now we know the dimensions of the grid and numout has been set we can 
-      ! allocate arrays
+      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
       CALL nemo_alloc()
-
-      !                             !--------------------------------!
-      !                             !  Model general initialization  !
-      !                             !--------------------------------!
-
-      CALL nemo_ctl                           ! Control prints & Benchmark
+      !                             !-------------------------------!
+      !                             !  NEMO general initialization  !
+      !                             !-------------------------------!
+
+      CALL nemo_ctl                          ! Control prints
 
       !                                      ! Domain decomposition
@@ -295,5 +289,4 @@
       IF( nn_timing == 1 )  CALL timing_init
       !
-
       !                                      ! General initialization
       IF( nn_timing == 1 )  CALL timing_start( 'nemo_init')
@@ -374,8 +367,9 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         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
+         WRITE(numout,*) '      read domain configuration files               ln_read_cfg      = ', ln_read_cfg
+         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
+         WRITE(numout,*) '      write  configuration definition files         ln_write_cfg     = ', ln_write_cfg
+         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
@@ -432,5 +426,5 @@
       !!----------------------------------------------------------------------
       !
-      IF ( lk_mpp ) CALL mppsync
+      IF( lk_mpp )   CALL mppsync
       !
       CALL iom_close                                 ! close all input/output files managed by iom_*
@@ -455,5 +449,5 @@
       !! ** Method  :
       !!----------------------------------------------------------------------
-      USE diawri,       ONLY: dia_wri_alloc
+      USE diawri ,      ONLY: dia_wri_alloc
       USE dom_oce,      ONLY: dom_oce_alloc
       USE zdf_oce,      ONLY: zdf_oce_alloc
@@ -484,5 +478,5 @@
       !! ** Method  :
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have
+      INTEGER, INTENT(in) ::   num_pes   ! The number of MPI processes we have
       !
       INTEGER, PARAMETER :: nfactmax = 20
@@ -493,9 +487,9 @@
       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'
@@ -528,5 +522,5 @@
       !!
       !! ** Purpose :   return the prime factors of n.
-      !!                knfax factors are returned in array kfax which is of 
+      !!                knfax factors are returned in array kfax which is of
       !!                maximum dimension kmaxfax.
       !! ** Method  :
@@ -538,16 +532,15 @@
       INTEGER :: ifac, jl, inu
       INTEGER, PARAMETER :: ntest = 14
-      INTEGER :: ilfax(ntest)
+      INTEGER, DIMENSION(ntest) ::   ilfax
+      !!----------------------------------------------------------------------
       !
       ! lfax contains the set of allowed factors.
-      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
-         &                            128,   64,   32,   16,    8,   4,   2  /
-      !!----------------------------------------------------------------------
-
+      ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)
+      !
       ! 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
@@ -557,8 +550,8 @@
       ! l points to the allowed factor list.
       ! ifac holds the current factor.
-
+      !
       inu   = kn
       knfax = 0
-
+      !
       DO jl = ntest, 1, -1
          !
@@ -584,5 +577,5 @@
          !
       END DO
-
+      !
    20 CONTINUE      ! Label 20 is the exit point from the factor search loop.
       !
@@ -590,28 +583,26 @@
 
 #if defined key_mpp_mpi
+
    SUBROUTINE nemo_northcomms
-      !!======================================================================
+      !!----------------------------------------------------------------------
       !!                     ***  ROUTINE  nemo_northcomms  ***
-      !! nemo_northcomms    :  Setup for north fold exchanges with explicit 
-      !!                       point-to-point messaging
-      !!=====================================================================
-      !!----------------------------------------------------------------------
-      !!
-      !! ** Purpose :   Initialization of the northern neighbours lists.
+      !! ** Purpose :   Setup for north fold exchanges with explicit 
+      !!                point-to-point messaging
+      !!
+      !! ** Method :   Initialization of the northern neighbours lists.
       !!----------------------------------------------------------------------
       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
-      !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S.
-      !Mocavero, CMCC) 
-      !!----------------------------------------------------------------------
-
+      !!    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
@@ -625,5 +616,5 @@
           !loop over the other north-fold processes to find the processes
           !managing the points belonging to the sxT-dxT range
-
+  
           DO jn = 1, jpni
                 !sxT is the first point (in the global domain) of the jn
@@ -660,4 +651,5 @@
       l_north_nogather = .TRUE.
    END SUBROUTINE nemo_northcomms
+
 #else
    SUBROUTINE nemo_northcomms      ! Dummy routine
@@ -686,4 +678,5 @@
    END SUBROUTINE istate_init
 
+
    SUBROUTINE stp_ctl( kt, kindic )
       !!----------------------------------------------------------------------
@@ -712,4 +705,5 @@
       !
    END SUBROUTINE stp_ctl
+
    !!======================================================================
 END MODULE nemogcm
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/C1D/domc1d.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/C1D/domc1d.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/C1D/domc1d.F90	(revision 7200)
@@ -85,31 +85,31 @@
       !  mesh, only glamt and gphit   !
       ! ============================= !
-
+      !
       SELECT CASE( jphgr_msh )   ! type of horizontal mesh
-
+      !
       CASE ( 0 )                 !  curvilinear coordinate on the sphere read in coordinate.nc file
-
+         !
          CALL iom_open( 'coordinates', inum )
          CALL iom_get( inum, jpdom_unknown, 'glamt', glamdta ) ! mig, mjg undefined at this point
          CALL iom_get( inum, jpdom_unknown, 'gphit', gphidta ) ! so use jpdom_unknown not jpdom_data
          CALL iom_close ( inum )
-
+         !
       CASE ( 1 )                 ! geographical mesh on the sphere with regular grid-spacing
-
+         !
          DO jj = 1, jpjdta
             DO ji = 1, jpidta
                zti = FLOAT( ji - 1 + nimpp - 1 )
                ztj = FLOAT( jj - 1 + njmpp - 1 )
-
+               !
                glamdta(ji,jj) = ppglam0 + ppe1_deg * zti
                gphidta(ji,jj) = ppgphi0 + ppe2_deg * ztj
             END DO
          END DO
-
+         !
       CASE ( 2:3 )               ! f- or beta-plane with regular grid-spacing
-         
+         !
          glam0 = 0.e0
          gphi0 = - ppe2_m * 1.e-3
-
+         !
          DO jj = 1, jpjdta
             DO ji = 1, jpidta
@@ -118,36 +118,36 @@
             END DO
          END DO
-
+         !
       CASE ( 4 )                 ! geographical mesh on the sphere, isotropic MERCATOR type
-
+         !
          IF( ppgphi0 == -90 )   CALL ctl_stop( ' Mercator grid cannot start at south pole !!!! ' )
-
+         !
          zarg = rpi / 4. - rpi / 180. * ppgphi0 / 2.
          ijeq = ABS( 180. / rpi * LOG( COS( zarg ) / SIN( zarg ) ) / ppe1_deg )
          IF( ppgphi0 > 0 )   ijeq = -ijeq
-
+         !
          DO jj = 1, jpjdta
             DO ji = 1, jpidta
                zti = FLOAT( ji - 1    + nimpp - 1 )
                ztj = FLOAT( jj - ijeq + njmpp - 1 )
-
+               !
                glamdta(ji,jj) = ppglam0 + ppe1_deg * zti
                gphidta(ji,jj) = 1. / rad * ASIN ( TANH( ppe1_deg * rad * ztj ) )
             END DO
          END DO
-
+         !
       CASE ( 5 )                 ! beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
-   
+         !
          zlam1 = -85
          zphi1 = 29
-         ze1 = 106000. / FLOAT(jp_cfg)
- 
+         ze1 = 106000. / REAL( nn_cfg , wp )
+         !
          zsin_alpha = - SQRT( 2. ) / 2.
          zcos_alpha =   SQRT( 2. ) / 2.
          ze1deg = ze1 / (ra * rad)
-
+         !
          glam0 = zlam1 + zcos_alpha * ze1deg * FLOAT( jpjdta-2 ) ! Force global
          gphi0 = zphi1 + zsin_alpha * ze1deg * FLOAT( jpjdta-2 )
-
+         !
          DO jj = 1, jpjdta
             DO ji = 1, jpidta
@@ -159,10 +159,10 @@
             END DO
          END DO
-
+         !
       CASE DEFAULT
-
+         !
          WRITE(ctmp1,*) '          bad flag value for jphgr_msh = ', jphgr_msh
          CALL ctl_stop( ctmp1 )
-
+         !
       END SELECT
 
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/depth_e3.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/depth_e3.F90	(revision 7200)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/depth_e3.F90	(revision 7200)
@@ -0,0 +1,165 @@
+MODULE depth_e3
+   !!======================================================================
+   !!                       ***  MODULE  depth_e3  ***
+   !!
+   !! zgr : vertical coordinate system 
+   !!======================================================================
+   !! History :  4.0  ! 2016-11  (S. Flavoni, G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   depth_to_e3   : use the depth of t- and w-points to calculate e3t & e3w
+   !!                   (generic interface for 1D and 3D fields)
+   !!   e3_to_depth   : use e3t & e3w to calculate the depth of t- and w-points
+   !!                   (generic interface for 1D and 3D fields)
+   !!---------------------------------------------------------------------
+   USE oce               ! ocean variables
+   USE dom_oce           ! ocean domain
+   !
+   USE in_out_manager    ! I/O manager
+   USE lbclnk            ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp           ! distributed memory computing library
+   USE wrk_nemo          ! Memory allocation
+   USE timing            ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+  
+   INTERFACE depth_to_e3
+      MODULE PROCEDURE depth_to_e3_1d, depth_to_e3_3d
+   END INTERFACE
+
+   INTERFACE e3_to_depth
+      MODULE PROCEDURE e3_to_depth_1d, e3_to_depth_3d
+   END INTERFACE
+
+   PUBLIC   depth_to_e3        ! called by usrdef_zgr
+   PUBLIC   e3_to_depth        ! 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 depth_to_e3_1d( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d )
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE depth_to_e3_1d  ***
+      !!
+      !! ** Purpose :   compute e3t & e3w scale factors from t- & w-depths of model levels
+      !!
+      !! ** Method  :   The scale factors are given by the discrete derivative 
+      !!              of the depth:
+      !!                               e3w(jk) = dk[ dept_1d ] 
+      !!                               e3t(jk) = dk[ depw_1d ]
+      !!              with, at top and bottom :
+      !!                      e3w( 1 ) = 2 * ( dept( 1 ) - depw( 1 ) )
+      !!                      e3t(jpk) = 2 * ( dept(jpk) - depw(jpk) )   
+      !!
+      !! ** Action  : - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(in   ) ::   pdept_1d, pdepw_1d   ! depths          [m]
+      REAL(wp), DIMENSION(:), INTENT(  out) ::   pe3t_1d , pe3w_1d    ! e3.=dk[depth]   [m]
+      !
+      INTEGER  ::   jk           ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      ! use pdep. at w- and t-points to compute e3. (e3. = dk[depth])
+      !
+      pe3w_1d( 1 ) = 2._wp * ( pdept_1d(1) - pdepw_1d(1) ) 
+      DO jk = 1, jpkm1
+         pe3w_1d(jk+1) = pdept_1d(jk+1) - pdept_1d(jk) 
+         pe3t_1d(jk  ) = pdepw_1d(jk+1) - pdepw_1d(jk) 
+      END DO
+      pe3t_1d(jpk) = 2._wp * ( pdept_1d(jpk) - pdepw_1d(jpk) )
+      !
+   END SUBROUTINE depth_to_e3_1d
+   
+      
+   SUBROUTINE depth_to_e3_3d( pdept_3d, pdepw_3d, pe3t_3d, pe3w_3d )
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE depth_to_e3_3d  ***
+      !!
+      !! ** Purpose :   compute e3t & e3w scale factors from t- & w-depths of model levels
+      !!
+      !! ** Method  :   The scale factors are given by the discrete derivative 
+      !!              of the depth:
+      !!                               e3w(jk) = dk[ dept_1d ] 
+      !!                               e3t(jk) = dk[ depw_1d ]
+      !!              with, at top and bottom :
+      !!                      e3w( 1 ) = 2 * ( dept( 1 ) - depw( 1 ) )
+      !!                      e3t(jpk) = 2 * ( dept(jpk) - depw(jpk) )   
+      !!
+      !! ** Action  : - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdept_3d, pdepw_3d   ! depth           [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t_3d , pe3w_3d    ! e3.=dk[depth]   [m]
+      !
+      INTEGER  ::   jk           ! dummy loop indices
+      !!----------------------------------------------------------------------      
+      pe3w_3d(:,:, 1 ) = 2._wp * ( pdept_3d(:,:,1) - pdepw_3d(:,:,1) ) 
+      DO jk = 1, jpkm1
+         pe3w_3d(:,:,jk+1) = pdept_3d(:,:,jk+1) - pdept_3d(:,:,jk) 
+         pe3t_3d(:,:,jk  ) = pdepw_3d(:,:,jk+1) - pdepw_3d(:,:,jk) 
+      END DO
+      pe3t_3d(:,:,jpk) = 2._wp * ( pdept_3d(:,:,jpk) - pdepw_3d(:,:,jpk) )   
+      !
+   END SUBROUTINE depth_to_e3_3d
+
+
+   SUBROUTINE e3_to_depth_1d( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d )
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE e3_to_depth_1d  ***
+      !!
+      !! ** Purpose :   compute t- & w-depths of model levels from e3t & e3w scale factors
+      !!
+      !! ** Method  :   The t- & w-depth are given by the summation of e3w & e3t, resp. 
+      !!
+      !! ** Action  : - pe3t_1d, pe3w_1d : scale factor of t- and w-point (m)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(in   ) ::   pe3t_1d , pe3w_1d    ! vert. scale factors   [m]
+      REAL(wp), DIMENSION(:), INTENT(  out) ::   pdept_1d, pdepw_1d   ! depth = SUM( e3 )     [m]
+      !
+      INTEGER  ::   jk           ! dummy loop indices
+      !!----------------------------------------------------------------------
+		!
+		pdepw_1d(1) = 0.0_wp
+      pdept_1d(1) = 0.5_wp * pe3w_1d(1)
+		DO jk = 2, jpk
+         pdepw_1d(jk) = pdepw_1d(jk-1) + pe3t_1d(jk-1) 
+         pdept_1d(jk) = pdept_1d(jk-1) + pe3w_1d(jk  ) 
+      END DO
+      !
+   END SUBROUTINE e3_to_depth_1d
+   
+      
+   SUBROUTINE e3_to_depth_3d( pe3t_3d, pe3w_3d, pdept_3d, pdepw_3d )
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE e3_to_depth_3d  ***
+      !!
+      !! ** Purpose :   compute t- & w-depths of model levels from e3t & e3w scale factors
+      !!
+      !! ** Method  :   The t- & w-depth are given by the summation of e3w & e3t, resp. 
+      !!
+      !! ** Action  : - pe3t_1d, pe3w_1d : scale factor of t- and w-point (m)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pe3t_3d , pe3w_3d    ! vert. scale factors   [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept_3d, pdepw_3d   ! depth = SUM( e3 )     [m]
+      !
+      INTEGER  ::   jk           ! dummy loop indices
+      !!----------------------------------------------------------------------      
+		!
+		pdepw_3d(:,:,1) = 0.0_wp
+      pdept_3d(:,:,1) = 0.5_wp * pe3w_3d(:,:,1)
+		DO jk = 2, jpk
+         pdepw_3d(:,:,jk) = pdepw_3d(:,:,jk-1) + pe3t_3d(:,:,jk-1) 
+         pdept_3d(:,:,jk) = pdept_3d(:,:,jk-1) + pe3w_3d(:,:,jk  ) 
+      END DO
+      !
+   END SUBROUTINE e3_to_depth_3d
+
+   !!======================================================================
+END MODULE depth_e3
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 7200)
@@ -22,5 +22,6 @@
    !!   dom_nam       : read and contral domain namelists
    !!   dom_ctl       : control print for the ocean domain
-   !!   cfg_write     : create the "domain_cfg.nc" file containing all required configuration information   
+   !!   domain_cfg    : read the global domain size in domain configuration file
+   !!   cfg_write     : create the domain configuration file
    !!----------------------------------------------------------------------
    USE oce            ! ocean variables
@@ -48,5 +49,6 @@
    PRIVATE
 
-   PUBLIC   dom_init   ! called by opa.F90
+   PUBLIC   dom_init     ! called by nemogcm.F90
+   PUBLIC   domain_cfg   ! called by nemogcm.F90
 
    !!-------------------------------------------------------------------------
@@ -110,6 +112,6 @@
          END SELECT
          WRITE(numout,*)     '      Ocean model configuration used:'
-         WRITE(numout,*)     '              cp_cfg = ', cp_cfg
-         WRITE(numout,*)     '              jp_cfg = ', jp_cfg
+         WRITE(numout,*)     '              cn_cfg = ', cn_cfg
+         WRITE(numout,*)     '              nn_cfg = ', nn_cfg
       ENDIF
       !
@@ -123,5 +125,5 @@
       CALL dom_glo                     ! global domain versus local domain
       CALL dom_nam                     ! read namelist ( namrun, namdom )
-      CALL dom_clo( cp_cfg, jp_cfg )   ! Closed seas and lake
+      CALL dom_clo( cn_cfg, nn_cfg )   ! Closed seas and lake
       CALL dom_hgr                     ! Horizontal mesh
       CALL dom_zgr( ik_top, ik_bot )   ! Vertical mesh and bathymetry
@@ -287,9 +289,9 @@
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!----------------------------------------------------------------------
-
+      !
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namrun, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namrun in reference namelist', lwp )
-
+      !
       REWIND( numnam_cfg )              ! Namelist namrun in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namrun, IOSTAT = ios, ERR = 902 )
@@ -380,5 +382,4 @@
       READ  ( numnam_ref, namdom, IOSTAT = ios, ERR = 903)
 903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdom in reference namelist', lwp )
-  
       !
       REWIND( numnam_cfg )              ! Namelist namdom in configuration namelist : space & time domain (bathymetry, mesh, timestep)
@@ -414,5 +415,5 @@
       READ  ( numnam_ref, namnc4, IOSTAT = ios, ERR = 907)
 907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namnc4 in reference namelist', lwp )
-
+      !
       REWIND( numnam_cfg )              ! Namelist namnc4 in configuration namelist : NETCDF
       READ  ( numnam_cfg, namnc4, IOSTAT = ios, ERR = 908 )
@@ -492,9 +493,67 @@
 
 
+   SUBROUTINE domain_cfg( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read the domain size in domain configuration file
+      !!
+      !! ** Method  :   
+      !!
+      !!----------------------------------------------------------------------
+      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 ::   inum, ii   ! local integer
+      REAL(wp) ::   zorca_res                     ! local scalars
+      REAL(wp) ::   ziglo, zjglo, zkglo, zperio   !   -      -
+      !!----------------------------------------------------------------------
+      !
+      ii = 1
+      WRITE(ldtxt(ii),*) '           '                                                    ;   ii = ii+1
+      WRITE(ldtxt(ii),*) 'domain_cfg : domain size read in', TRIM( cn_domcfg ), ' file'   ;   ii = ii+1
+      WRITE(ldtxt(ii),*) '~~~~~~~~~~ '                                                    ;   ii = ii+1
+      !
+      CALL iom_open( cn_domcfg, inum )
+      !
+      !                                   !- ORCA family specificity
+      IF(  iom_varid( inum, 'ORCA'           , ldstop = .FALSE. ) > 0  .AND.  &
+         & iom_varid( inum, 'ORCA_resolution', ldstop = .FALSE. ) > 0    ) THEN
+         !
+         cd_cfg = 'ORCA'
+         CALL iom_get( inum, 'ORCA_resolution', zorca_res )   ;   kk_cfg = INT( zorca_res )
+         !
+         WRITE(ldtxt(ii),*) '       '                                                    ;   ii = ii+1
+         WRITE(ldtxt(ii),*) '       ==>>>   ORCA configuration '                         ;   ii = ii+1
+         WRITE(ldtxt(ii),*) '       '                                                    ;   ii = ii+1
+         !
+      ELSE                                !- cd_cfg & k_cfg are not used
+         cd_cfg = 'UNKNOWN'
+         kk_cfg = -9999999
+      ENDIF
+      !
+      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(ldtxt(ii),*) '   cn_cfg = ', TRIM(cd_cfg), '   nn_cfg = ', kk_cfg             ;   ii = ii+1
+      WRITE(ldtxt(ii),*) '   jpiglo = ', jpiglo                                           ;   ii = ii+1
+      WRITE(ldtxt(ii),*) '   jpjglo = ', jpjglo      , '   jpkglo = ', jpkglo             ;   ii = ii +1
+      WRITE(ldtxt(ii),*) '   jpkglo = ', jpkglo                                           ;   ii = ii +1
+      WRITE(ldtxt(ii),*) '   type of global domain lateral boundary   jperio = ', jperio  ;   ii = ii +1
+      !        
+   END SUBROUTINE domain_cfg
+   
+   
    SUBROUTINE cfg_write
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE cfg_write  ***
       !!                   
-      !! ** Purpose :   Create the "domain_cfg" file, a NetCDF file which 
+      !! ** Purpose :   Create the "cn_domcfg_out" file, a NetCDF file which 
       !!              contains all the ocean domain informations required to 
       !!              define an ocean configuration.
@@ -503,10 +562,11 @@
       !!              ocean configuration.
       !!
-      !! ** output file :   domain_cfg.nc : domain size, characteristics, horizontal mesh,
-      !!                              Coriolis parameter, depth and vertical scale factors
+      !! ** output file :   domcfg_out.nc : domain size, characteristics, horizontal 
+      !!                       mesh, Coriolis parameter, and vertical scale factors
+      !!                    NB: also contain ORCA family information
       !!----------------------------------------------------------------------
       INTEGER           ::   ji, jj, jk   ! dummy loop indices
       INTEGER           ::   izco, izps, isco, icav
-      INTEGER           ::   inum     ! temprary units for 'domain_cfg.nc' file
+      INTEGER           ::   inum     ! local units
       CHARACTER(len=21) ::   clnam    ! filename (mesh and mask informations)
       REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! workspace
@@ -514,14 +574,21 @@
       !
       IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'cfg_write : create the "domain_cfg.nc" file containing all required configuration information'
+      IF(lwp) WRITE(numout,*) 'cfg_write : create the domain configuration file (', TRIM(cn_domcfg_out),'.nc)'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~'
       !
       !                       ! ============================= !
-      !                       !  create 'domain_cfg.nc' file  !
+      !                       !  create 'domcfg_out.nc' file  !
       !                       ! ============================= !
       !         
-      clnam = 'domain_cfg'  ! filename (configuration information)
+      clnam = 'domcfg_out'  ! filename (configuration information)
       CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
       
+      !
+      !                             !==  ORCA family specificities  ==!
+      IF( cn_cfg == "ORCA" ) THEN
+         CALL iom_rstput( 0, 0, inum, 'ORCA'      , 1._wp            , ktype = jp_i4 )
+         CALL iom_rstput( 0, 0, inum, 'ORCA_index', REAL( nn_cfg, wp), ktype = jp_i4 )         
+      ENDIF
+      !
       !                             !==  global domain size  ==!
       !
@@ -574,14 +641,14 @@
       !                             !==  vertical mesh  ==!
       !                                                     
-      CALL iom_rstput( 0, 0, inum, 'e3t_1d'  , e3t_1d  , ktype = jp_r8 )   ! reference 1D-coordinate
-      CALL iom_rstput( 0, 0, inum, 'e3w_1d'  , e3w_1d  , ktype = jp_r8 )
-      !
-      CALL iom_rstput( 0, 0, inum, 'e3t_0'   , e3t_0   , ktype = jp_r8 )   ! vertical scale factors
-      CALL iom_rstput( 0, 0, inum, 'e3u_0'   , e3u_0   , ktype = jp_r8 )
-      CALL iom_rstput( 0, 0, inum, 'e3v_0'   , e3v_0   , ktype = jp_r8 )
-      CALL iom_rstput( 0, 0, inum, 'e3f_0'   , e3f_0   , ktype = jp_r8 )
-      CALL iom_rstput( 0, 0, inum, 'e3w_0'   , e3w_0   , ktype = jp_r8 )
-      CALL iom_rstput( 0, 0, inum, 'e3uw_0'  , e3uw_0  , ktype = jp_r8 )
-      CALL iom_rstput( 0, 0, inum, 'e3vw_0'  , e3vw_0  , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3t_1d'  , e3t_1d , ktype = jp_r8 )   ! reference 1D-coordinate
+      CALL iom_rstput( 0, 0, inum, 'e3w_1d'  , e3w_1d , ktype = jp_r8 )
+      !
+      CALL iom_rstput( 0, 0, inum, 'e3t_0'   , e3t_0  , ktype = jp_r8 )   ! vertical scale factors
+      CALL iom_rstput( 0, 0, inum, 'e3u_0'   , e3u_0  , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3v_0'   , e3v_0  , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3f_0'   , e3f_0  , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3w_0'   , e3w_0  , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3uw_0'  , e3uw_0 , ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum, 'e3vw_0'  , e3vw_0 , ktype = jp_r8 )
       !                                         
       !                             !==  wet top and bottom level  ==!   (caution: multiplied by ssmask)
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 7200)
@@ -21,5 +21,5 @@
    !!----------------------------------------------------------------------
    !!   dom_hgr       : initialize the horizontal mesh 
-   !!   hgr_read      : read "coordinate" NetCDF file 
+   !!   hgr_read      : read horizontal information in the domain configuration file 
    !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain
@@ -91,5 +91,5 @@
       IF( ln_read_cfg ) THEN        !==  read in mesh_mask.nc file  ==!
          IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '          read horizontal mesh in "domain_cfg" file'
+         IF(lwp) WRITE(numout,*) '          read horizontal mesh in ', TRIM( cn_domcfg ), ' file'
          !
          CALL hgr_read   ( glamt , glamu , glamv , glamf ,   &    ! geographic position (required)
@@ -121,5 +121,5 @@
       ELSE
          IF( ln_read_cfg ) THEN
-            IF(lwp) WRITE(numout,*) '          Coriolis parameter have been read in "domain_cfg" file'
+            IF(lwp) WRITE(numout,*) '          Coriolis parameter have been read in ', TRIM( cn_domcfg ), ' file'
          ELSE
             IF(lwp) WRITE(numout,*) '          Coriolis parameter have been set in usr_def_hgr routine'
@@ -186,5 +186,5 @@
       ENDIF
       !
-      CALL iom_open( 'domain_cfg', inum )
+      CALL iom_open( cn_domcfg, inum )
       !
       CALL iom_get( inum, jpdom_data, 'glamt', plamt, lrowattr=ln_use_jattr )
@@ -210,5 +210,5 @@
       IF(  iom_varid( inum, 'ff_f', ldstop = .FALSE. ) > 0  .AND.  &
          & iom_varid( inum, 'ff_t', ldstop = .FALSE. ) > 0    ) THEN
-         IF(lwp) WRITE(numout,*) '           Coriolis factor at f- and t-points read in domain_cfg file'
+         IF(lwp) WRITE(numout,*) '           Coriolis factor at f- and t-points read in ', TRIM( cn_domcfg ), ' file'
          CALL iom_get( inum, jpdom_data, 'ff_f'  , pff_f  , lrowattr=ln_use_jattr )
          CALL iom_get( inum, jpdom_data, 'ff_t'  , pff_t  , lrowattr=ln_use_jattr )
@@ -219,5 +219,5 @@
       !
       IF( iom_varid( inum, 'e1e2u', ldstop = .FALSE. ) > 0 ) THEN
-         IF(lwp) WRITE(numout,*) '           e1e2u & e1e2v read in domain_cfg file'
+         IF(lwp) WRITE(numout,*) '           e1e2u & e1e2v read in ', TRIM( cn_domcfg ), ' file'
          CALL iom_get( inum, jpdom_data, 'e1e2u'  , pe1e2u  , lrowattr=ln_use_jattr )
          CALL iom_get( inum, jpdom_data, 'e1e2v'  , pe1e2v  , lrowattr=ln_use_jattr )
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 7200)
@@ -140,5 +140,6 @@
          END DO  
       END DO  
-!SF  add here lbc_lnk: bug not still understood : cause now domain_cfg is read !
+!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
 
@@ -263,5 +264,5 @@
       ! -------------------------------- 
       !
-      CALL usr_def_fmask( cp_cfg, jp_cfg, fmask )
+      CALL usr_def_fmask( cn_cfg, nn_cfg, fmask )
       !
       !
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 7200)
@@ -232,5 +232,5 @@
                END DO
             END DO
-            IF( cp_cfg == "orca" .AND. jp_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
+            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   ;   
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 7200)
@@ -23,5 +23,5 @@
    !!----------------------------------------------------------------------
    !!   dom_zgr       : read or set the ocean vertical coordinate system
-   !!   zgr_read      : read the vertical domain coordinate and mask in domain_cfg file
+   !!   zgr_read      : read the vertical information in the domain configuration file
    !!   zgr_top_bot   : ocean top and bottom level for t-, u, and v-points with 1 as minimum value
    !!---------------------------------------------------------------------
@@ -89,5 +89,5 @@
       IF( ln_read_cfg ) THEN        !==  read in mesh_mask.nc file  ==!
          IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '          Read vertical mesh in "domain_cfg" file'
+         IF(lwp) WRITE(numout,*) '          Read vertical mesh in ', TRIM( cn_domcfg ), ' file'
          !
          CALL zgr_read   ( ln_zco  , ln_zps  , ln_sco, ln_isfcav,   & 
@@ -120,5 +120,5 @@
       IF(lwp) THEN                     ! Control print
          WRITE(numout,*)
-         WRITE(numout,*) '   Type of vertical coordinate (read in domain_cfg.nc or set through user defined routines) :'
+         WRITE(numout,*) '   Type of vertical coordinate (read in ', TRIM( cn_domcfg ), ' file or set in userdef_nam) :'
          WRITE(numout,*) '      z-coordinate - full steps      ln_zco    = ', ln_zco
          WRITE(numout,*) '      z-coordinate - partial steps   ln_zps    = ', ln_zps
@@ -178,5 +178,5 @@
       !!              ***  ROUTINE zgr_read  ***
       !!
-      !! ** Purpose :   Read the vertical information in a domain_cfg.nc file
+      !! ** Purpose :   Read the vertical information in the domain configuration file
       !!
       !!----------------------------------------------------------------------
@@ -198,11 +198,11 @@
       IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*) '   zgr_read : read the vertical coordinates in "domain_cfg.nc" file'
-         WRITE(numout,*) '   ~~~~~~~~      jpiglo = ', jpiglo, ' jpjglo = ', jpjglo, ' jpkglo = ', jpkglo
-      ENDIF
-      !
-      CALL iom_open( 'domain_cfg', inum )
-      !
-      !                                   ! type of vertical coordinate
+         WRITE(numout,*) '   zgr_read : read the vertical coordinates in ', TRIM( cn_domcfg ), ' file'
+         WRITE(numout,*) '   ~~~~~~~~'
+      ENDIF
+      !
+      CALL iom_open( cn_domcfg, inum )
+      !
+      !                          !* type of vertical coordinate
       CALL iom_get( inum, 'ln_zco'   , z_zco )
       CALL iom_get( inum, 'ln_zps'   , z_zps )
@@ -212,14 +212,13 @@
       IF( z_sco == 0._wp ) THEN   ;   ld_sco = .false.   ;   ELSE   ;   ld_sco = .true.   ;   ENDIF
       !
-      !                                   ! ocean cavities under iceshelves
+      !                          !* ocean cavities under iceshelves
       CALL iom_get( inum, 'ln_isfcav', z_cav )
       IF( z_cav == 0._wp ) THEN   ;   ld_isfcav = .false.   ;   ELSE   ;   ld_isfcav = .true.   ;   ENDIF
       !
-      !                                   ! 1D vertical scale factors (reference coordinate)
-      CALL iom_get( inum, jpdom_unknown, 'e3t_1d'  , pe3t_1d  )
+      !                          !* vertical scale factors
+      CALL iom_get( inum, jpdom_unknown, 'e3t_1d'  , pe3t_1d  )                     ! 1D reference coordinate
       CALL iom_get( inum, jpdom_unknown, 'e3w_1d'  , pe3w_1d  )
       !
-      !                                   ! 3D vertical scale factors
-      CALL iom_get( inum, jpdom_data, 'e3t_0'  , pe3t  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e3t_0'  , pe3t  , lrowattr=ln_use_jattr )    ! 3D coordinate
       CALL iom_get( inum, jpdom_data, 'e3u_0'  , pe3u  , lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'e3v_0'  , pe3v  , lrowattr=ln_use_jattr )
@@ -229,7 +228,6 @@
       CALL iom_get( inum, jpdom_data, 'e3vw_0' , pe3vw , lrowattr=ln_use_jattr )
       !
-      !                                   ! 1D & 3D depths
-      !
-      !                                         ! old depth definition (obsolescent feature)
+      !                          !* depths
+      !                                   !- old depth definition (obsolescent feature)
       IF(  iom_varid( inum, 'gdept_1d', ldstop = .FALSE. ) > 0  .AND.  &
          & iom_varid( inum, 'gdepw_1d', ldstop = .FALSE. ) > 0  .AND.  &
@@ -237,5 +235,5 @@
          & iom_varid( inum, 'gdepw_0' , ldstop = .FALSE. ) > 0    ) THEN
          CALL ctl_warn( 'zgr_read : old definition of depths and scale factors used ', & 
-            &                      'depths at t- and w-points read in domain_cfg file')
+            &           '           depths at t- and w-points read in the domain configuration file')
          CALL iom_get( inum, jpdom_unknown, 'gdept_1d', pdept_1d )   
          CALL iom_get( inum, jpdom_unknown, 'gdepw_1d', pdepw_1d )
@@ -243,7 +241,7 @@
          CALL iom_get( inum, jpdom_data   , 'gdepw_0' , pdepw , lrowattr=ln_use_jattr )
          !
-      ELSE                                      ! depths computed from e3. scale factors
-         !
+      ELSE                                !- depths computed from e3. scale factors
          CALL e3_to_depth( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d )    ! 1D reference depth
+         CALL e3_to_depth( pe3t   , pe3w   , pdept   , pdepw    )    ! 3D depths
          IF(lwp) THEN
             WRITE(numout,*)
@@ -252,14 +250,11 @@
             WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
          ENDIF
-         !                                      
-         CALL e3_to_depth( pe3t   , pe3w   , pdept   , pdepw    )    ! 3D depths
-         !
-      ENDIF
-      !
-      !                                   ! ocean top and bottom level
-      CALL iom_get( inum, jpdom_data, 'bottom_level' , z2d  , lrowattr=ln_use_jattr )  ! nb of ocean T-points
+      ENDIF
+      !
+      !                          !* ocean top and bottom level
+      CALL iom_get( inum, jpdom_data, 'top_level'    , z2d  , lrowattr=ln_use_jattr )   ! 1st wet T-points (ISF)
+      k_top(:,:) = INT( z2d(:,:) )
+      CALL iom_get( inum, jpdom_data, 'bottom_level' , z2d  , lrowattr=ln_use_jattr )   ! last wet T-points
       k_bot(:,:) = INT( z2d(:,:) )
-      CALL iom_get( inum, jpdom_data, 'top_level'    , z2d  , lrowattr=ln_use_jattr )   ! nb of ocean T-points (ISF)
-      k_top(:,:) = INT( z2d(:,:) )
       !
       CALL iom_close( inum )
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 7200)
@@ -155,6 +155,8 @@
       !
       !
+!!gm  This should be removed from the code   ===>>>>  T & S files has to be changed
+      !
       !                                   !==   ORCA_R2 configuration and T & S damping   ==! 
-      IF( cp_cfg == "orca" .AND. jp_cfg == 2 .AND. ln_tsd_tradmp ) THEN    ! some hand made alterations
+      IF( cn_cfg == "orca" .AND. nn_cfg == 2 .AND. ln_tsd_tradmp ) THEN    ! some hand made alterations
          !
          ij0 = 101   ;   ij1 = 109                       ! Reduced T & S in the Alboran Sea
@@ -178,4 +180,5 @@
          sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
       ENDIF
+!!gm end
       !
       ptsd(:,:,:,jp_tem) = sf_tsd(jp_tem)%fnow(:,:,:)    ! NO mask
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 7200)
@@ -6,5 +6,5 @@
       !!     FOR USING THIS VERSION, A PREPROCESSING TRAITMENT IS RECOMMENDED
       !!     FOR DEFINING BETTER CUTTING OUT.
-      !!       This routine requires the presence of the "domain_cfg.nc" file.
+      !!       This routine requires the presence of the domain configuration file.
       !!       In this version, the land processors are avoided and the adress
       !!     processor (nproc, narea,noea, ...) are calculated again.
@@ -37,5 +37,5 @@
       !!                 !  1998-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
       !!  NEMO      1.0  !  2004-01  (G. Madec, J.M Molines)  F90 : free form , north fold jpni > 1
-      !!            4.0  !  2016-06  (G. Madec)  use domain_cfg file instead of bathymetry file
+      !!            4.0  !  2016-06  (G. Madec)  use domain configuration file instead of bathymetry file
       !!----------------------------------------------------------------------
       USE in_out_manager  ! I/O Manager
@@ -83,5 +83,5 @@
       ! 0. initialisation
       ! -----------------
-      CALL iom_open( 'domain_cfg', inum )
+      CALL iom_open( cn_domcfg, inum )
       !
       !                                   ! ocean top and bottom level
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 7200)
@@ -558,13 +558,4 @@
       END DO
 
-!!gm      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA R2
-!!gm         DO jj = 2, jpjm1
-!!gm            DO ji = fs_2, fs_jpim1   ! vector opt.
-!!gm               ! Take the minimum between aeiw and 1000 m2/s over shelves (depth shallower than 650 m)
-!!gm               IF( mbkt(ji,jj) <= 20 )   zaeiw(ji,jj) = MIN( zaeiw(ji,jj), 1000. )
-!!gm            END DO
-!!gm         END DO
-!!gm      ENDIF
-
       !                                         !==  Bound on eiv coeff.  ==!
       z1_f20 = 1._wp / (  2._wp * omega * sin( rad * 20._wp )  )
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 7200)
@@ -378,5 +378,5 @@
       ! (update freshwater fluxes)
       ! Should not be ran if ln_diurnal_only
-      IF( .NOT.(ln_diurnal_only) .AND. (nn_closea == 1) )   CALL sbc_clo( kt )   
+      IF( .NOT.ln_diurnal_only .AND. nn_closea == 1 )   CALL sbc_clo( kt, cn_cfg, nn_cfg )   
 
 !RBbug do not understand why see ticket 667
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 7200)
@@ -38,4 +38,8 @@
    REAL(wp) ::   r1_6 = 1._wp / 6._wp   ! =1/6
 
+   !                                        ! tridiag solver associated indices:
+   INTEGER, PARAMETER ::   np_NH   = 0   ! Neumann homogeneous boundary condition
+   INTEGER, PARAMETER ::   np_CEN2 = 1   ! 2nd order centered  boundary condition
+
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
@@ -706,7 +710,7 @@
 
 
-   SUBROUTINE interp_4th_cpt( pt_in, pt_out )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE interp_4th_cpt  ***
+   SUBROUTINE interp_4th_cpt_org( pt_in, pt_out )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interp_4th_cpt_org  ***
       !! 
       !! **  Purpose :   Compute the interpolation of tracer at w-point
@@ -739,7 +743,7 @@
       END DO
       !
-      jk=2                                            ! Switch to second order centered at top
-      DO jj=1,jpj
-         DO ji=1,jpi
+      jk = 2                                          ! Switch to second order centered at top
+      DO jj = 1, jpj
+         DO ji = 1, jpi
             zwd (ji,jj,jk) = 1._wp
             zwi (ji,jj,jk) = 0._wp
@@ -789,6 +793,178 @@
       END DO
       !    
+   END SUBROUTINE interp_4th_cpt_org
+   
+
+   SUBROUTINE interp_4th_cpt( pt_in, pt_out )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interp_4th_cpt  ***
+      !! 
+      !! **  Purpose :   Compute the interpolation of tracer at w-point
+      !!
+      !! **  Method  :   4th order compact interpolation
+      !!----------------------------------------------------------------------
+      REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   pt_in    ! field at t-point
+      REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pt_out   ! field interpolated at w-point
+      !
+      INTEGER ::   ji, jj, jk   ! dummy loop integers
+      INTEGER ::   ikt, ikb     ! local integers
+      REAL(wp),DIMENSION(jpi,jpj,jpk) :: zwd, zwi, zws, zwrm, zwt
+      !!----------------------------------------------------------------------
+      !
+      !                      !==  build the three diagonal matrix & the RHS  ==!
+      !
+      DO jk = 3, jpkm1                 ! interior (from jk=3 to jpk-1)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwd (ji,jj,jk) = 3._wp * wmask(ji,jj,jk) + 1._wp                 !       diagonal
+               zwi (ji,jj,jk) =         wmask(ji,jj,jk)                         ! lower diagonal
+               zws (ji,jj,jk) =         wmask(ji,jj,jk)                         ! upper diagonal
+               zwrm(ji,jj,jk) = 3._wp * wmask(ji,jj,jk)                     &   ! RHS
+                  &           *       ( pt_in(ji,jj,jk) + pt_in(ji,jj,jk-1) )
+            END DO
+         END DO
+      END DO
+      !
+!!gm
+!      SELECT CASE( kbc )               !* boundary condition
+!      CASE( np_NH   )   ! Neumann homogeneous at top & bottom
+!      CASE( np_CEN2 )   ! 2nd order centered  at top & bottom
+!      END SELECT
+!!gm  
+      !
+      DO jj = 2, jpjm1                 ! 2nd order centered at top & bottom
+         DO ji = fs_2, fs_jpim1
+            ikt = mikt(ji,jj) + 1            ! w-point below the 1st  wet point
+            ikb = mbkt(ji,jj)                !     -   above the last wet point
+            !
+            zwd (ji,jj,ikt) = 1._wp          ! top
+            zwi (ji,jj,ikt) = 0._wp
+            zws (ji,jj,ikt) = 0._wp
+            zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )
+            !
+            zwd (ji,jj,ikb) = 1._wp          ! bottom
+            zwi (ji,jj,ikb) = 0._wp
+            zws (ji,jj,ikb) = 0._wp
+            zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )            
+         END DO
+      END DO   
+      !
+      !                       !==  tridiagonal solver  ==!
+      !
+      DO jj = 2, jpjm1              !* 1st recurrence:   Tk = Dk - Ik Sk-1 / Tk-1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,2) = zwd(ji,jj,2)
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1              !* 2nd recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+         DO ji = fs_2, fs_jpim1
+            pt_out(ji,jj,2) = zwrm(ji,jj,2)
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1)             
+            END DO
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1              !* 3d recurrence:    Xk = (Zk - Sk Xk+1 ) / Tk
+         DO ji = fs_2, fs_jpim1
+            pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 2, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !    
    END SUBROUTINE interp_4th_cpt
-   
+
+
+   SUBROUTINE tridia_solver( pD, pU, pL, pRHS, pt_out , klev )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tridia_solver  ***
+      !! 
+      !! **  Purpose :   solve a symmetric 3diagonal system
+      !!
+      !! **  Method  :   solve M.t_out = RHS(t)  where M is a tri diagonal matrix ( jpk*jpk )
+      !!     
+      !!             ( D_1 U_1  0   0   0  )( t_1 )   ( RHS_1 )
+      !!             ( L_2 D_2 U_2  0   0  )( t_2 )   ( RHS_2 )
+      !!             (  0  L_3 D_3 U_3  0  )( t_3 ) = ( RHS_3 )
+      !!             (        ...          )( ... )   ( ...  )
+      !!             (  0   0   0  L_k D_k )( t_k )   ( RHS_k )
+      !!     
+      !!        M is decomposed in the product of an upper and lower triangular matrix.
+      !!        The tri-diagonals matrix is given as input 3D arrays:   pD, pU, pL 
+      !!        (i.e. the Diagonal, the Upper diagonal, and the Lower diagonal).
+      !!        The solution is pta.
+      !!        The 3d array zwt is used as a work space array.
+      !!----------------------------------------------------------------------
+      REAL(wp),DIMENSION(:,:,:), INTENT(in   ) ::   pD, pU, PL    ! 3-diagonal matrix
+      REAL(wp),DIMENSION(:,:,:), INTENT(in   ) ::   pRHS          ! Right-Hand-Side
+      REAL(wp),DIMENSION(:,:,:), INTENT(  out) ::   pt_out        !!gm field at level=F(klev)
+      INTEGER                  , INTENT(in   ) ::   klev          ! =1 pt_out at w-level 
+      !                                                           ! =0 pt at t-level
+      INTEGER ::   ji, jj, jk   ! dummy loop integers
+      INTEGER ::   kstart       ! local indices
+      REAL(wp),DIMENSION(jpi,jpj,jpk) ::   zwt   ! 3D work array
+      !!----------------------------------------------------------------------
+      !
+      kstart =  1  + klev
+      !
+      DO jj = 2, jpjm1              !* 1st recurrence:   Tk = Dk - Ik Sk-1 / Tk-1
+         DO ji = fs_2, fs_jpim1
+            zwt(ji,jj,kstart) = pD(ji,jj,kstart)
+         END DO
+      END DO
+      DO jk = kstart+1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zwt(ji,jj,jk) = pD(ji,jj,jk) - pL(ji,jj,jk) * pU(ji,jj,jk-1) /zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1              !* 2nd recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+         DO ji = fs_2, fs_jpim1
+            pt_out(ji,jj,kstart) = pRHS(ji,jj,kstart)
+         END DO
+      END DO
+      DO jk = kstart+1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               pt_out(ji,jj,jk) = pRHS(ji,jj,jk) - pL(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1)             
+            END DO
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1              !* 3d recurrence:    Xk = (Zk - Sk Xk+1 ) / Tk
+         DO ji = fs_2, fs_jpim1
+            pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, kstart, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - pU(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tridia_solver
+
    !!======================================================================
 END MODULE traadv_fct
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 7200)
@@ -545,5 +545,5 @@
       CALL wrk_dealloc( jpi, jpj, zmbk )
 
-                                        !* sign of grad(H) at u- and v-points
+      !                                 !* sign of grad(H) at u- and v-points
       mgrhu(jpi,:) = 0   ;   mgrhu(:,jpj) = 0   ;   mgrhv(jpi,:) = 0   ;   mgrhv(:,jpj) = 0
       DO jj = 1, jpjm1
@@ -553,5 +553,5 @@
          END DO
       END DO
-
+      !
       DO jj = 1, jpjm1              !* bbl thickness at u- (v-) point
          DO ji = 1, jpim1                 ! minimum of top & bottom e3u_0 (e3v_0)
@@ -561,27 +561,9 @@
       END DO
       CALL lbc_lnk( e3u_bbl_0, 'U', 1. )   ;   CALL lbc_lnk( e3v_bbl_0, 'V', 1. )      ! lateral boundary conditions
-
+      !
       !                             !* masked diffusive flux coefficients
       ahu_bbl_0(:,:) = rn_ahtbbl * e2_e1u(:,:) * e3u_bbl_0(:,:) * umask(:,:,1)
       ahv_bbl_0(:,:) = rn_ahtbbl * e1_e2v(:,:) * e3v_bbl_0(:,:) * vmask(:,:,1)
 
-
-      IF( cp_cfg == "orca" ) THEN   !* ORCA configuration : regional enhancement of ah_bbl
-         !
-         SELECT CASE ( jp_cfg )
-         CASE ( 2 )                          ! ORCA_R2
-            ij0 = 102   ;   ij1 = 102              ! Gibraltar enhancement of BBL
-            ii0 = 139   ;   ii1 = 140
-            ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
-            ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) =  4.e0*ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
-            !
-            ij0 =  88   ;   ij1 =  88              ! Red Sea enhancement of BBL
-            ii0 = 161   ;   ii1 = 162
-            ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) = 10.e0*ahu_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
-            ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1)) = 10.e0*ahv_bbl_0(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1))
-            !
-         END SELECT
-         !
-      ENDIF
       !
       IF( nn_timing == 1 )  CALL timing_stop( 'tra_bbl_init')
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_closea.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_closea.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_closea.F90	(revision 7200)
@@ -35,8 +35,8 @@
    PRIVATE
 
-   PUBLIC dom_clo      ! routine called by domain module
-   PUBLIC sbc_clo      ! routine called by step module
-   PUBLIC clo_rnf      ! routine called by sbcrnf module
-   PUBLIC clo_bat      ! routine called in domzgr module
+   PUBLIC dom_clo      ! called by domain module
+   PUBLIC sbc_clo      ! called by step module
+   PUBLIC clo_rnf      ! called by sbcrnf module
+   PUBLIC clo_bat      ! called in domzgr module
 
    INTEGER, PUBLIC, PARAMETER          ::   jpncs   = 4      !: number of closed sea
@@ -75,5 +75,5 @@
       !!                                   =2 put at location runoff
       !!----------------------------------------------------------------------
-      CHARACTER(len=1), INTENT(in   ) ::   cd_cfg   ! configuration name
+      CHARACTER(len=*), INTENT(in   ) ::   cd_cfg   ! configuration name
       INTEGER         , INTENT(in   ) ::   kcfg     ! configuration identifier 
       !
@@ -177,5 +177,5 @@
 
 
-   SUBROUTINE sbc_clo( kt )
+   SUBROUTINE sbc_clo( kt, cd_cfg, kcfg )
       !!---------------------------------------------------------------------
       !!                  ***  ROUTINE sbc_clo  ***
@@ -189,5 +189,7 @@
       !! ** Action  :   emp updated surface freshwater fluxes and associated heat content at kt
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean model time step
+      INTEGER         , INTENT(in   ) ::   kt       ! ocean model time step
+      CHARACTER(len=*), INTENT(in   ) ::   cd_cfg   ! configuration name
+      INTEGER         , INTENT(in   ) ::   kcfg     ! configuration identifier 
       !
       INTEGER             ::   ji, jj, jc, jn   ! dummy loop indices
@@ -272,5 +274,5 @@
       ENDIF
 
-      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN      ! Black Sea case for ORCA_R2 configuration
+      IF( cd_cfg == "orca" .AND. kcfg == 2 ) THEN      ! Black Sea case for ORCA_R2 configuration
          zze2    = ( zfwf(3) + zfwf(4) ) * 0.5_wp
          zfwf(3) = zze2
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_nam.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_nam.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_nam.F90	(revision 7200)
@@ -38,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,4 +51,6 @@
       !!----------------------------------------------------------------------
       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. 
@@ -66,4 +68,7 @@
       !
       WRITE( ldnam(:), namusr_def )
+      !
+      cd_cfg = 'GYRE'               ! name & resolution (not used)
+      kk_cfg = nn_GYRE
       !
       kpi = 30 * nn_GYRE + 2        ! Global Domain size
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_zgr.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_zgr.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/USR/usrdef_zgr.F90	(revision 7200)
@@ -112,7 +112,7 @@
       !!                   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_cfg.nc file. Indeed,
-      !!    Only e3. are saved in this file, depth are compute by a call to 
-      !!    the e3_to_depth subroutine.
+      !!    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.
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 7200)
@@ -46,9 +46,7 @@
    !!----------------------------------------------------------------------
    USE step_oce       ! module used in the ocean time stepping module (step.F90)
-   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
-#endif
+   USE phycst         ! physical constant                  (par_cst routine)
+   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
+   USE usrdef_nam     ! user defined configuration
    USE tideini        ! tidal components initialization   (tide_ini routine)
    USE bdyini         ! open boundary cond. setting       (bdy_init routine)
@@ -60,5 +58,4 @@
    USE ldftra         ! lateral diffusivity setting    (ldftra_init routine)
    USE zdfini         ! vertical physics setting          (zdf_init routine)
-   USE phycst         ! physical constant                  (par_cst routine)
    USE trdini         ! dyn/tra trends initialization     (trd_init routine)
    USE asminc         ! assimilation increments     
@@ -68,5 +65,4 @@
    USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
    USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
    USE step           ! NEMO time-stepping                 (stp     routine)
    USE icbini         ! handle bergs, initialisation
@@ -78,20 +74,25 @@
    USE stopar         ! Stochastic param.: ???
    USE stopts         ! Stochastic param.: ???
+   USE diurnal_bulk   ! diurnal bulk SST 
+   USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
+   USE crsini         ! initialise grid coarsening utility
+   USE diatmb         ! Top,middle,bottom output
+   USE dia25h         ! 25h mean output
+   USE sbc_oce , ONLY : lk_oasis
+   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
 #if defined key_top
    USE trcini         ! passive tracer initialisation
 #endif
+#if defined key_nemocice_decomp
+   USE ice_domain_size, only: nx_global, ny_global
+#endif
+   !
    USE lib_mpp        ! distributed memory computing
-   USE diurnal_bulk   ! diurnal bulk SST 
-   USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
+   USE mppini         ! shared/distributed memory setting (mpp_init routine)
+   USE lbcnfd , ONLY  : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges 
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 #if defined key_iomput
    USE xios           ! xIOserver
 #endif
-   USE crsini         ! initialise grid coarsening utility
-   USE lbcnfd , ONLY  : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges 
-   USE sbc_oce, ONLY  : lk_oasis
-   USE diatmb         ! Top,middle,bottom output
-   USE dia25h         ! 25h mean output
-   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
-   USE usrdef_nam     ! user defined configuration
 
    IMPLICIT NONE
@@ -125,5 +126,5 @@
       !!              Madec, 2008, internal report, IPSL.
       !!----------------------------------------------------------------------
-      INTEGER ::   istp       ! time step index
+      INTEGER ::   istp   ! time step index
       !!----------------------------------------------------------------------
       !
@@ -196,7 +197,7 @@
       !                            !==  finalize the run  ==!
       !                            !------------------------!
-      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
-      !
-      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
+      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
+      !
+      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
          WRITE(numout,cform_err)
          WRITE(numout,*) nstop, ' error have been found'
@@ -216,11 +217,11 @@
       !
 #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 
-         CALL cpl_finalize              ! end coupling and mpp communications with OASIS
+         CALL cpl_finalize                   ! end coupling and mpp communications with OASIS
       ELSE
-         IF( lk_mpp )   CALL mppstop    ! end mpp communications
+         IF( lk_mpp )   CALL mppstop         ! end mpp communications
       ENDIF
 #endif
@@ -235,8 +236,6 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER  ::   ji            ! dummy loop indices
-      INTEGER  ::   ilocal_comm   ! local integer
-      INTEGER  ::   ios, inum     !   -      -
-      REAL(wp) ::   ziglo, zjglo, zkglo, zperio   ! local scalars
+      INTEGER  ::   ji                 ! dummy loop indices
+      INTEGER  ::   ios, ilocal_comm   ! local integer
       CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
       !
@@ -244,5 +243,5 @@
          &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_timing, nn_diacfl
-      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
+      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_write_cfg, cn_domcfg_out, ln_use_jattr
       !!----------------------------------------------------------------------
       !
@@ -260,13 +259,13 @@
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
       !
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
       READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
       !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints
       READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
 903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
-      !
-      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
+
+      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist : Control prints & Benchmark
       READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
@@ -275,21 +274,12 @@
       !                             !  Set global domain size  !   (control print return in cltxt2)
       !                             !--------------------------!
-      IF( ln_read_cfg ) THEN              ! Read sizes in configuration "domain_cfg" 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 '         
-         WRITE(cltxt2(3),*) '~~~~~~~~~~    '
-         WRITE(cltxt2(4),*) '   jpiglo = ', jpiglo, ' jpjglo = ', jpjglo,  ' jpkglo = ', jpkglo
-         WRITE(cltxt2(5),*) '   global domain type of lateral boundary   jperio = ', jperio
-         !        
+      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
+         CALL domain_cfg ( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+         !
       ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      jpk    = jpkglo
+         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      jpk = jpkglo
       !
 #if defined key_agrif
@@ -313,6 +303,6 @@
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                     ! nemo local communicator given by oasis
-            CALL xios_initialize( "not used",local_comm=ilocal_comm )    ! send nemo communicator to xios
+            CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
+            CALL xios_initialize( "not used"       ,local_comm= ilocal_comm )    ! send nemo communicator to xios
          ELSE
             CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
@@ -324,11 +314,10 @@
       IF( lk_oasis ) THEN
          IF( Agrif_Root() ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                      ! nemo local communicator given by oasis
+            CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
          ENDIF
          ! Nodes selection (control print return in cltxt)
          narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
       ELSE
-         ilocal_comm = 0
-         ! Nodes selection (control print return in cltxt)
+         ilocal_comm = 0                                    ! Nodes selection (control print return in cltxt)
          narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop )
       ENDIF
@@ -340,13 +329,12 @@
       lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
 
-      IF(lwm) THEN
-         ! write merged namelists from earlier to output namelist now that the
-         ! file has been opened in call to mynode. nammpp has already been
-         ! written in mynode (if lk_mpp_mpi)
+      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
+         !                       ! now that the file has been opened in call to mynode. 
+         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
          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
+               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
             END DO
          ENDIF
@@ -394,23 +382,21 @@
          CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
          !
-
-
          WRITE(numout,*)
          WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                  version 3.7  (2016) '
+         WRITE(numout,*) '                NEMO version 3.7  (2016) '
          WRITE(numout,*)
          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,*) cltxt(ji)    ! control print of mynode
          END DO
          WRITE(numout,*)
          WRITE(numout,*)
          DO ji = 1, SIZE(cltxt2)
-            IF( cltxt2(ji) /= '' )   WRITE(numout,*) cltxt2(ji)     ! control print of domain size
+            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) cltxt2(ji)   ! control print of domain size
          END DO
          !
-         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
+         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
@@ -418,4 +404,5 @@
       ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
       CALL nemo_alloc()
+
       !                             !-------------------------------!
       !                             !  NEMO general initialization  !
@@ -534,5 +521,4 @@
                             CALL dia_tmb_init  ! TMB outputs
                             CALL dia_25h_init  ! 25h mean  outputs
-
       !
    END SUBROUTINE nemo_init
@@ -577,8 +563,9 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         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
+         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
+         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
+         WRITE(numout,*) '      write configuration definition file           ln_write_cfg     = ', ln_write_cfg
+         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
@@ -679,5 +666,5 @@
       !!----------------------------------------------------------------------
       !
-      ierr =        oce_alloc       ()          ! ocean
+      ierr =        oce_alloc       ()          ! ocean 
       ierr = ierr + dia_wri_alloc   ()
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
@@ -855,12 +842,12 @@
                 IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
+                   isendto(nsndto) = jn
                 ELSEIF ((sxM .le. sxT) .AND. (dxM .ge. dxT)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
+                   isendto(nsndto) = jn
                 ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
-                END IF
+                   isendto(nsndto) = jn
+                ENDIF
           END DO
           nfsloop = 1
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/par_oce.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/par_oce.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/OPA_SRC/par_oce.F90	(revision 7200)
@@ -16,9 +16,9 @@
    !!                   namcfg namelist parameters
    !!----------------------------------------------------------------------
-   LOGICAL       ::   ln_read_cfg      !: (=T) read the domain configuration in 'domain_cfg.nc" file
+   LOGICAL       ::   ln_read_cfg      !: (=T) read the domain configuration file or (=F) not
+   CHARACTER(lc) ::      cn_domcfg        !: filename the configuration file to be read
    LOGICAL       ::   ln_write_cfg     !: (=T) create the domain configuration file
+   CHARACTER(lc) ::      cn_domcfg_out    !: filename the configuration file to be read
    !
-   CHARACTER(lc) ::   cp_cfg           !: name of the configuration
-   INTEGER       ::   jp_cfg           !: resolution of the configuration 
    LOGICAL       ::   ln_use_jattr     !: input file read offset
    !                                   !  Use file global attribute: open_ocean_jstart to determine start j-row 
@@ -27,8 +27,12 @@
    !                                   !  with the extended grids used in the under ice shelf configurations to 
    !                                   !  be used without redundant rows when the ice shelves are not in use.
+   ! 
 
    !!---------------------------------------------------------------------
    !! Domain Matrix size 
    !!---------------------------------------------------------------------
+   ! configuration name & resolution   (required only in ORCA family case)
+   CHARACTER(lc) ::   cn_cfg           !: name of the configuration
+   INTEGER       ::   nn_cfg           !: resolution of the configuration 
 
    ! global domain size               !!! * total computational domain *
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 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90	(revision 7200)
@@ -4,66 +4,38 @@
    !! Ocean system   : NEMO GCM (ocean dynamics, on-line tracers, biochemistry and sea-ice)
    !!======================================================================
-   !! 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
-   !!             -   ! 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,
-   !!                             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
-   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
-   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
-   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
-   !!             -   ! 2004-08  (C. Talandier) New trends organization
-   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
-   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
-   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
-   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
-   !!             -   ! 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
-   !!             -   ! 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-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)
+   !! History :  3.6  ! 2015-12  (A. Ryan) Original code   (from OPA_SRC/) 
+   !!            4.0  ! 2016-11  (G. Madec, S. Flavoni)  domain configuration / user defined interface
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   nemo_gcm       : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
-   !!   nemo_init      : initialization of the NEMO system
-   !!   nemo_ctl       : initialisation of the contol print
-   !!   nemo_closefile : close remaining open files
-   !!   nemo_alloc     : dynamical allocation
-   !!   nemo_partition : calculate MPP domain decomposition
-   !!   factorise      : calculate the factors of the no. of MPI processes
+   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
+   !!   nemo_init     : initialization of the NEMO system
+   !!   nemo_ctl      : initialisation of the contol print
+   !!   nemo_closefile: close remaining open files
+   !!   nemo_alloc    : dynamical allocation
+   !!   nemo_partition: calculate MPP domain decomposition
+   !!   factorise     : calculate the factors of the no. of MPI processes
    !!----------------------------------------------------------------------
    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)
+   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
+   USE istate         ! initial state setting          (istate_init routine)
+   USE phycst         ! physical constant                  (par_cst routine)
+   USE step           ! NEMO time-stepping                 (stp     routine)
+   USE cpl_oasis3     ! OASIS3 coupling
+   USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
 #if defined key_nemocice_decomp
    USE ice_domain_size, only: nx_global, ny_global
 #endif
-   USE istate          ! initial state setting          (istate_init routine)
-   USE phycst          ! physical constant                  (par_cst routine)
-   USE diaobs          ! Observation diagnostics       (dia_obs_init routine)
-   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-   USE step            ! NEMO time-stepping                 (stp     routine)
-   USE cpl_oasis3      ! OASIS3 coupling
-   USE lib_mpp         ! distributed memory computing
+   !           ! Stand Alone Observation operator modules
+   USE sao_data
+   USE sao_intp
+   !
+   USE lib_mpp        ! distributed memory computing
+   USE mppini         ! shared/distributed memory setting (mpp_init routine)
+   USE lbcnfd  , ONLY : isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges 
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 #if defined key_iomput
    USE xios           ! xIOserver
 #endif
-   USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges 
-
-   ! Stand Alone Observation operator modules
-   USE sao_data
-   USE sao_intp
 
    IMPLICIT NONE
@@ -94,20 +66,20 @@
          !!             3. Cycle through match ups
          !!             4. Write results to file
-         !!
          !!----------------------------------------------------------------------
-         !! Initialise NEMO
-         CALL nemo_init
-         !! Initialise Stand Alone Observation operator data
-         CALL sao_data_init
-         !! Initialise obs_oper
-         CALL dia_obs_init
-         !! Interpolate to observation space
-         CALL sao_interp
-         !! Pipe to output files
-         CALL dia_obs_wri
-         !! Reset the obs_oper between
-         CALL dia_obs_dealloc
-         !! Safely stop MPI
-         IF(lk_mpp) CALL mppstop  ! end mpp communications
+         !
+         CALL nemo_init       ! Initialise NEMO
+         !
+         CALL sao_data_init   ! Initialise Stand Alone Observation operator data
+         !
+         CALL dia_obs_init    ! Initialise obs_operator
+         !
+         CALL sao_interp      ! Interpolate to observation space
+         !
+         CALL dia_obs_wri     ! Pipe to output files
+         !
+         CALL dia_obs_dealloc ! Reset the obs_oper between
+         !
+         IF(lk_mpp)   CALL mppstop  ! Safely stop MPI (end mpp communications)
+         !
    END SUBROUTINE nemo_gcm
 
@@ -119,17 +91,17 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER ::   ji            ! dummy loop indices
-      INTEGER ::   ilocal_comm   ! local integer
-      INTEGER ::   ios
-!!gm      CHARACTER(len=80), DIMENSION(16) ::   cltxt
-      CHARACTER(len=80), DIMENSION(-10:16) ::   cltxt
-      !
-      NAMELIST/namctl/ ln_ctl, nn_print, nn_ictls, nn_ictle,   &
-         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
+      INTEGER ::   ji                 ! dummy loop indices
+      INTEGER ::   ios, ilocal_comm   ! local integer
+      CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
+      !
+      NAMELIST/namctl/ ln_ctl   , nn_print, nn_ictls, nn_ictle,   &
+         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_timing, nn_diacfl
-      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
-      !!----------------------------------------------------------------------
-      !
-      cltxt = ''
+      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_write_cfg, cn_domcfg_out, ln_use_jattr
+      !!----------------------------------------------------------------------
+      !
+      cltxt  = ''
+      cltxt2 = ''
+      clnam  = ''  
       cxios_context = 'nemo'
       !
@@ -138,14 +110,13 @@
       CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
       !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints
       READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
       READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints
       READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
 903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
@@ -155,24 +126,15 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
-!!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
-         !        
+      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
+         CALL domain_cfg ( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+         !
       ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      jpk    = jpkglo
+         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      jpk = jpkglo
       !
 #if defined key_agrif
@@ -217,4 +179,5 @@
       ENDIF
 #endif
+
       narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
 
@@ -230,5 +193,5 @@
          IF( .NOT.ln_read_cfg ) THEN
             DO ji = 1, SIZE(clnam)
-               IF( TRIM(clnam (ji)) /= '' )   WRITE(numond, * ) clnam(ji)    ! namusr_def print
+               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
             END DO
          ENDIF
@@ -239,5 +202,5 @@
       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
@@ -247,14 +210,11 @@
       ENDIF
 
-      ! Calculate domain dimensions given calculated jpni and jpnj
-      ! This used to be done in par_oce.F90 when they were parameters rather
-      ! than variables
-      IF( Agrif_Root() ) THEN
+      IF( Agrif_Root() ) THEN       ! AGRIF mother: specific setting from jpni and jpnj
 #if defined key_nemocice_decomp
-         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first  dim.
-         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 
+         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim. 
 #else
-         jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci   ! first  dim.
-         jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj   ! second dim.
+         jpi = ( jpiglo     -2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( jpjglo     -2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim.
 #endif
       ENDIF
@@ -272,29 +232,25 @@
          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'
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Stand Alone Observation operator'
-         WRITE(numout,*) '                  version 1.0  (2015) '
+         WRITE(numout,*) '                NEMO version 3.7  (2015) '
          WRITE(numout,*)
          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,*) cltxt(ji)    ! control print of mynode
          END DO
-         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
-         !
-      ENDIF
-
-      ! Now we know the dimensions of the grid and numout has been set we can
-      ! allocate arrays
+         WRITE(numout,*)
+         WRITE(numout,*)
+         DO ji = 1, SIZE(cltxt2)
+            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) cltxt2(ji)   ! control print of domain size
+         END DO
+         !
+         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
+         !
+      ENDIF
+
+      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
       CALL nemo_alloc()
 
@@ -315,5 +271,4 @@
                             CALL     phy_cst    ! Physical constants
                             CALL     eos_init   ! Equation of state
-                            CALL     dom_cfg    ! Domain configuration
                             CALL     dom_init   ! Domain
 
@@ -337,5 +292,5 @@
       IF(lwp) THEN                  ! control print
          WRITE(numout,*)
-         WRITE(numout,*) 'nemo_ctl: Control prints & Benchmark'
+         WRITE(numout,*) 'nemo_ctl: Control prints'
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namctl'
@@ -364,8 +319,9 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         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
+         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
+         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
+         WRITE(numout,*) '      write configuration definition file           ln_write_cfg     = ', ln_write_cfg
+         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
@@ -439,5 +395,4 @@
       IF( numdct_heat     /= -1 )   CLOSE( numdct_heat     )   ! heat transports
       IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
-
       !
       numout = 6                                     ! redefine numout in case it is used after this point...
@@ -478,5 +433,5 @@
       !! ** Method  :
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have
+      INTEGER, INTENT(in) ::   num_pes   ! The number of MPI processes we have
       !
       INTEGER, PARAMETER :: nfactmax = 20
@@ -532,16 +487,15 @@
       INTEGER :: ifac, jl, inu
       INTEGER, PARAMETER :: ntest = 14
-      INTEGER :: ilfax(ntest)
+      INTEGER, DIMENSION(ntest) ::   ilfax
+      !!----------------------------------------------------------------------
       !
       ! lfax contains the set of allowed factors.
-      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
-         &                            128,   64,   32,   16,    8,   4,   2  /
-      !!----------------------------------------------------------------------
-
+      ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)
+      !
       ! 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
@@ -551,8 +505,8 @@
       ! l points to the allowed factor list.
       ! ifac holds the current factor.
-
+      !
       inu   = kn
       knfax = 0
-
+      !
       DO jl = ntest, 1, -1
          !
@@ -578,5 +532,5 @@
          !
       END DO
-
+      !
    20 CONTINUE      ! Label 20 is the exit point from the factor search loop.
       !
@@ -586,26 +540,24 @@
 
    SUBROUTINE nemo_northcomms
-      !!======================================================================
+      !!----------------------------------------------------------------------
       !!                     ***  ROUTINE  nemo_northcomms  ***
-      !! nemo_northcomms    :  Setup for north fold exchanges with explicit 
-      !!                       point-to-point messaging
-      !!=====================================================================
-      !!----------------------------------------------------------------------
-      !!
-      !! ** Purpose :   Initialization of the northern neighbours lists.
+      !! ** Purpose :   Setup for north fold exchanges with explicit 
+      !!                point-to-point messaging
+      !!
+      !! ** Method :   Initialization of the northern neighbours lists.
       !!----------------------------------------------------------------------
       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
       !!    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
@@ -629,12 +581,12 @@
                 IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
+                   isendto(nsndto) = jn
                 ELSEIF ((sxM .le. sxT) .AND. (dxM .ge. dxT)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
+                   isendto(nsndto) = jn
                 ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN
                    nsndto = nsndto + 1
-                     isendto(nsndto) = jn
-                END IF
+                   isendto(nsndto) = jn
+                ENDIF
           END DO
           nfsloop = 1
@@ -654,4 +606,5 @@
       l_north_nogather = .TRUE.
    END SUBROUTINE nemo_northcomms
+
 #else
    SUBROUTINE nemo_northcomms      ! Dummy routine
@@ -663,3 +616,2 @@
 END MODULE nemogcm
 
-
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_data.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_data.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_data.F90	(revision 7200)
@@ -1,23 +1,29 @@
 MODULE sao_data
-   !! =================================================================
-   !!                    *** MODULE sao_data ***
-   !! =================================================================
+   !!======================================================================
+   !!                       ***  MODULE sao_data  ***
+   !!======================================================================
+   !! History :  3.6  ! 2015-12  (A. Ryan)  Original code
+   !!----------------------------------------------------------------------
    USE par_kind, ONLY: lc
    USE lib_mpp         ! distributed memory computing
+   USE in_out_manager
 
    IMPLICIT NONE
-
-   !! Public data
 
    INTEGER, PARAMETER :: MaxNumFiles = 1000
 
    !! Stand Alone Observation operator settings
-   CHARACTER(len=lc) :: &
-      & sao_files(MaxNumFiles)         !: model files
-   INTEGER            :: &
-      & n_files, &                     !: number of files
-      & nn_sao_idx(MaxNumFiles), &     !: time_counter indices
-      & nn_sao_freq                    !: read frequency in time steps
+   CHARACTER(len=lc) ::   sao_files(MaxNumFiles)   !: model files
+   INTEGER           ::   n_files                  !: number of files
+   INTEGER           :: nn_sao_idx(MaxNumFiles)    !: time_counter indices
+   INTEGER           :: nn_sao_freq                !: read frequency in time steps
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: trazdf_imp.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
+
    SUBROUTINE sao_data_init()
       !!----------------------------------------------------------------------
@@ -27,18 +33,16 @@
       !!
       !!----------------------------------------------------------------------
-      USE in_out_manager
-      INTEGER            :: &
-         & jf                           !: file dummy loop index
-      LOGICAL :: lmask(MaxNumFiles)     !: Logical mask used for counting
-      INTEGER :: ios
-
-      ! Standard offline obs_oper information
+      INTEGER ::   jf                   ! file dummy loop index
+      LOGICAL ::   lmask(MaxNumFiles)   ! Logical mask used for counting
+      INTEGER ::   ios
+      !!
       NAMELIST/namsao/sao_files, nn_sao_idx, nn_sao_freq
+      !!----------------------------------------------------------------------
 
       ! Standard offline obs_oper initialisation
-      n_files = 0                   !: number of files to cycle through
-      sao_files(:) = ''             !: list of files to read in
-      nn_sao_idx(:) = 0             !: list of indices inside each file
-      nn_sao_freq = -1              !: input frequency in time steps
+      n_files = 0                   ! number of files to cycle through
+      sao_files(:) = ''             ! list of files to read in
+      nn_sao_idx(:) = 0             ! list of indices inside each file
+      nn_sao_freq = -1              ! input frequency in time steps
 
       ! Standard offline obs_oper settings
@@ -46,23 +50,18 @@
       READ  ( numnam_ref, namsao, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsao in reference namelist', .TRUE. )
-
+      !
       REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
       READ  ( numnam_cfg, namsao, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsao in configuration namelist', .TRUE. )
-
-
-      ! count input files
-      lmask(:) = .FALSE.
+     
+      lmask(:) = .FALSE.               ! count input files
       WHERE (sao_files(:) /= '') lmask(:) = .TRUE.
       n_files = COUNT(lmask)
-
-      !! Initialise sub obs window frequency
-      IF (nn_sao_freq == -1) THEN
-         !! Run length
-         nn_sao_freq = nitend - nit000 + 1
+      !
+      IF(nn_sao_freq == -1) THEN      ! Initialise sub obs window frequency
+         nn_sao_freq = nitend - nit000 + 1      ! Run length
       ENDIF
-
-      !! Print summary of settings
-      IF(lwp) THEN
+      !
+      IF(lwp) THEN                     ! Print summary of settings
          WRITE(numout,*)
          WRITE(numout,*) 'offline obs_oper : Initialization'
@@ -70,13 +69,12 @@
          WRITE(numout,*) '   Namelist namsao : set stand alone obs_oper parameters'
          DO jf = 1, n_files
-            WRITE(numout,'(1X,2A)') '   Input forecast file name          forecastfile = ', &
-               TRIM(sao_files(jf))
-            WRITE(numout,*) '   Input forecast file index        forecastindex = ', &
-               nn_sao_idx(jf)
+            WRITE(numout,'(1X,2A)') '   Input forecast file name          forecastfile = ', TRIM(sao_files(jf))
+            WRITE(numout,*) '   Input forecast file index        forecastindex = ', nn_sao_idx(jf)
          END DO
       END IF
-
+      !
    END SUBROUTINE sao_data_init
 
+   !!======================================================================
 END MODULE sao_data
 
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90	(revision 7200)
@@ -4,8 +4,10 @@
    !! ** Purpose : Run NEMO observation operator in offline mode
    !!======================================================================
-   !! NEMO modules
+   !! History :  3.6  ! 2015-12  (A. Ryan)  Original code
+   !!----------------------------------------------------------------------
+   !        ! NEMO modules
    USE in_out_manager
    USE diaobs
-   !! Stand Alone Observation operator modules
+   !        ! Stand Alone Observation operator modules
    USE sao_read
    USE sao_data
@@ -16,33 +18,41 @@
    PUBLIC sao_interp
 
-   CONTAINS
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: trazdf_imp.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
 
-      SUBROUTINE sao_interp
-         !!----------------------------------------------------------------------
-         !!                    ***  SUBROUTINE sao_interp ***
-         !!
-         !! ** Purpose : To interpolate the model as if it were running online.
-         !!
-         !! ** Method : 1. Populate model counterparts
-         !!             2. Call dia_obs at appropriate time steps
-         !!----------------------------------------------------------------------
-         INTEGER :: &
-            & istp, & ! time step index
-            & ifile   ! file index
-         istp = nit000 - 1
-         nstop = 0
-         ifile = 1
-         CALL sao_rea_dri(ifile)
-         DO WHILE ( istp <= nitend .AND. nstop == 0 )
-            IF (ifile <= n_files + 1) THEN
-               IF ( MOD(istp, nn_sao_freq) == nit000 ) THEN
-                  CALL sao_rea_dri(ifile)
-                  ifile = ifile + 1
-               ENDIF
-               CALL dia_obs(istp)
+   SUBROUTINE sao_interp
+      !!----------------------------------------------------------------------
+      !!                    ***  SUBROUTINE sao_interp ***
+      !!
+      !! ** Purpose : To interpolate the model as if it were running online.
+      !!
+      !! ** Method : 1. Populate model counterparts
+      !!             2. Call dia_obs at appropriate time steps
+      !!----------------------------------------------------------------------
+      INTEGER ::   istp    ! time step index
+      INTEGER ::   ifile   ! file index
+      !!----------------------------------------------------------------------
+      istp = nit000 - 1
+      nstop = 0
+      ifile = 1
+      CALL sao_rea_dri(ifile)
+      !
+      DO WHILE ( istp <= nitend .AND. nstop == 0 )
+         IF (ifile <= n_files + 1) THEN
+            IF ( MOD(istp, nn_sao_freq) == nit000 ) THEN
+               CALL sao_rea_dri(ifile)
+               ifile = ifile + 1
             ENDIF
-            istp = istp + 1
-         END DO
-      END SUBROUTINE sao_interp
+            CALL dia_obs(istp)
+         ENDIF
+         istp = istp + 1
+      END DO
+      !
+   END SUBROUTINE sao_interp
 
+   !!======================================================================
 END MODULE sao_intp
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_read.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_read.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAO_SRC/sao_read.F90	(revision 7200)
@@ -1,7 +1,7 @@
 MODULE sao_read
-   !!==================================================================
-   !!                    *** MODULE sao_read ***
+   !!======================================================================
+   !!                      ***  MODULE sao_read  ***
    !! Read routines : I/O for Stand Alone Observation operator
-   !!==================================================================
+   !!======================================================================
    USE mppini
    USE lib_mpp
@@ -12,4 +12,5 @@
    USE dom_oce, ONLY: nlci, nlcj, nimpp, njmpp, tmask
    USE par_oce, ONLY: jpi, jpj, jpk
+   !
    USE obs_fbm, ONLY: fbimdi, fbrmdi, fbsp, fbdp
    USE sao_data
@@ -20,6 +21,12 @@
    PUBLIC sao_rea_dri
 
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: trazdf_imp.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
-   SUBROUTINE sao_rea_dri(kfile)
+
+   SUBROUTINE sao_rea_dri( kfile )
       !!------------------------------------------------------------------------
       !!             *** sao_rea_dri ***
@@ -31,20 +38,20 @@
       !!
       !!------------------------------------------------------------------------
-      INTEGER, INTENT(IN) :: &
-              & kfile         !: File number
-      CHARACTER(len=lc) :: &
-              & cdfilename    !: File name
-      INTEGER :: &
-              & kindex        !: File index to read
-
-      cdfilename = TRIM(sao_files(kfile))
+      INTEGER, INTENT(in) ::   kfile         ! File number
+      !
+      CHARACTER(len=lc)   ::   cdfilename    ! File name
+      INTEGER ::   kindex        ! File index to read
+      !!------------------------------------------------------------------------
+      !
+      cdfilename = TRIM( sao_files(kfile) )
       kindex = nn_sao_idx(kfile)
-      CALL sao_read_file(TRIM(cdfilename), kindex)
-
+      CALL sao_read_file( TRIM( cdfilename ), kindex )
+      !
    END SUBROUTINE sao_rea_dri
 
-   SUBROUTINE sao_read_file(filename, ifcst)
+
+   SUBROUTINE sao_read_file( filename, ifcst )
       !!------------------------------------------------------------------------
-      !!             *** sao_read_file ***
+      !!                         ***  sao_read_file  ***
       !!
       !! Purpose : To fill tn and sn with dailymean field from netcdf files
@@ -54,31 +61,22 @@
       !! Author  : A. Ryan Oct 2010
       !!------------------------------------------------------------------------
-
-      INTEGER,          INTENT(IN) :: ifcst
-      CHARACTER(len=*), INTENT(IN) :: filename
-      INTEGER                      :: ncid, &
-                                    & varid,&
-                                    & istat,&
-                                    & ntimes,&
-                                    & tdim, &
-                                    & xdim, &
-                                    & ydim, &
-                                    & zdim
-      INTEGER                      :: ii, ij, ik
-      INTEGER, DIMENSION(4)        :: start_n, &
-                                    & count_n
-      INTEGER, DIMENSION(3)        :: start_s, &
-                                    & count_s
-      REAL(fbdp), DIMENSION(:,:,:),ALLOCATABLE :: temp_tn, &
-                                              & temp_sn
-      REAL(fbdp), DIMENSION(:,:),  ALLOCATABLE :: temp_sshn
-      REAL(fbdp)                     :: fill_val
+      INTEGER,          INTENT(in) ::   ifcst
+      CHARACTER(len=*), INTENT(in) ::   filename
+      INTEGER                      ::   ncid, varid, istat, ntimes
+      INTEGER                      ::   tdim, xdim, ydim, zdim
+      INTEGER                      ::   ii, ij, ik
+      INTEGER, DIMENSION(4)        ::   start_n, count_n
+      INTEGER, DIMENSION(3)        ::   start_s, count_s
+      REAL(fbdp)                   ::   fill_val
+      REAL(fbdp), DIMENSION(:,:,:), ALLOCATABLE ::   temp_tn, temp_sn
+      REAL(fbdp), DIMENSION(:,:)  , ALLOCATABLE ::   temp_sshn
 
       ! DEBUG
-      INTEGER :: istage
+      INTEGER ::   istage
+      !!------------------------------------------------------------------------
 
       IF (TRIM(filename) == 'nofile') THEN
-         tsn(:,:,:,:) = fbrmdi
-         sshn(:,:) = fbrmdi
+         tsn (:,:,:,:) = fbrmdi
+         sshn(:,:)     = fbrmdi
       ELSE
          WRITE(numout,*) "Opening :", TRIM(filename)
@@ -169,4 +167,7 @@
          istat = nf90_close(ncid)
       END IF
+      !
    END SUBROUTINE sao_read_file
+   
+   !!------------------------------------------------------------------------
 END MODULE sao_read
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 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 7200)
@@ -2,71 +2,44 @@
    !!======================================================================
    !!                       ***  MODULE nemogcm   ***
-   !! Ocean system   : NEMO GCM (ocean dynamics, on-line tracers, biochemistry and sea-ice)
+   !! StandAlone Surface module : surface fluxes + sea-ice + iceberg floats
    !!======================================================================
-   !! 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
-   !!             -   ! 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,
-   !!                             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
-   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
-   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
-   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
-   !!             -   ! 2004-08  (C. Talandier) New trends organization
-   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
-   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
-   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
-   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
-   !!             -   ! 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
-   !!             -   ! 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-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 
+   !! History :  3.6  ! 2011-11  (S. Alderson, G. Madec) original code
    !!             -   ! 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)
+   !!            4.0  ! 2016-10  (G. Madec, S. Flavoni)  domain configuration / user defined interface
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   nemo_gcm       : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
-   !!   nemo_init      : initialization of the NEMO system
-   !!   nemo_ctl       : initialisation of the contol print 
-   !!   nemo_closefile : close remaining open files
-   !!   nemo_alloc     : dynamical allocation
-   !!   nemo_partition : calculate MPP domain decomposition
-   !!   factorise      : calculate the factors of the no. of MPI processes
+   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
+   !!   nemo_init     : initialization of the NEMO system
+   !!   nemo_ctl      : initialisation of the contol print
+   !!   nemo_closefile: close remaining open files
+   !!   nemo_alloc    : dynamical allocation
+   !!   nemo_partition: calculate MPP domain decomposition
+   !!   factorise     : calculate the factors of the no. of MPI processes
    !!----------------------------------------------------------------------
-   USE step_oce        ! module used in the ocean time stepping module
-   USE sbc_oce         ! surface boundary condition: ocean
-   USE domcfg          ! domain configuration               (dom_cfg routine)
-   USE daymod          ! calendar
-   USE mppini          ! shared/distributed memory setting (mpp_init routine)
-   USE domain          ! domain initialization             (dom_init routine)
-   USE phycst          ! physical constant                  (par_cst routine)
-   USE step            ! NEMO time-stepping                 (stp     routine)
-   USE lib_mpp         ! distributed memory computing
-#if defined key_nosignedzero
-   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-#endif
+   USE step_oce       ! module used in the ocean time stepping module
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE phycst         ! physical constant                  (par_cst routine)
+   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
+   USE usrdef_nam     ! user defined configuration
+   USE daymod         ! calendar
+   USE step           ! NEMO time-stepping                 (stp     routine)
+   USE cpl_oasis3     !
+   USE sbcssm         !
+   USE icbstp         ! handle bergs, calving, themodynamics and transport
+#if defined key_bdy
+   USE bdyini         ! open boundary cond. setting       (bdy_init routine). clem: mandatory for LIM3
+   USE bdydta         ! open boundary cond. setting   (bdy_dta_init routine). clem: mandatory for LIM3
+#endif
+   USE bdy_par
+   !
+   USE lib_mpp        ! distributed memory computing
+   USE mppini         ! shared/distributed memory setting (mpp_init routine)
+   USE lbcnfd   , ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 #if defined key_iomput
-   USE xios
-#endif
-   USE cpl_oasis3
-   USE sbcssm
-   USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges
-   USE icbstp          ! handle bergs, calving, themodynamics and transport
-#if defined key_bdy
-   USE bdyini          ! open boundary cond. setting       (bdy_init routine). clem: mandatory for LIM3
-   USE bdydta          ! open boundary cond. setting   (bdy_dta_init routine). clem: mandatory for LIM3
-#endif
-   USE bdy_par
-   USE usrdef_nam     ! user defined configuration
+   USE xios           ! xIOserver
+#endif
 
    IMPLICIT NONE
@@ -99,5 +72,5 @@
       !!              Madec, 2008, internal report, IPSL.
       !!----------------------------------------------------------------------
-      INTEGER ::   istp       ! time step index
+      INTEGER ::   istp   ! time step index
       !!----------------------------------------------------------------------
       !
@@ -105,5 +78,5 @@
       CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
 #endif
-
+      !
       !                            !-----------------------!
       CALL nemo_init               !==  Initialisations  ==!
@@ -152,9 +125,9 @@
       !                            !==  finalize the run  ==!
       !                            !------------------------!
-      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
-      !
-      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
+      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
+      !
+      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
          WRITE(numout,cform_err)
-         WRITE(numout,*) nstop, ' error have been found' 
+         WRITE(numout,*) nstop, ' error have been found'
       ENDIF
       !
@@ -169,11 +142,11 @@
       !
 #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 
-         CALL cpl_finalize              ! end coupling and mpp communications with OASIS
+         CALL cpl_finalize                   ! end coupling and mpp communications with OASIS
       ELSE
-         IF( lk_mpp )   CALL mppstop    ! end mpp communications
+         IF( lk_mpp )   CALL mppstop         ! end mpp communications
       ENDIF
 #endif
@@ -191,12 +164,11 @@
       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=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
       CHARACTER(len=80)                 ::   clname
       !
-      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
-         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
+      NAMELIST/namctl/ ln_ctl   , nn_print, nn_ictls, nn_ictle,   &
+         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_timing, nn_diacfl
-      NAMELIST/namcfg/ ln_read_cfg, ln_write_cfg, cp_cfg, jp_cfg, ln_use_jattr
+      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_write_cfg, cn_domcfg_out, ln_use_jattr
       !!----------------------------------------------------------------------
       !
@@ -204,5 +176,4 @@
       cltxt2 = ''
       clnam  = ''  
-      clbug  = ''
       cxios_context = 'nemo'
       !
@@ -220,14 +191,13 @@
    ENDIF
       !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints
       READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
       READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints & Benchmark
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints
       READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
 903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
@@ -237,24 +207,15 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
-!!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
-         !        
+      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
+         CALL domain_cfg ( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+         !
       ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      jpk    = jpkglo
+         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      jpk = jpkglo
       !
 #if defined key_agrif
@@ -281,5 +242,5 @@
             CALL xios_initialize( "not used",local_comm=ilocal_comm )    ! send nemo communicator to xios
          ELSE
-            CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )        ! nemo local communicator given by xios
+            CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
          ENDIF
       ENDIF
@@ -296,4 +257,5 @@
       ENDIF
 #endif
+
       narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
 
@@ -301,18 +263,17 @@
       lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
 
-      IF(lwm) THEN
-         ! write merged namelists from earlier to output namelist now that the
-         ! file has been opened in call to mynode. nammpp has already been
-         ! written in mynode (if lk_mpp_mpi)
+      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
+         !                       ! now that the file has been opened in call to mynode. 
+         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
          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
+               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 
+      ! 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
@@ -326,14 +287,11 @@
       ENDIF
 
-      ! Calculate domain dimensions given calculated jpni and jpnj
-      ! This used to be done in par_oce.F90 when they were parameters rather
-      ! than variables
-      IF( Agrif_Root() ) THEN
+      IF( Agrif_Root() ) THEN       ! AGRIF mother: specific setting from jpni and jpnj
 #if defined key_nemocice_decomp
-         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first  dim.
-         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 
+         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim. 
 #else
-         jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci   ! first  dim.
-         jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj   ! second dim.
+         jpi = ( jpiglo     -2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( jpjglo     -2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim.
 #endif
       ENDIF
@@ -366,31 +324,28 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                  version 3.7  (2015) '
+         WRITE(numout,*) '                  version 3.7  (2016) '
          WRITE(numout,*) '             StandAlone Surface version (SAS) '
          WRITE(numout,*)
          WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt) 
-            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
+         DO ji = 1, SIZE(cltxt)
+            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
+            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) cltxt2(ji)   ! control print of domain size
          END DO
          !
-         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
+         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
 
-      ! Now we know the dimensions of the grid and numout has been set we can 
-      ! allocate arrays
+      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
       CALL nemo_alloc()
-
       !                             !-------------------------------!
       !                             !  NEMO general initialization  !
       !                             !-------------------------------!
 
-      CALL nemo_ctl                          ! Control prints & Benchmark
+      CALL nemo_ctl                          ! Control prints
 
       !                                      ! Domain decomposition
@@ -404,5 +359,4 @@
                             CALL phy_cst    ! Physical constants
                             CALL eos_init   ! Equation of state
-                            CALL dom_cfg    ! Domain configuration
                             CALL dom_init   ! Domain
 
@@ -437,5 +391,5 @@
       IF(lwp) THEN                  ! control print
          WRITE(numout,*)
-         WRITE(numout,*) 'nemo_ctl: Control prints & Benchmark'
+         WRITE(numout,*) 'nemo_ctl: Control prints'
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namctl'
@@ -464,8 +418,9 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         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
+         WRITE(numout,*) '      read domain configuration files               ln_read_cfg      = ', ln_read_cfg
+         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
+         WRITE(numout,*) '      write  configuration definition files         ln_write_cfg     = ', ln_write_cfg
+         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
@@ -486,5 +441,5 @@
          !                              ! indices used for the SUM control
          IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
-            lsp_area = .FALSE.                        
+            lsp_area = .FALSE.
          ELSE                                             ! print control done over a specific  area
             lsp_area = .TRUE.
@@ -558,5 +513,5 @@
 #endif
       !
-      INTEGER :: ierr,ierr1,ierr2,ierr3,ierr4,ierr5,ierr6,ierr7,ierr8
+      INTEGER :: ierr, ierr1, ierr2, ierr3, ierr4, ierr5, ierr6, ierr7, ierr8
       INTEGER :: jpm
       !!----------------------------------------------------------------------
@@ -577,11 +532,11 @@
       ! clem: should not be needed. To be checked out
       jpm = MAX(jp_tem, jp_sal)
-      ALLOCATE( tsn(jpi,jpj,1,jpm)  , STAT=ierr2 )
-      ALLOCATE( ub(jpi,jpj,1)       , STAT=ierr3 )
-      ALLOCATE( vb(jpi,jpj,1)       , STAT=ierr4 )
-      ALLOCATE( tsb(jpi,jpj,1,jpm)  , STAT=ierr5 )
+      ALLOCATE( tsn (jpi,jpj,1,jpm) , STAT=ierr2 )
+      ALLOCATE( ub  (jpi,jpj,1)     , STAT=ierr3 )
+      ALLOCATE( vb  (jpi,jpj,1)     , STAT=ierr4 )
+      ALLOCATE( tsb (jpi,jpj,1,jpm) , STAT=ierr5 )
       ALLOCATE( sshn(jpi,jpj)       , STAT=ierr6 )
-      ALLOCATE( un(jpi,jpj,1)       , STAT=ierr7 )
-      ALLOCATE( vn(jpi,jpj,1)       , STAT=ierr8 )
+      ALLOCATE( un  (jpi,jpj,1)     , STAT=ierr7 )
+      ALLOCATE( vn  (jpi,jpj,1)     , STAT=ierr8 )
       ierr = ierr + ierr1 + ierr2 + ierr3 + ierr4 + ierr5 + ierr6 + ierr7 + ierr8
 #endif
@@ -601,5 +556,5 @@
       !! ** Method  :
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have
+      INTEGER, INTENT(in) ::   num_pes   ! The number of MPI processes we have
       !
       INTEGER, PARAMETER :: nfactmax = 20
@@ -645,5 +600,5 @@
       !!
       !! ** Purpose :   return the prime factors of n.
-      !!                knfax factors are returned in array kfax which is of 
+      !!                knfax factors are returned in array kfax which is of
       !!                maximum dimension kmaxfax.
       !! ** Method  :
@@ -655,11 +610,10 @@
       INTEGER :: ifac, jl, inu
       INTEGER, PARAMETER :: ntest = 14
-      INTEGER :: ilfax(ntest)
+      INTEGER, DIMENSION(ntest) ::   ilfax
+      !!----------------------------------------------------------------------
       !
       ! lfax contains the set of allowed factors.
-      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
-         &                            128,   64,   32,   16,    8,   4,   2  /
-      !!----------------------------------------------------------------------
-
+      ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)
+      !
       ! Clear the error flag and initialise output vars
       kerr  = 0
@@ -709,12 +663,10 @@
 
    SUBROUTINE nemo_northcomms
-      !!======================================================================
+      !!----------------------------------------------------------------------
       !!                     ***  ROUTINE  nemo_northcomms  ***
-      !! nemo_northcomms    :  Setup for north fold exchanges with explicit 
-      !!                       point-to-point messaging
-      !!=====================================================================
-      !!----------------------------------------------------------------------
-      !!
-      !! ** Purpose :   Initialization of the northern neighbours lists.
+      !! ** Purpose :   Setup for north fold exchanges with explicit 
+      !!                point-to-point messaging
+      !!
+      !! ** Method :   Initialization of the northern neighbours lists.
       !!----------------------------------------------------------------------
       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
@@ -783,4 +735,5 @@
    END SUBROUTINE nemo_northcomms
 #endif
+
    !!======================================================================
 END MODULE nemogcm
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 7200)
@@ -416,6 +416,6 @@
       IF(lwp)  WRITE(numout,*)
 
-      IF( cp_cfg == "orca" .AND. .NOT. lk_c1d ) THEN      ! ORCA configuration (not 1D) !
-         !                                                    ! --------------------------- !
+      IF( cn_cfg == "orca" .AND. .NOT. lk_c1d ) THEN      ! ORCA configuration (not 1D) !
+         !                                                ! --------------------------- !
          ! set total alkalinity, phosphate, nitrate & silicate
          zarea          = 1._wp / glob_sum( cvol(:,:,:) ) * 1e6              
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/trcice_pisces.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/trcice_pisces.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/PISCES/trcice_pisces.F90	(revision 7200)
@@ -225,5 +225,5 @@
             WHERE( gphit(:,:) <  0._wp ) ; trc_o(:,:,jn) = zpisc(jn,3) ; END WHERE ! Antarctic 
          ENDIF
-         IF( cp_cfg == "orca" ) THEN     !  Baltic Sea particular case for ORCA configurations
+         IF( cn_cfg == "orca" ) THEN     !  Baltic Sea particular case for ORCA configurations
              WHERE( 14._wp <= glamt(:,:) .AND. glamt(:,:) <= 32._wp .AND.    &
                     54._wp <= gphit(:,:) .AND. gphit(:,:) <= 66._wp )
@@ -264,5 +264,5 @@
        
          !-- Baltic
-         IF( cp_cfg == "orca" ) THEN  ! Baltic treated seperately for ORCA configs
+         IF( cn_cfg == "orca" ) THEN  ! Baltic treated seperately for ORCA configs
             IF ( trc_ice_ratio(jn) >= - 1._wp ) THEN ! no prescribed conc. ; typically everything but iron) 
                WHERE( 14._wp <= glamt(:,:) .AND. glamt(:,:) <= 32._wp .AND.    &
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 7200)
@@ -252,7 +252,7 @@
          ! -------------------
 
-         IF( cp_cfg == "orca" ) THEN
-            !
-            SELECT CASE ( jp_cfg )
+         IF( cn_cfg == "orca" ) THEN
+            !
+            SELECT CASE ( nn_cfg )
             !                                           ! =======================
             CASE ( 1 )                                  ! eORCA_R1 configuration
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90	(revision 7200)
@@ -429,5 +429,5 @@
 
 !!gm Test removed, nothing specific to a configuration should survive out of usrdef modules
-!!gm      IF ( cp_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration
+!!gm      IF ( cn_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration
 !!gm      ! GYRE : for diagnostic fields, are needed if cyclic B.C. are present, but not for purely MPI comm. 
 !!gm      ! therefore we do not call lbc_lnk in GYRE config. (closed basin, no cyclic B.C.)
@@ -569,5 +569,5 @@
                
          !-- Lateral boundary conditions
-               IF ( cp_cfg .NE. 'gyre' ) THEN
+               IF ( cn_cfg .NE. 'gyre' ) THEN
                   CALL lbc_lnk( ztmltot(:,:,jn) , 'T', 1. )   ;   CALL lbc_lnk( ztmlres(:,:,jn) , 'T', 1. )
                   CALL lbc_lnk( ztmlatf(:,:,jn) , 'T', 1. )   ;   CALL lbc_lnk( ztmlrad(:,:,jn) , 'T', 1. )
@@ -620,5 +620,5 @@
 
          !-- Lateral boundary conditions 
-               IF ( cp_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration    
+               IF ( cn_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration    
                   CALL lbc_lnk( ztmltot2(:,:,jn), 'T', 1. )
                   CALL lbc_lnk( ztmlres2(:,:,jn), 'T', 1. )
@@ -992,9 +992,9 @@
 
          !-- Lateral boundary conditions
-         IF ( cp_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration 
+         IF ( cn_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration 
             ! ES_B27_CD_WARN : lbc inutile GYRE, cf. + haut
             DO jn = 1, jpdiabio
               CALL lbc_lnk( ztmltrdbio2(:,:,jn), 'T', 1. )
-            ENDDO
+            END DO
          ENDIF
 
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_cfg
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_cfg	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_cfg	(revision 7200)
@@ -15,5 +15,5 @@
 !-----------------------------------------------------------------------
    !
-   ln_e2_dep   = .true.    ! =T : e3=dk[depth] in discret sens. 
+   ln_e3_dep   = .true.    ! =T : e3=dk[depth] in discret sens. 
    !                       !      ===>>> will become the only possibility in v4.0
    !                       ! =F : e3 analytical derivative of depth function
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_ref
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_ref	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/namelist_ref	(revision 7200)
@@ -74,5 +74,5 @@
 !-----------------------------------------------------------------------
    !
-   ln_e2_dep   = .true.    ! =T : e3=dk[depth] in discret sens. 
+   ln_e3_dep   = .true.    ! =T : e3=dk[depth] in discret sens. 
    !                       !      ===>>> will become the only possibility in v4.0
    !                       ! =F : e3 analytical derivative of depth function
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domain.f90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domain.f90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domain.f90	(revision 7200)
@@ -379,8 +379,8 @@
       !!              ocean configuration.
       !!
-      !! ** output file :   domain_cfg.nc : domain size, characteristics,
-      !horizontal mesh,
-      !!                              Coriolis parameter, depth and vertical
-      !scale factors
+      !! ** output file :   domain_cfg.nc : domain size, characteristics,horizontal mesh,
+      !!                              Coriolis parameter, and vertical scale factors
+      !!                              NB: also contains ORCA family information (if cp_cfg = "ORCA")
+      !!                              and depths (ln_e3_dep=F) 
       !!----------------------------------------------------------------------
       INTEGER           ::   ji, jj, jk   ! dummy loop indices
@@ -402,4 +402,10 @@
       CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
       
+      !
+      !                             !==  ORCA family specificities  ==!
+      IF( cp_cfg == "ORCA" ) THEN
+         CALL iom_rstput( 0, 0, inum, 'ORCA'      , 1._wp            , ktype = jp_i4 )
+         CALL iom_rstput( 0, 0, inum, 'ORCA_index', REAL( jp_cfg, wp), ktype = jp_i4 )         
+      ENDIF
       !                             !==  global domain size  ==!
       !
@@ -456,11 +462,4 @@
       CALL iom_rstput( 0, 0, inum, 'e3w_1d'  , e3w_1d  , ktype = jp_r8 )
       !
-      IF(.NOT.ln_e2_dep ) THEN                                             !  depth (t- & w-points)
-         CALL iom_rstput( 0, 0, inum, 'gdept_1d', gdept_1d, ktype = jp_r8 )   ! required only with  
-         CALL iom_rstput( 0, 0, inum, 'gdepw_1d', gdepw_1d, ktype = jp_r8 )   ! the old e3. definition
-         CALL iom_rstput( 0, 0, inum, 'gdept_0' , gdept_0 , ktype = jp_r8 )
-         CALL iom_rstput( 0, 0, inum, 'gdepw_0' , gdepw_0 , ktype = jp_r8 )
-      ENDIF
-      !
       CALL iom_rstput( 0, 0, inum, 'e3t_0'   , e3t_0   , ktype = jp_r8 )   !  vertical scale factors (e
       CALL iom_rstput( 0, 0, inum, 'e3u_0'   , e3u_0   , ktype = jp_r8 )
@@ -470,4 +469,11 @@
       CALL iom_rstput( 0, 0, inum, 'e3uw_0'  , e3uw_0  , ktype = jp_r8 )
       CALL iom_rstput( 0, 0, inum, 'e3vw_0'  , e3vw_0  , ktype = jp_r8 )
+      !
+      IF(.NOT.ln_e3_dep ) THEN                                             !  depth (t- & w-points)
+         CALL iom_rstput( 0, 0, inum, 'gdept_1d', gdept_1d, ktype = jp_r8 )   ! required only with  
+         CALL iom_rstput( 0, 0, inum, 'gdepw_1d', gdepw_1d, ktype = jp_r8 )   ! the old e3. definition
+         CALL iom_rstput( 0, 0, inum, 'gdept_0' , gdept_0 , ktype = jp_r8 )
+         CALL iom_rstput( 0, 0, inum, 'gdepw_0' , gdepw_0 , ktype = jp_r8 )
+      ENDIF
       !                                         
       !                             !==  ocean top and bottom level  ==!
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domzgr.f90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domzgr.f90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/domzgr.f90	(revision 7200)
@@ -314,5 +314,5 @@
       ENDIF
 
-      IF ( ln_isfcav .OR. ln_e2_dep ) THEN      ! e3. = dk[gdep]   
+      IF ( ln_isfcav .OR. ln_e3_dep ) THEN      ! e3. = dk[gdep]   
          !
 !==>>>   need to be like this to compute the pressure gradient with ISF. 
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/nemogcm.f90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/nemogcm.f90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/nemogcm.f90	(revision 7200)
@@ -131,5 +131,5 @@
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_bench, nn_timing, nn_diacfl
-      NAMELIST/namcfg/ ln_e2_dep,                                &
+      NAMELIST/namcfg/ ln_e3_dep,                                &
          &             cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, &
          &             jpizoom, jpjzoom, jperio, ln_use_jattr
@@ -288,5 +288,5 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         WRITE(numout,*) '      vertical scale factors =T: e3.=dk[depth]       ln_e2_dep = ', ln_e2_dep
+         WRITE(numout,*) '      vertical scale factors =T: e3.=dk[depth]       ln_e3_dep = ', ln_e3_dep
          WRITE(numout,*) '                             =F: old definition                 '
          WRITE(numout,*) '      configuration name                               cp_cfg  = ', TRIM(cp_cfg)
@@ -303,5 +303,5 @@
          WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
          !
-         IF(.NOT.ln_e2_dep ) THEN
+         IF(.NOT.ln_e3_dep ) THEN
             WRITE(numout,cform_war)
             WRITE(numout,*)
Index: /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/par_oce.f90
===================================================================
--- /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/par_oce.f90	(revision 7199)
+++ /branches/2016/dev_r6409_SIMPLIF_2_usrdef/NEMOGCM/TOOLS/DOMAINcfg/src/par_oce.f90	(revision 7200)
@@ -29,5 +29,5 @@
    !!----------------------------------------------------------------------
    !
-   LOGICAL       ::   ln_e2_dep        ! e3. definition flag
+   LOGICAL       ::   ln_e3_dep        ! e3. definition flag
    !
    CHARACTER(lc) ::   cp_cfg           !: name of the configuration
