1 subroutine da_data_distribution(ob_name, num_obs, min_val, max_val, bin_width, ob)
3 !---------------------------------------------------------------------------
4 ! Purpose: Bin ob data to get distribution.
5 !---------------------------------------------------------------------------
9 character (len=*), intent(in) :: ob_name ! Data description.
10 integer, intent(in) :: num_obs ! Number of obs.
11 real, intent(in) :: min_val ! Minimum bin value.
12 real, intent(in) :: max_val ! Maximum bin value.
13 real, intent(in) :: bin_width ! Bin width.
14 real, intent(in) :: ob(:) ! Ob data.
16 integer :: num_bins ! Number of bins
17 integer :: bin ! Bin counter.
18 integer :: n ! Data counter.
19 integer :: num_missing ! Number of missing data.
21 real, allocatable :: bin_val(:) ! Central value of bin.
22 real, allocatable :: bin_min(:) ! Minimum value of bin.
23 integer, allocatable :: num_in_bin(:) ! Number of values in bin.
25 if (trace_use) call da_trace_entry("da_data_distribution")
27 !---------------------------------------------------------------------------
28 ! [1.0] Initialise bins:
29 !---------------------------------------------------------------------------
31 num_bins = int((max_val - min_val) / bin_width) + 1
33 allocate(bin_val(1:num_bins))
36 bin_val(bin) = bin_val(bin-1) + bin_width
39 allocate(bin_min(1:num_bins+1))
40 bin_min(1:num_bins) = bin_val(1:num_bins) - 0.5 * bin_width
41 bin_min(num_bins+1) = bin_val(num_bins) + 0.5 * bin_width
43 allocate(num_in_bin(0:num_bins+1))
44 num_in_bin(0:num_bins+1) = 0
47 !---------------------------------------------------------------------------
48 ! [2.0] Assign data to bins:
49 !---------------------------------------------------------------------------
52 if (ob(n) == missing_r) then
53 num_missing = num_missing + 1
54 else if (ob(n) < bin_min(1) .AND. ob(n) /= missing_r) then
55 num_in_bin(0) = num_in_bin(0) + 1
56 else if (ob(n) >= bin_min(num_bins+1)) then
57 num_in_bin(num_bins+1) = num_in_bin(num_bins+1) + 1
60 if (ob(n) >= bin_min(bin) .AND. ob(n) < bin_min(bin+1)) then
61 num_in_bin(bin) = num_in_bin(bin) + 1
68 !---------------------------------------------------------------------------
69 ! [3.0] Output statistics:
70 !---------------------------------------------------------------------------
72 write(unit=stdout,fmt='(A,A,A,I8)')' Number of ', trim(ob_name), &
74 write(unit=stdout,fmt='(A,I8)')' Number with missing data indicator = ', &
76 write(unit=stdout,fmt='(A,f12.5,A,I8)')' Number below minimum O-B(', &
77 min_val-0.5*bin_width, ') = ', num_in_bin(0)
79 write(unit=stdout,fmt='(I4,f12.5,I8)')bin, bin_val(bin), num_in_bin(bin)
81 write(unit=stdout,fmt='(A,f12.5,A,I8)')' Number above maximum O-B(', &
82 max_val+0.5*bin_width, ') = ', num_in_bin(num_bins+1)
84 !---------------------------------------------------------------------------
86 !---------------------------------------------------------------------------
90 deallocate(num_in_bin)
92 if (trace_use) call da_trace_exit("da_data_distribution")
94 end subroutine da_data_distribution