WAVEWATCH III  beta 0.0.1
w3swldmd.F90
Go to the documentation of this file.
1 
6 
7 #include "w3macros.h"
8 !/ ------------------------------------------------------------------- /
18 MODULE w3swldmd
19  !/
20  !/ +-----------------------------------+
21  !/ | WAVEWATCH III NOAA/NCEP |
22  !/ | H. L. Tolman |
23  !/ | FORTRAN 90 |
24  !/ +-----------------------------------+
25  !/
26  !/ 21-Nov-2011 : Origination. ( version 4.07 )
27  !/
28  !/ Copyright 2009 National Weather Service (NWS),
29  !/ National Oceanic and Atmospheric Administration. All rights
30  !/ reserved. WAVEWATCH III is a trademark of the NWS.
31  !/ No unauthorized use without permission.
32  !/
33  ! 1. Purpose :
34  !
35  ! Source term module for swell dissipation based on different
36  ! physics that can be independently selected form the input
37  ! and whitecapping dissipation terms in the model setup.
38  !
39  ! 2. Variables and types :
40  !
41  ! Name Type Scope Description
42  ! ----------------------------------------------------------------
43  ! ----------------------------------------------------------------
44  !
45  ! 3. Subroutines and functions :
46  !
47  ! Name Type Scope Description
48  ! ----------------------------------------------------------------
49  ! W3SWL4 Subr. Public Ardhuin et al (2010+) swell dissipation
50  ! W3SWL6 Subr. Public Babanin (2011) swell dissipation
51  !
52  ! IRANGE Func. Private Generate a sequence of integer values
53  ! ----------------------------------------------------------------
54  !
55  ! 4. Subroutines and functions used :
56  !
57  ! Name Type Module Description
58  ! ----------------------------------------------------------------
59  ! STRACE Subr. W3SERVMD Subroutine tracing.
60  ! ----------------------------------------------------------------
61  !
62  ! 5. Remarks :
63  !
64  !
65  ! 6. Switches :
66  !
67  ! !/S Enable subroutine tracing.
68  !
69  ! 7. Source code :
70  !/
71  !/ ------------------------------------------------------------------- /
72  !/
73  PUBLIC :: w3swl4, w3swl6
74  PRIVATE :: irange
75  !/
76 CONTAINS
77  !/ ------------------------------------------------------------------- /
93  SUBROUTINE w3swl4 (A, CG, WN, DAIR, S, D)
94  !/
95  !/ +-----------------------------------+
96  !/ | WAVEWATCH III NOAA/NCEP |
97  !/ | H. L. Tolman |
98  !/ | FORTRAN 90 |
99  !/ | Last update : 13-Aug-2021 |
100  !/ +-----------------------------------+
101  !/
102  !/ 29-May-2009 : Origination (w3srcxmd.ftn) ( version 3.14 )
103  !/ 06-Jan-2012 : Implementation (S. Zieger)
104  !/ 13-Aug-2021 : Consider DAIR a variable ( version x.xx )
105  !/
106  ! 1. Purpose :
107  !
108  ! FIXME
109  !
110  ! 2. Method :
111  !
112  ! 3. Parameters :
113  !
114  ! Parameter list
115  ! ----------------------------------------------------------------
116  ! A¹ R.A. I Action density spectrum
117  ! CG R.A. I Group velocities
118  ! WN R.A. I Wavenumbers
119  ! DAIR R.A. I Air density
120  ! S¹ R.A. O Source term
121  ! D¹ R.A. O Diagonal term of derivative
122  ! ¹ Stored as 1-D array with dimension NTH*NK (column by column).
123  ! ----------------------------------------------------------------
124  !
125  ! 4. Subroutines used :
126  !
127  ! Name Type Module Description
128  ! ----------------------------------------------------------------
129  ! IRANGE Func. W3SWLDMD
130  ! STRACE Subr. W3SERVMD Subroutine tracing.
131  ! ----------------------------------------------------------------
132  !
133  ! 5. Called by :
134  !
135  ! Name Type Module Description
136  ! ----------------------------------------------------------------
137  ! W3SRCE Subr. W3SRCEMD Source term integration.
138  ! W3EXPO Subr. N/A Point output post-processor.
139  ! GXEXPO Subr. N/A GrADS point output post-processor.
140  ! ----------------------------------------------------------------
141  !
142  ! 6. Error messages :
143  !
144  ! None.
145  !
146  ! 7. Remarks :
147  !
148  ! 8. Structure :
149  !
150  ! See comments in source code.
151  !
152  ! 9. Switches :
153  !
154  ! !/S Enable subroutine tracing.
155  !
156  ! 10. Source code :
157  !
158  !/ ------------------------------------------------------------------- /
159  USE constants, ONLY: grav, dwat
160  USE w3gdatmd, ONLY: nk, nth, nspec, sig2, dden, fte, swl6b1
161 #ifdef W3_S
162  USE w3servmd, ONLY: strace
163 #endif
164  !/
165  IMPLICIT NONE
166  !/
167  !/ ------------------------------------------------------------------- /
168  !/ Parameter list
169  REAL, INTENT(IN) :: a(nspec), cg(nk), wn(nk), dair
170  REAL, INTENT(OUT) :: s(nspec), d(nspec)
171  !/
172  !/ ------------------------------------------------------------------- /
173  !/ Local parameters
174 #ifdef W3_S
175  INTEGER, SAVE :: ient = 0
176 #endif
177  INTEGER :: ikn(nk), ith
178  REAL, PARAMETER :: va = 1.4e-5 ! Air kinematic viscosity (used in WAM).
179  REAL :: eb(nk), wn2(nspec), emean
180  REAL :: fe, aorb, re, recrit, uosig, cdsv
181  !/
182  !/ ------------------------------------------------------------------- /
183  !/
184 #ifdef W3_S
185  CALL strace (ient, 'W3SWL4')
186 #endif
187  !
188  ikn = irange(1,nspec,nth)
189  d = 0.
190  wn2 = 0.
191  !
192  DO ith = 1, nth
193  wn2(ikn+(ith-1)) = wn ! Wavenumbers to all directions.
194  END DO
195  !
196  eb = sum(reshape(a,(/ nth,nk /)),1) * dden(1:nk) / cg
197  emean = sum(eb) + (eb(nk) / dden(nk)) * fte
198  !
199  aorb = 2.0*sqrt(emean)
200  !
201  eb = sum(reshape(a*sig2**2,(/ nth,nk /)),1) * dden(1:nk) / cg
202  uosig = 2.0*sqrt(sum(eb))
203 
204  fe = swl6b1 ! (from NAMELIST)
205  ! FE = 0.001 ! (from NAMELIST)
206  !/ 0.001 - 0.019 with median value 0.007 (Ardhuin et al 2009, Babanin 2011)
207  cdsv = 1.2
208  !
209  recrit = 1.0e5
210  re = 4.0 * uosig * aorb / va
211  !
212  IF (re .GT. recrit) THEN
213  d = -(16.0/grav) * (dair/dwat) * fe * (sig2**2) *uosig
214  ELSE
215  d = -2.0 * (dair/dwat) * cdsv * wn2 * sqrt(2.0 * va * sig2)
216  END IF
217  !
218  s = d * a
219  !
220  ! WRITE(*,*) ' FE =',FE
221  ! WRITE(*,*) ' HS =',4.*SQRT(EMEAN)
222  ! WRITE(*,*) ' UOSIG =',UOSIG
223  ! WRITE(*,*) ' AORB =',AORB
224  ! WRITE(*,*) ' RE/RECRIT=',RE/RECRIT
225  ! WRITE(*,*) ' SWL4_tot =',SUM(SUM(RESHAPE(S,(/ NTH,NK /)),1)*DDEN/CG)
226  !/
227  !/ End of W3SWL4 ----------------------------------------------------- /
228  !/
229  END SUBROUTINE w3swl4
230  !/ ------------------------------------------------------------------- /
251  SUBROUTINE w3swl6 (A, CG, WN, S, D)
252  !/
253  !/ +-----------------------------------+
254  !/ | WAVEWATCH III NOAA/NCEP |
255  !/ | H. L. Tolman |
256  !/ | FORTRAN 90 |
257  !/ | Last update : 16-Feb-2012 |
258  !/ +-----------------------------------+
259  !/
260  !/ 29-May-2009 : Origination (w3srcxmd.ftn) ( version 3.14 )
261  !/ 16-Feb-2012 : Implementation ( version 4.07 )
262  !/ (S. Zieger)
263  !/
264  ! 1. Purpose :
265  !
266  ! Turbulent dissipation of narrow-banded swell as described in
267  ! Babanin (2011, Section 7.5).
268  !
269  ! Babanin 2011: Cambridge Press, 295-321, 463pp.
270  !
271  ! 2. Method :
272  !
273  ! S = D * A
274  !
275  ! 3. Parameters :
276  !
277  ! Parameter list
278  ! ----------------------------------------------------------------
279  ! A¹ R.A. I Action density spectrum
280  ! CG R.A. I Group velocities
281  ! WN R.A. I Wavenumbers
282  ! S¹ R.A. O Source term
283  ! D¹ R.A. O Diagonal term of derivative
284  ! ¹ Stored as 1-D array with dimension NTH*NK (column by column).
285  ! ----------------------------------------------------------------
286  !
287  ! 4. Subroutines used :
288  !
289  ! Name Type Module Description
290  ! ----------------------------------------------------------------
291  ! IRANGE Func. W3SWLDMD
292  ! STRACE Subr. W3SERVMD Subroutine tracing.
293  ! ----------------------------------------------------------------
294  !
295  ! 5. Called by :
296  !
297  ! Name Type Module Description
298  ! ----------------------------------------------------------------
299  ! W3SRCE Subr. W3SRCEMD Source term integration.
300  ! W3EXPO Subr. N/A Point output post-processor.
301  ! GXEXPO Subr. N/A GrADS point output post-processor.
302  ! ----------------------------------------------------------------
303  !
304  ! 6. Error messages :
305  !
306  ! None.
307  !
308  ! 7. Remarks :
309  !
310  ! 8. Structure :
311  !
312  ! See comments in source code.
313  !
314  ! 9. Switches :
315  !
316  ! !/S Enable subroutine tracing.
317  !
318  ! 10. Source code :
319  !
320  !/ ------------------------------------------------------------------- /
321  USE constants, ONLY: grav
322  USE w3gdatmd, ONLY: nk, nth, nspec, sig, dden, dth
323  USE w3gdatmd, ONLY: swl6cstb1, swl6b1, fte, ftwn
324 #ifdef W3_T6
325  USE w3odatmd, ONLY: ndst
326 #endif
327 #ifdef W3_S
328  USE w3servmd, ONLY: strace
329 #endif
330  !/
331  IMPLICIT NONE
332  !/
333  !/ ------------------------------------------------------------------- /
334  !/ Parameter list
335  REAL, INTENT(IN) :: a(nspec), cg(nk), wn(nk)
336  REAL, INTENT(OUT) :: s(nspec), d(nspec)
337  !/
338  !/ ------------------------------------------------------------------- /
339  !/ Local parameters
340 #ifdef W3_S
341  INTEGER, SAVE :: ient = 0
342 #endif
343  INTEGER :: ik, ith, ikn(nk)
344  REAL, DIMENSION(NK) :: aband, kmax, anar, bn, aorb, ddis
345  REAL :: k(nth,nk), b1
346  !/
347  !/ ------------------------------------------------------------------- /
348  !/
349 #ifdef W3_S
350  CALL strace (ient, 'W3SWL6')
351 #endif
352  !
353  !/ 0) --- Initialize parameters -------------------------------------- /
354  ikn = irange(1,nspec,nth) ! Index vector for array access, e.g.
355  ! ! in form of WN(1:NK) == WN2(IKN).
356  aband = sum(reshape(a,(/ nth,nk /)),1) ! action density as function of wavenumber
357  ddis = 0.
358  d = 0.
359  b1 = swl6b1 ! empirical constant from NAMELIST
360  !
361  !/ 1) --- Choose calculation of steepness a*k ------------------------ /
362  !/ Replace the measure of steepness with the spectral
363  ! saturation after Banner et al. (2002) ---------------------- /
364  k = reshape(a,(/ nth,nk /))
365  kmax = maxval(k,1)
366  DO ik = 1,nk
367  IF (kmax(ik).LT.1.0e-34) THEN
368  k(1:nth,ik) = 1.
369  ELSE
370  k(1:nth,ik) = k(1:nth,ik)/kmax(ik)
371  END IF
372  END DO
373  anar = 1.0/( sum(k,1) * dth )
374  bn = anar * ( aband * sig(1:nk) * dth ) * wn**3
375  !
376  IF (.NOT.swl6cstb1) THEN
377  !
378  !/ --- A constant value for B1 attenuates swell too strong in the
379  !/ western central Pacific (i.e. cross swell less than 1.0m).
380  !/ Workaround is to scale B1 with steepness a*kp, where kp is
381  !/ the peak wavenumber. SWL6B1 remains a scaling constant, but
382  !/ with different magnitude. --------------------------------- /
383  ik = maxloc(aband,1) ! Index for peak
384  ! EMEAN = SUM(ABAND * DDEN / CG) ! Total sea surface variance
385  b1 = swl6b1 * ( 2. * sqrt(sum(aband*dden/cg)) * wn(ik) )
386  !
387  END IF
388  !
389  !/ 2) --- Calculate the derivative term only (in units of 1/s) ------- /
390  DO ik = 1,nk
391  IF (aband(ik) .GT. 1.e-30) THEN
392  ddis(ik) = -(2./3.) * b1 * sig(ik) * sqrt(bn(ik))
393  END IF
394  END DO
395  !
396  !/ 3) --- Apply dissipation term of derivative to all directions ----- /
397  DO ith = 1, nth
398  d(ikn+(ith-1)) = ddis
399  END DO
400  !
401  s = d * a
402  !
403  ! WRITE(*,*) ' B1 =',B1
404  ! WRITE(*,*) ' DDIS_tot =',SUM(DDIS*ABAND*DDEN/CG)
405  ! WRITE(*,*) ' EDENS_tot=',sum(aband*dden/cg)
406  ! WRITE(*,*) ' EDENS_tot=',sum(aband*sig*dth*dsii/cg)
407  ! WRITE(*,*) ' '
408  ! WRITE(*,*) ' SWL6_tot =',sum(SUM(RESHAPE(S,(/ NTH,NK /)),1)*DDEN/CG)
409  !
410  !/
411  !/ End of W3SWL6 ----------------------------------------------------- /
412  !/
413  END SUBROUTINE w3swl6
414  !/ ------------------------------------------------------------------- /
415  !/
430  FUNCTION irange(X0,X1,DX) RESULT(IX)
431  !/
432  !/ +-----------------------------------+
433  !/ | WAVEWATCH III NOAA/NCEP |
434  !/ | H. L. Tolman |
435  !/ | S. Zieger |
436  !/ | FORTRAN 90 |
437  !/ | Last update : 15-Feb-2011 |
438  !/ +-----------------------------------+
439  !/
440  !/ 15-Feb-2011 : Origination from W3SRC6MD ( version 4.07 )
441  !/ (S. Zieger)
442  !/
443  ! 1. Purpose :
444  ! Generate a linear-spaced sequence of integer
445  ! numbers. Used for array addressing (indexing).
446  !
447  !/
448  IMPLICIT NONE
449  INTEGER, INTENT(IN) :: x0, x1, dx
450  INTEGER, ALLOCATABLE :: ix(:)
451  INTEGER :: n
452  INTEGER :: i
453  !
454  n = int(real(x1-x0)/real(dx))+1
455  ALLOCATE(ix(n))
456  DO i = 1, n
457  ix(i) = x0+ (i-1)*dx
458  END DO
459  !/
460  END FUNCTION irange
461  !/ ------------------------------------------------------------------- /
462  !/
463 END MODULE w3swldmd
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3swldmd
Source term module for swell dissipation.
Definition: w3swldmd.F90:18
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3gdatmd::swl6cstb1
logical, pointer swl6cstb1
Definition: w3gdatmd.F90:1338
w3swldmd::w3swl4
subroutine, public w3swl4(A, CG, WN, DAIR, S, D)
FIXME.
Definition: w3swldmd.F90:94
w3servmd
Definition: w3servmd.F90:3
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3odatmd
Definition: w3odatmd.F90:3
constants::dwat
real, parameter dwat
DWAT Density of water (kg/m3).
Definition: constants.F90:62
w3gdatmd::swl6b1
real, pointer swl6b1
Definition: w3gdatmd.F90:1335
w3gdatmd::sig2
real, dimension(:), pointer sig2
Definition: w3gdatmd.F90:1234
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3gdatmd::fte
real, pointer fte
Definition: w3gdatmd.F90:1232
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
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
w3swldmd::w3swl6
subroutine, public w3swl6(A, CG, WN, S, D)
Turbulent dissipation of narrow-banded swell.
Definition: w3swldmd.F90:252
w3gdatmd::ftwn
real, pointer ftwn
Definition: w3gdatmd.F90:1232
constants::grav
real, parameter grav
GRAV Acc.
Definition: constants.F90:61