1 subroutine da_transform_vptox(grid, vp, be, ep)
2 !subroutine da_transform_vptox(grid, vp, be, ep, nobwin)
4 !-----------------------------------------------------------------------
5 ! Purpose: Physical transform of analysis increment variables.
6 ! Updated for Analysis on Arakawa-C grid
7 ! Author: Syed RH Rizvi, MMM/ESSL/NCAR, Date: 10/22/2008
10 ! Implementation of multi-variate BE for cv_options=6
11 ! Syed RH Rizvi, MMM/NESL/NCAR, Date: 02/01/2010
12 !------------------------
13 ! Zhiquan (Jake) Liu, NCAR/MMM, 2015-09
14 ! re-order transforms to avoid local chi_u and store full variables in vp
15 ! full vp will be written out and used as input of inverse U transform
16 ! for multi-resolution incremental 4DVAR
17 ! order: v4 (rh), v3 (T), v5 (Ps), v2 (Chi_u -> Chi)
18 !-----------------------------------------------------------------------
22 type (domain), intent(inout) :: grid
24 type (vp_type), intent(inout) :: vp ! CV on grid structure.
25 type (be_type), intent(in), optional :: be ! Background errors.
26 type (ep_type), intent(in), optional :: ep ! Ensemble perturbations.
27 ! integer, intent(in), optional :: nobwin
29 integer :: i, k, j, k1, ij ! Loop counters.
30 !real, allocatable :: chi_u(:,:,:) ! Unbalanced chi
32 if (trace_use) call da_trace_entry("da_transform_vptox")
34 !---------------------------------------------------------------------------
35 ! [1] Add flow-dependent increments in control variable space (vp):
36 !---------------------------------------------------------------------------
38 if (be % ne > 0 .and. alphacv_method == alphacv_method_vp) then
39 call da_add_flow_dependence_vp(be % ne, ep, vp, its,ite, jts,jte, kts,kte)
42 !--------------------------------------------------------------------------
43 ! [2] Impose statistical balance constraints:
44 !--------------------------------------------------------------------------
46 if ( jb_factor > 0.0 ) then
48 !$OMP PRIVATE ( ij, k1, k, j, i)
49 do ij = 1 , grid%num_tiles
51 ! 2.1 Pseudo rh_u to Pseudo rh (only for cv6)
52 ! do moisture first to avoid local (chi_u,t_t,Ps_u) variables
53 !--------------------------------------------------------------
54 if ( cv_options == 6 ) then
57 do j = grid%j_start(ij), grid%j_end(ij)
59 vp%v4(i,j,k1) = vp%v4(i,j,k1) + be%reg_psi_rh(j,k1,k)*vp%v1(i,j,k) + &
60 be%reg_chi_u_rh(j,k1,k)*vp%v2(i,j,k) + be%reg_t_u_rh(j,k1,k)*vp%v3(i,j,k)
67 do j = grid%j_start(ij), grid%j_end(ij)
69 vp%v4(i,j,k) = vp%v4(i,j,k) + be%reg_ps_u_rh(j,k)*vp%v5(i,j,1)
75 ! 2.2 t_u --> t, do this before chi_u --> chi
76 !----------------------------------------------
77 if (cv_options /= 7) then
80 do j = grid%j_start(ij), grid%j_end(ij)
82 vp%v3(i,j,k) = vp%v3(i,j,k) + be%reg_psi_t(j,k,k1)*vp%v1(i,j,k1)
89 if ( cv_options == 6 ) then
92 do j = grid%j_start(ij), grid%j_end(ij)
94 vp%v3(i,j,k) = vp%v3(i,j,k) + be%reg_chi_u_t(j,k,k1)*vp%v2(i,j,k1)
102 do j = grid%j_start(ij), grid%j_end(ij)
104 grid%xa%t(i,j,k) = vp%v3(i,j,k)
109 ! 2.3 Ps_u --> Ps, do this before chi_u --> chi
110 !-------------------------------------------------
111 if (cv_options /= 7) then
113 do j = grid%j_start(ij), grid%j_end(ij)
115 vp%v5(i,j,1) = vp%v5(i,j,1) + be%reg_psi_ps(j,k)*vp%v1(i,j,k)
121 if ( cv_options == 6 ) then
123 do j = grid%j_start(ij), grid%j_end(ij)
125 vp%v5(i,j,1) = vp%v5(i,j,1) + be%reg_chi_u_ps(j,k)*vp%v2(i,j,k)
131 do j = grid%j_start(ij), grid%j_end(ij)
133 grid%xa%psfc(i,j) = vp%v5(i,j,1)
137 ! 2.4 Chi_u --> Chi, do this last
138 !-----------------------------------
139 if (cv_options /= 7) then
141 do j = grid%j_start(ij), grid%j_end(ij)
143 vp%v2(i,j,k) = vp%v2(i,j,k) + be%reg_psi_chi(j,k)* vp%v1(i,j,k)
149 ! if ( cv_options == 6 ) deallocate (chi_u )
152 !$OMP END PARALLEL DO
153 !--------------------------------------------------------------------------
154 ! [3] Transform to model variable space:
155 !--------------------------------------------------------------------------
158 if ((fg_format==fg_format_wrf_arw_regional .or. &
159 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
164 if ((fg_format==fg_format_wrf_arw_regional .or. &
165 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
172 #include "HALO_PSICHI_UV.inc"
176 if ((fg_format==fg_format_wrf_arw_regional .or. &
177 fg_format==fg_format_wrf_arw_global ) .and. ide == ipe ) then
182 if ((fg_format==fg_format_wrf_arw_regional .or. &
183 fg_format==fg_format_wrf_arw_global ) .and. jde == jpe ) then
189 ! Psi and chi to u and v:
190 if ( cv_options == 5 .or. cv_options == 6 ) then
191 call da_psichi_to_uv(vp % v1, vp % v2, grid%xb % coefx, &
192 grid%xb % coefy , grid%xa % u, grid%xa % v)
193 else if ( cv_options == 7 ) then
198 if ( cloud_cv_options /= 1 ) then
199 ! Pseudo RH --> Water vapor mixing ratio:
201 !$OMP PRIVATE ( ij, i, j, k )
202 do ij = 1 , grid%num_tiles
204 do j = grid%j_start(ij), grid%j_end(ij)
206 grid%xa % q(i,j,k) = vp%v4(i,j,k) * grid%xb%qs(i,j,k)
211 !$OMP END PARALLEL DO
212 else ! cloud_cv_options=1
213 ! Pseudo RH --> Total water mixing ratio:
215 !$OMP PRIVATE ( ij, i, j, k )
216 do ij = 1 , grid%num_tiles
218 do j = grid%j_start(ij), grid%j_end(ij)
220 grid%xa % qt(i,j,k) = vp%v4(i,j,k) * grid%xb%qs(i,j,k)
225 !$OMP END PARALLEL DO
228 if ( cloud_cv_options >= 2 ) then
231 !$OMP PRIVATE ( ij, i, j, k )
232 do ij = 1 , grid%num_tiles
234 do j = grid%j_start(ij), grid%j_end(ij)
236 grid%xa % qcw(i,j,k) = vp%v6(i,j,k)
241 !$OMP END PARALLEL DO
244 !$OMP PRIVATE ( ij, i, j, k )
245 do ij = 1 , grid%num_tiles
247 do j = grid%j_start(ij), grid%j_end(ij)
249 grid%xa % qrn(i,j,k) = vp%v7(i,j,k)
254 !$OMP END PARALLEL DO
257 !$OMP PRIVATE ( ij, i, j, k )
258 do ij = 1 , grid%num_tiles
260 do j = grid%j_start(ij), grid%j_end(ij)
262 grid%xa % qci(i,j,k) = vp%v8(i,j,k)
267 !$OMP END PARALLEL DO
270 !$OMP PRIVATE ( ij, i, j, k )
271 do ij = 1 , grid%num_tiles
273 do j = grid%j_start(ij), grid%j_end(ij)
275 grid%xa % qsn(i,j,k) = vp%v9(i,j,k)
280 !$OMP END PARALLEL DO
283 !$OMP PRIVATE ( ij, i, j, k )
284 do ij = 1 , grid%num_tiles
286 do j = grid%j_start(ij), grid%j_end(ij)
288 grid%xa % qgr(i,j,k) = vp%v10(i,j,k)
293 !$OMP END PARALLEL DO
294 end if ! cloud_cv_options>=2
299 !$OMP PRIVATE ( ij, i, j, k )
300 do ij = 1 , grid%num_tiles
302 do j = grid%j_start(ij), grid%j_end(ij)
304 grid%xa % w(i,j,k) = vp%v11(i,j,k)
309 !$OMP END PARALLEL DO
311 end if ! jb_factor > 0.0
313 ! !---------------------------------------------------------------------------
314 ! ! [4] Add flow-dependent increments in model space (grid%xa):
315 ! !---------------------------------------------------------------------------
317 !! if (be % ne > 0 .and. alphacv_method == alphacv_method_xa) then
318 !! call da_add_flow_dependence_xa(grid, be % ne, ep, vp)
320 ! if (be % ne > 0 .and. alphacv_method == alphacv_method_xa) then
321 ! if ( anal_type_hybrid_dual_res ) then
322 ! if( present(nobwin) ) then
323 ! call da_add_flow_dependence_xa_dual_res(grid, be % ne, ep, vp, nobwin)
325 ! call da_add_flow_dependence_xa_dual_res(grid, be % ne, ep, vp)
328 ! if( present(nobwin) ) then
329 ! call da_add_flow_dependence_xa(grid, be % ne, ep, vp, nobwin)
331 ! call da_add_flow_dependence_xa(grid, be % ne, ep, vp)
336 if (trace_use) call da_trace_exit("da_transform_vptox")
338 end subroutine da_transform_vptox