C-------------------------------------------------------------------------
	SUBROUTINE GETDATA(dname,d_ln,*)
C-------------------------------------------------------------------------
C This is a general purpose subroutine which reads in data using
C subroutine READDATA. The file name (in DNAME) has been validated
C so errors are not expected.
C
C Subroutine READDATA is designed to accomodate many different
C file formats. It is recommended that this subroutine be modified
C to add additional file formats rather than modify this subroutine. 
C					B. H. Toby
C-------------------------------------------------------------------------
C Parameters:
C	DNAME(:d_ln)    is set as the name of the diffractogram datafile
C   
	CHARACTER*(*) dname
	INTEGER d_ln
	LOGICAL STATUS
	CHARACTER*80 dataform,peakform

	include '[-.shared]jcpds.parms'
	include 'SEARCH.cmn'
	include 'SEARCH.par'
	include '[-.shared]flabel.common'

	LOGICAL DTOTT,TTTOD,DTOPDF,PDFTOD,DTOIND,INDTOD,flag
	NPTS = 0
C Read the raw data file
	CALL READDATA(dname,1,STATUS,.false.,.true.,
	1	dataform,peakform,.false.)
	IF (.not. STATUS) GOTO 33
C   If we are here, the file was read without errors

C Set the working diffractogram array from the arrays from file
	ymax = B(I,1)
	DO I=2,NPOINT(1)
	  ymax = max(ymax,B(I,1))
	ENDDO
C convert the raw data to d-spaces
	call DATCONV(BX(1,1),fxtyp(1),npoint(1),wave(1),
	1	BX(1,1),XTYP_D,npoint(1),0.0,*900)
	fxtyp(1) = XTYP_D
C convert the raw data to the "PDF" units and scale the y-axis
	DO 101 I=1,NPOINT(1)
	  FLAG = DTOPDF(prdat(NPTS+1),Bx(i,1))
	  if (.not. flag) goto 101
	  irdat(NPTS+1) = 10000 * B(I,1) / ymax
	  NPTS = NPTS + 1
101	CONTINUE
	RETURN
C------------------------------------------------------------------------
33	ln = lench(cfilnam(1))
	write (lo,'(A)') ' GETDATA ERROR -- unable to read file '
	1	//cfilnam(1)(:ln)
3	RETURN 1
900	write (lo,'(A)') ' GETDATA ERROR -- unable to convert file '
	1	//cfilnam(1)(:ln)
	RETURN 1
	end
