Index: NEMO/trunk/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/in_out_manager.F90	(revision 13286)
@@ -118,5 +118,4 @@
    LOGICAL ::   ln_timing        !: run control for timing
    LOGICAL ::   ln_diacfl        !: flag whether to create CFL diagnostics
-   INTEGER ::   nn_print         !: level of print (0 no print)
    INTEGER ::   nn_ictls         !: Start i indice for the SUM control
    INTEGER ::   nn_ictle         !: End   i indice for the SUM control
@@ -125,8 +124,4 @@
    INTEGER ::   nn_isplt         !: number of processors following i
    INTEGER ::   nn_jsplt         !: number of processors following j
-   !                                          
-   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt    !: OLD namelist names
-
-   INTEGER ::   ijsplt     =    1      !: nb of local domain = nb of processors
 
    !!----------------------------------------------------------------------
Index: NEMO/trunk/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/iom.F90	(revision 13286)
@@ -21,4 +21,5 @@
    !!----------------------------------------------------------------------
    USE dom_oce         ! ocean space and time domain
+   USE domutl          ! 
    USE c1d             ! 1D vertical configuration
    USE flo_oce         ! floats module declarations
@@ -34,5 +35,4 @@
    USE ice      , ONLY :   jpl
 #endif
-   USE domngb          ! ocean space and time domain
    USE phycst          ! physical constants
    USE dianam          ! build name of file
@@ -101,5 +101,5 @@
 CONTAINS
 
-   SUBROUTINE iom_init( cdname, fname, ld_tmppatch, ld_closedef ) 
+   SUBROUTINE iom_init( cdname, fname, ld_closedef ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -110,5 +110,4 @@
       CHARACTER(len=*),           INTENT(in)  :: cdname
       CHARACTER(len=*), OPTIONAL, INTENT(in)  :: fname
-      LOGICAL         , OPTIONAL, INTENT(in)  :: ld_tmppatch
       LOGICAL         , OPTIONAL, INTENT(in)  :: ld_closedef
 #if defined key_iomput
@@ -123,22 +122,7 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds
       REAL(wp), DIMENSION(2,jpkam1)         :: za_bnds   ! ABL vertical boundaries
-      LOGICAL ::   ll_tmppatch = .TRUE.    !: seb: patch before we remove periodicity
-      INTEGER ::   nldi_save, nlei_save    !:      and close boundaries in output files
-      INTEGER ::   nldj_save, nlej_save    !:
       LOGICAL ::   ll_closedef = .TRUE.
       !!----------------------------------------------------------------------
       !
-      ! seb: patch before we remove periodicity and close boundaries in output files
-      IF( PRESENT(ld_tmppatch) ) THEN   ;   ll_tmppatch = ld_tmppatch
-      ELSE                              ;   ll_tmppatch = .TRUE.
-      ENDIF
-      IF ( ll_tmppatch ) THEN
-         nldi_save = nldi   ;   nlei_save = nlei
-         nldj_save = nldj   ;   nlej_save = nlej
-         IF( nimpp           ==      1 ) nldi = 1
-         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
-         IF( njmpp           ==      1 ) nldj = 1
-         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
-      ENDIF
       IF ( PRESENT(ld_closedef) ) ll_closedef = ld_closedef
       !
@@ -157,10 +141,10 @@
 
       SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
-      CASE ( 1)   ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), &
-          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
-      CASE ( 0)   ; CALL xios_define_calendar( TYPE = "NoLeap"   , time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), &
-          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
-      CASE (30)   ; CALL xios_define_calendar( TYPE = "D360"     , time_origin = xios_date(irefyear,irefmonth,irefday,00,00,00), &
-          &                                    start_date = xios_date(nyear,nmonth,nday,0,0,0) )
+      CASE ( 1)   ;   CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(irefyear,irefmonth,irefday,0,0,0),   &
+          &                                                          start_date  = xios_date(   nyear,   nmonth,   nday,0,0,0) )
+      CASE ( 0)   ;   CALL xios_define_calendar( TYPE = "NoLeap"   , time_origin = xios_date(irefyear,irefmonth,irefday,0,0,0),   &
+          &                                                          start_date  = xios_date(   nyear,   nmonth,   nday,0,0,0) )
+      CASE (30)   ;   CALL xios_define_calendar( TYPE = "D360"     , time_origin = xios_date(irefyear,irefmonth,irefday,0,0,0),   &
+          &                                                          start_date  = xios_date(   nyear,   nmonth,   nday,0,0,0) )
       END SELECT
 
@@ -176,8 +160,8 @@
          !
          IF( ln_cfmeta ) THEN   ! Add additional grid metadata
-            CALL iom_set_domain_attr("grid_T", area = real( e1e2t(nldi:nlei, nldj:nlej), dp))
-            CALL iom_set_domain_attr("grid_U", area = real( e1e2u(nldi:nlei, nldj:nlej), dp))
-            CALL iom_set_domain_attr("grid_V", area = real( e1e2v(nldi:nlei, nldj:nlej), dp))
-            CALL iom_set_domain_attr("grid_W", area = real( e1e2t(nldi:nlei, nldj:nlej), dp))
+            CALL iom_set_domain_attr("grid_T", area = real( e1e2t(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_U", area = real( e1e2u(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_V", area = real( e1e2v(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_W", area = real( e1e2t(Nis0:Nie0, Njs0:Nje0), dp))
             CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit )
             CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu )
@@ -199,8 +183,8 @@
          !
          IF( ln_cfmeta .AND. .NOT. llrst_context) THEN   ! Add additional grid metadata
-            CALL iom_set_domain_attr("grid_T", area = real(e1e2t_crs(nldi:nlei, nldj:nlej), dp))
-            CALL iom_set_domain_attr("grid_U", area = real(e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej), dp) )
-            CALL iom_set_domain_attr("grid_V", area = real(e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej), dp) )
-            CALL iom_set_domain_attr("grid_W", area = real(e1e2t_crs(nldi:nlei, nldj:nlej), dp ) )
+            CALL iom_set_domain_attr("grid_T", area = real(e1e2t_crs(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_U", area = real(e1u_crs(Nis0:Nie0, Njs0:Nje0) * e2u_crs(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_V", area = real(e1v_crs(Nis0:Nie0, Njs0:Nje0) * e2v_crs(Nis0:Nie0, Njs0:Nje0), dp))
+            CALL iom_set_domain_attr("grid_W", area = real(e1e2t_crs(Nis0:Nie0, Njs0:Nje0), dp))
             CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs )
             CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs )
@@ -288,8 +272,4 @@
       DEALLOCATE( zt_bnds, zw_bnds )
       !
-      IF ( ll_tmppatch ) THEN
-         nldi = nldi_save   ;   nlei = nlei_save
-         nldj = nldj_save   ;   nlej = nlej_save
-      ENDIF
 #endif
       !
@@ -671,5 +651,5 @@
 
 
-   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev, cdcomp )
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, ldstop, ldiof, kdlev, cdcomp )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -680,5 +660,4 @@
       INTEGER         , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
-      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
@@ -693,12 +672,9 @@
       LOGICAL               ::   llok      ! check the existence 
       LOGICAL               ::   llwrt     ! local definition of ldwrt
-      LOGICAL               ::   llnoov    ! local definition to read overlap
       LOGICAL               ::   llstop    ! local definition of ldstop
       LOGICAL               ::   lliof     ! local definition of ldiof
       INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
       INTEGER               ::   iln, ils  ! lengths of character
-      INTEGER               ::   idom      ! type of domain
       INTEGER               ::   istop     ! 
-      INTEGER, DIMENSION(2,5) ::   idompar ! domain parameters: 
       ! local number of points for x,y dimensions
       ! position of first local point for x,y dimensions
@@ -732,7 +708,4 @@
       ELSE                        ;   lliof = .FALSE.
       ENDIF
-      ! do we read the overlap 
-      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
-      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif
       ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
       ! =============
@@ -774,37 +747,4 @@
          lxios_sini = .TRUE.
       ENDIF
-      IF( llwrt ) THEN
-         ! check the domain definition
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!         idom = jpdom_local_noovlap   ! default definition
-         IF( llnoov ) THEN   ;   idom = jpdom_local_noovlap   ! default definition
-         ELSE                ;   idom = jpdom_local_full      ! default definition
-         ENDIF
-         IF( PRESENT(kdom) )   idom = kdom
-         ! create the domain informations
-         ! =============
-         SELECT CASE (idom)
-         CASE (jpdom_local_full)
-            idompar(:,1) = (/ jpi             , jpj              /)
-            idompar(:,2) = (/ nimpp           , njmpp            /)
-            idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1  /)
-            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
-            idompar(:,5) = (/ jpi - nlei      , jpj - nlej       /)
-         CASE (jpdom_local_noextra)
-            idompar(:,1) = (/ nlci            , nlcj             /)
-            idompar(:,2) = (/ nimpp           , njmpp            /)
-            idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /)
-            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
-            idompar(:,5) = (/ nlci - nlei     , nlcj - nlej      /)
-         CASE (jpdom_local_noovlap)
-            idompar(:,1) = (/ nlei  - nldi + 1, nlej  - nldj + 1 /)
-            idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /)
-            idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /)
-            idompar(:,4) = (/ 0               , 0                /)
-            idompar(:,5) = (/ 0               , 0                /)
-         CASE DEFAULT
-            CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' )
-         END SELECT
-      ENDIF
       ! Open the NetCDF file
       ! =============
@@ -830,5 +770,5 @@
       ENDIF
       IF( istop == nstop ) THEN   ! no error within this routine
-         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev, cdcomp = cdcomp )
+         CALL iom_nf90_open( clname, kiomid, llwrt, llok, kdlev = kdlev, cdcomp = cdcomp )
       ENDIF
       !
@@ -1091,109 +1031,102 @@
    END SUBROUTINE iom_g1d_dp
 
-   SUBROUTINE iom_g2d_sp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios)
-      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
-      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
-      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
-      REAL(sp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
-      REAL(dp)        , ALLOCATABLE  , DIMENSION(:,:)           ::   ztmp_pvar ! tmp var to read field
-      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
-      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
-      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
-                                                                               ! look for and use a file attribute
-                                                                               ! called open_ocean_jstart to set the start
-                                                                               ! value for the 2nd dimension (netcdf only)
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios      ! read data using XIOS
+   SUBROUTINE iom_g2d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios)
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(sp)        , INTENT(  out), DIMENSION(:,:)         ::   pvar      ! read field
+      REAL(dp)        , ALLOCATABLE  , DIMENSION(:,:)         ::   ztmp_pvar ! tmp var to read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      CHARACTER(len=1), INTENT(in   )              , OPTIONAL ::   cd_type   ! nature of grid-points (T, U, V, F, W)
+      REAL(dp)        , INTENT(in   )              , OPTIONAL ::   psgn      ! -1.(1.): (not) change sign across the north fold
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   kfill     ! value of kfillmode in lbc_lbk
+      INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) THEN
             ALLOCATE(ztmp_pvar(size(pvar,1), size(pvar,2)))
-            CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=ztmp_pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr,  ldxios=ldxios)
+            CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r2d = ztmp_pvar  , ktime = ktime,   &
+             &                                                      cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
+             &                                                      kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+            pvar = ztmp_pvar
+            DEALLOCATE(ztmp_pvar)
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g2d_sp
+
+   SUBROUTINE iom_g2d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios)
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(dp)        , INTENT(  out), DIMENSION(:,:)         ::   pvar      ! read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      CHARACTER(len=1), INTENT(in   )              , OPTIONAL ::   cd_type   ! nature of grid-points (T, U, V, F, W)
+      REAL(dp)        , INTENT(in   )              , OPTIONAL ::   psgn      ! -1.(1.): (not) change sign across the north fold
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   kfill     ! value of kfillmode in lbc_lbk
+      INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r2d = pvar  , ktime = ktime,   &
+            &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
+            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+      ENDIF
+   END SUBROUTINE iom_g2d_dp
+
+   SUBROUTINE iom_g3d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios )
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(sp)        , INTENT(  out), DIMENSION(:,:,:)       ::   pvar      ! read field
+      REAL(dp)        , ALLOCATABLE  , DIMENSION(:,:,:)       ::   ztmp_pvar ! tmp var to read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      CHARACTER(len=1), INTENT(in   )              , OPTIONAL ::   cd_type   ! nature of grid-points (T, U, V, F, W)
+      REAL(dp)        , INTENT(in   )              , OPTIONAL ::   psgn      ! -1.(1.) : (not) change sign across the north fold
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   kfill     ! value of kfillmode in lbc_lbk
+      INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ALLOCATE(ztmp_pvar(size(pvar,1), size(pvar,2), size(pvar,3)))
+            CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r3d = ztmp_pvar  , ktime = ktime,   &
+            &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
+            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
             pvar = ztmp_pvar
             DEALLOCATE(ztmp_pvar)
          END IF
       ENDIF
-   END SUBROUTINE iom_g2d_sp
-
-
-   SUBROUTINE iom_g2d_dp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios)
-      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
-      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
-      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
-      REAL(dp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
-      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
-      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
-      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
-                                                                               ! look for and use a file attribute
-                                                                               ! called open_ocean_jstart to set the start
-                                                                               ! value for the 2nd dimension (netcdf only)
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios      ! read data using XIOS
-      !
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr,  ldxios=ldxios)
-      ENDIF
-   END SUBROUTINE iom_g2d_dp
-
-   SUBROUTINE iom_g3d_sp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios )
-      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
-      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
-      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
-      REAL(sp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
-      REAL(dp)        , ALLOCATABLE  , DIMENSION(:,:,:)           ::   ztmp_pvar ! tmp var to read field
-      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
-      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
-      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   )                  , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
-                                                                                 ! look for and use a file attribute
-                                                                                 ! called open_ocean_jstart to set the start
-                                                                                 ! value for the 2nd dimension (netcdf only)
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios        ! read data using XIOS
+   END SUBROUTINE iom_g3d_sp
+
+   SUBROUTINE iom_g3d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios )
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(dp)        , INTENT(  out), DIMENSION(:,:,:)       ::   pvar      ! read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      CHARACTER(len=1), INTENT(in   )              , OPTIONAL ::   cd_type   ! nature of grid-points (T, U, V, F, W)
+      REAL(dp)        , INTENT(in   )              , OPTIONAL ::   psgn      ! -1.(1.) : (not) change sign across the north fold
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   kfill     ! value of kfillmode in lbc_lbk
+      INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) THEN
-            ALLOCATE(ztmp_pvar(size(pvar,1), size(pvar,2), size(pvar,3)))
-            CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=ztmp_pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr, ldxios=ldxios )
-            pvar = ztmp_pvar
-            DEALLOCATE(ztmp_pvar)
+            CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r3d = pvar  , ktime = ktime,   &
+            &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
+            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
          END IF
       ENDIF
-   END SUBROUTINE iom_g3d_sp
-
-   SUBROUTINE iom_g3d_dp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr, ldxios )
-      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
-      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
-      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
-      REAL(dp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
-      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
-      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
-      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   )                  , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
-                                                                                 ! look for and use a file attribute
-                                                                                 ! called open_ocean_jstart to set the start
-                                                                                 ! value for the 2nd dimension (netcdf only)
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios        ! read data using XIOS
-      !
-      IF( kiomid > 0 ) THEN
-         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     lrowattr=lrowattr, ldxios=ldxios )
-      ENDIF
    END SUBROUTINE iom_g3d_dp
 
-
-
    !!----------------------------------------------------------------------
 
-   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
-         &                  pv_r1d, pv_r2d, pv_r3d,   &
-         &                  ktime , kstart, kcount,   &
-         &                  lrowattr, ldxios        )
+   SUBROUTINE iom_get_123d( kiomid , kdom, cdvar, pv_r1d, pv_r2d, pv_r3d, ktime ,   &
+         &                  cd_type, psgn, kfill, kstart, kcount, ldxios )
       !!-----------------------------------------------------------------------
       !!                  ***  ROUTINE  iom_get_123d  ***
@@ -1203,23 +1136,20 @@
       !! ** Method : read ONE record at each CALL
       !!-----------------------------------------------------------------------
-      INTEGER                    , INTENT(in   )           ::   kiomid     ! Identifier of the file
-      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
-      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar      ! Name of the variable
-      REAL(dp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
-      REAL(dp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
-      REAL(dp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
-      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
-      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis 
-      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
-      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to
-                                                                           ! look for and use a file attribute
-                                                                           ! called open_ocean_jstart to set the start
-                                                                           ! value for the 2nd dimension (netcdf only)
-      LOGICAL                    , INTENT(in   ), OPTIONAL ::   ldxios     ! use XIOS to read restart
-      !
-      LOGICAL                        ::   llxios       ! local definition for XIOS read
-      LOGICAL                        ::   llnoov      ! local definition to read overlap
-      LOGICAL                        ::   luse_jattr  ! local definition to read open_ocean_jstart file attribute
-      INTEGER                        ::   jstartrow   ! start point for 2nd dimension optionally set by file attribute
+      INTEGER                    , INTENT(in   )           ::   kiomid    ! Identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar     ! Name of the variable
+      REAL(dp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d    ! read field (1D case)
+      REAL(dp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d    ! read field (2D case)
+      REAL(dp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d    ! read field (3D case)
+      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime     ! record number
+      CHARACTER(len=1)           , INTENT(in   ), OPTIONAL ::   cd_type   ! nature of grid-points (T, U, V, F, W)
+      REAL(dp)                   , INTENT(in   ), OPTIONAL ::   psgn      ! -1.(1.) : (not) change sign across the north fold
+      INTEGER                    , INTENT(in   ), OPTIONAL ::   kfill     ! value of kfillmode in lbc_lbk
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart    ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount    ! number of points to be read in each axis
+      LOGICAL                    , INTENT(in   ), OPTIONAL ::   ldxios    ! use XIOS to read restart
+      !
+      LOGICAL                        ::   llok        ! true if ok!
+      LOGICAL                        ::   llxios      ! local definition for XIOS read
       INTEGER                        ::   jl          ! loop on number of dimension 
       INTEGER                        ::   idom        ! type of domain
@@ -1238,9 +1168,11 @@
       INTEGER, DIMENSION(jpmax_dims) ::   ishape      ! size of the dimensions of the variable
       REAL(dp)                       ::   zscf, zofs  ! sacle_factor and add_offset
+      REAL(wp)                       ::   zsgn        ! local value of psgn
       INTEGER                        ::   itmp        ! temporary integer
       CHARACTER(LEN=256)             ::   clinfo      ! info character
       CHARACTER(LEN=256)             ::   clname      ! file name
       CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
-      LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension.
+      CHARACTER(LEN=1)               ::   cl_type     ! local value of cd_type
+      LOGICAL                        ::   ll_only3rd  ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension.
       INTEGER                        ::   inlev       ! number of levels for 3D data
       REAL(dp)                       ::   gma, gmi
@@ -1251,33 +1183,26 @@
       !
       llxios = .FALSE.
-      if(PRESENT(ldxios)) llxios = ldxios
-      idvar = iom_varid( kiomid, cdvar ) 
+      IF( PRESENT(ldxios) )   llxios = ldxios
+      !
       idom = kdom
+      istop = nstop
       !
       IF(.NOT.llxios) THEN
          clname = iom_file(kiomid)%name   !   esier to read
          clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
-         ! local definition of the domain ?
-         ! do we read the overlap 
-         ! ugly patch SM+JMM+RB to overwrite global definition in some cases
-         llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
          ! check kcount and kstart optionals parameters...
-         IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
-         IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
-         IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND.  idom /= jpdom_autoglo_xy  ) &
-     &          CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy')
-
-         luse_jattr = .false.
-         IF( PRESENT(lrowattr) ) THEN
-            IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
-            IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
-         ENDIF
-
+         IF( PRESENT(kcount) .AND. .NOT. PRESENT(kstart) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
+         IF( PRESENT(kstart) .AND. .NOT. PRESENT(kcount) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
+         IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND. idom /= jpdom_auto_xy ) &
+            &          CALL ctl_stop(TRIM(clinfo), 'kstart present needs idom = jpdom_unknown or idom = jpdom_auto_xy')
+         IF( idom == jpdom_auto_xy .AND. .NOT. PRESENT(kstart) ) &
+            &          CALL ctl_stop(TRIM(clinfo), 'idom = jpdom_auto_xy requires kstart to be present')
+         !
          ! Search for the variable in the data base (eventually actualize data)
-         istop = nstop
          !
+         idvar = iom_varid( kiomid, cdvar ) 
          IF( idvar > 0 ) THEN
-            ! to write iom_file(kiomid)%dimsz in a shorter way !
-            idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
+            !
+            idimsz(:) = iom_file(kiomid)%dimsz(:, idvar)      ! to write iom_file(kiomid)%dimsz in a shorter way
             inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
             idmspc = inbdim                                   ! number of spatial dimensions in the file
@@ -1285,27 +1210,11 @@
             IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
             !
-            ! update idom definition...
-            ! Identify the domain in case of jpdom_auto(glo/dta) definition
-            IF( idom == jpdom_autoglo_xy ) THEN
-               ll_depth_spec = .TRUE.
-               idom = jpdom_autoglo
-            ELSE
-               ll_depth_spec = .FALSE.
-            ENDIF
-            IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
-               IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
-               ELSE                               ;   idom = jpdom_data
-               ENDIF
+            ! Identify the domain in case of jpdom_auto definition
+            IF( idom == jpdom_auto .OR. idom == jpdom_auto_xy ) THEN            
+               idom = jpdom_global   ! default
+               ! else: if the file name finishes with _xxxx.nc with xxxx any number
                ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
                ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
                IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
-            ENDIF
-            ! Identify the domain in case of jpdom_local definition
-            IF( idom == jpdom_local ) THEN
-               IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
-               ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
-               ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
-               ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
-               ENDIF
             ENDIF
             !
@@ -1320,15 +1229,22 @@
             WRITE(cldmspc , fmt='(i1)') idmspc
             !
-            !!GS: we consider 2D data as 3D data with vertical dim size = 1
-            !IF(     idmspc <  irankpv ) THEN 
-            !   CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
-            !      &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
-            !ELSEIF( idmspc == irankpv ) THEN
-            IF( idmspc == irankpv ) THEN
+            IF(     idmspc <  irankpv ) THEN                     ! it seems we want to read more than we can...
+               IF(     irankpv == 3 .AND. idmspc == 2 ) THEN     !   3D input array from 2D spatial data in the file:
+                  llok = inlev == 1                              !     -> 3rd dimension must be equal to 1
+               ELSEIF( irankpv == 3 .AND. idmspc == 1 ) THEN     !   3D input array from 1D spatial data in the file:
+                  llok = inlev == 1 .AND. SIZE(pv_r3d, 2) == 1   !     -> 2nd and 3rd dimensions must be equal to 1
+               ELSEIF( irankpv == 2 .AND. idmspc == 2 ) THEN     !   2D input array from 1D spatial data in the file:
+                  llok = SIZE(pv_r2d, 2) == 1                    !     -> 2nd dimension must be equal to 1
+               ELSE
+                  llok = .FALSE.
+               ENDIF
+               IF( .NOT. llok )   CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
+                  &                                            '=> cannot read a true '//clrankpv//'D array from this file...' )
+            ELSEIF( idmspc == irankpv ) THEN
                IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
                   &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
-            ELSEIF( idmspc >  irankpv ) THEN
+            ELSEIF( idmspc >  irankpv ) THEN                     ! it seems we want to read less than we should...
                   IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
-                     CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
+                     CALL ctl_warn( trim(clinfo), '2D array input but 3 spatial dimensions in the file...'              ,   &
                            &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
                            &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
@@ -1344,45 +1260,29 @@
             ! definition of istart and icnt
             !
-            icnt  (:) = 1
-            istart(:) = 1
-            istart(idmspc+1) = itime
-   
-            IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN 
-               istart(1:idmspc) = kstart(1:idmspc) 
-               icnt  (1:idmspc) = kcount(1:idmspc)
-            ELSE
-               IF(idom == jpdom_unknown ) THEN
-                  icnt(1:idmspc) = idimsz(1:idmspc)
-               ELSE 
-                  IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
-                     IF(     idom == jpdom_data    ) THEN
-                        jstartrow = 1
-                        IF( luse_jattr ) THEN
-                           CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
-                           jstartrow = MAX(1,jstartrow)
-                        ENDIF
-                        istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below
-                     ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below
-                     ENDIF
-                     ! we do not read the overlap                     -> we start to read at nldi, nldj
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
-                     IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
-                  ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
-                     IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
-                     ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
-                     ENDIF
-                     IF( PRESENT(pv_r3d) ) THEN
-                        IF( idom == jpdom_data ) THEN                        ;                               icnt(3) = inlev
-                        ELSEIF( ll_depth_spec .AND. PRESENT(kstart) ) THEN   ;   istart(3) = kstart(3)   ;   icnt(3) = kcount(3)
-                        ELSE                                                 ;                               icnt(3) = inlev
-                        ENDIF
-                     ENDIF
+            icnt  (:) = 1              ! default definition (simple way to deal with special cases listed above) 
+            istart(:) = 1              ! default definition (simple way to deal with special cases listed above) 
+            istart(idmspc+1) = itime   ! temporal dimenstion
+            !
+            IF( idom == jpdom_unknown ) THEN
+               IF( PRESENT(kstart) .AND. idom /= jpdom_auto_xy ) THEN 
+                  istart(1:idmspc) = kstart(1:idmspc) 
+                  icnt  (1:idmspc) = kcount(1:idmspc)
+               ELSE
+                  icnt  (1:idmspc) = idimsz(1:idmspc)
+               ENDIF
+            ELSE   !   not a 1D array as pv_r1d requires jpdom_unknown
+               ! we do not read the overlap and the extra-halos -> from Nis0 to Nie0 and from Njs0 to Nje0 
+               IF( idom == jpdom_global )   istart(1:2) = (/ mig0(Nis0), mjg0(Njs0) /)
+               icnt(1:2) = (/ Ni_0, Nj_0 /)
+               IF( PRESENT(pv_r3d) ) THEN
+                  IF( idom == jpdom_auto_xy ) THEN
+                     istart(3) = kstart(3)
+                     icnt  (3) = kcount(3)
+                  ELSE
+                     icnt  (3) = inlev
                   ENDIF
                ENDIF
             ENDIF
-
+            !
             ! check that istart and icnt can be used with this file
             !-
@@ -1395,5 +1295,5 @@
                ENDIF
             END DO
-
+            !
             ! check that icnt matches the input array
             !-     
@@ -1405,19 +1305,10 @@
             ELSE
                IF( irankpv == 2 ) THEN
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
-                  IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
-                  ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
-                  ENDIF
+                  ishape(1:2) = SHAPE(pv_r2d(Nis0:Nie0,Njs0:Nje0  ))   ;   ctmp1 = 'd(Nis0:Nie0,Njs0:Nje0)'
                ENDIF
                IF( irankpv == 3 ) THEN 
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
-                  IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
-                  ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
-                  ENDIF
+                  ishape(1:3) = SHAPE(pv_r3d(Nis0:Nie0,Njs0:Nje0,:))   ;   ctmp1 = 'd(Nis0:Nie0,Njs0:Nje0,:)'
                ENDIF
-            ENDIF
-         
+            ENDIF         
             DO jl = 1, irankpv
                WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
@@ -1431,17 +1322,7 @@
          IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
             !
-         ! find the right index of the array to be read
-! JMM + SM: ugly patch before getting the new version of lib_mpp)
-!         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
-!         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
-!         ENDIF
-            IF( llnoov ) THEN
-               IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
-               ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
-               ENDIF
-            ELSE
-               IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
-               ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
-               ENDIF
+            ! find the right index of the array to be read
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = Nis0   ;   ix2 = Nie0      ;   iy1 = Njs0   ;   iy2 = Nje0
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
             ENDIF
       
@@ -1450,16 +1331,14 @@
             IF( istop == nstop ) THEN   ! no additional errors until this point...
                IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
-             
+
+               cl_type = 'T'
+               IF( PRESENT(cd_type) )   cl_type = cd_type
+               zsgn = 1._wp
+               IF( PRESENT(psgn   ) )   zsgn    = psgn
                !--- overlap areas and extra hallows (mpp)
-               IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
-                  CALL lbc_lnk( 'iom', pv_r2d,'Z', -999.0_wp, kfillmode = jpfillnothing )
-               ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
-                  ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
-                  IF( icnt(3) == inlev ) THEN
-                     CALL lbc_lnk( 'iom', pv_r3d,'Z', -999.0_wp, kfillmode = jpfillnothing )
-                  ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
-                     DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
-                     DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
-                  ENDIF
+               IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown .AND. cl_type /= 'Z' ) THEN
+                  CALL lbc_lnk( 'iom', pv_r2d, cl_type, zsgn, kfillmode = kfill )
+               ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown .AND. cl_type /= 'Z' ) THEN
+                  CALL lbc_lnk( 'iom', pv_r3d, cl_type, zsgn, kfillmode = kfill )
                ENDIF
                !
@@ -1478,20 +1357,13 @@
          CALL iom_swap( TRIM(crxios_context) ) 
          IF( PRESENT(pv_r3d) ) THEN
-            pv_r3d(:, :, :) = 0.
-            if(lwp) write(numout,*) 'XIOS RST READ (3D): ',trim(cdvar)
+            IF(lwp) WRITE(numout,*) 'XIOS RST READ (3D): ',TRIM(cdvar)
             CALL xios_recv_field( trim(cdvar), pv_r3d)
-            IF(idom /= jpdom_unknown ) then
-                CALL lbc_lnk( 'iom', pv_r3d,'Z', -999.0_wp, kfillmode = jpfillnothing)
-            ENDIF
+            IF(idom /= jpdom_unknown )   CALL lbc_lnk( 'iom', pv_r3d,'Z', -999., kfillmode = jpfillnothing)
          ELSEIF( PRESENT(pv_r2d) ) THEN
-            pv_r2d(:, :) = 0.
-            if(lwp) write(numout,*) 'XIOS RST READ (2D): ', trim(cdvar)
+            IF(lwp) WRITE(numout,*) 'XIOS RST READ (2D): ', TRIM(cdvar)
             CALL xios_recv_field( trim(cdvar), pv_r2d)
-            IF(idom /= jpdom_unknown ) THEN
-                CALL lbc_lnk('iom', pv_r2d,'Z',-999.0_wp, kfillmode = jpfillnothing)
-            ENDIF
+            IF(idom /= jpdom_unknown )   CALL lbc_lnk('iom', pv_r2d,'Z',-999., kfillmode = jpfillnothing)
          ELSEIF( PRESENT(pv_r1d) ) THEN
-            pv_r1d(:) = 0.
-            if(lwp) write(numout,*) 'XIOS RST READ (1D): ', trim(cdvar)
+            IF(lwp) WRITE(numout,*) 'XIOS RST READ (1D): ', TRIM(cdvar)
             CALL xios_recv_field( trim(cdvar), pv_r1d)
          ENDIF
@@ -2036,9 +1908,15 @@
       CHARACTER(LEN=*)            , INTENT(in) ::   cdname
       REAL(sp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
-#if defined key_iomput
-      CALL xios_send_field(cdname, pfield2d)
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield2d, dim=1) == jpi .AND. SIZE(pfield2d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield2d(Nis0:Nie0, Njs0:Nje0) )       ! this extraction will create a copy of pfield2d
+         ELSE
+            CALL xios_send_field( cdname, pfield2d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield2d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p2d_sp
 
@@ -2046,9 +1924,15 @@
       CHARACTER(LEN=*)            , INTENT(in) ::   cdname
       REAL(dp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
-#if defined key_iomput
-      CALL xios_send_field(cdname, pfield2d)
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield2d, dim=1) == jpi .AND. SIZE(pfield2d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield2d(Nis0:Nie0, Njs0:Nje0) )       ! this extraction will create a copy of pfield2d
+         ELSE
+            CALL xios_send_field( cdname, pfield2d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield2d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p2d_dp
 
@@ -2056,9 +1940,15 @@
       CHARACTER(LEN=*)                , INTENT(in) ::   cdname
       REAL(sp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
-#if defined key_iomput
-      CALL xios_send_field( cdname, pfield3d )
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield3d, dim=1) == jpi .AND. SIZE(pfield3d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield3d(Nis0:Nie0, Njs0:Nje0,:) )     ! this extraction will create a copy of pfield3d
+         ELSE
+            CALL xios_send_field( cdname, pfield3d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield3d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p3d_sp
 
@@ -2066,9 +1956,15 @@
       CHARACTER(LEN=*)                , INTENT(in) ::   cdname
       REAL(dp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
-#if defined key_iomput
-      CALL xios_send_field( cdname, pfield3d )
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield3d, dim=1) == jpi .AND. SIZE(pfield3d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield3d(Nis0:Nie0, Njs0:Nje0,:) )     ! this extraction will create a copy of pfield3d
+         ELSE
+            CALL xios_send_field( cdname, pfield3d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield3d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p3d_dp
 
@@ -2076,9 +1972,15 @@
       CHARACTER(LEN=*)                , INTENT(in) ::   cdname
       REAL(sp),       DIMENSION(:,:,:,:), INTENT(in) ::   pfield4d
-#if defined key_iomput
-      CALL xios_send_field(cdname, pfield4d)
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield4d, dim=1) == jpi .AND. SIZE(pfield4d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield4d(Nis0:Nie0, Njs0:Nje0,:,:) )   ! this extraction will create a copy of pfield4d
+         ELSE
+            CALL xios_send_field (cdname, pfield4d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield4d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield4d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p4d_sp
 
@@ -2086,9 +1988,15 @@
       CHARACTER(LEN=*)                , INTENT(in) ::   cdname
       REAL(dp),       DIMENSION(:,:,:,:), INTENT(in) ::   pfield4d
-#if defined key_iomput
-      CALL xios_send_field(cdname, pfield4d)
+      IF( iom_use(cdname) ) THEN
+#if defined key_iomput
+         IF( SIZE(pfield4d, dim=1) == jpi .AND. SIZE(pfield4d, dim=2) == jpj ) THEN
+            CALL xios_send_field( cdname, pfield4d(Nis0:Nie0, Njs0:Nje0,:,:) )   ! this extraction will create a copy of pfield4d
+         ELSE
+            CALL xios_send_field (cdname, pfield4d )
+         ENDIF
 #else
-      IF( .FALSE. )   WRITE(numout,*) cdname, pfield4d   ! useless test to avoid compilation warnings
-#endif
+         WRITE(numout,*) pfield4d   ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings
+#endif
+      ENDIF
    END SUBROUTINE iom_p4d_dp
 
@@ -2287,18 +2195,14 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
       !
-      INTEGER  :: ni, nj
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
       LOGICAL, INTENT(IN) :: ldxios, ldrxios
       !!----------------------------------------------------------------------
       !
-      ni = nlei-nldi+1
-      nj = nlej-nldj+1
-      !
-      CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj)
-      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
+      CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=Ni0glo,nj_glo=Nj0glo,ibegin=mig0(Nis0)-1,jbegin=mjg0(Njs0)-1,ni=Ni_0,nj=Nj_0)
+      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 0, data_ni = Ni_0, data_jbegin = 0, data_nj = Nj_0)
 !don't define lon and lat for restart reading context. 
       IF ( .NOT.ldrxios ) &
-         CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = real(RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)), dp),   &
-         &                                     latvalue = real(RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)),dp ) )  
+         CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = real(RESHAPE(plon(Nis0:Nie0, Njs0:Nje0),(/ Ni_0*Nj_0 /)),dp),   &
+         &                                        latvalue = real(RESHAPE(plat(Nis0:Nie0, Njs0:Nje0),(/ Ni_0*Nj_0 /)),dp ))  
       !
       IF ( ln_mskland .AND. (.NOT.ldxios) ) THEN
@@ -2306,15 +2210,14 @@
          SELECT CASE ( cdgrd )
          CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
-         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( 'iom', zmask, 'U', 1.0_wp )
-         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( 'iom', zmask, 'V', 1.0_wp )
+         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)
+         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)
          CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
          END SELECT
          !
-         CALL iom_set_domain_attr( "grid_"//cdgrd       , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni*nj    /)) /= 0. )
-         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. )
+         CALL iom_set_domain_attr( "grid_"//cdgrd       , mask = RESHAPE(zmask(Nis0:Nie0,Njs0:Nje0,1),(/Ni_0*Nj_0    /)) /= 0. )
+         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(Nis0:Nie0,Njs0:Nje0,:),(/Ni_0,Nj_0,jpk/)) /= 0. )
       ENDIF
       !
    END SUBROUTINE set_grid
-
 
    SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt )
@@ -2329,7 +2232,9 @@
       REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coord. of the point of cell (i,j)
       !
-      INTEGER :: ji, jj, jn, ni, nj
+      INTEGER :: ji, jj, jn
       INTEGER :: icnr, jcnr                             ! Offset such that the vertex coordinate (i+icnr,j+jcnr)
-      !                                                 ! represents the bottom-left corner of cell (i,j)
+      !                                                 ! represents the
+      !                                                 bottom-left corner of
+      !                                                 cell (i,j)
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j)
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_fld       ! Working array to determine where to rotate cells
@@ -2346,81 +2251,34 @@
       END SELECT
       !
-      ni = nlei-nldi+1   ! Dimensions of subdomain interior
-      nj = nlej-nldj+1
-      !
       z_fld(:,:) = 1._wp
       CALL lbc_lnk( 'iom', z_fld, cdgrd, -1.0_wp )    ! Working array for location of northfold
       !
       ! Cell vertices that can be defined
-      DO jj = 2, jpjm1
-         DO ji = 2, jpim1
-            z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
-            z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
-            z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
-            z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
-            z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
-            z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
-            z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
-            z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
-         END DO
-      END DO
-      !
-      ! Cell vertices on boundries
-      DO jn = 1, 4
-         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1.0_wp, pfillval=999._wp )
-         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1.0_wp, pfillval=999._wp )
-      END DO
-      !
-      ! Zero-size cells at closed boundaries if cell points provided,
-      ! otherwise they are closed cells with unrealistic bounds
-      IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN
-         IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN
-            DO jn = 1, 4        ! (West or jpni = 1), closed E-W
-               z_bnds(jn,1,:,1) = plat_pnt(1,:)  ;  z_bnds(jn,1,:,2) = plon_pnt(1,:)
-            END DO
-         ENDIF
-         IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN
-            DO jn = 1, 4        ! (East or jpni = 1), closed E-W
-               z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:)  ;  z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:)
-            END DO
-         ENDIF
-         IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN
-            DO jn = 1, 4        ! South or (jpnj = 1, not symmetric)
-               z_bnds(jn,:,1,1) = plat_pnt(:,1)  ;  z_bnds(jn,:,1,2) = plon_pnt(:,1)
-            END DO
-         ENDIF
-         IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio  < 3 ) THEN
-            DO jn = 1, 4        ! (North or jpnj = 1), no north fold
-               z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj)  ;  z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj)
-            END DO
-         ENDIF
-      ENDIF
-      !
-      IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN    ! Rotate cells at the north fold
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( z_fld(ji,jj) == -1. ) THEN
-                  z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:)
-                  z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:)
-                  z_bnds(:,ji,jj,:) = z_rot(:,:)
-               ENDIF
-            END DO
-         END DO
-      ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN                  ! Invert cells at the symmetric equator
-         DO ji = 1, jpi
-            z_rot(1:2,:) = z_bnds(3:4,ji,1,:)
-            z_rot(3:4,:) = z_bnds(1:2,ji,1,:)
-            z_bnds(:,ji,1,:) = z_rot(:,:)
-         END DO
-      ENDIF
-      !
-      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat =real( RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)), dp),           &
-          &                                    bounds_lon =real( RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), dp), nvertex=4 )
-      !
-      DEALLOCATE( z_bnds, z_fld, z_rot ) 
+      DO_2D_00_00
+         z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
+         z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
+         z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
+         z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
+         z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
+         z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
+         z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
+         z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
+      END_2D
+      !
+      DO_2D_00_00
+         IF( z_fld(ji,jj) == -1. ) THEN
+            z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:)
+            z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:)
+            z_bnds(:,ji,jj,:) = z_rot(:,:)
+         ENDIF
+      END_2D
+      !
+      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = real(RESHAPE(z_bnds(:,Nis0:Nie0,Njs0:Nje0,1),(/ 4,Ni_0*Nj_0 /)), dp),           &
+          &                                    bounds_lon = real(RESHAPE(z_bnds(:,Nis0:Nie0,Njs0:Nje0,2),(/ 4,Ni_0*Nj_0 /)), dp), nvertex=4 )
+      !
+      DEALLOCATE( z_bnds, z_fld, z_rot )
       !
    END SUBROUTINE set_grid_bounds
 
-
    SUBROUTINE set_grid_znl( plat )
       !!----------------------------------------------------------------------
@@ -2432,19 +2290,17 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
       !
-      INTEGER  :: ni, nj, ix, iy
+      INTEGER  :: ix, iy
       REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon
       !!----------------------------------------------------------------------
       !
-      ni=nlei-nldi+1       ! define zonal mean domain (jpj*jpk)
-      nj=nlej-nldj+1
-      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0._wp
+      ALLOCATE( zlon(Ni_0*Nj_0) )       ;       zlon(:) = 0._wp
       !
 !      CALL dom_ngb( -168.53_wp, 65.03_wp, ix, iy, 'T' ) !  i-line that passes through Bering Strait: Reference latitude (used in plots)
       CALL dom_ngb( 180.0_wp, 90.0_wp, ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots)
-      CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj)
-      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
+      CALL iom_set_domain_attr("gznl", ni_glo=Ni0glo, nj_glo=Nj0glo, ibegin=mig0(Nis0)-1, jbegin=mjg0(Njs0)-1, ni=Ni_0, nj=Nj_0)
+      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 0, data_ni = Ni_0, data_jbegin = 0, data_nj = Nj_0)
       CALL iom_set_domain_attr("gznl", lonvalue = real(zlon, dp),   &
-         &                             latvalue = real(RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)),dp))  
-      CALL iom_set_zoom_domain_attr("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo)
+         &                             latvalue = real(RESHAPE(plat(Nis0:Nie0, Njs0:Nje0),(/ Ni_0*Nj_0 /)),dp))  
+      CALL iom_set_zoom_domain_attr("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=Nj_0)
       !
       CALL iom_update_file_name('ptr')
@@ -2523,5 +2379,5 @@
          ! Equatorial section (attributs: jbegin, ni, name_suffix)
          CALL dom_ngb( 0.0_wp, 0.0_wp, ix, iy, cl1 )
-         CALL iom_set_zoom_domain_attr('Eq'//cl1, ibegin=0, jbegin=iy-1, ni=jpiglo, nj=1 )
+         CALL iom_set_zoom_domain_attr('Eq'//cl1, ibegin=0, jbegin=iy-1, ni=Ni0glo, nj=1 )
          CALL iom_get_file_attr   ('Eq'//cl1, name_suffix = clsuff             )
          CALL iom_set_file_attr   ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq')
Index: NEMO/trunk/src/OCE/IOM/iom_def.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 13286)
@@ -13,14 +13,9 @@
    PRIVATE
 
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_data          = 1   !: ( 1  :jpiglo, 1  :jpjglo)    !!gm to be suppressed
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_global        = 2   !: ( 1  :jpiglo, 1  :jpjglo)
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_local         = 3   !: One of the 3 following cases
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_full    = 4   !: ( 1  :jpi   , 1  :jpi   )
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noextra = 5   !: ( 1  :nlci  , 1  :nlcj  )
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noovlap = 6   !: (nldi:nlei  ,nldj:nlej  )
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 7   !: No dimension checking
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo       = 8   !: 
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only
-   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !: 
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_global        = 1   !: ( 1  :Ni0glo, 1  :Nj0glo)
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_local         = 2   !: (Nis0: Nie0 ,Njs0: Nje0 )
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 3   !: No dimension checking
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_auto          = 4   !: 
+   INTEGER, PARAMETER, PUBLIC ::   jpdom_auto_xy       = 5   !: Automatically set horizontal dimensions only
 
    INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
@@ -35,5 +30,4 @@
    INTEGER, PARAMETER, PUBLIC ::   jpmax_digits =  9   !: maximum number of digits for the cpu number in the file name
 
-
 !$AGRIF_DO_NOT_TREAT
    INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
@@ -45,6 +39,4 @@
    LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
    LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
-
-
 
    TYPE, PUBLIC ::   file_descriptor
Index: NEMO/trunk/src/OCE/IOM/iom_nf90.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 13286)
@@ -47,5 +47,5 @@
 CONTAINS
 
-   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar, kdlev, cdcomp )
+   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdlev, cdcomp )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -57,5 +57,4 @@
       LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file?
       LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence 
-      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
       INTEGER                , INTENT(in   ), OPTIONAL ::   kdlev       ! size of the ice/abl third dimension
       CHARACTER(len=3)       , INTENT(in   ), OPTIONAL ::   cdcomp      ! name of component calling iom_nf90_open
@@ -134,25 +133,25 @@
             CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL,                   idmy ), clinfo)
             ! define dimensions
-                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo)
-                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo)
+                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',  Ni_0, idmy ), clinfo)
+                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',  Nj_0, idmy ), clinfo)
             SELECT CASE (clcomp)
-            CASE ('OCE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',            jpk, idmy ), clinfo)
-            CASE ('ICE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numcat',          kdlev, idmy ), clinfo)
-            CASE ('ABL')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',          kdlev, idmy ), clinfo)
-            CASE ('SED')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numsed',          kdlev, idmy ), clinfo)
+            CASE ('OCE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',   jpk, idmy ), clinfo)
+            CASE ('ICE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numcat', kdlev, idmy ), clinfo)
+            CASE ('ABL')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev', kdlev, idmy ), clinfo)
+            CASE ('SED')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numsed', kdlev, idmy ), clinfo)
             CASE DEFAULT   ;   CALL ctl_stop( 'iom_nf90_open unknown component type' )
             END SELECT
                                CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
             ! global attributes
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_local'     , kdompar(:,1)       ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_first' , kdompar(:,2)       ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_last'  , kdompar(:,3)       ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_start', kdompar(:,4)       ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , kdompar(:,5)       ), clinfo)
-            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij                        ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number'         , narea-1                      ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/ 1        , 2           /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_global'    , (/ Ni0glo    , Nj0glo     /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_size_local'     , (/ Ni_0      , Nj_0       /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_first' , (/ mig0(Nis0), mjg0(Njs0) /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_position_last'  , (/ mig0(Nie0), mjg0(Nje0) /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/ 0         , 0          /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/ 0         , 0          /) ), clinfo)
+            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'                        ), clinfo)
          ELSE                          !* the file should be open for read mode so it must exist...
             CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' )
@@ -672,9 +671,9 @@
          IF( PRESENT(pv_r2d) .OR. PRESENT(pv_r3d) ) THEN
             idimsz(1:2) = iom_file(kiomid)%dimsz(1:2,idvar)
-            IF(     idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN
-               ix1 = nldi   ;   ix2 = nlei   ;   iy1 = nldj   ;   iy2 = nlej
-            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN
-               ix1 = 1      ;   ix2 = nlci   ;   iy1 = 1      ;   iy2 = nlcj
-            ELSEIF( idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN
+            IF(     idimsz(1) == Ni_0 .AND. idimsz(2) == Nj_0 ) THEN
+               ix1 = Nis0   ;   ix2 = Nie0   ;   iy1 = Njs0   ;   iy2 = Nje0
+            ELSEIF( idimsz(1) == jpi  .AND. idimsz(2) == jpj  ) THEN
+               ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
+            ELSEIF( idimsz(1) == jpi  .AND. idimsz(2) == jpj  ) THEN
                ix1 = 1      ;   ix2 = jpi    ;   iy1 = 1      ;   iy2 = jpj
             ELSE 
Index: NEMO/trunk/src/OCE/IOM/prtctl.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/prtctl.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/prtctl.F90	(revision 13286)
@@ -8,29 +8,21 @@
    !!----------------------------------------------------------------------
    USE dom_oce          ! ocean space and time domain variables
-#if defined key_nemocice_decomp
-   USE ice_domain_size, only: nx_global, ny_global
-#endif
    USE in_out_manager   ! I/O manager
+   USE mppini           ! distributed memory computing
    USE lib_mpp          ! distributed memory computing
 
    IMPLICIT NONE
    PRIVATE
-
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   numid
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   nlditl , nldjtl    ! first, last indoor index for each i-domain
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   nleitl , nlejtl    ! first, last indoor index for each j-domain
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   nimpptl, njmpptl   ! i-, j-indexes for each processor
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   nlcitl , nlcjtl    ! dimensions of every subdomain
-   INTEGER , DIMENSION(:), ALLOCATABLE, SAVE ::   ibonitl, ibonjtl   !
-
-   REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE ::   t_ctll , s_ctll    ! previous tracer trend values
-   REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE ::   u_ctll , v_ctll    ! previous velocity trend values
-
-   INTEGER ::   ktime   ! time step
-
+   
+   INTEGER , DIMENSION(  :), ALLOCATABLE ::   numprt_oce, numprt_top
+   INTEGER , DIMENSION(  :), ALLOCATABLE ::   nall_ictls, nall_ictle   ! first, last indoor index for each i-domain
+   INTEGER , DIMENSION(  :), ALLOCATABLE ::   nall_jctls, nall_jctle   ! first, last indoor index for each j-domain
+   REAL(wp), DIMENSION(  :), ALLOCATABLE ::   t_ctl , s_ctl            ! previous tracer trend values
+   REAL(wp), DIMENSION(  :), ALLOCATABLE ::   u_ctl , v_ctl            ! previous velocity trend values
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   tra_ctl                  ! previous top trend values
+   !                                          
    PUBLIC prt_ctl         ! called by all subroutines
    PUBLIC prt_ctl_info    ! called by all subroutines
-   PUBLIC prt_ctl_init    ! called by opa.F90
-   PUBLIC sub_dom         ! called by opa.F90
+   PUBLIC prt_ctl_init    ! called by nemogcm.F90 and prt_ctl_trc_init
 
    !!----------------------------------------------------------------------
@@ -41,6 +33,6 @@
 CONTAINS
 
-   SUBROUTINE prt_ctl (tab2d_1, tab3d_1, mask1, clinfo1, tab2d_2, tab3d_2,   &
-      &                                  mask2, clinfo2, kdim, clinfo3 )
+   SUBROUTINE prt_ctl (tab2d_1, tab3d_1, tab4d_1, tab2d_2, tab3d_2, mask1, mask2,   &
+      &                 clinfo, clinfo1, clinfo2, clinfo3, kdim )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE prt_ctl  ***
@@ -68,4 +60,5 @@
       !!                    tab2d_1 : first 2D array
       !!                    tab3d_1 : first 3D array
+      !!                    tab4d_1 : first 4D array
       !!                    mask1   : mask (3D) to apply to the tab[23]d_1 array
       !!                    clinfo1 : information about the tab[23]d_1 array
@@ -77,508 +70,360 @@
       !!                    clinfo3 : additional information 
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL ::   tab2d_1
-      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL ::   tab3d_1
-      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL ::   mask1
-      CHARACTER (len=*)         , INTENT(in), OPTIONAL ::   clinfo1
-      REAL(wp), DIMENSION(:,:)  , INTENT(in), OPTIONAL ::   tab2d_2
-      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL ::   tab3d_2
-      REAL(wp), DIMENSION(:,:,:), INTENT(in), OPTIONAL ::   mask2
-      CHARACTER (len=*)         , INTENT(in), OPTIONAL ::   clinfo2
-      INTEGER                   , INTENT(in), OPTIONAL ::   kdim
-      CHARACTER (len=*)         , INTENT(in), OPTIONAL ::   clinfo3
-      !
-      CHARACTER (len=15) :: cl2
-      INTEGER ::  jn, sind, eind, kdir,j_id
+      REAL(wp),         DIMENSION(:,:)    , INTENT(in), OPTIONAL ::   tab2d_1
+      REAL(wp),         DIMENSION(:,:,:)  , INTENT(in), OPTIONAL ::   tab3d_1
+      REAL(wp),         DIMENSION(:,:,:,:), INTENT(in), OPTIONAL ::   tab4d_1
+      REAL(wp),         DIMENSION(:,:)    , INTENT(in), OPTIONAL ::   tab2d_2
+      REAL(wp),         DIMENSION(:,:,:)  , INTENT(in), OPTIONAL ::   tab3d_2
+      REAL(wp),         DIMENSION(:,:,:)  , INTENT(in), OPTIONAL ::   mask1
+      REAL(wp),         DIMENSION(:,:,:)  , INTENT(in), OPTIONAL ::   mask2
+      CHARACTER(len=*), DIMENSION(:)      , INTENT(in), OPTIONAL ::   clinfo    ! information about the tab3d array
+      CHARACTER(len=*)                    , INTENT(in), OPTIONAL ::   clinfo1
+      CHARACTER(len=*)                    , INTENT(in), OPTIONAL ::   clinfo2
+      CHARACTER(len=*)                    , INTENT(in), OPTIONAL ::   clinfo3
+      INTEGER                             , INTENT(in), OPTIONAL ::   kdim
+      !
+      CHARACTER(len=30) :: cl1, cl2
+      INTEGER ::  jn, jl, kdir
+      INTEGER ::  iis, iie, jjs, jje
+      INTEGER ::  itra, inum
       REAL(wp) :: zsum1, zsum2, zvctl1, zvctl2
-      REAL(wp), DIMENSION(jpi,jpj)     :: ztab2d_1, ztab2d_2
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask1, zmask2, ztab3d_1, ztab3d_2
-      !!----------------------------------------------------------------------
-
+      !!----------------------------------------------------------------------
+      !
       ! Arrays, scalars initialization 
-      kdir      = jpkm1
-      cl2       = ''
-      zsum1     = 0.e0
-      zsum2     = 0.e0
-      zvctl1    = 0.e0
-      zvctl2    = 0.e0
-      ztab2d_1(:,:)   = 0.e0
-      ztab2d_2(:,:)   = 0.e0
-      ztab3d_1(:,:,:) = 0.e0
-      ztab3d_2(:,:,:) = 0.e0
-      zmask1  (:,:,:) = 1.e0
-      zmask2  (:,:,:) = 1.e0
+      cl1  = ''
+      cl2  = ''
+      kdir = jpkm1
+      itra = 1
 
       ! Control of optional arguments
-      IF( PRESENT(clinfo2) )   cl2                  = clinfo2
-      IF( PRESENT(kdim)    )   kdir                 = kdim
-      IF( PRESENT(tab2d_1) )   ztab2d_1(:,:)        = tab2d_1(:,:)
-      IF( PRESENT(tab2d_2) )   ztab2d_2(:,:)        = tab2d_2(:,:)
-      IF( PRESENT(tab3d_1) )   ztab3d_1(:,:,1:kdir) = tab3d_1(:,:,1:kdir)
-      IF( PRESENT(tab3d_2) )   ztab3d_2(:,:,1:kdir) = tab3d_2(:,:,1:kdir)
-      IF( PRESENT(mask1)   )   zmask1  (:,:,:)      = mask1  (:,:,:)
-      IF( PRESENT(mask2)   )   zmask2  (:,:,:)      = mask2  (:,:,:)
-
-      IF( lk_mpp .AND. jpnij > 1 ) THEN       ! processor number
-         sind = narea
-         eind = narea
-      ELSE                                    ! processors total number
-         sind = 1
-         eind = ijsplt
-      ENDIF
+      IF( PRESENT(clinfo1) )   cl1  = clinfo1
+      IF( PRESENT(clinfo2) )   cl2  = clinfo2
+      IF( PRESENT(kdim)    )   kdir = kdim
+      IF( PRESENT(tab4d_1) )   itra = SIZE(tab4d_1,dim=4)
 
       ! Loop over each sub-domain, i.e. the total number of processors ijsplt
-      DO jn = sind, eind
-         ! Set logical unit
-         j_id = numid(jn - narea + 1)
-         ! Set indices for the SUM control
-         IF( .NOT. lsp_area ) THEN
-            IF (lk_mpp .AND. jpnij > 1)   THEN
-               nictls = MAX(  1, nlditl(jn) )
-               nictle = MIN(jpi, nleitl(jn) )
-               njctls = MAX(  1, nldjtl(jn) )
-               njctle = MIN(jpj, nlejtl(jn) )
-               ! Do not take into account the bound of the domain
-               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
-               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
-               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nleitl(jn) - 1)
-               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, nlejtl(jn) - 1)
+      DO jl = 1, SIZE(nall_ictls)
+
+         ! define shoter names...
+         iis = nall_ictls(jl)
+         iie = nall_ictle(jl)
+         jjs = nall_jctls(jl)
+         jje = nall_jctle(jl)
+
+         IF( PRESENT(clinfo) ) THEN   ;   inum = numprt_top(jl)
+         ELSE                         ;   inum = numprt_oce(jl)
+         ENDIF
+
+         DO jn = 1, itra
+
+            IF( PRESENT(clinfo3) ) THEN
+               IF    ( clinfo3 == 'tra-ta' )   THEN
+                  zvctl1 = t_ctl(jl)
+               ELSEIF( clinfo3 == 'tra'    )   THEN
+                  zvctl1 = t_ctl(jl)
+                  zvctl2 = s_ctl(jl)
+               ELSEIF( clinfo3 == 'dyn'    )   THEN
+                  zvctl1 = u_ctl(jl)
+                  zvctl2 = v_ctl(jl)
+               ELSE
+                  zvctl1 = tra_ctl(jn,jl)
+               ENDIF
+            ENDIF
+
+            ! 2D arrays
+            IF( PRESENT(tab2d_1) ) THEN
+               IF( PRESENT(mask1) ) THEN   ;   zsum1 = SUM( tab2d_1(iis:iie,jjs:jje) * mask1(iis:iie,jjs:jje,1) )
+               ELSE                        ;   zsum1 = SUM( tab2d_1(iis:iie,jjs:jje)                            )
+               ENDIF
+            ENDIF
+            IF( PRESENT(tab2d_2) ) THEN
+               IF( PRESENT(mask2) ) THEN   ;   zsum2 = SUM( tab2d_2(iis:iie,jjs:jje) * mask2(iis:iie,jjs:jje,1) )
+               ELSE                        ;   zsum2 = SUM( tab2d_2(iis:iie,jjs:jje)                            )
+               ENDIF
+            ENDIF
+
+            ! 3D arrays
+            IF( PRESENT(tab3d_1) ) THEN
+               IF( PRESENT(mask1) ) THEN   ;   zsum1 = SUM( tab3d_1(iis:iie,jjs:jje,1:kdir) * mask1(iis:iie,jjs:jje,1:kdir) )
+               ELSE                        ;   zsum1 = SUM( tab3d_1(iis:iie,jjs:jje,1:kdir)                                 )
+               ENDIF
+            ENDIF
+            IF( PRESENT(tab3d_2) ) THEN
+               IF( PRESENT(mask2) ) THEN   ;   zsum2 = SUM( tab3d_2(iis:iie,jjs:jje,1:kdir) * mask2(iis:iie,jjs:jje,1:kdir) )
+               ELSE                        ;   zsum2 = SUM( tab3d_2(iis:iie,jjs:jje,1:kdir)                                 )
+               ENDIF
+            ENDIF
+
+            ! 4D arrays
+            IF( PRESENT(tab4d_1) ) THEN
+               IF( PRESENT(mask1) ) THEN   ;   zsum1 = SUM( tab4d_1(iis:iie,jjs:jje,1:kdir,jn) * mask1(iis:iie,jjs:jje,1:kdir) )
+               ELSE                        ;   zsum1 = SUM( tab4d_1(iis:iie,jjs:jje,1:kdir,jn)                                 )
+               ENDIF
+            ENDIF
+
+            ! Print the result
+            IF( PRESENT(clinfo ) )   cl1  = clinfo(jn)
+            IF( PRESENT(clinfo3) )   THEN
+               !
+               IF( PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) ) THEN
+                  WRITE(inum, "(3x,a,' : ',D23.16,3x,a,' : ',D23.16)") cl1, zsum1 - zvctl1, cl2, zsum2 - zvctl2
+               ELSE
+                  WRITE(inum, "(3x,a,' : ',D23.16                  )") cl1, zsum1 - zvctl1
+               ENDIF
+               !
+               SELECT CASE( clinfo3 )
+               CASE ( 'tra-ta' ) 
+                  t_ctl(jl) = zsum1
+               CASE ( 'tra' ) 
+                  t_ctl(jl) = zsum1
+                  s_ctl(jl) = zsum2
+               CASE ( 'dyn' ) 
+                  u_ctl(jl) = zsum1
+                  v_ctl(jl) = zsum2
+               CASE default
+                  tra_ctl(jn,jl) = zsum1
+               END SELECT
+            ELSEIF ( PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) )   THEN
+               WRITE(inum, "(3x,a,' : ',D23.16,3x,a,' : ',D23.16)") cl1, zsum1, cl2, zsum2
             ELSE
-               nictls = MAX(  1, nimpptl(jn) - 1 + nlditl(jn) )
-               nictle = MIN(jpi, nimpptl(jn) - 1 + nleitl(jn) )
-               njctls = MAX(  1, njmpptl(jn) - 1 + nldjtl(jn) )
-               njctle = MIN(jpj, njmpptl(jn) - 1 + nlejtl(jn) )
-               ! Do not take into account the bound of the domain
-               IF( ibonitl(jn) == -1 .OR. ibonitl(jn) == 2 ) nictls = MAX(2, nictls)
-               IF( ibonjtl(jn) == -1 .OR. ibonjtl(jn) == 2 ) njctls = MAX(2, njctls)
-               IF( ibonitl(jn) ==  1 .OR. ibonitl(jn) == 2 ) nictle = MIN(nictle, nimpptl(jn) + nleitl(jn) - 2)
-               IF( ibonjtl(jn) ==  1 .OR. ibonjtl(jn) == 2 ) njctle = MIN(njctle, njmpptl(jn) + nlejtl(jn) - 2)
-            ENDIF
-         ENDIF
-
-         IF( PRESENT(clinfo3)) THEN
-            IF ( clinfo3 == 'tra' )  THEN
-               zvctl1 = t_ctll(jn)
-               zvctl2 = s_ctll(jn)
-            ELSEIF ( clinfo3 == 'dyn' )   THEN
-               zvctl1 = u_ctll(jn)
-               zvctl2 = v_ctll(jn)
-            ENDIF
-         ENDIF
-
-         ! Compute the sum control
-         ! 2D arrays
-         IF( PRESENT(tab2d_1) )   THEN
-            zsum1 = SUM( ztab2d_1(nictls:nictle,njctls:njctle)*zmask1(nictls:nictle,njctls:njctle,1) )
-            zsum2 = SUM( ztab2d_2(nictls:nictle,njctls:njctle)*zmask2(nictls:nictle,njctls:njctle,1) )
-         ENDIF
-
-         ! 3D arrays
-         IF( PRESENT(tab3d_1) )   THEN
-            zsum1 = SUM( ztab3d_1(nictls:nictle,njctls:njctle,1:kdir)*zmask1(nictls:nictle,njctls:njctle,1:kdir) )
-            zsum2 = SUM( ztab3d_2(nictls:nictle,njctls:njctle,1:kdir)*zmask2(nictls:nictle,njctls:njctle,1:kdir) )
-         ENDIF
-
-         ! Print the result
-         IF( PRESENT(clinfo3) )   THEN
-            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1-zvctl1, cl2, zsum2-zvctl2
-            SELECT CASE( clinfo3 )
-            CASE ( 'tra-ta' ) 
-               t_ctll(jn) = zsum1
-            CASE ( 'tra' ) 
-                t_ctll(jn) = zsum1
-                s_ctll(jn) = zsum2
-            CASE ( 'dyn' ) 
-                u_ctll(jn) = zsum1
-                v_ctll(jn) = zsum2 
-            END SELECT
-         ELSEIF ( PRESENT(clinfo2) .OR. PRESENT(tab2d_2) .OR. PRESENT(tab3d_2) )   THEN
-            WRITE(j_id,FMT='(a,D23.16,3x,a,D23.16)')clinfo1, zsum1, cl2, zsum2
-         ELSE
-            WRITE(j_id,FMT='(a,D23.16)')clinfo1, zsum1
-         ENDIF
-
-      ENDDO
-      !
-   END SUBROUTINE prt_ctl
-
-
-   SUBROUTINE prt_ctl_info (clinfo1, ivar1, clinfo2, ivar2, itime)
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE prt_ctl_info  ***
-      !!
-      !! ** Purpose : - print information without any computation
-      !!
-      !! ** Action  : - input arguments
-      !!                    clinfo1 : information about the ivar1
-      !!                    ivar1   : value to print
-      !!                    clinfo2 : information about the ivar2
-      !!                    ivar2   : value to print
-      !!----------------------------------------------------------------------
-      CHARACTER (len=*), INTENT(in)           ::   clinfo1
-      INTEGER          , INTENT(in), OPTIONAL ::   ivar1
-      CHARACTER (len=*), INTENT(in), OPTIONAL ::   clinfo2
-      INTEGER          , INTENT(in), OPTIONAL ::   ivar2
-      INTEGER          , INTENT(in), OPTIONAL ::   itime
-      !
-      INTEGER :: jn, sind, eind, iltime, j_id
-      !!----------------------------------------------------------------------
-
-      IF( lk_mpp .AND. jpnij > 1 ) THEN       ! processor number
-         sind = narea
-         eind = narea
-      ELSE                                    ! total number of processors
-         sind = 1
-         eind = ijsplt
-      ENDIF
-
-      ! Set to zero arrays at each new time step
-      IF( PRESENT(itime) )   THEN
-         iltime = itime
-         IF( iltime > ktime )   THEN
-            t_ctll(:) = 0.e0   ;   s_ctll(:) = 0.e0
-            u_ctll(:) = 0.e0   ;   v_ctll(:) = 0.e0
-            ktime = iltime
-         ENDIF
-      ENDIF
-
-      ! Loop over each sub-domain, i.e. number of processors ijsplt
-      DO jn = sind, eind
-         !
-         j_id = numid(jn - narea + 1)         ! Set logical unit
-         !
-         IF( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
-            WRITE(j_id,*)clinfo1, ivar1, clinfo2, ivar2
-         ELSEIF ( PRESENT(ivar1) .AND. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
-            WRITE(j_id,*)clinfo1, ivar1, clinfo2
-         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. PRESENT(ivar2) )   THEN
-            WRITE(j_id,*)clinfo1, ivar1, ivar2
-         ELSEIF ( PRESENT(ivar1) .AND. .NOT. PRESENT(clinfo2) .AND. .NOT. PRESENT(ivar2) )   THEN
-            WRITE(j_id,*)clinfo1, ivar1
-         ELSE
-            WRITE(j_id,*)clinfo1
-         ENDIF
-         !
-      END DO
-      !
-   END SUBROUTINE prt_ctl_info
-
-
-   SUBROUTINE prt_ctl_init
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE prt_ctl_init  ***
-      !!
-      !! ** Purpose :   open ASCII files & compute indices
-      !!----------------------------------------------------------------------
-      INTEGER ::   jn, sind, eind, j_id
-      CHARACTER (len=28) :: clfile_out
-      CHARACTER (len=23) :: clb_name
-      CHARACTER (len=19) :: cl_run
-      !!----------------------------------------------------------------------
-
-      ! Allocate arrays
-      ALLOCATE( nlditl(ijsplt) , nleitl(ijsplt) , nimpptl(ijsplt) , ibonitl(ijsplt) ,   &
-         &      nldjtl(ijsplt) , nlejtl(ijsplt) , njmpptl(ijsplt) , ibonjtl(ijsplt) ,   &
-         &      nlcitl(ijsplt) , t_ctll(ijsplt) , u_ctll (ijsplt) ,                     &
-         &      nlcjtl(ijsplt) , s_ctll(ijsplt) , v_ctll (ijsplt)                       )
-
-      ! Initialization 
-      t_ctll(:) = 0.e0
-      s_ctll(:) = 0.e0
-      u_ctll(:) = 0.e0
-      v_ctll(:) = 0.e0
-      ktime = 1
-
-      IF( lk_mpp .AND. jpnij > 1 ) THEN
-         sind = narea
-         eind = narea
-         clb_name = "('mpp.output_',I4.4)"
-         cl_run = 'MULTI processor run'
-         ! use indices for each area computed by mpp_init subroutine
-         nlditl(1:jpnij) = nldit(:) 
-         nleitl(1:jpnij) = nleit(:) 
-         nldjtl(1:jpnij) = nldjt(:) 
-         nlejtl(1:jpnij) = nlejt(:) 
-         !
-         nimpptl(1:jpnij) = nimppt(:)
-         njmpptl(1:jpnij) = njmppt(:)
-         !
-         nlcitl(1:jpnij) = nlcit(:)
-         nlcjtl(1:jpnij) = nlcjt(:)
-         !
-         ibonitl(1:jpnij) = ibonit(:)
-         ibonjtl(1:jpnij) = ibonjt(:)
-      ELSE
-         sind = 1
-         eind = ijsplt
-         clb_name = "('mono.output_',I4.4)"
-         cl_run = 'MONO processor run '
-         ! compute indices for each area as done in mpp_init subroutine
-         CALL sub_dom
-      ENDIF
-
-      ALLOCATE( numid(eind-sind+1) )
-
-      DO jn = sind, eind
-         WRITE(clfile_out,FMT=clb_name) jn-1
-         CALL ctl_opn( numid(jn -narea + 1), clfile_out, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', 1, numout, .FALSE. )
-         j_id = numid(jn -narea + 1)
-         WRITE(j_id,*)
-         WRITE(j_id,*) '                 L O D Y C - I P S L'
-         WRITE(j_id,*) '                     O P A model'
-         WRITE(j_id,*) '            Ocean General Circulation Model'
-         WRITE(j_id,*) '               version OPA 9.0  (2005) '
-         WRITE(j_id,*)
-         WRITE(j_id,*) '                   PROC number: ', jn
-         WRITE(j_id,*)
-         WRITE(j_id,FMT="(19x,a20)")cl_run
-
-         ! Print the SUM control indices
-         IF( .NOT. lsp_area )   THEN
-            nictls = nimpptl(jn) + nlditl(jn) - 1
-            nictle = nimpptl(jn) + nleitl(jn) - 1
-            njctls = njmpptl(jn) + nldjtl(jn) - 1
-            njctle = njmpptl(jn) + nlejtl(jn) - 1
-         ENDIF
-         WRITE(j_id,*) 
-         WRITE(j_id,*) 'prt_ctl :  Sum control indices'
-         WRITE(j_id,*) '~~~~~~~'
-         WRITE(j_id,*)
-         WRITE(j_id,9000)'                                nlej   = ', nlejtl(jn), '              '
-         WRITE(j_id,9000)'                  ------------- njctle = ', njctle, ' -------------'
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9002)'           nictls = ', nictls,  '                           nictle = ', nictle
-         WRITE(j_id,9002)'           nldi   = ', nlditl(jn),  '                           nlei   = ', nleitl(jn)
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9001)'                  |                                       |'
-         WRITE(j_id,9004)'  njmpp  = ',njmpptl(jn),'   ------------- njctls = ', njctls, ' -------------'
-         WRITE(j_id,9003)'           nimpp  = ', nimpptl(jn), '        nldj   = ', nldjtl(jn), '              '
-         WRITE(j_id,*)
-         WRITE(j_id,*)
-
-9000     FORMAT(a41,i4.4,a14)
-9001     FORMAT(a59)
-9002     FORMAT(a20,i4.4,a36,i3.3)
-9003     FORMAT(a20,i4.4,a17,i4.4)
-9004     FORMAT(a11,i4.4,a26,i4.4,a14)
-      END DO
-      !
-   END SUBROUTINE prt_ctl_init
-
-
-   SUBROUTINE sub_dom
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE sub_dom  ***
-      !!                    
-      !! ** Purpose :   Lay out the global domain over processors. 
-      !!                CAUTION: 
-      !!                This part has been extracted from the mpp_init
-      !!                subroutine and names of variables/arrays have been 
-      !!                slightly changed to avoid confusion but the computation
-      !!                is exactly the same. Any modification about indices of
-      !!                each sub-domain in the mppini.F90 module should be reported 
-      !!                here.
-      !!
-      !! ** Method  :   Global domain is distributed in smaller local domains.
-      !!                Periodic condition is a function of the local domain position
-      !!                (global boundary or neighbouring domain) and of the global
-      !!                periodic
-      !!                Type :         jperio global periodic condition
-      !!
-      !! ** Action  : - set domain parameters
-      !!                    nimpp     : longitudinal index 
-      !!                    njmpp     : latitudinal  index
-      !!                    narea     : number for local area
-      !!                    nlcil      : first dimension
-      !!                    nlcjl      : second dimension
-      !!                    nbondil    : mark for "east-west local boundary"
-      !!                    nbondjl    : mark for "north-south local boundary"
-      !!
-      !! History :
-      !!        !  94-11  (M. Guyon)  Original code
-      !!        !  95-04  (J. Escobar, M. Imbard)
-      !!        !  98-02  (M. Guyon)  FETI method
-      !!        !  98-05  (M. Imbard, J. Escobar, L. Colombet )  SHMEM and MPI versions
-      !!   8.5  !  02-08  (G. Madec)  F90 : free form
-      !!----------------------------------------------------------------------
-      INTEGER ::   ji, jj, jn               ! dummy loop indices
-      INTEGER ::   &
-         ii, ij,                         &  ! temporary integers
-         irestil, irestjl,               &  !    "          "
-         ijpi  , ijpj, nlcil,            &  ! temporary logical unit
-         nlcjl , nbondil, nbondjl,       &
-         nrecil, nrecjl, nldil, nleil, nldjl, nlejl
-
-      INTEGER, DIMENSION(jpi,jpj) ::   iimpptl, ijmpptl, ilcitl, ilcjtl   ! workspace
-      REAL(wp) ::   zidom, zjdom            ! temporary scalars
-      INTEGER ::   inum                     ! local logical unit
-      !!----------------------------------------------------------------------
-
-      !
-      !
-      !  1. Dimension arrays for subdomains
-      ! -----------------------------------
-      !  Computation of local domain sizes ilcitl() ilcjtl()
-      !  These dimensions depend on global sizes isplt,jsplt and jpiglo,jpjglo
-      !  The subdomains are squares leeser than or equal to the global
-      !  dimensions divided by the number of processors minus the overlap
-      !  array (cf. par_oce.F90).
-
-#if defined key_nemocice_decomp
-      ijpi = ( nx_global+2-2*nn_hls + (isplt-1) ) / isplt + 2*nn_hls
-      ijpj = ( ny_global+2-2*nn_hls + (jsplt-1) ) / jsplt + 2*nn_hls 
-#else
-      ijpi = ( jpiglo-2*nn_hls + (isplt-1) ) / isplt + 2*nn_hls
-      ijpj = ( jpjglo-2*nn_hls + (jsplt-1) ) / jsplt + 2*nn_hls
-#endif
-
-
-      nrecil  = 2 * nn_hls
-      nrecjl  = 2 * nn_hls
-      irestil = MOD( jpiglo - nrecil , isplt )
-      irestjl = MOD( jpjglo - nrecjl , jsplt )
-
-      IF(  irestil == 0 )   irestil = isplt
-#if defined key_nemocice_decomp
-
-      ! In order to match CICE the size of domains in NEMO has to be changed
-      ! The last line of blocks (west) will have fewer points 
-      DO jj = 1, jsplt 
-         DO ji=1, isplt-1 
-            ilcitl(ji,jj) = ijpi 
-         END DO 
-         ilcitl(isplt,jj) = jpiglo - (isplt - 1) * (ijpi - nrecil)
-      END DO 
-
-#else 
-
-      DO jj = 1, jsplt
-         DO ji = 1, irestil
-            ilcitl(ji,jj) = ijpi
-         END DO
-         DO ji = irestil+1, isplt
-            ilcitl(ji,jj) = ijpi -1
+               WRITE(inum, "(3x,a,' : ',D23.16                  )") cl1, zsum1
+            ENDIF
+
          END DO
       END DO
-
-#endif
-      
-      IF( irestjl == 0 )   irestjl = jsplt
-#if defined key_nemocice_decomp 
-
-      ! Same change to domains in North-South direction as in East-West. 
-      DO ji = 1, isplt 
-         DO jj=1, jsplt-1 
-            ilcjtl(ji,jj) = ijpj 
-         END DO 
-         ilcjtl(ji,jsplt) = jpjglo - (jsplt - 1) * (ijpj - nrecjl)
-      END DO 
-
-#else 
-
-      DO ji = 1, isplt
-         DO jj = 1, irestjl
-            ilcjtl(ji,jj) = ijpj
-         END DO
-         DO jj = irestjl+1, jsplt
-            ilcjtl(ji,jj) = ijpj -1
-         END DO
+      !
+   END SUBROUTINE prt_ctl
+
+
+   SUBROUTINE prt_ctl_info (clinfo, ivar, cdcomp )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_info  ***
+      !!
+      !! ** Purpose : - print information without any computation
+      !!
+      !! ** Action  : - input arguments
+      !!                    clinfo : information about the ivar
+      !!                    ivar   : value to print
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),           INTENT(in) ::   clinfo
+      INTEGER         , OPTIONAL, INTENT(in) ::   ivar
+      CHARACTER(len=3), OPTIONAL, INTENT(in) ::   cdcomp   ! only 'top' is accepted
+      !
+      CHARACTER(len=3) :: clcomp
+      INTEGER ::  jl, inum
+      !!----------------------------------------------------------------------
+      !
+      IF( PRESENT(cdcomp) ) THEN   ;   clcomp = cdcomp
+      ELSE                         ;   clcomp = 'oce'
+      ENDIF
+      !
+      DO jl = 1, SIZE(nall_ictls)
+         !
+         IF( clcomp == 'oce' )   inum = numprt_oce(jl)
+         IF( clcomp == 'top' )   inum = numprt_top(jl)
+         !
+         IF ( PRESENT(ivar) ) THEN   ;   WRITE(inum,*) clinfo, ivar
+         ELSE                        ;   WRITE(inum,*) clinfo
+         ENDIF
+         !
       END DO
-
-#endif
-      zidom = nrecil
-      DO ji = 1, isplt
-         zidom = zidom + ilcitl(ji,1) - nrecil
+      !
+   END SUBROUTINE prt_ctl_info
+
+
+   SUBROUTINE prt_ctl_init( cdcomp, kntra )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE prt_ctl_init  ***
+      !!
+      !! ** Purpose :   open ASCII files & compute indices
+      !!----------------------------------------------------------------------
+      CHARACTER(len=3), OPTIONAL, INTENT(in   ) ::   cdcomp   ! only 'top' is accepted
+      INTEGER         , OPTIONAL, INTENT(in   ) ::   kntra    ! only for 'top': number of tracers
+      !
+      INTEGER ::   ji, jj, jl
+      INTEGER ::   inum, idg, idg2
+      INTEGER ::   ijsplt, iimax, ijmax
+      INTEGER, DIMENSION(:,:), ALLOCATABLE ::    iimppt, ijmppt, ijpi, ijpj, iproc
+      INTEGER, DIMENSION(  :), ALLOCATABLE ::     iipos,  ijpos
+      LOGICAL, DIMENSION(:,:), ALLOCATABLE ::   llisoce
+      CHARACTER(len=64) :: clfile_out
+      CHARACTER(LEN=64) :: clfmt, clfmt2, clfmt3, clfmt4
+      CHARACTER(len=32) :: clname, cl_run
+      CHARACTER(len= 3) :: clcomp
+      !!----------------------------------------------------------------------
+      !
+      clname = 'output'
+      IF( PRESENT(cdcomp) ) THEN
+         clname = TRIM(clname)//'.'//TRIM(cdcomp)
+         clcomp = cdcomp
+      ELSE
+         clcomp = 'oce'
+      ENDIF
+      !
+      IF( jpnij > 1 ) THEN   ! MULTI processor run
+         cl_run = 'MULTI processor run'
+         idg = MAX( INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1, 4 )    ! how many digits to we need to write? min=4, max=9
+         WRITE(clfmt, "('(a,i', i1, '.', i1, ')')") idg, idg        ! '(a,ix.x)'
+         WRITE(clfile_out,clfmt) 'mpp.'//trim(clname)//'_', narea - 1
+         ijsplt = 1
+      ELSE                   ! MONO processor run
+         cl_run = 'MONO processor run '
+         IF(lwp) THEN                  ! control print
+            WRITE(numout,*)
+            WRITE(numout,*) 'prt_ctl_init: sn_cfctl%l_prtctl parameters'
+            WRITE(numout,*) '~~~~~~~~~~~~~'
+         ENDIF
+         IF( nn_ictls+nn_ictle+nn_jctls+nn_jctle == 0 )   THEN    ! print control done over the default area         
+            nn_isplt = MAX(1, nn_isplt)            ! number of processors following i-direction
+            nn_jsplt = MAX(1, nn_jsplt)            ! number of processors following j-direction
+            ijsplt = nn_isplt * nn_jsplt           ! total number of processors ijsplt
+            IF( ijsplt == 1 )   CALL ctl_warn( 'nn_isplt & nn_jsplt are equal to 1 -> control sum done over the whole domain' )
+            IF(lwp) WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
+            IF(lwp) WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
+            idg = MAX( INT(LOG10(REAL(MAX(1,ijsplt-1),wp))) + 1, 4 )    ! how many digits to we need to write? min=4, max=9
+            WRITE(clfmt, "('(a,i', i1, '.', i1, ')')") idg, idg         ! '(a,ix.x)'
+            IF( ijsplt == 1 ) WRITE(clfile_out,clfmt) 'mono.'//trim(clname)//'_', 0
+         ELSE                                             ! print control done over a specific  area
+            ijsplt = 1
+            IF( nn_ictls < 1 .OR. nn_ictls > Ni0glo )   THEN
+               CALL ctl_warn( '          - nictls must be 1<=nictls>=Ni0glo, it is forced to 1' )
+               nn_ictls = 1
+            ENDIF
+            IF( nn_ictle < 1 .OR. nn_ictle > Ni0glo )   THEN
+               CALL ctl_warn( '          - nictle must be 1<=nictle>=Ni0glo, it is forced to Ni0glo' )
+               nn_ictle = Ni0glo
+            ENDIF
+            IF( nn_jctls < 1 .OR. nn_jctls > Nj0glo )   THEN
+               CALL ctl_warn( '          - njctls must be 1<=njctls>=Nj0glo, it is forced to 1' )
+               nn_jctls = 1
+            ENDIF
+            IF( nn_jctle < 1 .OR. nn_jctle > Nj0glo )   THEN
+               CALL ctl_warn( '          - njctle must be 1<=njctle>=Nj0glo, it is forced to Nj0glo' )
+               nn_jctle = Nj0glo
+            ENDIF
+            WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
+            WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
+            WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
+            WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
+            idg = MAXVAL( (/ nn_ictls,nn_ictle,nn_jctls,nn_jctle /) )   ! temporary use of idg to store the largest index
+            idg = MAX( INT(LOG10(REAL(idg,wp))) + 1, 4 )                ! how many digits to we need to write? min=4, max=9
+            WRITE(clfmt, "('(4(a,i', i1, '.', i1, '))')") idg, idg         ! '(4(a,ix.x))'
+            WRITE(clfile_out,clfmt) 'mono.'//trim(clname)//'_', nn_ictls, '_', nn_ictle, '_', nn_jctls, '_', nn_jctle
+         ENDIF
+      ENDIF
+
+      ! Allocate arrays
+      IF( .NOT. ALLOCATED(nall_ictls) ) ALLOCATE( nall_ictls(ijsplt), nall_ictle(ijsplt), nall_jctls(ijsplt), nall_jctle(ijsplt) )
+
+      IF( jpnij > 1 ) THEN   ! MULTI processor run
+         !
+         nall_ictls(1) = Nis0
+         nall_ictle(1) = Nie0
+         nall_jctls(1) = Njs0
+         nall_jctle(1) = Nje0
+         !
+      ELSE                   ! MONO processor run
+         !
+         IF( nn_ictls+nn_ictle+nn_jctls+nn_jctle == 0 )   THEN    ! print control done over the default area
+            !
+            ALLOCATE(  iimppt(nn_isplt,nn_jsplt), ijmppt(nn_isplt,nn_jsplt),  ijpi(nn_isplt,nn_jsplt),  ijpj(nn_isplt,nn_jsplt),   &
+               &      llisoce(nn_isplt,nn_jsplt),  iproc(nn_isplt,nn_jsplt), iipos(nn_isplt*nn_jsplt), ijpos(nn_isplt*nn_jsplt) )
+            CALL mpp_basesplit( jpiglo, jpjglo, nn_hls, nn_isplt, nn_jsplt, iimax, ijmax, iimppt, ijmppt, ijpi, ijpj )
+            CALL mpp_is_ocean( llisoce )
+            CALL mpp_getnum( llisoce, iproc, iipos, ijpos )
+            !
+            DO jj = 1,nn_jsplt
+               DO ji = 1, nn_isplt
+                  jl = iproc(ji,jj) + 1
+                  nall_ictls(jl) = iimppt(ji,jj) - 1 +      1      + nn_hls
+                  nall_ictle(jl) = iimppt(ji,jj) - 1 + ijpi(ji,jj) - nn_hls
+                  nall_jctls(jl) = ijmppt(ji,jj) - 1 +      1      + nn_hls
+                  nall_jctle(jl) = ijmppt(ji,jj) - 1 + ijpj(ji,jj) - nn_hls
+               END DO
+            END DO
+            !
+            DEALLOCATE( iimppt, ijmppt, ijpi, ijpj, llisoce, iproc, iipos, ijpos )
+            !
+         ELSE                                             ! print control done over a specific  area
+            !
+            nall_ictls(1) = nn_ictls + nn_hls
+            nall_ictle(1) = nn_ictle + nn_hls
+            nall_jctls(1) = nn_jctls + nn_hls
+            nall_jctle(1) = nn_jctle + nn_hls
+            !
+         ENDIF
+      ENDIF
+
+      ! Initialization 
+      IF( clcomp == 'oce' ) THEN
+         ALLOCATE( t_ctl(ijsplt), s_ctl(ijsplt), u_ctl(ijsplt), v_ctl(ijsplt), numprt_oce(ijsplt) )
+         t_ctl(:) = 0.e0
+         s_ctl(:) = 0.e0
+         u_ctl(:) = 0.e0
+         v_ctl(:) = 0.e0
+      ENDIF
+      IF( clcomp == 'top' ) THEN
+         ALLOCATE( tra_ctl(kntra,ijsplt), numprt_top(ijsplt) )
+         tra_ctl(:,:) = 0.e0
+      ENDIF
+
+      DO jl = 1,ijsplt
+
+         IF( ijsplt > 1 ) WRITE(clfile_out,clfmt) 'mono.'//trim(clname)//'_', jl-1
+
+         CALL ctl_opn( inum, clfile_out, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', 1, numout, .FALSE. )
+         IF( clcomp == 'oce' )   numprt_oce(jl) = inum
+         IF( clcomp == 'top' )   numprt_top(jl) = inum
+         WRITE(inum,*)
+         WRITE(inum,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
+         WRITE(inum,*) '                       NEMO team'
+         WRITE(inum,*) '            Ocean General Circulation Model'
+         IF( clcomp == 'oce' )   WRITE(inum,*) '                NEMO version 4.x  (2020) '
+         IF( clcomp == 'top' )   WRITE(inum,*) '                 TOP vversion x (2020) '
+         WRITE(inum,*)
+         IF( ijsplt > 1 )   &
+            &   WRITE(inum,*) '              MPI-subdomain number: ', jl-1
+         IF(  jpnij > 1 )   &
+            &   WRITE(inum,*) '              MPI-subdomain number: ', narea-1
+         WRITE(inum,*)
+         WRITE(inum,'(19x,a20)') cl_run
+         WRITE(inum,*) 
+         WRITE(inum,*) 'prt_ctl :  Sum control indices'
+         WRITE(inum,*) '~~~~~~~'
+         WRITE(inum,*)
+         !
+         ! clfmt2: '              ----- jctle = XXX (YYY) -----'             -> '(18x, 13a1, a9, iM, a2, iN, a2, 13a1)'
+         ! clfmt3: '              |                           |'             -> '(18x, a1, Nx, a1)'
+         ! clfmt4: '        ictls = XXX (YYY)           ictle = XXX (YYY)'   -> '(Nx, a9, iM, a2, iP, a2, Qx, a9, iM, a2, iP, a2)'
+         !         '              |                           |'
+         !         '              ----- jctle = XXX (YYY) -----'
+         ! clfmt5: '   njmpp = XXX'                                          -> '(Nx, a9, iM)'
+         ! clfmt6: '           nimpp = XXX'                                  -> '(Nx, a9, iM)'
+         !
+         idg = MAXVAL( (/ nall_ictls(jl), nall_ictle(jl), nall_jctls(jl), nall_jctle(jl) /) )   ! temporary use of idg
+         idg = INT(LOG10(REAL(idg,wp))) + 1                                                     ! how many digits do we use?
+         idg2 = MAXVAL( (/ mig0(nall_ictls(jl)), mig0(nall_ictle(jl)), mjg0(nall_jctls(jl)), mjg0(nall_jctle(jl)) /) )
+         idg2 = INT(LOG10(REAL(idg2,wp))) + 1                                                   ! how many digits do we use?
+         WRITE(clfmt2, "('(18x, 13a1, a9, i', i1, ', a2, i',i1,', a2, 13a1)')") idg, idg2
+         WRITE(clfmt3, "('(18x, a1, ', i2,'x, a1)')") 13+9+idg+2+idg2+2+13 - 2
+         WRITE(clfmt4, "('(', i2,'x, a9, i', i1,', a2, i', i1,', a2, ', i2,'x, a9, i', i1,', a2, i', i1,', a2)')") &
+            &          18-7, idg, idg2, 13+9+idg+2+idg2+2+13 - (2+idg+2+idg2+2+8), idg, idg2
+         WRITE(inum,clfmt2) ('-', ji=1,13), ' jctle = ', nall_jctle(jl), ' (', mjg0(nall_jctle(jl)), ') ', ('-', ji=1,13)
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt4)                 ' ictls = ', nall_ictls(jl), ' (', mig0(nall_ictls(jl)), ') ',   &
+            &                               ' ictle = ', nall_ictle(jl), ' (', mig0(nall_ictle(jl)), ') '
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt3) '|', '|'
+         WRITE(inum,clfmt2) ('-', ji=1,13), ' jctls = ', nall_jctls(jl), ' (', mjg0(nall_jctls(jl)), ') ', ('-', ji=1,13)
+         WRITE(inum,*)
+         WRITE(inum,*)
+         !
       END DO
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*)' sum ilcitl(i,1) = ', zidom, ' jpiglo = ', jpiglo
-      
-      zjdom = nrecjl
-      DO jj = 1, jsplt
-         zjdom = zjdom + ilcjtl(1,jj) - nrecjl
-      END DO
-      IF(lwp) WRITE(numout,*)' sum ilcitl(1,j) = ', zjdom, ' jpjglo = ', jpjglo
-      IF(lwp) WRITE(numout,*)
-      
-
-      !  2. Index arrays for subdomains
-      ! -------------------------------
-
-      iimpptl(:,:) = 1
-      ijmpptl(:,:) = 1
-      
-      IF( isplt > 1 ) THEN
-         DO jj = 1, jsplt
-            DO ji = 2, isplt
-               iimpptl(ji,jj) = iimpptl(ji-1,jj) + ilcitl(ji-1,jj) - nrecil
-            END DO
-         END DO
-      ENDIF
-
-      IF( jsplt > 1 ) THEN
-         DO jj = 2, jsplt
-            DO ji = 1, isplt
-               ijmpptl(ji,jj) = ijmpptl(ji,jj-1)+ilcjtl(ji,jj-1)-nrecjl
-            END DO
-         END DO
-      ENDIF
-      
-      ! 3. Subdomain description
-      ! ------------------------
-
-      DO jn = 1, ijsplt
-         ii = 1 + MOD( jn-1, isplt )
-         ij = 1 + (jn-1) / isplt
-         nimpptl(jn) = iimpptl(ii,ij)
-         njmpptl(jn) = ijmpptl(ii,ij)
-         nlcitl (jn) = ilcitl (ii,ij)     
-         nlcil       = nlcitl (jn)     
-         nlcjtl (jn) = ilcjtl (ii,ij)     
-         nlcjl       = nlcjtl (jn)
-         nbondjl = -1                                    ! general case
-         IF( jn   >  isplt          )   nbondjl = 0      ! first row of processor
-         IF( jn   >  (jsplt-1)*isplt )  nbondjl = 1     ! last  row of processor
-         IF( jsplt == 1             )   nbondjl = 2      ! one processor only in j-direction
-         ibonjtl(jn) = nbondjl
-         
-         nbondil = 0                                     ! 
-         IF( MOD( jn, isplt ) == 1 )   nbondil = -1      !
-         IF( MOD( jn, isplt ) == 0 )   nbondil =  1      !
-         IF( isplt            == 1 )   nbondil =  2      ! one processor only in i-direction
-         ibonitl(jn) = nbondil
-         
-         nldil =  1   + nn_hls
-         nleil = nlcil - nn_hls
-         IF( nbondil == -1 .OR. nbondil == 2 )   nldil = 1
-         IF( nbondil ==  1 .OR. nbondil == 2 )   nleil = nlcil
-         nldjl =  1   + nn_hls
-         nlejl = nlcjl - nn_hls
-         IF( nbondjl == -1 .OR. nbondjl == 2 )   nldjl = 1
-         IF( nbondjl ==  1 .OR. nbondjl == 2 )   nlejl = nlcjl
-         nlditl(jn) = nldil
-         nleitl(jn) = nleil
-         nldjtl(jn) = nldjl
-         nlejtl(jn) = nlejl
-      END DO
-      !
-      ! Save processor layout in layout_prtctl.dat file 
-      IF(lwp) THEN
-         CALL ctl_opn( inum, 'layout_prtctl.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
-         WRITE(inum,'(a)') 'nproc nlcil nlcjl nldil nldjl nleil nlejl nimpptl njmpptl ibonitl ibonjtl'
-         !
-         DO jn = 1, ijsplt
-            WRITE(inum,'(i5,6i6,4i8)') jn-1,nlcitl(jn),  nlcjtl(jn), &
-               &                            nlditl(jn),  nldjtl(jn), &
-               &                            nleitl(jn),  nlejtl(jn), &
-               &                           nimpptl(jn), njmpptl(jn), &
-               &                           ibonitl(jn), ibonjtl(jn)
-         END DO
-         CLOSE(inum)   
-      END IF
-      !
-      !
-   END SUBROUTINE sub_dom
+      !
+   END SUBROUTINE prt_ctl_init
+
 
    !!======================================================================
Index: NEMO/trunk/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/trunk/src/OCE/IOM/restart.F90	(revision 13237)
+++ NEMO/trunk/src/OCE/IOM/restart.F90	(revision 13286)
@@ -214,10 +214,10 @@
              IF( .NOT.lxios_set ) THEN
                  IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-                 CALL iom_init( crxios_context, ld_tmppatch = .false. )
+                 CALL iom_init( crxios_context )
                  lxios_set = .TRUE.
              ENDIF
          ENDIF
          IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
-             CALL iom_init( crxios_context, ld_tmppatch = .false. )
+             CALL iom_init( crxios_context )
              IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
              lxios_set = .TRUE.
@@ -259,10 +259,10 @@
       
       ! Diurnal DSST 
-      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios ) 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst, ldxios = lrxios ) 
       IF ( ln_diurnal_only ) THEN 
          IF(lwp) WRITE( numout, * ) &
          &   "rst_read:- ln_diurnal_only set, setting rhop=rho0" 
          rhop = rho0
-         CALL iom_get( numror, jpdom_autoglo, 'tn'     , w3d, ldxios = lrxios ) 
+         CALL iom_get( numror, jpdom_auto, 'tn'     , w3d, ldxios = lrxios ) 
          ts(:,:,1,jp_tem,Kmm) = w3d(:,:,1)
          RETURN 
@@ -270,20 +270,22 @@
       
       IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lrxios )   ! before fields
-         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lrxios )
-         CALL iom_get( numror, jpdom_autoglo, 'tb'     , ts(:,:,:,jp_tem,Kbb), ldxios = lrxios )
-         CALL iom_get( numror, jpdom_autoglo, 'sb'     , ts(:,:,:,jp_sal,Kbb), ldxios = lrxios )
-         CALL iom_get( numror, jpdom_autoglo, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lrxios )
+         ! before fields
+         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
+         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
+         CALL iom_get( numror, jpdom_auto, 'tb'     , ts(:,:,:,jp_tem,Kbb), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_auto, 'sb'     , ts(:,:,:,jp_sal,Kbb), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_auto, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lrxios )
       ELSE
          l_1st_euler =  .TRUE.      ! before field not found, forced euler 1st time-step
       ENDIF
       !
-      CALL iom_get( numror, jpdom_autoglo, 'un'     , uu(:,:,:       ,Kmm), ldxios = lrxios )       ! now    fields
-      CALL iom_get( numror, jpdom_autoglo, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lrxios )
-      CALL iom_get( numror, jpdom_autoglo, 'tn'     , ts(:,:,:,jp_tem,Kmm), ldxios = lrxios )
-      CALL iom_get( numror, jpdom_autoglo, 'sn'     , ts(:,:,:,jp_sal,Kmm), ldxios = lrxios )
-      CALL iom_get( numror, jpdom_autoglo, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lrxios )
+      ! now fields
+      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'tn'     , ts(:,:,:,jp_tem,Kmm), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_auto, 'sn'     , ts(:,:,:,jp_sal,Kmm), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_auto, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lrxios )
       IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
+         CALL iom_get( numror, jpdom_auto, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
       ELSE
          CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) )   
