Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icb_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icb_oce.F90	(revision 12744)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icb_oce.F90	(revision 12745)
@@ -147,7 +147,4 @@
    INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)       ::   nicbfldexpect                    !: nfold expected number of bergs
    INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)       ::   nicbfldreq                       !: nfold message handle (immediate send)
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   :: griddata                           !: work array for icbrst
-
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -196,7 +193,4 @@
       icb_alloc = icb_alloc + ill
 
-      ALLOCATE( griddata(jpi,jpj,1), STAT=ill )
-      icb_alloc = icb_alloc + ill
-
       CALL mpp_sum ( 'icb_oce', icb_alloc )
       IF( icb_alloc > 0 )   CALL ctl_warn('icb_alloc: allocation of arrays failed')
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icbrst.F90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icbrst.F90	(revision 12744)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/ICB/icbrst.F90	(revision 12745)
@@ -91,8 +91,8 @@
             ij = INT( localpt%yj + 0.5 )
             ! Only proceed if this iceberg is on the local processor (excluding halos).
-            IF ( ii .GE. nldi+nimpp-1 .AND. ii .LE. nlei+nimpp-1 .AND. &
-           &     ij .GE. nldj+njmpp-1 .AND. ij .LE. nlej+njmpp-1 ) THEN           
-
-               CALL iom_get( ncid, jpdom_unknown, 'number'       , zdata(:) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) )
+            IF ( ii >= mig(nldi) .AND. ii <= mig(nlei) .AND.   &
+           &     ij >= mjg(nldj) .AND. ij <= mjg(nlej) ) THEN           
+
+               CALL iom_get( ncid, jpdom_unknown, 'number', zdata(:) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) )
                localberg%number(:) = INT(zdata(:))
                imax_icb = MAX( imax_icb, INT(zdata(1)) )
@@ -126,5 +126,6 @@
       CALL iom_get( ncid, jpdom_auto,    'calving_hflx', src_calving_hflx  )
       CALL iom_get( ncid, jpdom_auto,    'stored_heat' , berg_grid%stored_heat  )
-      CALL iom_get( ncid, jpdom_auto_xy, 'stored_ice'  , berg_grid%stored_ice, kstart=(/1,1,1/), kcount=(/1,1,nclasses/) )
+      ! with jpdom_auto_xy, ue use only the third element of kstart and kcount.
+      CALL iom_get( ncid, jpdom_auto_xy, 'stored_ice'  , berg_grid%stored_ice, kstart=(/-99,-99,1/), kcount=(/-99,-99,nclasses/) )
       
       CALL iom_get( ncid, jpdom_unknown, 'kount' , zdata(:) )
@@ -225,8 +226,8 @@
    
          ! Dimensions
-         nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
+         nret = NF90_DEF_DIM(ncid, 'x', nlei-nldi+1, ix_dim)
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
    
-         nret = NF90_DEF_DIM(ncid, 'y', jpj, iy_dim)
+         nret = NF90_DEF_DIM(ncid, 'y', nlej-nldj+1, iy_dim)
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
    
@@ -242,11 +243,11 @@
             nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              )
             nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/jpi   , jpj   /) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/nimpp , njmpp /) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/nimpp + jpi - 1 , njmpp + jpj - 1  /) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/nldi - 1        , nldj - 1         /) )
-            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/jpi - nlei      , jpj - nlej       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/ 1              , 2               /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/ jpiglo         , jpjglo          /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/ nlei - nldi + 1, nlej - nldj + 1 /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/ mig(nldi)      , mjg(nldj)       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/ mig(nlei)      , mjg(nlej)       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/ 0              , 0               /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/ 0              , 0               /) )
             nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              )
          ENDIF
@@ -340,12 +341,11 @@
          nstrt3(1) = 1
          nstrt3(2) = 1
-         nlngth3(1) = jpi
-         nlngth3(2) = jpj
+         nlngth3(1) = nlei - nldi + 1
+         nlngth3(2) = nlej - nldj + 1
          nlngth3(3) = 1
    
          DO jn=1,nclasses
-            griddata(:,:,1) = berg_grid%stored_ice(:,:,jn)
             nstrt3(3) = jn
-            nret = NF90_PUT_VAR( ncid, nsiceid, griddata, nstrt3, nlngth3 )
+            nret = NF90_PUT_VAR( ncid, nsiceid, berg_grid%stored_ice(nldi:nlei,nldj:nlej,jn), nstrt3, nlngth3 )
             IF (nret .ne. NF90_NOERR) THEN
                IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
@@ -358,11 +358,11 @@
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
    
-         nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
+         nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(nldi:nlei,nldj:nlej) )
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
          IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_heat written'
    
-         nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(:,:) )
+         nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(nldi:nlei,nldj:nlej) )
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
-         nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
+         nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(nldi:nlei,nldj:nlej) )
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
          IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: calving written'
Index: /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90	(revision 12744)
+++ /NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90	(revision 12745)
@@ -762,9 +762,9 @@
       ENDIF
       IF( llwrt ) THEN
-         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                /)
+         idompar(:,1) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+         idompar(:,2) = (/ mig(nldi)      , mjg(nldj)       /)
+         idompar(:,3) = (/ mig(nlei)      , mjg(nlej)       /)
+         idompar(:,4) = (/ 0              , 0               /)
+         idompar(:,5) = (/ 0              , 0               /)
       ENDIF
       ! Open the NetCDF file
@@ -1081,6 +1081,8 @@
          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  ) &
+         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)
@@ -1096,5 +1098,4 @@
             !
             ! Identify the domain in case of jpdom_auto definition
-            ll_only3rd = idom == jpdom_auto_xy             ! depth is specified if idom == jpdom_auto_xy 
             IF( idom == jpdom_auto .OR. idom == jpdom_auto_xy ) THEN            
                idom = jpdom_global   ! default
@@ -1145,24 +1146,25 @@
             ! definition of istart and icnt
             !
-            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
+            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( PRESENT(kstart) .AND. .NOT. ll_only3rd ) 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
-                     ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
-                     IF( idom == jpdom_global )   istart(1:2) = (/ mig(nldi), mjg(nldj) /)
-                     icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
-                     IF( PRESENT(pv_r3d) ) THEN
-                        IF( ll_only3rd .AND. PRESENT(kstart) ) THEN   ;   istart(3) = kstart(3)   ;   icnt(3) = kcount(3)
-                        ELSE                                          ;                               icnt(3) = inlev
-                        ENDIF
-                     ENDIF
+            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 nldi to nlei and from nldj to nlej 
+               IF( idom == jpdom_global )   istart(1:2) = (/ mig(nldi), mjg(nldj) /)
+               icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+               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
