| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | spec_frequency_bins(histogramming_spec%n_frequency_bins) | |||
| real(kind=dp), | intent(out) | :: | ratio |
subroutine integrate_frequency_histogram_spec(spec_frequency_bins, ratio) ! specific histogram integration routine which sums up the inputted ! frequency_bins integer(int64), intent(in) :: spec_frequency_bins(histogramming_spec%n_frequency_bins) real(dp), intent(out) :: ratio character(*), parameter :: this_routine = "integrate_frequency_histogram_spec" integer(int64) :: all_frequency_bins(histogramming_spec%n_frequency_bins) integer(int64) :: i, threshold integer(int64) :: n_elements, cnt real(dp) :: test_ratio, all_test_ratio logical :: mpi_ltmp ! test a change to the tau-search by now integrating on each ! processor seperately and communicate the maximas if (t_test_hist_tau) then test_ratio = 0.0_dp n_elements = sum(spec_frequency_bins) if (n_elements == 0) then test_ratio = 0.0_dp else if (n_elements < 0) then test_ratio = -1.0_dp ! if any of the frequency_ratios is full i guess i should ! also end the histogramming tau-search or? ! yes i have to communicate that.. or else it gets ! fucked up.. t_fill_frequency_hists = .false. else threshold = int(histogramming_spec%frq_ratio_cutoff * n_elements, kind=int64) cnt = 0_int64 i = 0_int64 do while (cnt < threshold) i = i + 1 cnt = cnt + spec_frequency_bins(i) end do test_ratio = i * histogramming_spec%frq_step_size end if ! how do i best deal with the mpi communication. ! i could use a mpialllor on (.not. t_fill_frequency_hists) to ! check if one of them is false on any processor.. call MPIAllLORLogical(.not. t_fill_frequency_hists, mpi_ltmp) if (mpi_ltmp) then ! then i know one of the frequency histograms is full.. so ! stop on all nodes! t_fill_frequency_hists = .false. ratio = -1.0_dp return else all_test_ratio = 0.0_dp call MPIAllReduce(test_ratio, MPI_MAX, all_test_ratio) ratio = all_test_ratio end if return end if ! MPI communicate all_frequency_bins = 0 call MPIAllReduce(spec_frequency_bins, MPI_SUM, all_frequency_bins) n_elements = sum(all_frequency_bins) ! have to check if no elements are yet stored into the histogram! if (n_elements == 0) then ratio = 0.0_dp return else if (n_elements < 0) then ! i reached an integer overflow.. and should stop histogramming ! this also means i should make an additional flag for only ! the histogramming option without the tau-search to it ! so i can also stop just the histogramming after an int ! overflow in the histograms ! TODO: in this case i also have to decide if i want to print ! it at this moment.. or maybe still at the end of the ! calculation.. but yes, maybe i want to, by default, always ! print them to be able to continue from a certain setting call stop_all(this_routine, "Overflow reached") ratio = -1.0_dp t_fill_frequency_hists = .false. return end if threshold = int(histogramming_spec%frq_ratio_cutoff * n_elements, kind=int64) cnt = 0 i = 0 do while (cnt < threshold) i = i + 1 cnt = cnt + all_frequency_bins(i) end do ratio = i * histogramming_spec%frq_step_size end subroutine integrate_frequency_histogram_spec