115
116
120
122# ifdef DISTRIBUTE
124# endif
125
126
127
128 integer, intent(in) :: ng, tile, model
129 integer, intent(in) :: LBi, UBi, LBj, UBj
130 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
131# if defined SEDIMENT && defined SED_MORPH
132 integer, intent(in) :: nstp, nnew
133# endif
134
135# ifdef ASSUMED_SHAPE
136# if defined SEDIMENT && defined SED_MORPH
137 real(r8), intent(in) :: omn(LBi:,LBj:)
138 real(r8), intent(in) :: bed_thick(LBi:,LBj:,:)
139# endif
140 real(r8), intent(in) :: Huon(LBi:,LBj:,:)
141 real(r8), intent(in) :: Hvom(LBi:,LBj:,:)
142# ifdef OMEGA_IMPLICIT
143 real(r8), intent(in) :: pm(LBi:,LBj:)
144 real(r8), intent(in) :: pn(LBi:,LBj:)
145# endif
146 real(r8), intent(in) :: z_w(LBi:,LBj:,0:)
147# if defined WEC_VF
148 real(r8), intent(in) :: W_stokes(LBi:,LBj:,0:)
149# endif
150# ifdef OMEGA_IMPLICIT
151 real(r8), intent(out) :: Wi(LBi:,LBj:,0:)
152# endif
153 real(r8), intent(out) :: W(LBi:,LBj:,0:)
154
155# else
156
157# if defined SEDIMENT && defined SED_MORPH
158 real(r8), intent(in) :: omn(LBi:UBi,LBj:UBj)
159 real(r8), intent(in) :: bed_thick(LBi:UBi,LBj:UBj,3)
160# endif
161 real(r8), intent(in) :: Huon(LBi:UBi,LBj:UBj,N(ng))
162 real(r8), intent(in) :: Hvom(LBi:UBi,LBj:UBj,N(ng))
163# ifdef OMEGA_IMPLICIT
164 real(r8), intent(in) :: pm(LBi:UBi,LBj:UBj)
165 real(r8), intent(in) :: pn(LBi:UBi,LBj:UBj)
166# endif
167 real(r8), intent(in) :: z_w(LBi:UBi,LBj:UBj,0:N(ng))
168# if defined WEC_VF
169 real(r8), intent(in) :: W_stokes(LBi:UBi,LBj:UBj,0:N(ng))
170# endif
171# ifdef OMEGA_IMPLICIT
172 real(r8), intent(out) :: Wi(LBi:UBi,LBj:UBj,0:N(ng))
173# endif
174 real(r8), intent(out) :: W(LBi:UBi,LBj:UBj,0:N(ng))
175# endif
176
177
178
179 integer :: i, ii, is, j, jj, k
180# if defined SEDIMENT && defined SED_MORPH
181 real(r8) :: cff1
182# endif
183 real(r8), dimension(IminS:ImaxS) :: wrk
184# ifdef OMEGA_IMPLICIT
185 real(r8), dimension(IminS:ImaxS,0:N(ng)) :: Cu_adv
186 real(r8) :: cff
187 real(r8) :: cw, c2d, dh, cw_max, cw_max2, cw_min
188
189 real(r8), parameter :: amax = 0.75_r8
190 real(r8), parameter :: amin = 0.60_r8
191 real(r8), parameter :: cmnx_ratio = amin/amax
192 real(r8), parameter :: cutoff = 2.0_r8-amin/amax
193 real(r8), parameter :: r4cmx = 1.0_r8/(4.0_r8-4.0_r8*amin/amax)
194# endif
195
196# include "set_bounds.h"
197
198
199
200
201
202
203
204
205
206
207# if defined SEDIMENT && defined SED_MORPH
208
209
210
211
212 cff1=1.0_r8/(
dt(ng)*
n(ng))
213
214# endif
215 DO j=jstr,jend
216 DO i=istr,iend
217 w(i,j,0)=0.0_r8
218# if defined SEDIMENT && defined SED_MORPH
219 wrk(i)=cff1*(bed_thick(i,j,nstp)- &
220 & bed_thick(i,j,nnew))*omn(i,j)
221# endif
222 END DO
224 DO i=istr,iend
225 w(i,j,k)=w(i,j,k-1)- &
226# if defined SEDIMENT && defined SED_MORPH
227 & wrk(i)- &
228# endif
229 & (huon(i+1,j,k)-huon(i,j,k)+ &
230 & hvom(i,j+1,k)-hvom(i,j,k))
231
232# ifdef OMEGA_IMPLICIT
233
234
235
236 cu_adv(i,k)=max(huon(i+1,j ,k),0.0_r8)- &
237 & min(huon(i ,j ,k),0.0_r8)+ &
238 & max(hvom(i ,j+1,k),0.0_r8)- &
239 & min(hvom(i ,j ,k),0.0_r8)
240# endif
241 END DO
242 END DO
243
244
245
246
247
248
249
250
251
252
255 IF (int(
sources(ng)%Dsrc(is)).eq.2)
THEN
258 IF (((istrr.le.ii).and.(ii.le.iendr)).and. &
259 & ((jstrr.le.jj).and.(jj.le.jendr)).and. &
260 & (j.eq.jj)) THEN
261# if defined SEDIMENT && defined SED_MORPH
262 wrk(ii)=cff1*(bed_thick(ii,jj,nstp)- &
263 & bed_thick(ii,jj,nnew))*omn(ii,jj)
264# endif
266 w(ii,jj,k)=w(ii,jj,k-1)- &
267# if defined SEDIMENT && defined SED_MORPH
268 & wrk(ii)- &
269# endif
270 & (huon(ii+1,jj,k)-huon(ii,jj,k)+ &
271 & hvom(ii,jj+1,k)-hvom(ii,jj,k))+ &
273 END DO
274 END IF
275 END IF
276 END DO
277 END IF
278
279 DO i=istr,iend
280 wrk(i)=w(i,j,
n(ng))/(z_w(i,j,
n(ng))-z_w(i,j,0))
281# ifdef OMEGA_IMPLICIT
282 cu_adv(i,0)=
dt(ng)*pm(i,j)*pn(i,j)
283# endif
284 END DO
285
286
287
288
289
290
291
292
294 DO i=istr,iend
295 w(i,j,k)=w(i,j,k)- &
296# if defined WEC_VF
297 & w_stokes(i,j,k)- &
298# endif
299 & wrk(i)*(z_w(i,j,k)-z_w(i,j,0))
300
301# ifdef OMEGA_IMPLICIT
302
303
304
305
306 wi(i,j,k)=w(i,j,k)
307 IF (wi(i,j,k).ge.0.0_r8) THEN
308 c2d=cu_adv(i,k)
309 dh=z_w(i,j,k)-z_w(i,j,k-1)
310 ELSE
311 c2d=cu_adv(i,k+1)
312 dh=z_w(i,j,k+1)-z_w(i,j,k)
313 END IF
314
315
316
317
318
319
320
321
322
323
324
325 cw_max=amax*dh-c2d*cu_adv(i,0)
326 IF (cw_max.ge.0.0_r8) THEN
327 cw_max2=cw_max*cw_max
328 cw_min=cw_max*cmnx_ratio
329 cw=abs(wi(i,j,k))*cu_adv(i,0)
330 IF (cw.le.cw_min) THEN
331 cff=cw_max2
332 ELSE IF (cw.le.cutoff*cw_max) THEN
333 cff=cw_max2+r4cmx*(cw-cw_min)**2
334 ELSE
335 cff=cw_max*cw
336 END IF
337
338 w(i,j,k)=cw_max2*wi(i,j,k)/cff
339 wi(i,j,k)=wi(i,j,k)-w(i,j,k)
340 ELSE
341 w(i,j,k)=0.0_r8
342 END IF
343# endif
344 END DO
345 END DO
346 DO i=istr,iend
348 END DO
349 END DO
350
351
352
354 & lbi, ubi, lbj, ubj, 0,
n(ng), &
355 & w)
356# ifdef OMEGA_IMPLICIT
358 & lbi, ubi, lbj, ubj, 0,
n(ng), &
359 & wi)
360# endif
361# ifdef DISTRIBUTE
363 & lbi, ubi, lbj, ubj, 0,
n(ng), &
366 & w)
367# ifdef OMEGA_IMPLICIT
369 & lbi, ubi, lbj, ubj, 0,
n(ng), &
372 & wi)
373# endif
374# endif
375
376 RETURN
subroutine bc_w3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, a)
integer, dimension(:), allocatable n
real(dp), dimension(:), allocatable dt
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
logical, dimension(:), allocatable lwsrc
type(t_sources), dimension(:), allocatable sources
integer, dimension(:), allocatable nsrc
subroutine mp_exchange3d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, lbk, ubk, nghost, ew_periodic, ns_periodic, a, b, c, d)