     	SUBROUTINE WDIKEY
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY,  SEPT-1987
C
C	THIS ROUTINE WRITES OUT A KEYBAORD DIFILE FROM COMMON BLOCKS
C	IN LINE FORMAT: d-spacing(A), intensity(%), FWHM, H, K, L
C
     	INCLUDE 'FILECONV.CBS'

     	CLOSE( UNIT=IOUT )
     	OPEN( UNIT=IOUT, FILE=FILOUT, STATUS='NEW',
     	1 FORM='FORMATTED', CARRIAGECONTROL='LIST', ERR=888 )
C
C  WRITE THE PEAK LIST...
C
      DO I=1, NPKS
     	WRITE(IOUT,1000,ERR=888) FDSP(I), RELA(I),
     1  FWHM(I), (PHKL(j,I),j=1,4) 
      ENDDO
1000	FORMAT(3G13.5,4I4)
     	GOTO 999
888	IERR = 1
999	RETURN
     	END
