!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
!
real(fp) FUNCTION FSVGEN_Z(V,IREACT,INTG)
!
!  DMC - ARGUMENT INTG DETERMINES WHICH INTEGRAL
!  <SIGMA*V>, <SIGMA*V*VX>, <SIGMA*V*V**2>
!     0          1             2
!
!      - ARGUMENT IREACT:
!        =1: CX
!        =2: II
!
!---------------------------
!
!  *** DMC JUNE 1989 ***
!  ARGUMENT IREACT IS NOW OBSOLETE, BUT IS RETAINED FOR COMPATIBILITY
!  FSVGEN AND OTHER CROSS-SECTION / REACTION RATE TABLE INTEGRATION
!  ROUTINES HAVE BEEN INTEGRATED INTO A SINGLE PROGRAM, SIGTAB, VIA
!  A SUBROUTINE LIBRARY, SIGSUB_LIB, WHICH HAS ITS OWN COMMON BLOCK
!  AND GENERAL CROSS SECTION ROUTINE, SIGALL.  THE ACTUAL REACTION
!  BEING CONSIDERED IS IDENTIFIED IN SIGSUB COMMON.  POSSIBILITIES
!  INCLUDE HELIUM REACTIONS, ETC. WHEREAS THE ORIGINAL VERSION OF
!  THIS ROUTINE ASSUMED HYDROGEN ONLY.
!
!---------------------------
!
!============
! idecl:  explicitize implicit INTEGER declarations:
  use iso_c_binding, only: fp => c_double
  use sigtabl_mod, only : VCFAC,ifun,VI,T,B2
  IMPLICIT NONE
  INTEGER intg,ireact
!============
! idecl:  explicitize implicit DOUBLE PRECISION declarations:
!     DOUBLE PRECISION vi,t,b2,u,b2inv,d,d2,z,z2,e1,ee2,exp1,exp2,
!    > ee1,e2,zsig,zdum,zans
!============
  real(fp) u,b2inv,d,d2,z,z2,e1,ee2,exp1,exp2,ee1,e2,zsig,&
       zdum,zans
  real(fp) V,E
  real(fp) SIGALL_Z
!
!	COMMON PARAMETERS
!	VI - SPEED OF INJECTED PARTICLE (CM/SEC)
!	T=.5E00*TMASS/C**2
!	B2 - BMASS(2)/(2.E00*TEMP(2))
!
  U=V/VCFAC
  B2INV=1.0_fp/B2
  E=T*U**2
  D=VI-U
  D2=D*D
  Z=VI+U
  Z2=Z*Z
!
!  EXP(-B2*(VI-U)**2) TERM
  E1=-B2*D2
  IF(E1.LT.-180.0_fp) GO TO 2000
!
  IF(INTG.EQ.0) THEN
     EE2=1.0_fp
  ELSE IF(INTG.EQ.1) THEN
     EE2=D+1.0_fp/(2.0_fp*B2*VI)
  ELSE IF(INTG.EQ.2) THEN
     EE2=D2+B2INV
  ELSE
     write(6,9999) INTG
9999 FORMAT(' FSVGEN:  ILLEGAL INTG=',I10)
     call bad_exit
  ENDIF
!
  EXP1=exp(E1)
!
  EXP2=0.0_fp
  EE1=1.0_fp
!
  E2=-B2*Z2
  IF(E2.LT.-180.0_fp) GO TO 1000
!
!  EXP(-B2*(VI+U)**2) TERM
  EXP2=exp(E2)
!
  IF(INTG.EQ.0) THEN
     EE1=1.0_fp
  ELSE IF(INTG.EQ.1) THEN
     EE1=Z+1.0_fp/(2.0_fp*B2*VI)
  ELSE IF(INTG.EQ.2) THEN
     EE1=Z2+B2INV
  ENDIF
!-----------------------------------------
1000  CONTINUE
!
  ZSIG=1.e+4_fp*SIGALL_Z(E,ZDUM)
!
  ZANS=ZSIG*U*U*(EXP1*EE2-EXP2*EE1)
!
  FSVGEN_Z=ZANS
!
  RETURN
!-----------------------------------------
2000  FSVGEN_Z=0.0_fp
  RETURN
END FUNCTION FSVGEN_Z
!
!******************* END FILE FSVGEN_Z.FOR ; GROUP FSVINT *********************
! 30Jun2000 fgtok -s r8_precision.sub "r8con.csh conversion"
