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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | filename |
name of the file to write to |
||
| character(len=*), | intent(in) | :: | label1 |
name of the file to write to label of the first axis |
||
| character(len=*), | intent(in) | :: | label2 |
name of the file to write to label of the first axis label of the second axis |
||
| 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