1 subroutine da_set_tst_trnsf_fld(grid, va, vb, typical_rms)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
9 type(domain), intent(in) :: grid ! model state
10 real, intent(out) :: va(ims:ime, jms:jme, kms:kme)
11 real, intent(in) :: vb(ims:ime, jms:jme, kms:kme)
12 real, intent(in) :: typical_rms
14 real :: gbuf(ids:ide, jds:jde, kds:kde)
16 integer :: k ! loop counter.
17 real :: scale ! scale factor.
18 real :: xy_dim_inv ! 1 / real(iy * jx)
19 real :: field_mean ! mean field.
20 real :: field_rms ! rms field.
22 if (trace_use) call da_trace_entry("da_set_tst_trnsf_fld")
24 size3d = (ide-ids+1)*(jde-jds+1)*(kde-kds+1)
26 call da_patch_to_global(grid, vb, gbuf)
27 call wrf_dm_bcast_real(gbuf, size3d)
29 xy_dim_inv = 1.0 / real((ide-ids+1)*(jde-jds+1))
32 field_mean = sum(gbuf(ids:ide, jds:jde, k)) * xy_dim_inv
34 gbuf(ids:ide, jds:jde, k) = gbuf(ids:ide, jds:jde, k) - field_mean
36 field_rms = sqrt(1.0e-6+sum(gbuf(ids:ide, jds:jde, k)**2) * xy_dim_inv)
38 scale = typical_rms / field_rms
40 va(its:ite, jts:jte, k) = scale * gbuf(its:ite, jts:jte, k)
43 if (trace_use) call da_trace_exit("da_set_tst_trnsf_fld")
45 end subroutine da_set_tst_trnsf_fld