My Project
Functions/Subroutines
swancom2.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine sbot (ABRBOT, DEP2, ECOS, ESIN, KWAVE, SPCSIG, UBOT, UX2, UY2, IDCMIN, IDCMAX, ISSTOP, VARFR, FRCOEF, IG, IMATRA)
 
subroutine frabre (HM, ETOT, QBLOC)
 
subroutine ssurf (ETOT, HM, QB, SMEBRK, IMATRA, IMATDA, IDCMIN, IDCMAX, PLWBRK, ISSTOP, IG)
 
subroutine swcap (SPCDIR, SPCSIG, KWAVE, IDCMIN, IDCMAX, ISSTOP, ETOT, IMATDA, IMATRA, PLWCAP, CGO, UFRIC, DEP2, DISSIP, DISIMP, IG)
 
subroutine brkpar (BRCOEF, ECOS, ESIN, AC2, SPCSIG, DEP2, IG)
 

Function/Subroutine Documentation

◆ brkpar()

subroutine brkpar ( real, intent(out)  BRCOEF,
real, dimension(mdc), intent(in)  ECOS,
real, dimension(mdc), intent(in)  ESIN,
real, dimension(mdc,msc,0:mt), intent(in)  AC2,
real, dimension(msc), intent(in)  SPCSIG,
real, dimension(mt), intent(in)  DEP2,
integer, intent(in)  IG 
)

Definition at line 886 of file swancom2.f90.

886 
887 ! (This subroutine has not been fully tested yet)
888 !
889 !****************************************************************
890 !
891  USE swcomm3
892  USE swcomm4
893  USE ocpcomm4
894  USE mod_prec
895  USE all_vars, ONLY : mt,ntsn,nbsn,vx,vy,art2
896 !
897  IMPLICIT NONE
898 !
899 ! 2. Purpose
900 !
901 ! Determine the bottom slope in upwave direction and calculate
902 ! the slope dependent breaking parameter according to Nelson (1987)
903 ! Note that Nelson (1987) is used here since in Nelson (1994a,1994b)
904 ! an error is present in the equation.
905 !
906 ! 3. Method
907 !
908 ! The breaker parameter is given by:
909 !
910 ! Hm / d = 0.55 + 0.88 exp ( -0.012 * cot beta)
911 !
912 ! with beta the angle the bed makes with the horizontal. This
913 ! above equation is only valid for positive slopes (Negative
914 ! slopes were not considered by Nelson. For very steep slopes
915 ! (>0.05 say) a very large breaker parameter is obtained (>>1).
916 !
917 ! To ensure wave breaking in laboratory cases (with very steep
918 ! slopes an upper limit of 0.81 (which corresponds to a bottom
919 ! slope of 0.01) is imposed on the model of Nelson.
920 !
921 ! For negative bottom slopes (not considered by Nelson) a value
922 ! op 0.73 is imposed (which is the average value in Table 2 of
923 ! Battjes and Janssen (1978).
924 !
925  REAL, INTENT(OUT) :: BRCOEF ! variable breaker coefficient
926 
927  REAL, INTENT(IN) :: SPCSIG(MSC)
928  REAL, INTENT(IN) :: AC2(MDC,MSC,0:MT) ! action densities
929  REAL, INTENT(IN) :: ECOS(MDC), ESIN(MDC) ! Cos and Sin of Theta
930  REAL, INTENT(IN) :: DEP2(MT) ! depths at grid points
931 
932 !!$ REAL, INTENT(IN) :: RDX(10), RDY(10)
933  INTEGER, INTENT(IN) :: IG
934 
935 ! 9. STRUCTURE
936 !
937 ! ------------------------------------------------------------
938 ! Calculate total energy per direction for all frequencies
939 ! determine action density per direction weighted with cos/sin
940 ! determine mean propagation direction of energy
941 ! ------------------------------------------------------------
942 ! calculate the depth derivative in the mean wave direction
943 ! according to dd/ds (see also subroutine SPROSD)
944 ! calculate the slope dependend breaking coefficient
945 ! ------------------------------------------------------------
946 ! End of NELSON
947 ! -------------------------------------------------------------
948 !
949 !************************************************************************
950 !
951  INTEGER :: ID ,IS ! counters
952  INTEGER :: J,I1,I2
953  REAL(SP) :: F1
954 !
955 !
956  REAL :: ETOTS,EEX,EEY,EAD,SIGMA1,COSDIR,SINDIR,DDDX,DDDY,DDDS,DETOT
957 !
958 ! *** determine the average wave direction ***
959 !
960  eex = 0.
961  eey = 0.
962  etots = 0.
963  DO id = 1, mdc
964  ead = 0.
965  DO is = 1, msc
966  sigma1 = spcsig(is)
967  detot = sigma1**2 * ac2(id,is,kcgrd(1))
968  ead = ead + detot
969  END DO
970  etots = etots + ead
971  eex = eex + ead * ecos(id)
972  eey = eey + ead * esin(id)
973  END DO
974 !
975  IF(etots > 0.)THEN
976  cosdir = eex / etots
977  sindir = eey / etots
978  ELSE
979  cosdir = 1.
980  sindir = 0.
981  END IF
982 !
983 ! *** Determine bottom slope in average wave propagation direction ***
984 !
985 ! DDDX = RDX(1) * (DEP2(KCGRD(1)) - DEP2(KCGRD(2))) &
986 ! + RDX(2) * (DEP2(KCGRD(1)) - DEP2(KCGRD(3)))
987 ! DDDY = RDY(1) * (DEP2(KCGRD(1)) - DEP2(KCGRD(2))) &
988 ! + RDY(2) * (DEP2(KCGRD(1)) - DEP2(KCGRD(3)))
989  dddx = 0.0_sp
990  dddy = 0.0_sp
991 
992  DO j=1,ntsn(ig)-1
993  i1 = nbsn(ig,j)
994  i2 = nbsn(ig,j+1)
995  f1 = 0.50_sp*(dep2(i1)+dep2(i2))
996  dddx = dddx + f1*(vy(i1)-vy(i2))
997  dddy = dddy + f1*(vx(i2)-vx(i1))
998  END DO
999  dddx = dddx/art2(ig)
1000  dddy = dddy/art2(ig)
1001 
1002 !
1003  ddds = -1. * ( dddx * cosdir + dddy * sindir )
1004 !
1005 ! *** calculate breaking coefficient according to Nelson (1987) ***
1006 !
1007  IF(ddds >= 0.)THEN
1008  ddds = max( 1.e-6 , ddds)
1009  brcoef = psurf(4) + psurf(7) * exp( -psurf(8) / ddds )
1010  brcoef = min( psurf(5) , brcoef )
1011  ELSE
1012  brcoef = psurf(6)
1013  END IF
1014 !
1015 ! PSURF(2) = BRKVAR deleted
1016 ! PSURF(2) is no longer used to transmit br. coefficient
1017 
1018  RETURN
integer, dimension(:), allocatable, target ntsn
Definition: mod_main.f90:1023
real, dimension(:), allocatable, save spcsig
Definition: swmod2.f90:767
real, dimension(msurf) psurf
Definition: swmod1.f90:2135
integer mt
Definition: mod_main.f90:78
real, dimension(:,:,:), allocatable ac2
real(sp), dimension(:), allocatable, target art2
Definition: mod_main.f90:1011
integer mdc
Definition: swmod1.f90:1672
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
integer, dimension(micmax) kcgrd
Definition: swmod1.f90:1670
integer msc
Definition: swmod1.f90:1673
integer, dimension(:,:), allocatable, target nbsn
Definition: mod_main.f90:1030

◆ frabre()

subroutine frabre ( real  HM,
real  ETOT,
real  QBLOC 
)

Definition at line 225 of file swancom2.f90.

225 !
226 !****************************************************************
227 !
228 ! to compute the fraction of breaking waves in point ix,iy
229 ! of the computational grid
230 !
231 ! Method (updated...)
232 !
233 ! The fraction of breaking waves in a point ix,iy is given by
234 ! the implicit relation:
235 !
236 ! 1 - Qb ETOT
237 ! ------ = -8 * -----
238 ! ln Qb HM**2
239 !
240 ! from which Qb can be found by solving the equation:
241 !
242 ! ETOT
243 ! F = 1 - Qb + 8 * ---- * ln(Qb) = 0.
244 ! 2
245 ! HM
246 !
247 ! The following appproximation is applied:
248 !
249 ! 2
250 ! (1)| B = sqrt( 8 ETOT/HM ), i.e. B = Hrms/HM
251 !
252 !
253 ! | Qo = 0. B <= 0.5
254 ! (2)| 2
255 ! | Qo = ( 2B -1 ) 0.5 < B <= 1
256 !
257 !
258 ! applying the Newton-Raphson procedure (for 0.2<B<1.0):
259 !
260 ! | Qb = 0. B <= 0.2
261 ! |
262 ! | 2
263 ! | 2 Qo - exp((Qo-1)/B )
264 ! (3)| Qb = Qo - B ------------------ 0.2 < B < 1.0
265 ! | 2 2
266 ! | B - exp((Qo-1)/B )
267 ! |
268 ! |
269 ! | Qb = 1. B >= 1.0
270 ! |
271 !
272  USE swcomm4
273  USE ocpcomm4
274 !
275  IMPLICIT NONE
276 
277  REAL :: ETOT, HM, QBLOC
278  INTEGER :: IENT
279  REAL :: B, B2, QO, Z
280 
281  IF((hm > 0.) .AND. (etot >= 0.))THEN
282  b = sqrt(8. * etot / (hm*hm) )
283  ELSE
284  b = 0.0
285  END IF
286 !
287  IF(b <= 0.5)THEN
288  qo = 0.
289  ELSE IF(b <= 1.0)THEN
290  qo = (2.*b - 1.)**2
291  END IF
292 !
293  IF(b <= 0.2)THEN
294  qbloc = 0.0
295  ELSE IF(b < 1.0)THEN
296 !
297 ! *** second iteration to find Qb ***
298 !
299  b2 = b*b
300  z = exp((qo-1.)/b2)
301  qbloc = qo - b2 * (qo-z)/(b2-z)
302  ELSE
303  qbloc = 1.0
304  END IF
305 !
306  RETURN
Here is the caller graph for this function:

◆ sbot()

subroutine sbot ( real  ABRBOT,
real, dimension(mt)  DEP2,
real, dimension(mdc)  ECOS,
real, dimension(mdc)  ESIN,
real, dimension(msc,icmax)  KWAVE,
real, dimension(msc)  SPCSIG,
real, dimension(mt)  UBOT,
real, dimension(mt)  UX2,
real, dimension(mt)  UY2,
integer, dimension(msc)  IDCMIN,
integer, dimension(msc)  IDCMAX,
integer  ISSTOP,
logical  VARFR,
real, dimension(mt)  FRCOEF,
integer  IG,
real, dimension(mdc,msc)  IMATRA 
)

Definition at line 16 of file swancom2.f90.

16 ! (This subroutine has been tested only for case IBOT = 1)
17 !
18 !****************************************************************
19 !
20 ! Computation of the source terms due to bottom friction
21 !
22 ! Method
23 !
24 ! In SWAN several bottom dissipation models are computed, i.e.:
25 !
26 ! IBOT = 1 Jonswap bottom friction model
27 ! IBOT = 2 Collins bottom friction model
28 ! IBOT = 3 Madsen bottom friction model (see Tolman)
29 !
30 ! Both methods are implemented in SWAN and the user has to make
31 ! a choice in the input file.
32 !
33 ! 1. Jonswap model:
34 ! -----------------
35 !
36 ! The bottom interaction term SEbf(s,d) is supposed to take the
37 ! Jonswap form (Hasselman et al. 1973):
38 ! 2
39 ! sigma E(s,d)
40 ! SEbf = -GAMMA ----------------
41 ! 2 2
42 ! g sinh (kD)
43 ! 2 -3
44 ! where GAMMA is the decay parameter ,(default GAMMA = 0.067 m s ).
45 ! In the Jonswap form the current velocities are not taken into
46 ! account.
47 !
48 ! 2. COLLINS model:
49 ! -----------------
50 !
51 ! The energy dissipation due to bottom friction is modelled
52 ! according the quadratic friction law:
53 ! 2
54 ! SE = Tau * |U|
55 !
56 ! which for a spectrum can be written as:
57 ! 2
58 ! sigma
59 ! SE(s,d)= - ---------------- * (Cfw.Ub + Cfc.Uc) * E(s,d)
60 ! 2
61 ! g sinh (K(s) * D)
62 !
63 ! Ub is the velocity due to the wave at the bottom
64 !
65 ! The current velocity is Uc
66 !
67 ! 2. MADSEN formulation:
68 ! ----------------------
69 !
70 ! The bottom dissipation applying Madsen formulation is as
71 ! follows:
72 !
73 ! fw [n - 1/2] UBR E(s,d)
74 ! [1] Sdsb(s,d) = - ------------------------
75 ! D
76 !
77 ! in which :
78 ! 2
79 ! s * D
80 ! [1a] (n - 1/2) = -------------
81 ! 2
82 ! 2 g sinh (kD)
83 !
84 ! UBOT(IX,IY) is computed in the subroutine SINTGRL. The friction
85 ! factor fw is estimated using the formulation of Jonsson (1963,
86 ! 1966a):
87 !
88 ! 1 1 Ab,r
89 ! [2] -------- + log { ---------- } = mf + log { ----- }
90 ! 4 sqrt(fw) 10 4 sqrt(fw) 10 Kn
91 !
92 ! with:
93 !
94 ! 2 // 1
95 ! [3] Ab,r = 2 * // -------------- E(s,d) ds dd
96 ! // 2
97 ! sinh (kD)
98 !
99 ! with: Ab,r is the representative near bottom excursion
100 ! amplitude
101 ! Kn equivalent roughness
102 ! mf constant ( mf = -0.08) (determined by Jonsson
103 ! and Carlssen 1976 )
104 !
105 ! [2] is only valid for Ab,r/Kn larger than approximately 1.
106 ! For smaller values a constant value of fw is used (fw = 0.3
107 ! for Ab,r/Kn < 1.57 )
108 !
109  USE swcomm3
110  USE swcomm4
111  USE ocpcomm4
112 ! USE ALL_VARS, ONLY : MT,AC2
113  USE vars_wave, ONLY : mt,ac2
114 
115  IMPLICIT NONE
116 
117  REAL SPCSIG(MSC)
118  INTEGER ID,IS,ISSTOP,J,IDDUM,IG
119  REAL :: XDUM,KD,SBOTEO,CFBOT,FACB,CFW,FW,CURR,UC,ABRBOT,ADUM,CDUM,DDUM
120  LOGICAL VARFR
121  REAL :: DEP2(MT),ECOS(MDC),ESIN(MDC),IMATDA(MDC,MSC),IMATRA(MDC,MSC), &
122  KWAVE(MSC,ICMAX),PLBTFR(MDC,MSC,NPTST),UBOT(MT), &
123  UX2(MT),UY2(MT),DISSC1(MDC,MSC),FRCOEF(MT)
124  INTEGER :: IDCMIN(MSC),IDCMAX(MSC)
125  REAL :: AKN
126 
127  IF(ibot >= 1 .AND. dep2(ig) > 0.)THEN
128  IF(ibot == 1)THEN
129 !
130 ! *** Jonswap model ***
131 !
132 ! PBOT(3) = GAMMA (a) in the Jonswap equation,
133 !
134  cfbot = pbot(3) / grav_w**2
135 
136 ! CFBOT = CFBOT*10.0 !JQI added
137  ELSE IF (ibot == 2)THEN
138 !
139 ! *** Collins model ***
140 !
141 ! PBOT(2) = [cfw]
142 !
143  IF(varfr)THEN
144  cfw = frcoef(ig)
145  ELSE
146  cfw = pbot(2)
147  ENDIF
148  cfbot = cfw * ubot(ig) / grav_w
149  ELSE IF(ibot == 3)THEN
150 !
151 ! *** Madsen model ***
152 !
153  IF(varfr)THEN
154  akn = frcoef(ig)
155  ELSE
156  akn = pbot(5)
157  ENDIF
158 !
159 ! *** PBOT(4) = Mf ***
160 ! *** AKN = PBOT(5) = [kn] (roughness) ***
161 !
162  IF((abrbot/akn) > 1.57)THEN
163  xdum = pbot(4) + log10( abrbot / akn )
164 !
165 ! *** solving the implicit equation using a Newton ***
166 ! *** Rapshon iteration proces : a + log a = b ***
167 ! *** the start value for ADUM = 0.3 because 0.3626 ***
168 ! *** is the minimum value of ADUM with b=-0.08. ***
169 !
170  adum = 0.3
171  DO j = 1, 50
172  cdum = adum
173  ddum = ( adum + log10(adum) - xdum ) / ( 1.+ ( 1. / adum) )
174  adum = adum - ddum
175  IF(abs(cdum - adum) < 1.e-4) GOTO 29
176  END DO
177  WRITE(*,*) ' error in iteration fw: Madsen formulation'
178 29 CONTINUE
179 ! 1 1
180 ! *** computation of FW --> A = ----- --> FW = -----
181 ! 4 uFW 16 A**2
182  fw = 1. / (16. * adum**2)
183  ELSE
184  fw = 0.3
185  ENDIF
186  cfbot = ubot(ig) * fw / (sqrt(2.) * grav_w)
187  ENDIF
188 
189  DO is = 1, isstop
190  kd = kwave(is,1) * dep2(ig)
191  IF(kd < 10.)THEN
192  facb = cfbot * (spcsig(is) / sinh(kd)) **2
193 !
194  DO iddum = idcmin(is) , idcmax(is)
195  id = mod( iddum - 1 + mdc , mdc ) + 1
196 !
197  sboteo = facb
198  IF(ibot == 2 .AND. icur == 1 .AND. pbot(1) > 0.)THEN
199 ! additional dissipation due to current, seldom used
200  curr = ux2(ig)*ecos(id) + uy2(ig)*esin(id)
201  uc = abs(curr)
202 ! PBOT(1) = [cfc]
203  sboteo = facb + pbot(1) * uc * (spcsig(is) / sinh(kd)) **2
204  END IF
205 !
206 ! *** store the results in the array IMATDA ***
207 !
208  imatra(id,is) = imatra(id,is) - sboteo*ac2(id,is,ig)
209  imatda(id,is) = imatda(id,is) + sboteo
210 ! IF (TESTFL) PLBTFR(ID,IS,IPTST) = -1.* SBOTEO
211 ! DISSC1(ID,IS) = DISSC1(ID,IS) + SBOTEO
212  END DO !IDDUM
213  END IF
214  END DO !IS
215 !
216  ENDIF
217 !
218  RETURN
real, dimension(:), allocatable, save spcsig
Definition: swmod2.f90:767
integer mt
Definition: mod_main.f90:78
integer icur
Definition: swmod1.f90:2125
real grav_w
Definition: swmod1.f90:1721
real, dimension(:,:,:), allocatable ac2
integer ibot
Definition: swmod1.f90:2125
integer mdc
Definition: swmod1.f90:1672
logical varfr
Definition: swmod1.f90:1365
real, dimension(mbot) pbot
Definition: swmod1.f90:2133

◆ ssurf()

subroutine ssurf ( real  ETOT,
real  HM,
real  QB,
real  SMEBRK,
real, dimension(mdc,msc)  IMATRA,
real, dimension(mdc,msc)  IMATDA,
integer, dimension(msc)  IDCMIN,
integer, dimension(msc)  IDCMAX,
real, dimension(mdc,msc,nptst)  PLWBRK,
integer  ISSTOP,
integer  IG 
)

Definition at line 314 of file swancom2.f90.

314 !
315 !****************************************************************
316 ! Computation of the source term due to wave breaking.
317 ! White capping is not taken into account
318 !
319 ! Method
320 !
321 ! The source term for surf breaking is implemented following
322 ! the approach of Battjes/Janssen (1978) for the energy dissipation:
323 !
324 ! Alpha - 2 - SMEBRK
325 ! Dtot = ---- Qb * f * Hm with f = ------
326 ! 4 2 * Pi
327 !
328 ! Now the source term is:
329 !
330 ! SIGMA * AC2(ID,IS,IX,IY)
331 ! Sbr = - Dtot * ------------------------ =
332 ! Etot
333 !
334 !
335 ! Alpha * SMEBRK * Qb * Hm * Hm SIGMA * AC2(ID,IS,IX,IY)
336 ! = - ------------------------------ * -------------------------
337 ! 8 * Pi Etot
338 !
339 !
340 ! = WS * SIGMA * AC2(ID,IS,IX,IY) = WS * E
341 !
342 !
343 ! with
344 !
345 ! Alpha = PSURF(1) ;
346 !
347 ! SMEBRK Qb
348 ! WS = Alpha ------ -- ;
349 ! Pi BB
350 ! 2
351 ! BB = 8 Etot / Hm = - (1 - Qb) / ln (Qb) ;
352 !
353 !
354 ! The local maximum wave height Hm and mean frequency SMEBRK are computed
355 ! in subroutine SINTGRL.
356 ! The fraction of breaking waves Qb is calculated in the subroutine FRABRE
357 !
358 ! The new value for the dissipation is computed implicitly using
359 ! the last computed value for the action density Nold (at the spatial
360 ! gridpoint under consideration).
361 !
362 ! Sbr = WS * N
363 !
364 ! = Sbr_new + (d Sbr/d N) (Nnew - Nold)
365 !
366 ! = WS * Nnew + SbrD * (Nnew - Nold)
367 !
368 ! = (WS + SbrD)* Nnew - SbrD * Nold
369 !
370 ! = SURFA1 * Nnew - SURFA0 * Nold
371 !
372 ! In order to do this we need the derivative
373 ! of the source term Sbr to the action density N
374 !
375 ! d Sbr d WS
376 ! SbrD = ----- = ---- * N + WS
377 ! d N d N
378 !
379 ! Since BB and SMEBRK * N are proportional, we have
380 !
381 ! d Sbr d WS SMEBRK (d Qb/ d BB) *BB - Qb
382 ! ----- = ---- * BB + WS = Alpha ------ --------------------- * BB + WS =
383 ! d N d BB Pi sqr(BB)
384 !
385 !
386 ! SMEBRK d Qb
387 ! Alpha ------ ----
388 ! Pi d BB
389 !
390 ! With:
391 !
392 ! d Qb 1
393 ! ---- = ------------- ;
394 ! d BB (d BB / d Qb)
395 !
396 ! 2
397 ! d Qb ln (Qb)
398 ! ---- = ---------------------------
399 ! d BB ln (Qb) + (1 - Qb) (1 / Qb)
400 !
401 ! Qb (1 - Qb)
402 ! = ------------ ;
403 ! BB (BB - Qb)
404 !
405 ! ------------------------------------------------------------
406 ! Get HM, QB and ETOT from the subroutine SINTGRL
407 ! For spectral direction IS and ID do,
408 ! get the mean energy frequency average over the full spectrum
409 ! If ETOT > 0 then
410 ! compute source term for energy dissipation SURFA0 and SURFA1
411 ! Else
412 ! source term for wave breaking is 0.
413 ! End if
414 ! ----------------------------------------------------------
415 ! Compute source terms for energy averaged frequency
416 ! Store results in the arrays IMATDA and IMATRA
417 ! ------------------------------------------------------------
418  USE swcomm3
419  USE swcomm4
420  USE ocpcomm4
421 ! USE ALL_VARS, ONLY : MT,AC2
422  USE vars_wave, ONLY : mt,ac2
423 !
424  IMPLICIT NONE
425 
426  INTEGER :: ISSTOP,IDCMIN(MSC),IDCMAX(MSC)
427  REAL :: DISSC0(MDC,MSC),DISSC1(MDC,MSC), &
428  IMATDA(MDC,MSC),IMATRA(MDC,MSC),PLWBRK(MDC,MSC,NPTST)
429  REAL :: ETOT,HM,QB,SMEBRK
430  INTEGER :: ID,IDDUM,IENT,IS,IG
431  DOUBLE PRECISION BB,DIS0,SbrD,SURFA0,SURFA1,WS
432 !
433 ! ALFA = PSURF(1) <default = 1.0>
434 !
435  bb = 8. * dble(etot) / ( dble(hm)**2 )
436 ! SURFA0 = 0.
437 ! SURFA1 = 0.
438 ! IF(REAL(BB) > 0. .AND. REAL(ABS(BB - DBLE(QB))) > 0.)THEN
439 ! IF(BB < 1.)THEN
440 ! WS = ( DBLE(PSURF(1)) / DBLE(PI_W)) * DBLE(QB) * DBLE(SMEBRK) / BB
441 ! SbrD = WS * (1. - DBLE(QB)) / (BB - DBLE(QB))
442 ! ELSE
443 ! WS = ( DBLE(PSURF(1)) / DBLE(PI_W)) * DBLE(SMEBRK)
444 ! SbrD = 0.
445 ! END IF
446 ! SURFA0 = SbrD
447 ! SURFA1 = WS + SbrD
448 ! ELSE
449 ! SURFA0 = 0.
450 ! SURFA1 = 0.
451 ! END IF
452  IF(real(bb) > 0. .AND. real(abs(bb - dble(qb))) > 0.)THEN
453  ws = ( dble(psurf(1)) / dble(pi_w)) * dble(qb) * dble(smebrk) / bb
454  ELSE
455  ws = 0.
456  ENDIF
457 
458 !
459 ! *** store the results for surf wave breaking ***
460 ! *** in the matrices IMATDA and IMATRA ***
461 !
462  DO is = 1, isstop
463  DO iddum = idcmin(is), idcmax(is)
464  id = mod( iddum - 1 + mdc , mdc ) + 1
465  imatda(id,is) = imatda(id,is) + real(ws)
466  dis0 = ws * dble(ac2(id,is,ig))
467  imatra(id,is) = imatra(id,is) - real(dis0)
468  END DO
469  END DO
470 
471 
472  RETURN
real, dimension(msurf) psurf
Definition: swmod1.f90:2135
integer mt
Definition: mod_main.f90:78
real, dimension(:,:,:), allocatable ac2
integer mdc
Definition: swmod1.f90:1672
real pi_w
Definition: swmod1.f90:1721

◆ swcap()

subroutine swcap ( real, dimension(mdc,6), intent(in)  SPCDIR,
real, dimension(msc), intent(in)  SPCSIG,
real, dimension(msc,micmax), intent(in)  KWAVE,
integer, dimension(msc), intent(in)  IDCMIN,
integer, dimension(msc), intent(in)  IDCMAX,
integer, intent(in)  ISSTOP,
real, intent(in)  ETOT,
real, dimension(mdc,msc), intent(inout)  IMATDA,
real, dimension(mdc,msc), intent(inout)  IMATRA,
real, dimension(mdc,msc,nptst), intent(out)  PLWCAP,
real, dimension(msc,micmax), intent(in)  CGO,
real, intent(in)  UFRIC,
real, dimension(mt), intent(in)  DEP2,
real, dimension(mdc,msc), intent(inout)  DISSIP,
real, dimension(mdc,msc), intent(inout)  DISIMP,
integer  IG 
)

Definition at line 482 of file swancom2.f90.

482 ! (This subroutine has not been fully tested. Only tested for
483 ! case IWCAP = 2)
484 !
485 !****************************************************************
486 !
487 ! Calculates the dissipation due to whitecapping
488 !
489 ! Method
490 !
491 ! Whitecapping dissipation is formulated as follows:
492 !
493 ! S_wc(sig,th) = - C_wc E(sig,th)
494 !
495 ! where the coefficient C_wc has four basic forms:
496 !
497 ! C_wc1 = C_K sig~ (k/k~): According to Komen (generalised)
498 ! C_wc2 = C_BJ sig~ (k/k~): According to Battjes-Janssen (modified)
499 ! C_wc3 = C_LH : According to Longuet Higgins (1969)
500 ! C_wc4 = C_CSM : According to cumulative steepness
501 ! method (Ris et al. (1999) and Donelan (1999))
502 !
503 ! In these formulations C_K is defined as (Komen; 1994 p. 145):
504 !
505 ! n1 n2
506 ! C_K = C1 [(1-delta) + delta (k/k~) ] (S~/S_PM)
507 !
508 ! where C1, delta, n1 and n2 can be varied
509 !
510 !
511 ! C_BJ is defined as:
512 !
513 ! 2
514 ! alpha Hm Qb
515 ! C_BJ = -----------
516 ! 8 Pi m0
517 !
518 ! where alpha can be varied.
519 !
520 ! for Hrms > Hm the formulation changes in a limit to (Hrms->Hm; Qb->1):
521 !
522 ! alpha
523 ! C_BJ = -----
524 ! Pi
525 !
526 ! and C_LH is defined as (Komen; 1994 p. 151-152):
527 !
528 ! 4 2 2
529 ! C_LH = C3 Sqrt[(m0 sig0 )/g ] exp(A) sig0 (sig/sig0)
530 !
531 ! where
532 ! 2 2 4 2 2
533 ! A = -1/8 [1-eps ] [g /(m0 sig0 )] with [1-eps ] = [m2 ] / [m0 m4]
534 !
535 ! and C3 can be varied
536 !
537 !
538 ! Cumulative steepness method. Basic idea is that dissipation depends
539 ! on the steepness of the wave spectrum at and below a particular
540 ! frequency. Details can be found in "SWAN fysica plus" (2002),
541 ! report H3937/A832, implemented by Delf Hydraulics and Alkyon by
542 ! order of RIKZ/RWS as a part of the project HR-Ontwikkeling.
543 ! 40.41
544 ! Recent modifications are described in: 40.41
545 ! Hurdle, D.P., and G.Ph. van Vledder, 2004: Improved spectral wave 40.41
546 ! modelling of white-capping dissipation in swell sea systems. Proc. 40.41
547 ! Offshore Mechanics, Arctic Engineering Conference, June 2004, 40.41
548 ! Vancouver, Canada, paper OMAE2004-51562. 40.41
549 ! 40.41
550 ! Default values: C_st = 4 40.41
551 ! m = 2 40.41
552 ! 40.41
553 ! C_CSM = A*C_st S(sig,th) 40.41
554 !
555 ! where
556 !
557 ! C_st is a tuneable coefficient and
558 !
559 ! S(sig,th) = integrals from 0 to sig and from 0 to 2pi of
560 !
561 ! k^2 |cos(th-th')|^m E(sig,th) dsig dth'
562 !
563 ! where coefficient m controls the directional dependence in case
564 ! of straining mechanism (if dominant then m = 2 else m > 10) and
565 ! th is the actual direction where straining mechanism takes
566 ! place.
567 ! 40.41
568 ! A is a normalisation coefficient computed 40.41
569 ! 40.41
570 ! 1 GAMMA(0.5*m+1.) 40.41
571 ! A = -------- ---------------- 40.41
572 ! SQRT(PI) GAMMA(0.5*m+0.5) 40.41
573 !
574 ! In these equations the variables have the following meaning:
575 !
576 ! Hm : Maximum wave height
577 ! Hrms : Root mean square of the wave heights
578 ! eps^2: Measure for the spectral bandwidth
579 ! m0 : Total wave energy density (=ETOT)
580 ! m2 : Second moment of the variance spectrum (=ETOT2)
581 ! m4 : Fourth moment of the variance spectrum (=ETOT4)
582 ! k : Wave number (=KWAVE(IS,1))
583 ! k~ : Mean wave number
584 ! Qb : Fraction of breaking waves
585 ! sig : Frequency (=SPCSIG(IS))
586 ! sig0 : Average zero crossing frequency
587 ! sig~ : Mean frequency
588 ! S~ : Overall steepness (STP_OV)
589 ! S_PM : Overall steepness for a Pierson-Moskowitz spectrum
590 ! th : direction theta (=SPCDIR(ID))
591 !
592 ! ------------------------------------------------------------
593 ! Calculate needed parameters
594 ! ------------------------------------------------------------
595 ! If IWCAP = 1, 2, or 5; Calculate C_K
596 ! If IWCAP = 4 or 5; Calcualte C_BJ
597 ! If IWCAP = 3; Calculate C_LH
598 ! If IWCAP = 6; Calculate cumulative steepness spectrum
599 ! IF IWCAP = 7; Calculate with Alves and Banner (2003)
600 ! ------------------------------------------------------------
601 ! For frequency dependent part of the spectrum
602 ! Calculate dissipation term due to whitecapping
603 ! ------------------------------------------------------------
604 ! For the whole frequency domain
605 ! Fill the matrices and PLWCAP-array
606 ! ------------------------------------------------------------
607 ! End of SWCAP
608 ! ------------------------------------------------------------
609  USE swcomm3
610  USE swcomm4
611  USE ocpcomm4
612  USE m_wcap
613 ! USE ALL_VARS, ONLY : MT,AC2
614  USE vars_wave, ONLY : mt,ac2
615 
616  IMPLICIT NONE
617 
618  INTEGER, INTENT(IN) :: ISSTOP, IDCMIN(MSC), IDCMAX(MSC)
619  REAL, INTENT(IN) :: DEP2(MT)
620  REAL, INTENT(IN) :: ETOT
621  REAL, INTENT(IN) :: KWAVE(MSC,MICMAX)
622  REAL, INTENT(IN) :: SPCDIR(MDC,6), SPCSIG(MSC)
623  REAL, INTENT(OUT) :: PLWCAP(MDC,MSC,NPTST)
624  REAL, INTENT(IN OUT) :: IMATDA(MDC,MSC), IMATRA(MDC,MSC)
625  REAL, INTENT(IN OUT) :: DISSIP(MDC,MSC), DISIMP(MDC,MSC)
626  REAL, INTENT(IN) :: UFRIC
627  REAL, INTENT(IN) :: CGO(MSC,MICMAX)
628 
629  INTEGER, SAVE :: IENT = 0
630  INTEGER :: ID, IDDUM, IS, ID1, ID2, IF, IL, MXWCP,IG
631  REAL :: A, C_BJ, HM, HRMS, N1, N2
632  REAL :: QB_WC, SIG0, STP_OV, STP_PM
633  REAL :: DDIF, DELTA, DSTEEP, EBIN, XFAC
634  REAL :: CPOW, CTOT, GAMMA
635  REAL :: BINSIZE
636  REAL, ALLOCATABLE :: C_K(:), C_LH(:), WCAP(:), WCIMPL(:)
637  REAL, ALLOCATABLE :: CUMSTP(:,:), DSIGMA(:)
638  REAL, ALLOCATABLE :: FCOS(:)
639  REAL :: B, P
640  REAL :: EF(MSC)
641  CHARACTER*20 NUMSTR, CHARS
642  CHARACTER*80 MSGSTR
643 
644  mxwcp = 7
645  IF(iwcap > mxwcp)THEN
646 !
647 ! Error message
648 !
649  chars = numstr(mxwcp+1,rnan,'(I1)')
650  CALL txpbla(chars,IF,il)
651  msgstr = 'Value for IWCAP should be less than '// chars(if:il)
652  CALL msgerr ( 4, msgstr )
653  RETURN
654  END IF
655 !
656 ! Initialisation
657 !
658  IF(etot <= 0.) RETURN
659  IF(etot2 <= 0.) RETURN
660  IF(etot4 <= 0.) RETURN
661  IF(actot <= 0.) RETURN
662  IF(edrktot <= 0.) RETURN
663 !
664  ALLOCATE (c_k(msc), c_lh(msc), wcap(msc), wcimpl(msc))
665  ALLOCATE (cumstp(0:msc,mdc), dsigma(1:msc))
666  ALLOCATE (fcos(1:mdc))
667  wcimpl(1:msc) = 0.
668 !
669 ! Calculate coefficients
670 !
671  IF((iwcap == 1) .OR. (iwcap == 2) .OR. (iwcap == 5))THEN
672 !
673 ! Calculate C_K
674 !
675  stp_ov = km_wam * sqrt(etot)
676  stp_pm = sqrt(pwcap(2))
677  n1 = pwcap(11)
678  n2 = 2. * pwcap(9)
679  c_k(:) = pwcap(1) * (1. - pwcap(10) + &
680  pwcap(10) * (kwave(:,1) / km_wam)**n1) * &
681  (stp_ov / stp_pm)**n2
682 !
683  ENDIF
684 !
685  IF((iwcap == 4) .OR. (iwcap == 5))THEN
686 !
687 ! Calculate values for Hm and Qb
688 !
689  hrms = sqrt(8. * etot)
690  IF (iwcap.EQ.4) hm = pwcap(6) / km01
691  IF (iwcap.EQ.5) hm = pwcap(6) / (pwcap(8) * km_wam)
692  CALL frabre(hm, etot, qb_wc)
693 !
694 ! Calculate C_BJ
695 !
696  IF(hrms >= hm)THEN
697  c_bj = pwcap(7) / pi_w
698  ELSE IF(hrms > 0.)THEN
699  c_bj = (pwcap(7) * hm**2 * qb_wc) / (pi_w * hrms**2)
700  ELSE
701  c_bj = 0.
702  END IF
703  ENDIF
704 !
705  IF(iwcap == 3)THEN
706 !
707 ! Calculate C_LH
708 !
709  sig0 = sqrt(etot2 / etot)
710 !
711 ! A = -(1./8.)*(ETOT2**2/(ETOT*ETOT4))*(GRAV_W**2/(ETOT*SIG0**4))
712 ! rewrite to prevent underflow
713 !
714  a = -(1./8.) * grav_w**2 / etot4
715  DO is=1, isstop
716 ! C_LH(IS) = PWCAP(5) * SQRT((ETOT * SIG0**4) / GRAV_W**2) *
717 ! & EXP(A) * SIG0 * (SPCSIG(IS) / SIG0)**2
718 ! rewrite to prevent underflow:
719 !
720  c_lh(is) = pwcap(5) * exp(a) * sqrt(etot2) * spcsig(is)**2 / grav_w
721  END DO
722  END IF
723 !
724 ! In case of cumulative steepness method, calculate its spectrum
725 !
726  IF(iwcap == 6)THEN
727  xfac = (spcsig(3)-spcsig(1))/(2.*spcsig(2))
728  dsigma(:) = xfac*spcsig(:)
729  delta = spcdir(2,1)-spcdir(1,1)
730 !
731 ! --- precompute cos dependence
732 !
733  DO id1 = 1, mdc
734  ddif = real(id1-1)*delta
735  fcos(id1) = (abs(cos(ddif)))**pwcap(13)
736  END DO
737 !
738 ! --- compute normalisation coefficient
739 !
740  cpow = pwcap(13)
741  IF(cpow > 10)THEN
742  ctot = sqrt(cpow/(2.*pi_w))*(1.+0.25/cpow)
743  ELSE
744  ctot = 1./sqrt(pi_w)*gamma(0.5*cpow+1.)/gamma(0.5*cpow+0.5)
745  END IF
746 !
747  cumstp = 0.
748  DO is = 1,isstop
749  binsize = spcsig(is)*delta*dsigma(is)
750  DO id1 = 1,mdc
751  cumstp(is,id1) = cumstp(is-1,id1)
752  DO id2 = 1,mdc
753  ebin= ac2(id2,is,ig)*binsize
754 ! EBIN= AC2(ID2,IS,kcgrd(1))*BINSIZE
755  dsteep = kwave(is,1)**2*ebin*fcos(abs(id1-id2)+1)
756  cumstp(is,id1) = cumstp(is,id1) + dsteep
757  END DO
758  END DO
759  END DO
760  cumstp = pwcap(12)*cumstp
761  cumstp = cumstp*ctot
762  END IF
763 !
764 ! Calculate dissipation according to Alves & Banner (2003)
765 !
766  IF(iwcap == 7)THEN
767 !
768 ! Loop to calculate B(k)
769 !
770  DO is = 1, isstop
771 !
772 ! Calculate E(f)
773 !
774  ef(is) = 0.
775  DO id = 1,mdc
776  ef(is) = ef(is) + ac2(id,is,ig)*spcsig(is)*pi2_w*ddir
777  END DO
778 !
779 ! Calculate saturation spectrum B(k) from E(f)
780 !
781  b = (1./pi2_w) * cgo(is,1) * kwave(is,1)**3 * ef(is)
782 !
783 ! Calculate exponent P of the relative saturation (B/Br)
784 !
785  pwcap(10)= 3. + tanh(25.76*(ufric*kwave(is,1)/spcsig(is)-0.1))
786  p = 0.5*pwcap(10)*(1. + tanh( 10.*( (b/pwcap(12))**0.5 - 1.)))
787 !
788 ! Calculate WCAP(IS) from B(k) and P
789 !
790  stp_ov = km_wam * sqrt(etot)
791  wcap(is) = pwcap(1)*(b/pwcap(12))**(p/2.) * &
792  stp_ov**pwcap(9) * (kwave(is,1)/km_wam)**pwcap(11) * &
793  (grav_w**(0.5)*kwave(is,1)**(0.5)/spcsig(is))**(pwcap(10)/2-1) * &
794  grav_w**(0.5)*kwave(is,1)**(0.5)
795  END DO
796  END IF
797 !
798  IF(iwcap < 6)THEN
799 !
800 ! Calculate the whitecapping source term WCAP(IS)
801 !
802  DO is=1, isstop
803  IF((iwcap == 1) .OR. (iwcap == 2) .OR. &
804  ((iwcap == 5) .AND. (c_bj <= c_k(is))))THEN
805  wcap(is) = c_k(is) * sigm_10 * (kwave(is,1) / km_wam)
806  ELSE IF(iwcap == 3)THEN
807  wcap(is) = c_lh(is)
808  ELSE IF((iwcap == 4) .OR. ((iwcap == 5) .AND. (c_bj >= c_k(is))))THEN
809  IF(iwcap == 4) wcap(is) = c_bj*sigm01 *(kwave(is,1)/km01 )
810  IF(iwcap == 5) wcap(is) = c_bj*sigm_10*(kwave(is,1)/km_wam)
811 !
812 ! Calculate a term that is added to both sides of the equation to compensate
813 ! for the strong non-linearity in the fraction of breaking waves Qb
814 !
815  IF(hrms < hm)THEN
816  wcimpl(is)=wcap(is) * ((1.-qb_wc)/((hrms**2/hm**2)-qb_wc))
817  wcap(is) =wcap(is) + wcimpl(is)
818  END IF
819  ELSE
820  CALL msgerr(2,'Whitecapping is inactive')
821  WRITE (printf,*) 'Occurs in gridpoint: ', ig
822  END IF
823  END DO
824 
825  END IF
826 !
827 ! Fill the diagonal of the matrix and the PLWCAP-array
828 !
829  IF(iwcap /= 6)THEN
830 
831  DO is=1, isstop
832 !
833 ! Only fill the values for the current sweep
834 !
835  DO iddum = idcmin(is), idcmax(is)
836  id = mod(iddum - 1 + mdc, mdc) + 1
837  imatda(id,is) = imatda(id,is) + wcap(is)
838  imatra(id,is) = imatra(id,is) - wcap(is) * ac2(id,is,ig)
839 
840  dissip(id,is) = dissip(id,is) + wcap(is)
841  IF (testfl) plwcap(id,is,iptst) = -1.*(wcap(is)-wcimpl(is))
842  END DO
843  END DO
844 
845  ELSE
846 
847  DO is=1, isstop
848 !
849 ! Only fill the values for the current sweep
850 !
851  DO iddum = idcmin(is), idcmax(is)
852  id = mod(iddum - 1 + mdc, mdc) + 1
853  imatda(id,is) = imatda(id,is) + cumstp(is,id)
854  dissip(id,is) = dissip(id,is) + cumstp(is,id)
855  IF (testfl) plwcap(id,is,iptst) = -1.*cumstp(is,id)
856  END DO
857  END DO
858 
859  END IF
860 !
861 ! Add the implicit part to the right-hand side
862 !
863  IF((iwcap == 4) .OR. (iwcap == 5))THEN
864  DO is=1, isstop
865 !
866 ! Only fill the values for the current sweep
867 !
868  DO iddum = idcmin(is), idcmax(is)
869  id = mod(iddum - 1 + mdc, mdc) + 1
870  imatra(id,is) = imatra(id,is) + wcimpl(is) * ac2(id,is,ig)
871  disimp(id,is) = disimp(id,is) + wcimpl(is) * ac2(id,is,ig)
872  END DO
873  END DO
874  END IF
875 !
876  DEALLOCATE (c_k, c_lh, wcap, wcimpl)
877  DEALLOCATE (cumstp, dsigma, fcos)
878 !
879  RETURN
real, dimension(:), allocatable, save spcsig
Definition: swmod2.f90:767
logical testfl
Definition: swmod1.f90:2274
real, dimension(mwcap) pwcap
Definition: swmod1.f90:2136
integer mt
Definition: mod_main.f90:78
real, dimension(:,:), allocatable, save spcdir
Definition: swmod2.f90:767
real grav_w
Definition: swmod1.f90:1721
real, save sigm01
Definition: swmod2.f90:113
real, dimension(:,:,:), allocatable ac2
real rnan
Definition: swmod1.f90:485
integer mdc
Definition: swmod1.f90:1672
real pi2_w
Definition: swmod1.f90:1722
character *20 function numstr(IVAL, RVAL, FORM)
Definition: swanser.f90:305
subroutine frabre(HM, ETOT, QBLOC)
Definition: swancom2.f90:225
real pi_w
Definition: swmod1.f90:1721
real, save edrktot
Definition: swmod2.f90:105
integer printf
Definition: swmod1.f90:517
real, save etot2
Definition: swmod2.f90:108
real function gamma(XX)
Definition: swanser.f90:788
real, save sigm_10
Definition: swmod2.f90:112
subroutine msgerr(LEV, STRING)
Definition: ocpmix.f90:582
real, save etot4
Definition: swmod2.f90:109
integer msc
Definition: swmod1.f90:1673
subroutine txpbla(TEXT, IF, IL)
Definition: swanser.f90:202
integer iwcap
Definition: swmod1.f90:2129
real, save km_wam
Definition: swmod2.f90:110
integer iptst
Definition: swmod1.f90:2269
real, save actot
Definition: swmod2.f90:104
real ddir
Definition: swmod1.f90:1676
real, save km01
Definition: swmod2.f90:111
Here is the call graph for this function: