      SUBROUTINE dordblur (ear, ne, param, ifl, photar, tmp)

      IMPLICIT NONE

      INTEGER ne, ifl
      REAL ear(0:ne), param(4), photar(ne), tmp(ne)

c Subroutine to smooth the model spectrum by relativistic effects from a
c disk in the presence of a non-spinning black hole - uses xsdili. 
c ACF and RMJ May/June 1998

c Arguments :
c    ear      r        i: Energy ranges
c    ne       i        i: Number of elements in photar array
c    param    r        i: Model parameters

c  parameters :
c       1        power law index for emissivity (10 for disk)
c       2        inner radius (GM/c**2)
c       3        outer radius (GM/c**2)
c       4        inclination  (degrees)

c    ifl      i        i: Data set
c    photar   r      i/r: Model flux
c    tmp      r        i: Dynamically allocated workspace array
c                         (This was added Mar 09, removed udmget)


      INTEGER MAXB, HALFMAXB
      PARAMETER (MAXB=1000,HALFMAXB=MAXB/2)

      REAL energy,sum,earb(0:MAXB)
      REAL paramb(5), photarb(MAXB)
      REAL r1, r2, f1, f2

      INTEGER ie, je, i
      INTEGER if, if1, if2

      LOGICAL first

      save first,earb
      DATA first/.true./
      if (first) then
         do i=0,MAXB
           earb(i)=20.0*float(i)/float(MAXB)
         end do
         first=.false.
      end if
      paramb(1)=10.
      paramb(2)=param(1)
      paramb(3)=param(2)
      paramb(4)=param(3)
      paramb(5)=param(4)
      call xsdili(earb,MAXB,paramb,ifl,photarb)

       do ie=1,ne
         tmp(ie)=0.0
       enddo

c Loop over energy ranges for the current dataset
      
	sum=0.
	do i=1,maxb
	  sum=sum+photarb(i)
	enddo
        IF ( sum .NE. 0.0 .AND. sum .NE. 1.0 ) THEN
	  do i=1,maxb
	    photarb(i)=photarb(i)/sum
	  enddo
        ENDIF
c
	do ie=1,ne
	  energy=0.5*(ear(ie-1)+ear(ie))
	  do je=1,ne
   	     f1=ear(je-1)/energy*float(halfmaxb)*
     :                    (1.0+1.0/float(halfmaxb))
	     f2=ear(je)/energy*float(halfmaxb)*
     :                    (1.0+1.0/float(halfmaxb))
	     if1=f1
	     r1=f1-if1
	     if2=f2
	     r2=f2-if2
	     sum=0.0

             do if=if1+1,if2-1
                if(if.ge.1.and.if.le.maxb)then
	           sum=sum+photarb(if)
	        endif
             end do
             
             if(if1.ge.1.and.if1.le.maxb)then
               sum=sum+(1.0-r1)*photarb(if1)
             end if
             
             if(if2.ge.1.and.if2.le.maxb)then
                sum=sum+(r2)*photarb(if2)
             end if
             
             if (if1 .eq. if2) then
               if(if1.ge.1.and.if1.le.maxb)then
                 sum=sum-photarb(if1)
               end if
             end if
             
	     tmp(je)=tmp(je)+photar(ie)*sum
	  enddo
	enddo


      DO ie = 1, ne
         photar(ie) = tmp(ie)
      ENDDO

      RETURN
      END

