da_oi_stats_sound.inc

References to this file elsewhere.
1 subroutine da_oi_stats_sound (stats_unit, oi)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: TBD
5    !-----------------------------------------------------------------------
6 
7    implicit none
8 
9    integer,        intent (in)      :: stats_unit    ! Output unit for stats.
10    type (ob_type), intent (in)      :: oi            ! OI
11 
12    type (stats_sound_type)          :: Sound
13    integer                          :: nu, nv, nt, nq
14    integer                          :: n, k
15 
16    if (trace_use) call da_trace_entry("da_oi_stats_sound")
17 
18    nu = 0
19    nv = 0
20    nt = 0
21    nq = 0
22 
23    Sound%maximum%u = maxmin_type(missing_r, 0, 0)
24    Sound%maximum%v = maxmin_type(missing_r, 0, 0)
25    Sound%maximum%t = maxmin_type(missing_r, 0, 0)
26    Sound%maximum%q = maxmin_type(missing_r, 0, 0)
27    Sound%minimum%u = maxmin_type(-missing_r, 0, 0)
28    Sound%minimum%v = maxmin_type(-missing_r, 0, 0)
29    Sound%minimum%t = maxmin_type(-missing_r, 0, 0)
30    Sound%minimum%q = maxmin_type(-missing_r, 0, 0)
31    Sound%average = residual_sound1_type(0.0, 0.0, 0.0, 0.0)
32    Sound%rms_err = Sound%average
33 
34    if (oi%num_Sound > 0) then
35       do n=1, oi%num_Sound
36          if (oi%sound(n)%loc%proc_domain) then
37            do k=1, oi%sound(n)%info%levels
38               call da_stats_calculate(oi%Sound(n)%loc%obs_global_index, &
39                                k, oi%Sound(n)%u(k)%qc, &
40                                oi%sound(n)%u(k)%inv, nu, &
41                                sound%minimum%u, Sound%maximum%u, &
42                                sound%average%u, Sound%rms_err%u)
43               call da_stats_calculate(oi%Sound(n)%loc%obs_global_index, &
44                                k, oi%Sound(n)%v(k)%qc, &
45                                oi%sound(n)%v(k)%inv, nv, &
46                                sound%minimum%v, Sound%maximum%v, &
47                                sound%average%v, Sound%rms_err%v)
48               call da_stats_calculate(oi%Sound(n)%loc%obs_global_index, &
49                                k, oi%Sound(n)%t(k)%qc, &
50                                oi%sound(n)%t(k)%inv, nt, &
51                                sound%minimum%t, Sound%maximum%t, &
52                                sound%average%t, Sound%rms_err%t)
53               call da_stats_calculate(oi%Sound(n)%loc%obs_global_index, &
54                                k, oi%Sound(n)%q(k)%qc, &
55                                oi%Sound(n)%q(k)%inv, nq, &
56                                Sound%minimum%q, Sound%maximum%q, &
57                                Sound%average%q, Sound%rms_err%q)
58             end do
59          end if    ! end if (oi%sound(n)%loc%proc_domain)
60       end do
61    end if
62 
63    ! Do inter-processor communication to gather statistics.
64    call da_proc_sum_int(nu)
65    call da_proc_sum_int(nv)
66    call da_proc_sum_int(nt)
67    call da_proc_sum_int(nq)
68 
69    call da_proc_stats_combine(Sound%average%u, Sound%rms_err%u, &
70                            Sound%minimum%u%value, Sound%maximum%u%value, &
71                            Sound%minimum%u%n, Sound%maximum%u%n, &
72                            Sound%minimum%u%l, Sound%maximum%u%l)
73    call da_proc_stats_combine(Sound%average%v, Sound%rms_err%v, &
74                            Sound%minimum%v%value, Sound%maximum%v%value, &
75                            Sound%minimum%v%n, Sound%maximum%v%n, &
76                            Sound%minimum%v%l, Sound%maximum%v%l)
77    call da_proc_stats_combine(Sound%average%t, Sound%rms_err%t, &
78                            Sound%minimum%t%value, Sound%maximum%t%value, &
79                            Sound%minimum%t%n, Sound%maximum%t%n, &
80                            Sound%minimum%t%l, Sound%maximum%t%l)
81    call da_proc_stats_combine(Sound%average%q, Sound%rms_err%q, &
82                            Sound%minimum%q%value, Sound%maximum%q%value, &
83                            Sound%minimum%q%n, Sound%maximum%q%n, &
84                            Sound%minimum%q%l, Sound%maximum%q%l)
85 
86    if (rootproc) then
87       if (nu /= 0 .or. nv /= 0 .or. nt /= 0 .or. nq /= 0) then
88          write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of OI for sound'
89          call da_print_stats_sound(stats_unit, nu, nv, nt, nq, Sound)
90       end if
91    end if
92 
93    if (trace_use) call da_trace_exit("da_oi_stats_sound")
94 
95 end subroutine da_oi_stats_sound
96 
97