
From:	CLINE           7-MAY-1985 17:35  
To:	POWDER

C   PROGRAM TO CONVERT AN AUTO RAW DATA FILE TO A  FORMAT THAT GIGIPLOT
C   CAN HANDLE.
C   LINK WITH POWD:[POWDER.QUANT.SUBS]QUANT/LIB

	CHARACTER FILENAME*40, TNAM*6,TJKL*6
C
C    THIS NEXT PIECE WAS TAKEN OTHER PROGRAMS
C
C  DATA FILE STRUCTRE IS DEFINED IN "AUTO - A REAL TIME DIFFRACTOMETER
C  CONTROL SYSTEM" R.L. SNYDER, C.R.HUBBARD AND N. PANAGIOTOPOLOUS
C  NBS REPORT 1981
C
C*********************************************************************
C
C  THE FOLLOWING PARAMETER STATMENT DEFINES THE DIMENSIONS FOR
C  THE QUANTATATIVE ANALYSIS SUBROUTINES.  TO REDIMENSION
C  SIMPLY CHANGE THIS STATMENT HERE AND IN EACH SUBROUTINE.
C      NF = THE NUMBER OF DATA FILES ALLOWED FOR INPUT
C      NR = THE MAXIMUM NUMBER OF REFLECTIONS WHICH CAN BE PROCESSED
C      NP = THE MAXIMUM NUMBER OF PHASES ALLOWED
C      NT = THE MAXIMUM NUMBER OF DATA POINTS FOR ANY REFLECTION
C
	PARAMETER  (NF=30, NR=100, NP=10, NT=1000)
	COMMON/IO/ IRD,ITYP,IPRT,ISCRT,ICOBRG,LIMPRT,IDBUG
	COMMON /FILE/ LU,ITYPE,IEND
	COMMON /FILEC/ NAME
	COMMON/SVDAT1/AINT(NR,NF),VINT(NR,NF),NREFL,IFILE
	COMMON/LABELS/ PHASE(NR),HKL(NR)
	COMMON/SVDAT2/ FRELS(NR),SRELS(NR),WT(NF),KODES(NR),STDS(NR),
     * SSTDS(NR),IOVS(NR),IPKS(NR),RELOV(2,NR),
     * RELOVS(2,NR), WTP(8,NR), CONC(NF), XMURHO(NR)
	COMMON /SVDA2C/ MAN(2,NR),KHL(2,NR),ELM(8,NR)
	COMMON /RECRD1/ IFLAG(10)
	COMMON /RECR1C/ TITLE,DATE,TIME,RNFLNM
	COMMON /RECRD2/ XLAMBD,TAKEOF,DIVANG,RADIUS,SOLLIN,
     1 SOLLOT,RECSLT,DEADTM,STABIL,TBASE
	COMMON /RECR2C/ UNIT,TARGET,LINE,FOCAL,DIVSLT,MONOCH,DETECT
	COMMON/RECRD7/BANG,PANG,EANG,DANG,RATE,MVCNT,TIMLIM,FIXERR,
     * LIMCNT,KODE,IOVLP,IPK,NPK,NBG,FREL,STDREL,STD,SIGSTD,
     * WTPRCT,PKTIME,BKGTIM,IOPTIM,ILOC,CONSTD
	COMMON /RECR7C/ NAM,JKL
	COMMON /RECRD8/ FRELOV(2),SRELOV(2),WTPCPH(8)
	COMMON /RECR8C/ NAMEOV(2),JKLOV(2),ELMTPH(8)
	COMMON/RECRD9/NPTS,X(NT),V(NT)
	CHARACTER*100 TITLE
	CHARACTER*6 DATE,TIME,MAN,JKL,NAMEOV,JKLOV,NAM,KHL,RNFLNM
	CHARACTER*20 NAME
	CHARACTER*2 ELMTPH, ELM
	CHARACTER*4 UNIT
	CHARACTER*2 TARGET,LINE,FOCAL,DIVSLT,MONOCH,DETECT
C
C-----LOGICAL UNIT# ASSIGNMENTS
C     IRD IS FOR CRT TERMINAL INPUT OR CARD READER INPUT
C     ITYP IS FOR CRT TERMINAL OUTPUT (REQUESTING USER RESPONSES)
C     IPRT IS FOR 132 COLUMN PRINTER OUTPUT (FINAL RESULTS)
C     LU   IS FOR AUTO DATA FILE INPUT (OPENED BY QUANT82 ROUTINES)
C     ICOBRG IS FOR COPLAND-BRAGG BINARY FILE (SEE QUANT AND COBRAG)
C     ISCRT  IS FOR TEMPORARY SCRATCH FILE IN RUNFIL
C
	IRD  = 5
	ITYP = 5
	IPRT = 6
30	LU    = 10
	ICOBRG= 30
	ISCRT = 40
C-----SET THE DEBUG PRINT OUT FLAG TO OFF(=0).  ON=1
	IDBUG = 0
	LIMPRT=0
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C  OUR PROGRAM LINES START HERE
C
C Open raw data file
	ITYPE=1
	CALL AUTOLU
C
C Open output file
	WRITE(IPRT,3)
3	FORMAT(' Output file name for X,Y pairs:',$)
	READ(IRD,2) FILENAME
2	FORMAT(A40)
	IXY=2
	OPEN(IXY,NAME=FILENAME,STATUS='NEW')
C
C What are we looking for?
	WRITE(IPRT,10)
10	FORMAT(' What are we looking for?'/' phase  H K L')
	READ(IRD,11) TNAM,TJKL
11	FORMAT(2A6)
	WRITE(IPRT,15)
15	FORMAT(' How many measurements?',$)
	READ(IRD,16) NMEAS
16	FORMAT(I6)
C
C  Loop for number of measurements
	DO 500, IMEAS=1,NMEAS
C
C  Look for it
100	CALL QUANRD
	IF(IEND.EQ.1) GOTO 999
	IF(TNAM.NE.NAM .OR. TJKL.NE.JKL) GOTO 100
C
C  Found it.
	WRITE(IXY,200) NPTS
200	FORMAT(I5)
	ANG = BANG
	DO 250,I=1,NPTS
	WRITE(IXY,210) ANG,X(I)
210	FORMAT(F7.3,',',F7.3)
	ANG=ANG+DANG
250	CONTINUE
C
C  ALL DONE WITH THAT PEAK.
500 	CONTINUE
	STOP 'ALL DONE'
C
C  Something went wrong
999	WRITE(IPRT,998) IMEAS
998	FORMAT(' ERROR--END OF FILE FOUND.  IMEAS=',I5)
	STOP
	END
