!------------------------------------------------------------------------------
!
real(fp) FUNCTION SIGE_Z(E)
  use iso_c_binding, only: fp => c_double
  use csigma_mod
  IMPLICIT NONE
  real(fp) ::  e,b,fun,fbosch
  real(fp) ::  energy,einput,zs,add,e_input
  real(fp) ::  fdpc,fendf
!...This function is used to calculate the fusion cross section
!...after a call to sigma has been made.  The functional form of
!...the fusion cross sections is given in the paper by B. H. Duane
!...in BNWL-1685.  The value of the cross section is returned by
!...SIGE and has the units of m**2.
!
!---------------------------
!  MOD DMC 11 SEP 1991 -- SUPPORT BOSCH NEW BOSCH FITS.
!  SEE COMMENTS IN SUBROUTINE SIGMA (SIGMA.F90) FOR FULL EXPLANATION
!
!******************************************************************************
!
  IF(LBOSCH) THEN
!-----------------------
!  BEGINNING OF NEW BOSCH FIT CODE -- DMC 11 SEP 1991
!
     SIGE_Z=0.0_fp
     ENERGY=EFAC*E  ! CONVERT TO CTR OF MASS FRAME
!
     EINPUT=MIN(ENERGY,EHI)
     IF(EINPUT.GE.ELOW) THEN
        IF(EINPUT.LE.EMID) THEN
           ZS=FBOSCH(EINPUT,ALOW(1),ALOW(2),ALOW(3),ALOW(4),ALOW(5),&
                BLOW(1),BLOW(2),BLOW(3),BLOW(4))
        ELSE
           ZS=FBOSCH(EINPUT,AHI(1),AHI(2),AHI(3),AHI(4),AHI(5),&
                BHI(1),BHI(2),BHI(3),BHI(4))
        ENDIF
        IF(ENERGY.GT.EHI) ZS=ZS+SLOPE*(ENERGY-EHI)
        SIGE_Z=1.e-31_fp*(ZS*EXP(-BG/SQRT(ENERGY))/ENERGY)
     ENDIF
!
!  END OF NEW BOSCH FIT CODE
!-----------------------
  endif
  IF(LDPC) THEN
!  BEGINNING OF DPC FIT 06/2018
     SIGE_Z = 0.0_fp
     IF (E .GT. 1.e-3_fp) THEN
        EINPUT=E*FE
!...Note that the energy has been corrected for a possible reverse
!...reaction.
        ADD=BG/SQRT(EINPUT)
        B=EXP(-ADD)
        e_input=min(EINPUT,10000.0_fp*FE) !suggestion by David Coster, 07/09/2018
            ! The problem is that I (DC) have no data for the T-T cross-section beyond 10MeV, 
            ! and so can't work out what the S-function does beyond that.
            ! I suspect a workable solution would be not to extrapolate the S-function
            ! beyond 10 MeV but use its value at 10 MeV, but then apply the other
            ! factors after that ...
               
        ZS=FDPC(E_INPUT,AHI(1),AHI(2),AHI(3),AHI(4),AHI(5),AHI(6),&
             BHI(1),BHI(2),BHI(3),BHI(4),BHI(5))
        SIGE_Z=ZS*B/EINPUT*1.e-31_fp
     endif
  endif
  IF(LFUN) THEN
!-----------------------
!  BEGINNING OF OLD FIT CODE
     IF (E .GT. 1.e-3_fp) THEN
        ENERGY=E*FE*1.e+3_fp
!...Note that the energy has been corrected for a possible reverse
!...reaction.
        ADD=A1/SQRT(ENERGY)
!
        IF (ADD .LT. 87.5_fp) THEN
           B=EXP(-ADD)
           SIGE_Z=FUN(B,A2,A3,A4,A5,ENERGY)
!
           IF (SIGE_Z .GT. 1.e-10_fp) THEN
              SIGE_Z = SIGE_Z*1.e-28_fp
           ELSE
              SIGE_Z = 0.0_fp
           END IF
!     
        ELSE
           SIGE_Z = 0.0_fp
        END IF
!
     ELSE
        SIGE_Z = 0.0_fp
     END IF
!
!  END OF OLD FIT CODE
!-----------------------
  ENDIF
!
  RETURN
END FUNCTION SIGE_Z

!------------------------------------------------------------------------------
! 30Jun2000 fgtok -s r8_precision.sub "r8con.csh conversion"
