1 subroutine da_transfer_xatowrftl(grid, config_flags, filnam, timestr)
3 !---------------------------------------------------------------------------
4 ! Purpose: Convert analysis increments into WRFTL increments
5 ! (following xatowrf, but only keep the increments)
6 !---------------------------------------------------------------------------
10 type(domain), intent(inout) :: grid
11 type(grid_config_rec_type), intent(inout) :: config_flags
12 character*4, intent(in) :: filnam
13 character(len=256), intent(in) :: timestr
18 integer :: is, ie, js, je, ks, ke
23 real, allocatable, dimension(:,:,:) :: g_press
25 real, allocatable, dimension(:,:,:) :: utmp, vtmp, g_press
30 if (trace_use) call da_trace_entry("da_transfer_xatowrftl")
39 allocate (g_press(grid%xp%ims:grid%xp%ime,grid%xp%jms:grid%xp%jme,grid%xp%kms:grid%xp%kme))
41 !---------------------------------------------------------------------------
42 ! [1.0] Get the mixing ratio of moisture first, as it is easy.
43 !---------------------------------------------------------------------------
48 grid%g_moist(i,j,k,P_G_QV)=grid%xa%q(i,j,k)/(1.0-grid%xb%q(i,j,k))**2
53 !---------------------------------------------------------------------------
54 ! [2.0] COMPUTE increments of dry-column air mass per unit area
55 !---------------------------------------------------------------------------
62 sdmd=sdmd+grid%g_moist(i,j,k,P_G_QV)*grid%dnw(k)
63 s1md=s1md+(1.0+grid%moist(i,j,k,P_QV))*grid%dnw(k)
65 grid%g_mu_2(i,j)=-(grid%xa%psfc(i,j)+grid%xb%psac(i,j)*sdmd)/s1md
69 !---------------------------------------------------------------------------
70 ! [3.0] compute pressure increments (for computing theta increments)
71 !---------------------------------------------------------------------------
77 g_press(i,j,k)=g_press(i,j,k+1) &
78 -(grid%g_mu_2(i,j)*(1.0+grid%moist(i,j,k,P_QV)) &
79 +(grid%mu_2(i,j)+grid%mub(i,j))*grid%g_moist(i,j,k,P_G_QV))* &
81 grid%xa%p(i,j,k)=0.5*(g_press(i,j,k)+g_press(i,j,k+1))
86 !---------------------------------------------------------------------------
87 ! [4.0] convert temperature increments into theta increments
88 ! evaluate also the increments of (1/rho) and geopotential
89 !---------------------------------------------------------------------------
94 grid%g_t_2(i,j,k)=(t0+grid%t_2(i,j,k))* &
95 (grid%xa%t(i,j,k)/grid%xb%t(i,j,k) &
96 -kappa*grid%xa%p(i,j,k)/grid%xb%p(i,j,k))
102 ! grid%g_ph_2(i,j,ks)=0.0
104 ! rho_cgrid=grid%xb%rho(i,j,k) &
105 ! *(grid%xa%p(i,j,k)/grid%xb%p(i,j,k) &
106 ! -grid%xa%t(i,j,k)/grid%xb%t(i,j,k) &
107 ! -0.61*grid%xa%q(i,j,k)/(1.0+0.61*grid%xb%q(i,j,k)))
108 ! grid%g_ph_2(i,j,k+1)=grid%g_ph_2(i,j,k) &
109 ! -(g_press(i,j,k+1)-g_press(i,j,k) &
110 ! +(grid%ph_2(i,j,k+1)-grid%ph_2(i,j,k))*rho_cgrid) &
111 ! /grid%xb%rho(i,j,k)
123 !---------------------------------------------------------------------------
124 ! [5.0] convert from a-grid to c-grid
125 !---------------------------------------------------------------------------
128 if ((fg_format==fg_format_wrf_arw_regional .or. &
129 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
134 if ((fg_format==fg_format_wrf_arw_regional .or. &
135 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
141 #include "HALO_XA_A.inc"
145 if ((fg_format==fg_format_wrf_arw_regional .or. &
146 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
151 if ((fg_format==fg_format_wrf_arw_regional .or. &
152 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
158 grid%g_u_2 = grid%xa%u
159 grid%g_v_2 = grid%xa%v
163 #include "HALO_XA_A.inc"
165 allocate ( utmp(grid%xp%ims:grid%xp%ime,grid%xp%jms:grid%xp%jme, grid%xp%kms:grid%xp%kme) )
166 allocate ( vtmp(grid%xp%ims:grid%xp%ime,grid%xp%jms:grid%xp%jme, grid%xp%kms:grid%xp%kme) )
171 ! The southern boundary (fill A-GRID boundaries)
172 ! To keep the gradient, A(0) = 2A(1)-A(2)
173 if (js == grid%xp%jds) then
174 vtmp(is:ie,js-1,ks:ke)=2.0*grid%xa%v(is:ie,js ,ks:ke) &
175 - grid%xa%v(is:ie,js+1,ks:ke)
178 ! The northern boundary
179 if (je == grid%xp%jde) then
180 vtmp(is:ie,je+1,ks:ke)=2.0*grid%xa%v(is:ie,je ,ks:ke) &
181 - grid%xa%v(is:ie,je-1,ks:ke)
184 ! The western boundary (fill A-GRID boundaries)
185 ! To keep the gradient, A(0) = 2A(1)-A(2)
186 if (is == grid%xp%ids) then
187 utmp(is-1,js:je,ks:ke)=2.0*grid%xa%u(is ,js:je,ks:ke) &
188 - grid%xa%u(is+1,js:je,ks:ke)
191 ! The eastern boundary
192 if (ie == grid%xp%ide) then
193 utmp(ie+1,js:je,ks:ke)=2.0*grid%xa%u(ie ,js:je,ks:ke) &
194 - grid%xa%u(ie-1,js:je,ks:ke)
200 grid%g_u_2(i,j,k)=0.5*(utmp(i-1,j ,k)+utmp(i,j,k))
205 grid%g_v_2(i,j,k)=0.5*(vtmp(i ,j-1,k)+vtmp(i,j,k))
218 grid%g_u_2(i,j,k)=0.5*(grid%xa%u(i-1,j,k)+grid%xa%u(i,j,k))
223 grid%g_v_2(i,j,k)=0.5*(grid%xa%v(i,j-1,k)+grid%xa%v(i,j,k))
228 ! To keep the gradient, A(N+1) = 2A(N)-A(N-1)
229 ! and on C-Grid, this will lead to C(N+1)=(A(N)+A(N+1))/2=(3A(N)-A(N-1))/2
231 ! The eastern boundary
232 grid%g_u_2(ie+1,js:je,ks:ke)=(3.0*grid%xa%u(ie,js:je,ks:ke)-grid%xa%u(ie-1,js:je,ks:ke))/2.0
234 ! The northern boundary
235 grid%g_v_2(is:ie,je+1,ks:ke)=(3.0*grid%xa%v(is:ie,je,ks:ke)-grid%xa%v(is:ie,je-1,ks:ke))/2.0
237 ! To keep the gradient, A(0) = 2A(1)-A(2)
238 ! and on C-Grid, this will lead to C(1)=(A(0)+A(1))/2=(3A(1)-A(2))/2
240 ! The western boundary
241 grid%g_u_2(is,js:je,ks:ke)=(3.0*grid%xa%u(is,js:je,ks:ke)-grid%xa%u(is+1,js:je,ks:ke))/2.0
243 ! The southern boundary
244 grid%g_v_2(is:ie,js,ks:ke)=(3.0*grid%xa%v(is:ie,js,ks:ke)-grid%xa%v(is:ie,js+1,ks:ke))/2.0
249 !---------------------------------------------------------------------------
250 ! [6.0] save OTHERinCREMENT
251 !---------------------------------------------------------------------------
256 grid%g_w_2(i,j,k)=grid%xa%w(i,j,k)
261 !if ( config_flags%mp_physics_ad == warmrain_ad ) then
262 if ( f_g_qc .and. cloud_cv_options >= 1 ) then
263 grid%g_moist(is:ie,js:je,ks:ke,p_g_qc) = grid%xa%qcw(is:ie,js:je,ks:ke)
265 if ( f_g_qr .and. cloud_cv_options >= 1 ) then
266 grid%g_moist(is:ie,js:je,ks:ke,p_g_qr) = grid%xa%qrn(is:ie,js:je,ks:ke)
269 !if ( config_flags%mp_physics_ad == icecld_ad ) then
270 if ( f_g_qi .and. cloud_cv_options >= 2 ) then
271 grid%g_moist(is:ie,js:je,ks:ke,p_g_qi) = grid%xa%qci(is:ie,js:je,ks:ke)
273 if ( f_g_qs .and. cloud_cv_options >= 2 ) then
274 grid%g_moist(is:ie,js:je,ks:ke,p_g_qs) = grid%xa%qsn(is:ie,js:je,ks:ke)
276 if ( f_g_qg .and. cloud_cv_options >= 2 ) then
277 grid%g_moist(is:ie,js:je,ks:ke,p_g_qg) = grid%xa%qgr(is:ie,js:je,ks:ke)
282 call da_transfer_wrftl_lbc_t0 ( grid )
284 !---------------------------------------------------------------------------
286 !---------------------------------------------------------------------------
288 call kj_swap (grid%g_u_2, model_grid%g_u_2, &
289 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
290 call kj_swap (grid%g_v_2, model_grid%g_v_2, &
291 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
292 call kj_swap (grid%g_w_2, model_grid%g_w_2, &
293 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
294 call kj_swap (grid%g_t_2, model_grid%g_t_2, &
295 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
296 call kj_swap (grid%g_ph_2, model_grid%g_ph_2, &
297 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
298 call kj_swap (grid%g_p, model_grid%g_p, &
299 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
300 model_grid%g_mu_2 = grid%g_mu_2
301 model_grid%g_rainnc = 0.0
302 model_grid%g_rainncv = 0.0
303 model_grid%g_rainc = 0.0
304 model_grid%g_raincv = 0.0
306 do i = PARAM_FIRST_SCALAR, num_g_moist
307 call kj_swap (grid%g_moist(:,:,:,i), model_grid%g_moist(:,:,:,i), &
308 grid%xp%ims, grid%xp%ime, grid%xp%jms, grid%xp%jme, grid%xp%kms, grid%xp%kme)
311 if ( .not. trajectory_io .or. var4d_detail_out ) &
312 call med_hist_out ( grid , AUXHIST8_ALARM , config_flags )
314 if (trace_use) call da_trace_exit("da_transfer_xatowrftl")
317 end subroutine da_transfer_xatowrftl