1 subroutine da_oi_stats_metar (stats_unit, iv, ob)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
9 integer, intent (in) :: stats_unit ! Output unit for stats.
10 type (iv_type), intent (in) :: iv ! OI
11 type(y_type), intent (in) :: ob ! Observation structure.
13 type (stats_metar_type) :: stats
14 integer :: nu, nv, nt, np, nq
16 real :: u_inv, v_inv, u_obs, v_obs
18 if (trace_use_dull) call da_trace_entry("da_oi_stats_metar")
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%p = maxmin_type(missing_r, 0, 0)
30 stats%maximum%q = maxmin_type(missing_r, 0, 0)
31 stats%minimum%u = maxmin_type(-missing_r, 0, 0)
32 stats%minimum%v = maxmin_type(-missing_r, 0, 0)
33 stats%minimum%t = maxmin_type(-missing_r, 0, 0)
34 stats%minimum%p = maxmin_type(-missing_r, 0, 0)
35 stats%minimum%q = maxmin_type(-missing_r, 0, 0)
36 stats%average = residual_metar1_type(0.0, 0.0, 0.0, 0.0, 0.0)
37 stats%rms_err = stats%average
39 do n=1, iv%info(metar)%nlocal
40 if (iv%info(metar)%proc_domain(1,n)) then
42 u_inv = iv%metar(n)%u%inv
43 v_inv = iv%metar(n)%v%inv
47 if (.not. wind_sd_metar .and. wind_stats_sd) &
48 call da_ffdduv_diagnose(u_obs, u_inv, u_obs, v_obs, v_inv, v_obs, &
49 iv%metar(n)%u%qc, iv%metar(n)%v%qc, convert_uv2fd)
50 if (wind_sd_metar .and. .not. wind_stats_sd) &
51 call da_ffdduv_diagnose(u_obs, u_inv, u_obs, v_obs, v_inv, v_obs, &
52 iv%metar(n)%u%qc, iv%metar(n)%v%qc, convert_fd2uv)
54 call da_stats_calculate(iv%info(metar)%obs_global_index(n), &
55 0, iv%metar(n)%u%qc, &
57 stats%minimum%u, stats%maximum%u, &
58 stats%average%u, stats%rms_err%u)
59 call da_stats_calculate(iv%info(metar)%obs_global_index(n), &
60 0, iv%metar(n)%v%qc, &
62 stats%minimum%v, stats%maximum%v, &
63 stats%average%v, stats%rms_err%v)
64 call da_stats_calculate(iv%info(metar)%obs_global_index(n), &
65 0, iv%metar(n)%t%qc, &
66 iv%metar(n)%t%inv, nt, &
67 stats%minimum%t, stats%maximum%t, &
68 stats%average%t, stats%rms_err%t)
69 call da_stats_calculate(iv%info(metar)%obs_global_index(n), &
70 0, iv%metar(n)%p%qc, &
71 iv%metar(n)%p%inv, np, &
72 stats%minimum%p, stats%maximum%p, &
73 stats%average%p, stats%rms_err%p)
74 call da_stats_calculate(iv%info(metar)%obs_global_index(n), &
75 0, iv%metar(n)%q%qc, &
76 iv%metar(n)%q%inv, nq, &
77 stats%minimum%q, stats%maximum%q, &
78 stats%average%q, stats%rms_err%q)
82 ! Do inter-processor communication to gather statistics.
84 call da_proc_sum_int(nu)
85 call da_proc_sum_int(nv)
86 call da_proc_sum_int(nt)
87 call da_proc_sum_int(np)
88 call da_proc_sum_int(nq)
90 call da_proc_stats_combine(stats%average%u, stats%rms_err%u, &
91 stats%minimum%u%value, stats%maximum%u%value, &
92 stats%minimum%u%n, stats%maximum%u%n, &
93 stats%minimum%u%l, stats%maximum%u%l)
94 call da_proc_stats_combine(stats%average%v, stats%rms_err%v, &
95 stats%minimum%v%value, stats%maximum%v%value, &
96 stats%minimum%v%n, stats%maximum%v%n, &
97 stats%minimum%v%l, stats%maximum%v%l)
98 call da_proc_stats_combine(stats%average%t, stats%rms_err%t, &
99 stats%minimum%t%value, stats%maximum%t%value, &
100 stats%minimum%t%n, stats%maximum%t%n, &
101 stats%minimum%t%l, stats%maximum%t%l)
102 call da_proc_stats_combine(stats%average%p, stats%rms_err%p, &
103 stats%minimum%p%value, stats%maximum%p%value, &
104 stats%minimum%p%n, stats%maximum%p%n, &
105 stats%minimum%p%l, stats%maximum%p%l)
106 call da_proc_stats_combine(stats%average%q, stats%rms_err%q, &
107 stats%minimum%q%value, stats%maximum%q%value, &
108 stats%minimum%q%n, stats%maximum%q%n, &
109 stats%minimum%q%l, stats%maximum%q%l)
112 if (nu /= 0 .or. nv /= 0 .or. nt /= 0 .or. np /= 0 .or. nq /= 0) then
113 write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of OI for metar'
114 call da_print_stats_metar(stats_unit, nu, nv, nt, np, nq, stats)
118 if (trace_use_dull) call da_trace_exit("da_oi_stats_metar")
120 end subroutine da_oi_stats_metar