Index: NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/ICE/icerst.F90
===================================================================
--- NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/ICE/icerst.F90	(revision 13313)
+++ NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/src/ICE/icerst.F90	(revision 13334)
@@ -25,4 +25,7 @@
    USE lib_mpp        ! MPP library
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
+
+   USE agrif_oce      ! initial state interpolation
+   USE agrif_ice_interp  
 
    IMPLICIT NONE
@@ -185,98 +188,112 @@
       ENDIF
 
-      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir )
-
-      ! test if v_i exists 
-      id0 = iom_varid( numrir, 'v_i' , ldstop = .FALSE. )
-
-      !                    ! ------------------------------ !
-      IF( id0 > 0 ) THEN   ! == case of a normal restart == !
-         !                 ! ------------------------------ !
+#if defined key_agrif
+      IF( (.NOT.Agrif_Root()).AND.ln_init_chfrpar ) THEN
+         !                 ! -------------------------------- !
+         !                 ! == set ice fields from parent == !
+         !                 ! -------------------------------- !
+         !
+         CALL agrif_istate_ice
+         !
+      ELSE
+#endif
+
+         CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir )
+
+         ! test if v_i exists 
+         id0 = iom_varid( numrir, 'v_i' , ldstop = .FALSE. )
+
+         !                    ! ------------------------------ !
+         IF( id0 > 0 ) THEN   ! == case of a normal restart == !
+            !                 ! ------------------------------ !
          
-         ! Time info
-         CALL iom_get( numrir, 'nn_fsbc', zfice )
-         CALL iom_get( numrir, 'kt_ice' , ziter )    
-         IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
-         IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
-
-         ! Control of date
-         IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
-            &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart',  &
-            &                   '   verify the file or rerun with the value 0 for the',        &
-            &                   '   control of time parameter  nrstdt' )
-         IF( NINT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
-            &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
-            &                   '   verify the file or rerun with the value 0 for the',         &
-            &                   '   control of time parameter  nrstdt' )
-
-         ! --- mandatory fields --- ! 
-         CALL iom_get( numrir, jpdom_auto, 'v_i'  , v_i   )
-         CALL iom_get( numrir, jpdom_auto, 'v_s'  , v_s   )
-         CALL iom_get( numrir, jpdom_auto, 'sv_i' , sv_i  )
-         CALL iom_get( numrir, jpdom_auto, 'a_i'  , a_i   )
-         CALL iom_get( numrir, jpdom_auto, 't_su' , t_su  )
-         CALL iom_get( numrir, jpdom_auto, 'u_ice', u_ice, cd_type = 'U', psgn = -1._wp )
-         CALL iom_get( numrir, jpdom_auto, 'v_ice', v_ice, cd_type = 'V', psgn = -1._wp )
-         ! Snow enthalpy
-         DO jk = 1, nlay_s
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'e_s'//'_l'//zchar1
-            CALL iom_get( numrir, jpdom_auto, znam , z3d )
-            e_s(:,:,jk,:) = z3d(:,:,:)
-         END DO
-         ! Ice enthalpy
-         DO jk = 1, nlay_i
-            WRITE(zchar1,'(I2.2)') jk
-            znam = 'e_i'//'_l'//zchar1
-            CALL iom_get( numrir, jpdom_auto, znam , z3d )
-            e_i(:,:,jk,:) = z3d(:,:,:)
-         END DO
-         ! -- optional fields -- !
-         ! ice age
-         id1 = iom_varid( numrir, 'oa_i' , ldstop = .FALSE. )
-         IF( id1 > 0 ) THEN                       ! fields exist
-            CALL iom_get( numrir, jpdom_auto, 'oa_i', oa_i )
-         ELSE                                     ! start from rest
-            IF(lwp) WRITE(numout,*) '   ==>>   previous run without ice age output then set it to zero'
-            oa_i(:,:,:) = 0._wp
+            ! Time info
+            CALL iom_get( numrir, 'nn_fsbc', zfice )
+            CALL iom_get( numrir, 'kt_ice' , ziter )    
+            IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
+            IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
+
+            ! Control of date
+            IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
+               &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart',  &
+               &                   '   verify the file or rerun with the value 0 for the',        &
+               &                   '   control of time parameter  nrstdt' )
+            IF( NINT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
+               &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
+               &                   '   verify the file or rerun with the value 0 for the',         &
+               &                   '   control of time parameter  nrstdt' )
+
+            ! --- mandatory fields --- ! 
+            CALL iom_get( numrir, jpdom_auto, 'v_i'  , v_i   )
+            CALL iom_get( numrir, jpdom_auto, 'v_s'  , v_s   )
+            CALL iom_get( numrir, jpdom_auto, 'sv_i' , sv_i  )
+            CALL iom_get( numrir, jpdom_auto, 'a_i'  , a_i   )
+            CALL iom_get( numrir, jpdom_auto, 't_su' , t_su  )
+            CALL iom_get( numrir, jpdom_auto, 'u_ice', u_ice, cd_type = 'U', psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'v_ice', v_ice, cd_type = 'V', psgn = -1._wp )
+            ! Snow enthalpy
+            DO jk = 1, nlay_s
+               WRITE(zchar1,'(I2.2)') jk
+               znam = 'e_s'//'_l'//zchar1
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )
+               e_s(:,:,jk,:) = z3d(:,:,:)
+            END DO
+            ! Ice enthalpy
+            DO jk = 1, nlay_i
+               WRITE(zchar1,'(I2.2)') jk
+               znam = 'e_i'//'_l'//zchar1
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )
+               e_i(:,:,jk,:) = z3d(:,:,:)
+            END DO
+            ! -- optional fields -- !
+            ! ice age
+            id1 = iom_varid( numrir, 'oa_i' , ldstop = .FALSE. )
+            IF( id1 > 0 ) THEN                       ! fields exist
+               CALL iom_get( numrir, jpdom_auto, 'oa_i', oa_i )
+            ELSE                                     ! start from rest
+               IF(lwp) WRITE(numout,*) '   ==>>   previous run without ice age output then set it to zero'
+               oa_i(:,:,:) = 0._wp
+            ENDIF
+            ! melt ponds
+            id2 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. )
+            IF( id2 > 0 ) THEN                       ! fields exist
+               CALL iom_get( numrir, jpdom_auto, 'a_ip' , a_ip )
+               CALL iom_get( numrir, jpdom_auto, 'v_ip' , v_ip )
+            ELSE                                     ! start from rest
+               IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it to zero'
+               a_ip(:,:,:) = 0._wp
+               v_ip(:,:,:) = 0._wp
+            ENDIF
+            ! fields needed for Met Office (Jules) coupling
+            IF( ln_cpl ) THEN
+               id3 = iom_varid( numrir, 'cnd_ice' , ldstop = .FALSE. )
+               id4 = iom_varid( numrir, 't1_ice'  , ldstop = .FALSE. )
+               IF( id3 > 0 .AND. id4 > 0 ) THEN         ! fields exist
+                  CALL iom_get( numrir, jpdom_auto, 'cnd_ice', cnd_ice )
+                  CALL iom_get( numrir, jpdom_auto, 't1_ice' , t1_ice  )
+               ELSE                                     ! start from rest
+                  IF(lwp) WRITE(numout,*) '   ==>>   previous run without conductivity output then set it to zero'
+                  cnd_ice(:,:,:) = 0._wp
+                  t1_ice (:,:,:) = rt0
+               ENDIF
+            ENDIF
+
+            CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
+
+            !                 ! ---------------------------------- !
+         ELSE                 ! == case of a simplified restart == !
+            !                 ! ---------------------------------- !
+            CALL ctl_warn('ice_rst_read: you are using a simplified ice restart')
+            !
+            CALL ice_istate_init
+            CALL ice_istate( nit000, Kbb, Kmm, Kaa )
+            !
+            IF( .NOT.ln_iceini .OR. .NOT.ln_iceini_file ) &
+               &   CALL ctl_stop('STOP', 'ice_rst_read: you need ln_ice_ini=T and ln_iceini_file=T')
+            !
          ENDIF
-         ! melt ponds
-         id2 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. )
-         IF( id2 > 0 ) THEN                       ! fields exist
-            CALL iom_get( numrir, jpdom_auto, 'a_ip' , a_ip )
-            CALL iom_get( numrir, jpdom_auto, 'v_ip' , v_ip )
-         ELSE                                     ! start from rest
-            IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it to zero'
-            a_ip(:,:,:) = 0._wp
-            v_ip(:,:,:) = 0._wp
-         ENDIF
-         ! fields needed for Met Office (Jules) coupling
-         IF( ln_cpl ) THEN
-            id3 = iom_varid( numrir, 'cnd_ice' , ldstop = .FALSE. )
-            id4 = iom_varid( numrir, 't1_ice'  , ldstop = .FALSE. )
-            IF( id3 > 0 .AND. id4 > 0 ) THEN         ! fields exist
-               CALL iom_get( numrir, jpdom_auto, 'cnd_ice', cnd_ice )
-               CALL iom_get( numrir, jpdom_auto, 't1_ice' , t1_ice  )
-            ELSE                                     ! start from rest
-               IF(lwp) WRITE(numout,*) '   ==>>   previous run without conductivity output then set it to zero'
-               cnd_ice(:,:,:) = 0._wp
-               t1_ice (:,:,:) = rt0
-            ENDIF
-         ENDIF
-
-         CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
-
-         !                 ! ---------------------------------- !
-      ELSE                 ! == case of a simplified restart == !
-         !                 ! ---------------------------------- !
-         CALL ctl_warn('ice_rst_read: you are using a simplified ice restart')
-         !
-         CALL ice_istate_init
-         CALL ice_istate( nit000, Kbb, Kmm, Kaa )
-         !
-         IF( .NOT.ln_iceini .OR. .NOT.ln_iceini_file ) &
-            &   CALL ctl_stop('STOP', 'ice_rst_read: you need ln_ice_ini=T and ln_iceini_file=T')
-         !
-      ENDIF
+#if defined key_agrif
+      ENDIF
+#endif
 
    END SUBROUTINE ice_rst_read
