ROMS
Loading...
Searching...
No Matches
sed_bed.F
Go to the documentation of this file.
1#include "cppdefs.h"
2
4
5#if defined NONLINEAR && defined SEDIMENT && !defined COHESIVE_BED
6!
7!git $Id$
8!==================================================== John C. Warner ===
9! Copyright (c) 2002-2025 The ROMS Group Hernan G. Arango !
10! Licensed under a MIT/X style license !
11! See License_ROMS.md !
12!=======================================================================
13! !
14! This routine computes sediment bed layer stratigraphy. !
15! !
16! Warner, J.C., C.R. Sherwood, R.P. Signell, C.K. Harris, and H.G. !
17! Arango, 2008: Development of a three-dimensional, regional, !
18! coupled wave, current, and sediment-transport model, Computers !
19! & Geosciences, 34, 1284-1306. !
20! !
21!=======================================================================
22!
23 implicit none
24!
25 PRIVATE
26 PUBLIC :: sed_bed
27!
28 CONTAINS
29!
30!***********************************************************************
31 SUBROUTINE sed_bed (ng, tile)
32!***********************************************************************
33!
34 USE mod_param
35 USE mod_forces
36 USE mod_grid
37 USE mod_ocean
38 USE mod_sedbed
39 USE mod_stepping
40# ifdef BBL_MODEL
41 USE mod_bbl
42# endif
43!
44! Imported variable declarations.
45!
46 integer, intent(in) :: ng, tile
47!
48! Local variable declarations.
49!
50 character (len=*), parameter :: myfile = &
51 & __FILE__
52!
53# include "tile.h"
54!
55# ifdef PROFILE
56 CALL wclock_on (ng, inlm, 16, __line__, myfile)
57# endif
58 CALL sed_bed_tile (ng, tile, &
59 & lbi, ubi, lbj, ubj, &
60 & imins, imaxs, jmins, jmaxs, &
61 & nstp(ng), nnew(ng), &
62# ifdef WET_DRY
63 & grid(ng) % rmask_wet, &
64# endif
65# ifdef BBL_MODEL
66 & bbl(ng) % bustrc, &
67 & bbl(ng) % bvstrc, &
68 & bbl(ng) % bustrw, &
69 & bbl(ng) % bvstrw, &
70 & bbl(ng) % bustrcwmax, &
71 & bbl(ng) % bvstrcwmax, &
72# else
73 & forces(ng) % bustr, &
74 & forces(ng) % bvstr, &
75# endif
76 & ocean(ng) % t, &
77# ifdef SUSPLOAD
78 & sedbed(ng) % ero_flux, &
79 & sedbed(ng) % settling_flux, &
80# endif
81# if defined SED_MORPH
82 & sedbed(ng) % bed_thick, &
83# endif
84 & sedbed(ng) % bed, &
85 & sedbed(ng) % bed_frac, &
86 & sedbed(ng) % bed_mass, &
87 & sedbed(ng) % bottom)
88# ifdef PROFILE
89 CALL wclock_off (ng, inlm, 16, __line__, myfile)
90# endif
91!
92 RETURN
93 END SUBROUTINE sed_bed
94!
95!***********************************************************************
96 SUBROUTINE sed_bed_tile (ng, tile, &
97 & LBi, UBi, LBj, UBj, &
98 & IminS, ImaxS, JminS, JmaxS, &
99 & nstp, nnew, &
100# ifdef WET_DRY
101 & rmask_wet, &
102# endif
103# ifdef BBL_MODEL
104 & bustrc, bvstrc, &
105 & bustrw, bvstrw, &
106 & bustrcwmax, bvstrcwmax, &
107# else
108 & bustr, bvstr, &
109# endif
110 & t, &
111# ifdef SUSPLOAD
112 & ero_flux, settling_flux, &
113# endif
114# if defined SED_MORPH
115 & bed_thick, &
116# endif
117 & bed, bed_frac, bed_mass, &
118 & bottom)
119!***********************************************************************
120!
121 USE mod_param
122 USE mod_scalars
123 USE mod_sediment
124!
125 USE bc_3d_mod, ONLY : bc_r3d_tile
127# ifdef DISTRIBUTE
129# endif
130!
131! Imported variable declarations.
132!
133 integer, intent(in) :: ng, tile
134 integer, intent(in) :: LBi, UBi, LBj, UBj
135 integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
136 integer, intent(in) :: nstp, nnew
137!
138# ifdef ASSUMED_SHAPE
139# ifdef WET_DRY
140 real(r8), intent(in) :: rmask_wet(LBi:,LBj:)
141# endif
142# ifdef BBL_MODEL
143 real(r8), intent(in) :: bustrc(LBi:,LBj:)
144 real(r8), intent(in) :: bvstrc(LBi:,LBj:)
145 real(r8), intent(in) :: bustrw(LBi:,LBj:)
146 real(r8), intent(in) :: bvstrw(LBi:,LBj:)
147 real(r8), intent(in) :: bustrcwmax(LBi:,LBj:)
148 real(r8), intent(in) :: bvstrcwmax(LBi:,LBj:)
149# else
150 real(r8), intent(in) :: bustr(LBi:,LBj:)
151 real(r8), intent(in) :: bvstr(LBi:,LBj:)
152# endif
153# if defined SED_MORPH
154 real(r8), intent(inout):: bed_thick(LBi:,LBj:,:)
155# endif
156 real(r8), intent(inout) :: t(LBi:,LBj:,:,:,:)
157# ifdef SUSPLOAD
158 real(r8), intent(inout) :: ero_flux(LBi:,LBj:,:)
159 real(r8), intent(inout) :: settling_flux(LBi:,LBj:,:)
160# endif
161 real(r8), intent(inout) :: bed(LBi:,LBj:,:,:)
162 real(r8), intent(inout) :: bed_frac(LBi:,LBj:,:,:)
163 real(r8), intent(inout) :: bed_mass(LBi:,LBj:,:,:,:)
164 real(r8), intent(inout) :: bottom(LBi:,LBj:,:)
165# else
166# ifdef WET_DRY
167 real(r8), intent(in) :: rmask_wet(LBi:UBi,LBj:UBj)
168# endif
169# ifdef BBL_MODEL
170 real(r8), intent(in) :: bustrc(LBi:UBi,LBj:UBj)
171 real(r8), intent(in) :: bvstrc(LBi:UBi,LBj:UBj)
172 real(r8), intent(in) :: bustrw(LBi:UBi,LBj:UBj)
173 real(r8), intent(in) :: bvstrw(LBi:UBi,LBj:UBj)
174 real(r8), intent(in) :: bustrcwmax(LBi:UBi,LBj:UBj)
175 real(r8), intent(in) :: bvstrcwmax(LBi:UBi,LBj:UBj)
176# else
177 real(r8), intent(in) :: bustr(LBi:UBi,LBj:UBj)
178 real(r8), intent(in) :: bvstr(LBi:UBi,LBj:UBj)
179# endif
180# if defined SED_MORPH
181 real(r8), intent(inout):: bed_thick(LBi:UBi,LBj:UBj,3)
182# endif
183 real(r8), intent(inout) :: t(LBi:UBi,LBj:UBj,N(ng),3,NT(ng))
184# ifdef SUSPLOAD
185 real(r8), intent(inout) :: ero_flux(LBi:UBi,LBj:UBj,NST)
186 real(r8), intent(inout) :: settling_flux(LBi:UBi,LBj:UBj,NST)
187# endif
188 real(r8), intent(inout) :: bed(LBi:UBi,LBj:UBj,Nbed,MBEDP)
189 real(r8), intent(inout) :: bed_frac(LBi:UBi,LBj:UBj,Nbed,NST)
190 real(r8), intent(inout) :: bed_mass(LBi:UBi,LBj:UBj,Nbed,1:2,NST)
191 real(r8), intent(inout) :: bottom(LBi:UBi,LBj:UBj,MBOTP)
192# endif
193!
194! Local variable declarations.
195!
196 integer :: Ksed, i, ised, j, k, ks
197 integer :: bnew
198
199 real(r8), parameter :: eps = 1.0e-14_r8
200
201 real(r8) :: cff, cff1, cff2, cff3
202 real(r8) :: thck_avail, thck_to_add
203
204 real(r8), dimension(IminS:ImaxS,NST) :: dep_mass
205 real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: tau_w
206
207# include "set_bounds.h"
208
209# ifdef BEDLOAD
210 bnew=nnew
211# else
212 bnew=nstp
213# endif
214!
215!-----------------------------------------------------------------------
216! Compute sediment bed layer stratigraphy.
217!-----------------------------------------------------------------------
218!
219# if defined BEDLOAD_MPM || defined SUSPLOAD
220# ifdef BBL_MODEL
221 DO j=jstr-1,jend+1
222 DO i=istr-1,iend+1
223 tau_w(i,j)=sqrt(bustrcwmax(i,j)*bustrcwmax(i,j)+ &
224 & bvstrcwmax(i,j)*bvstrcwmax(i,j))
225# ifdef WET_DRY
226 tau_w(i,j)=tau_w(i,j)*rmask_wet(i,j)
227# endif
228 END DO
229 END DO
230# else
231 DO j=jstrm1,jendp1
232 DO i=istrm1,iendp1
233 tau_w(i,j)=0.5_r8*sqrt((bustr(i,j)+bustr(i+1,j))* &
234 & (bustr(i,j)+bustr(i+1,j))+ &
235 & (bvstr(i,j)+bvstr(i,j+1))* &
236 & (bvstr(i,j)+bvstr(i,j+1)))
237# ifdef WET_DRY
238 tau_w(i,j)=tau_w(i,j)*rmask_wet(i,j)
239# endif
240 END DO
241 END DO
242# endif
243# endif
244!
245!-----------------------------------------------------------------------
246! Update bed properties according to ero_flux and dep_flux.
247!-----------------------------------------------------------------------
248!
249# ifdef SUSPLOAD
250 j_loop : DO j=jstr,jend
251 sed_loop: DO ised=1,nst
252!
253! The deposition and resuspension of sediment on the bottom "bed"
254! is due to precepitation flux FC(:,0), already computed, and the
255! resuspension (erosion, hence called ero_flux). The resuspension is
256! applied to the bottom-most grid box value qc(:,1) so the total mass
257! is conserved. Restrict "ero_flux" so that "bed" cannot go negative
258! after both fluxes are applied.
259!
260 DO i=istr,iend
261 dep_mass(i,ised)=0.0_r8
262
263# ifdef SED_MORPH
264!
265! Apply morphology factor.
266!
267 ero_flux(i,j,ised)=ero_flux(i,j,ised)*morph_fac(ised,ng)
268 settling_flux(i,j,ised)=settling_flux(i,j,ised)* &
269 & morph_fac(ised,ng)
270!
271# endif
272 IF ((ero_flux(i,j,ised)-settling_flux(i,j,ised)).lt. &
273 & 0.0_r8) THEN
274!
275! If first time step of deposit, then store deposit material in
276! temporary array, dep_mass.
277!
278 IF ((time(ng).gt.(bed(i,j,1,iaged)+1.1_r8*dt(ng))).and. &
279 & (bed(i,j,1,ithck).gt.newlayer_thick(ng))) THEN
280 dep_mass(i,ised)=settling_flux(i,j,ised)- &
281 & ero_flux(i,j,ised)
282 END IF
283 bed(i,j,1,iaged)=time(ng)
284 END IF
285!
286! Update bed mass arrays.
287!
288 bed_mass(i,j,1,nnew,ised)=max(bed_mass(i,j,1,bnew,ised)- &
289 & (ero_flux(i,j,ised)- &
290 & settling_flux(i,j,ised)), &
291 & 0.0_r8)
292 DO k=2,nbed
293 bed_mass(i,j,k,nnew,ised)=bed_mass(i,j,k,nstp,ised)
294 END DO
295 END DO
296 END DO sed_loop
297!
298! If first time step of deposit, create new layer and combine bottom
299! two bed layers.
300!
301 DO i=istr,iend
302 cff=0.0_r8
303!
304! Determine if deposition ocurred here.
305!
306 IF (nbed.gt.1) THEN
307 DO ised=1,nst
308 cff=cff+dep_mass(i,ised)
309 END DO
310 IF (cff.gt.0.0_r8) THEN
311!
312! Combine bottom layers.
313!
314 bed(i,j,nbed,iporo)=0.5_r8*(bed(i,j,nbed-1,iporo)+ &
315 & bed(i,j,nbed,iporo))
316 bed(i,j,nbed,iaged)=0.5_r8*(bed(i,j,nbed-1,iaged)+ &
317 & bed(i,j,nbed,iaged))
318 DO ised=1,nst
319 bed_mass(i,j,nbed,nnew,ised)= &
320 & bed_mass(i,j,nbed-1,nnew,ised)+ &
321 & bed_mass(i,j,nbed ,nnew,ised)
322 END DO
323!
324! Push layers down.
325!
326 DO k=nbed-1,2,-1
327 bed(i,j,k,iporo)=bed(i,j,k-1,iporo)
328 bed(i,j,k,iaged)=bed(i,j,k-1,iaged)
329 DO ised =1,nst
330 bed_mass(i,j,k,nnew,ised)=bed_mass(i,j,k-1,nnew,ised)
331 END DO
332 END DO
333!
334! Set new top layer parameters.
335!
336 DO ised=1,nst
337 bed_mass(i,j,2,nnew,ised)=max(bed_mass(i,j,2,nnew,ised)-&
338 & dep_mass(i,ised),0.0_r8)
339 bed_mass(i,j,1,nnew,ised)=dep_mass(i,ised)
340 END DO
341 END IF
342 END IF !NBED=1
343!
344! Recalculate thickness and fractions for all layers.
345!
346 DO k=1,nbed
347 cff3=0.0_r8
348 DO ised=1,nst
349 cff3=cff3+bed_mass(i,j,k,nnew,ised)
350 END DO
351 IF (cff3.eq.0.0_r8) THEN
352 cff3=eps
353 END IF
354 bed(i,j,k,ithck)=0.0_r8
355 DO ised=1,nst
356 bed_frac(i,j,k,ised)=bed_mass(i,j,k,nnew,ised)/cff3
357 bed(i,j,k,ithck)=max(bed(i,j,k,ithck)+ &
358 & bed_mass(i,j,k,nnew,ised)/ &
359 & (srho(ised,ng)* &
360 & (1.0_r8-bed(i,j,k,iporo))),0.0_r8)
361 END DO
362 END DO
363 END DO
364 END DO j_loop
365!
366! End of Suspended Sediment only section.
367!
368# endif
369!
370! Ensure top bed layer thickness is greater or equal than active layer
371! thickness. If need to add sed to top layer, then entrain from lower
372! levels. Create new layers at bottom to maintain Nbed.
373!
374 j_loop2 : DO j=jstr,jend
375 DO i=istr,iend
376!
377! Calculate active layer thickness, bottom(i,j,iactv).
378!
379 bottom(i,j,iactv)=max(0.0_r8, &
380 & 0.007_r8* &
381 & (tau_w(i,j)-bottom(i,j,itauc))*rho0)+ &
382 & 6.0_r8*bottom(i,j,isd50)
383!
384# ifdef SED_MORPH
385!
386! Apply morphology factor.
387!
388 bottom(i,j,iactv)=max(bottom(i,j,iactv)*morph_fac(1,ng), &
389 & bottom(i,j,iactv))
390# endif
391!
392 IF (bottom(i,j,iactv).gt.bed(i,j,1,ithck)) THEN
393 IF (nbed.eq.1) THEN
394 bottom(i,j,iactv)=bed(i,j,1,ithck)
395 ELSE
396 thck_to_add=bottom(i,j,iactv)-bed(i,j,1,ithck)
397 thck_avail=0.0_r8
398 ksed=1 ! initialize
399 DO k=2,nbed
400 IF (thck_avail.lt.thck_to_add) THEN
401 thck_avail=thck_avail+bed(i,j,k,ithck)
402 ksed=k
403 END IF
404 END DO
405!
406! Catch here if there was not enough bed material.
407!
408 IF (thck_avail.lt.thck_to_add) THEN
409 bottom(i,j,iactv)=bed(i,j,1,ithck)+thck_avail
410 thck_to_add=thck_avail
411 END IF
412!
413! Update bed mass of top layer and fractional layer.
414!
415 cff2=max(thck_avail-thck_to_add,0.0_r8)/ &
416 & max(bed(i,j,ksed,ithck),eps)
417 DO ised=1,nst
418 cff1=0.0_r8
419 DO k=1,ksed
420 cff1=cff1+bed_mass(i,j,k,nnew,ised)
421 END DO
422 cff3=cff2*bed_mass(i,j,ksed,nnew,ised)
423 bed_mass(i,j,1 ,nnew,ised)=cff1-cff3
424 bed_mass(i,j,ksed,nnew,ised)=cff3
425 END DO
426!
427! Update thickness of fractional layer ksource_sed.
428!
429 bed(i,j,ksed,ithck)=max(thck_avail-thck_to_add,0.0_r8)
430!
431! Upate bed fraction of top layer.
432!
433 cff3=0.0_r8
434 DO ised=1,nst
435 cff3=cff3+bed_mass(i,j,1,nnew,ised)
436 END DO
437 IF (cff3.eq.0.0_r8) THEN
438 cff3=eps
439 END IF
440 DO ised=1,nst
441 bed_frac(i,j,1,ised)=bed_mass(i,j,1,nnew,ised)/cff3
442 END DO
443!
444! Upate bed thickness of top layer.
445!
446 bed(i,j,1,ithck)=bottom(i,j,iactv)
447!
448! Pull all layers closer to the surface.
449!
450 DO k=ksed,nbed
451 ks=ksed-2
452 bed(i,j,k-ks,ithck)=bed(i,j,k,ithck)
453 bed(i,j,k-ks,iporo)=bed(i,j,k,iporo)
454 bed(i,j,k-ks,iaged)=bed(i,j,k,iaged)
455 DO ised=1,nst
456 bed_frac(i,j,k-ks,ised)=bed_frac(i,j,k,ised)
457 bed_mass(i,j,k-ks,nnew,ised)=bed_mass(i,j,k,nnew,ised)
458 END DO
459 END DO
460!
461! Add new layers onto the bottom. Split what was in the bottom layer to
462! fill these new empty cells. ("ks" is the number of new layers).
463!
464 ks=ksed-2
465 cff=1.0_r8/real(ks+1,r8)
466 DO k=nbed,nbed-ks,-1
467 bed(i,j,k,ithck)=bed(i,j,nbed-ks,ithck)*cff
468 bed(i,j,k,iaged)=bed(i,j,nbed-ks,iaged)
469 DO ised=1,nst
470 bed_frac(i,j,k,ised)=bed_frac(i,j,nbed-ks,ised)
471 bed_mass(i,j,k,nnew,ised)= &
472 & bed_mass(i,j,nbed-ks,nnew,ised)*cff
473 END DO
474 END DO
475 END IF ! Nbed > 1
476 END IF ! increase top bed layer
477 END DO
478 END DO j_loop2
479!
480!-----------------------------------------------------------------------
481! Store old bed thickness.
482!-----------------------------------------------------------------------
483!
484# if defined SED_MORPH
485 DO j=jstrr,jendr
486 DO i=istrr,iendr
487 bed_thick(i,j,nnew)=0.0_r8
488 DO k=1,nbed
489 bed_thick(i,j,nnew)=bed_thick(i,j,nnew)+ &
490 & bed(i,j,k,ithck)
491 END DO
492 END DO
493 END DO
494 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
495 CALL exchange_r2d_tile (ng, tile, &
496 & lbi, ubi, lbj, ubj, &
497 & bed_thick(:,:,nnew))
498 END IF
499# endif
500!
501!-----------------------------------------------------------------------
502! Apply periodic or gradient boundary conditions to property arrays.
503!-----------------------------------------------------------------------
504!
505 DO ised=1,nst
506 CALL bc_r3d_tile (ng, tile, &
507 & lbi, ubi, lbj, ubj, 1, nbed, &
508 & bed_frac(:,:,:,ised))
509 CALL bc_r3d_tile (ng, tile, &
510 & lbi, ubi, lbj, ubj, 1, nbed, &
511 & bed_mass(:,:,:,nnew,ised))
512 END DO
513# ifdef DISTRIBUTE
514 CALL mp_exchange4d (ng, tile, inlm, 2, &
515 & lbi, ubi, lbj, ubj, 1, nbed, 1, nst, &
516 & nghostpoints, &
517 & ewperiodic(ng), nsperiodic(ng), &
518 & bed_frac, &
519 & bed_mass(:,:,:,nnew,:))
520# endif
521
522 DO i=1,mbedp
523 CALL bc_r3d_tile (ng, tile, &
524 & lbi, ubi, lbj, ubj, 1, nbed, &
525 & bed(:,:,:,i))
526 END DO
527# ifdef DISTRIBUTE
528 CALL mp_exchange4d (ng, tile, inlm, 1, &
529 & lbi, ubi, lbj, ubj, 1, nbed, 1, mbedp, &
530 & nghostpoints, &
531 & ewperiodic(ng), nsperiodic(ng), &
532 & bed)
533# endif
534!
535 RETURN
536 END SUBROUTINE sed_bed_tile
537#endif
538 END MODULE sed_bed_mod
subroutine bc_r3d_tile(ng, tile, lbi, ubi, lbj, ubj, lbk, ubk, a)
Definition bc_3d.F:48
subroutine exchange_r2d_tile(ng, tile, lbi, ubi, lbj, ubj, a)
type(t_bbl), dimension(:), allocatable bbl
Definition mod_bbl.F:62
type(t_forces), dimension(:), allocatable forces
Definition mod_forces.F:554
type(t_grid), dimension(:), allocatable grid
Definition mod_grid.F:365
type(t_ocean), dimension(:), allocatable ocean
Definition mod_ocean.F:351
integer, parameter inlm
Definition mod_param.F:662
integer nghostpoints
Definition mod_param.F:710
real(dp), dimension(:), allocatable dt
logical, dimension(:), allocatable ewperiodic
logical, dimension(:), allocatable nsperiodic
real(dp), dimension(:), allocatable time
real(dp) rho0
type(t_sedbed), dimension(:), allocatable sedbed
Definition sedbed_mod.h:157
integer, parameter iactv
integer, parameter iaged
real(r8), dimension(:,:), allocatable srho
integer, parameter iporo
integer, parameter isd50
real(r8), dimension(:,:), allocatable morph_fac
real(r8), dimension(:), allocatable newlayer_thick
integer, parameter itauc
integer, parameter ithck
integer, dimension(:), allocatable nnew
integer, dimension(:), allocatable nstp
subroutine mp_exchange4d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, lbk, ubk, lbt, ubt, nghost, ew_periodic, ns_periodic, a, b, c)
subroutine mp_exchange3d(ng, tile, model, nvar, lbi, ubi, lbj, ubj, lbk, ubk, nghost, ew_periodic, ns_periodic, a, b, c, d)
subroutine, public sed_bed(ng, tile)
Definition sed_bed.F:32
subroutine sed_bed_tile(ng, tile, lbi, ubi, lbj, ubj, imins, imaxs, jmins, jmaxs, nstp, nnew, rmask_wet, bustrc, bvstrc, bustrw, bvstrw, bustrcwmax, bvstrcwmax, t, ero_flux, settling_flux, bed_thick, bed, bed_frac, bed_mass, bottom)
Definition sed_bed.F:119
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