C		PROGRAM EXNORM
C  
C  TO NORMALISE EXAFS SPECTRA FOR FALLOFF OF ATOMIC ABSORPTION
C
C  J.C. PHILLIPS, EMBL OUTSTATION, HAMBURG
C  MODIFIED 2/22/83 FOR USE AT BNL.
C
	DIMENSION X(512),Y(512)
	BYTE FILNAM(10),FNAM2(10)
C
C        READ IN CONSTANTS AND FILENAMES
C
	WRITE(5,111)
	READ(5,112) WL,C1,D1,A1
	WRITE(5,100)
	READ(5,103) FILNAM
	CALL RFILE(X,FILNAM,NCH1)
	WRITE(5,102)
	READ(5,103) FNAM2
	WRITE(5,104)
	READ(5,105) NSPEC
	IF(NSPEC.EQ.0) NSPEC=1
	WRITE(5,107) 
	READ(5,103) FILNAM
	EDGE=C1*WL**3-D1*WL**4+A1
	EZERO=12398./WL
	DO 10 I=1,NCH1
	X(I)=.0381002*X(I)**2+EZERO
	X(I)=12398./X(I)
	X(I)=C1*X(I)**3-D1*X(I)**4+A1
	X(I)=EDGE/X(I)
10	CONTINUE
	DO 20 J=1,NSPEC
	CALL RFILE(Y,FNAM2,NCH2)
	WRITE(5,109) FNAM2
	DO 3 I=1,NCH2
	Y(I)=Y(I)*X(I)
3	CONTINUE
	CALL WFILE(Y,FILNAM,NCH2)
	WRITE(5,110) FILNAM
C	CALL NEWFIL(FILNAM)
C	CALL NEWFIL(FNAM2)
20	CONTINUE
	CALL EXIT
100	FORMAT('$ K-SPACE FILENAME     ? ')
102	FORMAT('$ 1ST INPUT FILENAME   ? ')
103	FORMAT(10A1)
104	FORMAT('$ NO. OF SPECTRA       ? ')
105	FORMAT(I5)
107	FORMAT('$ 1ST OUTPUT FILENAME  ? ')
110	FORMAT('                    ',10A1,/)
109	FORMAT('       ',10A1)
111	FORMAT('$ EDGE WL, C1, D1, A1  ? ')
112	FORMAT(4F12.5)
	END


