1 SUBROUTINE da_transform_bal( vp, be, grid )
5 TYPE (vp_type), INTENT(INOUT) :: vp ! work array.
6 TYPE (be_type), INTENT(IN) :: be ! Background errors.
7 type (domain) , intent(inout) :: grid ! Domain variables.
9 INTEGER :: i, j, k, kk, ij ! Loop counters.
11 !-------------------------------------------------------------------
13 !-------------------------------------------------------------------
15 ! linear balance btw psi and t-b, Psfc_b and chi_b
16 ! [3.1] Calculate t_b from psi
19 !$OMP PRIVATE (i, j, k, ij)
20 DO ij = 1, grid%num_tiles
22 DO j = grid%j_start(ij), grid%j_end(ij)
24 grid%xa%t(i,j,k)=vp%v3(i,j,k)
32 !$OMP PRIVATE (i, j, k, kk, ij)
33 DO ij = 1, grid%num_tiles
36 DO j = grid%j_start(ij), grid%j_end(ij)
38 grid%xa%t(i,j,k) = grid%xa%t(i,j,k) + &
39 be%agvz(i,j,k,kk) * vp%v1(i,j,kk)
47 ! [3.2] Calculate chi_b from psi
50 !$OMP PRIVATE (i, j, k, ij)
51 DO ij = 1, grid%num_tiles
53 DO j = grid%j_start(ij), grid%j_end(ij)
55 vp%v2(i,j,k) = vp%v2(i,j,k) + &
56 be%bvz(i,j,k) * vp%v1(i,j,k)
63 ! [3.3] Calculate Psfc_b from psi
66 !$OMP PRIVATE (i, j, ij)
67 DO ij = 1, grid%num_tiles
68 DO j = grid%j_start(ij), grid%j_end(ij)
70 grid%xa%psfc(i,j)=vp%v5(i,j,1)
78 !$OMP PRIVATE (i, j, k, ij)
79 DO ij = 1, grid%num_tiles
81 DO j = grid%j_start(ij), grid%j_end(ij)
83 grid%xa%psfc(i,j) = grid%xa%psfc(i,j) + &
84 be%wgvz(i,j,k) * vp%v1(i,j,k)
91 !--convert from delt.ln(ps) to delt.ps
93 !$OMP PRIVATE (i, j, ij)
94 DO ij = 1, grid%num_tiles
95 DO j = grid%j_start(ij), grid%j_end(ij)
97 grid%xa%psfc(i,j) = grid%xa%psfc(i,j) * grid%xb%psfc(i,j)
101 !$OMP END PARALLEL DO
103 ! [3.4] Transform psi and chi to u and v:
105 ! Communicate halo region.
107 #include "HALO_PSICHI_UV.inc"
110 call da_psichi_to_uv( vp%v1, vp%v2, grid%xb%coefx, &
111 grid%xb%coefy, grid%xa%u, grid%xa%v )
113 ! [3.5] treat humidity
116 IF ( cv_options == 3 ) THEN
118 !$OMP PRIVATE (i, j, k, ij)
119 DO ij = 1, grid%num_tiles
121 DO j = grid%j_start(ij), grid%j_end(ij)
123 grid%xa%q(i,j,k) = vp%v4(i,j,k) * grid%xb%qs(i,j,k)
128 !$OMP END PARALLEL DO
129 ELSE IF ( cv_options_hum == 1 ) THEN
131 grid%xa%q(its:ite,jts:jte,kts:kte) = vp%v4(its:ite,jts:jte,kts:kte)
133 ELSE IF ( cv_options_hum == 2 ) THEN
135 grid%xa%rh(its:ite,jts:jte,kts:kte) = vp%v4(its:ite,jts:jte,kts:kte)
137 CALL DA_TPRH_To_Q_Lin( grid )
141 END SUBROUTINE da_transform_bal