WAVEWATCH III  beta 0.0.1
w3sdb1md.F90
Go to the documentation of this file.
1 
8 
9 #include "w3macros.h"
10 !/ ------------------------------------------------------------------- /
24 MODULE w3sdb1md
25  !/
26  !/ +-----------------------------------+
27  !/ | WAVEWATCH III NOAA/NCEP |
28  !/ | J. H. Alves |
29  !/ | H. L. Tolman |
30  !/ | FORTRAN 90 |
31  !/ | Last update : 29-May-2009 |
32  !/ +-----------------------------------+
33  !/
34  !/ 25-Apr-2007 : Origination of module. ( version 3.11 )
35  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
36  !/
37  !/ Copyright 2009 National Weather Service (NWS),
38  !/ National Oceanic and Atmospheric Administration. All rights
39  !/ reserved. WAVEWATCH III is a trademark of the NWS.
40  !/ No unauthorized use without permission.
41  !/
42  ! 1. Purpose :
43  !
44  ! Dummy slot for bottom friction source term.
45  !
46  ! 2. Variables and types :
47  !
48  ! 3. Subroutines and functions :
49  !
50  ! Name Type Scope Description
51  ! ----------------------------------------------------------------
52  ! W3SDB1 Subr. Public Battjes and Janssen depth-induced
53  ! breaking.
54  ! ----------------------------------------------------------------
55  !
56  ! 4. Subroutines and functions used :
57  !
58  ! See subroutine documentation.
59  !
60  ! 5. Remarks :
61  !
62  ! 6. Switches :
63  !
64  ! See subroutine documentation.
65  !
66  ! 7. Source code :
67  !/
68  !/ ------------------------------------------------------------------- /
69  !/
70  PUBLIC
71  !/
72 CONTAINS
73  !/ ------------------------------------------------------------------- /
96  SUBROUTINE w3sdb1 (IX, A, DEPTH, EMEAN, FMEAN, WNMEAN, CG, LBREAK, S, D )
97  !/
98  !/ +-----------------------------------+
99  !/ | WAVEWATCH III NOAA/NCEP |
100  !/ | FORTRAN 90 |
101  !/ | J. H. Alves |
102  !/ | H. L. Tolman |
103  !/ ! A. Roland |
104  !/ | Last update : 08-Jun-2018 |
105  !/ +-----------------------------------+
106  !/
107  !/ 25-Apr-2007 : Origination of module. ( version 3.11 )
108  !/ 08-Jun-2018 : Add DEBUGDB1. ( version 6.04 )
109  !/ 03-Apr-2019 : Rewrite in terms of energy density (A. Roland,version 6.07)
110  !/ 03-Apr-2019 : Add Thornton & Guza, 1983 (A. Roland,version 6.07)
111  !/
112  ! 1. Purpose :
113  !
114  ! Compute depth-induced breaking using Battjes and Janssen bore
115  ! model approach
116  !
117  ! 2. Method : Battjes & Janssen (1978),
118  !
119  ! Sbr = Dtot/Etot*WA = D * WA
120  ! Dtot = 0.25*alpha*Qb*fm*Hmax²
121  ! fm = sigma/2Pi
122  ! BB = Hrms²/Hmax² = 8Etot/Hmax²
123  ! D = Dtot/Etot = BJALFA * sigma / pi * Qb/BB = 2 * BJALFA * fm * Qb/BB
124  !
125  ! AR: only valid for Hrms .le. Hm, Qb .le. 1, otherwise, in the degenrative regime it is
126  ! due to Qb > 1 that all wave are broken and Hrms .le. Hmax
127  ! MLIM can be used to enforce this conditions, source term will smoothly converge to this limit.
128  !
129  ! Where CDB = SDBC1 = BJALFA (defaults to BJALFA = 1)
130  ! modified via ww3_grid namelist parameter BJALFA
131  ! HM = GAMMA * DEP
132  ! GAMMA = SDBC2 defaults to 0.73 (mean Battjes/Janssen value)
133  ! modified via ww3_grid namelist parameter BJGAM
134  !
135  ! And QB is estimated by iterations using the nonlinear expression
136  !
137  ! 1 - QB = HRMS**2
138  ! ------ -------
139  ! ln QB HM**2
140  !
141  ! 3. Parameters :
142  !
143  ! Parameter list
144  ! ----------------------------------------------------------------
145  ! A R.A. I Action density spectrum (1-D)
146  ! EMEAN Real I Mean wave energy.
147  ! FMEAN Real I Mean wave frequency.
148  ! WNMEAN Real I Mean wave number.
149  ! DEPTH Real I Mean water depth.
150  ! S R.A. O Source term (1-D version).
151  ! D R.A. O Diagonal term of derivative (1-D version).
152  ! ----------------------------------------------------------------
153  !
154  ! 4. Subroutines used :
155  !
156  ! STRACE Subroutine tracing (!/S switch).
157  !
158  ! 5. Called by :
159  !
160  ! W3SRCE Source term integration.
161  ! W3EXPO Point output post-processor.
162  ! GXEXPO GrADS point output post-processor.
163  !
164  ! 6. Error messages :
165  !
166  ! None.
167  !
168  ! 7. Remarks :
169  !
170  ! - Note that the Miche criterion con influence wave growth.
171  !
172  ! 8. Structure :
173  !
174  ! See source code.
175  !
176  ! 9. Switches :
177  !
178  ! !/S Enable subroutine tracing.
179  ! !/Tn Enable test output.
180  !
181  ! 10. Source code :
182  !
183  !/ ------------------------------------------------------------------- /
184  !/
185  USE constants
186  USE w3gdatmd, ONLY: nk, nth, nspec, sdbc1, sdbc2, fdonly, fssource, dden
187  USE w3odatmd, ONLY: ndst
188  USE w3gdatmd, ONLY: sig
189  USE w3odatmd, only : iaproc
190 #ifdef W3_S
191  USE w3servmd, ONLY: strace
192 #endif
193 #ifdef W3_T0
194  USE w3arrymd, ONLY: prt2ds
195 #endif
196 #ifdef W3_T1
197  USE w3arrymd, ONLY: outmat
198 #endif
199  !/
200  IMPLICIT NONE
201  !/
202  !/ ------------------------------------------------------------------- /
203  !/ Parameter list
204  !/
205  INTEGER, INTENT(IN) :: IX ! Local grid number
206  REAL, INTENT(IN) :: A(NSPEC)
207  REAL, INTENT(INOUT) :: EMEAN, FMEAN, WNMEAN, DEPTH
208  REAL, INTENT(OUT) :: S(NSPEC), D(NSPEC)
209  REAL, INTENT(IN) :: CG(NK)
210  LOGICAL, INTENT(OUT) :: LBREAK
211  INTEGER :: ITH, IK, IWB
212  !/
213  !/ ------------------------------------------------------------------- /
214  !/ Local parameters
215  !/
216  INTEGER :: IS
217 #ifdef W3_S
218  INTEGER, SAVE :: IENT = 0
219 #endif
220  real*8 :: hm, bb, arg, q0, qb, b, cbj, hrms, eb(nk)
221  real*8 :: aux, cbj2, ratio, s0, s1, thr, br1, br2, fak
222  REAL :: ETOT, FMEAN2
223 #ifdef W3_T0
224  REAL :: DOUT(NK,NTH)
225 #endif
226  !/
227  !/ ------------------------------------------------------------------- /
228  !/
229 #ifdef W3_S
230  CALL strace (ient, 'W3SDB1')
231 #endif
232  !
233  ! 0. Initialzations ------------------------------------------------- /
234  ! Never touch this 4 lines below ... otherwise my exceptionhandling will not work.
235  s = 0.
236  d = 0.
237 
238  thr = dble(1.e-15)
239  IF (sum(a) .LT. thr) RETURN
240 
241  iwb = 1
242  !
243 #ifdef W3_T
244  WRITE (ndst,9000) sdbc1, sdbc2, fdonly
245 #endif
246  !
247  ! 1. Integral quantities. AR: make sure mean quantities are computed, need to move upward
248  !
249  etot = 0.
250  fmean2 = 0.
251  DO ik=1, nk
252  eb(ik) = 0.
253  DO ith=1, nth
254  eb(ik) = eb(ik) + a(ith+(ik-1)*nth)
255  END DO
256  END DO
257  DO ik=1, nk
258  eb(ik) = eb(ik) * dden(ik) / cg(ik)
259  etot = etot + eb(ik)
260  END DO
261  DO ik=1, nk
262  fmean2 = fmean2 + eb(ik) * sig(ik)
263  END DO
264  fmean2 = fmean2 / etot * tpiinv
265  !
266  ! 2do compute wlmean
267  !
268  ! 1.a. Maximum wave height
269  ! 1.a.1. Simple limit
270  !
271  IF ( fdonly ) THEN
272  hm = dble(sdbc2) * dble(depth)
273  ELSE
274  !
275  ! 1.a.2. Miche style criterion
276  !
277  hm = dble(sdbc2) / dble(wnmean) * tanh( dble(wnmean) * max(depth,0.) )
278  END IF
279  !
280  !AR: Add Dingemans ...
281  ! 1.b. Hrms and ratio Hrms / Hmax
282  !
283  hrms = dsqrt(8.d0 * dble(emean))
284  IF ( hm .GT. thr) THEN
285  bb = hrms * hrms / ( hm * hm )
286  b = dsqrt(bb)
287  ELSE
288  bb = 0.d0
289  b = 0.d0
290  END IF
291  !
292  ! 2. Fraction of breaking waves -------------------------------------- /
293  ! 2.a. First guess breaking fraction
294  !
295  IF ( b .LE. 0.5d0 ) THEN
296  q0 = 0.d0
297  ELSE IF ( b .LE. 1.d0 ) THEN
298  q0 = ( 2.d0 * b - 1.d0 ) ** 2
299  END IF
300  !
301  ! 2.b. Iterate to obtain actual breaking fraction
302  !
303  IF ( b .LE. 0.2d0 ) THEN
304  qb = 0.d0
305  ELSE IF ( b .LT. 1.d0 ) THEN
306  arg = exp(( q0 - 1.d0 ) / bb )
307  qb = q0 - bb * ( q0 - arg ) / ( bb - arg )
308  DO is=1, 3
309  qb = exp((qb-1.)/bb)
310  END DO
311  ELSE
312  qb = 1.0 - thr
313  END IF
314  !
315  ! 3. Estimate the breaking coefficient ------------------------------- /
316  !
317  cbj = 0
318  IF (iwb == 1) THEN
319  IF ( ( bb .GT. thr) .AND. ( abs( bb - qb ) .GT. thr) ) THEN
320  IF ( bb .LT. 1.0) THEN
321  cbj = 2 * dble(sdbc1) * qb * dble(fmean) / bb
322  ELSE
323  cbj = 2 * dble(sdbc1) * dble(fmean) * bb ! AR: degenerative regime, all waves must be .le. Hmax, we just smoothly let the excessive energy vanish by * BB.
324  END IF
325  ELSE
326  cbj = 0.d0
327  ENDIF
328  d = - cbj
329  s = d * a
330  ELSE IF (iwb == 2) THEN
331  IF (etot .GT. thr) THEN
332  hrms = sqrt(8*emean)
333  fak = (1+4./sqrt(pi)*(b*bb+1.5*b)*exp(-bb)-erf(b))
334  cbj = -sdbc1*sqrt(pi)/16.*fmean*hrms**3/depth/etot
335  ELSE
336  cbj = 0.
337  ENDIF
338  d = - cbj
339  s = d * a
340  ENDIF
341 
342  IF (cbj .GT. 0.) THEN
343  lbreak = .true.
344  ELSE
345  lbreak = .false.
346  ENDIF
347 
348 #ifdef W3_DEBUGRUN
349  IF (ix == debug_node) THEN
350  WRITE(*,'(A200)') 'IX, DEPTH, CBJ, BB, QB, SDBC1, SDBC2, FMEAN, FMEAN2, HS'
351  WRITE(*,'(I10,20F20.10)') ix, depth, cbj, bb, qb, sdbc1, sdbc2, fmean, fmean2, 4*sqrt(etot)
352  ENDIF
353 #endif
354  !
355  ! ... Test output of arrays
356  !
357 #ifdef W3_T0
358  DO ik=1, nk
359  DO ith=1, nth
360  dout(ik,ith) = d(ith+(ik-1)*nth)
361  END DO
362  END DO
363  CALL prt2ds (ndst, nk, nk, nth, dout, sig, ' ', 1., &
364  0.0, 0.001, 'Diag Sdb', ' ', 'NONAME')
365 #endif
366  !
367 #ifdef W3_T1
368  CALL outmat (ndst, d, nth, nth, nk, 'diag Sdb')
369 #endif
370  !
371  RETURN
372  !
373  ! Formats
374  !
375 #ifdef W3_T
376 9000 FORMAT (' TEST W3SDB1 : PARAMETERS :',2f7.3,l4)
377 #endif
378  !/
379  !/ End of W3SDB1 ----------------------------------------------------- /
380  !/
381  END SUBROUTINE w3sdb1
382  !/
383  !/
384  !/ End of module W3SDB1MD -------------------------------------------- /
385  !/
386 END MODULE w3sdb1md
w3gdatmd::sdbc1
real, pointer sdbc1
Definition: w3gdatmd.F90:1393
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
constants::pi
real, parameter pi
PI Value of Pi.
Definition: constants.F90:71
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3sdb1md
Dummy slot for bottom friction source term.
Definition: w3sdb1md.F90:24
w3odatmd::iaproc
integer, pointer iaproc
Definition: w3odatmd.F90:457
w3gdatmd::fssource
logical, pointer fssource
Definition: w3gdatmd.F90:1406
w3arrymd::outmat
subroutine outmat(NDS, A, MX, NX, NY, MNAME)
Definition: w3arrymd.F90:988
w3sdb1md::w3sdb1
subroutine w3sdb1(IX, A, DEPTH, EMEAN, FMEAN, WNMEAN, CG, LBREAK, S, D)
Compute depth-induced breaking using Battjes and Janssen bore model approach.
Definition: w3sdb1md.F90:97
w3servmd
Definition: w3servmd.F90:3
constants::tpiinv
real, parameter tpiinv
TPIINV Inverse of 2*Pi.
Definition: constants.F90:74
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3odatmd
Definition: w3odatmd.F90:3
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3arrymd
Definition: w3arrymd.F90:3
w3gdatmd::fdonly
logical, pointer fdonly
Definition: w3gdatmd.F90:1394
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
constants::debug_node
integer, parameter debug_node
DEBUG_NODE Node number used for debugging.
Definition: constants.F90:99
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3gdatmd::dden
real, dimension(:), pointer dden
Definition: w3gdatmd.F90:1234
w3gdatmd
Definition: w3gdatmd.F90:16
w3arrymd::prt2ds
subroutine prt2ds(NDS, NFR0, NFR, NTH, E, FR, UFR, FACSP, FSC, RRCUT, PRVAR, PRUNIT, PNTNME)
Definition: w3arrymd.F90:1943
w3gdatmd::sdbc2
real, pointer sdbc2
Definition: w3gdatmd.F90:1393