	PROGRAM SIEMENS
!Program to take Siemens 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
	INTEGER*4	IYO(10)		!One line of output
	REAL*4		YO(10)		!One line of input
	INTEGER*4	IUIN,IUOUT	!Input and output unit nos.
	CHARACTER*80	INNAME,OUTNAME	!Input & output file names
	CHARACTER*1	IX		!Dummy character
        CHARACTER*80	TITLE		!DAta title

	DATA	IUIN,IUOUT/10,11/

!Open files

	TYPE *,' Enter Siemens 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

	TITLE = ' '
        READ(IUIN,'(A)') TITLE(1:49)
        READ(IUIN,'(A)') TITLE(50:66)
        WRITE(IUOUT,'(A)') TITLE
        TYPE 1,TITLE(1:66)
1	FORMAT(' Title: ',A)
	READ(IUIN,2) START,FINISH,STEP,TIME
2	FORMAT(4F10.0)
	TYPE 3,START,FINISH,STEP
3	FORMAT(' Starting 2-theta = ',F10.2,' ending 2-theta = ',F10.2,
	1	' step = ',F6.4)
	NSTEPS = (FINISH-START)/STEP+1
	NREC = (NSTEPS-1)/10+1
	TYPE 4,NSTEPS,NREC
4	FORMAT(' Number of data = ',I6,' number of output records = ',I5)
	TITLE = ' '
	WRITE(TITLE,10) 'BANK 1',NSTEPS,NREC,'CONST',START*100.,STEP*100.,TIME
10	FORMAT(A,2I8,1X,A,3F10.1,22X)
        WRITE(IUOUT,'(A)') TITLE

!Process data

	DO IREC = 1,NREC
          READ(IUIN,5) YO
5	  FORMAT(10F7.0)
	  DO I=1,10
	    IYO(I) = YO(I)
	  END DO
	  WRITE(TITLE,6) IYO
6	  FORMAT(10I8)
          WRITE(IUOUT,'(A)') TITLE
	END DO

!Finished

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