1 subroutine da_uvprho_to_w_adj(grid)
3 !---------------------------------------------------------------------------
4 ! Purpose: Calculates vertical velocity increments from Richardson's Eq.
6 ! Method: Richardson's Eq., which
7 ! combines continuity Eq., thermodynamic Eq. and hrdrostatic Eq.
8 !---------------------------------------------------------------------------
12 type (domain), intent(inout) :: grid
14 integer :: is, ie ! 1st dim. end points.
15 integer :: js, je ! 2nd dim. end points.
19 real, dimension(ims:ime,jms:jme,kms:kme) :: URHO, VRHO
20 real, dimension(ims:ime,jms:jme,kms:kme) :: DIV, WZ
23 if (trace_use) call da_trace_entry("da_uvprho_to_w_adj")
25 ! initialize to zero for some variables because of the adjoint requirements.
33 ! integration to calculate the vertical velocity
38 grid%xa%w(I,J,K+1)=grid%xa%w(I,J,K+1)+grid%xa%w(I,J,K)
39 WZ(I,J,K)=grid%xa%w(I,J,K)*(grid%xb%hf(I,J,K)-grid%xb%hf(I,J,K+1))
42 grid%xa%w(I,J,kte+1)=0.0
46 call da_w_adjustment_adj(grid%xb,WZ)
50 WZ(its:ite,jts:jte,kts:kte)=WZ(its:ite,jts:jte,kts:kte)/(GAMMA*grid%xb%p(its:ite,jts:jte,kts:kte))
52 ! Term 4: Derivative of basic vertical velocity with respect to z.
57 grid%xa%p(I,J,K)=grid%xa%p(I,J,K)-WZ(I,J,K)*GAMMA* &
58 (grid%xb%w(I,J,K+1)-grid%xb%w(I,J,K))/ &
59 (grid%xb%hf(I,J,K+1)-grid%xb%hf(I,J,K))
64 ! Term 3.2: Vertical integration of the basic mass divergence
70 DIV(I,J,K+1)=DIV(I,J,K+1)+ &
71 TERM3*GRAVITY*0.5*(grid%xb%h(I,J,K+1)-grid%xb%h(I,J,K))
72 DIV(I,J,K) =DIV(I,J,K)+ &
73 TERM3*GRAVITY*0.5*(grid%xb%h(I,J,K+1)-grid%xb%h(I,J,K))
79 call da_uv_to_divergence_adj(grid, URHO,VRHO, DIV)
81 ! Computation to check for edge of domain:
82 if (test_transforms) then
83 is = its-1; ie = ite+1; js = jts-1; je = jte+1
84 if (its == ids) is = ids; if (ite == ide) ie = ide
85 if (jts == jds) js = jds; if (jte == jde) je = jde
93 grid%xa%rho(is:ie,js:je,kts:kte)=grid%xa%rho(is:ie,js:je,kts:kte)+VRHO(is:ie,js:je,kts:kte)*grid%xb%v(is:ie,js:je,kts:kte)
94 grid%xa%rho(is:ie,js:je,kts:kte)=grid%xa%rho(is:ie,js:je,kts:kte)+URHO(is:ie,js:je,kts:kte)*grid%xb%u(is:ie,js:je,kts:kte)
99 ! Term 3.1: Vertical integration of the perturbed mass divergence
104 TERM3=TERM3+WZ(I,J,K)
105 DIV(I,J,K+1)=DIV(I,J,K+1)+ &
106 TERM3*GRAVITY*0.5*(grid%xb%h(I,J,K+1)-grid%xb%h(I,J,K))
107 DIV(I,J,K) =DIV(I,J,K)+ &
108 TERM3*GRAVITY*0.5*(grid%xb%h(I,J,K+1)-grid%xb%h(I,J,K))
114 call da_uv_to_divergence_adj(grid, URHO,VRHO, DIV)
116 grid%xa%v(is:ie,js:je,kts:kte)=grid%xa%v(is:ie,js:je,kts:kte)+VRHO(is:ie,js:je,kts:kte)*grid%xb%rho(is:ie,js:je,kts:kte)
117 grid%xa%u(is:ie,js:je,kts:kte)=grid%xa%u(is:ie,js:je,kts:kte)+URHO(is:ie,js:je,kts:kte)*grid%xb%rho(is:ie,js:je,kts:kte)
122 ! Term 2.2: Divergence term from basic wind
124 call da_uv_to_divergence(grid%xb, grid%xb%u,grid%xb%v, DIV)
126 grid%xa%p(its:ite,jts:jte,kts:kte)=grid%xa%p(its:ite,jts:jte,kts:kte)-WZ(its:ite,jts:jte,kts:kte)*GAMMA*DIV(its:ite,jts:jte,kts:kte)
128 ! Term 2.1: Divergence term from perturbed wind
130 DIV(its:ite,jts:jte,kts:kte)=-WZ(its:ite,jts:jte,kts:kte)*GAMMA*grid%xb%p(its:ite,jts:jte,kts:kte) ! DIV redefined
132 call da_uv_to_divergence_adj(grid, grid%xa%u,grid%xa%v, DIV)
134 ! Computation to check for edge of domain:
139 if (its == ids) is = ids+1
140 if (ite == ide) ie = ide-1
141 if (jts == jds) js = jds+1
142 if (jte == jde) je = jde-1
144 ! Term 1.2: Basic pressure advection along the perturbed wind
150 WZ(I,J-1,K)=WZ(I,J-1,K)+WZ(I,J,K)
159 WZ(I,J+1,K)=WZ(I,J+1,K)+WZ(I,J,K)
168 WZ(I-1,J,K)=WZ(I-1,J,K)+WZ(I,J,K)
177 WZ(I+1,J,K)=WZ(I+1,J,K)+WZ(I,J,K)
185 grid%xa%v(I,J,K)=grid%xa%v(I,J,K)-WZ(I,J,K)* &
186 (grid%xb%p(I,J+1,K)-grid%xb%p(I,J-1,K))*grid%xb%coefy(I,J)
187 grid%xa%u(I,J,K)=grid%xa%u(I,J,K)-WZ(I,J,K)* &
188 (grid%xb%p(I+1,J,K)-grid%xb%p(I-1,J,K))*grid%xb%coefx(I,J)
193 !-------------------------------------------------------------------------
194 ! Computation to check for edge of domain:
195 ! This is only for adjoint, as we have to cross the processor boundary
196 ! to get the contribution.
203 grid%xp%v1z(its:ite, jts:jte, kts:kte) = wz(its:ite, jts:jte, kts:kte)
206 #include "HALO_BAL_EQN_ADJ.inc"
212 wz(is, js:je, kts:kte) = grid%xp%v1z(is, js:je, kts:kte)
218 wz(ie, js:je, kts:kte) = grid%xp%v1z(ie, js:je, kts:kte)
224 wz(is:ie, js, kts:kte) = grid%xp%v1z(is:ie, js, kts:kte)
230 wz(is:ie, je, kts:kte) = grid%xp%v1z(is:ie, je, kts:kte)
233 ! Term 1.1: Perturbed pressure advection along the basic wind
238 grid%xa%p(I,J+1,K)=grid%xa%p(I,J+1,K)-WZ(I,J,K)*grid%xb%v(I,J,K)*grid%xb%coefy(I,J)
239 grid%xa%p(I,J-1,K)=grid%xa%p(I,J-1,K)+WZ(I,J,K)*grid%xb%v(I,J,K)*grid%xb%coefy(I,J)
240 grid%xa%p(I+1,J,K)=grid%xa%p(I+1,J,K)-WZ(I,J,K)*grid%xb%u(I,J,K)*grid%xb%coefx(I,J)
241 grid%xa%p(I-1,J,K)=grid%xa%p(I-1,J,K)+WZ(I,J,K)*grid%xb%u(I,J,K)*grid%xb%coefx(I,J)
248 if (trace_use) call da_trace_exit("da_uvprho_to_w_adj")
250 end subroutine da_uvprho_to_w_adj