C LAST UPDATE: 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C**************************
C**     LDM_SAME_SPD     **
C**************************
C
C
      LOGICAL FUNCTION LDM_SAME_SPD (IPACK, IXY, NPL)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose: See if all values are the same for the plates of a pack for
C          an spd parameter set
C
C ***** 'LDM' SERVICE ROUTINE ONLY ****
C
C Author:  John W. Campbell, June 1993
C
C Arguments:
C
      INTEGER IPACK
      INTEGER IXY
      INTEGER NPL

C IPACK    (R)   Pack number
C IXY      (R)   =1 SPDX parameters, =2 SPDY parameters
C NPL      (R)   Number of plates
C
C====== Parameter statements
C 

C
C====== GLOBALS:
C
      INCLUDE 'ldm_data.finc'
      EXTERNAL LDM_BDAT
C
C====== FUNCTION TYPES:
C
      
C
C====== LOCALS:
C
      INTEGER I
      INTEGER J
      INTEGER IVAL
      INTEGER ND
      INTEGER ITYP
      INTEGER IFLAG
      INTEGER IERR
      INTEGER IVAL_REF
      CHARACTER*1 VALSTR
      CHARACTER*1 ERRSTR
      CHARACTER*8 P(LDM_MAXSPD+3)
      REAL VALUE
      REAL VREF
      REAL EPSIL

C     INTEGER I            !Packs loop variable
C     INTEGER J            !Plates loop variable
C     INTEGER IVAL         !Integer value of parameter
C     INTEGER ND           !No. of decimal placed for parameter value print
C     INTEGER ITYP         !Parameter type flag from LDM_GET
C     INTEGER IFLAG        !Parameter value status flag from LDM_GET
C     INTEGER IERR         !Error flag from LDM_GET
C     INTEGER IVAL_REF     !Reference value (integer)
C     CHARACTER*1 VALSTR   !Parameter value string (treated as dummy here)
C     CHARACTER*1 ERRSTR   !Error return string (treated as dummy here)
C     CHARACTER*8 P(LDM_MAXSPD+3)     !Parameter names
C     REAL VALUE           !Real value of parameter
C     REAL VREF            !Reference value (real)
C     REAL EPSIL           !Small difference for 'equal' values test
C
C-------------------------------------------------------------------------------
C
C
C====== See if same for all packs and plates
C
      IF (IXY.EQ.1) THEN
         P(1) = 'SPDX_N'
         P(2) = 'SPDX_MIN'
         P(3) = 'SPDX_MAX'
         DO 10 I= 1, LDM_MAXSPD
            P(I+3) = 'SPDX'
            CALL STR_ADDI(P(I+3),I,0)
10       CONTINUE
      ELSE
         P(1) = 'SPDY_N'
         P(2) = 'SPDY_MIN'
         P(3) = 'SPDY_MAX'
         DO 20 I= 1, LDM_MAXSPD
            P(I+3) = 'SPDY'
            CALL STR_ADDI(P(I+3),I,0)
20       CONTINUE
      END IF
      LDM_SAME_SPD = .TRUE.
      CALL LDM_GET (P(1), IPACK, 1, VALSTR, VREF, ND, IVAL_REF,
     +                 IFLAG, ITYP, IERR, ERRSTR)
     
      DO 30 J = 1, NPL
         CALL LDM_GET (P(1), IPACK, J, VALSTR, VALUE, ND, IVAL,
     +                IFLAG, ITYP, IERR, ERRSTR)
         IF (IVAL.NE.IVAL_REF) GO TO 100
30    CONTINUE
      DO 50 I = 2, IVAL_REF+3
         CALL LDM_GET (P(I), IPACK, 1, VALSTR, VREF, ND, IVAL_REF,
     +                 IFLAG, ITYP, IERR, ERRSTR)
         EPSIL = 1.0E-09
         DO 40 J = 1, NPL
            CALL LDM_GET (P(I), IPACK, J, VALSTR, VALUE, ND, IVAL,
     +                   IFLAG, ITYP, IERR, ERRSTR)
            IF (ABS(VALUE-VREF).GT.EPSIL) GO TO 100
40       CONTINUE
50    CONTINUE
      RETURN
100   LDM_SAME_SPD = .FALSE.
      RETURN
      END
