     	SUBROUTINE RDITAG
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY,  FEB-1987
C
C	THIS ROUTINE READS FROM A SCINTAG DIFILE
C	AND STORES IN THE CORRESPONDING COMMON BLOCKS
C
     	INCLUDE 'FILECONV.CBS'
     	REAL*4 LAMDA
     	INTEGER*2 ITIT(40), HH, KK, LL
     	EQUIVALENCE (ITIT,SLID)

     	CLOSE( UNIT=IINP )
     	OPEN( UNIT=IINP, FILE=FILINP, STATUS='OLD',
     	1 FORM='UNFORMATTED', READONLY, ERR=888 )
C
C  READ THE FILE HEADER INFORMATION...
C
     	READ(IINP,ERR=777,END=777) ITIT, BANG(1), BANG(2), BANG(3),
     	1 BANG(10), DUMY, WAVE(1,6)

     	DO I=1, 5
     	   IF( ABS(WAVE(1,6)-WAVE(1,I)).LT.0.001 ) IELE = I
     	ENDDO
C
C  READ THE PEAK LIST...
C
     	LAMDA = 0.5*WAVE(1,IELE)
     	DO I=1, MNK

     	   READ(IINP,ERR=777,END=666) F2TH(I), DUMY, AREA(I,JRES),
     	1  PHGH(I), FWHM(I), HH, KK, LL

     	   C2TH(I) = F2TH(I)
     	   FDSP(I) = LAMDA / SIN(DTOR*F2TH(I))
     	   CDSP(I) = FDSP(I)
     	   PHKL(1,I) = HH
     	   PHKL(2,I) = KK
     	   PHKL(3,I) = LL
     	   PEAK(I) = 'KA1'

     	ENDDO
     	NPKS = MNK
     	GOTO 999
666	NPKS = I - 1
     	IF( NPKS.GT.0 ) GOTO 999
777	IERR = 1
     	GOTO 999
888	IERR = 2
999	IF( NPKS.EQ.0 ) GOTO 9999
C
C  CALCULATE THE RELATIVE INTENSITY...
C
     	DUMY = AREA(1,JRES)
     	DO I=2, NPKS
     	   IF( AREA(I,JRES).GT.DUMY ) DUMY = AREA(I,JRES)
     	ENDDO
     	DO I=1, NPKS
     	   RELA(I) = 100.0*AREA(I,JRES)/DUMY
     	ENDDO

9999	RETURN
     	END
