C******************** START FILE UTRACE.FOR ; GROUP URDUTS ******************
C=============================================
C&  UTRACE  UREAD INDIRECT INPUT FILE RECORD TRACEBACK AFTER ERROR
C       D. MC CUNE MAY 8 1980
C   PROVIDE TRACEBACK ON INDIRECT FILES AFTER ERROR
C
C  INPUT:  UREAD COMMON
C
C   OUTPUT:  TRACEBACK TABLE ON UNIT LUNTRM
C
C
      SUBROUTINE UTRACE
C
      USE USERIO
C
      WRITE(LUNTRM,1001)
 1001 FORMAT(/' UREAD SUBROUTINE UTRACE ** INDIRECT FILES TRACEBACK'/
     >  ' FILENAME                   RECORD COUNT')
        IMAX=MAX0(NLUNIN,NLUNIO)
        DO 10 J=IMAX,1,-1
          IF(J.EQ.IMAX) THEN
            CALL UTRAHD(CBUFF(2:LBUFF))
          ELSE
            CALL UTRAHD(AHDBUF(J))
          ENDIF
C
          ILFILN=INDEX(XFILE(J),' ')-1
          IF(ILFILN.LE.0) ILFILN=LFILN
C
          IF(J.GT.NLUNIO) THEN
            IF(ILFILN.LE.30) THEN
              WRITE(LUNTRM,1002) XFILE(J),NCMND(J)
            ELSE
      	WRITE(LUNTRM,1012) XFILE(J),NCMND(J)
            ENDIF
 1002 FORMAT(1X,A,T32,I4,1X,' @INPUT FILE CALLED FROM:')
 1012 FORMAT(1X,A/T32,I4,1X,' @INPUT FILE CALLED FROM:')
          ELSE IF(J.GT.1) THEN
            IF(ILFILN.LE.30) THEN
              WRITE(LUNTRM,1003) XFILE(J),NCMND(J)
            ELSE
      	WRITE(LUNTRM,1013) XFILE(J),NCMND(J)
            ENDIF
 1003 FORMAT(1X,A,T32,I4,1X,' >OUTPUT FILE CALLED FROM:')
 1013 FORMAT(1X,A/1X,T32,I4,1X,' >OUTPUT FILE CALLED FROM:')
          ELSE
            IF(ILFILN.LE.30) THEN
              WRITE(LUNTRM,1004) XFILE(J),NCMND(J)
            ELSE
      	WRITE(LUNTRM,1014) XFILE(J),NCMND(J)
            ENDIF
 1004 FORMAT(1X,A,T32,I4)
 1014   FORMAT(1X,A/1X,T32,I4)
          ENDIF
 10     CONTINUE
      RETURN
      	END
C******************** END FILE UTRACE.FOR ; GROUP URDUTS ******************
