! -----------------------------------------------------------------------------
! This file was automatically created by SARAH version 4.12.2
! SARAH References: arXiv:0806.0538, 0909.2863, 1002.0840, 1207.0906, 1309.7223
! (c) Florian Staub, 2013
! ------------------------------------------------------------------------------
! File created at 18:22 on 2.10.2017
! ----------------------------------------------------------------------

Module SvRe3Decays_seesaw1nmssm

Use Control
Use Settings
Use CouplingsForDecays_seesaw1nmssm
Use ThreeBodyPhaseSpaceS

Contains

Subroutine SvReThreeBodyDecay(n_in,MAh,MAh2,MCha,MCha2,MChi,MChi2,MFd,MFd2,           &
& MFe,MFe2,MFu,MFu2,MFv,MFv2,MGlu,MGlu2,Mhh,Mhh2,MHpm,MHpm2,MSd,MSd2,MSe,MSe2,           &
& MSu,MSu2,MSvIm,MSvIm2,MSvRe,MSvRe2,MVWm,MVWm2,MVZ,MVZ2,pG,TW,UM,UP,UV,v,               &
& ZA,ZD,ZDL,ZDR,ZE,ZEL,ZER,ZH,ZN,ZP,ZU,ZUL,ZUR,ZVI,ZVR,ZW,ZZ,betaH,g1,g2,g3,             &
& Yd,Ye,lam,kap,lamN,Yu,Yv,Td,Te,Tlam,Tk,TLN,Tu,Tv,mq2,ml2,mHd2,mHu2,md2,mu2,            &
& me2,mv2,ms2,M1,M2,M3,vd,vu,vS,gSvReAhChacFe,gSvReAhChiFv,gSvRecSeChaChi,               &
& gSvRecHpmChaFv,gSvRehhChacFe,gSvReSvImChacCha,gSvReSvReChacCha,gSvReSvImChiChi,        &
& gSvReSvReChiChi,gSvRecHpmChiFe,gSvRehhChiFv,gSvReFeFucSd,gSvRecSeFeFv,gSvReFeSucFd,    &
& gSvReSvImFecFe,gSvReSvReFecFe,gSvReFvFdcSd,gSvReFvFucSu,gSvReSvImFvFv,gSvReSvReFvFv,   &
& gSvReSeFucFd,gSvReSvImFdcFd,gSvReSvImFucFu,gSvReSvReFdcFd,gSvReSvReFucFu,              &
& epsI,deltaM,CheckRealStates,gT,gPartial,BR)

Implicit None

Real(dp),Intent(in) :: MAh(3),MAh2(3),MCha(2),MCha2(2),MChi(5),MChi2(5),MFd(3),MFd2(3),MFe(3),               &
& MFe2(3),MFu(3),MFu2(3),MFv(6),MFv2(6),MGlu,MGlu2,Mhh(3),Mhh2(3),MHpm(2),               &
& MHpm2(2),MSd(6),MSd2(6),MSe(6),MSe2(6),MSu(6),MSu2(6),MSvIm(6),MSvIm2(6),              &
& MSvRe(6),MSvRe2(6),MVWm,MVWm2,MVZ,MVZ2,TW,v,ZA(3,3),ZH(3,3),ZP(2,2),ZZ(2,2),betaH

Complex(dp),Intent(in) :: pG,UM(2,2),UP(2,2),UV(6,6),ZD(6,6),ZDL(3,3),ZDR(3,3),ZE(6,6),ZEL(3,3),ZER(3,3),       &
& ZN(5,5),ZU(6,6),ZUL(3,3),ZUR(3,3),ZVI(6,6),ZVR(6,6),ZW(2,2)

Complex(dp) :: cplAhSvImSvRe(3,6,6),cplAhSvReSvRe(3,6,6),cplcChaChaAhL(2,2,3),cplcChaChaAhR(2,2,3),  &
& cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaChaVZL(2,2),cplcChaChaVZR(2,2),       &
& cplcChaFeSvImL(2,3,6),cplcChaFeSvImR(2,3,6),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),&
& cplcFdChaSuL(3,2,6),cplcFdChaSuR(3,2,6),cplcFdFdAhL(3,3,3),cplcFdFdAhR(3,3,3),         &
& cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3),cplcFdFdVZL(3,3),cplcFdFdVZR(3,3),               &
& cplcFdFuHpmL(3,3,2),cplcFdFuHpmR(3,3,2),cplcFdFuVWmL(3,3),cplcFdFuVWmR(3,3),           &
& cplcFeChaSvImL(3,2,6),cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),&
& cplcFeFeAhL(3,3,3),cplcFeFeAhR(3,3,3),cplcFeFehhL(3,3,3),cplcFeFehhR(3,3,3),           &
& cplcFeFeVZL(3,3),cplcFeFeVZR(3,3),cplcFuFuAhL(3,3,3),cplcFuFuAhR(3,3,3),               &
& cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3),cplcFuFuVZL(3,3),cplcFuFuVZR(3,3),               &
& cplChaFucSdL(2,3,6),cplChaFucSdR(2,3,6),cplChiChacHpmL(5,2,2),cplChiChacHpmR(5,2,2),   &
& cplChiChacVWmL(5,2),cplChiChacVWmR(5,2),cplChiChiAhL(5,5,3),cplChiChiAhR(5,5,3),       &
& cplChiChihhL(5,5,3),cplChiChihhR(5,5,3),cplChiChiVZL(5,5),cplChiChiVZR(5,5),           &
& cplChiFdcSdL(5,3,6),cplChiFdcSdR(5,3,6),cplChiFecSeL(5,3,6),cplChiFecSeR(5,3,6),       &
& cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplChiFvSvImL(5,6,6),cplChiFvSvImR(5,6,6),     &
& cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),cplFvChacSeL(6,2,6),cplFvChacSeR(6,2,6),     &
& cplFvFecHpmL(6,3,2),cplFvFecHpmR(6,3,2),cplFvFecVWmL(6,3),cplFvFecVWmR(6,3),           &
& cplFvFvAhL(6,6,3),cplFvFvAhR(6,6,3),cplFvFvhhL(6,6,3),cplFvFvhhR(6,6,3),               &
& cplFvFvVZL(6,6),cplFvFvVZR(6,6),cplhhSvImSvRe(3,6,6),cplhhSvReSvRe(3,6,6),             &
& cplHpmSvRecSe(2,6,6),cplSeSvRecHpm(6,6,2),cplSeSvRecVWm(6,6),cplSvImSvReVZ(6,6),       &
& cplSvRecSeVWm(6,6)

Real(dp),Intent(in) :: g1,g2,g3,mHd2,mHu2,ms2,vd,vu,vS

Complex(dp),Intent(in) :: Yd(3,3),Ye(3,3),lam,kap,lamN(3,3),Yu(3,3),Yv(3,3),Td(3,3),Te(3,3),Tlam,               &
& Tk,TLN(3,3),Tu(3,3),Tv(3,3),mq2(3,3),ml2(3,3),md2(3,3),mu2(3,3),me2(3,3),              &
& mv2(3,3),M1,M2,M3

Real(dp),Intent(inout) :: gSvReAhChacFe(6,3,2,3),gSvReAhChiFv(6,3,5,6),gSvRecSeChaChi(6,6,2,5),gSvRecHpmChaFv(6,2,2,6),&
& gSvRehhChacFe(6,3,2,3),gSvReSvImChacCha(6,6,2,2),gSvReSvReChacCha(6,6,2,2),            &
& gSvReSvImChiChi(6,6,5,5),gSvReSvReChiChi(6,6,5,5),gSvRecHpmChiFe(6,2,5,3),             &
& gSvRehhChiFv(6,3,5,6),gSvReFeFucSd(6,3,3,6),gSvRecSeFeFv(6,6,3,6),gSvReFeSucFd(6,3,6,3),&
& gSvReSvImFecFe(6,6,3,3),gSvReSvReFecFe(6,6,3,3),gSvReFvFdcSd(6,6,3,6),gSvReFvFucSu(6,6,3,6),&
& gSvReSvImFvFv(6,6,6,6),gSvReSvReFvFv(6,6,6,6),gSvReSeFucFd(6,6,3,3),gSvReSvImFdcFd(6,6,3,3),&
& gSvReSvImFucFu(6,6,3,3),gSvReSvReFdcFd(6,6,3,3),gSvReSvReFucFu(6,6,3,3)

Real(dp) :: gSvReAhChacFei(3,2,3),gSvReAhChiFvi(3,5,6),gSvRecSeChaChii(6,2,5),gSvRecHpmChaFvi(2,2,6),&
& gSvRehhChacFei(3,2,3),gSvReSvImChacChai(6,2,2),gSvReSvReChacChai(6,2,2),               &
& gSvReSvImChiChii(6,5,5),gSvReSvReChiChii(6,5,5),gSvRecHpmChiFei(2,5,3),gSvRehhChiFvi(3,5,6),&
& gSvReFeFucSdi(3,3,6),gSvRecSeFeFvi(6,3,6),gSvReFeSucFdi(3,6,3),gSvReSvImFecFei(6,3,3), &
& gSvReSvReFecFei(6,3,3),gSvReFvFdcSdi(6,3,6),gSvReFvFucSui(6,3,6),gSvReSvImFvFvi(6,6,6),&
& gSvReSvReFvFvi(6,6,6),gSvReSeFucFdi(6,3,3),gSvReSvImFdcFdi(6,3,3),gSvReSvImFucFui(6,3,3),&
& gSvReSvReFdcFdi(6,3,3),gSvReSvReFucFui(6,3,3)

Real(dp), Intent(inout), Optional :: BR(:,:), gPartial(:,:)
Real(dp), Intent(inout) :: gT(:)
Integer, Intent(in) :: n_in
Real(dp), Intent(in) :: epsI, deltaM
Logical, Intent(in) ::  CheckRealStates
Integer :: i_start, i_end, i_run, n_out, n_length, gt1, gt2, gt3, i1
Logical :: check
Iname = Iname +1
NameOfUnit(Iname) = 'SvReThreeBodyDecay'

If (CheckRealStates) Then
Else
End If

check=CheckRealStates

If (n_in.Lt.0) Then
 i_start = 1
 i_end = 6
 Else If ( (n_in.Ge.1).And.(n_in.Le. 6) ) Then
 i_start = n_in
 i_end = n_in
Else
 If (ErrorLevel.Ge.-1) Then
   Write (ErrCan, *) 'Problem in subroutine'//NameOfUnit(Iname)
   Write (ErrCan, *) 'Value of n_in out of range, (n_in,6) = ',n_in,6
 End If

 If (ErrorLevel.Gt.0) Call TerminateProgram

 If (Present(BR)) BR = 0._dp
 Iname = Iname - 1
 Return
End If

Do i_run = i_start, i_end

Call CouplingsFor_SvRe_decays_3B(MSvRe(i_run),i_run,MAh,MAh2,MCha,MCha2,              &
& MChi,MChi2,MFd,MFd2,MFe,MFe2,MFu,MFu2,MFv,MFv2,MGlu,MGlu2,Mhh,Mhh2,MHpm,               &
& MHpm2,MSd,MSd2,MSe,MSe2,MSu,MSu2,MSvIm,MSvIm2,MSvRe,MSvRe2,MVWm,MVWm2,MVZ,             &
& MVZ2,pG,TW,UM,UP,UV,v,ZA,ZD,ZDL,ZDR,ZE,ZEL,ZER,ZH,ZN,ZP,ZU,ZUL,ZUR,ZVI,ZVR,            &
& ZW,ZZ,betaH,g1,g2,g3,Yd,Ye,lam,kap,lamN,Yu,Yv,Td,Te,Tlam,Tk,TLN,Tu,Tv,mq2,             &
& ml2,mHd2,mHu2,md2,mu2,me2,mv2,ms2,M1,M2,M3,vd,vu,vS,cplAhSvImSvRe,cplAhSvReSvRe,       &
& cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaChaVZL,cplcChaChaVZR,   &
& cplcChaFeSvImL,cplcChaFeSvImR,cplcChaFeSvReL,cplcChaFeSvReR,cplcFdChaSuL,              &
& cplcFdChaSuR,cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,cplcFdFdVZL,              &
& cplcFdFdVZR,cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL,cplcFdFuVWmR,cplcFeChaSvImL,        &
& cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,      &
& cplcFeFehhR,cplcFeFeVZL,cplcFeFeVZR,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL,               &
& cplcFuFuhhR,cplcFuFuVZL,cplcFuFuVZR,cplChaFucSdL,cplChaFucSdR,cplChiChacHpmL,          &
& cplChiChacHpmR,cplChiChacVWmL,cplChiChacVWmR,cplChiChiAhL,cplChiChiAhR,cplChiChihhL,   &
& cplChiChihhR,cplChiChiVZL,cplChiChiVZR,cplChiFdcSdL,cplChiFdcSdR,cplChiFecSeL,         &
& cplChiFecSeR,cplChiFucSuL,cplChiFucSuR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,      &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFecHpmL,cplFvFecHpmR,cplFvFecVWmL,        &
& cplFvFecVWmR,cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,        &
& cplhhSvImSvRe,cplhhSvReSvRe,cplHpmSvRecSe,cplSeSvRecHpm,cplSeSvRecVWm,cplSvImSvReVZ,   &
& cplSvRecSeVWm,deltaM)

gSvReAhChacFei = 0._dp
Call SvReToAhChacFe(i_run,MAh,MCha,MFe,MSvIm,MSvRe,cplAhSvImSvRe,cplAhSvReSvRe,       &
& cplcChaChaAhL,cplcChaChaAhR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,              &
& cplcFeChaSvReR,cplcFeFeAhL,cplcFeFeAhR,deltaM,epsI,check,gSvReAhChacFei)

gSvReAhChacFe(i_run,:,:,:) = gSvReAhChacFei
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReAhChacFei)

gSvReAhChiFvi = 0._dp
Call SvReToAhChiFv(i_run,MAh,MChi,MFv,MSvIm,MSvRe,cplAhSvImSvRe,cplAhSvReSvRe,        &
& cplChiChiAhL,cplChiChiAhR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& cplFvFvAhL,cplFvFvAhR,deltaM,epsI,check,gSvReAhChiFvi)

gSvReAhChiFv(i_run,:,:,:) = gSvReAhChiFvi
gT(i_run) = gT(i_run) + Sum(gSvReAhChiFvi)

gSvRecSeChaChii = 0._dp
Call SvReTocSeChaChi(i_run,MSe,MCha,MChi,MVWm,MHpm,MFe,MFv,MSvRe,cplHpmSvRecSe,       &
& cplSvRecSeVWm,cplcFeChaSvReL,cplcFeChaSvReR,cplChiChacHpmL,cplChiChacHpmR,             &
& cplChiChacVWmL,cplChiChacVWmR,cplChiFecSeL,cplChiFecSeR,cplChiFvSvReL,cplChiFvSvReR,   &
& cplFvChacSeL,cplFvChacSeR,deltaM,epsI,check,gSvRecSeChaChii)

gSvRecSeChaChi(i_run,:,:,:) = gSvRecSeChaChii
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvRecSeChaChii)

gSvRecHpmChaFvi = 0._dp
Call SvReTocHpmChaFv(i_run,MHpm,MCha,MFv,MSe,MFe,MChi,MSvRe,cplSeSvRecHpm,            &
& cplcFeChaSvReL,cplcFeChaSvReR,cplChiChacHpmL,cplChiChacHpmR,cplChiFvSvReL,             &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFecHpmL,cplFvFecHpmR,deltaM,              &
& epsI,check,gSvRecHpmChaFvi)

gSvRecHpmChaFv(i_run,:,:,:) = gSvRecHpmChaFvi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvRecHpmChaFvi)

gSvRehhChacFei = 0._dp
Call SvReTohhChacFe(i_run,Mhh,MCha,MFe,MSvIm,MSvRe,cplhhSvImSvRe,cplhhSvReSvRe,       &
& cplcChaChahhL,cplcChaChahhR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,              &
& cplcFeChaSvReR,cplcFeFehhL,cplcFeFehhR,deltaM,epsI,check,gSvRehhChacFei)

gSvRehhChacFe(i_run,:,:,:) = gSvRehhChacFei
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvRehhChacFei)

gSvReSvImChacChai = 0._dp
Call SvReToSvImChacCha(i_run,MSvIm,MCha,MVZ,MAh,Mhh,MFe,MSvRe,cplAhSvImSvRe,          &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,   &
& cplcChaChaVZL,cplcChaChaVZR,cplcChaFeSvImL,cplcChaFeSvImR,cplcChaFeSvReL,              &
& cplcChaFeSvReR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,            &
& deltaM,epsI,check,gSvReSvImChacChai)

gSvReSvImChacCha(i_run,:,:,:) = gSvReSvImChacChai
gT(i_run) = gT(i_run) + Sum(gSvReSvImChacChai)

gSvReSvReChacChai = 0._dp
Call SvReToSvReChacCha(i_run,MSvRe,MCha,MAh,Mhh,MFe,cplAhSvReSvRe,cplhhSvReSvRe,      &
& cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaFeSvReL,cplcChaFeSvReR, &
& cplcFeChaSvReL,cplcFeChaSvReR,deltaM,epsI,check,gSvReSvReChacChai)

gSvReSvReChacCha(i_run,:,:,:) = gSvReSvReChacChai
gT(i_run) = gT(i_run) + Sum(gSvReSvReChacChai)

gSvReSvImChiChii = 0._dp
Call SvReToSvImChiChi(i_run,MSvIm,MChi,MVZ,MAh,Mhh,MFv,MSvRe,cplAhSvImSvRe,           &
& cplhhSvImSvRe,cplSvImSvReVZ,cplChiChiAhL,cplChiChiAhR,cplChiChihhL,cplChiChihhR,       &
& cplChiChiVZL,cplChiChiVZR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& deltaM,epsI,check,gSvReSvImChiChii)

gSvReSvImChiChi(i_run,:,:,:) = gSvReSvImChiChii
gT(i_run) = gT(i_run) + Sum(gSvReSvImChiChii)

gSvReSvReChiChii = 0._dp
Call SvReToSvReChiChi(i_run,MSvRe,MChi,MAh,Mhh,MFv,cplAhSvReSvRe,cplhhSvReSvRe,       &
& cplChiChiAhL,cplChiChiAhR,cplChiChihhL,cplChiChihhR,cplChiFvSvReL,cplChiFvSvReR,       &
& deltaM,epsI,check,gSvReSvReChiChii)

gSvReSvReChiChi(i_run,:,:,:) = gSvReSvReChiChii
gT(i_run) = gT(i_run) + Sum(gSvReSvReChiChii)

gSvRecHpmChiFei = 0._dp
Call SvReTocHpmChiFe(i_run,MHpm,MChi,MFe,MSe,MCha,MFv,MSvRe,cplSeSvRecHpm,            &
& cplcChaFeSvReL,cplcChaFeSvReR,cplChiChacHpmL,cplChiChacHpmR,cplChiFecSeL,              &
& cplChiFecSeR,cplChiFvSvReL,cplChiFvSvReR,cplFvFecHpmL,cplFvFecHpmR,deltaM,             &
& epsI,check,gSvRecHpmChiFei)

gSvRecHpmChiFe(i_run,:,:,:) = gSvRecHpmChiFei
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvRecHpmChiFei)

gSvRehhChiFvi = 0._dp
Call SvReTohhChiFv(i_run,Mhh,MChi,MFv,MSvIm,MSvRe,cplhhSvImSvRe,cplhhSvReSvRe,        &
& cplChiChihhL,cplChiChihhR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& cplFvFvhhL,cplFvFvhhR,deltaM,epsI,check,gSvRehhChiFvi)

gSvRehhChiFv(i_run,:,:,:) = gSvRehhChiFvi
gT(i_run) = gT(i_run) + Sum(gSvRehhChiFvi)

gSvReFeFucSdi = 0._dp
Call SvReToFeFucSd(i_run,MFe,MFu,MSd,MCha,MSvRe,cplcChaFeSvReL,cplcChaFeSvReR,        &
& cplChaFucSdL,cplChaFucSdR,deltaM,epsI,check,gSvReFeFucSdi)

gSvReFeFucSd(i_run,:,:,:) = gSvReFeFucSdi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReFeFucSdi)

gSvRecSeFeFvi = 0._dp
Call SvReTocSeFeFv(i_run,MSe,MFe,MFv,MVWm,MHpm,MCha,MChi,MSvRe,cplHpmSvRecSe,         &
& cplSvRecSeVWm,cplcChaFeSvReL,cplcChaFeSvReR,cplChiFecSeL,cplChiFecSeR,cplChiFvSvReL,   &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFecHpmL,cplFvFecHpmR,cplFvFecVWmL,        &
& cplFvFecVWmR,deltaM,epsI,check,gSvRecSeFeFvi)

gSvRecSeFeFv(i_run,:,:,:) = gSvRecSeFeFvi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvRecSeFeFvi)

gSvReFeSucFdi = 0._dp
Call SvReToFeSucFd(i_run,MFe,MSu,MFd,MCha,MSvRe,cplcChaFeSvReL,cplcChaFeSvReR,        &
& cplcFdChaSuL,cplcFdChaSuR,deltaM,epsI,check,gSvReFeSucFdi)

gSvReFeSucFd(i_run,:,:,:) = gSvReFeSucFdi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReFeSucFdi)

gSvReSvImFecFei = 0._dp
Call SvReToSvImFecFe(i_run,MSvIm,MFe,MVZ,MAh,Mhh,MCha,MSvRe,cplAhSvImSvRe,            &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcChaFeSvImL,cplcChaFeSvImR,cplcChaFeSvReL,              &
& cplcChaFeSvReR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,            &
& cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,cplcFeFeVZL,cplcFeFeVZR,               &
& deltaM,epsI,check,gSvReSvImFecFei)

gSvReSvImFecFe(i_run,:,:,:) = gSvReSvImFecFei
gT(i_run) = gT(i_run) + Sum(gSvReSvImFecFei)

gSvReSvReFecFei = 0._dp
Call SvReToSvReFecFe(i_run,MSvRe,MFe,MAh,Mhh,MCha,cplAhSvReSvRe,cplhhSvReSvRe,        &
& cplcChaFeSvReL,cplcChaFeSvReR,cplcFeChaSvReL,cplcFeChaSvReR,cplcFeFeAhL,               &
& cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,deltaM,epsI,check,gSvReSvReFecFei)

gSvReSvReFecFe(i_run,:,:,:) = gSvReSvReFecFei
gT(i_run) = gT(i_run) + Sum(gSvReSvReFecFei)

gSvReFvFdcSdi = 0._dp
Call SvReToFvFdcSd(i_run,MFv,MFd,MSd,MChi,MSvRe,cplChiFdcSdL,cplChiFdcSdR,            &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,gSvReFvFdcSdi)

gSvReFvFdcSd(i_run,:,:,:) = gSvReFvFdcSdi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReFvFdcSdi)

gSvReFvFucSui = 0._dp
Call SvReToFvFucSu(i_run,MFv,MFu,MSu,MChi,MSvRe,cplChiFucSuL,cplChiFucSuR,            &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,gSvReFvFucSui)

gSvReFvFucSu(i_run,:,:,:) = gSvReFvFucSui
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReFvFucSui)

gSvReSvImFvFvi = 0._dp
Call SvReToSvImFvFv(i_run,MSvIm,MFv,MVZ,MAh,Mhh,MChi,MSvRe,cplAhSvImSvRe,             &
& cplhhSvImSvRe,cplSvImSvReVZ,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,   &
& cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,deltaM,              &
& epsI,check,gSvReSvImFvFvi)

gSvReSvImFvFv(i_run,:,:,:) = gSvReSvImFvFvi
gT(i_run) = gT(i_run) + Sum(gSvReSvImFvFvi)

gSvReSvReFvFvi = 0._dp
Call SvReToSvReFvFv(i_run,MSvRe,MFv,MAh,Mhh,MChi,cplAhSvReSvRe,cplhhSvReSvRe,         &
& cplChiFvSvReL,cplChiFvSvReR,cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,               &
& deltaM,epsI,check,gSvReSvReFvFvi)

gSvReSvReFvFv(i_run,:,:,:) = gSvReSvReFvFvi
gT(i_run) = gT(i_run) + Sum(gSvReSvReFvFvi)

gSvReSeFucFdi = 0._dp
Call SvReToSeFucFd(i_run,MSe,MFu,MFd,MVWm,MHpm,MSvRe,cplSeSvRecHpm,cplSeSvRecVWm,     &
& cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL,cplcFdFuVWmR,deltaM,epsI,check,gSvReSeFucFdi)

gSvReSeFucFd(i_run,:,:,:) = gSvReSeFucFdi
gT(i_run) = gT(i_run) + 2._dp*Sum(gSvReSeFucFdi)

gSvReSvImFdcFdi = 0._dp
Call SvReToSvImFdcFd(i_run,MSvIm,MFd,MVZ,MAh,Mhh,MSvRe,cplAhSvImSvRe,cplhhSvImSvRe,   &
& cplSvImSvReVZ,cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,cplcFdFdVZL,             &
& cplcFdFdVZR,deltaM,epsI,check,gSvReSvImFdcFdi)

gSvReSvImFdcFd(i_run,:,:,:) = gSvReSvImFdcFdi
gT(i_run) = gT(i_run) + Sum(gSvReSvImFdcFdi)

gSvReSvImFucFui = 0._dp
Call SvReToSvImFucFu(i_run,MSvIm,MFu,MVZ,MAh,Mhh,MSvRe,cplAhSvImSvRe,cplhhSvImSvRe,   &
& cplSvImSvReVZ,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL,cplcFuFuhhR,cplcFuFuVZL,             &
& cplcFuFuVZR,deltaM,epsI,check,gSvReSvImFucFui)

gSvReSvImFucFu(i_run,:,:,:) = gSvReSvImFucFui
gT(i_run) = gT(i_run) + Sum(gSvReSvImFucFui)

gSvReSvReFdcFdi = 0._dp
Call SvReToSvReFdcFd(i_run,MSvRe,MFd,MAh,Mhh,cplAhSvReSvRe,cplhhSvReSvRe,             &
& cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,deltaM,epsI,check,gSvReSvReFdcFdi)

gSvReSvReFdcFd(i_run,:,:,:) = gSvReSvReFdcFdi
gT(i_run) = gT(i_run) + Sum(gSvReSvReFdcFdi)

gSvReSvReFucFui = 0._dp
Call SvReToSvReFucFu(i_run,MSvRe,MFu,MAh,Mhh,cplAhSvReSvRe,cplhhSvReSvRe,             &
& cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL,cplcFuFuhhR,deltaM,epsI,check,gSvReSvReFucFui)

gSvReSvReFucFu(i_run,:,:,:) = gSvReSvReFucFui
gT(i_run) = gT(i_run) + Sum(gSvReSvReFucFui)

End Do

If (Present(gPartial)) Then
Do i1 = i_start, i_end

n_length=1
Do gt1=2,3
  Do gt2=1,2
    Do gt3=1,3
gPartial(i1,n_length)= 2._dp*gSvReAhChacFe(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=2,3
  Do gt2=1,5
    Do gt3=1,6
gPartial(i1,n_length)= gSvReAhChiFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,2
    Do gt3=1,5
gPartial(i1,n_length)= 2._dp*gSvRecSeChaChi(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=2,2
  Do gt2=1,2
    Do gt3=1,6
gPartial(i1,n_length)= 2._dp*gSvRecHpmChaFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,3
  Do gt2=1,2
    Do gt3=1,3
gPartial(i1,n_length)= 2._dp*gSvRehhChacFe(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,2
    Do gt3=1,2
gPartial(i1,n_length)= gSvReSvImChacCha(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,2
    Do gt3=1,2
gPartial(i1,n_length)= gSvReSvReChacCha(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,5
    Do gt3=gt2,5
gPartial(i1,n_length)= gSvReSvImChiChi(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,5
    Do gt3=gt2,5
gPartial(i1,n_length)= gSvReSvReChiChi(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=2,2
  Do gt2=1,5
    Do gt3=1,3
gPartial(i1,n_length)= 2._dp*gSvRecHpmChiFe(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,3
  Do gt2=1,5
    Do gt3=1,6
gPartial(i1,n_length)= gSvRehhChiFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,3
  Do gt2=1,3
    Do gt3=1,6
gPartial(i1,n_length)= 2._dp*gSvReFeFucSd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,6
gPartial(i1,n_length)= 2._dp*gSvRecSeFeFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,3
  Do gt2=1,6
    Do gt3=1,3
gPartial(i1,n_length)= 2._dp*gSvReFeSucFd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvImFecFe(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvReFecFe(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,6
gPartial(i1,n_length)= 2._dp*gSvReFvFdcSd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,6
gPartial(i1,n_length)= 2._dp*gSvReFvFucSu(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,6
    Do gt3=gt2,6
gPartial(i1,n_length)= gSvReSvImFvFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,6
    Do gt3=gt2,6
gPartial(i1,n_length)= gSvReSvReFvFv(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= 2._dp*gSvReSeFucFd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvImFdcFd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvImFucFu(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvReFdcFd(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
Do gt1=1,6
  Do gt2=1,3
    Do gt3=1,3
gPartial(i1,n_length)= gSvReSvReFucFu(i1,gt1,gt2,gt3)
n_length=n_length+1
     End Do
  End Do
End Do
If (Present(BR).And.(gT(i1).Gt.0._dp)) Then
BR(i1,:)=gPartial(i1,:)/gT(i1)
Else If (Present(BR)) Then
BR(i1,:)=0._dp
End If

End Do
End if
Iname = Iname - 1

End Subroutine SvReThreeBodyDecay

Subroutine SvReToAhChacFe(iIN,MAh,MCha,MFe,MSvIm,MSvRe,cplAhSvImSvRe,cplAhSvReSvRe,   &
& cplcChaChaAhL,cplcChaChaAhR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,              &
& cplcFeChaSvReR,cplcFeFeAhL,cplcFeFeAhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MAh(3),MCha(2),MFe(3),MSvIm(6),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplAhSvReSvRe(3,6,6),cplcChaChaAhL(2,2,3),cplcChaChaAhR(2,2,3),  &
& cplcFeChaSvImL(3,2,6),cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),&
& cplcFeFeAhL(3,3,3),cplcFeFeAhR(3,3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 289
Allocate( gSum(3,2,3, Isum) )
Allocate( Contribution(3,2,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=2,3
      Do gt2=1,2
        Do gt3=1,3
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MFe(gt3)/MSvRe(iIN))**2
rj2 = (MAh(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFe(gt3))+Abs(MCha(gt2))+Abs(MAh(gt1)))) Then
!--------------
!  SvIm
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvIm(i1)
mass(2) = MSvIm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(gt1,i1,iIN))
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm'
      End Do

!--------------
!  SvRe
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvRe(i1)
mass(2) = MSvRe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(gt1,iIN,i1))
coup(3) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcFeFeAhL(gt3,i1,gt1))
coup(3) = Conjg(cplcFeFeAhR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Cha
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcFeChaSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcChaChaAhL(i1,gt2,gt1))
coup(3) = Conjg(cplcChaChaAhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Cha'
      End Do

!--------------
!  SvIm, SvIm
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvIm(i2)
coup(1) = cplAhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(gt1,i2,iIN)
coup(6) = Conjg(cplcFeChaSvImL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvImR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvIm,SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvIm'
        End Do
      End Do

!--------------
!  SvIm, SvRe
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvRe(i2)
coup(1) = cplAhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplcFeChaSvReL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvReR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvIm,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvRe'
        End Do
      End Do

!--------------
!  SvIm, bar[Fe]
!--------------
Do i1=1,6
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeFeAhL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeFeAhR(gt3,i2,gt1))
coup(5) = cplAhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvIm,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,bar[Fe]'
        End Do
      End Do

!--------------
!  SvIm, Cha
!--------------
Do i1=1,6
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaChaAhL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaChaAhR(i2,gt2,gt1))
coup(5) = cplAhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvIm,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Cha'
        End Do
      End Do

!--------------
!  SvRe, SvRe
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvRe(i1)
mass(2) = MSvRe(i2)
coup(1) = cplAhSvReSvRe(gt1,iIN,i1)
coup(3) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplcFeChaSvReL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvReR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvRe,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,SvRe'
        End Do
      End Do

!--------------
!  SvRe, bar[Fe]
!--------------
Do i1=1,6
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeFeAhL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeFeAhR(gt3,i2,gt1))
coup(5) = cplAhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvRe,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,bar[Fe]'
        End Do
      End Do

!--------------
!  SvRe, Cha
!--------------
Do i1=1,6
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaChaAhL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaChaAhR(i2,gt2,gt1))
coup(5) = cplAhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: SvRe,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Cha'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcFeFeAhL(gt3,i1,gt1)
coup(4) = cplcFeFeAhR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplcFeFeAhL(gt3,i2,gt1)
coup(8) = cplcFeFeAhR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcFeFeAhL(gt3,i1,gt1)
coup(4) = cplcFeFeAhR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaChaAhL(i2,gt2,gt1)
coup(8) = cplcChaChaAhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: bar[Fe],Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Cha'
        End Do
      End Do

!--------------
!  Cha, Cha
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i1,iIN)
coup(2) = cplcFeChaSvReR(gt3,i1,iIN)
coup(3) = cplcChaChaAhL(i1,gt2,gt1)
coup(4) = cplcChaChaAhR(i1,gt2,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaChaAhL(i2,gt2,gt1)
coup(8) = cplcChaChaAhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Cha cFe Propagator: Cha,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Cha,Cha'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=2,3
      Do gt2=1,2
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:289))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToAhChacFe

Subroutine SvReToAhChiFv(iIN,MAh,MChi,MFv,MSvIm,MSvRe,cplAhSvImSvRe,cplAhSvReSvRe,    &
& cplChiChiAhL,cplChiChiAhR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& cplFvFvAhL,cplFvFvAhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MAh(3),MChi(5),MFv(6),MSvIm(6),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplAhSvReSvRe(3,6,6),cplChiChiAhL(5,5,3),cplChiChiAhR(5,5,3),    &
& cplChiFvSvImL(5,6,6),cplChiFvSvImR(5,6,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),   &
& cplFvFvAhL(6,6,3),cplFvFvAhR(6,6,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 529
Allocate( gSum(3,5,6, Isum) )
Allocate( Contribution(3,5,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=2,3
      Do gt2=1,5
        Do gt3=1,6
Isum = 0

rk2 = (MChi(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (MAh(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MChi(gt2))+Abs(MAh(gt1)))) Then
!--------------
!  SvIm
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvIm(i1)
mass(2) = MSvIm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(gt1,i1,iIN))
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm'
      End Do

!--------------
!  SvRe
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvRe(i1)
mass(2) = MSvRe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(gt1,iIN,i1))
coup(3) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt2,i1,iIN))
coup(4) = Conjg(cplFvFvAhL(i1,gt3,gt1))
coup(3) = Conjg(cplFvFvAhR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChiAhL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChiAhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  SvIm, SvIm
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvIm(i2)
coup(1) = cplAhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4) = cplAhSvImSvRe(gt1,i2,iIN)
coup(6) = Conjg(cplChiFvSvImL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvImR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvIm,SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvIm'
        End Do
      End Do

!--------------
!  SvIm, SvRe
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvRe(i2)
coup(1) = cplAhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4) = cplAhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplChiFvSvReL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvReR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvIm,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvRe'
        End Do
      End Do

!--------------
!  SvIm, Fv
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplFvFvAhL(i2,gt3,gt1))
coup(3) = Conjg(cplFvFvAhR(i2,gt3,gt1))
coup(5) = cplAhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvIm,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Fv'
        End Do
      End Do

!--------------
!  SvIm, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChiAhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChiAhR(i2,gt2,gt1))
coup(5) = cplAhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvIm,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Chi'
        End Do
      End Do

!--------------
!  SvRe, SvRe
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvRe(i1)
mass(2) = MSvRe(i2)
coup(1) = cplAhSvReSvRe(gt1,iIN,i1)
coup(3) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
coup(4) = cplAhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplChiFvSvReL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvReR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvRe,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,SvRe'
        End Do
      End Do

!--------------
!  SvRe, Fv
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplFvFvAhL(i2,gt3,gt1))
coup(3) = Conjg(cplFvFvAhR(i2,gt3,gt1))
coup(5) = cplAhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvRe,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Fv'
        End Do
      End Do

!--------------
!  SvRe, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChiAhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChiAhR(i2,gt2,gt1))
coup(5) = cplAhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: SvRe,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Chi'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplFvFvAhL(i1,gt3,gt1)
coup(4) = cplFvFvAhR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplFvFvAhL(i2,gt3,gt1)
coup(8) = cplFvFvAhR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

!--------------
!  Fv, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplFvFvAhL(i1,gt3,gt1)
coup(4) = cplFvFvAhR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChiAhL(i2,gt2,gt1)
coup(8) = cplChiChiAhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: Fv,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiChiAhL(i1,gt2,gt1)
coup(4) = cplChiChiAhR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChiAhL(i2,gt2,gt1)
coup(8) = cplChiChiAhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Ah Chi Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=2,3
      Do gt2=1,5
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:529))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToAhChiFv

Subroutine SvReTocSeChaChi(iIN,MSe,MCha,MChi,MVWm,MHpm,MFe,MFv,MSvRe,cplHpmSvRecSe,   &
& cplSvRecSeVWm,cplcFeChaSvReL,cplcFeChaSvReR,cplChiChacHpmL,cplChiChacHpmR,             &
& cplChiChacVWmL,cplChiChacVWmR,cplChiFecSeL,cplChiFecSeR,cplChiFvSvReL,cplChiFvSvReR,   &
& cplFvChacSeL,cplFvChacSeR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSe(6),MCha(2),MChi(5),MVWm,MHpm(2),MFe(3),MFv(6),MSvRe(6)

Complex(dp),Intent(in) :: cplHpmSvRecSe(2,6,6),cplSvRecSeVWm(6,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),  &
& cplChiChacHpmL(5,2,2),cplChiChacHpmR(5,2,2),cplChiChacVWmL(5,2),cplChiChacVWmR(5,2),   &
& cplChiFecSeL(5,3,6),cplChiFecSeR(5,3,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),     &
& cplFvChacSeL(6,2,6),cplFvChacSeR(6,2,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 144
Allocate( gSum(6,2,5, Isum) )
Allocate( Contribution(6,2,5, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,2
        Do gt3=1,5
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MChi(gt3)/MSvRe(iIN))**2
rj2 = (MSe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MChi(gt3))+Abs(MCha(gt2))+Abs(MSe(gt1)))) Then
!--------------
!  VWm
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVWm
mass(2) = MVWm
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvRecSeVWm(iIN,gt1))
coup(3) = Conjg(cplChiChacVWmL(gt3,gt2))
coup(2) = Conjg(cplChiChacVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: VWm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VWm'

!--------------
!  Hpm
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplHpmSvRecSe(i1,iIN,gt1))
coup(3) = Conjg(cplChiChacHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChacHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplChiFecSeL(gt3,i1,gt1))
coup(3) = Conjg(cplChiFecSeR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplFvChacSeL(i1,gt2,gt1))
coup(3) = Conjg(cplFvChacSeR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  VWm, Hpm
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSvRecSeVWm(iIN,gt1)
coup(2) = Conjg(cplChiChacVWmL(gt3,gt2))
coup(3) = Conjg(cplChiChacVWmR(gt3,gt2))
coup(4) = cplHpmSvRecSe(i2,iIN,gt1)
coup(5) = Conjg(cplChiChacHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplChiChacHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: VWm,Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,Hpm'
      End Do

!--------------
!  VWm, bar[Fe]
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm2
mass(1) = MFe2(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFecSeL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFecSeR(gt3,i2,gt1))
coup(5) = cplSvRecSeVWm(iIN,gt1)
coup(7) = Conjg(cplChiChacVWmL(gt3,gt2))
coup(6) = Conjg(cplChiChacVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: VWm,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,bar[Fe]'
      End Do

!--------------
!  VWm, Fv
!--------------
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm2
mass(1) = MFv2(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplFvChacSeL(i2,gt2,gt1))
coup(3) = Conjg(cplFvChacSeR(i2,gt2,gt1))
coup(5) = cplSvRecSeVWm(iIN,gt1)
coup(7) = Conjg(cplChiChacVWmL(gt3,gt2))
coup(6) = Conjg(cplChiChacVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: VWm,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,Fv'
      End Do

!--------------
!  Hpm, Hpm
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplHpmSvRecSe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChacHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChacHpmR(gt3,gt2,i1))
coup(4) = cplHpmSvRecSe(i2,iIN,gt1)
coup(6) = Conjg(cplChiChacHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplChiChacHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Hpm,Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,Hpm'
        End Do
      End Do

!--------------
!  Hpm, bar[Fe]
!--------------
Do i1=1,2
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFecSeL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFecSeR(gt3,i2,gt1))
coup(5) = cplHpmSvRecSe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChacHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplChiChacHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Hpm,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,bar[Fe]'
        End Do
      End Do

!--------------
!  Hpm, Fv
!--------------
Do i1=1,2
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplFvChacSeL(i2,gt2,gt1))
coup(3) = Conjg(cplFvChacSeR(i2,gt2,gt1))
coup(5) = cplHpmSvRecSe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChacHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplChiChacHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Hpm,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,Fv'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplChiFecSeL(gt3,i1,gt1)
coup(4) = cplChiFecSeR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplChiFecSeL(gt3,i2,gt1)
coup(8) = cplChiFecSeR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Fv
!--------------
Do i1=1,3
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFv(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplChiFecSeL(gt3,i1,gt1)
coup(4) = cplChiFecSeR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplFvChacSeL(i2,gt2,gt1)
coup(8) = cplFvChacSeR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: bar[Fe],Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Fv'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplFvChacSeL(i1,gt2,gt1)
coup(4) = cplFvChacSeR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplFvChacSeL(i2,gt2,gt1)
coup(8) = cplFvChacSeR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Cha Chi Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,2
        Do gt3=1,5
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:144))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTocSeChaChi

Subroutine SvReTocHpmChaFv(iIN,MHpm,MCha,MFv,MSe,MFe,MChi,MSvRe,cplSeSvRecHpm,        &
& cplcFeChaSvReL,cplcFeChaSvReR,cplChiChacHpmL,cplChiChacHpmR,cplChiFvSvReL,             &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFecHpmL,cplFvFecHpmR,deltaM,              &
& epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MHpm(2),MCha(2),MFv(6),MSe(6),MFe(3),MChi(5),MSvRe(6)

Complex(dp),Intent(in) :: cplSeSvRecHpm(6,6,2),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),cplChiChacHpmL(5,2,2),&
& cplChiChacHpmR(5,2,2),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),cplFvChacSeL(6,2,6),   &
& cplFvChacSeR(6,2,6),cplFvFecHpmL(6,3,2),cplFvFecHpmR(6,3,2)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 196
Allocate( gSum(2,2,6, Isum) )
Allocate( Contribution(2,2,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=2,2
      Do gt2=1,2
        Do gt3=1,6
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (MHpm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MCha(gt2))+Abs(MHpm(gt1)))) Then
!--------------
!  Se
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSe(i1)
mass(2) = MSe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSeSvRecHpm(i1,iIN,gt1))
coup(3) = Conjg(cplFvChacSeL(gt3,gt2,i1))
coup(2) = Conjg(cplFvChacSeR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Se"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Se'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplFvFecHpmL(gt3,i1,gt1))
coup(3) = Conjg(cplFvFecHpmR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChacHpmL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChacHpmR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  Se, Se
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSe(i1)
mass(2) = MSe(i2)
coup(1) = cplSeSvRecHpm(i1,iIN,gt1)
coup(3) = Conjg(cplFvChacSeL(gt3,gt2,i1))
coup(2) = Conjg(cplFvChacSeR(gt3,gt2,i1))
coup(4) = cplSeSvRecHpm(i2,iIN,gt1)
coup(6) = Conjg(cplFvChacSeL(gt3,gt2,i2))
coup(5) = Conjg(cplFvChacSeR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Se,Se"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,Se'
        End Do
      End Do

!--------------
!  Se, bar[Fe]
!--------------
Do i1=1,6
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MSe(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplFvFecHpmL(gt3,i2,gt1))
coup(3) = Conjg(cplFvFecHpmR(gt3,i2,gt1))
coup(5) = cplSeSvRecHpm(i1,iIN,gt1)
coup(7) = Conjg(cplFvChacSeL(gt3,gt2,i1))
coup(6) = Conjg(cplFvChacSeR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Se,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,bar[Fe]'
        End Do
      End Do

!--------------
!  Se, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MSe(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChacHpmL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChacHpmR(i2,gt2,gt1))
coup(5) = cplSeSvRecHpm(i1,iIN,gt1)
coup(7) = Conjg(cplFvChacSeL(gt3,gt2,i1))
coup(6) = Conjg(cplFvChacSeR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Se,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,Chi'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplFvFecHpmL(gt3,i1,gt1)
coup(4) = cplFvFecHpmR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplFvFecHpmL(gt3,i2,gt1)
coup(8) = cplFvFecHpmR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Chi
!--------------
Do i1=1,3
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MChi(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplFvFecHpmL(gt3,i1,gt1)
coup(4) = cplFvFecHpmR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(i2,gt2,gt1)
coup(8) = cplChiChacHpmR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: bar[Fe],Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiChacHpmL(i1,gt2,gt1)
coup(4) = cplChiChacHpmR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(i2,gt2,gt1)
coup(8) = cplChiChacHpmR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Cha Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=2,2
      Do gt2=1,2
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:196))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTocHpmChaFv

Subroutine SvReTohhChacFe(iIN,Mhh,MCha,MFe,MSvIm,MSvRe,cplhhSvImSvRe,cplhhSvReSvRe,   &
& cplcChaChahhL,cplcChaChahhR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,              &
& cplcFeChaSvReR,cplcFeFehhL,cplcFeFehhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: Mhh(3),MCha(2),MFe(3),MSvIm(6),MSvRe(6)

Complex(dp),Intent(in) :: cplhhSvImSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),  &
& cplcFeChaSvImL(3,2,6),cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),&
& cplcFeFehhL(3,3,3),cplcFeFehhR(3,3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 289
Allocate( gSum(3,2,3, Isum) )
Allocate( Contribution(3,2,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,3
      Do gt2=1,2
        Do gt3=1,3
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MFe(gt3)/MSvRe(iIN))**2
rj2 = (Mhh(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFe(gt3))+Abs(MCha(gt2))+Abs(Mhh(gt1)))) Then
!--------------
!  SvIm
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvIm(i1)
mass(2) = MSvIm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(gt1,i1,iIN))
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm'
      End Do

!--------------
!  SvRe
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvRe(i1)
mass(2) = MSvRe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(gt1,iIN,i1))
coup(3) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcFeFehhL(gt3,i1,gt1))
coup(3) = Conjg(cplcFeFehhR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Cha
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcFeChaSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcChaChahhL(i1,gt2,gt1))
coup(3) = Conjg(cplcChaChahhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Cha'
      End Do

!--------------
!  SvIm, SvIm
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvIm(i2)
coup(1) = cplhhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(gt1,i2,iIN)
coup(6) = Conjg(cplcFeChaSvImL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvImR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvIm,SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvIm'
        End Do
      End Do

!--------------
!  SvIm, SvRe
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvRe(i2)
coup(1) = cplhhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplcFeChaSvReL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvReR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvIm,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvRe'
        End Do
      End Do

!--------------
!  SvIm, bar[Fe]
!--------------
Do i1=1,6
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeFehhL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeFehhR(gt3,i2,gt1))
coup(5) = cplhhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvIm,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,bar[Fe]'
        End Do
      End Do

!--------------
!  SvIm, Cha
!--------------
Do i1=1,6
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaChahhL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaChahhR(i2,gt2,gt1))
coup(5) = cplhhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplcFeChaSvImL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvImR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvIm,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Cha'
        End Do
      End Do

!--------------
!  SvRe, SvRe
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvRe(i1)
mass(2) = MSvRe(i2)
coup(1) = cplhhSvReSvRe(gt1,iIN,i1)
coup(3) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplcFeChaSvReL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeChaSvReR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvRe,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,SvRe'
        End Do
      End Do

!--------------
!  SvRe, bar[Fe]
!--------------
Do i1=1,6
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeFehhL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeFehhR(gt3,i2,gt1))
coup(5) = cplhhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvRe,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,bar[Fe]'
        End Do
      End Do

!--------------
!  SvRe, Cha
!--------------
Do i1=1,6
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaChahhL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaChahhR(i2,gt2,gt1))
coup(5) = cplhhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplcFeChaSvReL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeChaSvReR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: SvRe,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Cha'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcFeFehhL(gt3,i1,gt1)
coup(4) = cplcFeFehhR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplcFeFehhL(gt3,i2,gt1)
coup(8) = cplcFeFehhR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcFeFehhL(gt3,i1,gt1)
coup(4) = cplcFeFehhR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaChahhL(i2,gt2,gt1)
coup(8) = cplcChaChahhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: bar[Fe],Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Cha'
        End Do
      End Do

!--------------
!  Cha, Cha
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i1,iIN)
coup(2) = cplcFeChaSvReR(gt3,i1,iIN)
coup(3) = cplcChaChahhL(i1,gt2,gt1)
coup(4) = cplcChaChahhR(i1,gt2,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaChahhL(i2,gt2,gt1)
coup(8) = cplcChaChahhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Cha cFe Propagator: Cha,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Cha,Cha'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,3
      Do gt2=1,2
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:289))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTohhChacFe

Subroutine SvReToSvImChacCha(iIN,MSvIm,MCha,MVZ,MAh,Mhh,MFe,MSvRe,cplAhSvImSvRe,      &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,   &
& cplcChaChaVZL,cplcChaChaVZR,cplcChaFeSvImL,cplcChaFeSvImR,cplcChaFeSvReL,              &
& cplcChaFeSvReR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,            &
& deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MCha(2),MVZ,MAh(3),Mhh(3),MFe(3),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplcChaChaAhL(2,2,3),    &
& cplcChaChaAhR(2,2,3),cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaChaVZL(2,2),     &
& cplcChaChaVZR(2,2),cplcChaFeSvImL(2,3,6),cplcChaFeSvImR(2,3,6),cplcChaFeSvReL(2,3,6),  &
& cplcChaFeSvReR(2,3,6),cplcFeChaSvImL(3,2,6),cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),&
& cplcFeChaSvReR(3,2,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 169
Allocate( gSum(6,2,2, Isum) )
Allocate( Contribution(6,2,2, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,2
        Do gt3=1,2
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MCha(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MCha(gt3))+Abs(MCha(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(2) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcChaFeSvImL(gt3,i1,gt1))
coup(3) = Conjg(cplcChaFeSvImR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Fe
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFeSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcFeChaSvImL(i1,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fe'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(3) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcChaChaAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(3) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  VZ, bar[Fe]
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MFe2(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(gt3,i2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(6) = Conjg(cplcChaChaVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: VZ,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,bar[Fe]'
      End Do

!--------------
!  VZ, Fe
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MFe2(i2)
coup(1) = cplcChaFeSvReL(gt3,i2,iIN)
coup(2) = cplcChaFeSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(i2,gt2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(6) = Conjg(cplcChaChaVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: VZ,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Fe'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChaAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChaAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, bar[Fe]
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(gt3,i2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Ah,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,bar[Fe]'
        End Do
      End Do

!--------------
!  Ah, Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i2,iIN)
coup(2) = cplcChaFeSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(i2,gt2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Ah,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fe'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, bar[Fe]
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(gt3,i2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: hh,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,bar[Fe]'
        End Do
      End Do

!--------------
!  hh, Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i2,iIN)
coup(2) = cplcChaFeSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(i2,gt2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: hh,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fe'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcChaFeSvImL(gt3,i1,gt1)
coup(4) = cplcChaFeSvImR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplcChaFeSvImL(gt3,i2,gt1)
coup(8) = cplcChaFeSvImR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcChaFeSvImL(gt3,i1,gt1)
coup(4) = cplcChaFeSvImR(gt3,i1,gt1)
coup(5) = cplcChaFeSvReL(gt3,i2,iIN)
coup(6) = cplcChaFeSvReR(gt3,i2,iIN)
coup(7) = cplcFeChaSvImL(i2,gt2,gt1)
coup(8) = cplcFeChaSvImR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: bar[Fe],Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Fe'
        End Do
      End Do

!--------------
!  Fe, Fe
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i1,iIN)
coup(2) = cplcChaFeSvReR(gt3,i1,iIN)
coup(3) = cplcFeChaSvImL(i1,gt2,gt1)
coup(4) = cplcFeChaSvImR(i1,gt2,gt1)
coup(5) = cplcChaFeSvReL(gt3,i2,iIN)
coup(6) = cplcChaFeSvReR(gt3,i2,iIN)
coup(7) = cplcFeChaSvImL(i2,gt2,gt1)
coup(8) = cplcFeChaSvImR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Cha cCha Propagator: Fe,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fe,Fe'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,2
        Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:169))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImChacCha

Subroutine SvReToSvReChacCha(iIN,MSvRe,MCha,MAh,Mhh,MFe,cplAhSvReSvRe,cplhhSvReSvRe,  &
& cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaFeSvReL,cplcChaFeSvReR, &
& cplcFeChaSvReL,cplcFeChaSvReR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MCha(2),MAh(3),Mhh(3),MFe(3)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplcChaChaAhL(2,2,3),cplcChaChaAhR(2,2,3),  &
& cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6), &
& cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 144
Allocate( gSum(6,2,2, Isum) )
Allocate( Contribution(6,2,2, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,2
        Do gt3=1,2
Isum = 0

rk2 = (MCha(gt2)/MSvRe(iIN))**2
rm2 = (MCha(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MCha(gt3))+Abs(MCha(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  bar[Fe]
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcFeChaSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcChaFeSvReL(gt3,i1,gt1))
coup(3) = Conjg(cplcChaFeSvReR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe]'
      End Do

!--------------
!  Fe
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFe(i1)
mass(2) = MFe(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFeSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcFeChaSvReL(i1,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvReR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fe'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcChaChaAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChaAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, bar[Fe]
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaFeSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaFeSvReR(gt3,i2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Ah,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,bar[Fe]'
        End Do
      End Do

!--------------
!  Ah, Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i2,iIN)
coup(2) = cplcChaFeSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcFeChaSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvReR(i2,gt2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Ah,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fe'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, bar[Fe]
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFe(i2)
coup(1) = cplcFeChaSvReL(i2,gt2,iIN)
coup(2) = cplcFeChaSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaFeSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaFeSvReR(gt3,i2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: hh,bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,bar[Fe]'
        End Do
      End Do

!--------------
!  hh, Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i2,iIN)
coup(2) = cplcChaFeSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcFeChaSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplcFeChaSvReR(i2,gt2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: hh,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fe'
        End Do
      End Do

!--------------
!  bar[Fe], bar[Fe]
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcChaFeSvReL(gt3,i1,gt1)
coup(4) = cplcChaFeSvReR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(i2,gt2,iIN)
coup(6) = cplcFeChaSvReR(i2,gt2,iIN)
coup(7) = cplcChaFeSvReL(gt3,i2,gt1)
coup(8) = cplcChaFeSvReR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: bar[Fe],bar[Fe]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],bar[Fe]'
        End Do
      End Do

!--------------
!  bar[Fe], Fe
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcFeChaSvReL(i1,gt2,iIN)
coup(2) = cplcFeChaSvReR(i1,gt2,iIN)
coup(3) = cplcChaFeSvReL(gt3,i1,gt1)
coup(4) = cplcChaFeSvReR(gt3,i1,gt1)
coup(5) = cplcChaFeSvReL(gt3,i2,iIN)
coup(6) = cplcChaFeSvReR(gt3,i2,iIN)
coup(7) = cplcFeChaSvReL(i2,gt2,gt1)
coup(8) = cplcFeChaSvReR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: bar[Fe],Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Fe],Fe'
        End Do
      End Do

!--------------
!  Fe, Fe
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MFe(i1)
mass(2) = MFe(i2)
coup(1) = cplcChaFeSvReL(gt3,i1,iIN)
coup(2) = cplcChaFeSvReR(gt3,i1,iIN)
coup(3) = cplcFeChaSvReL(i1,gt2,gt1)
coup(4) = cplcFeChaSvReR(i1,gt2,gt1)
coup(5) = cplcChaFeSvReL(gt3,i2,iIN)
coup(6) = cplcChaFeSvReR(gt3,i2,iIN)
coup(7) = cplcFeChaSvReL(i2,gt2,gt1)
coup(8) = cplcFeChaSvReR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Cha cCha Propagator: Fe,Fe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fe,Fe'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,2
        Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:144))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReChacCha

Subroutine SvReToSvImChiChi(iIN,MSvIm,MChi,MVZ,MAh,Mhh,MFv,MSvRe,cplAhSvImSvRe,       &
& cplhhSvImSvRe,cplSvImSvReVZ,cplChiChiAhL,cplChiChiAhR,cplChiChihhL,cplChiChihhR,       &
& cplChiChiVZL,cplChiChiVZR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MChi(5),MVZ,MAh(3),Mhh(3),MFv(6),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplChiChiAhL(5,5,3),     &
& cplChiChiAhR(5,5,3),cplChiChihhL(5,5,3),cplChiChihhR(5,5,3),cplChiChiVZL(5,5),         &
& cplChiChiVZR(5,5),cplChiFvSvImL(5,6,6),cplChiFvSvImR(5,6,6),cplChiFvSvReL(5,6,6),      &
& cplChiFvSvReR(5,6,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 169
Allocate( gSum(6,5,5, Isum) )
Allocate( Contribution(6,5,5, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,5
        Do gt3=gt2,5
Isum = 0

rk2 = (MChi(gt2)/MSvRe(iIN))**2
rm2 = (MChi(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MChi(gt3))+Abs(MChi(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplChiChiVZL(gt2,gt3))
coup(2) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplChiChiVZL(gt3,gt2))
coup(2) = Conjg(cplChiChiVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i1,gt1,iIN)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i1,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt2,i1,iIN))
coup(4) = Conjg(cplChiFvSvImL(gt3,i1,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplChiFvSvImL(gt2,i1,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt2,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MFv(i1)
mass(2) = MFv(i1)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvImL(gt2,i1,gt1)
coup(4) = cplChiFvSvImR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i1,iIN)
coup(6) = cplChiFvSvReR(gt2,i1,iIN)
coup(7) = cplChiFvSvImL(gt3,i1,gt1)
coup(8) = cplChiFvSvImR(gt3,i1,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplChiChiVZL(gt2,gt3))
coup(3) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplChiChiAhL(gt2,gt3,i2))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplChiChiVZL(gt2,gt3))
coup(3) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  VZ, Fv
!--------------
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MFv2(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt3,i2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplChiChiVZL(gt2,gt3))
coup(6) = Conjg(cplChiChiVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MVZ2
mass(1) = MFv2(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt2,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt2,i2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplChiChiVZL(gt2,gt3))
coup(6) = Conjg(cplChiChiVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: VZ,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Fv'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, Fv
!--------------
Do i1=1,3
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt3,i2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MAh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt2,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt2,i2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Ah,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fv'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, Fv
!--------------
Do i1=1,3
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt3,i2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = Mhh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplChiFvSvImL(gt2,i2,gt1))
coup(3) = Conjg(cplChiFvSvImR(gt2,i2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: hh,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fv'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplChiFvSvImL(gt3,i1,gt1)
coup(4) = cplChiFvSvImR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplChiFvSvImL(gt3,i2,gt1)
coup(8) = cplChiFvSvImR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvImL(gt2,i1,gt1)
coup(4) = cplChiFvSvImR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplChiFvSvImL(gt3,i2,gt1)
coup(8) = cplChiFvSvImR(gt3,i2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvImL(gt2,i1,gt1)
coup(4) = cplChiFvSvImR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplChiFvSvImL(gt2,i2,gt1)
coup(8) = cplChiFvSvImR(gt2,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplChiFvSvImL(gt3,i1,gt1)
coup(4) = cplChiFvSvImR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplChiFvSvImL(gt2,i2,gt1)
coup(8) = cplChiFvSvImR(gt2,i2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Chi Chi Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,5
        Do gt3=gt2,5
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:169))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImChiChi

Subroutine SvReToSvReChiChi(iIN,MSvRe,MChi,MAh,Mhh,MFv,cplAhSvReSvRe,cplhhSvReSvRe,   &
& cplChiChiAhL,cplChiChiAhR,cplChiChihhL,cplChiChihhR,cplChiFvSvReL,cplChiFvSvReR,       &
& deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MChi(5),MAh(3),Mhh(3),MFv(6)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplChiChiAhL(5,5,3),cplChiChiAhR(5,5,3),    &
& cplChiChihhL(5,5,3),cplChiChihhR(5,5,3),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 144
Allocate( gSum(6,5,5, Isum) )
Allocate( Contribution(6,5,5, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,5
        Do gt3=gt2,5
Isum = 0

rk2 = (MChi(gt2)/MSvRe(iIN))**2
rm2 = (MChi(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MChi(gt3))+Abs(MChi(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i1,iIN,gt1)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i1,iIN,gt1)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt2,i1,iIN))
coup(4) = Conjg(cplChiFvSvReL(gt3,i1,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplChiFvSvReL(gt2,i1,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt2,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MFv(i1)
mass(2) = MFv(i1)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvReL(gt2,i1,gt1)
coup(4) = cplChiFvSvReR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i1,iIN)
coup(6) = cplChiFvSvReR(gt2,i1,iIN)
coup(7) = cplChiFvSvReL(gt3,i1,gt1)
coup(8) = cplChiFvSvReR(gt3,i1,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, Fv
!--------------
Do i1=1,3
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplChiFvSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt3,i2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MAh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplChiFvSvReL(gt2,i2,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt2,i2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Ah,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fv'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, Fv
!--------------
Do i1=1,3
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplChiFvSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt3,i2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = Mhh(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i2,iIN)
coup(2) = cplChiFvSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplChiFvSvReL(gt2,i2,gt1))
coup(3) = Conjg(cplChiFvSvReR(gt2,i2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: hh,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fv'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplChiFvSvReL(gt3,i1,gt1)
coup(4) = cplChiFvSvReR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplChiFvSvReL(gt3,i2,gt1)
coup(8) = cplChiFvSvReR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvReL(gt2,i1,gt1)
coup(4) = cplChiFvSvReR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplChiFvSvReL(gt3,i2,gt1)
coup(8) = cplChiFvSvReR(gt3,i2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt3,i1,iIN)
coup(2) = cplChiFvSvReR(gt3,i1,iIN)
coup(3) = cplChiFvSvReL(gt2,i1,gt1)
coup(4) = cplChiFvSvReR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplChiFvSvReL(gt2,i2,gt1)
coup(8) = cplChiFvSvReR(gt2,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplChiFvSvReL(gt3,i1,gt1)
coup(4) = cplChiFvSvReR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(gt3,i2,iIN)
coup(6) = cplChiFvSvReR(gt3,i2,iIN)
coup(7) = cplChiFvSvReL(gt2,i2,gt1)
coup(8) = cplChiFvSvReR(gt2,i2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Chi Chi Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,5
        Do gt3=gt2,5
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:144))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReChiChi

Subroutine SvReTocHpmChiFe(iIN,MHpm,MChi,MFe,MSe,MCha,MFv,MSvRe,cplSeSvRecHpm,        &
& cplcChaFeSvReL,cplcChaFeSvReR,cplChiChacHpmL,cplChiChacHpmR,cplChiFecSeL,              &
& cplChiFecSeR,cplChiFvSvReL,cplChiFvSvReR,cplFvFecHpmL,cplFvFecHpmR,deltaM,             &
& epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MHpm(2),MChi(5),MFe(3),MSe(6),MCha(2),MFv(6),MSvRe(6)

Complex(dp),Intent(in) :: cplSeSvRecHpm(6,6,2),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),cplChiChacHpmL(5,2,2),&
& cplChiChacHpmR(5,2,2),cplChiFecSeL(5,3,6),cplChiFecSeR(5,3,6),cplChiFvSvReL(5,6,6),    &
& cplChiFvSvReR(5,6,6),cplFvFecHpmL(6,3,2),cplFvFecHpmR(6,3,2)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 196
Allocate( gSum(2,5,3, Isum) )
Allocate( Contribution(2,5,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=2,2
      Do gt2=1,5
        Do gt3=1,3
Isum = 0

rk2 = (MChi(gt2)/MSvRe(iIN))**2
rm2 = (MFe(gt3)/MSvRe(iIN))**2
rj2 = (MHpm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFe(gt3))+Abs(MChi(gt2))+Abs(MHpm(gt1)))) Then
!--------------
!  Se
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSe(i1)
mass(2) = MSe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSeSvRecHpm(i1,iIN,gt1))
coup(3) = Conjg(cplChiFecSeL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFecSeR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Se"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Se'
      End Do

!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChacHpmL(gt2,i1,gt1))
coup(3) = Conjg(cplChiChacHpmR(gt2,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt2,i1,iIN))
coup(4) = Conjg(cplFvFecHpmL(i1,gt3,gt1))
coup(3) = Conjg(cplFvFecHpmR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  Se, Se
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSe(i1)
mass(2) = MSe(i2)
coup(1) = cplSeSvRecHpm(i1,iIN,gt1)
coup(3) = Conjg(cplChiFecSeL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFecSeR(gt2,gt3,i1))
coup(4) = cplSeSvRecHpm(i2,iIN,gt1)
coup(6) = Conjg(cplChiFecSeL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFecSeR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Se,Se"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,Se'
        End Do
      End Do

!--------------
!  Se, bar[Cha]
!--------------
Do i1=1,6
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MSe(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt3,iIN)
coup(2) = cplcChaFeSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChacHpmL(gt2,i2,gt1))
coup(3) = Conjg(cplChiChacHpmR(gt2,i2,gt1))
coup(5) = cplSeSvRecHpm(i1,iIN,gt1)
coup(7) = Conjg(cplChiFecSeL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFecSeR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Se,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,bar[Cha]'
        End Do
      End Do

!--------------
!  Se, Fv
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MSe(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplFvFecHpmL(i2,gt3,gt1))
coup(3) = Conjg(cplFvFecHpmR(i2,gt3,gt1))
coup(5) = cplSeSvRecHpm(i1,iIN,gt1)
coup(7) = Conjg(cplChiFecSeL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFecSeR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Se,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Se,Fv'
        End Do
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt3,iIN)
coup(2) = cplcChaFeSvReR(i1,gt3,iIN)
coup(3) = cplChiChacHpmL(gt2,i1,gt1)
coup(4) = cplChiChacHpmR(gt2,i1,gt1)
coup(5) = cplcChaFeSvReL(i2,gt3,iIN)
coup(6) = cplcChaFeSvReR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(gt2,i2,gt1)
coup(8) = cplChiChacHpmR(gt2,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

!--------------
!  bar[Cha], Fv
!--------------
Do i1=1,2
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MFv(i2)
coup(1) = cplcChaFeSvReL(i1,gt3,iIN)
coup(2) = cplcChaFeSvReR(i1,gt3,iIN)
coup(3) = cplChiChacHpmL(gt2,i1,gt1)
coup(4) = cplChiChacHpmR(gt2,i1,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplFvFecHpmL(i2,gt3,gt1)
coup(8) = cplFvFecHpmR(i2,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: bar[Cha],Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Fv'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplFvFecHpmL(i1,gt3,gt1)
coup(4) = cplFvFecHpmR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplFvFecHpmL(i2,gt3,gt1)
coup(8) = cplFvFecHpmR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cHpm Chi Fe Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=2,2
      Do gt2=1,5
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:196))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTocHpmChiFe

Subroutine SvReTohhChiFv(iIN,Mhh,MChi,MFv,MSvIm,MSvRe,cplhhSvImSvRe,cplhhSvReSvRe,    &
& cplChiChihhL,cplChiChihhR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,     &
& cplFvFvhhL,cplFvFvhhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: Mhh(3),MChi(5),MFv(6),MSvIm(6),MSvRe(6)

Complex(dp),Intent(in) :: cplhhSvImSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplChiChihhL(5,5,3),cplChiChihhR(5,5,3),    &
& cplChiFvSvImL(5,6,6),cplChiFvSvImR(5,6,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),   &
& cplFvFvhhL(6,6,3),cplFvFvhhR(6,6,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 529
Allocate( gSum(3,5,6, Isum) )
Allocate( Contribution(3,5,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,3
      Do gt2=1,5
        Do gt3=1,6
Isum = 0

rk2 = (MChi(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (Mhh(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MChi(gt2))+Abs(Mhh(gt1)))) Then
!--------------
!  SvIm
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvIm(i1)
mass(2) = MSvIm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(gt1,i1,iIN))
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm'
      End Do

!--------------
!  SvRe
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MSvRe(i1)
mass(2) = MSvRe(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(gt1,iIN,i1))
coup(3) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe'
      End Do

!--------------
!  Fv
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MFv(i1)
mass(2) = MFv(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFvSvReR(gt2,i1,iIN))
coup(4) = Conjg(cplFvFvhhL(i1,gt3,gt1))
coup(3) = Conjg(cplFvFvhhR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fv'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChihhL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChihhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  SvIm, SvIm
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvIm(i2)
coup(1) = cplhhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4) = cplhhSvImSvRe(gt1,i2,iIN)
coup(6) = Conjg(cplChiFvSvImL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvImR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvIm,SvIm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvIm'
        End Do
      End Do

!--------------
!  SvIm, SvRe
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvIm(i1)
mass(2) = MSvRe(i2)
coup(1) = cplhhSvImSvRe(gt1,i1,iIN)
coup(3) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplChiFvSvReL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvReR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvIm,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,SvRe'
        End Do
      End Do

!--------------
!  SvIm, Fv
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplFvFvhhL(i2,gt3,gt1))
coup(3) = Conjg(cplFvFvhhR(i2,gt3,gt1))
coup(5) = cplhhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvIm,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Fv'
        End Do
      End Do

!--------------
!  SvIm, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvIm(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChihhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChihhR(i2,gt2,gt1))
coup(5) = cplhhSvImSvRe(gt1,i1,iIN)
coup(7) = Conjg(cplChiFvSvImL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvImR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvIm,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvIm,Chi'
        End Do
      End Do

!--------------
!  SvRe, SvRe
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MSvRe(i1)
mass(2) = MSvRe(i2)
coup(1) = cplhhSvReSvRe(gt1,iIN,i1)
coup(3) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(gt1,iIN,i2)
coup(6) = Conjg(cplChiFvSvReL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFvSvReR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvRe,SvRe"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,SvRe'
        End Do
      End Do

!--------------
!  SvRe, Fv
!--------------
Do i1=1,6
  Do i2=1,6
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i2,iIN)
coup(2) = cplChiFvSvReR(gt2,i2,iIN)
coup(4) = Conjg(cplFvFvhhL(i2,gt3,gt1))
coup(3) = Conjg(cplFvFvhhR(i2,gt3,gt1))
coup(5) = cplhhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvRe,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Fv'
        End Do
      End Do

!--------------
!  SvRe, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MSvRe(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChihhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChihhR(i2,gt2,gt1))
coup(5) = cplhhSvReSvRe(gt1,iIN,i1)
coup(7) = Conjg(cplChiFvSvReL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFvSvReR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: SvRe,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='SvRe,Chi'
        End Do
      End Do

!--------------
!  Fv, Fv
!--------------
Do i1=1,5
  Do i2=i1+1,6
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MFv(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplFvFvhhL(i1,gt3,gt1)
coup(4) = cplFvFvhhR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(gt2,i2,iIN)
coup(6) = cplChiFvSvReR(gt2,i2,iIN)
coup(7) = cplFvFvhhL(i2,gt3,gt1)
coup(8) = cplFvFvhhR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: Fv,Fv"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Fv'
        End Do
      End Do

!--------------
!  Fv, Chi
!--------------
Do i1=1,6
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MFv(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(gt2,i1,iIN)
coup(2) = cplChiFvSvReR(gt2,i1,iIN)
coup(3) = cplFvFvhhL(i1,gt3,gt1)
coup(4) = cplFvFvhhR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChihhL(i2,gt2,gt1)
coup(8) = cplChiChihhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: Fv,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fv,Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiChihhL(i1,gt2,gt1)
coup(4) = cplChiChihhR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiChihhL(i2,gt2,gt1)
coup(8) = cplChiChihhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->hh Chi Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,3
      Do gt2=1,5
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:529))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTohhChiFv

Subroutine SvReToFeFucSd(iIN,MFe,MFu,MSd,MCha,MSvRe,cplcChaFeSvReL,cplcChaFeSvReR,    &
& cplChaFucSdL,cplChaFucSdR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MFe(3),MFu(3),MSd(6),MCha(2),MSvRe(6)

Complex(dp),Intent(in) :: cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),cplChaFucSdL(2,3,6),cplChaFucSdR(2,3,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 4
Allocate( gSum(3,3,6, Isum) )
Allocate( Contribution(3,3,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,3
      Do gt2=1,3
        Do gt3=1,6
Isum = 0

rk2 = (MFe(gt1)/MSvRe(iIN))**2
rm2 = (MFu(gt2)/MSvRe(iIN))**2
rj2 = (MSd(gt3)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MSd(gt3))+Abs(MFu(gt2))+Abs(MFe(gt1)))) Then
!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt1,iIN))
coup(4) = Conjg(cplChaFucSdL(i1,gt2,gt3))
coup(3) = Conjg(cplChaFucSdR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fe Fu cSd Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt1,iIN)
coup(2) = cplcChaFeSvReR(i1,gt1,iIN)
coup(3) = cplChaFucSdL(i1,gt2,gt3)
coup(4) = cplChaFucSdR(i1,gt2,gt3)
coup(5) = cplcChaFeSvReL(i2,gt1,iIN)
coup(6) = cplcChaFeSvReR(i2,gt1,iIN)
coup(7) = cplChaFucSdL(i2,gt2,gt3)
coup(8) = cplChaFucSdR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fe Fu cSd Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,3
      Do gt2=1,3
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:4))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToFeFucSd

Subroutine SvReTocSeFeFv(iIN,MSe,MFe,MFv,MVWm,MHpm,MCha,MChi,MSvRe,cplHpmSvRecSe,     &
& cplSvRecSeVWm,cplcChaFeSvReL,cplcChaFeSvReR,cplChiFecSeL,cplChiFecSeR,cplChiFvSvReL,   &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFecHpmL,cplFvFecHpmR,cplFvFecVWmL,        &
& cplFvFecVWmR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSe(6),MFe(3),MFv(6),MVWm,MHpm(2),MCha(2),MChi(5),MSvRe(6)

Complex(dp),Intent(in) :: cplHpmSvRecSe(2,6,6),cplSvRecSeVWm(6,6),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),  &
& cplChiFecSeL(5,3,6),cplChiFecSeR(5,3,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),     &
& cplFvChacSeL(6,2,6),cplFvChacSeR(6,2,6),cplFvFecHpmL(6,3,2),cplFvFecHpmR(6,3,2),       &
& cplFvFecVWmL(6,3),cplFvFecVWmR(6,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 100
Allocate( gSum(6,3,6, Isum) )
Allocate( Contribution(6,3,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
Isum = 0

rk2 = (MFe(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (MSe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MFe(gt2))+Abs(MSe(gt1)))) Then
!--------------
!  VWm
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVWm
mass(2) = MVWm
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvRecSeVWm(iIN,gt1))
coup(3) = Conjg(cplFvFecVWmL(gt3,gt2))
coup(2) = Conjg(cplFvFecVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: VWm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VWm'

!--------------
!  Hpm
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplHpmSvRecSe(i1,iIN,gt1))
coup(3) = Conjg(cplFvFecHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFecHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm'
      End Do

!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplFvChacSeL(gt3,i1,gt1))
coup(3) = Conjg(cplFvChacSeR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiFecSeL(i1,gt2,gt1))
coup(3) = Conjg(cplChiFecSeR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  VWm, Hpm
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSvRecSeVWm(iIN,gt1)
coup(2) = Conjg(cplFvFecVWmL(gt3,gt2))
coup(3) = Conjg(cplFvFecVWmR(gt3,gt2))
coup(4) = cplHpmSvRecSe(i2,iIN,gt1)
coup(5) = Conjg(cplFvFecHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplFvFecHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: VWm,Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,Hpm'
      End Do

!--------------
!  VWm, bar[Cha]
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm2
mass(1) = MCha2(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplFvChacSeL(gt3,i2,gt1))
coup(3) = Conjg(cplFvChacSeR(gt3,i2,gt1))
coup(5) = cplSvRecSeVWm(iIN,gt1)
coup(7) = Conjg(cplFvFecVWmL(gt3,gt2))
coup(6) = Conjg(cplFvFecVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: VWm,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,bar[Cha]'
      End Do

!--------------
!  VWm, Chi
!--------------
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm2
mass(1) = MChi2(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFecSeL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFecSeR(i2,gt2,gt1))
coup(5) = cplSvRecSeVWm(iIN,gt1)
coup(7) = Conjg(cplFvFecVWmL(gt3,gt2))
coup(6) = Conjg(cplFvFecVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: VWm,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VWm,Chi'
      End Do

!--------------
!  Hpm, Hpm
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplHpmSvRecSe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFecHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFecHpmR(gt3,gt2,i1))
coup(4) = cplHpmSvRecSe(i2,iIN,gt1)
coup(6) = Conjg(cplFvFecHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplFvFecHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Hpm,Hpm"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,Hpm'
        End Do
      End Do

!--------------
!  Hpm, bar[Cha]
!--------------
Do i1=1,2
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplFvChacSeL(gt3,i2,gt1))
coup(3) = Conjg(cplFvChacSeR(gt3,i2,gt1))
coup(5) = cplHpmSvRecSe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFecHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplFvFecHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Hpm,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,bar[Cha]'
        End Do
      End Do

!--------------
!  Hpm, Chi
!--------------
Do i1=1,2
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFecSeL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFecSeR(i2,gt2,gt1))
coup(5) = cplHpmSvRecSe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFecHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplFvFecHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Hpm,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Hpm,Chi'
        End Do
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplFvChacSeL(gt3,i1,gt1)
coup(4) = cplFvChacSeR(gt3,i1,gt1)
coup(5) = cplcChaFeSvReL(i2,gt2,iIN)
coup(6) = cplcChaFeSvReR(i2,gt2,iIN)
coup(7) = cplFvChacSeL(gt3,i2,gt1)
coup(8) = cplFvChacSeR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

!--------------
!  bar[Cha], Chi
!--------------
Do i1=1,2
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MChi(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplFvChacSeL(gt3,i1,gt1)
coup(4) = cplFvChacSeR(gt3,i1,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFecSeL(i2,gt2,gt1)
coup(8) = cplChiFecSeR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: bar[Cha],Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFecSeL(i1,gt2,gt1)
coup(4) = cplChiFecSeR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFecSeL(i2,gt2,gt1)
coup(8) = cplChiFecSeR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->cSe Fe Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:100))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReTocSeFeFv

Subroutine SvReToFeSucFd(iIN,MFe,MSu,MFd,MCha,MSvRe,cplcChaFeSvReL,cplcChaFeSvReR,    &
& cplcFdChaSuL,cplcFdChaSuR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MFe(3),MSu(6),MFd(3),MCha(2),MSvRe(6)

Complex(dp),Intent(in) :: cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),cplcFdChaSuL(3,2,6),cplcFdChaSuR(3,2,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 4
Allocate( gSum(3,6,3, Isum) )
Allocate( Contribution(3,6,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,3
      Do gt2=1,6
        Do gt3=1,3
Isum = 0

rk2 = (MFe(gt1)/MSvRe(iIN))**2
rm2 = (MFd(gt3)/MSvRe(iIN))**2
rj2 = (MSu(gt2)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFd(gt3))+Abs(MSu(gt2))+Abs(MFe(gt1)))) Then
!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt1,iIN))
coup(4) = Conjg(cplcFdChaSuL(gt3,i1,gt2))
coup(3) = Conjg(cplcFdChaSuR(gt3,i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fe Su cFd Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt1,iIN)
coup(2) = cplcChaFeSvReR(i1,gt1,iIN)
coup(3) = cplcFdChaSuL(gt3,i1,gt2)
coup(4) = cplcFdChaSuR(gt3,i1,gt2)
coup(5) = cplcChaFeSvReL(i2,gt1,iIN)
coup(6) = cplcChaFeSvReR(i2,gt1,iIN)
coup(7) = cplcFdChaSuL(gt3,i2,gt2)
coup(8) = cplcFdChaSuR(gt3,i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fe Su cFd Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,3
      Do gt2=1,6
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:4))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToFeSucFd

Subroutine SvReToSvImFecFe(iIN,MSvIm,MFe,MVZ,MAh,Mhh,MCha,MSvRe,cplAhSvImSvRe,        &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcChaFeSvImL,cplcChaFeSvImR,cplcChaFeSvReL,              &
& cplcChaFeSvReR,cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,            &
& cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,cplcFeFeVZL,cplcFeFeVZR,               &
& deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MFe(3),MVZ,MAh(3),Mhh(3),MCha(2),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplcChaFeSvImL(2,3,6),   &
& cplcChaFeSvImR(2,3,6),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),cplcFeChaSvImL(3,2,6),&
& cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),cplcFeFeAhL(3,3,3),  &
& cplcFeFeAhR(3,3,3),cplcFeFehhL(3,3,3),cplcFeFehhR(3,3,3),cplcFeFeVZL(3,3),             &
& cplcFeFeVZR(3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 121
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFe(gt2)/MSvRe(iIN))**2
rm2 = (MFe(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFe(gt3))+Abs(MFe(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(2) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcFeChaSvImL(gt3,i1,gt1))
coup(3) = Conjg(cplcFeChaSvImR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  Cha
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcFeChaSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcChaFeSvImL(i1,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Cha'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(3) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFeFeAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(3) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  VZ, bar[Cha]
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MCha2(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(gt3,i2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(6) = Conjg(cplcFeFeVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: VZ,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,bar[Cha]'
      End Do

!--------------
!  VZ, Cha
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MCha2(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(i2,gt2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(6) = Conjg(cplcFeFeVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: VZ,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Cha'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFeAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFeAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, bar[Cha]
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(gt3,i2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Ah,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,bar[Cha]'
        End Do
      End Do

!--------------
!  Ah, Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(i2,gt2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Ah,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Cha'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, bar[Cha]
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeChaSvImL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeChaSvImR(gt3,i2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: hh,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,bar[Cha]'
        End Do
      End Do

!--------------
!  hh, Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaFeSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvImR(i2,gt2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: hh,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Cha'
        End Do
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplcFeChaSvImL(gt3,i1,gt1)
coup(4) = cplcFeChaSvImR(gt3,i1,gt1)
coup(5) = cplcChaFeSvReL(i2,gt2,iIN)
coup(6) = cplcChaFeSvReR(i2,gt2,iIN)
coup(7) = cplcFeChaSvImL(gt3,i2,gt1)
coup(8) = cplcFeChaSvImR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

!--------------
!  bar[Cha], Cha
!--------------
Do i1=1,2
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplcFeChaSvImL(gt3,i1,gt1)
coup(4) = cplcFeChaSvImR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaFeSvImL(i2,gt2,gt1)
coup(8) = cplcChaFeSvImR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: bar[Cha],Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Cha'
        End Do
      End Do

!--------------
!  Cha, Cha
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i1,iIN)
coup(2) = cplcFeChaSvReR(gt3,i1,iIN)
coup(3) = cplcChaFeSvImL(i1,gt2,gt1)
coup(4) = cplcChaFeSvImR(i1,gt2,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaFeSvImL(i2,gt2,gt1)
coup(8) = cplcChaFeSvImR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fe cFe Propagator: Cha,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Cha,Cha'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImFecFe

Subroutine SvReToSvReFecFe(iIN,MSvRe,MFe,MAh,Mhh,MCha,cplAhSvReSvRe,cplhhSvReSvRe,    &
& cplcChaFeSvReL,cplcChaFeSvReR,cplcFeChaSvReL,cplcFeChaSvReR,cplcFeFeAhL,               &
& cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MFe(3),MAh(3),Mhh(3),MCha(2)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplcChaFeSvReL(2,3,6),cplcChaFeSvReR(2,3,6),&
& cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),cplcFeFeAhL(3,3,3),cplcFeFeAhR(3,3,3),     &
& cplcFeFehhL(3,3,3),cplcFeFehhR(3,3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 100
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFe(gt2)/MSvRe(iIN))**2
rm2 = (MFe(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFe(gt3))+Abs(MFe(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcChaFeSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFeSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplcFeChaSvReL(gt3,i1,gt1))
coup(3) = Conjg(cplcFeChaSvReR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
      End Do

!--------------
!  Cha
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplcFeChaSvReL(gt3,i1,iIN))
coup(1) = Conjg(cplcFeChaSvReR(gt3,i1,iIN))
coup(4) = Conjg(cplcChaFeSvReL(i1,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvReR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Cha'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFeFeAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFeAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, bar[Cha]
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeChaSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeChaSvReR(gt3,i2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Ah,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,bar[Cha]'
        End Do
      End Do

!--------------
!  Ah, Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaFeSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvReR(i2,gt2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Ah,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Cha'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, bar[Cha]
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFeSvReL(i2,gt2,iIN)
coup(2) = cplcChaFeSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplcFeChaSvReL(gt3,i2,gt1))
coup(3) = Conjg(cplcFeChaSvReR(gt3,i2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: hh,bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,bar[Cha]'
        End Do
      End Do

!--------------
!  hh, Cha
!--------------
Do i1=1,3
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i2,iIN)
coup(2) = cplcFeChaSvReR(gt3,i2,iIN)
coup(4) = Conjg(cplcChaFeSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplcChaFeSvReR(i2,gt2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: hh,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Cha'
        End Do
      End Do

!--------------
!  bar[Cha], bar[Cha]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplcFeChaSvReL(gt3,i1,gt1)
coup(4) = cplcFeChaSvReR(gt3,i1,gt1)
coup(5) = cplcChaFeSvReL(i2,gt2,iIN)
coup(6) = cplcChaFeSvReR(i2,gt2,iIN)
coup(7) = cplcFeChaSvReL(gt3,i2,gt1)
coup(8) = cplcFeChaSvReR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: bar[Cha],bar[Cha]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
        End Do
      End Do

!--------------
!  bar[Cha], Cha
!--------------
Do i1=1,2
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFeSvReL(i1,gt2,iIN)
coup(2) = cplcChaFeSvReR(i1,gt2,iIN)
coup(3) = cplcFeChaSvReL(gt3,i1,gt1)
coup(4) = cplcFeChaSvReR(gt3,i1,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaFeSvReL(i2,gt2,gt1)
coup(8) = cplcChaFeSvReR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: bar[Cha],Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Cha'
        End Do
      End Do

!--------------
!  Cha, Cha
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcFeChaSvReL(gt3,i1,iIN)
coup(2) = cplcFeChaSvReR(gt3,i1,iIN)
coup(3) = cplcChaFeSvReL(i1,gt2,gt1)
coup(4) = cplcChaFeSvReR(i1,gt2,gt1)
coup(5) = cplcFeChaSvReL(gt3,i2,iIN)
coup(6) = cplcFeChaSvReR(gt3,i2,iIN)
coup(7) = cplcChaFeSvReL(i2,gt2,gt1)
coup(8) = cplcChaFeSvReR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fe cFe Propagator: Cha,Cha"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Cha,Cha'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:100))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReFecFe

Subroutine SvReToFvFdcSd(iIN,MFv,MFd,MSd,MChi,MSvRe,cplChiFdcSdL,cplChiFdcSdR,        &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MFv(6),MFd(3),MSd(6),MChi(5),MSvRe(6)

Complex(dp),Intent(in) :: cplChiFdcSdL(5,3,6),cplChiFdcSdR(5,3,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 25
Allocate( gSum(6,3,6, Isum) )
Allocate( Contribution(6,3,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
Isum = 0

rk2 = (MFv(gt1)/MSvRe(iIN))**2
rm2 = (MFd(gt2)/MSvRe(iIN))**2
rj2 = (MSd(gt3)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MSd(gt3))+Abs(MFd(gt2))+Abs(MFv(gt1)))) Then
!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFdcSdL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFdcSdR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fv Fd cSd Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt1,iIN)
coup(2) = cplChiFvSvReR(i1,gt1,iIN)
coup(3) = cplChiFdcSdL(i1,gt2,gt3)
coup(4) = cplChiFdcSdR(i1,gt2,gt3)
coup(5) = cplChiFvSvReL(i2,gt1,iIN)
coup(6) = cplChiFvSvReR(i2,gt1,iIN)
coup(7) = cplChiFdcSdL(i2,gt2,gt3)
coup(8) = cplChiFdcSdR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fv Fd cSd Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToFvFdcSd

Subroutine SvReToFvFucSu(iIN,MFv,MFu,MSu,MChi,MSvRe,cplChiFucSuL,cplChiFucSuR,        &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MFv(6),MFu(3),MSu(6),MChi(5),MSvRe(6)

Complex(dp),Intent(in) :: cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 25
Allocate( gSum(6,3,6, Isum) )
Allocate( Contribution(6,3,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
Isum = 0

rk2 = (MFv(gt1)/MSvRe(iIN))**2
rm2 = (MFu(gt2)/MSvRe(iIN))**2
rj2 = (MSu(gt3)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MSu(gt3))+Abs(MFu(gt2))+Abs(MFv(gt1)))) Then
!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFucSuL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFucSuR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fv Fu cSu Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt1,iIN)
coup(2) = cplChiFvSvReR(i1,gt1,iIN)
coup(3) = cplChiFucSuL(i1,gt2,gt3)
coup(4) = cplChiFucSuR(i1,gt2,gt3)
coup(5) = cplChiFvSvReL(i2,gt1,iIN)
coup(6) = cplChiFvSvReR(i2,gt1,iIN)
coup(7) = cplChiFucSuL(i2,gt2,gt3)
coup(8) = cplChiFucSuR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Fv Fu cSu Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToFvFucSu

Subroutine SvReToSvImFvFv(iIN,MSvIm,MFv,MVZ,MAh,Mhh,MChi,MSvRe,cplAhSvImSvRe,         &
& cplhhSvImSvRe,cplSvImSvReVZ,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL,cplChiFvSvReR,   &
& cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,deltaM,              &
& epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MFv(6),MVZ,MAh(3),Mhh(3),MChi(5),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplChiFvSvImL(5,6,6),    &
& cplChiFvSvImR(5,6,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),cplFvFvAhL(6,6,3),      &
& cplFvFvAhR(6,6,3),cplFvFvhhL(6,6,3),cplFvFvhhR(6,6,3),cplFvFvVZL(6,6),cplFvFvVZR(6,6)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 144
Allocate( gSum(6,6,6, Isum) )
Allocate( Contribution(6,6,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,6
        Do gt3=gt2,6
Isum = 0

rk2 = (MFv(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MFv(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplFvFvVZL(gt2,gt3))
coup(2) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplFvFvVZL(gt3,gt2))
coup(2) = Conjg(cplFvFvVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i1,gt1,iIN)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i1,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplChiFvSvImL(i1,gt3,gt1))
coup(3) = Conjg(cplChiFvSvImR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiFvSvImL(i1,gt2,gt1))
coup(3) = Conjg(cplChiFvSvImR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MChi(i1)
mass(2) = MChi(i1)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvImL(i1,gt2,gt1)
coup(4) = cplChiFvSvImR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i1,gt2,iIN)
coup(6) = cplChiFvSvReR(i1,gt2,iIN)
coup(7) = cplChiFvSvImL(i1,gt3,gt1)
coup(8) = cplChiFvSvImR(i1,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplFvFvVZL(gt2,gt3))
coup(3) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplFvFvAhL(gt2,gt3,i2))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplFvFvVZL(gt2,gt3))
coup(3) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  VZ, Chi
!--------------
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ2
mass(1) = MChi2(i2)
coup(1) = cplChiFvSvReL(i2,gt2,iIN)
coup(2) = cplChiFvSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt3,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt3,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplFvFvVZL(gt2,gt3))
coup(6) = Conjg(cplFvFvVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MVZ2
mass(1) = MChi2(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt2,gt1))
coup(5) = cplSvImSvReVZ(gt1,iIN)
coup(7) = Conjg(cplFvFvVZL(gt2,gt3))
coup(6) = Conjg(cplFvFvVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC  ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: VZ,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Chi'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, Chi
!--------------
Do i1=1,3
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt2,iIN)
coup(2) = cplChiFvSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt3,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt3,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MAh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt2,gt1))
coup(5) = cplAhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Ah,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Chi'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, Chi
!--------------
Do i1=1,3
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt2,iIN)
coup(2) = cplChiFvSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt3,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt3,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = Mhh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFvSvImL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFvSvImR(i2,gt2,gt1))
coup(5) = cplhhSvImSvRe(i1,gt1,iIN)
coup(7) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: hh,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt2,iIN)
coup(2) = cplChiFvSvReR(i1,gt2,iIN)
coup(3) = cplChiFvSvImL(i1,gt3,gt1)
coup(4) = cplChiFvSvImR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt2,iIN)
coup(6) = cplChiFvSvReR(i2,gt2,iIN)
coup(7) = cplChiFvSvImL(i2,gt3,gt1)
coup(8) = cplChiFvSvImR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvImL(i1,gt2,gt1)
coup(4) = cplChiFvSvImR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt2,iIN)
coup(6) = cplChiFvSvReR(i2,gt2,iIN)
coup(7) = cplChiFvSvImL(i2,gt3,gt1)
coup(8) = cplChiFvSvImR(i2,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvImL(i1,gt2,gt1)
coup(4) = cplChiFvSvImR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFvSvImL(i2,gt2,gt1)
coup(8) = cplChiFvSvImR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt2,iIN)
coup(2) = cplChiFvSvReR(i1,gt2,iIN)
coup(3) = cplChiFvSvImL(i1,gt3,gt1)
coup(4) = cplChiFvSvImR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFvSvImL(i2,gt2,gt1)
coup(8) = cplChiFvSvImR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fv Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,6
        Do gt3=gt2,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:144))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImFvFv

Subroutine SvReToSvReFvFv(iIN,MSvRe,MFv,MAh,Mhh,MChi,cplAhSvReSvRe,cplhhSvReSvRe,     &
& cplChiFvSvReL,cplChiFvSvReR,cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,               &
& deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MFv(6),MAh(3),Mhh(3),MChi(5)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),  &
& cplFvFvAhL(6,6,3),cplFvFvAhR(6,6,3),cplFvFvhhL(6,6,3),cplFvFvhhR(6,6,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 121
Allocate( gSum(6,6,6, Isum) )
Allocate( Contribution(6,6,6, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,6
        Do gt3=gt2,6
Isum = 0

rk2 = (MFv(gt2)/MSvRe(iIN))**2
rm2 = (MFv(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFv(gt3))+Abs(MFv(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i1,iIN,gt1)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i1,iIN,gt1)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt2,iIN))
coup(4) = Conjg(cplChiFvSvReL(i1,gt3,gt1))
coup(3) = Conjg(cplChiFvSvReR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSvRe(iIN)
coup(2) = Conjg(cplChiFvSvReL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFvSvReR(i1,gt3,iIN))
coup(4) = Conjg(cplChiFvSvReL(i1,gt2,gt1))
coup(3) = Conjg(cplChiFvSvReR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC

 mass(1) = MChi(i1)
mass(2) = MChi(i1)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvReL(i1,gt2,gt1)
coup(4) = cplChiFvSvReR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i1,gt2,iIN)
coup(6) = cplChiFvSvReR(i1,gt2,iIN)
coup(7) = cplChiFvSvReL(i1,gt3,gt1)
coup(8) = cplChiFvSvReR(i1,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  Ah, Chi
!--------------
Do i1=1,3
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt2,iIN)
coup(2) = cplChiFvSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFvSvReL(i2,gt3,gt1))
coup(3) = Conjg(cplChiFvSvReR(i2,gt3,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MAh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFvSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFvSvReR(i2,gt2,gt1))
coup(5) = cplAhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Ah,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Chi'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

!--------------
!  hh, Chi
!--------------
Do i1=1,3
  Do i2=1,5
Isum = Isum + 1

resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt2,iIN)
coup(2) = cplChiFvSvReR(i2,gt2,iIN)
coup(4) = Conjg(cplChiFvSvReL(i2,gt3,gt1))
coup(3) = Conjg(cplChiFvSvReR(i2,gt3,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = Mhh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFvSvReL(i2,gt3,iIN)
coup(2) = cplChiFvSvReR(i2,gt3,iIN)
coup(4) = Conjg(cplChiFvSvReL(i2,gt2,gt1))
coup(3) = Conjg(cplChiFvSvReR(i2,gt2,gt1))
coup(5) = cplhhSvReSvRe(i1,iIN,gt1)
coup(7) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: hh,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Chi'
        End Do
      End Do

!--------------
!  Chi, Chi
!--------------
Do i1=1,4
  Do i2=i1+1,5
Isum = Isum + 1

resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt2,iIN)
coup(2) = cplChiFvSvReR(i1,gt2,iIN)
coup(3) = cplChiFvSvReL(i1,gt3,gt1)
coup(4) = cplChiFvSvReR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt2,iIN)
coup(6) = cplChiFvSvReR(i2,gt2,iIN)
coup(7) = cplChiFvSvReL(i2,gt3,gt1)
coup(8) = cplChiFvSvReR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvReL(i1,gt2,gt1)
coup(4) = cplChiFvSvReR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt2,iIN)
coup(6) = cplChiFvSvReR(i2,gt2,iIN)
coup(7) = cplChiFvSvReL(i2,gt3,gt1)
coup(8) = cplChiFvSvReR(i2,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt3,iIN)
coup(2) = cplChiFvSvReR(i1,gt3,iIN)
coup(3) = cplChiFvSvReL(i1,gt2,gt1)
coup(4) = cplChiFvSvReR(i1,gt2,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFvSvReL(i2,gt2,gt1)
coup(8) = cplChiFvSvReR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFvSvReL(i1,gt2,iIN)
coup(2) = cplChiFvSvReR(i1,gt2,iIN)
coup(3) = cplChiFvSvReL(i1,gt3,gt1)
coup(4) = cplChiFvSvReR(i1,gt3,gt1)
coup(5) = cplChiFvSvReL(i2,gt3,iIN)
coup(6) = cplChiFvSvReR(i2,gt3,iIN)
coup(7) = cplChiFvSvReL(i2,gt2,gt1)
coup(8) = cplChiFvSvReR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC  ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fv Fv Propagator: Chi,Chi"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,6
        Do gt3=gt2,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReFvFv

Subroutine SvReToSeFucFd(iIN,MSe,MFu,MFd,MVWm,MHpm,MSvRe,cplSeSvRecHpm,               &
& cplSeSvRecVWm,cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL,cplcFdFuVWmR,deltaM,              &
& epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSe(6),MFu(3),MFd(3),MVWm,MHpm(2),MSvRe(6)

Complex(dp),Intent(in) :: cplSeSvRecHpm(6,6,2),cplSeSvRecVWm(6,6),cplcFdFuHpmL(3,3,2),cplcFdFuHpmR(3,3,2),      &
& cplcFdFuVWmL(3,3),cplcFdFuVWmR(3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 9
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFu(gt2)/MSvRe(iIN))**2
rm2 = (MFd(gt3)/MSvRe(iIN))**2
rj2 = (MSe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFd(gt3))+Abs(MFu(gt2))+Abs(MSe(gt1)))) Then
!--------------
!  conj[VWm]
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVWm
mass(2) = MVWm
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSeSvRecVWm(gt1,iIN))
coup(3) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(2) = Conjg(cplcFdFuVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Se Fu cFd Propagator: conj[VWm]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm]'

!--------------
!  conj[Hpm]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSeSvRecHpm(gt1,iIN,i1))
coup(3) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Se Fu cFd Propagator: conj[Hpm]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm]'
      End Do

!--------------
!  conj[VWm], conj[Hpm]
!--------------
  Do i2=1,2
Isum = Isum + 1

resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSeSvRecVWm(gt1,iIN)
coup(2) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(3) = Conjg(cplcFdFuVWmR(gt3,gt2))
coup(4) = cplSeSvRecHpm(gt1,iIN,i2)
coup(5) = Conjg(cplcFdFuHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFuHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Se Fu cFd Propagator: conj[VWm],conj[Hpm]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],conj[Hpm]'
      End Do

!--------------
!  conj[Hpm], conj[Hpm]
!--------------
Do i1=1,1
  Do i2=i1+1,2
Isum = Isum + 1

resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplSeSvRecHpm(gt1,iIN,i1)
coup(3) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
coup(4) = cplSeSvRecHpm(gt1,iIN,i2)
coup(6) = Conjg(cplcFdFuHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFuHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->Se Fu cFd Propagator: conj[Hpm],conj[Hpm]"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],conj[Hpm]'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:9))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSeFucFd

Subroutine SvReToSvImFdcFd(iIN,MSvIm,MFd,MVZ,MAh,Mhh,MSvRe,cplAhSvImSvRe,             &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,           &
& cplcFdFdVZL,cplcFdFdVZR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MFd(3),MVZ,MAh(3),Mhh(3),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplcFdFdAhL(3,3,3),      &
& cplcFdFdAhR(3,3,3),cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3),cplcFdFdVZL(3,3),             &
& cplcFdFdVZR(3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 49
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFd(gt2)/MSvRe(iIN))**2
rm2 = (MFd(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFd(gt3))+Abs(MFd(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(2) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(3) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFdFdAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFdAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(3) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fd cFd Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:49))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImFdcFd

Subroutine SvReToSvImFucFu(iIN,MSvIm,MFu,MVZ,MAh,Mhh,MSvRe,cplAhSvImSvRe,             &
& cplhhSvImSvRe,cplSvImSvReVZ,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL,cplcFuFuhhR,           &
& cplcFuFuVZL,cplcFuFuVZR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvIm(6),MFu(3),MVZ,MAh(3),Mhh(3),MSvRe(6)

Complex(dp),Intent(in) :: cplAhSvImSvRe(3,6,6),cplhhSvImSvRe(3,6,6),cplSvImSvReVZ(6,6),cplcFuFuAhL(3,3,3),      &
& cplcFuFuAhR(3,3,3),cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3),cplcFuFuVZL(3,3),             &
& cplcFuFuVZR(3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 49
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFu(gt2)/MSvRe(iIN))**2
rm2 = (MFu(gt3)/MSvRe(iIN))**2
rj2 = (MSvIm(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFu(gt3))+Abs(MFu(gt2))+Abs(MSvIm(gt1)))) Then
!--------------
!  VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MVZ
mass(2) = MVZ
m_in = MSvRe(iIN)
coup(1) = Conjg(cplSvImSvReVZ(gt1,iIN))
coup(3) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(2) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: VZ"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'

!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvImSvRe(i1,gt1,iIN))
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  VZ, Ah
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(3) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFuFuAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFuFuAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: VZ,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
      End Do

!--------------
!  VZ, hh
!--------------
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSvImSvReVZ(gt1,iIN)
coup(2) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(3) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(5) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: VZ,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplAhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvImSvRe(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4) = cplhhSvImSvRe(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvIm Fu cFu Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1,6
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:49))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvImFucFu

Subroutine SvReToSvReFdcFd(iIN,MSvRe,MFd,MAh,Mhh,cplAhSvReSvRe,cplhhSvReSvRe,         &
& cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MFd(3),MAh(3),Mhh(3)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplcFdFdAhL(3,3,3),cplcFdFdAhR(3,3,3),      &
& cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 36
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFd(gt2)/MSvRe(iIN))**2
rm2 = (MFd(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFd(gt3))+Abs(MFd(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fd cFd Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fd cFd Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFdFdAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fd cFd Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fd cFd Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fd cFd Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:36))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReFdcFd

Subroutine SvReToSvReFucFu(iIN,MSvRe,MFu,MAh,Mhh,cplAhSvReSvRe,cplhhSvReSvRe,         &
& cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL,cplcFuFuhhR,deltaM,epsI,check,g,WriteContributions)

Implicit None

Real(dp),Intent(in) :: MSvRe(6),MFu(3),MAh(3),Mhh(3)

Complex(dp),Intent(in) :: cplAhSvReSvRe(3,6,6),cplhhSvReSvRe(3,6,6),cplcFuFuAhL(3,3,3),cplcFuFuAhR(3,3,3),      &
& cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3)

Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR,  res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSvRe(iIN)

Isum = 36
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '

Isum = 0

    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
Isum = 0

rk2 = (MFu(gt2)/MSvRe(iIN))**2
rm2 = (MFu(gt3)/MSvRe(iIN))**2
rj2 = (MSvRe(gt1)/MSvRe(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSvRe(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSvRe(iIN)).gt.(Abs(MFu(gt3))+Abs(MFu(gt2))+Abs(MSvRe(gt1)))) Then
!--------------
!  Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplAhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fu cFu Propagator: Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
      End Do

!--------------
!  hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp

mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSvRe(iIN)
coup(1) = Conjg(cplhhSvReSvRe(i1,iIN,gt1))
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC  ! Color factor
resS = resS + resC

 resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fu cFu Propagator: hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
      End Do

!--------------
!  Ah, Ah
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplAhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFuFuAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fu cFu Propagator: Ah,Ah"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
        End Do
      End Do

!--------------
!  Ah, hh
!--------------
Do i1=1,3
  Do i2=1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fu cFu Propagator: Ah,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
        End Do
      End Do

!--------------
!  hh, hh
!--------------
Do i1=1,2
  Do i2=i1+1,3
Isum = Isum + 1

resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSvReSvRe(i1,iIN,gt1)
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4) = cplhhSvReSvRe(i2,iIN,gt1)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC  ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "SvRe->SvRe Fu cFu Propagator: hh,hh"
Write(*,*)  "M_in: ",m_in
Write(*,*)  "mass: ",mass
Write(*,*)  "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
        End Do
      End Do

Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
       End Do
     End Do
   End Do
!----------
!Summing
!----------
g=0._dp
    Do gt1=1, iIN-1
      Do gt2=1,3
        Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:36))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
  Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
  g(gt1,gt2,gt3)=0._dp
End If
       End Do
     End Do
   End Do
End Subroutine SvReToSvReFucFu

End Module SvRe3Decays_seesaw1nmssm