Index: NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/iceistate.F90
===================================================================
--- NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/iceistate.F90	(revision 12967)
+++ NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/iceistate.F90	(revision 12988)
@@ -85,8 +85,6 @@
       !! ** Steps   :   1) Set initial surface and basal temperatures
       !!                2) Recompute or read sea ice state variables
-      !!                3) Fill in the ice thickness distribution using gaussian
-      !!                4) Fill in space-dependent arrays for state variables
-      !!                5) snow-ice mass computation
-      !!                6) store before fields
+      !!                3) Fill in space-dependent arrays for state variables
+      !!                4) snow-ice mass computation
       !!
       !! ** Notes   : o_i, t_su, t_s, t_i, sz_i must be filled everywhere, even
@@ -284,7 +282,7 @@
          ENDIF
          
-         !-------------!
-         ! fill fields !
-         !-------------!
+         !----------------!
+         ! 3) fill fields !
+         !----------------!
          ! select ice covered grid points
          npti = 0 ; nptidx(:) = 0
@@ -393,10 +391,15 @@
          t1_ice(:,:,:) = t_i (:,:,1,:)
          !
+         ! ice concentration should not exceed amax
+         at_i(:,:) = SUM( a_i, dim=3 )
+         DO jl = 1, jpl
+            WHERE( at_i(:,:) > rn_amax_2d(:,:) )   a_i(:,:,jl) = a_i(:,:,jl) * rn_amax_2d(:,:) / at_i(:,:)
+         END DO
+         at_i(:,:) = SUM( a_i, dim=3 )
+         !
       ENDIF ! ln_iceini
       !
-      at_i(:,:) = SUM( a_i, dim=3 )
-      !
       !----------------------------------------------
-      ! 3) Snow-ice mass (case ice is fully embedded)
+      ! 4) Snow-ice mass (case ice is fully embedded)
       !----------------------------------------------
       snwice_mass  (:,:) = tmask(:,:,1) * SUM( rhos * v_s(:,:,:) + rhoi * v_i(:,:,:), dim=3  )   ! snow+ice mass
@@ -448,19 +451,4 @@
          ENDIF
       ENDIF
-      
-      !------------------------------------
-      ! 4) store fields at before time-step
-      !------------------------------------
-      ! it is only necessary for the 1st interpolation by Agrif
-      a_i_b  (:,:,:)   = a_i  (:,:,:)
-      e_i_b  (:,:,:,:) = e_i  (:,:,:,:)
-      v_i_b  (:,:,:)   = v_i  (:,:,:)
-      v_s_b  (:,:,:)   = v_s  (:,:,:)
-      e_s_b  (:,:,:,:) = e_s  (:,:,:,:)
-      sv_i_b (:,:,:)   = sv_i (:,:,:)
-      u_ice_b(:,:)     = u_ice(:,:)
-      v_ice_b(:,:)     = v_ice(:,:)
-      ! total concentration is needed for Lupkes parameterizations
-      at_i_b (:,:)     = at_i (:,:) 
 
 !!clem: output of initial state should be written here but it is impossible because
Index: NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/icestp.F90
===================================================================
--- NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/icestp.F90	(revision 12967)
+++ NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/src/ICE/icestp.F90	(revision 12988)
@@ -202,5 +202,5 @@
          IF( lrst_ice )                 CALL ice_rst_write( kt )      ! -- Ice restart file 
          !
-         IF( ln_icectl )                CALL ice_ctl( kt )            ! -- alerts in case of model crash
+         IF( ln_icectl )                CALL ice_ctl( kt )            ! -- Control checks
          !
       ENDIF   ! End sea-ice time step only
@@ -223,5 +223,5 @@
       !! ** purpose :   Initialize sea-ice parameters
       !!----------------------------------------------------------------------
-      INTEGER :: ji, jj, ierr
+      INTEGER :: jl, ierr
       !!----------------------------------------------------------------------
       IF(lwp) WRITE(numout,*)
@@ -247,4 +247,9 @@
       IF( ierr /= 0 )   CALL ctl_stop('STOP', 'ice_init : unable to allocate ice arrays')
       !
+      !                                ! set max concentration in both hemispheres
+      WHERE( gphit(:,:) > 0._wp )   ;   rn_amax_2d(:,:) = rn_amax_n  ! NH
+      ELSEWHERE                     ;   rn_amax_2d(:,:) = rn_amax_s  ! SH
+      END WHERE
+      !
       CALL ice_itd_init                ! ice thickness distribution initialization
       !
@@ -252,10 +257,9 @@
       !
       !                                ! Initial sea-ice state
-
       IF ( ln_rstart .OR. nn_iceini_file == 2 ) THEN
          CALL ice_rst_read                      ! start from a restart file
       ELSE
          CALL ice_istate_init
-         CALL ice_istate( nit000 )              ! start from rest: sea-ice deduced from sst
+         CALL ice_istate( nit000 )              ! start from rest or read a file
       ENDIF
       CALL ice_var_glo2eqv
@@ -275,9 +279,4 @@
       tn_ice(:,:,:) = t_su(:,:,:)      ! initialisation of surface temp for coupled simu
       !
-      !                                ! set max concentration in both hemispheres
-      WHERE( gphit(:,:) > 0._wp )   ;   rn_amax_2d(:,:) = rn_amax_n  ! NH
-      ELSEWHERE                     ;   rn_amax_2d(:,:) = rn_amax_s  ! SH
-      END WHERE
-
       IF( ln_rstart )   CALL iom_close( numrir )  ! close input ice restart file
       !
