C**********************************************************************
C
	SUBROUTINE WRCNT
C
C	THIS IS CALLED BY IFSSCN AT EACH STEP TO DEAL WITH THE COUNTS.
C	WHEN 16 COUNTS HAVE BEEN COLLECTED, THE LINE IS WRITTEN TO A FILE.
C
      INCLUDE 'COMMON.FTN'
C Uses COUNTS, TIME, ICOUNT, CNT, IFSTAT, ANGLE, STPSIZ, IERR
C Calls WRREC.
C
 	IF( IFSTAT.EQ.4 .OR. IFSTAT.EQ.5) GOTO 100
	WRITE(IERR,4) IFSTAT, ANGLE*STPSIZ
 4	FORMAT(' > ERROR IN WRCNT < IFSTAT =',I3,' 2THETA=',F8.4)
C
100	ICOUNT = ICOUNT + 1
C  Normally store the counts.
	CNT(ICOUNT) = COUNTS
C  If max # counts hit then use time counted in tenths of seconds.
	IF(IFSTAT.EQ.5) CNT(I) = - 10.0 * CTIME
C  Write out record when full.
	IF(ICOUNT.EQ.16) CALL WRREC
C
	RETURN
	END
