Index: branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/hydrol.f90
===================================================================
--- branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/hydrol.f90	(revision 7239)
+++ branches/ORCHIDEE_2_2/ORCHIDEE/src_sechiba/hydrol.f90	(revision 7255)
@@ -415,6 +415,4 @@
   REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:,:)  :: profil_froz_hydro_ns  !! As  profil_froz_hydro per soiltile
 !$OMP THREADPRIVATE(profil_froz_hydro_ns)
-  REAL(r_std), ALLOCATABLE, SAVE, DIMENSION (:,:)    :: temp_hydro            !! Temp profile on hydrological levels
-!$OMP THREADPRIVATE(temp_hydro)
 
 
@@ -971,5 +969,4 @@
     IF (ok_freeze_cwrr) THEN
        CALL xios_orchidee_send_field("profil_froz_hydro",profil_froz_hydro)
-       CALL xios_orchidee_send_field("temp_hydro",temp_hydro)
     END IF
     CALL xios_orchidee_send_field("profil_froz_hydro_ns", profil_froz_hydro_ns)
@@ -1156,6 +1153,4 @@
     IF (ok_freeze_cwrr) THEN
        CALL histwrite_p(hist_id, 'profil_froz_hydro', kjit,profil_froz_hydro , kjpindex*nslm, indexlayer)
-       
-       CALL histwrite_p(hist_id, 'temp_hydro', kjit,temp_hydro , kjpindex*nslm, indexlayer)
     ENDIF
     CALL histwrite_p(hist_id, 'kk_moy', kjit, kk_moy,kjpindex*nslm, indexlayer) ! averaged over soiltiles
@@ -1761,8 +1756,4 @@
        IF (ier /= 0) CALL ipslerr_p(3,'hydrol_init','Problem in allocate of variable profil_froz_hydrol','','')
        profil_froz_hydro(:,:) = zero
-       
-       ALLOCATE (temp_hydro(kjpindex, nslm),stat=ier)
-       IF (ier /= 0) CALL ipslerr_p(3,'hydrol_init','Problem in allocate of variable temp_hydro','','')
-       temp_hydro(:,:) = 280.
     ENDIF
     
@@ -3829,13 +3820,8 @@
        ! 0.1 Calculate the temperature and fozen fraction at the hydrological levels
        
-       ! AD16*** This subroutine could probably be simplified massively given
-       ! that hydro and T share the same vertical discretization 
-       ! Here stempdiag is in from thermosoil and temp_hydro is out
-       CALL hydrol_calculate_temp_hydro(kjpindex, stempdiag, snow,snowdz)
-       
-       ! Calculates profil_froz_hydro_ns as a function of temp_hydro, and mc if ok_thermodynamical_freezing
+       ! Calculates profil_froz_hydro_ns as a function of stempdiag and mc if ok_thermodynamical_freezing
        ! These values will be kept till the end of the prognostic loop
        DO jst=1,nstm
-          CALL hydrol_soil_froz(nvan, avan, mcr, mcs, kjpindex,jst,njsc)
+          CALL hydrol_soil_froz(nvan, avan, mcr, mcs, kjpindex,jst,njsc,stempdiag)
        ENDDO
 
@@ -3970,6 +3956,6 @@
        !! The conductivity comes from hydrol_soil_coef and relates to the liquid phase only
        !  This seems consistent with ok_freeze
-       CALL hydrol_soil_infilt(ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, jst, njsc, flux_infilt, qinfilt_ns, ru_infilt_ns, &
-            check_infilt_ns)
+       CALL hydrol_soil_infilt(ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, jst, njsc, flux_infilt,  stempdiag, &
+	                       qinfilt_ns, ru_infilt_ns, check_infilt_ns)
        ru_ns(:,jst) = ru_infilt_ns(:,jst) 
 
@@ -4646,7 +4632,7 @@
 
        !! 8.2 Since we estimate bare soile evap for the next time step, we update profil_froz_hydro and mcl
-       !     (effect of mc only, the change in temp_hydro is neglected)
-       IF ( ok_freeze_cwrr ) CALL hydrol_soil_froz(nvan, avan, mcr, mcs,kjpindex,jst,njsc)
-        DO jsl = 1, nslm
+       !     (effect of mc only, the change in stempdiag is neglected)
+       IF ( ok_freeze_cwrr ) CALL hydrol_soil_froz(nvan, avan, mcr, mcs,kjpindex,jst,njsc,stempdiag)
+       DO jsl = 1, nslm
           DO ji =1, kjpindex
              mcl(ji,jsl,jst)= MIN( mc(ji,jsl,jst), mcr(ji) + &
@@ -4936,5 +4922,6 @@
 !_ hydrol_soil_infilt
 
-  SUBROUTINE hydrol_soil_infilt(ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, ins, njsc, flux_infilt, qinfilt_ns, ru_infilt, check)
+  SUBROUTINE hydrol_soil_infilt(ks, nvan, avan, mcr, mcs, mcfc, mcw, kjpindex, ins, njsc, flux_infilt, stempdiag, &
+                                qinfilt_ns, ru_infilt, check)
 
     !! 0. Variable and parameter declaration
@@ -4956,4 +4943,5 @@
     REAL(r_std), DIMENSION (kjpindex), INTENT (in)    :: flux_infilt     !! Water to infiltrate
                                                                          !!  @tex $(kg m^{-2})$ @endtex
+    REAL(r_std),DIMENSION (kjpindex,nslm), INTENT (in):: stempdiag       !! Diagnostic temp profile from thermosoil									 
     !! 0.2 Output variables
     REAL(r_std), DIMENSION(kjpindex,nstm), INTENT(out) :: check       !! delta SM - flux (mm/dt_sechiba)
@@ -5022,5 +5010,5 @@
 
           IF (ok_freeze_cwrr) THEN
-             IF (temp_hydro(ji, jsl) .LT. ZeroCelsius) THEN
+             IF (stempdiag(ji, jsl) .LT. ZeroCelsius) THEN
                 k_m = k(ji,jsl)
              ENDIF
@@ -5782,5 +5770,5 @@
 !_ hydrol_soil_froz
  
-  SUBROUTINE hydrol_soil_froz(nvan, avan, mcr, mcs, kjpindex,ins,njsc)
+  SUBROUTINE hydrol_soil_froz(nvan, avan, mcr, mcs, kjpindex,ins,njsc,stempdiag)
 
     IMPLICIT NONE
@@ -5798,4 +5786,5 @@
     REAL(r_std),DIMENSION (kjpindex), INTENT (in)     :: mcr              !! Residual volumetric water content (m^{3} m^{-3})
     REAL(r_std),DIMENSION (kjpindex), INTENT (in)     :: mcs              !! Saturated volumetric water content (m^{3} m^{-3})
+    REAL(r_std),DIMENSION (kjpindex,nslm), INTENT (in):: stempdiag        !! Diagnostic temp profile from thermosoil
 
     !! 0.2 Output variables
@@ -5829,9 +5818,9 @@
              IF ((.NOT. ok_thermodynamical_freezing).OR.(mc(ji,jsl, ins).LT.(mcr(ji)+min_sechiba))) THEN
                 ! Linear soil freezing or soil moisture below residual
-                IF (temp_hydro(ji, jsl).GE.(ZeroCelsius+fr_dT/2.)) THEN
+                IF (stempdiag(ji, jsl).GE.(ZeroCelsius+fr_dT/2.)) THEN
                    x=1._r_std
-                ELSE IF ( (temp_hydro(ji,jsl) .GE. (ZeroCelsius-fr_dT/2.)) .AND. &
-                     (temp_hydro(ji,jsl) .LT. (ZeroCelsius+fr_dT/2.)) ) THEN 
-                   x=(temp_hydro(ji, jsl)-(ZeroCelsius-fr_dT/2.))/fr_dT
+                ELSE IF ( (stempdiag(ji,jsl) .GE. (ZeroCelsius-fr_dT/2.)) .AND. &
+                     (stempdiag(ji,jsl) .LT. (ZeroCelsius+fr_dT/2.)) ) THEN 
+                   x=(stempdiag(ji, jsl)-(ZeroCelsius-fr_dT/2.))/fr_dT
                 ELSE 
                    x=0._r_std
@@ -5839,11 +5828,11 @@
              ELSE IF (ok_thermodynamical_freezing) THEN
                 ! Thermodynamical soil freezing
-                IF (temp_hydro(ji, jsl).GE.(ZeroCelsius+fr_dT/2.)) THEN
+                IF (stempdiag(ji, jsl).GE.(ZeroCelsius+fr_dT/2.)) THEN
                    x=1._r_std
-                ELSE IF ( (temp_hydro(ji,jsl) .GE. (ZeroCelsius-fr_dT/2.)) .AND. &
-                     (temp_hydro(ji,jsl) .LT. (ZeroCelsius+fr_dT/2.)) ) THEN
+                ELSE IF ( (stempdiag(ji,jsl) .GE. (ZeroCelsius-fr_dT/2.)) .AND. &
+                     (stempdiag(ji,jsl) .LT. (ZeroCelsius+fr_dT/2.)) ) THEN
                    ! Factor 2.2 from the PhD of Isabelle Gouttevin
                    x=MIN(((mcs(ji)-mcr(ji)) &
-                        *((2.2*1000.*avan(ji)*(ZeroCelsius+fr_dT/2.-temp_hydro(ji, jsl)) &
+                        *((2.2*1000.*avan(ji)*(ZeroCelsius+fr_dT/2.-stempdiag(ji, jsl)) &
                         *lhf/ZeroCelsius/10.)**nvan(ji)+1.)**(-m)) / &
                         (mc(ji,jsl, ins)-mcr(ji)),1._r_std)                
@@ -6645,87 +6634,4 @@
   END SUBROUTINE hydrol_alma
   !
-
-
-!! ================================================================================================================================
-!! SUBROUTINE   : hydrol_calculate_temp_hydro
-!!
-!>\BRIEF         Calculate the temperature at hydrological levels  
-!!
-!! DESCRIPTION  : None
-!!
-!! RECENT CHANGE(S) : None
-!!
-!! MAIN OUTPUT VARIABLE(S) : 
-!!
-!! REFERENCE(S) : 
-!!
-!! FLOWCHART    : None
-!! \n
-!_ ================================================================================================================================
-
-
-  SUBROUTINE hydrol_calculate_temp_hydro(kjpindex, stempdiag, snow,snowdz)
-
-    !! 0.1 Input variables
-
-    INTEGER(i_std), INTENT(in)                             :: kjpindex 
-    REAL(r_std),DIMENSION (kjpindex,nslm), INTENT (in)     :: stempdiag
-    REAL(r_std),DIMENSION (kjpindex), INTENT (in)          :: snow
-    REAL(r_std),DIMENSION (kjpindex,nsnow), INTENT (in)    :: snowdz
-
-
-    !! 0.2 Local variables
-    
-    INTEGER jh, jsl, ji
-    REAL(r_std) :: snow_h
-    REAL(r_std)  :: lev_diag, prev_diag, lev_prog, prev_prog
-    REAL(r_std), DIMENSION(nslm,nslm) :: intfactt
-    
-    
-    DO ji=1,kjpindex
-       !The snow pack is above the surface soil in the new snow model.
-       snow_h=0
-              
-       intfactt(:,:)=0.
-       prev_diag = snow_h
-       DO jh = 1, nslm
-          IF (jh.EQ.1) THEN
-             lev_diag = zz(2)/1000./2.+snow_h
-          ELSEIF (jh.EQ.nslm) THEN
-             lev_diag = zz(nslm)/1000.+snow_h
-             
-          ELSE
-             lev_diag = zz(jh)/1000. &
-                  & +(zz(jh+1)-zz(jh))/1000./2.+snow_h
-             
-          ENDIF
-          prev_prog = 0.0
-          DO jsl = 1, nslm
-             lev_prog = diaglev(jsl)
-             IF ((lev_diag.GT.diaglev(nslm).AND. &
-                  & prev_diag.LT.diaglev(nslm)-min_sechiba)) THEN
-                lev_diag=diaglev(nslm)          
-             ENDIF
-             intfactt(jh,jsl) = MAX(MIN(lev_diag,lev_prog)-MAX(prev_diag, prev_prog),&
-                  & 0.0)/(lev_diag-prev_diag)
-             prev_prog = lev_prog
-          ENDDO
-          IF (lev_diag.GT.diaglev(nslm).AND. &
-               & prev_diag.GE.diaglev(nslm)-min_sechiba) intfactt(jh,nslm)=1.
-          prev_diag = lev_diag
-       ENDDO
-    ENDDO
-    
-    temp_hydro(:,:)=0.
-    DO jsl= 1, nslm
-       DO jh= 1, nslm
-          DO ji = 1, kjpindex
-             temp_hydro(ji,jh) = temp_hydro(ji,jh) + stempdiag(ji,jsl)*intfactt(jh,jsl)
-          ENDDO
-       ENDDO
-    ENDDO
-    
-  END SUBROUTINE hydrol_calculate_temp_hydro
-
 
 !! ================================================================================================================================
