C   This program converts a Diffrac-11 raw data file to diffrac-5 format.
C   Jim Walker, 15-FEB-85
C
	CHARACTER*32 INFIL, OUTFIL
	IREAD=1
	IWRIT=2
	IMSG=6
	KB=5
C
C  Open the files
	WRITE(IMSG,101)
	READ(KB,103) INFIL
	OPEN(UNIT=IREAD, NAME=INFIL, 
     &	ACCESS='DIRECT', TYPE='OLD', ASSOCIATEVARIABLE=NEXTR, 
     &	RECORDSIZE=1, FORM='UNFORMATTED', READONLY)
	WRITE(IMSG,102)
	READ(KB,103) OUTFIL
	OPEN(UNIT=IWRIT, NAME=OUTFIL, ACCESS='DIRECT', TYPE='NEW',
     &    ASSOCIATEVARIABLE=NEXTW, RECORDSIZE=1, FORM='UNFORMATTED')
101	FORMAT(' Enter name of input file:',$)
102	FORMAT(' Enter name of outfile:',$)
103	FORMAT(A32)
C
C  Copy ID, and Date
	NEXTR=1
	NEXTW=1
	DO 200, I=1,7
	READ(IREAD'NEXTR) REC
	WRITE(IWRIT'NEXTW) REC
200	CONTINUE
C
C  Copy the measreing parameters
	NEXTR=31
	NEXTW=9
	READ(IREAD'NEXTR) SANG
	WRITE(IWRIT'NEXTW) SANG
	READ(IREAD'NEXTR) EANG
	WRITE(IWRIT'NEXTW) EANG
	READ(IREAD'NEXTR) AINC
	WRITE(IWRIT'NEXTW) AINC
	READ(IREAD'NEXTR) CTIM
	WRITE(IWRIT'NEXTW) CTIM
C
C  Copy the counts
	NEXTR=36
	NEXTW=13
	NPTS = INT( (EANG-SANG)/AINC + 1.3)
	DO 300, I=1,NPTS
	READ(IREAD'NEXTR) REC
	WRITE(IWRIT'NEXTW) REC
300	CONTINUE
C
C  Finish up
	CLOSE(UNIT=IREAD)
	CLOSE(UNIT=IWRIT)
	STOP 'Conversion complete.'
	END
