ROMS
Loading...
Searching...
No Matches
ad_set_massflux_mod Module Reference

Functions/Subroutines

subroutine, public ad_set_massflux (ng, tile, model)
 
subroutine ad_set_massflux_tile (ng, tile, model, lbi, ubi, lbj, ubj, imins, imaxs, jmins, jmaxs, nrhs, u, v, ad_u, ad_v, hz, ad_hz, om_v, on_u, ad_huon, ad_hvom)
 

Function/Subroutine Documentation

◆ ad_set_massflux()

subroutine, public ad_set_massflux_mod::ad_set_massflux ( integer, intent(in) ng,
integer, intent(in) tile,
integer, intent(in) model )

Definition at line 30 of file ad_set_massflux.F.

31!***********************************************************************
32!
33 USE mod_param
34 USE mod_grid
35 USE mod_ocean
36 USE mod_stepping
37!
38! Imported variable declarations.
39!
40 integer, intent(in) :: ng, tile, model
41!
42! Local variable declarations.
43!
44 character (len=*), parameter :: MyFile = &
45 & __FILE__
46!
47# include "tile.h"
48!
49# ifdef PROFILE
50 CALL wclock_on (ng, model, 12, __line__, myfile)
51# endif
52 CALL ad_set_massflux_tile (ng, tile, model, &
53 & lbi, ubi, lbj, ubj, &
54 & imins, imaxs, jmins, jmaxs, &
55 & nrhs(ng), &
56 & ocean(ng) % u, &
57 & ocean(ng) % v, &
58 & ocean(ng) % ad_u, &
59 & ocean(ng) % ad_v, &
60# ifdef WEC_MELLOR
61 & ocean(ng) % u_stokes, &
62 & ocean(ng) % v_stokes, &
63 & ocean(ng) % ad_u_stokes, &
64 & ocean(ng) % ad_v_stokes, &
65# endif
66 & grid(ng) % Hz, &
67 & grid(ng) % ad_Hz, &
68 & grid(ng) % om_v, &
69 & grid(ng) % on_u, &
70 & grid(ng) % ad_Huon, &
71 & grid(ng) % ad_Hvom)
72# ifdef PROFILE
73 CALL wclock_off (ng, model, 12, __line__, myfile)
74# endif
75!
76 RETURN
type(t_grid), dimension(:), allocatable grid
Definition mod_grid.F:365
type(t_ocean), dimension(:), allocatable ocean
Definition mod_ocean.F:351
integer, dimension(:), allocatable nrhs
recursive subroutine wclock_off(ng, model, region, line, routine)
Definition timers.F:148
recursive subroutine wclock_on(ng, model, region, line, routine)
Definition timers.F:3

References ad_set_massflux_tile(), mod_grid::grid, mod_stepping::nrhs, mod_ocean::ocean, wclock_off(), and wclock_on().

Referenced by ad_main3d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ad_set_massflux_tile()

subroutine ad_set_massflux_mod::ad_set_massflux_tile ( integer, intent(in) ng,
integer, intent(in) tile,
integer, intent(in) model,
integer, intent(in) lbi,
integer, intent(in) ubi,
integer, intent(in) lbj,
integer, intent(in) ubj,
integer, intent(in) imins,
integer, intent(in) imaxs,
integer, intent(in) jmins,
integer, intent(in) jmaxs,
integer, intent(in) nrhs,
real(r8), dimension(lbi:,lbj:,:,:), intent(in) u,
real(r8), dimension(lbi:,lbj:,:,:), intent(in) v,
real(r8), dimension(lbi:,lbj:,:,:), intent(inout) ad_u,
real(r8), dimension(lbi:,lbj:,:,:), intent(inout) ad_v,
real(r8), dimension(lbi:,lbj:,:), intent(in) hz,
real(r8), dimension(lbi:,lbj:,:), intent(inout) ad_hz,
real(r8), dimension(lbi:,lbj:), intent(in) om_v,
real(r8), dimension(lbi:,lbj:), intent(in) on_u,
real(r8), dimension(lbi:,lbj:,:), intent(inout) ad_huon,
real(r8), dimension(lbi:,lbj:,:), intent(inout) ad_hvom )
private

Definition at line 81 of file ad_set_massflux.F.

94!***********************************************************************
95!
96 USE mod_param
97 USE mod_scalars
98!
100# ifdef DISTRIBUTE
102# endif
103!
104! Imported variable declarations.
105!
106 integer, intent(in) :: ng, tile, model
107 integer, intent(in) :: LBi, UBi, LBj, UBj
108 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
109 integer, intent(in) :: nrhs
110!
111# ifdef ASSUMED_SHAPE
112 real(r8), intent(in) :: u(LBi:,LBj:,:,:)
113 real(r8), intent(in) :: v(LBi:,LBj:,:,:)
114# ifdef WEC_MELLOR
115 real(r8), intent(in) :: u_stokes(LBi:,LBj:,:)
116 real(r8), intent(in) :: v_stokes(LBi:,LBj:,:)
117# endif
118 real(r8), intent(in) :: Hz(LBi:,LBj:,:)
119 real(r8), intent(in) :: om_v(LBi:,LBj:)
120 real(r8), intent(in) :: on_u(LBi:,LBj:)
121
122 real(r8), intent(inout) :: ad_u(LBi:,LBj:,:,:)
123 real(r8), intent(inout) :: ad_v(LBi:,LBj:,:,:)
124# ifdef WEC_MELLOR
125 real(r8), intent(inout) :: ad_u_stokes(LBi:,LBj:,:)
126 real(r8), intent(inout) :: ad_v_stokes(LBi:,LBj:,:)
127# endif
128 real(r8), intent(inout) :: ad_Hz(LBi:,LBj:,:)
129
130 real(r8), intent(inout) :: ad_Huon(LBi:,LBj:,:)
131 real(r8), intent(inout) :: ad_Hvom(LBi:,LBj:,:)
132# else
133 real(r8), intent(in) :: u(LBi:UBi,LBj:UBj,N(ng),2)
134 real(r8), intent(in) :: v(LBi:UBi,LBj:UBj,N(ng),2)
135# ifdef WEC_MELLOR
136 real(r8), intent(in) :: u_stokes(LBi:UBi,LBj:UBj,N(ng))
137 real(r8), intent(in) :: v_stokes(LBi:UBi,LBj:UBj,N(ng))
138# endif
139 real(r8), intent(in) :: Hz(LBi:UBi,LBj:UBj,N(ng))
140 real(r8), intent(in) :: om_v(LBi:UBi,LBj:UBj)
141 real(r8), intent(in) :: on_u(LBi:UBi,LBj:UBj)
142
143 real(r8), intent(inout) :: ad_u(LBi:UBi,LBj:UBj,N(ng),2)
144 real(r8), intent(inout) :: ad_v(LBi:UBi,LBj:UBj,N(ng),2)
145# ifdef WEC_MELLOR
146 real(r8), intent(inout) :: ad_u_stokes(LBi:UBi,LBj:UBj,N(ng))
147 real(r8), intent(inout) :: ad_v_stokes(LBi:UBi,LBj:UBj,N(ng))
148# endif
149 real(r8), intent(inout) :: ad_Hz(LBi:UBi,LBj:UBj,N(ng))
150
151 real(r8), intent(inout) :: ad_Huon(LBi:UBi,LBj:UBj,N(ng))
152 real(r8), intent(inout) :: ad_Hvom(LBi:UBi,LBj:UBj,N(ng))
153# endif
154!
155! Local variable declarations.
156!
157 integer :: i, j, k
158
159 real(r8) :: adfac, adfac1
160
161# include "set_bounds.h"
162!
163!-----------------------------------------------------------------------
164! Compute horizontal mass fluxes, Hz*u/n and Hz*v/m.
165!-----------------------------------------------------------------------
166!
167! Exchange boundary information.
168!
169# ifdef DISTRIBUTE
170!^ CALL mp_exchange3d (ng, tile, model, 2, &
171!^ & LBi, UBi, LBj, UBj, 1, N(ng), &
172!^ & NghostPoints, &
173!^ & EWperiodic(ng), NSperiodic(ng), &
174!^ & tl_Huon, tl_Hvom)
175!^
176 CALL ad_mp_exchange3d (ng, tile, model, 2, &
177 & lbi, ubi, lbj, ubj, 1, n(ng), &
178 & nghostpoints, &
179 & ewperiodic(ng), nsperiodic(ng), &
180 & ad_huon, ad_hvom)
181!
182# endif
183
184 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
185!^ CALL exchange_v3d_tile (ng, tile, &
186!^ & LBi, UBi, LBj, UBj, 1, N(ng), &
187!^ & tl_Hvom)
188!^
189 CALL ad_exchange_v3d_tile (ng, tile, &
190 & lbi, ubi, lbj, ubj, 1, n(ng), &
191 & ad_hvom)
192!^ CALL exchange_u3d_tile (ng, tile, &
193!^ & LBi, UBi, LBj, UBj, 1, N(ng), &
194!^ & tl_Huon)
195!^
196 CALL ad_exchange_u3d_tile (ng, tile, &
197 & lbi, ubi, lbj, ubj, 1, n(ng), &
198 & ad_huon)
199 END IF
200!
201! Compute adjoint horizontal mass fluxes.
202!
203 DO k=1,n(ng)
204 DO j=jstrp,jendt
205 DO i=istrt,iendt
206# ifdef WEC_MELLOR
207!^ tl_Hvom(i,j,k)=tl_Hvom(i,j,k)+ &
208!^ & 0.5_r8*om_v(i,j)* &
209!^ & ((Hz(i,j,k)+Hz(i,j-1,k))* &
210!^ & tl_v_stokes(i,j,k)+ &
211!^ & (tl_Hz(i,j,k)+tl_Hz(i,j-1,k))* &
212!^ & v_stokes(i,j,k))
213!^
214 adfac=0.5_r8*om_v(i,j)*tl_hvom(i,j,k)
215 adfac1=adfac*v_stokes(i,j,k)
216 tl_v_stokes(i,j,k)=tl_v_stokes(i,j,k)+ &
217 & adfac*(hz(i,j,k)+hz(i,j-1,k))
218 ad_hz(i,j-1,k)=ad_hz(i,j-1,k)+adfac1
219 ad_hz(i,j ,k)=ad_hz(i,j ,k)+adfac1
220# endif
221!^ tl_Hvom(i,j,k)=0.5_r8*om_v(i,j)* &
222!^ & ((Hz(i,j,k)+Hz(i,j-1,k))* &
223!^ & tl_v(i,j,k,nrhs)+ &
224!^ & (tl_Hz(i,j,k)+tl_Hz(i,j-1,k))* &
225!^ & v(i,j,k,nrhs))
226!^
227 adfac=0.5_r8*om_v(i,j)*ad_hvom(i,j,k)
228 adfac1=adfac*v(i,j,k,nrhs)
229 ad_v(i,j,k,nrhs)=ad_v(i,j,k,nrhs)+ &
230 & adfac*(hz(i,j,k)+hz(i,j-1,k))
231 ad_hz(i,j-1,k)=ad_hz(i,j-1,k)+adfac1
232 ad_hz(i,j ,k)=ad_hz(i,j ,k)+adfac1
233 ad_hvom(i,j,k)=0.0_r8
234 END DO
235 END DO
236 DO j=jstrt,jendt
237 DO i=istrp,iendt
238# ifdef WEC_MELLOR
239!^ tl_Huon(i,j,k)=tl_Huon(i,j,k)+ &
240!^ & 0.5_r8*on_u(i,j)* &
241!^ & ((Hz(i,j,k)+Hz(i-1,j,k))* &
242!^ & tl_u_stokes(i,j,k)+ &
243!^ & (tl_Hz(i,j,k)+tl_Hz(i-1,j,k))* &
244!^ & u_stokes(i,j,k))
245!^
246 adfac=0.5_r8*on_u(i,j)*ad_huon(i,j,k)
247 adfac1=adfac*u_stokes(i,j,k)
248 ad_u_stokes(i,j,k)=ad_u_stokes(i,j,k)+ &
249 & adfac*(hz(i,j,k)+hz(i-1,j,k))
250 ad_hz(i-1,j,k)=ad_hz(i-1,j,k)+adfac1
251 ad_hz(i ,j,k)=ad_hz(i ,j,k)+adfac1
252# endif
253!^ tl_Huon(i,j,k)=0.5_r8*on_u(i,j)* &
254!^ & ((Hz(i,j,k)+Hz(i-1,j,k))* &
255!^ & tl_u(i,j,k,nrhs)+ &
256!^ & (tl_Hz(i,j,k)+tl_Hz(i-1,j,k))* &
257!^ & u(i,j,k,nrhs))
258!^
259 adfac=0.5_r8*on_u(i,j)*ad_huon(i,j,k)
260 adfac1=adfac*u(i,j,k,nrhs)
261 ad_u(i,j,k,nrhs)=ad_u(i,j,k,nrhs)+ &
262 & adfac*(hz(i,j,k)+hz(i-1,j,k))
263 ad_hz(i-1,j,k)=ad_hz(i-1,j,k)+adfac1
264 ad_hz(i ,j,k)=ad_hz(i ,j,k)+adfac1
265 ad_huon(i,j,k)=0.0_r8
266 END DO
267 END DO
268 END DO
269!
270 RETURN
subroutine ad_exchange_v3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, ad_a)
subroutine ad_exchange_u3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, ad_a)
integer, dimension(:), allocatable n
Definition mod_param.F:479
integer nghostpoints
Definition mod_param.F:710
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
subroutine ad_mp_exchange3d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, lbk, ubk, nghost, ew_periodic, ns_periodic, ad_a, ad_b, ad_c, ad_d)

References ad_exchange_3d_mod::ad_exchange_u3d_tile(), ad_exchange_3d_mod::ad_exchange_v3d_tile(), mp_exchange_mod::ad_mp_exchange3d(), mod_scalars::ewperiodic, mod_param::nghostpoints, and mod_scalars::nsperiodic.

Referenced by ad_set_massflux().

Here is the call graph for this function:
Here is the caller graph for this function: