	SUBROUTINE D11D5(FILE1,FILE2,NENTR)
C++
C++	Routine: D11D5
C	Programmer: DJ HELM
C	Date: 13 FEB 85
C++	Purpose: Conversion routine
C++	Syntax:
C++		CALL D11D5(FILE1,FILE2)
C++	Calls:
C++
C	Modifications
C	Who	date	what
C
C
C
	COMMON /TRMBLK/IUNIT1,IUNIT2,TERM
C
	BYTE FILE1(32),FILE2(32),ID(16),DAT(9),TIM(8),BLK(3),USER(12)
C
	INTEGER*2 IUNIT1,IUNIT2,NSTEPS,TUBKV,TUBMA,DET,SCAN
	1,NORM,NRANG,TERM,NENTR
C
	REAL*4 WAVE,SNGLE,ENGLE,STPSIZ,TIME,TUBVOL,LAMBDA,ANODE
	1,DELWAV,WAVE1,WAVE2,ZERO
C
	DATA BLK/3*' '/
	DATA TIM/8*' '/
	DATA USER/12*' '/
C
	WAVE1=0.0
	WAVE2=0.0
	DELWAV=0.0
	SCAN=0
	ZERO=0
C
	READ(IUNIT2'1,ERR=900)(ID(I),I=1,4)
	WRITE(IUNIT1'1,ERR=950)(ID(I),I=1,4)
	READ(IUNIT2'2,ERR=900)(ID(I),I=5,8)
	WRITE(IUNIT1'2,ERR=950)(ID(I),I=5,8)
	READ(IUNIT2'3,ERR=900)(ID(I),I=9,12)
	WRITE(IUNIT1'3,ERR=950)(ID(I),I=9,12)
	READ(IUNIT2'4,ERR=900)(ID(I),I=13,16)
	WRITE(IUNIT1'4,ERR=950)(ID(I),I=13,16)
	READ(IUNIT2'5,ERR=900)(DAT(I),I=1,4)
	WRITE(IUNIT1'5,ERR=950)(DAT(I),I=1,4)
	READ(IUNIT2'6,ERR=900)(DAT(I),I=5,8)
	WRITE(IUNIT1'6,ERR=950)(DAT(I),I=5,8)
	READ(IUNIT2'7,ERR=900)DAT(9)
	WRITE(IUNIT1'7,ERR=950)DAT(9),(BLK(I),I=1,3)
C
	READ(IUNIT2'31,ERR=950)SNGLE
	READ(IUNIT2'32,ERR=950)ENGLE
	READ(IUNIT2'33,ERR=950)STPSIZ
	READ(IUNIT2'34,ERR=950)TIME
C
	WAVE='WAVE'
	WRITE(IUNIT1'8,ERR=900)WAVE
	WRITE(IUNIT1'9,ERR=900)SNGLE
	WRITE(IUNIT1'10,ERR=900)ENGLE
	WRITE(IUNIT1'11,ERR=900)STPSIZ
	WRITE(IUNIT1'12,ERR=900)TIME
C
C	calculate the number of NSTEPS
C
	NSTEPS=IFIX((ENGLE-SNGLE)/STPSIZ)+1
C
C	check to see if the wavelength is in the d5 data file
C
	READ(IUNIT2'14,ERR=950)WAVE1
	READ(IUNIT2'15,ERR=950)DELWAV
	WAVE2=WAVE1+DELWAV
C
	IREC=NSTEPS+13
	WRITE(IUNIT1'IREC,ERR=900)WAVE1
	WRITE(IUNIT1'IREC+1,ERR=900)WAVE2
C
C
C	set all of the calibration coefs to 0
C
C
C	write out the measurement information
C
C
C	transfer the intensities
C
	IOF5=13
	IOF11=36
	DO 120 I=1,NSTEPS
	READ(IUNIT2'IOF11,ERR=950)VAL
	WRITE(IUNIT1'IOF5,ERR=900)VAL
	IOF5=IOF5+1
	IOF11=IOF11+1
120	CONTINUE
C
C	everything completed
C	
121	CLOSE(UNIT=IUNIT1)
	CLOSE(UNIT=IUNIT2)
	CALL CAUPDA(FILE1,ID,NENTR,NSTEPS)
	IF(IER.NE.0)GO TO 201
	WRITE(TERM,200)(FILE2(I),I=1,26),(FILE1(I),I=1,26)	
200	FORMAT(' File ',26A1,' has been transfered to ',26A1)
201	RETURN
C
C	errors
C
900	CALL ERRSNS(IER)
	WRITE(TERM,901)IER,FILE1
901	FORMAT(' An error',I4,' has occured while reading from 
	1file :',32A1)
	GO TO 121
C
950	CALL ERRSNS(IER)
	WRITE(TERM,951)IER,FILE1
951	FORMAT(' An error',I4,' has occured while writing to file :',32A1)
	GO TO 121
	END
