C------------------------------------------------------------------------
	SUBROUTINE GETDI (PDF2T,IREL,ndsp,STATUS)
C========================================================================
C
C	   Routine to convert the d-spacings in the current pattern
C	   to the format used by Powder Suite
C
C========================================================================

	IMPLICIT INTEGER (A-Z)

	BYTE	     IREL(*)
	INTEGER*2    PDF2T(*)
	INTEGER*2    NDSP
	INTEGER	     STATUS

	INCLUDE 'IORET.CMN'
	INCLUDE 'PDFDATA.CMN'
	INCLUDE 'DSPCDS.CMN'
	
	PARAMETER (MAXOBS = 201)

	LOGICAL FLAG,DTOPDF

	CHARACTER    HKLED(MAXOBS),INTED(MAXOBS),DSPED(MAXOBS)
	CHARACTER    CHAR, PICODE
	INTEGER*2    HKL(MAXOBS,3),INT(MAXOBS),SUB
	REAL         DSP(MAXOBS)

	CHARACTER*9 DSPACE(200)
	CHARACTER*4  INTEN(200)
	CHARACTER*22 HKAYL(200)
C
	STATUS = 0
	IF (NUMC(18).LT.1) THEN
	  STATUS = 1
	  WRITE (*,'(A)') ' ERROR -- no d-space PDF-2 cards'
	  RETURN
	ENDIF

C	... Convert spacings from CARDI(n) to Floating/Integer/Alpha
	NUMOBS = 0
	DO 4000 NCARD=1,NUMC(18)
	  DO 4005 ISP=1,69,23
	    NUMOBS = NUMOBS + 1
	    READ (UNIT=CARDI(NCARD) (ISP:ISP+22), FMT=1800)
     1		DSP(NUMOBS),   INT(NUMOBS),   INTED(NUMOBS),
     2		HKL(NUMOBS,1), HKL(NUMOBS,2), HKL(NUMOBS,3), HKLED(NUMOBS),
     3		DSPED(NUMOBS)  
1800	    FORMAT(F7.4,I3,A1,3I3,A1,1X,A1)
	    IF(DSP(NUMOBS) .EQ. 0.0) NUMOBS = NUMOBS - 1
4005	  CONTINUE
4000	CONTINUE

D	write(6,529) 
D     1  (LN, DSP(LN), INT(LN), INTED(LN),
D     2   HKL(LN,1), HKL(LN,2), HKL(LN,3), HKLED(LN),
D     3   DSPED(LN), LN=1,numobs)
529	FORMAT( (' ',2(i3,F7.3,I3,A1,3I3,A1,1X,A1)) )
C-->	type *,' '

C get maximum intensity (N.B. some patterns are scaled to 999 not 100)
	MAXI = INT(1)
	DO k=2,NUMOBS
	  IF (MAXI .LT. INT(k)) MAXI = INT(k)
	ENDDO
	IF (MAXI .LE. 0) THEN
	  STATUS = 1
	  WRITE (*,'(A)') ' ERROR -- maximum intensity is <=0'
	  RETURN
	ENDIF

	ndsp = 0
	DO 250 j=1,NUMOBS
C skip over multiply indexed lines
	  IF(j.LT.NUMOBS .and. DSP(j).EQ.DSP(j+1) .and. 
     1		INT(j) .EQ. INT(j+1)) GOTO 250
C convert to GG D/I format
	  FLAG = DTOPDF(PDF2T(ndsp+1),DSP(j))
	  IF (FLAG) THEN
	    ndsp = ndsp + 1
C scale intensities to 100 -- full scale
	    IREL(ndsp) = NINT((100./MAXI)*INT(j))
	  ENDIF
250	CONTINUE
	RETURN
	END

