C======= MAIN PROGRAM FOR total ========
C======= fast electron inelestic scattering===========
C=======   
      INTEGER NE,NW,NERY
      REAL*8  DERY,ERYMAX,RES1,RES2,
     *    CO,H,XX,K,KVINT,SIGMA,
     *    OM(1000), SIGM(1000),
     *    OM1(1000000),SIGM1(1000000),
     *    F1(1000000),F2(1000000),
     *    ERY(250),ESIGM(250)

C----------------------
      NAMELIST/FAST/NW,H,DERY,ERYMAX,OM,SIGM

      OPEN(5,FILE='SYS$INPU',STATUS='OLD')
      READ(5,FAST)
      OPEN(6,FILE='SYS$OUTP',STATUS='NEW')
C==================
       CO=137.04/2./3.14
      WRITE(6,10) H                       
  10  FORMAT('             FAST ELECTRON '/ 
     *       '   INELASTIC SCATTERING CROSS SECTION '/
     *     '  H= ',F10.7 /
     *     ' OMRy',7X,'SIGM')
      DO 15 I=1,NW
      WRITE(6,20)OM(I),SIGM(I)
  20  FORMAT(2E15.8)       
  15  CONTINUE   
C_______________________
      NE=IDINT((OM(NW)-OM(1))/H)
      WRITE(6,35)NE
  35  FORMAT( ' Ne=',I10/'  Om1          Sigm1   ')       
      XX=OM(1) 
      DO 30 I=1,NE
      OM1(I)=XX
       IF(XX.GT.OM(1).AND.XX.LT.OM(NW))THEN
      SIGM1(I)=KVINT(XX,OM,SIGM,1,NW)
       END IF
      SIGM1(1)=SIGM(1)           
C        IF (I.GT.(NE-10).AND.I.LT.NE)THEN
      WRITE(6,50)OM1(I),SIGM1(I)      
  50  FORMAT(2E15.8)  
C        END IF
      XX=XX+H           
  30  CONTINUE          
C++++++++++++++++++++++++++++++++++

C++++++++++++++++++++++++++++++++++++
      WRITE(6,70)              
  70  FORMAT(8X,' ERY       E*SIGM         SIGM',   
     *  '    E*SIGM_B         RES2 ')      
      NERY=IDINT((ERYMAX-OM1(1))/DERY)
      ERY(1)=OM1(1)

      DO 80 I=1,NERY
C      WRITE(6,58)ERY(I)              
C  58  FORMAT(' ERY(I) ', E15.8)      
      DO 40 J=1,NE
      F1(J)=SIGM1(J)/OM1(J)
      IF(OM1(J).GT.ERY(I)) THEN 
      F1(J)=0.
      END IF
  40  CONTINUE
C      DO 57 J=1,NE
C      WRITE(6,55)F1(J),OM1(J),ERY(I)              
C  55  FORMAT(' F1 ', E15.8, '  ERYJ ',2E15.8)      
C  57  CONTINUE 
      CALL SIMPS(NE,H,F1,RES1)
C      WRITE(6,56)RES1              
C  56  FORMAT(' RES1 ', E15.8)      
       RES1=RES1*CO
      DO 60 J=1,NE         
      F2(J)=SIGM1(J)/OM1(J)*DLOG(OM1(J))
      IF(OM1(J).GT.ERY(I)) THEN 
      F2(J)=0.
      END IF
  60  CONTINUE
      CALL SIMPS(NE,H,F2,RES2)
       RES2=RES2*CO
C      WRITE(6,56)RES2              
C  56  FORMAT(' RES2 `', E15.8)      
      K=4.*ERY(I)
      ESIGM(I)=DLOG(K)*RES1-RES2
      SIGMA=ESIGM(I)/ERY(I)
       WRITE(6,75)ERY(I),ESIGM(I),SIGMA,RES1,RES2
  75   FORMAT(5E15.8) 
      ERY(I+1)=ERY(I)+DERY     
  80  CONTINUE
      STOP
      END