1 subroutine da_transfer_xatowrf_nmm_regional(grid)
3 !---------------------------------------------------------------------------
4 ! Purpose: Convert analysis increments into WRF-NMM increments
5 ! Writes analysis increments
7 ! Author : Syed RH Rizvi, MMM/NCAR
9 !---------------------------------------------------------------------------
13 type(domain), intent(inout) :: grid
19 ! arrays to hold wrf increments on the c-grid
21 real, dimension(ims:ime,jms:jme, &
23 u_cgrid, v_cgrid, q_cgrid, ph_cgrid
25 real, dimension(ims:ime,jms:jme) :: mu_cgrid
28 if (trace_use) call da_trace_entry("da_transfer_xatowrf_nmm_regional")
31 ! Adjust grid%xa%q to makte grid%xb%q + grid%xa%q > 0.0
33 if (check_rh == check_rh_tpw) then
34 call da_check_rh(grid)
35 else if (check_rh == check_rh_simple) then
36 call da_check_rh_simple(grid)
40 if (print_detail_xa) then
41 write(unit=stdout, fmt='(a, e24.12)') &
42 'sum(abs(grid%xa%u(its:ite,jts:jte,kts:kte)))=', &
43 sum(abs(grid%xa%u(its:ite,jts:jte,kts:kte))), &
44 'sum(abs(grid%xa%v(its:ite,jts:jte,kts:kte)))=', &
45 sum(abs(grid%xa%v(its:ite,jts:jte,kts:kte))), &
46 'sum(abs(grid%xa%t(its:ite,jts:jte,kts:kte)))=', &
47 sum(abs(grid%xa%t(its:ite,jts:jte,kts:kte))), &
48 'sum(abs(grid%xa%p(its:ite,jts:jte,kts:kte)))=', &
49 sum(abs(grid%xa%p(its:ite,jts:jte,kts:kte))), &
50 'sum(abs(grid%xb%t(its:ite,jts:jte,kts:kte)))=', &
51 sum(abs(grid%xb%t(its:ite,jts:jte,kts:kte))), &
52 'sum(abs(grid%xb%p(its:ite,jts:jte,kts:kte)))=', &
53 sum(abs(grid%xb%p(its:ite,jts:jte,kts:kte))), &
54 'sum(abs(grid%t_2 (its:ite,jts:jte,kts:kte)))=', &
55 sum(abs(grid%t_2 (its:ite,jts:jte,kts:kte)))
58 write(unit=stdout, fmt='(2(2x, a, e20.12))') &
59 'maxval(grid%xa%u(its:ite,jts:jte,kts:kte))=', &
60 maxval(grid%xa%u(its:ite,jts:jte,kts:kte)), &
61 'minval(grid%xa%u(its:ite,jts:jte,kts:kte))=', &
62 minval(grid%xa%u(its:ite,jts:jte,kts:kte)), &
63 'maxval(grid%xa%v(its:ite,jts:jte,kts:kte))=', &
64 maxval(grid%xa%v(its:ite,jts:jte,kts:kte)), &
65 'minval(grid%xa%v(its:ite,jts:jte,kts:kte))=', &
66 minval(grid%xa%v(its:ite,jts:jte,kts:kte)), &
67 'maxval(grid%xa%t(its:ite,jts:jte,kts:kte))=', &
68 maxval(grid%xa%t(its:ite,jts:jte,kts:kte)), &
69 'minval(grid%xa%t(its:ite,jts:jte,kts:kte))=', &
70 minval(grid%xa%t(its:ite,jts:jte,kts:kte)), &
71 'maxval(grid%xa%q(its:ite,jts:jte,kts:kte))=', &
72 maxval(grid%xa%q(its:ite,jts:jte,kts:kte)), &
73 'minval(grid%xa%q(its:ite,jts:jte,kts:kte))=', &
74 minval(grid%xa%q(its:ite,jts:jte,kts:kte)), &
75 'maxval(grid%xa%p(its:ite,jts:jte,kts:kte))=', &
76 maxval(grid%xa%p(its:ite,jts:jte,kts:kte)), &
77 'minval(grid%xa%p(its:ite,jts:jte,kts:kte))=', &
78 minval(grid%xa%p(its:ite,jts:jte,kts:kte)), &
79 'maxval(grid%xa%psfc(its:ite,jts:jte)) =', &
80 maxval(grid%xa%psfc(its:ite,jts:jte)), &
81 'minval(grid%xa%psfc(its:ite,jts:jte)) =', &
82 minval(grid%xa%psfc(its:ite,jts:jte))
86 ! CONVERT FROM A-GRID TO C-GRID
88 !TBH: NOTE that grid%xp%halo_id3 = HALO_PSICHI_UV_ADJ which its currently defined
89 !TBH: in the Regitstry as "dyn_em 24:grid%xa%u,grid%xa%v,grid%xa%psfc". Clearly it its not
90 !TBH: necessary to update halos in grid%xa%psfc here! Also, 24-point stencil its
91 !TBH: too thick, 9-point should suffice. Apparently, grid%xp%halo_id3 its used
92 !TBH: in many places! Thits needs to be fixed.
95 #include "HALO_PSICHI_UV_ADJ.inc"
100 ! The southern boundary
105 grid%xa%v(its:ite,jts-1,kts:kte)=2.0*grid%xa%v(its:ite,jts ,kts:kte) &
106 - grid%xa%v(its:ite,jts+1,kts:kte)
110 ! The northern boundary
113 grid%xa%v(its:ite,jte+1,kts:kte)=2.0*grid%xa%v(its:ite,jte ,kts:kte) &
114 - grid%xa%v(its:ite,jte-1,kts:kte)
118 ! The western boundary
120 grid%xa%u(its-1,jts:jte,kts:kte)=2.0*grid%xa%u(its ,jts:jte,kts:kte) &
121 - grid%xa%u(its+1,jts:jte,kts:kte)
124 ! The eastern boundary
126 grid%xa%u(ite+1,jts:jte,kts:kte)=2.0*grid%xa%u(ite ,jts:jte,kts:kte) &
127 - grid%xa%u(ite-1,jts:jte,kts:kte)
130 ! ========================
131 ! Write out the increment:
132 ! ========================
134 call da_write_increments_for_wrf_nmm_regional (grid)
139 u_cgrid(i,j,k)=0.5*(grid%xa%u(i-1,j ,k)+grid%xa%u(i,j,k))
140 v_cgrid(i,j,k)=0.5*(grid%xa%v(i ,j-1,k)+grid%xa%v(i,j,k))
145 !------------------------------------------------------------------------
146 ! Zero out the unused info
147 !------------------------------------------------------------------------
149 ! The northern boundary
150 if (jte == jde) u_cgrid(its:ite+1,jte+1,kts:kte)=0.0
152 ! The eastern boundary
153 if (ite == ide) v_cgrid(ite+1,jts:jte+1,kts:kte)=0.0
155 !---------------------------------------------------------------------------
156 ! Add increment to the original guess and update "grid"
157 !---------------------------------------------------------------------------
163 grid%u_2(i,j,k) = grid%u_2(i,j,k) + u_cgrid(i,j,k)
164 grid%v_2(i,j,k) = grid%v_2(i,j,k) + v_cgrid(i,j,k)
166 grid%mu_2(i,j)= grid%mu_2(i,j) + grid%xa%psfc(i,j)
167 grid%w_2(i,j,k) = grid%w_2(i,j,k) + grid%xa%w(i,j,k)
168 grid%moist(i,j,k,P_QV) = grid%moist(i,j,k,P_QV) + q_cgrid(i,j,k)
169 ! makte sure qv its positive.
170 if (num_pseudo ==0 .and. grid%moist(i,j,k,P_QV) < 1.0e-6) &
171 grid%moist(i,j,k,P_QV) = 1.0e-6
173 if (size(grid%moist,dim=4) >= 4) then
174 grid%moist(i,j,k,p_qc) = grid%moist(i,j,k,p_qc) + grid%xa%qcw(i,j,k)
175 grid%moist(i,j,k,p_qr) = grid%moist(i,j,k,p_qr) + grid%xa%qrn(i,j,k)
176 if (grid%moist(i,j,k,p_qc) < 0.0) grid%moist(i,j,k,p_qc) = 0.0
177 if (grid%moist(i,j,k,p_qr) < 0.0) grid%moist(i,j,k,p_qr) = 0.0
180 if (size(grid%moist,dim=4) >= 6) then
181 grid%moist(i,j,k,p_qi) = grid%moist(i,j,k,p_qi) + grid%xa%qci(i,j,k)
182 grid%moist(i,j,k,p_qs) = grid%moist(i,j,k,p_qs) + grid%xa%qsn(i,j,k)
183 if (grid%moist(i,j,k,p_qi) < 0.0) grid%moist(i,j,k,p_qi) = 0.0
184 if (grid%moist(i,j,k,p_qs) < 0.0) grid%moist(i,j,k,p_qs) = 0.0
187 if (size(grid%moist,dim=4) >= 7) then
188 grid%moist(i,j,k,p_qg) = grid%moist(i,j,k,p_qg) + grid%xa%qgr(i,j,k)
189 if (grid%moist(i,j,k,p_qg) < 0.0) grid%moist(i,j,k,p_qg) = 0.0
195 ! The northern boundary
200 grid%v_2(i,j,k) = grid%v_2(i,j,k) + v_cgrid(i,j,k)
205 ! The eastern boundary
210 grid%u_2(i,j,k) = grid%u_2(i,j,k) + u_cgrid(i,j,k)
215 if (print_detail_xa) then
216 write(unit=stdout, fmt=*) 'simple variables:'
219 write (unit=stdout,fmt=*) ' '
223 write(unit=stdout, fmt=*) &
224 ' grid%u_2(', ide+1, ',', j, ',', k, ')=', &
227 write(unit=stdout, fmt=*) ' '
232 write(unit=stdout, fmt=*) ' '
236 write(unit=stdout, fmt=*) &
237 ' grid%v_2(', i, ',', jde+1, ',', k, ')=', &
240 write(unit=stdout, fmt=*) ' '
244 write(unit=stdout, fmt='(2(2x, a, e20.12))') &
245 'maxval(mu_cgrid(its:ite,jts:jte)) =', &
246 maxval(mu_cgrid(its:ite,jts:jte)), &
247 'minval(mu_cgrid(its:ite,jts:jte)) =', &
248 minval(mu_cgrid(its:ite,jts:jte)), &
249 'maxval(u_cgrid(its:ite,jts:jte,kts:kte)) =', &
250 maxval(u_cgrid(its:ite,jts:jte,kts:kte)), &
251 'minval(u_cgrid(its:ite,jts:jte,kts:kte)) =', &
252 minval(u_cgrid(its:ite,jts:jte,kts:kte)), &
253 'maxval(v_cgrid(its:ite,jts:jte,kts:kte)) =', &
254 maxval(v_cgrid(its:ite,jts:jte,kts:kte)), &
255 'minval(v_cgrid(its:ite,jts:jte,kts:kte)) =', &
256 minval(v_cgrid(its:ite,jts:jte,kts:kte)), &
257 'maxval(q_cgrid(its:ite,jts:jte,kts:kte)) =', &
258 maxval(q_cgrid(its:ite,jts:jte,kts:kte)), &
259 'minval(q_cgrid(its:ite,jts:jte,kts:kte)) =', &
260 minval(q_cgrid(its:ite,jts:jte,kts:kte))
263 write(unit=stdout, fmt='(a, i3)') 'k=', k
265 write(unit=stdout, fmt='(2(2x, a, e20.12))') &
266 'maxval(u_cgrid(its:ite,jts:jte,k)) =', maxval(u_cgrid(its:ite,jts:jte,k)), &
267 'minval(u_cgrid(its:ite,jts:jte,k)) =', minval(u_cgrid(its:ite,jts:jte,k)), &
268 'maxval(v_cgrid(its:ite,jts:jte,k)) =', maxval(v_cgrid(its:ite,jts:jte,k)), &
269 'minval(v_cgrid(its:ite,jts:jte,k)) =', minval(v_cgrid(its:ite,jts:jte,k)), &
270 'maxval(q_cgrid(its:ite,jts:jte,k)) =', maxval(q_cgrid(its:ite,jts:jte,k)), &
271 'minval(q_cgrid(its:ite,jts:jte,k)) =', minval(q_cgrid(its:ite,jts:jte,k))
275 if (trace_use) call da_trace_exit("da_transfer_xatowrf_nmm_regional")
277 end subroutine da_transfer_xatowrf_nmm_regional