
C LAST UPDATE:
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
C
C**************************
C**     LSM_ADD_PKPL     **
C**************************
C
C
CD-Routine: Add packs and plates to selection - LSM_ADD_PKPL
C This routine is used to add further packs/plates to the selection
C made by LSM_SELECT_PKPL. Note that packs defined via LSM_OMIT will 
C always be omitted.
CD-end
CD-Fortran:
      SUBROUTINE LSM_ADD_PKPL (IPACK, IPLATE)
CD-end
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Add Packs and Plates to Selectio
C
C Author:  Steffi Arzt, John Campbell, July 1997
C
C Arguments:
C
      INTEGER IPACK
      INTEGER IPLATE
C
CD-Parameters:
C  IPACK       i (R)   No. of pack to add to the current packs/plates
C                      selection (0 = all packs)
C  IPLATE      i (R)   No. of plate to add to the current packs/plates
C                      selection (0 = all plates)
CD-end
C
C Implementation note: Sets 'select required' flag
C
C
C====== PARAMETERS:
C
      INCLUDE 'limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'use_reflns.finc'
      INCLUDE 'lsm_flags.finc'
C
C====== LOCALS:
C
      INTEGER IPK
      INTEGER IPL
      INTEGER IPK_MIN
      INTEGER IPK_MAX
      INTEGER IPL_MIN
      INTEGER IPL_MAX

C     INTEGER IPK              ! Packs loop counter
C     INTEGER IPL              ! Plates loop counter
C     INTEGER IPK_MIN          ! Minimum pack no. for loop
C     INTEGER IPK_MAX          ! Maximum pack no. for loop
C     INTEGER IPL_MIN          ! Minimum plate no. for loop
C     INTEGER IPL_MAX          ! Maximum plate no. for loop
C
C-------------------------------------------------------------------------------
C

      IF (IPACK.GT.MAXPACK.OR.IPLATE.GT.MAXPLATES) RETURN
C
C====== Note: Use MAXPACK & MAXPLATES here and check against actual limits
C             later (e.g. in LSM_TOP_LIRL
C
      IF (IPACK.GT.0) THEN
         IPK_MIN = IPACK
         IPK_MAX = IPACK
      ELSE
         IPK_MIN = 1
         IPK_MAX = MAXPACK
      END IF
      IF (IPLATE.GT.0) THEN
         IPL_MIN = IPLATE
         IPL_MAX = IPLATE
      ELSE
         IPL_MIN = 1
         IPL_MAX = MAXPLATES
      END IF

      DO 200 IPK = IPK_MIN, IPK_MAX
         IF (OMIT(IPK)) GO TO 200
         DO 100 IPL = IPL_MIN, IPL_MAX
            PKPL_USE(IPK,IPL) = .TRUE.
 100     CONTINUE
 200  CONTINUE
      SELECT_REQUIRED = .TRUE.
      RETURN
      END
