C   08/07/85 507081853  MEMBER NAME  SAFCHK   (S)           FORTRAN
C   07/11/79 911071729  MEMBER NAME  SAFCHK   (JADEGS)      FORTRAN
      SUBROUTINE SAFCHK(JUNIT)
      IMPLICIT INTEGER*2 (H)
#include "cgraph.for"
      COMMON/CADMIN/ IEVTP,NRREAD,NRWRIT,NRERR
      COMMON/CSVCW1/NDDSVE,NRWR
      REWIND JUNIT
      NREC=0
    1 CONTINUE
      READ(JUNIT,ERR=1000,END=2000) NDUMMY
      NREC=NREC+1
      GO TO 1
 1000 CONTINUE
      WRITE(JUSCRN,100) NREC
  100 FORMAT(' *** READ ERROR IN SAFCHK AFTER',I8,' RECORDS. ***')
    3 CONTINUE
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' THERE IS A READ ERROR ON YOU OUTPUT FILE.^')
      CALL TRMOUT(80,' THIS IS MOST GRAVE. PLEASE END YOUR GRAPHICS.^')
      CALL TRMOUT(80,' SESSION, KEEP YOUR CWORK CONTENTS SAFETY FILE ^')
      CALL TRMOUT(80,' AND INVESTIGE THE CONTENTS OF THE OUTPUT FILE^')
      CALL TRMOUT(80,' FROM BATCH.^')
      CALL TRMOUT(80,' ENTER THE NUMBER 777 TO INDICATE YOU HAVE^')
      CALL TRMOUT(80,' UNDERSTOOD THESE GRIM TIDINGS. ENTER ANY ^')
      CALL TRMOUT(80,' OTHER NUMBER IF THE MESSAGE HAS FLASHED BY^')
      CALL TRMOUT(80,' TOO FAST. ^')
      NDUM=TERNUM(NDDY)
      IF(NDUM.NE.777) GO TO 3
      RETURN
 2000 CONTINUE
      WRITE(JUSCRN,101) NRWR,NRWRIT,NREC
  101 FORMAT(' SAFCHK. NRWR, NRWRIT, NREC = ',3I8)
      IF((NRWR+NRWRIT).EQ.NREC) CALL TRMOUT(80,'SAFETY CHECK OK.^')
      IF((NRWR+NRWRIT).EQ.NREC) RETURN
    2 CONTINUE
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' ***** WARNING *****^')
      CALL TRMOUT(80,' YOU HAVE BEEN SCREWED BY AN OBSCURE BOS^')
      CALL TRMOUT(80,' FEATURE. LAST EVENT NOT, EMPHASIS NOT WRITTEN!^')
      CALL TRMOUT(80,' KEEP YOUR SAFETY FILE WITH THE CWORK CONTENTS^')
      CALL TRMOUT(80,' AND USE MODULE F11LHO.GRAPHL(JADED) TO RECOVER^')
      CALL TRMOUT(80,' AND WRITE YOUR EDITING RESULTS. DO NOT ATTEMPT^')
      CALL TRMOUT(80,' TO USE THIS MODULE FOR OTHER PURPOSES.^')
      CALL TRMOUT(80,' ENTER THE NUMBER 777 TO INDICATE YOU HAVE^')
      CALL TRMOUT(80,' UNDERSTOOD THESE GRIM TIDINGS. ENTER ANY ^')
      CALL TRMOUT(80,' OTHER NUMBER IF THE MESSAGE HAS FLASHED BY^')
      CALL TRMOUT(80,' TOO FAST. ^')
      NDUM=TERNUM(NDDY)
      IF(NDUM.NE.777) GO TO 2
      RETURN
      END
