1 subroutine da_transform_xtoxa_adj(grid, wpec_on)
3 !--------------------------------------------------------------------------------------------------
4 ! Purpose: Transfers fields from WRF TL fields to diagnostic fields needed by observational operators
6 !--------------------------------------------------------------------------------------------------
10 type(domain), intent(inout) :: grid
11 logical, intent(in), optional :: wpec_on
14 real :: sdmd, s1md, mu
15 real :: p(kms:kme), mr_a(kms:kme), mr_b(kms:kme)
18 logical :: calc_wpec_term
20 if (trace_use) call da_trace_entry("da_transform_xtoxa_adj")
22 !-------------------------------------------------------------------------
23 ! Polar treatment for Global
24 !-------------------------------------------------------------------------
27 ! Poles treatment for global WRFVAR
28 call da_get_avpoles(grid%xa%u,grid%xa%v, &
29 ids,ide,jds,jde,ims,ime,jms,jme,kms,kme,its,ite,jts,jte,kts,kte)
30 call da_get_aspoles(grid%xa%t, &
31 ids,ide,jds,jde,ims,ime,jms,jme,kms,kme,its,ite,jts,jte,kts,kte)
32 call da_get_aspoles(grid%xa%p, &
33 ids,ide,jds,jde,ims,ime,jms,jme,kms,kme,its,ite,jts,jte,kts,kte)
34 call da_get_aspoles(grid%xa%q, &
35 ids,ide,jds,jde,ims,ime,jms,jme,kms,kme,its,ite,jts,jte,kts,kte)
36 call da_get_aspoles(grid%xa%psfc, &
37 ids,ide,jds,jde,ims,ime,jms,jme,1,1,its,ite,jts,jte,1,1)
40 ! Compute w increments using Richardson's eqn.
41 if ( Use_RadarObs) then
45 grid%xa%w(i,j,k)=grid%xa%w(i,j,k)+0.5*grid%xa%wh(i,j,k)
46 grid%xa%w(i,j,k+1)=grid%xa%w(i,j,k+1)+0.5*grid%xa%wh(i,j,k)
51 if ( .not. var4d .and. cloud_cv_options == 1 ) call da_uvprho_to_w_adj(grid)
54 if ( cloud_cv_options == 1 ) then
55 ! Partition of hydrometeor increments via warm rain process
56 call da_moist_phys_adj(grid)
59 !-------------------------------------------------------------------------
60 ! If test_transforms = .true., not "XToY" transform needed to do here (YRG):
62 if (.not.test_transforms) then
63 if (use_ssmt1obs .or. use_ssmt2obs .or. use_gpspwobs .or. use_gpsztdobs .or. &
64 use_ssmitbobs .or. use_ssmiretrievalobs .or. use_gpsrefobs .or. use_gpsephobs) then
65 if (use_ssmitbobs) call da_transform_xtotb_adj(grid)
66 if (use_ssmt1obs .or. use_ssmt2obs .or. &
67 use_ssmitbobs .or. use_ssmiretrievalobs) then
69 call da_error(__FILE__,__LINE__, &
70 (/"grid%xb%speed is not available, see da_transfer_kmatoxb.inc"/))
72 call da_transform_xtoseasfcwind_adj(grid)
76 if ( use_gpsrefObs .or. use_gpsephObs .or. use_gpsztdObs) then
77 if (use_gpsztdObs) call da_transform_xtoztd_adj(grid)
78 call da_transform_XTogpsref_adj(grid)
82 call da_transform_xtotpw_adj(grid)
85 if (sfc_assi_options == 2) call da_transform_xtowtq_adj(grid)
88 calc_wpec_term = .false.
89 if ( present(wpec_on) ) then
90 if ( wpec_on ) calc_wpec_term = .true.
93 if ( .not. var4d .and. calc_wpec_term ) then
100 if ((fg_format==fg_format_wrf_arw_regional) .or. &
101 (fg_format==fg_format_wrf_arw_global ) ) then
104 geoh(k) = geoh(k) + 0.5*grid%xa%geoh(i,j,k)
105 geoh(k+1) = geoh(k+1) + 0.5*grid%xa%geoh(i,j,k)
106 grid%xa%mu(i,j)=grid%xa%mu(i,j)-c1h(k)*geoh(k+1)*grid%xb%dnw(k)/grid%xb%rho(i,j,k)
107 grid%xa%rho(i,j,k)=grid%xa%rho(i,j,k)+ &
108 geoh(k+1)*(c1h(k)*grid%xb%psac(i,j)+c2h(k))*grid%xb%dnw(k)/(grid%xb%rho(i,j,k)**2)
109 geoh(k) = geoh(k) + geoh(k+1)
116 call da_pt_to_rho_adj(grid)
118 if ( .not. var4d ) then
122 if ((fg_format==fg_format_wrf_arw_regional) .or. &
123 (fg_format==fg_format_wrf_arw_global ) ) then
124 if ( .not. calc_wpec_term ) mu=0.0
130 mr_b(k) = grid%xb%q(i,j,k)/(1.0 - grid%xb%q(i,j,k))
131 s1md=s1md+(1.0+mr_b(k))*grid%xb%dnw(k)
133 p(k) = p(k) + 0.5*grid%xa%p(i,j,k)
134 p(k+1) = p(k+1) + 0.5*grid%xa%p(i,j,k)
136 if ( calc_wpec_term ) then
137 grid%xa%mu(i,j) = grid%xa%mu(i,j) - c1h(k)*p(k)*(1.0+mr_b(k))*grid%xb%dnw(k)
140 mu = mu - c1h(k)*p(k)*(1.0+mr_b(k))*grid%xb%dnw(k)
143 mr_a(k) = - p(k)*(c1h(k)*grid%xb%psac(i,j)+c2h(k))*grid%xb%dnw(k)
144 p(k+1) = p(k+1) + p(k)
147 grid%xa%psfc(i,j) = grid%xa%psfc(i,j) - mu/s1md
148 sdmd=-mu*grid%xb%psac(i,j)/s1md
151 mr_a(k) = mr_a(k) + sdmd*grid%xb%dnw(k)
152 grid%xa%q(i,j,k) = grid%xa%q(i,j,k) + mr_a(k)/(1.0 - grid%xb%q(i,j,k))**2
154 else if (fg_format == fg_format_kma_global)then
157 coeff = grid%xb%KMA_B(K)/(grid%xb%KMA_A(K)+grid%xb%KMA_B(K)* &
158 grid%xb%psfc(I,J)/100.0)
160 PU = grid%xb%KMA_A(K+1) + grid%xb%KMA_B(K+1)*grid%xb%psfc(I,J)/100.0
161 PD = grid%xb%KMA_A(K ) + grid%xb%KMA_B(K )*grid%xb%psfc(I,J)/100.0
162 coeff=grid%xb%KMA_B(K)*1.0/(PD-PU)**2*(-PU*(LOG(PD)-LOG(PU))+PD-PU)&
163 + grid%xb%KMA_B(K+1)*1.0/(PD-PU)**2*(PD*(LOG(PD)-LOG(PU))-PD+PU)
166 grid%xa%psfc(i,j) = grid%xa % psfc(i,j) + &
167 grid%xb%p(i,j,k) * grid%xa % p(i,j,k)/100.0 * coeff
173 endif ! only for 3dvar
176 call da_set_boundary_xa(grid)
179 if (trace_use) call da_trace_exit("da_transform_xtoxa_adj")
181 end subroutine da_transform_xtoxa_adj