1 subroutine da_transform_xtoxa(grid, wpec_on)
3 !--------------------------------------------------------------------------------------------------
4 ! Purpose: Transfers fields from WRF TL fields to diagnostic fields needed by observational operators
5 ! Updated for Analysis on Arakawa-C grid
6 ! Author: Syed RH Rizvi, MMM/ESSL/NCAR, Date: 10/22/2008
7 !--------------------------------------------------------------------------------------------------
11 type(domain), intent(inout) :: grid
12 logical, intent(in), optional :: wpec_on
15 real :: sdmd, s1md, mu
21 logical :: calc_wpec_term
23 if (trace_use) call da_trace_entry("da_transform_xtoxa")
25 !----------------------------------------------------------------------
26 ! [4.0]: Move the following:
27 !----------------------------------------------------------------------
29 calc_wpec_term = .false.
30 if ( present(wpec_on) ) then
31 if ( wpec_on ) calc_wpec_term =.true.
34 if ( .not. var4d ) then ! for 4dvar, xa%p comes from the model
38 if ((fg_format==fg_format_wrf_arw_regional) .or. &
39 (fg_format==fg_format_wrf_arw_global ) ) then
44 mr_a(k) = grid%xa%q(i,j,k)/(1.0 - grid%xb%q(i,j,k))**2
45 mr_b(k) = grid%xb%q(i,j,k)/(1.0 - grid%xb%q(i,j,k))
47 sdmd=sdmd+mr_a(k)*grid%xb%dnw(k)
48 s1md=s1md+(1.0+mr_b(k))*grid%xb%dnw(k)
51 mu=-(grid%xa%psfc(i,j)+grid%xb%psac(i,j)*sdmd)/s1md
52 if ( calc_wpec_term ) then
59 p(k)=p(k+1)-(c1h(k)*mu*(1.0+mr_b(k)) &
60 + (c1h(k)*grid%xb%psac(i,j)+c2h(k))*mr_a(k))*grid%xb%dnw(k)
62 grid%xa%p(i,j,k)=0.5*(p(k)+p(k+1))
64 else if (fg_format == fg_format_kma_global) then
67 coeff=grid%xb%KMA_B(K)/(grid%xb%KMA_A(K)+grid%xb%KMA_B(K)*grid%xb%psfc(I,J)/100.0)
69 PU = grid%xb%KMA_A(K+1) + grid%xb%KMA_B(K+1)*grid%xb%psfc(I,J)/100.0
70 PD = grid%xb%KMA_A(K ) + grid%xb%KMA_B(K )*grid%xb%psfc(I,J)/100.0
71 coeff=grid%xb%KMA_B(K) *1.0/(PD-PU)**2*(-PU*(LOG(PD)-LOG(PU)) &
73 + grid%xb%KMA_B(K+1)*1.0/(PD-PU)**2*(PD*(LOG(PD)-LOG(PU))-PD+PU)
75 ! Here since grid%xa%psfc holds value in Pa. dlnp -> dp
76 grid%xa%p(i,j,k) = grid%xb%p(i,j,k) * grid%xa%psfc(I,J)/100.0 * coeff
83 endif ! only for 3dvar
85 call da_pt_to_rho_lin(grid)
87 if ( .not. var4d .and. calc_wpec_term ) then
90 if ((fg_format==fg_format_wrf_arw_regional) .or. &
91 (fg_format==fg_format_wrf_arw_global ) ) then
94 geoh(k+1)=geoh(k)+(-c1h(k)*grid%xa%mu(i,j) &
95 + grid%xa%rho(i,j,k)*(c1h(k)*grid%xb%psac(i,j)+c2h(k)) &
96 /grid%xb%rho(i,j,k))* grid%xb%dnw(k)/grid%xb%rho(i,j,k)
97 grid%xa%geoh(i,j,k)=0.5*(geoh(k)+geoh(k+1))
105 if ((fg_format==fg_format_wrf_arw_regional .or. &
106 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
111 if ((fg_format==fg_format_wrf_arw_regional .or. &
112 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
118 #include "HALO_XA.inc"
121 if ( .not. var4d .and. calc_wpec_term ) then
123 #include "HALO_XA_WPEC.inc"
124 #include "HALO_XB_WPEC.inc"
129 if ((fg_format==fg_format_wrf_arw_regional .or. &
130 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
135 if ((fg_format==fg_format_wrf_arw_regional .or. &
136 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
142 ! If test_transforms = .true., not "XToY" transform needed to do here:
144 if (.not.test_transforms) then
145 ! Exchange grid%xa halo region.
147 if (sfc_assi_options == 2) then
148 call da_transform_xtowtq (grid)
149 ! Exchange grid%xa (surface variable) halo region.
151 #include "HALO_SFC_XA.inc"
155 if (use_ssmt1obs .or. use_ssmt2obs .or. use_gpspwobs .or. use_gpsztdobs .or. &
156 use_ssmitbobs .or. use_ssmiretrievalobs .or. use_gpsrefobs .or. use_gpsephobs) then
158 ! Now do something for PW
159 call da_transform_xtotpw(grid)
161 ! Space-based GPS Refractivity, GPS Excess Phase, and Ground-based GPS ZTD:
162 if ( use_gpsrefObs .or. use_gpsephObs .or. use_gpsztdObs) then
163 call da_transform_xtogpsref_lin(grid)
164 if (use_GpsztdObs) call da_transform_xtoztd_lin(grid)
167 if (use_ssmt1obs .or. use_ssmt2obs .or. &
168 use_ssmitbobs .or. use_ssmiretrievalobs) then
170 call da_error(__FILE__,__LINE__, &
171 (/"grid%xb%speed is not available, see da_transfer_kmatoxb.inc"/))
173 call da_transform_xtoseasfcwind_lin(grid)
175 if (use_ssmitbobs) call da_transform_xtotb_lin (grid)
177 ! Exchange grid%xa halo region.
179 #include "HALO_SSMI_XA.inc"
184 ! Compute w increments using Richardson's eqn.
186 if ( Use_RadarObs ) then
187 if ( .not. var4d .and. cloud_cv_options == 1) call da_uvprho_to_w_lin(grid)
192 grid%xa%wh(i,j,k)=0.5*(grid%xa%w(i,j,k)+grid%xa%w(i,j,k+1))
198 #include "HALO_RADAR_XA_W.inc"
202 if ( cloud_cv_options == 1 )then
203 ! Partition of hydrometeor increments via warm rain process
204 call da_moist_phys_lin(grid)
207 !---------------------------------------------------------------
208 ! Polar treatment for Global
209 !---------------------------------------------------------------
212 call da_get_vpoles(grid%xa%u,grid%xa%v, &
213 ids, ide, jds, jde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
214 call da_get_spoles(grid%xa%t, &
215 ids, ide, jds, jde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
216 call da_get_spoles(grid%xa%p, &
217 ids, ide, jds, jde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
218 call da_get_spoles(grid%xa%q, &
219 ids, ide, jds, jde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
220 call da_get_spoles(grid%xa%psfc, &
221 ids, ide, jds, jde, ims, ime, jms, jme, 1, 1, its, ite, jts, jte, 1, 1)
222 call da_set_boundary_xa(grid)
225 if (trace_use) call da_trace_exit("da_transform_xtoxa")
227 end subroutine da_transform_xtoxa