      SUBROUTINE RRWDPC
*
* This subroutine reads a raw file from Diffrac / PC software
* for PSD data collection written by Gerhard Zorn
* 
*  This subroutine written for vaxconv convertion routine
*   By D. P. MAtheis           September 1990
*
*
      include 'fileconv.cbs'
      character*4 key
      REAL*4 LAMDA1, lambda2
      INTEGER*4 ITIT(20), flag, samp
      EQUIVALENCE (ITIT,SLID)
*
      close(unit=iinp)
      open(unit=iinp, file=filinp,  status='old',
     1  access='direct',  recl=4)
*form='unformatted',
*
* read scan parameters
*
      read(iinp,rec=1)key
      read(iinp,rec=2)npts
      read(iinp,rec=3)bang(10)
      read(iinp,rec=4)bang(3)
      read(iinp,rec=5)flag
      read(iinp,rec=6)samp
      read(iinp,rec=7)bang(1)
*
* read sample info
* 
      do i=11,18
        read(iinp,rec=i)itit(I-10)
      enddo
*
* read wavelength
*
      read(iinp,rec=19)lambda1
      read(iinp,rec=20)lambda2
      if(lambda1.eq.0.0.and.lambda2.eq.0.0)then
        iele = 4
      else
        wave(1,6) = lambda1
        wave(2,6) = lambda2
      endif
*
* read number of ranges
*
      read(iinp,rec=39)irngs
*
* read the intensity data
*
      do i=40,39+npts
        read(iinp,rec=i)yobs(i-39)
      enddo
*
* check for another range or end of file
*
      read(iinp,rec=40+npts,err=999)npts2
      print*,'This program will not yet read multiple ranges'
      go to 999
 777  IERR = 1
      GOTO 999
 888  IERR = 2
 999  RETURN
      END
