      SUBROUTINE ERRMSG(CSTATS,CSUBRT,CMSGNM)
      IMPLICIT NONE
C Arguments:
      CHARACTER CMSGNM*(*),CSTATS*(*),CSUBRT*(*)
C
C Local variables:
      INTEGER IOERR
C
C***********************************************************************
C Given:
C       CSTATS = 'WARNING' or 'FATAL'
C       CSUBRT = name of subroutine
C       CMESGN = message
C Prints a warning message in a standardized way,
C and STOPs if CSTATS='FATAL'
C
C Copyright (C) 1993, B.T. Draine and P.J. Flatau
C This code is covered by the GNU General Public License.
C
C History:
C 96.11.14 (PJF) Remove "getset" and hardwire "ioerr"
c 04.05.23 (BTD) cleanup
c end history
C***********************************************************************
      DATA IOERR/6/
      IF(CSTATS.EQ.'FATAL')THEN
         WRITE(IOERR,FMT=9000)CSUBRT
         WRITE(IOERR,FMT=9010)CMSGNM
         WRITE(IOERR,FMT=9020)
         STOP
      ELSEIF(CSTATS.EQ.'WARNING')THEN
         WRITE(IOERR,FMT=9030)CSUBRT
         WRITE(IOERR,FMT=9010)CMSGNM
      ENDIF
      RETURN
 9000 FORMAT(/,' >>>>> FATAL ERROR IN PROCEDURE: ',A)
 9010 FORMAT(1X,A)
 9020 FORMAT(' >>>>> EXECUTION ABORTED ')
 9030 FORMAT(/,' >>>>> WARNING IN PROCEDURE: ',A)
      END
