C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_RESET        **
C**************************
C
CD-Routine: Reset Default LDM Parameter Value(s) - LDM_RESET
C This routine is used to reset the default parameter value for an
C individual LDM parameter or for all LDM parameters. A blank
C keyword string indicates all parameters.
CD-end
CD-Fortran:
      SUBROUTINE LDM_RESET (KEYWORD, IPACK, IPLATE, IERR, ERRSTR)
CD-end
      INCLUDE 'implicit_none.finc'
C
C Purpose: Set an LDM parameter to its default value or reset
C          all defaults.
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      CHARACTER*(*) KEYWORD
      INTEGER IPACK
      INTEGER IPLATE
      INTEGER IERR
      CHARACTER*(*) ERRSTR

CD-Parameters:
C  KEYWORD   c  (R)  Full keyword string (upper case) or blank to reset all
C                    LDM parameters.
C  IPACK     i  (R)  Pack number or 0=all packs 
C                    (if relevant for the parameter)
C  IPLATE    i  (R)  Plate number or 0=all plates 
C                    (if relevant for the parameter)
C  IERR      i  (W)  Error flag = 0 OK
C                               =-1 Invalid pack specification
C                               =-2 Invalid plate specification
C                               =-3 Invalid LDM keyword
C  ERRSTR    c  (W)  Returns string for error message (max. 80 chars)
CD-end
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C
      INCLUDE 'ldm_defaults.finc'
      INCLUDE 'ldm_data.finc'
      INCLUDE 'ldm_derived.finc'
      INCLUDE 'ldm_lrl.finc'
      INCLUDE 'ldm_extended.finc'
      EXTERNAL LDM_BDAT
C
C====== FUNCTION TYPES:
C
      INTEGER LDM_SPD_PAR
      INTEGER KDMSTR
      INTEGER LENSTR
C
C====== LOCALS:
C
      LOGICAL FOUND
      INTEGER I, J, K
      INTEGER ICOEFF

C     LOGICAL FOUND    !Keyword found flag .true. yes, .false. no
C     INTEGER I, J, K  !Loop variables
C     INTEGER ICOEFF   !Polynomial coefficient number
C
C-------------------------------------------------------------------------------
C
C====== Initialisations
C
      IERR = 0
      ERRSTR = ' '
      FOUND = .FALSE.
C
C====== Clear LRL flags
C 
      PKOVL = -1   
      PLOVL = -1   
      PKGEN = -1   
      PLGEN = -1   
      PKMTX = -1   
      PLMTX = -1   
C
C====== Find keyword and set value
C
  
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'CRYSTAL') THEN
         CRYST = DF_CRYST
         IS_CRYST = DF_IS_CRYST
         CH_CRYST = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'TITLE') THEN
         TITLE = DF_TITLE
         IS_TITLE =  DF_IS_TITLE
         CH_TITLE = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SYSTEM') THEN
         SYST = DF_SYST
         IS_SYST = DF_IS_SYST
         CH_SYST = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'LATTICE') THEN
         LATT = DF_LATT
         IS_LATT = DF_IS_LATT
         CH_LATT = CH_MASK
         ISYS = 0
         KSYS(1) = 0
         KSYS(2) = 0
         KSYS(3) = 0
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SYMMETRY') THEN
         SPGNAM = DF_SPGNAM
         PGNAM = DF_PGNAM
         NSPGRP = DF_NSPGRP
         NSYMP = DF_NSYMP
         NSYM = DF_NSYM
         DO 30 K = 1, 192
            DO 20 J = 1, 4
               DO 10 I = 1,4
                  ROTSYM(I,J,K) = DF_ROTSYM
10             CONTINUE
20          CONTINUE
30       CONTINUE
         IS_SYMM = DF_IS_SYMM
         CH_SYMM = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'BEAM_AXIS') THEN
         BEAM = DF_BEAM
         IS_BEAM = DF_IS_BEAM
         CH_BEAM = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'ROTATION_AXIS') THEN
         ROT = DF_ROT
         IS_ROT = DF_IS_ROT
         CH_ROT = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'IMAGE_TYPE') THEN
         IMTYP = DF_IMTYP
         IS_IMTYP = DF_IS_IMTYP
         CH_IMTYP = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'IMAGE_DATA') THEN
         IMDAT = DF_IMDAT
         IMDAT_STR = DF_IMDAT_STR
         IS_IMDAT = DF_IS_IMDAT
         CH_IMDAT = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'DGEOM') THEN
         DGEOM = DF_DGEOM
         IS_DGEOM = DF_IS_DGEOM
         CH_DGEOM = CH_MASK
         IDGEOM = 1
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'AXORD') THEN
         AXORD = DF_AXORD
         IS_AXORD = DF_IS_AXORD
         CH_AXORD = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDTYPE') THEN
         FIDT = DF_FIDT
         IS_FIDT = DF_IS_FIDT
         CH_FIDT = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDX1') THEN
         FIDX1 = DF_FIDX1
         IS_FIDX1 = DF_IS_FIDX1
         CH_FIDX1 = CH_MASK
         ND_FIDX1 = DF_ND_FIDX1
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDY1') THEN
         FIDY1 = DF_FIDY1
         IS_FIDY1 = DF_IS_FIDY1
         CH_FIDY1 = CH_MASK
         ND_FIDY1 = DF_ND_FIDY1
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDX2') THEN
         FIDX2 = DF_FIDX2
         IS_FIDX2 = DF_IS_FIDX2
         CH_FIDX2 = CH_MASK
         ND_FIDX2 = DF_ND_FIDX2
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDY2') THEN
         FIDY2 = DF_FIDY2
         IS_FIDY2 = DF_IS_FIDY2
         CH_FIDY2 = CH_MASK
         ND_FIDY2 = DF_ND_FIDY2
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDX3') THEN
         FIDX3 = DF_FIDX3
         IS_FIDX3 = DF_IS_FIDX3
         CH_FIDX3 = CH_MASK
         ND_FIDX3 = DF_ND_FIDX3
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDY3') THEN
         FIDY3 = DF_FIDY3
         IS_FIDY3 = DF_IS_FIDY3
         CH_FIDY3 = CH_MASK
         ND_FIDY3 = DF_ND_FIDY3
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'NXRAST') THEN
         NXRAS = DF_NXRAS
         IS_NXRAS = DF_IS_NXRAS
         CH_NXRAS = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'NYRAST') THEN
         NYRAS = DF_NYRAS
         IS_NYRAS = DF_IS_NYRAS
         CH_NYRAS = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'RASTER_SIZE') THEN
         RAST = DF_RAST
         IS_RAST = DF_IS_RAST
         CH_RAST = CH_MASK
         ND_RAST = DF_ND_RAST
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'RMIN') THEN
         RMIN = DF_RMIN
         IS_RMIN = DF_IS_RMIN
         CH_RMIN = CH_MASK
         ND_RMIN = DF_ND_RMIN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'RMAX') THEN
         RMAX = DF_RMAX
         IS_RMAX = DF_IS_RMAX
         CH_RMAX = CH_MASK
         ND_RMAX = DF_ND_RMAX
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'XLOW') THEN
         XLOW = DF_XLOW
         IS_XLOW = DF_IS_XLOW
         CH_XLOW = CH_MASK
         ND_XLOW = DF_ND_XLOW
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'XHIGH') THEN
         XHIGH = DF_XHIGH
         IS_XHIGH = DF_IS_XHIGH
         CH_XHIGH = CH_MASK
         ND_XHIGH = DF_ND_XHIGH
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'YLOW') THEN
         YLOW = DF_YLOW
         IS_YLOW = DF_IS_YLOW
         CH_YLOW = CH_MASK
         ND_YLOW = DF_ND_YLOW
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'YHIGH') THEN
         YHIGH = DF_YHIGH
         IS_YHIGH = DF_IS_YHIGH
         CH_YHIGH = CH_MASK
         ND_YHIGH = DF_ND_YHIGH
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'DISTORTION_TYPE') THEN
         DSTOR = DF_DSTOR
         IS_DSTOR = DF_IS_DSTOR
         CH_DSTOR = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FTHRESH') THEN
         FTHR = DF_FTHR
         IS_FTHR = DF_IS_FTHR
         CH_FTHR = CH_MASK
         ND_FTHR = DF_ND_FTHR
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FIDBOX') THEN
         FBOX = DF_FBOX
         IS_FBOX = DF_IS_FBOX
         CH_FBOX = CH_MASK
         ND_FBOX = DF_ND_FBOX
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'STHRESH') THEN
         STHR = DF_STHR
         IS_STHR = DF_IS_STHR
         CH_STHR = CH_MASK
         ND_STHR = DF_ND_STHR
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'OVERLOAD_PIXEL') THEN
         OVPIX = DF_OVPIX
         IS_OVPIX = DF_IS_OVPIX
         CH_OVPIX = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'NUMPACK') THEN
         NUMP = DF_NUMP
         IS_NUMP = DF_IS_NUMP
         CH_NUMP = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'NPLATES') THEN
         NPLAT = DF_NPLAT
         IS_NPLAT = DF_IS_NPLAT
         CH_NPLAT = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'TEMPLATE') THEN
         TEMPL = DF_TEMPL
         IS_TEMPL = DF_IS_TEMPL
         CH_TEMPL = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_EPSILON') THEN
         EPS = DF_EPS
         IS_EPS = DF_IS_EPS
         CH_EPS = CH_MASK
         ND_EPS = DF_ND_EPS
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'DTILT') THEN
         DTILT = DF_DTILT
         IS_DTILT = DF_IS_DTILT
         CH_DTILT = CH_MASK
         ND_DTILT = DF_ND_DTILT
         COS_DTILT = 1.0
         SIN_DTILT = 0.0
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'N1OD') THEN
         N1OD = DF_N1OD
         IS_N1OD = DF_IS_N1OD
         CH_N1OD = CH_MASK
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'G1OD') THEN
         G1OD = DF_G1OD
         IS_G1OD = DF_IS_G1OD
         CH_G1OD = CH_MASK
         ND_G1OD = DF_ND_G1OD
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'BASEOD') THEN
         BASE = DF_BASE
         IS_BASE = DF_IS_BASE
         CH_BASE = CH_MASK
         ND_BASE = DF_ND_BASE
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'NONLINEARITY') THEN
         NONL = DF_NONL
         IS_NONL = DF_IS_NONL
         CH_NONL = CH_MASK
         ND_NONL = DF_ND_NONL
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'DSPIN') THEN
         DSPIN = DF_DSPIN
         IS_DSPIN = DF_IS_DSPIN
         CH_DSPIN = CH_MASK
         ND_DSPIN = DF_ND_DSPIN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPINDLE') THEN
         CALL LDM_DF_SPIN (IPACK, IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'PACK_ID') THEN
         CALL LDM_DF_PID (IPACK, IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'KEYPLATE') THEN
         CALL LDM_DISET_PK (IPACK, KEYP, DF_KEYP, IS_KEYP, CH_KEYP, 
     +                  DF_IS_KEYP, IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'FILENAME') THEN
         CALL LDM_DCSET_PL (IPACK, IPLATE, FNAME, 
     +                  DF_FNAME, IS_FNAME, CH_FNAME,
     +                  DF_IS_FNAME, 
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'X_CEN_F') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, XCENF, DF_XCENF, IS_XCENF,
     +                  CH_XCENF, DF_IS_XCENF, ND_XCENF, DF_ND_XCENF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'Y_CEN_F') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, YCENF, DF_YCENF, IS_YCENF,
     +                  CH_YCENF, DF_IS_YCENF, ND_YCENF, DF_ND_YCENF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPACING') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPAC, 
     +                  DF_SPAC, IS_SPAC, CH_SPAC,
     +                  DF_IS_SPAC, ND_SPAC, DF_ND_SPAC,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'A') THEN
         A = DF_A
         IS_A = DF_IS_A
         CH_A = CH_MASK
         ND_A = DF_ND_A
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'B') THEN
         B = DF_B
         IS_B = DF_IS_B
         CH_B = CH_MASK
         ND_B = DF_ND_B
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'C') THEN
         C = DF_C
         IS_C = DF_IS_C
         CH_C = CH_MASK
         ND_C = DF_ND_C
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'ALPHA') THEN
         ALPHA = DF_ALPHA
         IS_ALPHA = DF_IS_ALPHA
         CH_ALPHA = CH_MASK
         ND_ALPHA = DF_ND_ALPHA
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'BETA') THEN
         BETA = DF_BETA
         IS_BETA = DF_IS_BETA
         CH_BETA = CH_MASK
         ND_BETA = DF_ND_BETA
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'GAMMA') THEN
         GAMMA = DF_GAMMA
         IS_GAMMA = DF_IS_GAMMA
         CH_GAMMA = CH_MASK
         ND_GAMMA = DF_ND_GAMMA
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'LMIN') THEN
         CALL LDM_DFSET_PK (IPACK, LMIN, DF_LMIN, IS_LMIN, CH_LMIN,
     +                  DF_IS_LMIN, ND_LMIN, DF_ND_LMIN,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'LMAX') THEN
         CALL LDM_DFSET_PK (IPACK, LMAX, DF_LMAX, IS_LMAX, CH_LMAX,
     +                  DF_IS_LMAX, ND_LMAX, DF_ND_LMAX,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'DMIN') THEN
         CALL LDM_DFSET_PK (IPACK, DMIN, DF_DMIN, IS_DMIN, CH_DMIN,
     +                  DF_IS_DMIN, ND_DMIN, DF_ND_DMIN,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'PHIX') THEN
         CALL LDM_DFSET_PK (IPACK, PHIX, DF_PHIX, IS_PHIX, CH_PHIX,
     +                  DF_IS_PHIX, ND_PHIX, DF_ND_PHIX,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'PHIY') THEN
         CALL LDM_DFSET_PK (IPACK, PHIY, DF_PHIY, IS_PHIY, CH_PHIY,
     +                  DF_IS_PHIY, ND_PHIY, DF_ND_PHIY,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'PHIZ') THEN
         CALL LDM_DFSET_PK (IPACK, PHIZ, DF_PHIZ, IS_PHIZ, CH_PHIZ,
     +                  DF_IS_PHIZ, ND_PHIZ, DF_ND_PHIZ,
     +                  IERR, ERRSTR, LDM_MAXPK)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'CTOF') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, CTOF, 
     +                  DF_CTOF, IS_CTOF, CH_CTOF,
     +                  DF_IS_CTOF, ND_CTOF, DF_ND_CTOF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'Y_SCALE') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, YSCAL, 
     +                  DF_YSCAL, IS_YSCAL, CH_YSCAL,
     +                  DF_IS_YSCAL, ND_YSCAL, DF_ND_YSCAL,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_LENGTH') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPOTL, 
     +                  DF_SPOTL, IS_SPOTL, CH_SPOTL,
     +                  DF_IS_SPOTL, ND_SPOTL, DF_ND_SPOTL,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_WIDTH') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPOTW, 
     +                  DF_SPOTW, IS_SPOTW, CH_SPOTW,
     +                  DF_IS_SPOTW, ND_SPOTW, DF_ND_SPOTW,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_FACTOR') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPOTF, 
     +                  DF_SPOTF, IS_SPOTF, CH_SPOTF,
     +                  DF_IS_SPOTF, ND_SPOTF, DF_ND_SPOTF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_BORDER') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPOTB, 
     +                  DF_SPOTB, IS_SPOTB, CH_SPOTB,
     +                  DF_IS_SPOTB, ND_SPOTB, DF_ND_SPOTB,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPOT_DELTA') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPOTD, 
     +                  DF_SPOTD, IS_SPOTD, CH_SPOTD,
     +                  DF_IS_SPOTD, ND_SPOTD, DF_ND_SPOTD,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'X_C') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, XC, 
     +                  DF_XC, IS_XC, CH_XC,
     +                  DF_IS_XC, ND_XC, DF_ND_XC,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'Y_C') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, YC, 
     +                  DF_YC, IS_YC, CH_YC,
     +                  DF_IS_YC, ND_YC, DF_ND_YC,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'W_C') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, WC, 
     +                  DF_WC, IS_WC, CH_WC,
     +                  DF_IS_WC, ND_WC, DF_ND_WC,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'TWIST') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, TWIST, 
     +                  DF_TWIST, IS_TWIST, CH_TWIST,
     +                  DF_IS_TWIST, ND_TWIST, DF_ND_TWIST,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'TILT') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, TILT, 
     +                  DF_TILT, IS_TILT, CH_TILT,
     +                  DF_IS_TILT, ND_TILT, DF_ND_TILT,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'BULGE') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, BULGE, 
     +                  DF_BULGE, IS_BULGE, CH_BULGE,
     +                  DF_IS_BULGE, ND_BULGE, DF_ND_BULGE,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'ROFF') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, ROFF, 
     +                  DF_ROFF, IS_ROFF, CH_ROFF,
     +                  DF_IS_ROFF, ND_ROFF, DF_ND_ROFF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'TOFF') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, TOFF, 
     +                  DF_TOFF, IS_TOFF, CH_TOFF,
     +                  DF_IS_TOFF, ND_TOFF, DF_ND_TOFF,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDXY') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPDXY, 
     +                  DF_SPDXY, IS_SPDXY, CH_SPDXY,
     +                  DF_IS_SPDXY, ND_SPDXY, DF_ND_SPDXY,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDX_N') THEN
         CALL LDM_DISET_PL (IPACK, IPLATE, SPDXN, 
     +                  DF_SPDXN, IS_SPDXN, CH_SPDXN, DF_IS_SPDXN, 
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDX_MIN') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPDXMIN, 
     +                  DF_SPDXMIN, IS_SPDXMIN, CH_SPDXMIN,
     +                  DF_IS_SPDXMIN, ND_SPDXMIN, DF_ND_SPDXMIN,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDX_MAX') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPDXMAX, 
     +                  DF_SPDXMAX, IS_SPDXMAX, CH_SPDXMAX,
     +                  DF_IS_SPDXMAX, ND_SPDXMAX, DF_ND_SPDXMAX,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      DO 100 ICOEFF = 1, LDM_MAXSPD
         IF (KEYWORD.EQ.' '.OR.LDM_SPD_PAR(1,KEYWORD).EQ.ICOEFF) THEN        
            CALL LDM_DFSET_PL (IPACK, IPLATE, SPDX(1,1,ICOEFF), 
     +                  DF_SPDX, IS_SPDX(1,1,ICOEFF),
     +                  CH_SPDX(1,1,ICOEFF),
     +                  DF_IS_SPDX, ND_SPDX(1,1,ICOEFF), DF_ND_SPDX,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
            IF (IERR.NE.0) RETURN
            FOUND = .TRUE.
         END IF
100   CONTINUE
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDY_N') THEN
         CALL LDM_DISET_PL (IPACK, IPLATE, SPDYN, 
     +                  DF_SPDYN, IS_SPDYN, CH_SPDYN, DF_IS_SPDYN, 
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDY_MIN') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPDYMIN, 
     +                  DF_SPDYMIN, IS_SPDYMIN, CH_SPDYMIN,
     +                  DF_IS_SPDYMIN, ND_SPDYMIN, DF_ND_SPDYMIN,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'SPDY_MAX') THEN
         CALL LDM_DFSET_PL (IPACK, IPLATE, SPDYMAX, 
     +                  DF_SPDYMAX, IS_SPDYMAX, CH_SPDYMAX,
     +                  DF_IS_SPDYMAX, ND_SPDYMAX, DF_ND_SPDYMAX,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      DO 110 ICOEFF = 1, LDM_MAXSPD
         IF (KEYWORD.EQ.' '.OR.LDM_SPD_PAR(2,KEYWORD).EQ.ICOEFF) THEN
           CALL LDM_DFSET_PL (IPACK, IPLATE, SPDY(1,1,ICOEFF),
     +                  DF_SPDY, IS_SPDY(1,1,ICOEFF),
     +                  CH_SPDY(1,1,ICOEFF),
     +                  DF_IS_SPDY, ND_SPDY(1,1,ICOEFF), DF_ND_SPDY,
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
            IF (IERR.NE.0) RETURN
            FOUND = .TRUE.
         END IF
110   CONTINUE
      IF (KEYWORD.EQ.' '.OR.KEYWORD.EQ.'RFL') THEN
         CALL LDM_DISET_PL (IPACK, IPLATE, RFL, 
     +                  DF_RFL, IS_RFL, CH_RFL, DF_IS_RFL, 
     +                  IERR, ERRSTR, LDM_MAXPK, LDM_MAXPL)
         IF (IERR.NE.0) RETURN
         FOUND = .TRUE.
      END IF
      IF (EXTENDED) THEN
         CALL KDMF_RESET (KDX_EXT, KDMSTR(KEYWORD), LENSTR(KEYWORD),
     +                    IPACK, IPLATE, KDMSTR(ERRSTR), LEN(ERRSTR), 
     +                    IERR)
         IF (IERR.EQ.-3) ERRSTR = 'Invalid LDM (extended) keyword'
         RETURN
      END IF
      IF (.NOT.FOUND) THEN
         IERR = -3
         ERRSTR = 'Invalid LDM keyword'
      END IF 
      RETURN
      END
