C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_GET_SPDX     **
C**************************
C
C
CD-Doc:
C SPDX1, SPDX2...  SUBROUTINE LDM_GET_SPDX (ICOEFF, IPACK, IPLATE, SVAL, 
C                 +                         IFLAG, ND, IERR, ERRSTR)
CD-end
      SUBROUTINE LDM_GET_SPDX (ICOEFF, IPACK, IPLATE, SVAL, IFLAG, 
     +                         ND, IERR, ERRSTR)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: Get current values of one or all SPDX coefficients
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      INTEGER ICOEFF
      INTEGER IPACK
      INTEGER IPLATE
      REAL SVAL(*)
      INTEGER IFLAG
      INTEGER ND
      INTEGER IERR
      CHARACTER*(*) ERRSTR

C  ICOEFF    (R)   Coefficient no. if > 0, 0=all coefficients
C  IPACK     (R)   Pack number (explicit)
C  IPLATE    (R)   Plate number (explicit)
C  SVAL()    (W)   Returns polynomial coefficients.
C                  (if ICOEFF.GT.0 value is returned in SVAL(1))
C                  (if ICOEFF.EQ.0 dimension to at least LDM_MAXSPD)
C  IFLAG     (W)   Flag = -1 undefined value
C                       =  0 default value
C                       =  1 value set explicitly
C                       =  2 value set globally
C  ND        (W)   Number of decimal places for print (- if E format)
C  IERR      (W)   Error flag = 0 OK
C                             =-1 Invalid pack number
C                             =-2 Invalid plate number
C                             =-3 Invalid polynomial coefficient
C  ERRSTR    (W)   Error string if error found
C
C            Note: IFLAG and ND only set when single coefficient returned
C                  (otherwise 0)
C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      EXTERNAL LDM_BDAT
C
C====== LOCALS:
C
      INTEGER I
      INTEGER J
      INTEGER I1
      INTEGER I2
C
C-------------------------------------------------------------------------------
C
      CALL LDM_CHK_GPL (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
         J = 1
         IF (ICOEFF.EQ.0) J = I
         SVAL(J) = SPDX(IPACK,IPLATE,I)
100   CONTINUE
      IFLAG = 0
      ND = 0
      IF (ICOEFF.GT.0) THEN
         IFLAG = IS_SPDX(IPACK,IPLATE,ICOEFF)
         ND = ND_SPDX(IPACK,IPLATE,ICOEFF)
         IF (ND.EQ.-1000) ND = -4
      END IF
      RETURN
      END
