      SUBROUTINE DIVIDE(CDIVID,X1,X2,NX,MXARY,ARY)
C Arguments:
      REAL X1,X2
      INTEGER MXARY,NX
      CHARACTER CDIVID*3
      REAL ARY(MXARY)
C
C Local variables:
      INTEGER I
      REAL DELTA
C
C External Subroutines:
      EXTERNAL ERRMSG,WRIMSG
C
C Intrinsic Functions:
      INTRINSIC REAL
C***********************************************************************
C Given:
C       CDIVID='LIN','INV', or 'LOG'
C       X1 = lower limit to interval
C       X2 = upper limit to interval
C       NX = number of elements
C       MXARY=dimensioning information for array ARY
C
C Returns:
C       ARY(1-NX)=vector of points with
C                 ARY(1)=X1
C                 ARY(NX)=X2
C                 ARY(J) values spaced either
C                        linearly (if CDIVID.EQ.'LIN')
C                        linearly in 1/X (if CDIVID.EQ.'INV')
C                        logarithmically (if CDIVID.EQ.'LOG')
C
C Copyright (C) 1993, B.T. Draine and P.J. Flatau
C This code is covered by the GNU General Public License.
C***********************************************************************
      IF(NX.GT.MXARY)THEN
         CALL ERRMSG('FATAL','DIVIDE','  NX .GT. MXARY ')
      ENDIF
C      IF(X1.GT.X2)THEN
C         CALL ERRMSG('FATAL','DIVIDE','  X1 .GT. X2 ')
C      ENDIF
      IF(NX.LT.1)THEN
         CALL ERRMSG('FATAL','DIVIDE','  NX .LT. 1 ')
      ENDIF
      IF(NX.EQ.1)THEN
         CALL WRIMSG('DIVIDE',' Only one element initialized ')
         ARY(1)=X1
      ELSE
         IF(CDIVID.EQ.'LIN')THEN
            DELTA=(X2-X1)/REAL(NX-1)
            DO 10 I=1,NX
               ARY(I)=X1+DELTA*REAL(I-1)
   10       CONTINUE
         ELSEIF(CDIVID.EQ.'INV')THEN
            DELTA=(1./X2-1./X1)/REAL(NX-1)
            DO 20 I=1,NX
               ARY(I)=1./(1./X1+DELTA*REAL(I-1))
   20       CONTINUE
         ELSEIF(CDIVID.EQ.'LOG')THEN
            DELTA=ALOG(X2/X1)/REAL(NX-1)
            DO 30 I=1,NX
               ARY(I)=EXP(ALOG(X1)+DELTA*REAL(I-1))
   30       CONTINUE
         ENDIF
      ENDIF
      RETURN
      END
