C**********************************************************************
C
	SUBROUTINE CHEM
C
C  CHEMISTRY (OR MU/RO) IS REQUIRED FOR THE INTENSITY RATIO METHOD
C  Record 6 is elemental composition of the unknown or standard
C  If IFLAG(4) = 0 then record 6 is blank and mu/ro is used instead.
C
      INCLUDE 'COMMON.FTN'
C
3000	IF(IFLAG(4).EQ.0) GOTO 9999
	IF(IFLAG(4).NE.1) WRITE(ITYP,3001) (IFLAG(I),I=1,4)
3001	FORMAT(' >> INVALID CHEMISTRY FLAG << IFLAG =',4I2,/,
     &   ' > It will be corrected for you, but you should know.')
	IF(IFLAG(3).EQ.2) GOTO 3010
	WRITE(ITYP,3004)
3004	FORMAT(' Since you are not doing the intensity ratio method',
     &    ' you do not have to enter chemestry.')
C
C  Prompt for elemental composition
C
3010	WRITE(ITYP,3014)
3014	FORMAT(/,' Please enter the following information on the'
     1	' sample',/,' composition (max. 10 entries, return to'
     2	' finish):',//,'     - ELEMENT SYMBOL IN CAPITOL LETTERS',/
     3	'     - WEIGHT PERCENT IN SAMPLE',/
     4	'     - STANDARD DEVIATION',//
     5	'              EL % WT. S.DEV.',/
     6	' FORM:        AA NN.NN NN.NN',/
     7	' ---------------------------')
C        ELEMENT # II: aa ff.ff ff.ff
C
C  Loop up to 10 times to enter elements
C
	I = 1
C  Prompt for each element
3020	WRITE(ITYP,3024) I
3024	FORMAT(' ELEMENT # ',I2,'? ',$)
C  Read the symbol into IPKFND, wt% into PKTIM, s.dev into BKGTIM
	READ(IRD,3034,END=9500) IPKFND(I),PKTIM(I),BKGTIM(I)
3034	FORMAT(A2,X,F5.2,X,F5.2)
C
C  Blank for first element means we are done
C  this test is only meaningful the first time but so what.
	IF( IPKFND(1).EQ.'  ') GOTO 3200
C  Blank for other elements means no more elements.
	IF( IPKFND(I).EQ.'  ') GOTO 3100
C  End of loop.
	I = I + 1
	IF(I.LE.10) GOTO 3020
C
C  Echo data and confirm that it is right.
C
3100	NCHEM = I-1
	WRITE(ITYP,3104) (I,IPKFND(I),PKTIM(I),BKGTIM(I),I=1,NCHEM)
3104	FORMAT(/,' Sample composition as entered:',/,
     &    4('  EL % WT. S.DEV.  '), 3(/,4(2X,A2,2F6.2)) )
C
	WRITE(ITYP,3114)
3114	FORMAT(' All correct? <Y/N, ret=Y> ?',$)
	READ(IRD,3124,END=9500) IY
3124	FORMAT(A1)
C
	IF(IY.EQ.'N' .OR. IY.EQ.'n') GOTO 3000
C
C Set flag indicating chemestry is present.
	IFLAG(4) = 1
	GOTO 9999
C
C Set flag indicating chemestry is not present.
3200	IFLAG(4) = 0
	GOTO 9999
C
C  Set flag indicating user hit ^Z.
9500	IFLAG(4) = -1
C
9999	RETURN
	END
