      SUBROUTINE HYDRL6U(GT,RUNOFF,SNO,WF,WL,C,DELT,EVAPF,EVAPR,QFN,
     1                  GC,IL,JLAT,WCAP,GTLAST,SNOFAC)
C.......................................................................
C     * MAY 20/95 - M.LAZARE. ADD DIAGNOSTIC CALCULATION OF QFN.
C     * CCRN- DEC 12/79. R. LAPRISE AND N. MCFARLANE. PREVIOUS (GCMII)
C     *                  VERSION HYDROL5.   
C
C     * PURPOSE 1. ADJUST THE GROUND TEMPERATURE DUE TO PHASE CHANGE OF 
C                  GROUND WATER/SNOW. 
C               2. UPDATE WF,WL, SNO DUE TO EVAPORATION/DEPOSITION AND
C                  MELTING/FREEZING.
C               3. CALCULATION EVAPORATION OF SNOW. 
C     * DICTIONARY OF VARIABLES.
C 
C I   C       HEAT CAPACITY OF GROUND(J M-2 K-1)
C I   DELT    TIME STEP OF THE MODEL
C I   EVAPF   RATIO OF ACTUAL EVAPORATION RATE TO ITS POTENTIAL 
C I   EVAPR   EVAPORATION RATE (KG M-2 S-1  I.E.  MM S-1) 
C I   GC      GROUND COVER (TYPE) 1.=PACK ICE 
C                                 0.=OPEN WATER 
C                                -1.=LAND 
C I/O GT      GROUND TEMP. AT TIME T+DELT, BEFORE(I) AND AFTER(O) 
C             MELTING/FREEZING
C I   GTLAST  GT AT TIME T
C IC  HS      LATENT HEAT OF SUBLIMATION AT 0C (J/KG) 
C IC  HV      LATENT HEAT OF VAPORIZATION AT 0C(J/KG) 
C I   IL      LONGITUDE INDEX 
C O   QFN     EVAPORATION OF SNOW (KG/M2-S)
C I   JLAT    LATITUDE INDEX
C I/O RUNOFF  RUNOFF (MM I.E. KG/M2)
C I/O SNO     AMOUNT OF SNOW ON GROUND (KG/M2 I.E.
C             MM OF WATER EQUIVALENT OR CM OF SNOW) 
C I   SNOFAC  FRACTIONAL SNOW COVERAGE
C IC  TFREZ   FREEZING TEMPERATURE OF WATER 
C IC  WCAP    MAX.GROUND WATER HOLDING CAPACITY(MM I.E. KG/M2)
C I/O WF      FRACTION OF THE GROUND WATER HOLDING
C             CAPACITY FILLED BY WATER IN FROZEN FORM 
C I/O WL      FRACTION OF THE GROUND WATER HOLDING
C             CAPACITY FILLED BY WATER IN LIQUID FORM 
C     WTRANS  AMOUNT OF WATER FREEZING/MELTING(MM OF WATER I.E. KG/M2)
C.......................................................................
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)

      COMMON /PARAM1/PI,RVORD,TFREZ,HS,HV,DAYLNT
      COMMON /PARAM3/CSNO,CPACK,GTFSW,RKHI,SBC,SNOMAX 
C-----------------------------------------------------------------------
      IF(GC.EQ.0.)RETURN
C     * ACCOUNT FOR EVAPORATION,SUBLIMATION,DEPOSITION
C       OVER LAND.
C       --------- 
      IF(GC.EQ.1.)GO TO 250 
      IF(EVAPF.EQ.0.)GO TO 200
C 
C     * EVAPORATE SNOW. 
C     * NOTE: TOTAL EVAPORATIVE FLUX PARTITIONED BETWEEN LAND AND SNOW.
C
      QFN=MIN(EVAPR*SNOFAC/EVAPF,SNO/DELT)
      SNO=SNO- DELT*EVAPR*SNOFAC/EVAPF
C 
C     * EVAPORATE FROZEN GROUND WATER.
      IF(GTLAST.GT.TFREZ)GO TO 100
      WF=WF-(DELT*EVAPR/WCAP)*(EVAPF-SNOFAC)/EVAPF
      GO TO 200 
C 
C     * EVAPORATE LIQUID GROUND WATER.
  100 CONTINUE
      WL=WL-(DELT*EVAPR/WCAP)*(EVAPF-SNOFAC)/EVAPF
C 
C     * PRINT WARNING MESSAGE, IF NECESSARY.
  200 CONTINUE
C     * ENSURE SNO IS GREATER THAN ZERO, IF NOT BORROW FROM WF. 
      SNOP=MAX(0.,SNO)
      WF=WF -(SNOP-SNO)/WCAP
      SNO=SNOP
C     * ENSURE WL IS GREATER THAN ZERO, IF NOT BORROW FROM WF.
      WLP=MAX(0.,WL)
      WF=WF-(WLP-WL)*HV/HS
      WL=WLP
C     * ENSURE WF IS GREATER THAN ZERO, IF NOT BORROW FROM WL.
      WFP=MAX(0.,WF)
      WL=WL-(WFP-WF)*HS/HV
      WF=WFP
      IF(WL.LT.0.)WRITE(6,6001)IL,JLAT,WF,WL,EVAPF,SNOFAC,EVAPR,SNO,
     1                         GTLAST 
      IF(WL.LT.0.)WL=0. 
C 
C     * ACCOUNT FOR DEPOSITION, CHECK FOR RUNOFF. 
C 
      WTOT=WF+WL
      WTOT1=MIN(1.,WTOT)
      WL=WTOT1-WF 
      RUNOFF=RUNOFF+(WTOT-WTOT1)*WCAP 
      GO TO 300 
C 
C     * OVER PACK ICE.
C       ------------- 
  250 SNO=MAX(0.,SNO-EVAPR*DELT)
      GO TO 500 
C-----------------------------------------------------------------------
C     * ADJUSTEMENT OF GT DUE TO MELTING/FREEZING OVER LAND.
  300 CONTINUE
C 
C     * FREEZING. 
C       --------
      IF(GT.GE.TFREZ)GO TO 400
C 
C     * HEAT REQUIRED TO RAISE GT TO TFREZ. 
C 
      HADJ=C*(TFREZ-GT) 
C 
C     * HEAT AVAILABLE BY FREEZING ALL WL.
C 
      HFREZ=(HS-HV)*WL*WCAP 
C 
C     * ADJUSTEMENT.
C 
      HADJ=MIN(HADJ,HFREZ)
      GT=GT+HADJ/C
      WTRANS=HADJ/(HS-HV) 
      WL=WL-WTRANS/WCAP 
      WF=WF+WTRANS/WCAP 
      GO TO 900 
C 
C     * MELTING.
C       ------- 
  400 IF(GT.EQ.TFREZ)GO TO 900
C 
C     * HEAT AVAILABLE BY COOLING GT TO TFREZ.
C 
      HADJ=C*(GT-TFREZ) 
C 
C     * HEAT REQUIRED TO MELT ALL SNO,WF. 
C 
      HMELT=(HS-HV)*(SNO+WF*WCAP) 
      IF(HMELT.EQ.0.)GO TO 900
C 
C     * ADJUSTEMENT.
C 
      HADJ=MIN(HADJ,HMELT)
      GT=GT-HADJ/C
      WTRANS=HADJ/(HS-HV) 
      WL=WL+WTRANS/WCAP 
      SNO=SNO - SNOFAC*WTRANS 
      WF =WF  -(1.-SNOFAC)*WTRANS/WCAP
C 
C     * ENSURE PROPER PARTITIONING BETWEEN SNO AND WF.
C 
      WFP=MAX(0.,WF)
      SNO=SNO-(WFP-WF)*WCAP 
      WF=WFP
      SNOP=MAX(0.,SNO)
      WF=WF-(SNOP-SNO)/WCAP 
      SNO=SNOP
C 
C     * CHECK FOR RUNOFF. 
      WTOT=WF+WL
      WTOT1=MIN(1.,WTOT)
      WL=WTOT1-WF 
      RUNOFF=RUNOFF+(WTOT-WTOT1)*WCAP 
      GO TO 900 
C 
C     * OVER PACK ICE.
C       ------------- 
  500 IF(GT.LE.TFREZ)GO TO 900
      RUNOFF=RUNOFF+C*(GT-TFREZ)/(HS-HV)
      GT=TFREZ
  900 CONTINUE
C-----------------------------------------------------------------------
6001  FORMAT(' *** HYDROL5 *** EVAPORATION PROBLEM AT (',2I3,
     1       '),(WF,WL)=',  2E13.5,',(EVAPF,SNOFAC)=',2E13.5,/, 
     2       ' EVAPR=',E13.5,' MM/S', ',SNO=',E13.5, ',GTLAST=',E13.5)
      RETURN
      END 
