C----------------------------------------------------------------------
	SUBROUTINE READPHN(dname,pname,filform,nfil,STATUS)
C----------------------------------------------------------------------
C Read in a raw data file in Philips APD system running on the DG NOVA
C  assume the data has been collected with Cu K alpha 1 and 2 radiation
C----------------------------------------------------------------------
	LOGICAL status
	INTEGER nfil
	character*(*) dname,pname,filform
	CHARACTER*7 thisform/'APDNOVA'/

	include 'shared$common'
	include '[-.shared]flabel.common'
C
	INTEGER ln,npnt

	LOGICAL exist

	INTEGER NDAT(3),ITIM(3)

C Assume that the read was not successful
	STATUS = .false.

C check the file format qualifier, if one exists
	IF (filform .ne. ' ') THEN
	  I = LENCH(filform)
	  IF (filform(:I) .ne. thisform(:I)) RETURN
	ENDIF
C-------------------------------------------------------------------
C Is there a datafile name?
	IF (dname .eq. ' ') RETURN

C   First, Does the file exist?
	INQUIRE(FILE=dname,EXIST=exist,NAME=cfilnam(nfil),defaultfile='.rd')
	IF (.not. exist) goto 111
	OPEN(UNIT=IN,FILE=cfilnam(nfil),TYPE='OLD',ERR=111,FORM='FORMATTED'
	1	,readonly,shared)
	READ (IN,'(3F10.3)',err=111) START(nfil),DELTA(nfil),FINISH(nfil)
	NPNT = ((FINISH(nfil)-START(nfil))/DELTA(nfil))+1.5
	IF (NPNT.gt.M$PTS) then
	  WRITE (LI,'(A,i6)') 
	1	' WARNING -- NUMBER OF DATA POINTS WILL BE LIMITED TO ',
	2	M$PTS
	  NPNT = M$PTS
	ENDIF
C set the date to now since we have no better choice
	CALL IDATE(DATE(1,nfil),DATE(2,nfil),DATE(3,nfil))

	INST(nfil) ='DI'
	SOURCE(nfil) = 'PH'
	IRAD(nfil) = 'CU'
	CALL WAVESET(IRAD(nfil),WAVE(nfil),WKA1(nfil),WKA2(nfil),*33)
33	MONO(nfil) = .false.
	NPKS(nfil) = 0
	NBKGP(nfil) = 0
C	
	NMAX = NPNT
	DO N=1,NPNT,10
	  READ (IN,'(10F8.0)',end=112,err=111) 
	1		(B(I,nfil),I=N,MIN(nmax,N+9))
	  NPNT = MIN(nmax,N+9)
	ENDDO

C Compute X values and insure that ESD's are non-zero
112	DO i=1,NPNT
	  BESD(i,nfil) = sqrt(B(i,nfil))
	  IF (BESD(i,nfil) .eq. 0) BESD(i,nfil) = 1.0
	  bx(i,nfil) = START(nfil) + (I-1.)*DELTA(nfil)
	ENDDO

	ln = lench(cfilnam(nfil))
C set title to name of file since we have nothing better for right now
	ATITLE(nfil) = cfilnam(nfil)
	write (LO,'(A)') ' File '//cfilnam(nfil)(:ln)
	1	//' read in Philips APD (Nova) raw data format'

	FXTYP(nfil) = 1
	FYTYP(nfil) = 1
	filform = thisform
	STATUS = .true.
	NPOINT(nfil) = npnt
	FINISH(nfil) = START(nfil) + (NPNT-1)*DELTA(nfil)
111	close(unit=IN)
	RETURN
	END
