1 subroutine da_ao_stats_sound (stats_unit, iv, re, ob)
3 !-------------------------------------------------------------
5 !-------------------------------------------------------------
9 integer, intent (in) :: stats_unit ! Output unit for stats.
10 type (iv_type), intent (inout) :: iv ! iv
11 type (y_type), intent (in) :: re ! A - O
12 type(y_type), intent (in) :: ob ! Observation structure.
14 type (stats_sound_type) :: stats
15 integer :: nu, nv, nt, nq
17 real :: u_inc, v_inc, u_obs, v_obs
19 if (trace_use_dull) call da_trace_entry("da_ao_stats_sound")
26 stats%maximum%u = maxmin_type (missing_r, 0, 0)
27 stats%maximum%v = maxmin_type (missing_r, 0, 0)
28 stats%maximum%t = maxmin_type (missing_r, 0, 0)
29 stats%maximum%q = maxmin_type (missing_r, 0, 0)
30 stats%minimum%u = maxmin_type(-missing_r, 0, 0)
31 stats%minimum%v = maxmin_type(-missing_r, 0, 0)
32 stats%minimum%t = maxmin_type(-missing_r, 0, 0)
33 stats%minimum%q = maxmin_type(-missing_r, 0, 0)
35 stats%average = residual_sound1_type(0.0, 0.0, 0.0, 0.0)
36 stats%rms_err = stats%average
38 do n=1, iv%info(sound)%nlocal
39 do k=1, iv%info(sound)%levels(n)
41 u_inc = re%sound(n)%u(k)
42 v_inc = re%sound(n)%v(k)
43 u_obs = ob%sound(n)%u(k)
44 v_obs = ob%sound(n)%v(k)
46 if (.not. wind_sd_sound .and. wind_stats_sd) &
47 call da_ffdduv_diagnose(u_obs, u_obs, u_inc, v_obs, v_obs, v_inc, &
48 iv%sound(n)%u(k)%qc, iv%sound(n)%v(k)%qc, convert_uv2fd)
49 if (wind_sd_sound .and. .not. wind_stats_sd) &
50 call da_ffdduv_diagnose(u_obs, u_obs, u_inc, v_obs, v_obs, v_inc, &
51 iv%sound(n)%u(k)%qc, iv%sound(n)%v(k)%qc, convert_fd2uv)
53 if (iv%info(sound)%proc_domain(1,n)) then
54 call da_stats_calculate (n, k, iv%sound(n)%u(k)%qc, &
56 stats%minimum%u, stats%maximum%u, &
57 stats%average%u, stats%rms_err%u)
58 call da_stats_calculate (n, k, iv%sound(n)%v(k)%qc, &
60 stats%minimum%v, stats%maximum%v, &
61 stats%average%v, stats%rms_err%v)
62 call da_stats_calculate (n, k, iv%sound(n)%t(k)%qc, &
63 re%sound(n)%t(k), nt, &
64 stats%minimum%t, stats%maximum%t, &
65 stats%average%t, stats%rms_err%t)
66 call da_stats_calculate (n, k, iv%sound(n)%q(k)%qc, &
67 re%sound(n)%q(k), nq, &
68 stats%minimum%q, stats%maximum%q, &
69 stats%average%q, stats%rms_err%q)
74 ! Do inter-processor communication to gather statistics.
75 call da_proc_sum_int (nu)
76 call da_proc_sum_int (nv)
77 call da_proc_sum_int (nt)
78 call da_proc_sum_int (nq)
79 iv%nstats(sound) = nu + nv + nt + nq
81 call da_proc_stats_combine(stats%average%u, stats%rms_err%u, &
82 stats%minimum%u%value, stats%maximum%u%value, &
83 stats%minimum%u%n, stats%maximum%u%n, &
84 stats%minimum%u%l, stats%maximum%u%l)
85 call da_proc_stats_combine(stats%average%v, stats%rms_err%v, &
86 stats%minimum%v%value, stats%maximum%v%value, &
87 stats%minimum%v%n, stats%maximum%v%n, &
88 stats%minimum%v%l, stats%maximum%v%l)
89 call da_proc_stats_combine(stats%average%t, stats%rms_err%t, &
90 stats%minimum%t%value, stats%maximum%t%value, &
91 stats%minimum%t%n, stats%maximum%t%n, &
92 stats%minimum%t%l, stats%maximum%t%l)
93 call da_proc_stats_combine(stats%average%q, stats%rms_err%q, &
94 stats%minimum%q%value, stats%maximum%q%value, &
95 stats%minimum%q%n, stats%maximum%q%n, &
96 stats%minimum%q%l, stats%maximum%q%l)
99 if (nu /= 0 .or. nv /= 0 .or. nt /= 0 .or. nq /= 0) then
100 write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of AO for sound'
101 call da_print_stats_sound(stats_unit, nu, nv, nt, nq, stats)
105 if (trace_use_dull) call da_trace_exit("da_ao_stats_sound")
107 end subroutine da_ao_stats_sound