C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_CLR_GEN      **
C**************************
C
C
      SUBROUTINE LDM_CLR_GEN  (IPACK, IPLATE, ILEVEL)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Clear last pack/plate LRL generated flags
C
C ***** 'LDM' SERVICE ROUTINE ONLY *****
C
C Author:  John W. Campbell, July 1993
C
C Arguments:
C
      INTEGER IPACK
      INTEGER IPLATE
      INTEGER ILEVEL
C
C  IPACK     (R)   Pack number for parameter change (0=all, -1=not pack
C                  (or plate) dependent parameter)
C  IPLATE    (R)   Plate number for parameter change (0=all, -1=not plate
C                  dependent parameter)
C  ILEVEL    (R)   Flag = 1, clear flags for matrices, generate & overlaps
C                       = 2, clear flags for generate & overlaps
C                       = 3, clear flags for overlaps
C
C====== GLOBALS:
C
      INCLUDE 'ldm_lrl.finc'
C
C-------------------------------------------------------------------------------
C
C
C====== Global parameter
C
      IF (IPACK.EQ.-1.AND.IPLATE.EQ.-1) THEN
         PKOVL = -1
         PLOVL = -1
         IF (ILEVEL.GT.2) RETURN
         PKGEN = -1
         PLGEN = -1
         IF (ILEVEL.GT.1) RETURN
         PKMTX = -1
         PLMTX = -1
         RETURN
      END IF
C
C====== Pack dependent parameter
C
      IF (IPLATE.EQ.-1) THEN
         IF (IPACK.EQ.0.OR.IPACK.EQ.PKOVL) THEN
            PKOVL = -1
            PLOVL = -1
         END IF
         IF (ILEVEL.GT.2) RETURN
         IF (IPACK.EQ.0.OR.IPACK.EQ.PKGEN) THEN
            PKGEN = -1
            PLGEN = -1
         END IF
         IF (ILEVEL.GT.1) RETURN
         IF (IPACK.EQ.0.OR.IPACK.EQ.PKMTX) THEN
            PKMTX = -1
            PLMTX = -1
            RETURN
         END IF
      END IF
C
C====== Plate dependent parameter
C
      IF (IPACK.EQ.0.OR.IPLATE.EQ.0.
     +   OR.(IPACK.EQ.PKOVL.AND.IPLATE.EQ.PLOVL))THEN
         PKOVL = -1
         PLOVL = -1
      END IF
      IF (ILEVEL.GT.2) RETURN
      IF (IPACK.EQ.0.OR.IPLATE.EQ.0.
     +   OR.(IPACK.EQ.PKGEN.AND.IPLATE.EQ.PLGEN))THEN
         PKGEN = -1
         PLGEN = -1
      END IF
      IF (ILEVEL.GT.1) RETURN
      IF (IPACK.EQ.0.OR.IPLATE.EQ.0.
     +   OR.(IPACK.EQ.PKMTX.AND.IPLATE.EQ.PLMTX))THEN
         PKMTX = -1
         PLMTX = -1
         RETURN
      END IF
      RETURN
      END
