1 ! Generated by TAPENADE (INRIA, Tropics team)
2 ! Tapenade 3.7 (r4786) - 21 Feb 2013 15:53
4 ! Differentiation of surface_drag in reverse (adjoint) mode (with options r8):
5 ! gradient of useful results: v_phy rublten z rvblten u_phy
6 ! with respect to varying inputs: v_phy rublten z rvblten u_phy
7 !-------------------------------------------------------------------
8 !WRF:MODEL_LAYER:PHYSICS
9 MODULE a_module_bl_surface_drag
11 SUBROUTINE SURFACE_DRAG_B(rublten, rubltenb, rvblten, rvbltenb, u_phy, &
12 & u_phyb, v_phy, v_phyb, xland, z, zb, ht, kpbl2d, ids, ide, jds, jde, &
13 & kds, kde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte)
15 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde, ims, ime, jms, &
16 & jme, kms, kme, its, ite, jts, jte, kts, kte
17 INTEGER, DIMENSION(ims:ime, jms:jme), INTENT(OUT) :: kpbl2d
18 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: rublten, &
20 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: rubltenb
21 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: u_phy, v_phy&
23 REAL, DIMENSION(ims:ime, kms:kme, jms:jme) :: u_phyb, v_phyb, zb
24 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: xland, ht
26 REAL :: v0, tao_xz, tao_yz, cd, zh, zwt
27 REAL :: v0b, tao_xzb, tao_yzb, cdb, zhb, zwtb
28 INTEGER :: i, j, i_start, i_end, i_endu, j_start, j_end, j_endv, k
30 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: rvbltenb
38 !-----------------------------------------------------------------------
40 IF (ite .GT. ide - 1) THEN
47 IF (jte .GT. jde - 1) THEN
56 v0 = SQRT(u_phy(i, kts, j)**2 + v_phy(i, kts, j)**2)
57 IF (xland(i, j) - xland(i-1, j) .GE. 0.) THEN
58 abs0 = xland(i, j) - xland(i-1, j)
60 abs0 = -(xland(i, j)-xland(i-1, j))
62 IF (abs0 .LT. 1.0e-10) THEN
63 IF (xland(i, j) .LT. 1.5) THEN
72 IF (cd .LT. 1.e-4*v0) THEN
79 IF (cd .GT. 0.003) THEN
93 CALL PUSHREAL8(tao_xz)
94 tao_xz = cd*v0*u_phy(i, kts, j)
96 zh = z(i, k, j) - ht(i, j)
97 IF (zh .LT. 1000.) THEN
100 CALL PUSHCONTROL1B(0)
109 v0 = SQRT(u_phy(i, kts, j)**2 + v_phy(i, kts, j)**2)
110 IF (xland(i, j) - xland(i, j-1) .GE. 0.) THEN
111 abs1 = xland(i, j) - xland(i, j-1)
113 abs1 = -(xland(i, j)-xland(i, j-1))
115 IF (abs1 .LT. 1.0e-10) THEN
116 IF (xland(i, j) .LT. 1.5) THEN
120 CALL PUSHCONTROL2B(0)
125 IF (cd .LT. 1.e-4*v0) THEN
127 CALL PUSHCONTROL1B(0)
129 CALL PUSHCONTROL1B(1)
132 IF (cd .GT. 0.003) THEN
134 CALL PUSHCONTROL2B(3)
136 CALL PUSHCONTROL2B(2)
144 CALL PUSHCONTROL2B(1)
146 CALL PUSHREAL8(tao_yz)
147 tao_yz = cd*v0*v_phy(i, kts, j)
149 zh = z(i, k, j) - ht(i, j)
150 IF (zh .LT. 1000.) THEN
151 CALL PUSHCONTROL1B(1)
153 CALL PUSHCONTROL1B(0)
158 DO j=j_endv,j_start,-1
159 DO i=i_end,i_start,-1
162 CALL POPCONTROL1B(branch)
163 IF (branch .EQ. 0) THEN
166 zh = z(i, k, j) - ht(i, j)
167 zwt = 2.*(1000.-zh)/1000.
168 zwtb = -(tao_yz*0.5*rvbltenb(i, k, j)/1000.)
169 tao_yzb = tao_yzb - 0.5*zwt*rvbltenb(i, k, j)/1000.
170 zhb = -(2.*zwtb/1000.)
172 zb(i, k, j) = zb(i, k, j) + zhb
174 CALL POPREAL8(tao_yz)
175 tempb2 = v_phy(i, kts, j)*tao_yzb
178 v_phyb(i, kts, j) = v_phyb(i, kts, j) + cd*v0*tao_yzb
179 CALL POPCONTROL2B(branch)
180 IF (branch .LT. 2) THEN
181 IF (branch .EQ. 0) THEN
187 IF (branch .NE. 2) cdb = 0.0_8
188 CALL POPCONTROL1B(branch)
189 IF (branch .EQ. 0) v0b = v0b + 1.e-4*cdb
193 IF (u_phy(i, kts, j)**2 + v_phy(i, kts, j)**2 .EQ. 0.0_8) THEN
196 tempb1 = v0b/(2.0*SQRT(u_phy(i, kts, j)**2+v_phy(i, kts, j)**2))
198 u_phyb(i, kts, j) = u_phyb(i, kts, j) + 2*u_phy(i, kts, j)*tempb1
199 v_phyb(i, kts, j) = v_phyb(i, kts, j) + 2*v_phy(i, kts, j)*tempb1
202 DO j=j_end,j_start,-1
203 DO i=i_endu,i_start,-1
206 CALL POPCONTROL1B(branch)
207 IF (branch .EQ. 0) THEN
210 zh = z(i, k, j) - ht(i, j)
211 zwt = 2.*(1000.-zh)/1000.
212 zwtb = -(tao_xz*0.5*rubltenb(i, k, j)/1000.)
213 tao_xzb = tao_xzb - 0.5*zwt*rubltenb(i, k, j)/1000.
214 zhb = -(2.*zwtb/1000.)
216 zb(i, k, j) = zb(i, k, j) + zhb
218 CALL POPREAL8(tao_xz)
219 tempb0 = u_phy(i, kts, j)*tao_xzb
222 u_phyb(i, kts, j) = u_phyb(i, kts, j) + cd*v0*tao_xzb
223 CALL POPCONTROL2B(branch)
224 IF (branch .LT. 2) THEN
225 IF (branch .EQ. 0) THEN
231 IF (branch .NE. 2) cdb = 0.0_8
232 CALL POPCONTROL1B(branch)
233 IF (branch .EQ. 0) v0b = v0b + 1.e-4*cdb
237 IF (u_phy(i, kts, j)**2 + v_phy(i, kts, j)**2 .EQ. 0.0_8) THEN
240 tempb = v0b/(2.0*SQRT(u_phy(i, kts, j)**2+v_phy(i, kts, j)**2))
242 u_phyb(i, kts, j) = u_phyb(i, kts, j) + 2*u_phy(i, kts, j)*tempb
243 v_phyb(i, kts, j) = v_phyb(i, kts, j) + 2*v_phy(i, kts, j)*tempb
246 END SUBROUTINE SURFACE_DRAG_B
248 ! Generated by TAPENADE (INRIA, Tropics team)
249 ! Tapenade 3.6 (r4343) - 10 Feb 2012 10:52
251 ! Differentiation of surface_drag_init in reverse (adjoint) mode:
252 ! gradient of useful results: rublten rqvblten rvblten rthblten
253 ! with respect to varying inputs: rublten rqvblten rvblten rthblten
254 SUBROUTINE SURFACE_DRAG_INIT_B(rublten, rubltenb, rvblten, rvbltenb, &
255 & rthblten, rthbltenb, rqvblten, rqvbltenb, restart, ids, ide, jds, jde&
256 & , kds, kde, ims, ime, jms, jme, kms, kme, its, ite, jts, jte, kts, kte&
259 !-------------------------------------------------------------------
260 LOGICAL, INTENT(IN) :: restart
261 INTEGER, INTENT(IN) :: ids, ide, jds, jde, kds, kde, ims, ime, jms, &
262 & jme, kms, kme, its, ite, jts, jte, kts, kte
263 REAL, DIMENSION(ims:ime, kms:kme, jms:jme) :: rublten, rvblten, &
265 REAL, DIMENSION(ims:ime, kms:kme, jms:jme) :: rubltenb, rvbltenb, &
266 & rthbltenb, rqvbltenb
267 INTEGER :: i, j, k, itf, jtf, ktf
269 IF (jte .GT. jde - 1) THEN
274 IF (kte .GT. kde - 1) THEN
279 IF (ite .GT. ide - 1) THEN
284 IF (.NOT.restart) THEN
288 rqvbltenb(i, k, j) = 0.0
289 rthbltenb(i, k, j) = 0.0
290 rvbltenb(i, k, j) = 0.0
291 rubltenb(i, k, j) = 0.0
296 END SUBROUTINE SURFACE_DRAG_INIT_B
298 END MODULE a_module_bl_surface_drag