C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_NEWSTR       **
C**************************
C
CD-Routine: Define a New String Parameter - LDM_NEWSTR
C This routine is used create a new string LDM parameter to form part of
C an extended LDM parameter set.
CD-end
CD-Fortran:
      SUBROUTINE LDM_NEWSTR (KEYWORD, MINL, ITYP, ISTD, MAXLEN, 
     +                       S_DFLT, STRINGS, NUMS, LENS, ICHK, 
     +                       MATCH, IERR)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Define a new integer LDM parameter
C
C Author:  John W. Campbell, December 1995
C
C Arguments:
C
      CHARACTER*(*) KEYWORD
      INTEGER MINL
      INTEGER ITYP
      INTEGER ISTD
      INTEGER MAXLEN
      CHARACTER*(*) S_DFLT
      INTEGER LENS
      INTEGER NUMS
      CHARACTER*(*) STRINGS(NUMS)
      INTEGER ICHK
      INTEGER MATCH
      INTEGER IERR

CD-Parameters:
C KEYWORD   (R) Parameter name (full) character string  
C MINL      (R) Minimum length for keyword match
C ITYP      (R) Parameter type 1=dataset, 2=pack, 3=plate specific 
C               for single token; 4=dataset, 5=pack, 6=plate specific
C               multiple token string
C ISTD      (R) Standard parameter for output  = 1 yes, =0 no
C MAXLEN    (R) Maximum string length for parameter value
C S_DEFLT   (R) Default character string  
C STRINGS() (R) Array of character strings containing allowed values
C               CHARACTER*LENS STRINGS(NUMS)
C NUMS      (R) No. of strings in STRINGS
C LENS      (R) Length of each character string element in the
C                       STRINGS array
C ICHK      (R) Check value option =0 any string OK
C                                  =1 check using allowed strings
C MATCH     (R) Minimum no. of characters to be matched if ICHK==1;
C               if -MATCH given then only MATCH characters will be
C               checked and remainder will be ignored; if MATCH==0
C               all characters will be checked
C IERR      (W) Error return = 0 OK
C                            = 1 Parameter error
C                            =-1 Cannot allocate memory
CD-end
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      INCLUDE 'ldm_extended.finc'
      EXTERNAL LDM_BDAT
C
C====== FUNCTION TYPES:
C
      INTEGER KDMSTR
      INTEGER LENSTR
      EXTERNAL LDM_DUMMY_CHS
C
C====== LOCALS:
C
      INTEGER KERR
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      IF (.NOT.EXTENDED) THEN
         CALL LDM_EXTEND_INIT (KERR)
         IF (KERR.NE.0) THEN
            IERR = 1
            IF (KERR.EQ.-1) IERR = -1
            RETURN
         END IF
      END IF
      IF (ITYP.LT.1.OR.ITYP.GT.6) THEN
         IERR = 1
         RETURN
      END IF
      IF (MINL.LT.1) THEN
         IERR = 1
         RETURN
      END IF
      IF (ISTD.NE.0.AND.ISTD.NE.1) THEN
         IERR = 1
         RETURN
      END IF
      IF (ICHK.LT.0.OR.ICHK.GT.2) THEN
         IERR = 1
         RETURN
      END IF
      IF (NUMS.LT.1.OR.LENS.LT.1) THEN
         IERR = 1
         RETURN
      END IF
      CALL KDMF_DEFINE_STR (KDX_EXT, KDMSTR(KEYWORD), LENSTR(KEYWORD), 
     +                      MINL, ITYP, ISTD, MAXLEN, 
     +                      KDMSTR(S_DFLT), LENSTR(S_DFLT), 
     +                      KDMSTR(STRINGS), NUMS, LENS,
     +                      ICHK, MATCH, LDM_DUMMY_CHS, KERR)
      IF (KERR.GT.0) IERR = 1
      IF (KERR.LT.0) IERR = -1
      RETURN
      END
