CD-Section: Handle Extended LDM Data
C Routines are available to enable the handling of LDM data with an extended
C set of parameters. These are managed via the 'C' based 'KDM' (Keyword
C Data Module) routines. LDM routines are available to add new keyword
C parameters of various types. The KDMF_DEFINE_... routines may also be
C used to define parameters of some other types and the index to the
C keyword set required in such calls may be obtained by calling the
C LDM_KDX function. If such additional parameters are defined
C then they will be automatically handled by routines such as LDM_PARSE,
C LDM_WRITE, LDM_SET, LDM_RESET, LDM_CH_RESET, LDM_ANY_CH. In most cases
C LDM_GET may also be used though it will not fully handle integer,
C real or variable array parameter value keywords with more than one
C integer/real value. Also the returned string for such parameters could
C exceed the standard 120 characters maximum. For such cases the
C KDMF_GETVALUE routine may be called directly to enable the full data to 
C be returned. 
CD-end

C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_NEWINT       **
C**************************
C
CD-Routine: Define a New Integer Parameter - LDM_NEWINT
C This routine is used create a new integer LDM parameter to form part of
C an extended LDM parameter set.
CD-end
CD-Fortran:
      SUBROUTINE LDM_NEWINT (KEYWORD, MINL, ITYP, ISTD, I_DEFLT, 
     +                       I_MIN, I_MAX, ICHK, 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 I_DEFLT
      INTEGER I_MIN
      INTEGER I_MAX
      INTEGER ICHK
      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 ISTD      (R) Standard parameter for output  = 1 yes, =0 no
C I_DEFLT   (R) Default parameter value  
C I_MIN     (R) Minimum allowed value (if ICHK==5) 
C I_MAX     (R) Maximum allowed value (if ICHK==5) 
C ICHK      (R) Check value option =0 any integer OK,
C                                  =1 any >=0
C                                  =2 any >0
C                                  =3 any <=0
C                                  =4 any <0
C                                  =5 must be in range I_MIN to I_MAX
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_CHI
C
C====== LOCALS:
C
      INTEGER KERR
      INTEGER IDFLT(2)
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.3) 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.5) THEN
         IERR = 1
         RETURN
      END IF

      IDFLT(1) = I_DEFLT
      CALL KDMF_DEFINE_INT (KDX_EXT, KDMSTR(KEYWORD), LENSTR(KEYWORD), 
     +                      MINL, ITYP, ISTD, 1, IDFLT, I_MIN, I_MAX, 
     +                      ICHK, LDM_DUMMY_CHI, KERR)
      IF (KERR.GT.0) IERR = 1
      IF (KERR.LT.0) IERR = -1
      RETURN
      END
