*-----------------------------------------------------------------------
*     MSGDMP
*-----------------------------------------------------------------------
      SUBROUTINE MSGDMP(CLEV,CSUB,CMSG)

      CHARACTER CLEV*(*),CSUB*(*),CMSG*(*)

      LOGICAL   LCHREQ
      CHARACTER CLEVX*1,CSUBX*32,CPRC*32,CMSGX*200

      EXTERNAL  LCHREQ,LENC

      SAVE

      DATA      IMSG/0/

      CALL GLIGET('MSGUNIT',IUNIT)
      CALL GLIGET('MAXMSG',MAXMSG)
      CALL GLIGET('MSGLEV',MSGLEV)
      CALL GLIGET('NLNSIZE',LNSIZE)
      CALL PRCLVL(NLEV)
      CALL PRCNAM(MIN(NLEV,1), CPRC)

      CLEVX=CLEV
      CSUBX=CSUB
      LMSG=LENC(CMSG)
      LPRC=LENC(CPRC)
      LSUB=LENC(CSUBX)

      IF (LCHREQ(CLEVX,'E')) THEN
        CMSGX='** Error ('//CSUBX(1:LSUB)// '@ '
     #                    //CPRC(1:LPRC) // ') ' //CMSG(1:LMSG)
        CALL MSZDMP(CMSGX,IUNIT,LNSIZE)
        CALL OSABRT
        STOP
      END IF
      IF (IMSG.LT.MAXMSG) THEN
        IF (LCHREQ(CLEVX,'W') .AND. MSGLEV.LE.1) THEN
          IMSG=IMSG+1
          CMSGX='-Warning ('//CSUBX(1:LSUB)// '@ '
     #                      //CPRC(1:LPRC) // ') ' //CMSG(1:LMSG)
          CALL MSZDMP(CMSGX,IUNIT,LNSIZE)
        ELSE IF (LCHREQ(CLEVX,'M') .AND. MSGLEV.LE.0) THEN
          IMSG=IMSG+1
          CMSGX='-Message ('//CSUBX(1:LSUB)// '@ '
     #                      //CPRC(1:LPRC) // ') '//CMSG(1:LMSG)
          CALL MSZDMP(CMSGX,IUNIT,LNSIZE)
        END IF
        IF (IMSG.EQ.MAXMSG) THEN
          CMSGX='+++ THE FOLLOWING MESSAGES ARE SUPPRESSED.'
          CALL MSZDMP(CMSGX,IUNIT,LNSIZE)
        END IF
      END IF

      END
