
      SUBROUTINE xslorz (ear, ne, param, ifl, photar)

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

c XSPEC model subroutine to calculate a Lorentzian line profile.
c Parameters are :
c         1        Line energy in keV
c         2        Line width in keV.
c
c The Lorentzian is given by :
c
c       L(E) = (W/2*pi) / ( (E-E0)**2 + (W/2)**2 )
c
c where E0 is the line energy and W the line width. This integrates
c analytically to give the contribution in the energy range (E1,E2) as
c
c       L(E1,E2) = (1/pi) ( arctan(2(E2-E0)/W) - arctan(2(E1-E0)/W) )
c
c Note that if W=0 then L=0.

      REAL INVPI
      PARAMETER (INVPI=0.3183099)

      REAL f1, f2
      INTEGER ie

c Trap the case of W=0

      IF ( param(2) .LE. 0 ) THEN
         DO ie = 1, ne
            photar(ie) = 0.
         ENDDO
         RETURN
      ENDIF

c Loop round the energies

      f2 = atan(2*(ear(0)-param(1))/param(2))

      DO ie = 1, ne

         f1 = f2
         f2 = atan(2*(ear(ie)-param(1))/param(2))

         photar(ie) = INVPI * (f2 - f1)

      ENDDO

      RETURN
      END
