Index: /branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/slowproc.f90
===================================================================
--- /branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/slowproc.f90	(revision 7324)
+++ /branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/slowproc.f90	(revision 7325)
@@ -935,4 +935,5 @@
     LOGICAL                                               :: found_restart     !! found_restart=true if all 3 variables veget_max, veget and 
                                                                                !! frac_nobio are read from restart file
+    LOGICAL                                               :: call_slowproc_soilt !! This variables will be true if subroutine slowproc_soilt needs to be called
     !_ ================================================================================================================================
   
@@ -1075,4 +1076,5 @@
     
     ! Below we define the soil texture of the grid-cells
+
     ! Add the soil_classif as suffix for the variable name of njsc when it is stored in the restart file. 
     IF (soil_classif == 'zobler') THEN
@@ -1084,4 +1086,9 @@
     END IF
 
+    ! The variables are read from restart file. If at least one of the related variables are not found, the 
+    ! variable call_slowproc_soilt will be true and the variables will be read and interpolated from file in 
+    ! subroutine slowproc_soilt.
+    call_slowproc_soilt=.FALSE.
+
     CALL ioconf_setatt_p('UNITS', '-')
     CALL ioconf_setatt_p('LONG_NAME','Index of soil type')
@@ -1089,4 +1096,5 @@
     IF ( ALL( tmp_real(:) .EQ. val_exp) ) THEN
        njsc (:) = undef_int
+       call_slowproc_soilt=.TRUE.
     ELSE
        njsc = NINT(tmp_real)
@@ -1094,9 +1102,13 @@
 
     ! Salma: we define restget for the 7 soil variables following clay_frac
-
+    
     var_name= 'ks'
     CALL ioconf_setatt_p('UNITS', 'mm/d')
     CALL ioconf_setatt_p('LONG_NAME','Soil saturated water content')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., ks, "gather", nbp_glo, index_g)
+    IF ( ALL(ks(:) .EQ. val_exp ) ) THEN
+       ! ks is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'mcs'
@@ -1104,4 +1116,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., mcs, "gather", nbp_glo, index_g)
+    IF ( ALL(mcs(:) .EQ. val_exp ) ) THEN
+       ! mcs is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'mcr'
@@ -1109,4 +1125,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., mcr, "gather", nbp_glo, index_g)
+    IF ( ALL(mcr(:) .EQ. val_exp ) ) THEN
+       ! mcr is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'mcfc'
@@ -1114,4 +1134,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., mcfc, "gather", nbp_glo, index_g)
+    IF ( ALL(mcfc(:) .EQ. val_exp ) ) THEN
+       ! mcfc is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'mcw'
@@ -1119,4 +1143,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., mcw, "gather", nbp_glo, index_g)
+    IF ( ALL(mcw(:) .EQ. val_exp ) ) THEN
+       ! mcw is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'nvan'
@@ -1124,4 +1152,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., nvan, "gather", nbp_glo, index_g)
+    IF ( ALL(nvan(:) .EQ. val_exp ) ) THEN
+       ! nvan is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'avan'
@@ -1129,4 +1161,8 @@
     CALL ioconf_setatt_p('LONG_NAME','')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., avan, "gather", nbp_glo, index_g)
+    IF ( ALL(avan(:) .EQ. val_exp ) ) THEN
+       ! avan is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     !end salma
@@ -1136,4 +1172,8 @@
     CALL ioconf_setatt_p('LONG_NAME','Fraction of clay in each mesh')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., clayfraction, "gather", nbp_glo, index_g)
+    IF ( ALL(clayfraction(:) .EQ. val_exp ) ) THEN
+       ! clayfraction is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     var_name= 'sand_frac'
@@ -1141,4 +1181,8 @@
     CALL ioconf_setatt_p('LONG_NAME','Fraction of sand in each mesh')
     CALL restget_p (rest_id, var_name, nbp_glo, 1, 1, kjit, .TRUE., sandfraction, "gather", nbp_glo, index_g)	
+    IF ( ALL(sandfraction(:) .EQ. val_exp ) ) THEN
+       ! sandfraction is not in restart file
+       call_slowproc_soilt=.TRUE.
+    END IF
 
     ! Calculate siltfraction not needed to be in restart file
@@ -1318,8 +1362,6 @@
        ELSE ! impveg=T and impsoil=F
           ! 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 (call_slowproc_soilt) THEN
+             ! At least one of the output variables from slowproc_soilt were not found in the restart file 
              CALL slowproc_soilt(njsc, ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, lalo, neighbours, resolution, contfrac, soilclass, &
                   clayfraction, sandfraction, siltfraction)
@@ -1328,4 +1370,5 @@
                 njsc(ji) = MAXLOC(soilclass(ji,:),1)
              ENDDO
+             call_slowproc_soilt=.FALSE.
           ENDIF
        ENDIF
@@ -1453,10 +1496,8 @@
     ENDIF
     
-    ! 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 (printlev_loc>=4) WRITE (numout,*) 'clayfraction or njcs were not in restart file, call slowproc_soilt'
+    ! Initialize clayfraction, sandfraction, njsc, ks, nvan, avan, mcr, mcs, mcfc and mcw if one of them 
+    ! were not found in restart file and not already initialized using impveg
+    IF (call_slowproc_soilt) THEN
+       IF (printlev_loc>=4) WRITE (numout,*) 'clayfraction or njcs or one of the 7 new variables were not in restart file, call slowproc_soilt'
        CALL slowproc_soilt(njsc, ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, lalo, neighbours, resolution, contfrac, soilclass, &
             clayfraction, sandfraction, siltfraction)
@@ -1466,4 +1507,5 @@
           njsc(ji) = MAXLOC(soilclass(ji,:),1)
        ENDDO
+       call_slowproc_soilt=.FALSE.
     ENDIF
 
