1 subroutine da_oi_stats_lightning (stats_unit, iv)
3 !-----------------------------------------------------------------------
5 ! Authors: Z Chen (zchen@fjnu.edu.cn), Jenny Sun (NCAR), X Qie (IAP)
6 !-----------------------------------------------------------------------
10 integer, intent (in) :: stats_unit ! Output unit for stats.
11 type (iv_type), intent (in) :: iv ! OI
13 type (stats_lightning_type) :: stats
14 integer :: nw, nqv, ndiv
17 if (trace_use_dull) call da_trace_entry("da_oi_stats_lightning")
23 stats%maximum%w = maxmin_type(missing_r, 0, 0)
24 stats%minimum%w = maxmin_type(-missing_r, 0, 0)
25 stats%maximum%div = maxmin_type(missing_r, 0, 0)
26 stats%minimum%div = maxmin_type(-missing_r, 0, 0)
27 stats%maximum%qv = maxmin_type(missing_r, 0, 0)
28 stats%minimum%qv = maxmin_type(-missing_r, 0, 0)
30 stats%average = residual_lightning1_type(0.0, 0.0, 0.0)
31 stats%rms_err = stats%average
33 do n = 1, iv%info(lightning)%nlocal
34 if(iv%info(lightning)%proc_domain(1,n)) then
35 do k = 1, iv%info(lightning)%levels(n)
36 if(use_lightning_w) then
37 call da_stats_calculate(iv%info(lightning)%obs_global_index(n), &
38 k, iv%lightning(n)%w(k)%qc, &
39 iv%lightning(n)%w(k)%inv, nw, &
40 stats%minimum%w, stats%maximum%w, &
41 stats%average%w, stats%rms_err%w)
44 if(use_lightning_div) then
45 call da_stats_calculate(iv%info(lightning)%obs_global_index(n), &
46 k, iv%lightning(n)%div(k)%qc, &
47 iv%lightning(n)%div(k)%inv, ndiv, &
48 stats%minimum%div, stats%maximum%div, &
49 stats%average%div, stats%rms_err%div)
52 if(use_lightning_qv) then
53 call da_stats_calculate(iv%info(lightning)%obs_global_index(n), &
54 k, iv%lightning(n)%qv(k)%qc, &
55 iv%lightning(n)%qv(k)%inv, nqv, &
56 stats%minimum%qv, stats%maximum%qv, &
57 stats%average%qv, stats%rms_err%qv)
64 ! Do inter-processor communication to gather statistics.
65 if (use_lightning_w) then
66 call da_proc_sum_int (nw)
67 call da_proc_stats_combine(stats%average%w, stats%rms_err%w, &
68 stats%minimum%w%value, stats%maximum%w%value, &
69 stats%minimum%w%n, stats%maximum%w%n, &
70 stats%minimum%w%l, stats%maximum%w%l)
73 if (use_lightning_div) then
74 call da_proc_sum_int (ndiv)
75 call da_proc_stats_combine(stats%average%div, stats%rms_err%div, &
76 stats%minimum%div%value, stats%maximum%div%value, &
77 stats%minimum%div%n, stats%maximum%div%n, &
78 stats%minimum%div%l, stats%maximum%div%l)
81 if (use_lightning_qv) then
82 call da_proc_sum_int (nqv)
83 call da_proc_stats_combine(stats%average%qv, stats%rms_err%qv, &
84 stats%minimum%qv%value, stats%maximum%qv%value, &
85 stats%minimum%qv%n, stats%maximum%qv%n, &
86 stats%minimum%qv%l, stats%maximum%qv%l)
90 if ( nw /= 0 .or. ndiv /= 0 .or. nqv /= 0 ) then
91 write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of OI for lightning'
92 call da_print_stats_lightning(stats_unit, nw, ndiv, nqv, stats)
96 if (trace_use_dull) call da_trace_exit("da_oi_stats_lightning")
98 end subroutine da_oi_stats_lightning