C$TEST ERR1
C TO RUN AS A MAIN PROGRAM REMOVE NEXT LINE
      SUBROUTINE ERR1
C **********************************************************************
C
C  TO TEST THE ERROR HANDLING PACKAGE
C TEST NUMBER 1: TURNING RECOVERY ON AND OFF.
C
C **********************************************************************
      INTEGER OLDREC, NERR, NERROR, I1MACH
      INTEGER TEMP
C ENTER RECOVERY MODE.
      CALL ENTSRC(OLDREC, 1)
C SET AN ERROR.
C/6S
      CALL SETERR(39HFIRST ERROR TEST - RECOVERABLE ERROR OK, 39, 1, 1)
C/7S
C     CALL SETERR('FIRST ERROR TEST - RECOVERABLE ERROR OK', 39, 1, 1)
C/
C PRINT THE ERROR.
      CALL EPRINT
      IF (NERROR(NERR) .EQ. 1) GOTO 2
         TEMP = I1MACH(2)
         WRITE (TEMP,  1)
   1     FORMAT (14H NERROR FAILS.)
C TURN THE ERROR STATE OFF.
   2  CALL ERROFF
      IF (NERROR(NERR) .EQ. 0) GOTO 4
         TEMP = I1MACH(2)
         WRITE (TEMP,  3)
   3     FORMAT (42H ERROFF FAILS TO TURN THE ERROR STATE OFF.)
C SEE IF THE ERROR PRINTS.
   4  CALL EPRINT
C/6S
      CALL SETERR(
     1   34HSAME TEST -  LEAVING RECOVERY MODE,
     2   34, 2, 1)
C/7S
C     CALL SETERR(
C    1   'SAME TEST -  LEAVING RECOVERY MODE',
C    2   34, 2, 1)
C/
C RESTORE OLD RECOVERY LEVEL, THE DEFAULT.
      CALL RETSRC(OLDREC)
      TEMP = I1MACH(2)
      WRITE (TEMP,  5)
   5  FORMAT (42H RECOVERY MODE REMAINS ON WHEN TURNED OFF.)
      STOP
      END
