C
C**********************************************************************
C
C       THIS PROGRAM COLLECTS REAL TIME DATA FROM THE ANALOG SIMULATOR.
C       THE DATA ARE TEMPERATURE, PRESSURE, AND YIELD RATE, STORED IN
C       ARRAY IVAL1, IVAL2, AND IVAL3, RESPECTIVELY.  ONCE THE DATA ARE
C	COLLECTED, THEY ARE STORED IN THEIR RESPECTIVE DATA FILES.
C
C**********************************************************************
C
	DIMENSION IOSB(1),IVAL1(1810),IVAL2(1810),IVAL3(1810)
	WRITE(5,10)
10      FORMAT(1X,5X,'PLEASE INPUT SAMPLING RATE <10-30 CYCLES/SEC>.   '
     C,$)
	READ(5,20)K
20	FORMAT(I4)
C
C*********  AFTER THE SAMPLING TIME INTERVAL,Q, IS COMPUTED, THE CLOCK
C*********  IS RESET TO ZERO AND STARTS.
C
	Q=1./K
	TI=0.0
	N=0
	T=SECNDS(T)
C
C*********  DOUT CHECKS TO SEE IF THE ANALOG TO DIGITAL CHANNELS ARE
C*********  CLEAR.  DATA COLLECTION BEGINS WHEN IOSB EQUALS ONE.
C
30	CALL DOUT(0, ,IOSB,1)
	IF(IOSB(1).NE.1)GO TO 30
C
C*********  ADINP CONVERTS THE ANALOG SIGNAL TO A DIGITAL NUMBER.
C
40	N=N+1
	CALL ADINP(0,0,IVAL1(N))
	CALL ADINP(0,1,IVAL2(N))
	CALL ADINP(0,2,IVAL3(N))
	TI=TI+Q
50	DELTA=SECNDS(T)
	IF(DELTA.LE.TI)GO TO 50
	IF(DELTA.GE.60)GO TO 100
C
C*********  THE DIGITAL DATA IS STORED IN THE FOLLOWING DATA FILES.
C
	GO TO 40
100	CALL DOUT(0,IOSB,0)
	IF(IOSB(1).NE.1)GO TO 100
	CALL ASSIGN(1,'TEMP.DAT')
	CALL ASSIGN(2,'PRESS.DAT')
	CALL ASSIGN(3,'YIELD.DAT')
	WRITE(1,150)(IVAL1(J),J=1,N)
	WRITE(2,150)(IVAL2(J),J=1,N)
	WRITE(3,150)(IVAL3(J),J=1,N)
150	FORMAT(I6)
C
C*********  THE PREVIOUSLY OPEN FILES ARE NOW CLOSED.
C
	CALL CLOSE(1)
	CALL CLOSE(2)
	CALL CLOSE(3)
	STOP
	END
