C
C	SUBROUTINE  CHKNEG
C
C	FUNCTION : TO CHECK THE RETURNED FUNCTION CODE AFTER THE SYSLIB CALL
C		   HAS BEEN PERFORMED AND TO REPORT ALL POSSIBLE ERRORS .
C
C		  ON ERROR THE PROGRAM CAN GENERATE A DIVIDE BY ZERO TO 
C	   	  GIVE A TRACE BACK .
C
C
C
C	AUTHOR:	G. GUELFI	1-APRIL-1985
C
C
C	CALL IS
C
C	SUBROUTINE CHKNEG(ICODE,ICHK,NUM)
C
C		WHERE
C
C			ICODE	 IS SYSLIB FUNCTION VALUE
C			ICHK	 CAN CONTAIN ERROR VALUE TO BE IGNORED
C				 AND IT RETURNS VALUE OF ICODE
C			NUM	 IS VALUE TO GENERATE TRACE BACK
C
C				IF NUM = 0 THEN TRACE BACK
C				IF NUM = 1 ONLY REPORT ERROR
C
	SUBROUTINE CHKNEG(ICODE,ICHK,NUM)
C
C
C	CHECK ICODE FOR ERRORS
C
	IF (ICODE.GE.0.OR.ICODE.EQ.ICHK) GOTO 100

D	DO 1 I = 1,14
D	J = I - 1
D	CALL CLOSEC(J)
D1	CALL IFREEC(J)
	TYPE *,ICODE,'  CHKNEG ERROR '
	R = 1./NUM
100	ICHK = ICODE
	RETURN
	END
