SUBROUTINE WriteHistogramEnergies()
INTEGER :: i, io(8)
real(dp) :: Norm,EnergyBin
IF(iProcIndex.eq.Root) THEN
AllHistogramEnergy(:)=0.0_dp
AllAttemptHist(:)=0.0_dp
AllSpawnHist(:)=0.0_dp
AllDoublesHist(:)=0.0_dp
AllDoublesAttemptHist(:)=0.0_dp
AllSinglesHist(:)=0.0_dp
AllSinglesAttemptHist(:)=0.0_dp
AllSinglesHistOccOcc(:)=0.0_dp
AllSinglesHistOccVirt(:)=0.0_dp
AllSinglesHistVirtOcc(:)=0.0_dp
AllSinglesHistVirtVirt(:)=0.0_dp
end if
CALL MPIReduce(HistogramEnergy,MPI_SUM,AllHistogramEnergy)
CALL MPIReduce(AttemptHist,MPI_SUM,AllAttemptHist)
CALL MPIReduce(SpawnHist,MPI_SUM,AllSpawnHist)
CALL MPIReduce(SinglesHist,MPI_SUM,AllSinglesHist)
CALL MPIReduce(SinglesAttemptHist,MPI_SUM,AllSinglesAttemptHist)
CALL MPIReduce(DoublesHist,MPI_SUM,AllDoublesHist)
CALL MPIReduce(DoublesAttemptHist,MPI_SUM,AllDoublesAttemptHist)
CALL MPIReduce(SinglesHistOccOcc,MPI_SUM,AllSinglesHistOccOcc)
CALL MPIReduce(SinglesHistOccVirt,MPI_SUM,AllSinglesHistOccVirt)
CALL MPIReduce(SinglesHistVirtOcc,MPI_SUM,AllSinglesHistVirtOcc)
CALL MPIReduce(SinglesHistVirtVirt,MPI_SUM,AllSinglesHistVirtVirt)
IF(iProcIndex.eq.Root) THEN
AllHistogramEnergy=AllHistogramEnergy/sum(AllHistogramEnergy)
AllAttemptHist=AllAttemptHist/sum(AllAttemptHist)
AllSpawnHist=AllSpawnHist/sum(AllSpawnHist)
AllSinglesAttemptHist=AllSinglesAttemptHist/sum(AllSinglesAttemptHist)
AllDoublesHist=AllDoublesHist/sum(AllDoublesHist)
Norm=sum(AllDoublesAttemptHist)
AllDoublesAttemptHist=AllDoublesAttemptHist/Norm
do i=1,iOffDiagNoBins
AllDoublesAttemptHist(i)=AllDoublesAttemptHist(i)/Norm
end do
Norm=0.0_dp
do i=1,iOffDiagNoBins
Norm=Norm+AllSinglesHist(i)
end do
! write(stdout,*) "AllSinglesHistNorm = ",Norm
do i=1,iOffDiagNoBins
AllSinglesHist(i)=AllSinglesHist(i)/Norm
end do
! Norm=0.0_dp
! do i=1,iOffDiagNoBins
! Norm=Norm+AllSinglesHistOccOcc(i)
! end do
do i=1,iOffDiagNoBins
AllSinglesHistOccOcc(i)=AllSinglesHistOccOcc(i)/Norm
end do
! Norm=0.0_dp
! do i=1,iOffDiagNoBins
! Norm=Norm+AllSinglesHistOccVirt(i)
! end do
do i=1,iOffDiagNoBins
AllSinglesHistOccVirt(i)=AllSinglesHistOccVirt(i)/Norm
end do
! Norm=0.0_dp
! do i=1,iOffDiagNoBins
! Norm=Norm+AllSinglesHistVirtOcc(i)
! end do
do i=1,iOffDiagNoBins
AllSinglesHistVirtOcc(i)=AllSinglesHistVirtOcc(i)/Norm
end do
! Norm=0.0_dp
! do i=1,iOffDiagNoBins
! Norm=Norm+AllSinglesHistVirtVirt(i)
! end do
do i=1,iOffDiagNoBins
AllSinglesHistVirtVirt(i)=AllSinglesHistVirtVirt(i)/Norm
end do
io(1) = get_free_unit()
open(io(1),FILE='EVERYENERGYHIST',STATUS='UNKNOWN')
io(2) = get_free_unit()
open(io(2),FILE='ATTEMPTENERGYHIST',STATUS='UNKNOWN')
io(3) = get_free_unit()
open(io(3),FILE='SPAWNENERGYHIST',STATUS='UNKNOWN')
EnergyBin=BinRange/2.0_dp
do i=1,iNoBins
IF(AllHistogramEnergy(i).gt.0.0_dp) write(io(1),*) EnergyBin, AllHistogramEnergy(i)
IF(AllAttemptHist(i).gt.0.0_dp) write(io(2),*) EnergyBin, AllAttemptHist(i)
IF(AllSpawnHist(i).gt.0.0_dp) write(io(3),*) EnergyBin, AllSpawnHist(i)
EnergyBin=EnergyBin+BinRange
end do
close(io(1))
close(io(2))
close(io(3))
open(io(1),FILE='SINGLESHIST',STATUS='UNKNOWN')
open(io(2),FILE='ATTEMPTSINGLESHIST',STATUS='UNKNOWN')
open(io(3),FILE='DOUBLESHIST',STATUS='UNKNOWN')
io(4) = get_free_unit()
open(io(4),FILE='ATTEMPTDOUBLESHIST',STATUS='UNKNOWN')
io(5) = get_free_unit()
open(io(5),FILE='SINGLESHISTOCCOCC',STATUS='UNKNOWN')
io(6) = get_free_unit()
open(io(6),FILE='SINGLESHISTOCCVIRT',STATUS='UNKNOWN')
io(7) = get_free_unit()
open(io(7),FILE='SINGLESHISTVIRTOCC',STATUS='UNKNOWN')
io(8) = get_free_unit()
open(io(8),FILE='SINGLESHISTVIRTVIRT',STATUS='UNKNOWN')
EnergyBin=-OffDiagMax+OffDiagBinRange/2.0_dp
do i=1,iOffDiagNoBins
IF(AllSinglesHist(i).gt.0.0_dp) write(io(1),*) EnergyBin, AllSinglesHist(i)
IF(AllSinglesAttemptHist(i).gt.0.0_dp) write(io(2),*) EnergyBin, AllSinglesAttemptHist(i)
IF(AllDoublesHist(i).gt.0.0_dp) write(io(3),*) EnergyBin, AllDoublesHist(i)
IF(AllDoublesAttemptHist(i).gt.0.0_dp) write(io(4),*) EnergyBin, AllDoublesAttemptHist(i)
IF(AllSinglesHistOccOcc(i).gt.0.0_dp) write(io(5),*) EnergyBin, AllSinglesHistOccOcc(i)
IF(AllSinglesHistOccVirt(i).gt.0.0_dp) write(io(6),*) EnergyBin, AllSinglesHistOccVirt(i)
IF(AllSinglesHistVirtOcc(i).gt.0.0_dp) write(io(7),*) EnergyBin, AllSinglesHistVirtOcc(i)
IF(AllSinglesHistVirtVirt(i).gt.0.0_dp) write(io(8),*) EnergyBin, AllSinglesHistVirtVirt(i)
EnergyBin=EnergyBin+OffDiagBinRange
! write(stdout,*) i
end do
close(io(1))
close(io(2))
close(io(3))
close(io(4))
close(io(5))
close(io(6))
close(io(7))
close(io(8))
end if
END SUBROUTINE WriteHistogramEnergies