1 subroutine da_ao_stats_chem_sfc (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_chem_sfc_type) :: stats
17 real :: chem_inc, v_inc
19 if (trace_use_dull) call da_trace_entry("da_ao_stats_chem_sfc")
22 allocate(stats%maximum%chem(num_chemic_surf))
23 allocate(stats%minimum%chem(num_chemic_surf))
24 allocate(stats%average%chem(num_chemic_surf))
25 allocate(stats%rms_err%chem(num_chemic_surf))
27 do ichem=PARAM_FIRST_SCALAR, num_chemic_surf
28 stats%maximum%chem(ichem) = maxmin_type (0.0, 0, 0)
29 stats%minimum%chem(ichem) = maxmin_type (0.0, 0, 0)
30 stats%average%chem(ichem) = 0.0
31 stats%rms_err%chem(ichem) = 0.0
34 iv%nstats(chemic_surf) = 0
36 do ichem=PARAM_FIRST_SCALAR, num_chemic_surf
39 do n=1, iv%info(chemic_surf)%nlocal
40 if (iv%info(chemic_surf)%proc_domain(1,n)) then
42 chem_inc = re%chemic_surf(n)%chem(ichem)
44 call da_stats_calculate (n, 0, iv%chemic_surf(n)%chem(ichem)%qc, &
46 stats%minimum%chem(ichem), stats%maximum%chem(ichem), &
47 stats%average%chem(ichem), stats%rms_err%chem(ichem))
51 ! Do inter-processor communication to gather statistics.
52 call da_proc_sum_int (nchem)
54 iv%nstats(chemic_surf) = iv%nstats(chemic_surf)+nchem
56 call da_proc_stats_combine(stats%average%chem(ichem), stats%rms_err%chem(ichem), &
57 stats%minimum%chem(ichem)%value, stats%maximum%chem(ichem)%value, &
58 stats%minimum%chem(ichem)%n, stats%maximum%chem(ichem)%n, &
59 stats%minimum%chem(ichem)%l, stats%maximum%chem(ichem)%l)
63 write(unit=stats_unit, fmt='(/a/)') ' Diagnostics of AO for chem'
64 if (chemicda_opt == 1 .or. chemicda_opt == 2) then
65 call da_print_stats_chem_sfc(stats_unit, nchem, stats)
66 else if (chemicda_opt >= 3) then
67 call da_print_stats_chem_sfc(stats_unit, nchem, stats, ichem)
73 deallocate(stats%maximum%chem)
74 deallocate(stats%minimum%chem)
75 deallocate(stats%average%chem)
76 deallocate(stats%rms_err%chem)
78 if (trace_use_dull) call da_trace_exit("da_ao_stats_chem_sfc")
80 end subroutine da_ao_stats_chem_sfc