	SUBROUTINE ERROR(ICOND,MESS)
C
C  Note:  This is the UNIX version.  Error handling
C  actions not yet incorporated.
C
C       This subroutine handles errors.
C			Version 2, Greg Quinn, 30-NOV-79.
C                       Version 3, Bruce Cogan, Jan. 26, 1983
C                       Added writes if ICOND out of range.
C			Version 4U, D. Gudehus, September, 1994
C			Fixed up for UNIX
C			Version 4, D. Gudehus, October, 1999
C			Removed WRITE statements if condition falls
C			through to bottom.
C
C	Parameters:  ICOND  	Error level
C		     MESS	Character string to be printed.
C	
C	Error levels: 
C	ICOND=0	Warning - Message only
C	ICOND=-1 Error message given, but it is assumed that the calling
C		program will take care of the error.
C	ICOND=-2 Error condition may not be fatal.  User is given option 
C    		to continue.
C	ICOND=-3 Serious error - Force return to main program recovery 
C		location. 
C	ICOND=-4 Fatal error - Execution can't continue.  Return to 
C  		monitor by calling LIB$STOP.
C
	CHARACTER*(*) MESS
	CHARACTER*1 X
	DATA L/-2/  ! Default abort level;  should be set by main
		    ! program
C
C  Application program error codes are used in calls to LIB$SIGNAL
C  and LIB$STOP.  These codes are detected by the
C  default condition handlers STR$C_HANDL and STR$NOC_HANDL.
C
C	INTEGER APP$_ERROR,APP$_FATAL,SS$_ABORT
C	PARAMETER APP$_ERROR='80038002'X,APP$_FATAL='8003800C'X,
C	1SS$_ABORT='0000002C'X
C
C  Warning
	IF (ICOND.EQ.0) THEN
	  WRITE(7,1001) MESS
	  WRITE(6,1001) MESS
1001	  FORMAT(' WARNING!  ',A,/' Execution continues')
	  IF (ICOND.GT.L) RETURN
C
C  Error message only
	ELSE IF (ICOND.EQ.-1) THEN
   	  WRITE(7,1031) MESS
	  WRITE(6,1031) MESS
	  IF (ICOND.GT.L) RETURN
C
C  Possible error condition
	ELSE IF (ICOND.EQ.-2) THEN
   	  WRITE(7,1021) MESS
	  WRITE(6,1021) MESS
1021	  FORMAT(' POSSIBLE ERROR:  ',A/
	1 ' Enter "C" if you wish to proceed')
	  IF (ICOND.GT.L) RETURN
	  READ(5,1012) X
1012	  FORMAT(1A1)
	  IF (X.EQ.'C') RETURN
C	  CALL LIB$SIGNAL(%VAL(APP$_ERROR))
C
C  Serious error
	ELSE IF (ICOND.EQ.-3) THEN
	  WRITE(7,1031) MESS
	  WRITE(6,1031) MESS
1031	  FORMAT(' ERROR:  ',A)
	  IF (ICOND.GT.L) RETURN
C	  CALL LIB$SIGNAL(%VAL(APP$_ERROR))
C
C  Fatal error
	ELSE IF (ICOND.EQ.-4) THEN
   	  WRITE(7,1041) MESS
	  WRITE(6,1041) MESS
1041	  FORMAT(' FATAL ERROR:  ',A)
	  IF (ICOND.GT.L) RETURN
C	  CALL LIB$SIGNAL(%VAL(APP$_FATAL))
	  STOP
	END IF
C
C  If the condition has dropped through to here, signal it and
C  assume that a condition handler will grab it.
C
C	CALL LIB$SIGNAL(%VAL(ICOND))
	RETURN
C
C  Entry to change level for error abort
	ENTRY SETLEV(LL)
	L=LL
	RETURN
C
	END
