      SUBROUTINE  ErrMsg( MESSAG, FATAL )

c        Print out a warning or error message;  abort if error
c        after making symbolic dump (machine-specific)

      LOGICAL       FATAL, MsgLim, Cray
      CHARACTER*(*) MESSAG
      INTEGER       MaxMsg, NumMsg
      SAVE          MaxMsg, NumMsg, MsgLim
      DATA NumMsg / 0 /,  MaxMsg / 100 /,  MsgLim / .FALSE. /


      IF ( FATAL )  THEN
c        WRITE ( *, '(//,2A,//)' )  ' ******* ERROR >>>>>>  ', MESSAG
         call xerror("Fatal:", len("Fatal:"), 2, 1)
         call xerror(messag, len(messag), 1, 1)
         return
      END IF

      NumMsg = NumMsg + 1
      IF( MsgLim )  RETURN

c     IF ( NumMsg.LE.MaxMsg )  THEN
c        WRITE ( *, '(/,2A,/)' )  ' ******* WARNING >>>>>>  ', MESSAG
c     ELSE
c        WRITE ( *,99 )
c        MsgLim = .True.
c     ENDIF
      call xerror(messag, len(messag), 3, 2)

      RETURN

c  99 FORMAT( //,' >>>>>>  TOO MANY WARNING MESSAGES --  ',
c    $   'They will no longer be printed  <<<<<<<', // )
      END

      LOGICAL FUNCTION  WrtBad ( VarNam )

c          Write names of erroneous variables and return 'TRUE'

c      INPUT :   VarNam = Name of erroneous variable to be written
c                         ( CHARACTER, any length )

      CHARACTER*(*)  VarNam
      INTEGER        MaxMsg, NumMsg
      SAVE  NumMsg, MaxMsg
      DATA  NumMsg / 0 /,  MaxMsg / 50 /


      WrtBad = .TRUE.
      NumMsg = NumMsg + 1
c     WRITE ( *, '(3A)' )  ' ****  Input variable  ', VarNam,
c    $                     '  in error  ****'
      call xerror("Input variable error",
     $            len("Input variable error"), 4, 1)
      call xerror(VarNam, len(VarNam), 5, 1)
      IF ( NumMsg.EQ.MaxMsg )
     $   CALL  ErrMsg ( 'Too many input errors.  Aborting...', .TRUE. )
      RETURN
      END

      LOGICAL FUNCTION  WrtDim ( DimNam, MinVal )

c          Write name of too-small symbolic dimension and
c          the value it should be increased to;  return 'TRUE'

c      INPUT :  DimNam = Name of symbolic dimension which is too small
c                        ( CHARACTER, any length )
c               Minval = Value to which that dimension should be
c                        increased (at least)

      CHARACTER*(*)  DimNam
      INTEGER        MinVal


c     WRITE ( *, '(3A,I7)' )  ' ****  Symbolic dimension  ', DimNam,
c    $                     '  should be increased to at least ', MinVal
      call xerror("Dimension too small:", 
     $            len("Dimension too small:"), 6, 1)
      call xerror(DimNam, len(DimNam), 7, 1)
      WrtDim = .TRUE.
      RETURN
      END

      LOGICAL FUNCTION  TstBad( VarNam, RelErr )

c       Write name (VarNam) of variable failing self-test and its
c       percent error from the correct value;  return  'FALSE'.

      CHARACTER*(*)  VarNam
      REAL           RelErr


      TstBad = .FALSE.
c     WRITE( *, '(/,3A,1P,E11.2,A)' )
c    $       ' Output variable ', VarNam,' differed by ', 100.*RelErr,
c    $       ' per cent from correct value.  Self-test failed.'
      call xerror("Output variable error:", 
     $            len("Output variable error:"), 8, 1)
      call xerror(VarNam, len(VarNam), 9, 1)
      RETURN
      END
