Print out an already genereated 2d-histogram to disk The histogram is written with the two axes as first rows, then the data as a 2d-matrix @param[in] filename name of the file to write to @param[in] label1 label of the first axis @param[in] label2 label of the second axis @param[in] hists array of integers containing the histogram data for each pair of bins @param[in] bins1 bins of the first axis @param[in] bins2 bins of the second axis
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
character(len=*), | intent(in) | :: | label1 | |||
character(len=*), | intent(in) | :: | label2 | |||
integer, | intent(in) | :: | hist(:,:) | |||
real(kind=dp), | intent(in) | :: | bins1(:) | |||
real(kind=dp), | intent(in) | :: | bins2(:) |
subroutine print_2d_hist(filename, label1, label2, hist, bins1, bins2)
implicit none
character(len=*), intent(in) :: filename, label1, label2
real(dp), intent(in) :: bins1(:), bins2(:)
integer, intent(in) :: hist(:,:)
integer :: hist_unit
integer :: i, j
character, parameter :: tab = char(9)
if(iProcIndex == root) then
! output the histogram
hist_unit = get_free_unit()
open(hist_unit, file = filename, status = 'unknown')
write(hist_unit,"(A, A)") "# Boundaries of the bins of the first (vertical) dimension - ", label1
do j = 1, size(bins1)
write(hist_unit, '(G17.5)', advance = 'no') bins1(j)
end do
write(hist_unit, '()', advance = 'yes')
write(hist_unit, "(A, A)") "# Boundaries of the bins of the second (horizontal) dimension - ", label2
do j = 1, size(bins2)
write(hist_unit, '(G17.5)', advance = 'no') bins2(j)
end do
write(hist_unit, '()', advance = 'yes')
write(hist_unit, "(A)") "# Histogram - Note: Values laying exactly on a bounday are binned to the left"
do i = 1, size(bins1)-1
do j = 1, size(bins2)-1
write(hist_unit, '(G17.5)', advance = 'no') hist(i,j)
end do
write(hist_unit, '()', advance = 'yes')
end do
close(hist_unit)
end if
end subroutine print_2d_hist