c At each invocation to a subroutine or function,
c USER_DEBUG checks the STATUS WORD indicator.
c If any errors have occurred since the last call,
c it prints the error and clears the STATUS WORD.
c Compile main program with -g switch.
c Compile this program without -g switch.
c Link the programs together.

	subroutine user_debug(a,b,n)
	character*(*) a,b
	character*10 temp
	integer n, j, stndpsw, k
	data temp / 10H(' ',i1,$) /
1	Format (' ',a,$)
	k=0
10	k=k+1
	if (n.ge.10**k) goto 10
	temp(7:7) = char(48+k)
	j = stndpsw()
	if (0.lt.(j.and.95)) then
	  Print 1, 'In '
	  Print 1, b
	  Print 1, ', before line #'
	  Print temp, n
	  Print 1, ' ("CALL '
	  Print 1, a
	  Print 1, '")'
	  If (0.lt.(J.AND. 1)) Print 1,', Invalid Operation'
	  If (0.lt.(J.AND. 2)) Print 1,', Denormal'
	  If (0.lt.(J.AND. 4)) Print 1,', Zero Divide'
	  If (0.lt.(J.AND. 8)) Print 1,', Overflow'
	  If (0.lt.(J.AND.16)) Print 1,', Underflow'
	  If (0.lt.(J.AND.32)) Print 1,', Precision'
	  If (0.lt.(J.AND.64)) Print 1,', Stack Fault'
	  Print *, '.'
	  call clrndpex
d	 else
d	  print 1, " ("
d	  j=len(b)
d	  print 1, b(2:j-1)
d	  print 1, "-"
d	  j=len(a)
d	  print 1, a(2:j-1)
d	  print 1, ")"
	 end if
	end
