      SUBROUTINE PXIT (NAME, N)

C     * MAR 11/2004 - M.BERKLEY (MODIFIED for NCAR V3.2)
C     * OCT 01/92 - E. CHAN. (CHANGE STOP 1 TO STOP)
C     * MAY 10/90 - (CHECK FOR "GMETA" AND DISPOSE IT IF PRESENT)
C     * CLOSE GKS WORKSTATION AND THEN MAKE APPROPRIATE CALL TO XIT
C     * APR 24/90 - C. BERGSTEIN => MATCH UP TRAVELS WITH METACODE FRAMES
C     * AUGUST, 1989 H. REYNOLDS
C
C     * N.GE.0 IS FOR A NORMAL END. MESSAGE WITH DASHED LINE IS PRODUCED.
C     * NORMAL ENDS TERMINATE WITH   STOP.
C
C     * N.LT.0 IS FOR AN ABNORMAL END. MESSAGE WITH DOTTED LINE IS PRODUCED.
C     * IF N IS LESS THAN -100 THE PROGRAM SIMPLY TERMINATES.
C     * OTHERWISE IF N IS LESS THAN ZERO THE PROGRAM ABORTS.
C
C --------------------------------------------------------------------------
C
      CHARACTER*(*) NAME
      CHARACTER*8  CERR(2), DASH, STAR, NAME8
      CHARACTER*39 AMESG
C
      DATA DASH, STAR / '--------', '********' /
      NAME8=NAME
C
C     * PLOT ERROR MESSAGE AND PROPERLY CLOSE THE METACODE
C     * FILE IF A WARNING OR ABORT XIT IS CALLED.
C
      IF (N .LT. 0) THEN
         CALL SET (0., 1., 0., 1., 0., 1., 0., 1., 1)
         CALL SETUSV ('LW', 2000)
         WRITE (CERR(1), '(A8)') NAME8
         WRITE (CERR(2), '(I8)') N
         AMESG( 1:8 ) = '** XIT ('
         AMESG( 9:16) = CERR(2)
         AMESG(17:31) = ') CALLED FROM '
         AMESG(32:39) = CERR(1)
         CALL PWRITX (0.50, 0.97, AMESG, 39, 30, 0, 0)
         WRITE (44,'(A2)') 'NO'
         CALL FRAME
      ENDIF
C
      CALL CLSGKS
C
C     * NOW HANDLE EXIT PROCESSING
C
C     * PRINT APPROPRIATE TERMINATION MESSAGE
C
      IF (N .GE. 0) THEN
         WRITE (6,6010) DASH,NAME8,(DASH,I=1,9),N
      ELSE
         WRITE (6,6010) STAR,NAME8,(STAR,I=1,9),N
      ENDIF
C
      IF (N .GE. 0 .OR. N .LT. -100) THEN
C
C     * PROCESS METACODE
C
        CALL PUTMETA (IDUMMY)
        STOP
      ELSE
        CALL ABORT
      ENDIF
C
C---------------------------------------------------------------------
C
 6010 FORMAT ('0',A8,'  END  ',A8,9A8,I8)
C
      END
