C****************************************************************
C* 								*
C*								*
C*	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY *
C*	EITHER FOR THE CREATION OR FOR THE CLINICAL EFFICACY	*
C*	OF THIS PROGRAM. USERS MUST ASSUME FULL RESPONSIBILITY	*
C*	FOR ANY RESULTS OR DIAGNOSES OBTAINED FROM THE USE	*
C*	OF THIS PROGRAM. QUESTIONS ON THE EXECUTION OF THIS	*
C*	PROGRAM MUST BE REFERRED BACK TO THE ORIGINAL AUTHOR.	*
C*								*
C* AUTHOR:	SALLY FORSTER					*
C*		C/O DEPARTMENT OF NUCLEAR MEDICINE		*
C*		GUY'S HOSPITAL				*
C*		LONDON, ENGLAND					*
C*								*
C*		TEL: 01-407-7600 EXT 2583/4			*
C*								*
C****************************************************************
	SUBROUTINE FITCUR(IP,IE)
C*****CALLS THE SEPARATE FITTING ROUTINES
C*****AFTER SETTING UP X-COORDS IN CURVE2(FOR WINDOW)
C*****EACH ROUTINE RETURNS WITH FITTED CURVE IN CURVE 1
C*****AND FIT PARAMETERS IN CFITPAR.
C*****THESE VALUES ARE THEN CORRECTED FOR COLLECTION TIME 
C*****TO THE GROUP RATE FOR THE UPPERLIMIT OF THE FIT
C*****IF THE SAVE AREA HAS NOT BEEN LINEARISED
	IMPLICIT LOGICAL*1(A)
	IMPLICIT INTEGER*2(D-Z)
	COMMON//SAVDES(256),CURVE1(512),CURVE2(512),ICS,ICB,ICOM
	COMMON/INPARA/CPAR(10)
	COMMON/CH/F(4),CSR(20)
	COMMON/FIT/CFITPA(4)
	COMMON/WINDOW/FST,LST
	COMMON/LINEAR/ALIN,AINTER,ATOSEC
	COMMON/FITBND/J,I
C*****SET UP FIT BOUNDS
	IE=14
	I=FST
	J=LST
	IF(IP.LT.1)GOTO 5
	I=INTPAR(1)
	IF(IP.LT.2)GOTO 5
	J=INTPAR(2)
5	IF(J.LT.I+2)GOTO 500
	IF(J.GT.LST)GOTO 500
	IF(I.LT.FST)GOTO 500
	IF(IP.LT.3)GOTO 20
	DO 10 II=3,IP
	IF(CPAR(II).GE.0)GOTO 500
10	CONTINUE
C*****SET UP X-COORDS.
20	TRULST=LST
	LST=SAVDES(108)
	CALL SETX(K)
	LST=TRULST
C*****GET REAL TIME OF LAST POINT FOR DELIN
	CTMGET=CURVE2(J-FST+1)
C*****	     FE FG FL FP FT
	GOTO(40,50,60,70,80),ICOM-49
40	IF(EXPFIT(I,J))550,700,90
50	IF(GMSTRT(I,J))550,90,90
60	IF(LOGFIT(I,J))550,700,90
70	IF(POLFIT(I,J))600,90,90
80	IF(LINREG(I,J).LT.0)GOTO 700
90	IF (IP.LT.3)GOTO 110
	DO 100 II=3,IP
100	CSR(-INT(CPAR(II)))=CFITPA(II-2)
110	IF(.NOT.(ALIN.OR.ATOSEC))CALL DELIN(CTMGET)
	RETURN
500	IE=4
	RETURN
550	IE=6
	RETURN
600	WRITE(7,650)
650	FORMAT(1X,'UNSTABLE')
700	IE=12
	RETURN
	END
