1 subroutine da_ao_stats_lightning (stats_unit, iv, re)
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 (inout) :: iv ! iv
12 type (y_type), intent (in) :: re ! A - O
14 type (stats_lightning_type) :: stats
15 integer :: nw, ndiv, nqv
18 if (trace_use_dull) call da_trace_entry("da_ao_stats_lightning")
24 stats%maximum%w = maxmin_type (missing_r, 0, 0)
25 stats%maximum%div = maxmin_type (missing_r, 0, 0)
26 stats%maximum%qv = maxmin_type (missing_r, 0, 0)
27 stats%minimum%w = maxmin_type(-missing_r, 0, 0)
28 stats%minimum%div = maxmin_type(-missing_r, 0, 0)
29 stats%minimum%qv = maxmin_type(-missing_r, 0, 0)
31 stats%average = residual_lightning1_type(0.0, 0.0, 0.0)
32 stats%rms_err = stats%average
34 do n = 1, iv%info(lightning)%nlocal
35 if(iv%info(lightning)%proc_domain(1,n)) then
36 do k = 1, iv%info(lightning)%levels(n)
38 if(use_lightning_w) then
39 call da_stats_calculate (n, k, iv%lightning(n)%w(k)%qc, &
40 re%lightning(n)%w(k), nw, &
41 stats%minimum%w, stats%maximum%w, &
42 stats%average%w, stats%rms_err%w)
45 if(use_lightning_div) then
46 call da_stats_calculate (n, k, iv%lightning(n)%div(k)%qc, &
47 re%lightning(n)%div(k), 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 (n, k, iv%lightning(n)%qv(k)%qc, &
54 re%lightning(n)%qv(k), nqv, &
55 stats%minimum%qv, stats%maximum%qv, &
56 stats%average%qv, stats%rms_err%qv)
62 ! Do inter-processor communication to gather statistics.
63 if (use_lightning_w) then
64 call da_proc_sum_int (nw)
65 call da_proc_stats_combine(stats%average%w, stats%rms_err%w, &
66 stats%minimum%w%value, stats%maximum%w%value, &
67 stats%minimum%w%n, stats%maximum%w%n, &
68 stats%minimum%w%l, stats%maximum%w%l)
71 if (use_lightning_div) then
72 call da_proc_sum_int (ndiv)
73 call da_proc_stats_combine(stats%average%div, stats%rms_err%div, &
74 stats%minimum%div%value, stats%maximum%div%value, &
75 stats%minimum%div%n, stats%maximum%div%n, &
76 stats%minimum%div%l, stats%maximum%div%l)
79 if (use_lightning_qv) then
80 call da_proc_sum_int (nqv)
81 call da_proc_stats_combine(stats%average%qv, stats%rms_err%qv, &
82 stats%minimum%qv%value, stats%maximum%qv%value, &
83 stats%minimum%qv%n, stats%maximum%qv%n, &
84 stats%minimum%qv%l, stats%maximum%qv%l)
88 if ( nw /= 0 .or. ndiv /= 0 .or. nqv /= 0 ) then
89 write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of AO for lightning'
90 call da_print_stats_lightning(stats_unit, nw, ndiv, nqv, stats)
94 if (trace_use_dull) call da_trace_exit("da_ao_stats_lightning")
96 end subroutine da_ao_stats_lightning