      SUBROUTINE HYDROFRACTURE1(CMARK,DRAIN,ICE,STRESS,ROWS,COLS,
     &WAT_DEP,SURF,DEM,RUNOFF,CREV_DEP,TOTAL_DRAIN,SSX,X_L,Y_L,SUML)

      ! THIS SUBROUTINE SIMULATES HYDROFRACTURE FOR LAKES AS WELL AS
      ! NON-LAKE AREAS

      ! DESCRIPTION OF VARIABLES:

      ! CMARK: SHOWS 1 FOR CREVASSED CELL AND 0 FOR NON CREVASSED CELL.
      ! UPDATED EVERY TIMESTEP IN THE CREV_CELLS1.F SUBROUTINE. REMAINS
      ! UNMODIFIED IN THIS SUBROUTINE

      ! DRAIN: SHOWS 1 FOR ALL THE LAKE CELLS THAT HAVE DRAINED AND 0
      ! OTHERWISE. REMAINS UNMODIFIED IN THIS SUBROUTINE

      ! ICE: CONTAINS ICE THICKNESS (IN METERS) FOR EVERY GRID CELL.
      ! REMAINS UNMODIFIED IN THIS SUBROUTINE

      ! STRESS: CONTAINS STRESS (IN kPa) FOR EVERY GRID CELL. REMAINS
      ! UNMODIFIED IN THIS SUBROUTINE

      ! ROWS,COLS: ROWS AND COLUMNS OF THE STUDY AREA. REMAINS
      ! UNMODIFIED IN THIS SUBROUTINE

      ! WAT_DEP: SHOWS DEPTH OF WATER (IN METERS) IN CREVASSED CELLS. FOR
      ! NON-CREVASSED CELLS, THE VALUE IS 0. REMAINS UNMODIFIED IN THIS
      ! SUBROUTINE

      ! SURF: CONTAINS SURFACE HEIGHT (IN METERS) OF EVERY GRID CELL.
      ! REMAINS UNMODIFIED IN THIS SUBROUTINE

      ! DEM: CONTAINS DEM SURFACE ELEVATION (IN METERS) FOR EVERY GRID
      ! CELL. REMAINS UNMODIFIED IN THIS SUBROUTINE

      ! RUNOFF: CONTAINS RUNOFF MELTWATER (IN METERS) FOR EVERY GRID
      ! CELL. REMAINS UNMODIFIED IN THIS SUBROUTINE

      ! CREV_DEP: CONTAINS CREVASSE DEPTH FOR EVERY GRID CELL.
      ! UNMODIFIED IN THIS SUBROUTINE

      ! TOTAL_DRAIN: GIVES THE VOLUME OF WATER THAT DRAINS PER GRID CELL
      ! IN EVERY TIMESTEP. MODIFIED IN THIS SUBROUTINE

      ! SSX: CONSTANT

      ! X_L,Y_L: 1-D ARRAY. STORES THE NUCLEI OF THE LAKES. UNMODIFIED
      ! IN THIS SUBROUTINE

      ! SUML: GIVES VOLUME OF WATER THAT DRAINS FROM A LAKE. UNMODIFIED IN
      ! THIS SUBROUTINE

      IMPLICIT NONE

      INTEGER :: ROWS,COLS,CMARK(COLS,ROWS),DRAIN(COLS,ROWS),COUNTY,I,J
     &,I1,SSX,NUM1,MARK(COLS,ROWS),
     &MARK1(COLS,ROWS),PP,QQ,K1,K2,K3,K4,N2,ISTART,IEND,NTHREADS,
     &CHUNK,TID,OMP_GET_MAX_THREADS,OMP_GET_THREAD_NUM,X_L(SSX),
     &Y_L(SSX),I2,J2

      DOUBLE PRECISION :: ICE(COLS,ROWS),STRESS(COLS,ROWS),
     &WAT_DEP(COLS,ROWS),SURF(COLS,ROWS),DEM(COLS,ROWS),
     &RUNOFF(COLS,ROWS),CREV_DEP(COLS,ROWS),TOTAL_DRAIN(COLS,ROWS),
     &SUMNL(COLS,ROWS),SUML(COLS,ROWS),LAKE_DEPTH(COLS,ROWS),SUMR

      K1=0
      K2=0
      K3=0
      K4=0

      ! SIMULATING NON-LAKE HYDROFRACTURE

      LAKE_DEPTH=SURF-DEM
      SUML=0.
      SUMNL=0.
      TOTAL_DRAIN=0.

      CALL NON_LAKE_CREV_NEW1(CMARK,RUNOFF,STRESS,LAKE_DEPTH,CREV_DEP
     &,WAT_DEP,ICE,SUMNL,COLS,ROWS,DRAIN)

      ! SIMULATING LAKE HYDROFRACTURE

      NUM1=COUNT(X_L.NE.0) ! NO. OF LAKE PIXELS

      ISTART=1
      IEND=NUM1

      MARK=0.

      IF (NUM1.GT.0) THEN
        
      DO 130 I1=ISTART,IEND

      I=X_L(I1)
      J=Y_L(I1)
      MARK=0.
      PP=I
      QQ=J

      ! DELINEATE THE LAKE

      CALL LAKE_DEL1(PP,QQ,MARK,MARK1,SURF,DEM,K1,K2,K3,K4,COLS
     &,ROWS)

      SUMR=0.0

      ! CHECK WHETHER THE LAKE WILL DRAIN VIA HYDROFRACTURE OR NOT

      IF (SUM(MARK).GT.0) THEN

              CALL CREV_LAKE1(CMARK,DRAIN,MARK,ICE,STRESS,PP,QQ,ROWS,
     &COLS,WAT_DEP,SURF,DEM,RUNOFF,SUML,K1,K2,K3,K4,CREV_DEP)

      END IF

      MARK=0.
      MARK1=0.
      K1=0
      K2=0
      K3=0
      K4=0

130   CONTINUE

      END IF

      TOTAL_DRAIN=SUML+SUMNL ! TOTAL WATER DRAINED DUE TO HYDROFRACTURE

      ! CLEARING THE MATRICES THAT STORE DAILY DRAINAGE FROM NON-LAKE
      ! PIXELS AND LAKES

      SUMNL=0.

      RETURN

      END SUBROUTINE HYDROFRACTURE1


