C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_SET_SPDY     **
C**************************
C
C
CD-Doc:
C SPDY1, SPDY2...  SUBROUTINE LDM_SET_SPDY (ICOEFF, IPACK, IPLATE, 
C                 +                         SVAL, IERR, ERRSTR)
CD-end
      SUBROUTINE LDM_SET_SPDY (ICOEFF, IPACK, IPLATE, 
     +                         SVAL, IERR, ERRSTR)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Set values of all SPDY parameters; convenience routine
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      INTEGER ICOEFF
      INTEGER IPACK
      INTEGER IPLATE
      REAL SVAL(*)
      INTEGER IERR
      CHARACTER*(*) ERRSTR

C  ICOEFF    (R)   Coefficient no. if > 0, 0=all coefficients
C  IPACK     (R)   Pack number, 0=all packs
C  IPLATE    (R)   Plate number, 0=all plates
C  SVAL()    (R)   Values of the polynomial coefficients; for single 
C                  coefficient put value in first element of the array.
C                  (if ICOEFF.EQ.0) dimension to at least LDM_MAXSPD)
C  IERR      (W)   Error flag =0 OK
C                             =-1 Invalid pack number
C                             =-2 Invalid plate number
C                             =-3 Invalid coefficient flag
C  ERRSTR    (W)   Error description string if error found
C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      EXTERNAL LDM_BDAT
      INCLUDE 'ldm_lrl.finc'
C
C====== LOCALS:
C
      INTEGER I
      INTEGER I1
      INTEGER I2
      REAL VALUE
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      ERRSTR = ' '
      CALL LDM_CHK_SPL (IPACK, IPLATE, IERR, ERRSTR)
      IF (IERR.NE.0) RETURN
      IF (ICOEFF.LT.0.OR.ICOEFF.GT.LDM_MAXSPD) THEN
         IERR = -3
         ERRSTR = 'Invalid polynomial coefficient'
         RETURN
      END IF
      IF (ICOEFF.GT.0) THEN
         I1 = ICOEFF
         I2 = ICOEFF
      ELSE
         I1 = 1
         I2 = LDM_MAXSPD
      END IF
      DO 100 I = I1, I2
         VALUE = SVAL(1)
         IF (ICOEFF.EQ.0) VALUE = SVAL(I)
         CALL LDM_SETF_PL (IPACK, IPLATE, SPDY(1,1,I), 
     +                     IS_SPDY(1,1,I), CH_SPDY(1,1,I),
     +                     ND_SPDY(1,1,I), VALUE, 
     +                     LDM_MAXPK, LDM_MAXPL)
100   CONTINUE
      CALL LDM_CLR_GEN (IPACK, IPLATE, 2)
      RETURN
      END
