
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C*****************************
C**     LSM_SELECT_PKPL     **
C*****************************
C
C
CD-Routine: Select packs and plates - LSM_SELECT_PKPL
C This routine is used to select the packs and plates for which data are
C to be retrieved from the LIRL. This must be called prior to using routines
C such as LSM_NUM_NEXT or LSM_NEXT_REFLN and the LSM service routines
C LSM_NEXT_REFOBS. After calling this routine, the selection may be
C modified using LSM_ADD_PKPL or LSM_CLR_PKPL.  This routine
C overrides any previous selections. Remember also to select
C the required reflection classes using LSM_SELECT_SCREFS. Note that packs
C defined via LSM_OMIT will always be omitted.
CD-end
CD-Fortran:
      SUBROUTINE LSM_SELECT_PKPL (IPACK, IPLATE)
CD-end
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Select Packs and Plates for retrieving data from LIRL
C
C Author:  Steffi Arzt, John Campbell, July 1997
C
C Arguments:
C
C
      INTEGER IPACK
      INTEGER IPLATE
C
CD-Parameters:
C  IPACK       i (R)   No. of pack to select (0 = all packs)
C  IPLATE      i (R)   No. of plate to select (0 = all plates)
CD-end
C
C Implementation note: Sets 'select required' flag
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
      DO 50 IPK = 1, MAXPACK
         DO 40 IPL = 1, MAXPLATES
            PKPL_USE(IPK,IPL) = .FALSE.
 40      CONTINUE
 50   CONTINUE

      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_TOPLIRL
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
