C
C	SUBROUTINE  RDERR
C
C	FUNCTION : TO CHECK THE RETURNED FUNCTION CODE AFTER THE IREADW
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 RDERR(ICODE,IRD,NUM)
C
C		WHERE
C
C			ICODE	 IS IREADW FUNCTION VALUE
C			IRD	 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 RDERR(ICODE,IRD,NUM)
C
C
C	ERROR MESSAGES FOR IREADW
C
	IF (ICODE.GE.0.OR.ICODE.EQ.IRD) GOTO 100

D	DO 1 I = 1,14
D	J = I - 1
D	CALL CLOSEC(J)
D1	CALL IFREEC(J)
	TYPE *,ICODE,'  IREADW ERROR '
D	IF (ICODE.EQ.-1) TYPE *,'READ PASS EOF'
D	IF (ICODE.EQ.-2) TYPE *,'HWD ERR ON CHAN'
D	IF (ICODE.EQ.-3) TYPE *,'CHAN NOT OPEN'
	R = 1./NUM
100	IRD = ICODE
	RETURN
	END
