	PROGRAM RIGAKU
!Program to take Rigaku data files and convert them to GSAS raw powder files
	REAL*4		START		!Start 2-theta
	REAL*4		FINISH		!End 2-theta (no point here)
	REAL*4		STEP		!2-theta steps
	REAL*4		YO(10)		!One line of output
	INTEGER*4	IUIN,IUOUT	!Input and output unit nos.
	CHARACTER*80	INNAME,OUTNAME	!Input & output file names
	CHARACTER*1	IX		!Dummy character

	DATA	IUIN,IUOUT/10,11/

!Open files

	TYPE *,' Enter Rigaku data file name'
	ACCEPT '(A)',INNAME
	OPEN(IUIN,FILE=INNAME,STATUS='OLD',ACCESS='SEQUENTIAL')
	TYPE *,' Enter GSAS output data file name'
	ACCEPT '(A)',OUTNAME
	OPEN(IUOUT,FILE=OUTNAME,STATUS='UNKNOWN',ACCESS='SEQUENTIAL',
	1	RECORDTYPE='FIXED',RECL=80,FORM='FORMATTED')

!Read header

	READ(IUIN,6) START,FINISH,STEP
6	FORMAT(1X,F3.0,F4.0,F4.0)
	TYPE 1,START,FINISH,STEP
1	FORMAT(' Starting 2-theta = ',F10.2,' ending 2-theta = ',F10.2,
	1	' step = ',F6.4)
	NSTEPS = (FINISH-START)/STEP
	NREC = (NSTEPS-1)/10+1
	TYPE 2,NSTEPS,NREC
2	FORMAT(' Number of data = ',I6,' number of output records = ',I5)
	WRITE(IUOUT,*) 'BANK',NSTEPS,NREC,'CONST',START*100.,STEP*100.

!Process data

	DO IREC = 1,NREC
	  DO IDAT = 1,10
	    READ(IUIN,3) YO(IDAT)
3	    FORMAT(2X,F8.0)
	  END DO
	  WRITE(IUOUT,4) YO
4	  FORMAT(10F8.0)
	END DO

!Finished

	CLOSE(IUIN)
	CLOSE(IUOUT)
	STOP 'All done'
	END
