Index: /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/hydrol.f90
===================================================================
--- /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/hydrol.f90	(revision 7636)
+++ /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/hydrol.f90	(revision 7637)
@@ -1983,4 +1983,16 @@
        CALL restget_p (rest_id, 'moistc', nbp_glo, nslm , nstm, kjit, .TRUE., mc, "gather", nbp_glo, index_g)
 
+       IF ( ALL(mc(:,:,:) == val_exp) ) THEN
+        ! moistc was not found in restart file. Try to read moistc_1, moistc_2 and moistc_3 as in ORCHIDEE_2_0
+          WRITE(numout,*) 'moistc was not found in restart file. Try to read moistc_1, moistc_2 and moistc_3 as in ORCHIDEE_2_0'
+          DO jst=1,nstm
+             ! var_name= "mc_1" ... "mc_3"
+             WRITE (var_name,"('moistc_',I1)") jst
+             IF (is_root_prc) CALL ioconf_setatt_p('LONG_NAME',var_name)
+             CALL restget_p (rest_id, var_name, nbp_glo, nslm , 1, kjit, .TRUE., mc(:,:,jst), "gather", nbp_glo, index_g)
+          END DO
+       END IF
+
+
        IF (ok_nudge_mc) THEN
           CALL ioconf_setatt_p('LONG_NAME','Soil moisture read from nudging file')
@@ -2007,9 +2019,34 @@
       
        CALL restget_p (rest_id, 'moistcl', nbp_glo, nslm , nstm, kjit, .TRUE., mcl, "gather", nbp_glo, index_g)
-       !
+       IF ( ALL(mcl(:,:,:) == val_exp) ) THEN
+          ! moistcl was not found in restart file. Try to read moistcl_1, moistcl_2 and moistcl_3 as in ORCHIDEE_2_0
+          WRITE(numout,*) 'moistcl was not found in restart file. Try to read moistcl_1, moistcl_2 and moistcl_3 as in ORCHIDEE_2_0'
+          DO jst=1,nstm
+             ! var_name= "mcl_1" ... "mcl_3"
+             WRITE (var_name,"('moistcl_',I1)") jst
+             IF (is_root_prc) CALL ioconf_setatt_p('LONG_NAME',var_name)
+             CALL restget_p (rest_id, var_name, nbp_glo, nslm , 1, kjit, .TRUE., mcl(:,:,jst), "gather", nbp_glo, index_g)
+          END DO
+       END IF
+
+
        CALL ioconf_setatt_p('UNITS', '-')
        CALL ioconf_setatt_p('LONG_NAME','us')
        CALL restget_p (rest_id, 'us', nbp_glo, nvm, nstm, nslm, kjit, .TRUE., us, "gather", nbp_glo, index_g)
-       !
+       IF ( ALL(us(:,:,:,:) == val_exp) ) THEN
+          ! us was not found in restart file. Try to read us_1_01, us_1_02,.. as in ORCHIDEE_2_0
+          WRITE(numout,*) 'us was not found in restart file. Try to read us_1_01, us_1_02,.. as in ORCHIDEE_2_0'
+          DO jst=1,nstm
+             DO jsl=1,nslm
+                ! var_name= "us_1_01" ... "us_3_11"
+                WRITE (var_name,"('us_',i1,'_',i2.2)") jst,jsl
+                IF (is_root_prc) CALL ioconf_setatt_p('LONG_NAME',var_name)
+                CALL restget_p (rest_id, var_name, nbp_glo, nvm, 1, kjit, .TRUE., us(:,:,jst,jsl), "gather", nbp_glo, index_g)
+             END DO
+          END DO
+       END IF
+
+
+
        var_name= 'free_drain_coef'
        CALL ioconf_setatt_p('UNITS', '-')
Index: /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/slowproc.f90
===================================================================
--- /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/slowproc.f90	(revision 7636)
+++ /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/slowproc.f90	(revision 7637)
@@ -1324,4 +1324,16 @@
     CALL ioconf_setatt_p('LONG_NAME','Fraction of leaves in leaf age class ')
     CALL restget_p (rest_id, 'frac_age', nbp_glo, nvm, nleafages, kjit, .TRUE.,frac_age, "gather", nbp_glo, index_g)
+    IF (ALL( frac_age(:,:,:) .EQ. val_exp) ) THEN
+       ! frac_age was not found in restart file. Try to read frac_age_1, frac_age_2,... as in ORCHIDEE_2_0
+       WRITE(numout, *)'frac_age was not found in restart file. Try to read frac_age_1, frac_age_2,... as in ORCHIDEE_2_0'
+       DO jf = 1, nleafages
+          ! variable name is somewhat complicated as ioipsl does not allow 3d variables for the moment...
+          WRITE(laistring,'(i4)') jf
+          laistring=ADJUSTL(laistring)
+          var_name='frac_age_'//laistring(1:LEN_TRIM(laistring))
+          CALL restget_p (rest_id, var_name, nbp_glo, nvm, 1, kjit, .TRUE.,frac_age(:,:,jf), "gather", nbp_glo, index_g)
+       ENDDO
+
+    END IF
 
     !! 3. Some other initializations
@@ -1483,7 +1495,8 @@
           ! Case impsoilt=false and impveg=true
 
-          IF ( MINVAL(clayfraction) .EQ. MAXVAL(clayfraction) .AND. MAXVAL(clayfraction) .EQ. val_exp .OR. &
-               MINVAL(sandfraction) .EQ. MAXVAL(sandfraction) .AND. MAXVAL(sandfraction) .EQ. val_exp .OR. &
-               MINVAL(njsc) .EQ. MAXVAL(njsc) .AND. MAXVAL(njsc) .EQ. undef_int ) THEN
+          IF ( ( ( MINVAL(clayfraction) .EQ. MAXVAL(clayfraction) ) .AND. (MAXVAL(clayfraction) .EQ. val_exp ) ) .OR. &
+               ( ( MINVAL(sandfraction) .EQ. MAXVAL(sandfraction) ) .AND. (MAXVAL(sandfraction) .EQ. val_exp ) ) .OR. &
+               ( ( MINVAL(siltfraction) .EQ. MAXVAL(siltfraction) ) .AND. (MAXVAL(siltfraction) .EQ. val_exp ) ) .OR. &
+               ( ( MINVAL(njsc) .EQ. MAXVAL(njsc) ) .AND. ( MAXVAL(njsc) .EQ.undef_int ) ) ) THEN
              
              CALL slowproc_soilt(kjpindex, lalo, neighbours, resolution, contfrac, soilclass, &
@@ -1637,7 +1650,9 @@
     
     ! Initialize clayfraction and njsc if not found in restart file and not already initialized using impveg
-    IF ( MINVAL(clayfraction) .EQ. MAXVAL(clayfraction) .AND. MAXVAL(clayfraction) .EQ. val_exp .OR. &
-         MINVAL(sandfraction) .EQ. MAXVAL(sandfraction) .AND. MAXVAL(sandfraction) .EQ. val_exp .OR. &
-         MINVAL(njsc) .EQ. MAXVAL(njsc) .AND. MAXVAL(njsc) .EQ. undef_int ) THEN
+    IF ( ( ( MINVAL(clayfraction) .EQ. MAXVAL(clayfraction) ) .AND. (MAXVAL(clayfraction) .EQ. val_exp ) ) .OR. &
+         ( ( MINVAL(sandfraction) .EQ. MAXVAL(sandfraction) ) .AND. (MAXVAL(sandfraction) .EQ. val_exp ) ) .OR. &
+         ( ( MINVAL(siltfraction) .EQ. MAXVAL(siltfraction) ) .AND. (MAXVAL(siltfraction) .EQ. val_exp ) ) .OR. &
+         ( ( MINVAL(njsc) .EQ. MAXVAL(njsc) ) .AND. ( MAXVAL(njsc) .EQ. undef_int ) ) ) THEN
+
        
        IF (printlev_loc>=4) WRITE (numout,*) 'clayfraction or njcs were not in restart file, call slowproc_soilt'
Index: /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/thermosoil.f90
===================================================================
--- /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/thermosoil.f90	(revision 7636)
+++ /branches/ORCHIDEE_3_CMIP6/ORCHIDEE/src_sechiba/thermosoil.f90	(revision 7637)
@@ -536,5 +536,13 @@
     CALL ioconf_setatt_p('UNITS', 'K')
     CALL ioconf_setatt_p('LONG_NAME','Soil Temperature profile')
-    CALL restget_p (rest_id, 'ptn', nbp_glo, ngrnd, nvm, kjit, .TRUE., ptn, "gather", nbp_glo, index_g)
+    CALL restget_p (rest_id, 'ptn_pft', nbp_glo, ngrnd, nvm, kjit, .TRUE., ptn, "gather", nbp_glo, index_g)
+    IF (ALL(ptn(:,:,:)==val_exp)) THEN
+       ! ptn_pft was not found in restart file. Try to read ptn as in ORCHIDEE_2_0
+       WRITE(numout,*) 'ptn_pft was not found in restart file. Try to read ptn as in ORCHIDEE_2_0'
+       CALL restget_p (rest_id, 'ptn', nbp_glo, ngrnd, 1, kjit, .TRUE., ptn(:,:,1), "gather", nbp_glo, index_g)
+       DO jv = 2,nvm
+          ptn(:,:,jv)=ptn(:,:,1)
+       ENDDO
+    END IF
 
     ! Initialize ptn if it was not found in restart file
@@ -547,5 +555,5 @@
           DO jv = 2,nvm
              ptn(:,:,jv)=ptn(:,:,1)
-          ENDDO ! jv = 1,nvm
+          ENDDO
        ELSE
           ! Initialize ptn with a constant value which can be set in run.def
@@ -996,5 +1004,5 @@
     IF (printlev>=3) WRITE (numout,*) 'Write restart file with THERMOSOIL variables'
 
-    CALL restput_p(rest_id, 'ptn', nbp_glo, ngrnd, nvm, kjit, ptn, 'scatter', nbp_glo, index_g)
+    CALL restput_p(rest_id, 'ptn_pft', nbp_glo, ngrnd, nvm, kjit, ptn, 'scatter', nbp_glo, index_g)
 
     CALL restput_p(rest_id, 'ptn_pftmean', nbp_glo, ngrnd, 1, kjit, ptn_pftmean, 'scatter', nbp_glo, index_g)
