
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C******************************
C**      LSM_OMIT_LSP        **
C******************************
C
CD-Routine: Omit packs from processing - LSM_OMIT_LSP
C This routine is equivalent to a call to LSM_OMIT with its parameter 
C derived from the LSP parameter set.
CD-end
CD-Fortran:
      SUBROUTINE  LSM_OMIT_LSP (IERR, ERRSTR)
CD-end
C
      INCLUDE 'implicit_none.finc'
C
      INTEGER IERR
      CHARACTER*(*) ERRSTR
C
CD-Parameters:
C  IERR      i (W)   Error flag = 0 OK
C                               = 1 Error
C  ERRSTR    c (W)   Error string if IERR is non-zero (max 80 characters)
CD-end

C
C====== PARAMETERS:
C
      INCLUDE 'limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'use_reflns.finc'
      INCLUDE 'lsm_flags.finc'
C
C====== FUNCTION TYPES:
C

      INTEGER KDMSTR
      INTEGER LENSTR
      INTEGER NXTTOK
      INTEGER LDM_INTFP
C
C====== LOCALS:
C
      INTEGER KERR
      INTEGER I, K, IL, NI, NDIG
      INTEGER IDUM(2)
      INTEGER IV(MAXPACK), NX(MAXPACK), M1(MAXPACK), M2(MAXPACK) 
      INTEGER ISTAT
      INTEGER ITYP
      INTEGER MAXE
      REAL FP
      CHARACTER*200 VALSTR
      CHARACTER*80 STR
C
C-------------------------------------------------------------------------------
C
      MAXE = 80
      IERR = 0

      CALL LSM_OMIT (0, IDUM)

      STR = 'OMIT'
      CALL KDMF_GETVALSTR (KINDX, KDMSTR(STR), LENSTR(STR), 1, 1, 
     +                 200, KDMSTR(VALSTR), ISTAT,
     +                 ITYP, KDMSTR(ERRSTR), MAXE, KERR)
      IF (KERR.NE.0) GOTO 810 

      IL = 0
      DO 10 I = 1, MAXPACK
         NX(I) =  NXTTOK (VALSTR,' ,-', IL, M1(I), M2(I))
         IF (NX(I).EQ.-1) GO TO 20
         IF (I.EQ.1.AND.NX(1).EQ.0) THEN
            IERR = 1
            ERRSTR = 'No image/pack to ''LSM_OMIT'' given'
            RETURN
         END IF
         NI = LDM_INTFP(VALSTR(M1(I):M2(I)),FP,IV(I),NDIG)
         IF (NI.EQ.0.OR.NI.EQ.2) THEN
               IERR = 1
               ERRSTR = 'Syntax error or floating point number'//
     +                   'for packs in ''LSM_OMIT'' statement' 
               RETURN
         END IF
         IF(NI.EQ.-1) GO TO 10
         IF (IV(I).GT.MAXPACK.OR.IV(I).LT.1) THEN
            IERR = 1
            ERRSTR = 'Pack number zero or negative or'//
     +               'greater than MAXPACK'
            RETURN 
         END IF
         IF (I.EQ.1) CALL LSM_CLR_RFLAG (2, IV(1), 0, 0)    
         IF (I.GT.1) THEN
            IF (INDEX(VALSTR(M2(I-1):M1(I)),'-').NE.0) THEN
               DO 30 K = IV(I-1), IV(I)
                  OMIT(K) = .TRUE.
 30            CONTINUE
            ELSE
               OMIT(IV(I)) = .TRUE.
            END IF
         END IF
 10   CONTINUE   
 20   CONTINUE
      RETURN

 810  IERR = 1

      RETURN

      END
