Index: NEMO/trunk/src/OCE/ICB/icb_oce.F90
===================================================================
--- NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 13281)
+++ NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 13286)
@@ -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)
@@ -197,7 +194,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/trunk/src/OCE/ICB/icbini.F90
===================================================================
--- NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 13281)
+++ NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 13286)
@@ -133,5 +133,5 @@
       ! first entry with narea for this processor is left hand interior index
       ! last  entry                               is right hand interior index
-      jj = nlcj/2
+      jj = jpj/2
       nicbdi = -1
       nicbei = -1
@@ -149,5 +149,5 @@
       !
       ! repeat for j direction
-      ji = nlci/2
+      ji = jpi/2
       nicbdj = -1
       nicbej = -1
@@ -166,9 +166,9 @@
       ! special for east-west boundary exchange we save the destination index
       i1 = MAX( nicbdi-1, 1)
-      i3 = INT( src_calving(i1,nlcj/2) )
+      i3 = INT( src_calving(i1,jpj/2) )
       jj = INT( i3/nicbpack )
       ricb_left = REAL( i3 - nicbpack*jj, wp )
       i1 = MIN( nicbei+1, jpi )
-      i3 = INT( src_calving(i1,nlcj/2) )
+      i3 = INT( src_calving(i1,jpj/2) )
       jj = INT( i3/nicbpack )
       ricb_right = REAL( i3 - nicbpack*jj, wp )
@@ -203,11 +203,11 @@
          WRITE(numicb,*) 'processor ', narea
          WRITE(numicb,*) 'jpi, jpj   ', jpi, jpj
-         WRITE(numicb,*) 'nldi, nlei ', nldi, nlei
-         WRITE(numicb,*) 'nldj, nlej ', nldj, nlej
+         WRITE(numicb,*) 'Nis0, Nie0 ', Nis0, Nie0
+         WRITE(numicb,*) 'Njs0, Nje0 ', Njs0, Nje0
          WRITE(numicb,*) 'berg i interior ', nicbdi, nicbei
          WRITE(numicb,*) 'berg j interior ', nicbdj, nicbej
          WRITE(numicb,*) 'berg left       ', ricb_left
          WRITE(numicb,*) 'berg right      ', ricb_right
-         jj = nlcj/2
+         jj = jpj/2
          WRITE(numicb,*) "central j line:"
          WRITE(numicb,*) "i processor"
@@ -215,5 +215,5 @@
          WRITE(numicb,*) "i point"
          WRITE(numicb,*) (INT(src_calving(ji,jj)), ji=1,jpi)
-         ji = nlci/2
+         ji = jpi/2
          WRITE(numicb,*) "central i line:"
          WRITE(numicb,*) "j processor"
@@ -256,5 +256,5 @@
          ivar = iom_varid( inum, 'maxclass', ldstop=.FALSE. )
          IF( ivar > 0 ) THEN
-            CALL iom_get  ( inum, jpdom_data, 'maxclass', src_calving )   ! read the max distribution array
+            CALL iom_get  ( inum, jpdom_global, 'maxclass', src_calving )   ! read the max distribution array
             berg_grid%maxclass(:,:) = INT( src_calving )
             src_calving(:,:) = 0._wp
Index: NEMO/trunk/src/OCE/ICB/icbrst.F90
===================================================================
--- NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 13281)
+++ NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 13286)
@@ -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(Nis0) .AND. ii <= mig(Nie0) .AND.   &
+           &     ij >= mjg(Njs0) .AND. ij <= mjg(Nje0) ) 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)) )
@@ -123,8 +123,9 @@
 
       ! Gridded variables
-      CALL iom_get( ncid, jpdom_autoglo,    'calving'     , src_calving  )
-      CALL iom_get( ncid, jpdom_autoglo,    'calving_hflx', src_calving_hflx  )
-      CALL iom_get( ncid, jpdom_autoglo,    'stored_heat' , berg_grid%stored_heat  )
-      CALL iom_get( ncid, jpdom_autoglo_xy, 'stored_ice'  , berg_grid%stored_ice, kstart=(/1,1,1/), kcount=(/1,1,nclasses/) )
+      CALL iom_get( ncid, jpdom_auto,    'calving'     , src_calving  )
+      CALL iom_get( ncid, jpdom_auto,    'calving_hflx', src_calving_hflx  )
+      CALL iom_get( ncid, jpdom_auto,    'stored_heat' , berg_grid%stored_heat  )
+      ! 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(:) )
@@ -229,8 +230,8 @@
    
          ! Dimensions
-         nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
+         nret = NF90_DEF_DIM(ncid, 'x', Ni_0, 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', Nj_0, iy_dim)
          IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
    
@@ -244,14 +245,14 @@
          IF( lk_mpp ) THEN
             ! Set domain parameters (assume jpdom_local_full)
-            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_type'           , 'BOX'              )
+            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'    , (/ Ni0glo    , Nj0glo     /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/ Ni_0      , Nj_0       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/ mig0(Nis0), mjg0(Njs0) /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/ mig0(Nie0), mjg0(Nje0) /) )
+            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
          
@@ -344,12 +345,11 @@
          nstrt3(1) = 1
          nstrt3(2) = 1
-         nlngth3(1) = jpi
-         nlngth3(2) = jpj
+         nlngth3(1) = Ni_0
+         nlngth3(2) = Nj_0
          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(Nis0:Nie0,Njs0:Nje0,jn), nstrt3, nlngth3 )
             IF (nret .ne. NF90_NOERR) THEN
                IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
@@ -362,11 +362,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(Nis0:Nie0,Njs0:Nje0) )
          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(Nis0:Nie0,Njs0:Nje0) )
          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(Nis0:Nie0,Njs0:Nje0) )
          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'
