WAVEWATCH III  beta 0.0.1
w3src6md.F90
Go to the documentation of this file.
1 
9 
10 #include "w3macros.h"
11 !/ ------------------------------------------------------------------- /
12 
27 MODULE w3src6md
28  !/
29  !/ +-----------------------------------+
30  !/ | WAVEWATCH III NOAA/NCEP/NOPP |
31  !/ | S. Zieger |
32  !/ | Q. Liu |
33  !/ | FORTRAN 90 |
34  !/ | Last update : 26-Jun-2018 |
35  !/ +-----------------------------------+
36  !/
37  !/ 29-May-2009 : Origination (w3srcxmd.ftn) ( version 3.14 )
38  !/ 10-Feb-2011 : Implementation of source terms ( version 4.04 )
39  !/ (S. Zieger)
40  !/ 26-Jun-2017 : Recalibration of ST6 ( verison 6.06 )
41  !/ (Q. Liu )
42  !/
43  !/ Copyright 2009 National Weather Service (NWS),
44  !/ National Oceanic and Atmospheric Administration. All rights
45  !/ reserved. WAVEWATCH III is a trademark of the NWS.
46  !/ No unauthorized use without permission.
47  !/
48  ! 1. Purpose :
49  !
50  ! Observation-based wind input and dissipation after Donelan et al (2006),
51  ! and Babanin et al. (2010). Parameterisation is based on the field
52  ! data from Lake George, Australia. Initial implementation of input
53  ! and dissipation is based on work from Tsagareli et al. (2010) and
54  ! Rogers et al. (2012). Parameterisation extended and account for
55  ! negative input due to opposing winds (see Donelan et al, 2006) and
56  ! the vector version of the stress computation.
57  !
58  ! References:
59  ! Babanin et al. 2010: JPO 40(4) 667- 683
60  ! Donelan et al. 2006: JPO 36(8) 1672-1689
61  ! Tsagareli et al. 2010: JPO 40(4) 656- 666
62  ! Rogers et al. 2012: JTECH 29(9) 1329-1346
63  !
64  ! 2. Variables and types :
65  !
66  ! Not applicable.
67  !
68  ! 3. Subroutines and functions :
69  !
70  ! Name Type Scope Description
71  ! ----------------------------------------------------------------
72  ! W3SPR6 Subr. Public Integral parameter calculation following !/ST1.
73  ! W3SIN6 Subr. Public Observation-based wind input.
74  ! W3SDS6 Subr. Public Observation-based dissipation.
75  !
76  ! IRANGE Func. Private Generate a sequence of integer values.
77  ! LFACTOR Func. Private Calculate reduction factor for Sin.
78  ! TAUWINDS Func. Private Normal stress calculation for Sin.
79  ! ----------------------------------------------------------------
80  !
81  ! 4. Subroutines and functions used :
82  !
83  ! Name Type Module Description
84  ! ----------------------------------------------------------------
85  ! STRACE Subr. W3SERVMD Subroutine tracing.
86  ! ----------------------------------------------------------------
87  !
88  ! 5. Remarks :
89  !
90  ! 6. Switches :
91  !
92  ! !/S Enable subroutine tracing.
93  ! !/T6 Enable test output for wind input and dissipation subroutines.
94  !
95  ! 7. Source code :
96  !/
97  !/ ------------------------------------------------------------------- /
98  !/
99  PUBLIC :: w3spr6, w3sin6, w3sds6
100  PRIVATE :: lfactor, tauwinds, irange
101 CONTAINS
102  !/ ------------------------------------------------------------------- /
103 
121  SUBROUTINE w3spr6 (A, CG, WN, EMEAN, FMEAN, WNMEAN, AMAX, FP)
122  !/
123  !/ +-----------------------------------+
124  !/ | WAVEWATCH III NOAA/NCEP/NOPP |
125  !/ | S. Zieger |
126  !/ | FORTRAN 90 |
127  !/ | Last update : 11-Feb-2011 |
128  !/ +-----------------------------------+
129  !/
130  !/ 08-Oct-2007 : Origination. ( version 3.13 )
131  !/ 11-Feb-2011 : Implementation based on W3SPR1 ( version 4.04 )
132  !/ (S. Zieger)
133  !/
134  ! 1. Purpose :
135  ! Calculate mean wave parameters.
136  !
137  ! 2. Method :
138  ! See source term routines.
139  !
140  ! 3. Parameters :
141  !
142  ! Parameter list
143  ! ----------------------------------------------------------------
144  ! A R.A. I Action as a function of direction and wavenumber
145  ! CG R.A. I Group velocities
146  ! WN R.A. I Wavenumbers
147  ! EMEAN REAL O Mean wave energy
148  ! FMEAN REAL O Mean wave frequency
149  ! WNMEAN REAL O Mean wavenumber
150  ! AMAX REAL O Maximum action density in spectrum
151  ! FP REAL O Peak frequency (rad)
152  ! ----------------------------------------------------------------
153  !
154  ! 4. Subroutines used :
155  !
156  ! Name Type Module Description
157  ! ----------------------------------------------------------------
158  ! STRACE Subr. W3SERVMD Subroutine tracing.
159  ! ----------------------------------------------------------------
160  !
161  ! 5. Called by :
162  !
163  ! Name Type Module Description
164  ! ----------------------------------------------------------------
165  ! W3SRCE Subr. W3SRCEMD Source term integration.
166  ! W3EXPO Subr. N/A Point output post-processor.
167  ! GXEXPO Subr. N/A GrADS point output post-processor.
168  ! ----------------------------------------------------------------
169  !
170  ! 6. Error messages :
171  !
172  ! None.
173  !
174  ! 7. Remarks :
175  !
176  ! 8. Structure :
177  !
178  ! See source code.
179  !
180  ! 9. Switches :
181  !
182  ! !/S Enable subroutine tracing.
183  !
184  ! 10. Source code :
185  !
186  !/ ------------------------------------------------------------------- /
187  USE constants, ONLY: tpiinv
188  USE w3gdatmd, ONLY: nk, nth, sig, dth, dden, fte, ftf, ftwn, dsii
189  USE w3odatmd, ONLY: ndst, ndse
190  USE w3servmd, ONLY: extcde
191 #ifdef W3_S
192  USE w3servmd, ONLY: strace
193 #endif
194  !/
195  IMPLICIT NONE
196  !/
197  !/ ------------------------------------------------------------------- /
198  !/ Parameter list
199  !/
200  REAL, INTENT(IN) :: a(nth,nk), cg(nk), wn(nk)
201  REAL, INTENT(OUT) :: emean, fmean, wnmean, amax, fp
202  !/
203  !/ ------------------------------------------------------------------- /
204  !/ Local parameters
205  !/
206 #ifdef W3_S
207  INTEGER, SAVE :: ient = 0
208 #endif
209  INTEGER :: imax
210  REAL :: eb(nk), eband
211  REAL, PARAMETER :: hsmin = 0.05
212  REAL :: coeff(3)
213  !/
214  !/ ------------------------------------------------------------------- /
215  !/
216 #ifdef W3_S
217  CALL strace (ient, 'W3SPR6')
218 #endif
219  !
220  !
221  ! 1. Integrate over directions -------------------------------------- /
222  eb = sum(a,1) * dden / cg
223  amax = maxval(a)
224  !
225  ! 2. Integrate over wavenumbers ------------------------------------- /
226  emean = sum(eb)
227  fmean = sum(eb / sig(1:nk))
228  wnmean = sum(eb / sqrt(wn))
229  !
230  ! 3. Add tail beyond discrete spectrum and get mean pars ------------ /
231  ! ( DTH * SIG absorbed in FTxx )
232  eband = eb(nk) / dden(nk)
233  emean = emean + eband * fte
234  fmean = fmean + eband * ftf
235  wnmean = wnmean + eband * ftwn
236  !
237  ! 4. Final processing
238  fmean = tpiinv * emean / max(1.0e-7, fmean)
239  wnmean = ( emean / max(1.0e-7,wnmean) )**2
240  !
241  ! 5. Determine peak frequency using a weighted integral ------------- /
242  ! Young (1999) p239: integrate f F**4 df / integrate F**4 df ----- /
243  ! TODO: keep in mind that **fp** calculated in this way may not
244  ! work under mixing (wind-sea and swell) sea states (QL)
245  fp = 0.0
246  !
247  IF (4.0*sqrt(emean) .GT. hsmin) THEN
248  eb = sum(a,1) * sig(1:nk) /cg * dth
249  fp = sum(sig(1:nk) * eb**4 * dsii) / max(1e-10, sum(eb**4 * dsii))
250  fp = fp * tpiinv
251  END IF
252  !
253  RETURN
254  !/
255  !/ End of W3SPR6 ----------------------------------------------------- /
256  !/
257  END SUBROUTINE w3spr6
258  !/ ------------------------------------------------------------------- /
259 
290  SUBROUTINE w3sin6 (A, CG, WN2, UABS, USTAR, USDIR, CD, DAIR, &
291  TAUWX, TAUWY, TAUNWX, TAUNWY, S, D )
292  !/
293  !/ +-----------------------------------+
294  !/ | WAVEWATCH III NOAA/NCEP/NOPP |
295  !/ | S. Zieger |
296  !/ | Q. Liu |
297  !/ | FORTRAN 90 |
298  !/ | Last update : 13-Aug-2021 |
299  !/ +-----------------------------------+
300  !/
301  !/ 20-Dec-2010 : Origination. ( version 4.04 )
302  !/ (S. Zieger)
303  !/
304  !/ 26-Jun-2018 : UPROXY Update & UABS ( version 6.06 )
305  !/ (Q. Liu)
306  !/ 13-Aug-2021 : Consider DAIR a variable ( version x.xx )
307  !/
308  ! 1. Purpose :
309  !
310  ! Observation-based source term for wind input after Donelan, Babanin,
311  ! Young and Banner (Donelan et al ,2006) following the implementation
312  ! by Rogers et al. (2012).
313  !
314  ! References:
315  ! Donelan et al. 2006: JPO 36(8) 1672-1689.
316  ! Rogers et al. 2012: JTECH 29(9) 1329-1346
317  !
318  ! 2. Method :
319  !
320  ! Sin = B * E
321  !
322  ! 3. Parameters :
323  !
324  ! Parameter list
325  ! ----------------------------------------------------------------
326  ! A¹ R.A. I Action density spectrum
327  ! CG R.A. I Group velocities
328  ! WN2¹ R.A. I Wavenumbers
329  ! UABS Real I Wind speed at 10 m above sea level (U10)
330  ! USTAR Real I Friction velocity
331  ! USDIR Real I Direction of USTAR
332  ! CD Real I Drag coefficient
333  ! DAIR Real I Air density
334  ! S¹ R.A. O Source term
335  ! D¹ R.A. O Diagonal term of derivative
336  ! TAUWX-Y Real O Component of the wave-supported stress
337  ! TAUNWX-Y Real O Component of the negative part of the stress
338  ! ¹ Stored as 1-D array with dimension NTH*NK (column by column).
339  ! ----------------------------------------------------------------
340  !
341  ! 4. Subroutines used :
342  !
343  ! Name Type Module Description
344  ! ----------------------------------------------------------------
345  ! LFACTOR Subr. W3SRC6MD
346  ! IRANGE Func. W3SRC6MD
347  ! STRACE Subr. W3SERVMD Subroutine tracing.
348  ! ----------------------------------------------------------------
349  !
350  ! 5. Called by :
351  !
352  ! Name Type Module Description
353  ! ----------------------------------------------------------------
354  ! W3SRCE Subr. W3SRCEMD Source term integration.
355  ! W3EXPO Subr. N/A Point output post-processor.
356  ! GXEXPO Subr. N/A GrADS point output post-processor.
357  ! ----------------------------------------------------------------
358  !
359  ! 6. Error messages :
360  !
361  ! None.
362  !
363  ! 7. Remarks :
364  !
365  ! 8. Structure :
366  !
367  ! See comments in source code.
368  !
369  ! 9. Switches :
370  !
371  ! !/S Enable subroutine tracing.
372  ! !/T6 Test and diagnostic output for tail reduction.
373  !
374  ! 10. Source code :
375  !
376  !/ ------------------------------------------------------------------- /
377  USE constants, ONLY: dwat, tpi, grav
378  USE w3gdatmd, ONLY: nk, nth, nspec, dth, sig2, dden2
379  USE w3gdatmd, ONLY: ecos, esin, sin6a0, sin6ws
380  USE w3odatmd, ONLY: ndse
381  USE w3servmd, ONLY: extcde
382 #ifdef W3_S
383  USE w3servmd, ONLY: strace
384 #endif
385  !/
386  IMPLICIT NONE
387  !/
388  !/ ------------------------------------------------------------------- /
389  !/ Parameter list
390  REAL, INTENT(IN) :: a (nspec), cg(nk), wn2(nspec)
391  REAL, INTENT(IN) :: uabs, ustar, usdir, cd, dair
392  REAL, INTENT(OUT) :: tauwx, tauwy, taunwx, taunwy
393  REAL, INTENT(OUT) :: s(nspec), d(nspec)
394  !/
395  !/ ------------------------------------------------------------------- /
396  !/ Local parameters
397 #ifdef W3_S
398  INTEGER, SAVE :: ient = 0
399 #endif
400  INTEGER :: ik, ith, ikn(nk)
401  REAL :: cosu, sinu, uproxy
402  REAL, DIMENSION(NSPEC) :: cg2, ecos2, esin2, dsii2
403  REAL, DIMENSION(NK) :: dsii, sig, wn
404  REAL :: k(nth,nk), sdensig(nth,nk) ! 1,2,5)
405  REAL, DIMENSION(NK) :: adensig, kmax, anar, sqrtbn ! 1,2,3)
406  REAL, DIMENSION(NSPEC) :: w1, w2, sqrtbn2, cinv2 ! 4,7)
407  REAL, DIMENSION(NK) :: lfact, cinv ! 5)
408  !/ ------------------------------------------------------------------- /
409 #ifdef W3_S
410  CALL strace (ient, 'W3SIN6')
411 #endif
412  !
413  !/ 0) --- set up a basic variables ----------------------------------- /
414  cosu = cos(usdir)
415  sinu = sin(usdir)
416  !
417  taunwx = 0.
418  taunwy = 0.
419  tauwx = 0.
420  tauwy = 0.
421  !
422  !/ --- scale friction velocity to wind speed (10m) in
423  !/ the boundary layer ----------------------------------------- /
424  !/ Donelan et al. (2006) used U10 or U_{λ/2} in their S_{in}
425  !/ parameterization. To avoid some disadvantages of using U10 or
426  !/ U_{λ/2}, Rogers et al. (2012) used the following engineering
427  !/ conversion:
428  !/ UPROXY = SIN6WS * UST
429  !/
430  !/ SIN6WS = 28.0 following Komen et al. (1984)
431  !/ SIN6WS = 32.0 suggested by E. Rogers (2014)
432  !
433  uproxy = sin6ws * ustar ! Scale wind speed
434  !
435  ecos2 = ecos(1:nspec) ! Only indices from 1 to NSPEC
436  esin2 = esin(1:nspec) ! are requested.
437  !
438  ikn = irange(1,nspec,nth) ! Index vector for elements of 1 ... NK
439  ! ! such that e.g. SIG(1:NK) = SIG2(IKN).
440  dsii2 = dden2 / dth / sig2 ! Frequency bandwidths (int.) (rad)
441  dsii = dsii2(ikn)
442  sig = sig2(ikn)
443  wn = wn2(ikn)
444  cinv2 = wn2 / sig2 ! inverse phase speed
445  !
446  DO ith = 1, nth
447  cg2(ikn+(ith-1)) = cg ! Apply CG to all directions.
448  END DO
449  !
450  !/ 1) --- calculate 1d action density spectrum (A(sigma)) and
451  !/ zero-out values less than 1.0E-32 to avoid NaNs when
452  !/ computing directional narrowness in step 4). --------------- /
453  k = reshape(a,(/ nth,nk /))
454  adensig = sum(k,1) * sig * dth ! Integrate over directions.
455  !
456  !/ 2) --- calculate normalised directional spectrum K(theta,sigma) --- /
457  kmax = maxval(k,1)
458  DO ik = 1,nk
459  IF (kmax(ik).LT.1.0e-34) THEN
460  k(1:nth,ik) = 1.
461  ELSE
462  k(1:nth,ik) = k(1:nth,ik)/kmax(ik)
463  END IF
464  END DO
465  !
466  !/ 3) --- calculate normalised spectral saturation BN(IK) ------------ /
467  anar = 1.0/( sum(k,1) * dth ) ! directional narrowness
468  !
469  sqrtbn = sqrt( anar * adensig * wn**3 )
470  DO ith = 1, nth
471  sqrtbn2(ikn+(ith-1)) = sqrtbn ! Calculate SQRTBN for
472  END DO ! the entire spectrum.
473  !
474  !/ 4) --- calculate growth rate GAMMA and S for all directions for
475  !/ following winds (U10/c - 1 is positive; W1) and in 7) for
476  !/ adverse winds (U10/c -1 is negative, W2). W1 and W2
477  !/ complement one another. ------------------------------------ /
478  w1 = max( 0., uproxy * cinv2* ( ecos2*cosu + esin2*sinu ) - 1. )**2
479  !
480  d = (dair / dwat) * sig2 * &
481  (2.8 - ( 1. + tanh(10.*sqrtbn2*w1 - 11.) )) *sqrtbn2*w1
482  !
483  s = d * a
484  !
485  !/ 5) --- calculate reduction factor LFACT using non-directional
486  ! spectral density of the wind input ------------------------- /
487  cinv = cinv2(ikn)
488  sdensig = reshape(s*sig2/cg2,(/ nth,nk /))
489  CALL lfactor(sdensig, cinv, uabs, ustar, usdir, sig, dsii, &
490  lfact, tauwx, tauwy )
491  !
492  !/ 6) --- apply reduction (LFACT) to the entire spectrum ------------- /
493  IF (sum(lfact) .LT. nk) THEN
494  DO ith = 1, nth
495  d(ikn+ith-1) = d(ikn+ith-1) * lfact
496  END DO
497  s = d * a
498  END IF
499  !
500  !/ 7) --- compute negative wind input for adverse winds. negative
501  !/ growth is typically smaller by a factor of ~2.5 (=.28/.11)
502  !/ than those for the favourable winds [Donelan, 2006, Eq. (7)].
503  !/ the factor is adjustable with NAMELIST parameter in
504  !/ ww3_grid.inp: '&SIN6 SINA0 = 0.04 /' ----------------------- /
505  IF (sin6a0.GT.0.0) THEN
506  w2 = min( 0., uproxy * cinv2* ( ecos2*cosu + esin2*sinu ) - 1. )**2
507  d = d - ( (dair / dwat) * sig2 * sin6a0 * &
508  (2.8 - ( 1. + tanh(10.*sqrtbn2*w2 - 11.) )) *sqrtbn2*w2 )
509  s = d * a
510  ! --- compute negative component of the wave supported stresses
511  ! from negative part of the wind input ---------------------- /
512  sdensig = reshape(s*sig2/cg2,(/ nth,nk /))
513  CALL tau_wave_atmos(sdensig, cinv, sig, dsii, taunwx, taunwy )
514  END IF
515  !
516  !/
517  !/ End of W3SIN6 ----------------------------------------------------- /
518  !/
519  END SUBROUTINE w3sin6
520  !/ ------------------------------------------------------------------- /
521 
546  SUBROUTINE w3sds6 (A, CG, WN, S, D)
547  !/
548  !/ +-----------------------------------+
549  !/ | WAVEWATCH III NOAA/NCEP |
550  !/ | S. Zieger |
551  !/ | Q. Liu |
552  !/ | FORTRAN 90 |
553  !/ | Last update : 26-Jun-2018 |
554  !/ +-----------------------------------+
555  !/
556  !/ 23-Jun-2010 : Origination. ( version 4.04 )
557  !/ (S. Zieger)
558  !/ 26-Jun-2018 : Revise the width of the last bin ( version 6.06 )
559  !/ (Q. Liu)
560  !/
561  ! 1. Purpose :
562  !
563  ! Observation-based source term for dissipation after Babanin et al.
564  ! (2010) following the implementation by Rogers et al. (2012). The
565  ! dissipation function Sds accommodates an inherent breaking term T1
566  ! and an additional cumulative term T2 at all frequencies above the
567  ! peak. The forced dissipation term T2 is an integral that grows
568  ! toward higher frequencies and dominates at smaller scales
569  ! (Babanin et al. 2010).
570  !
571  ! References:
572  ! Babanin et al. 2010: JPO 40(4), 667-683
573  ! Rogers et al. 2012: JTECH 29(9) 1329-1346
574  !
575  ! 2. Method :
576  !
577  ! Sds = (T1 + T2) * E
578  !
579  ! 3. Parameters :
580  !
581  ! Parameter list
582  ! ----------------------------------------------------------------
583  ! A¹ R.A. I Action density spectrum
584  ! CG R.A. I Group velocities
585  ! WN R.A. I Wavenumbers
586  ! S¹ R.A. O Source term (1-D version)
587  ! D¹ R.A. O Diagonal term of derivative
588  ! ¹ Stored as 1-D array with dimension NTH*NK (column by column).
589  ! ----------------------------------------------------------------
590  !
591  ! 4. Subroutines used :
592  !
593  ! Name Type Module Description
594  ! ----------------------------------------------------------------
595  ! STRACE Subr. W3SERVMD Subroutine tracing.
596  ! ----------------------------------------------------------------
597  !
598  ! 5. Called by :
599  !
600  ! Name Type Module Description
601  ! ----------------------------------------------------------------
602  ! W3SRCE Subr. W3SRCEMD Source term integration.
603  ! W3EXPO Subr. N/A Point output post-processor.
604  ! GXEXPO Subr. N/A GrADS point output post-processor.
605  ! ----------------------------------------------------------------
606  !
607  ! 6. Error messages :
608  !
609  ! None.
610  !
611  ! 7. Remarks :
612  !
613  ! 8. Structure :
614  !
615  ! See source code.
616  !
617  ! 9. Switches :
618  !
619  ! !/S Enable subroutine tracing.
620  ! !/T6 Test output for dissipation terms T1 and T2.
621  !
622  ! 10. Source code :
623  !
624  !/ ------------------------------------------------------------------- /
625  USE constants, ONLY: grav, tpi
626  USE w3gdatmd, ONLY: nk, nth, nspec, dden, dsii, sig2, dth, xfr
627  USE w3gdatmd, ONLY: sds6a1, sds6a2, sds6p1, sds6p2, sds6et
628  USE w3odatmd, ONLY: ndse
629  USE w3servmd, ONLY: extcde
630 #ifdef W3_T6
631  USE w3timemd, ONLY: stme21
632  USE w3wdatmd, ONLY: time
633  USE w3odatmd, ONLY: ndst
634 #endif
635 #ifdef W3_S
636  USE w3servmd, ONLY: strace
637 #endif
638  !/
639  IMPLICIT NONE
640  !/
641  !/ ------------------------------------------------------------------- /
642  !/ Parameter list
643  REAL, INTENT(IN) :: a(nspec), cg(nk), wn(nk)
644  REAL, INTENT(OUT) :: s(nspec), d(nspec)
645  !/
646  !/ ------------------------------------------------------------------- /
647  !/ Local parameters
648 #ifdef W3_S
649  INTEGER, SAVE :: ient = 0
650 #endif
651  INTEGER :: ik, ith, ikn(nk)
652  REAL :: freq(nk) ! frequencies [Hz]
653  REAL :: dfii(nk) ! frequency bandwiths [Hz]
654  REAL :: anar(nk) ! directional narrowness
655  REAL :: bnt ! empirical constant for
656  ! wave breaking probability
657  REAL :: edens (nk) ! spectral density E(f)
658  REAL :: etdens(nk) ! threshold spec. density ET(f)
659  REAL :: exdens(nk) ! excess spectral density EX(f)
660  REAL :: nexdens(nk) ! normalised excess spectral density
661  REAL :: t1(nk) ! inherent breaking term
662  REAL :: t2(nk) ! forced dissipation term
663  REAL :: t12(nk) ! = T1+T2 or combined dissipation
664  REAL :: adf(nk), xfac, edensmax ! temp. variables
665 #ifdef W3_T6
666  CHARACTER(LEN=23) :: idtime
667 #endif
668  !/
669  !/ ------------------------------------------------------------------- /
670  !/
671 #ifdef W3_S
672  CALL strace (ient, 'W3SDS6')
673 #endif
674  !
675  !/ 0) --- Initialize essential parameters ---------------------------- /
676  ikn = irange(1,nspec,nth) ! Index vector for elements of 1,
677  ! ! 2,..., NK such that for example
678  ! ! SIG(1:NK) = SIG2(IKN).
679  freq = sig2(ikn)/tpi
680  anar = 1.0
681  bnt = 0.035**2
682  t1 = 0.0
683  t2 = 0.0
684  nexdens = 0.0
685  !
686  !/ 1) --- Calculate threshold spectral density, spectral density, and
687  !/ the level of exceedence EXDENS(f) -------------------------- /
688  etdens = ( tpi * bnt ) / ( anar * cg * wn**3 )
689  edens = sum(reshape(a,(/ nth,nk /)),1) * tpi * sig2(ikn) * dth / cg ! E(f)
690  exdens = max(0.0,edens-etdens)
691  !
692  !/ --- normalise by a generic spectral density -------------------- /
693  IF (sds6et) THEN ! ww3_grid.inp: &SDS6 SDSET = T or F
694  nexdens = exdens / etdens ! normalise by threshold spectral density
695  ELSE ! normalise by spectral density
696  edensmax = maxval(edens)*1e-5
697  IF (all(edens .GT. edensmax)) THEN
698  nexdens = exdens / edens
699  ELSE
700  DO ik = 1,nk
701  IF (edens(ik) .GT. edensmax) nexdens(ik) = exdens(ik) / edens(ik)
702  END DO
703  END IF
704  END IF
705  !
706  !/ 2) --- Calculate inherent breaking component T1 ------------------- /
707  t1 = sds6a1 * anar * freq * (nexdens**sds6p1)
708  !
709  !/ 3) --- Calculate T2, the dissipation of waves induced by
710  !/ the breaking of longer waves T2 ---------------------------- /
711  adf = anar * (nexdens**sds6p2)
712  xfac = (1.0-1.0/xfr)/(xfr-1.0/xfr)
713  DO ik = 1,nk
714  dfii = dsii/tpi
715  ! IF (IK .GT. 1) DFII(IK) = DFII(IK) * XFAC
716  IF (ik .GT. 1 .AND. ik .LT. nk) dfii(ik) = dfii(ik) * xfac
717  t2(ik) = sds6a2 * sum( adf(1:ik)*dfii(1:ik) )
718  END DO
719  !
720  !/ 4) --- Sum up dissipation terms and apply to all directions ------- /
721  t12 = -1.0 * ( max(0.0,t1)+max(0.0,t2) )
722  DO ith = 1, nth
723  d(ikn+ith-1) = t12
724  END DO
725  !
726  s = d * a
727  !
728  !/ 5) --- Diagnostic output (switch !/T6) ---------------------------- /
729 #ifdef W3_T6
730  CALL stme21 ( time , idtime )
731  WRITE (ndst,270) 'T1*E',idtime(1:19),(t1*edens)
732  WRITE (ndst,270) 'T2*E',idtime(1:19),(t2*edens)
733  WRITE (ndst,271) sum(sum(reshape(s,(/ nth,nk /)),1)*dden/cg)
734  !
735 270 FORMAT (' TEST W3SDS6 : ',a,'(',a,')',':',70e11.3)
736 271 FORMAT (' TEST W3SDS6 : Total SDS =',e13.5)
737 #endif
738  !/
739  !/ End of W3SDS6 ----------------------------------------------------- /
740  !/
741  END SUBROUTINE w3sds6
742  !/ ------------------------------------------------------------------- /
743  !/
744 
769  SUBROUTINE lfactor(S, CINV, U10, USTAR, USDIR, SIG, DSII, &
770  LFACT, TAUWX, TAUWY )
771  !/
772  !/ +-----------------------------------+
773  !/ | WAVEWATCH III NOAA/NCEP |
774  !/ | S. Zieger |
775  !/ | Q. Liu |
776  !/ | FORTRAN 90 |
777  !/ | Last update : 26-Jun-2018 |
778  !/ +-----------------------------------+
779  !/
780  !/ 15-Feb-2011 : Implemented following Rogers et al. (2012)
781  !/ (S. Zieger)
782  !/ 26-Jun-2018 : UPROXY, DSII10Hz Updates ( version 6.06 )
783  !/ (Q. Liu )
784  !
785  ! Rogers et al. (2012) JTECH 29(9), 1329-1346
786  !
787  ! 1. Purpose :
788  !
789  ! Numerical approximation for the reduction factor LFACTOR(f) to
790  ! reduce energy in the high-frequency part of the resolved part
791  ! of the spectrum to meet the constraint on total stress (TAU).
792  ! The constraint is TAU <= TAU_TOT (TAU_TOT = TAU_WAV + TAU_VIS),
793  ! thus the wind input is reduced to match our constraint.
794  !
795  ! 2. Method :
796  !
797  ! 1) If required, extend resolved part of the spectrum to 10Hz using
798  ! an approximation for the spectral slope at the high frequency
799  ! limit: Sin(F) prop. F**(-2) and for E(F) prop. F**(-5).
800  ! 2) Calculate stresses:
801  ! total stress: TAU_TOT = DAIR * USTAR**2
802  ! viscous stress: TAU_VIS = DAIR * Cv * U10**2
803  ! viscous stress (x,y-components):
804  ! TAUV_X = TAU_VIS * COS(USDIR)
805  ! TAUV_Y = TAU_VIS * SIN(USDIR)
806  ! wave supported stress (x,y-components): /10Hz
807  ! TAUW_X,Y = GRAV * DWAT * | [SinX,Y(F)]/C(F) dF
808  ! /
809  ! total stress (input): TAU = SQRT( (TAUW_X + TAUV_X)**2
810  ! + (TAUW_Y + TAUV_Y)**2 )
811  ! 3) If TAU does not meet our constraint reduce the wind input
812  ! using reduction factor:
813  ! LFACT(F) = MIN(1,exp((1-U/C(F))*RTAU))
814  ! Then alter RTAU and repeat 3) until our constraint is matched.
815  !
816  ! 3. Parameters :
817  !
818  ! Parameter list
819  ! ----------------------------------------------------------------
820  ! S R.A. I Wind input energy density spectrum (S_{in}(σ, θ))
821  ! CINV R.A. I Inverse phase speed 1/C(sigma)
822  ! U10 Real I Wind speed (10m)
823  ! USTAR Real I Friction velocity
824  ! USDIR Real I Wind direction
825  ! SIG R.A. I Relative frequencies [in rad.]
826  ! DSII R.A. I Frequency bandwiths [in rad.]
827  ! LFACTOR R.A. O Factor array LFACT(sigma)
828  ! TAUWX-Y Real O Component of the wave-supported stress
829  ! ----------------------------------------------------------------
830  !
831  ! 4. Subroutines used :
832  !
833  ! Name Type Scope Description
834  ! ----------------------------------------------------------------
835  ! STRACE Subr. W3SERVMD Subroutine tracing.
836  ! IRANGE Func. Private Index generator (ie, array addressing)
837  ! TAUWINDS Func. Private Normal stress calculation (TAU_NRM)
838  ! ----------------------------------------------------------------
839  !
840  ! ----------------------------------------------------------------
841  !
842  ! 5. Error messages :
843  !
844  ! A warning is issued to NDST using format 280 if the iteration
845  ! procedure reaches the upper iteration limit (ITERMAX). In this
846  ! case the last approximation for RTAU is used.
847  !
848  !/
849  USE constants, ONLY: dair, grav, tpi
850  USE w3gdatmd, ONLY: nk, nth, nspec, dth, xfr, ecos, esin
851  USE w3gdatmd, ONLY: sin6ws
852  USE w3odatmd, ONLY: ndst, ndse, iaproc, naperr
853  USE w3timemd, ONLY: stme21
854  USE w3wdatmd, ONLY: time
855 #ifdef W3_S
856  USE w3servmd, ONLY: strace
857 #endif
858  IMPLICIT NONE
859  !
860  !/ ------ I/O parameters --------------------------------------------- /
861  REAL, INTENT(IN) :: s(nth,nk) ! wind-input source term Sin
862  REAL, INTENT(IN) :: cinv(nk) ! inverse phase speed
863  REAL, INTENT(IN) :: u10 ! wind speed
864  REAL, INTENT(IN) :: ustar, usdir ! friction velocity & direction
865  REAL, INTENT(IN) :: sig(nk) ! relative frequencies
866  REAL, INTENT(IN) :: dsii(nk) ! frequency bandwidths
867  REAL, INTENT(OUT) :: lfact(nk) ! correction factor
868  REAL, INTENT(OUT) :: tauwx, tauwy ! normal stress components
869  !
870  !/ --- local parameters (in order of appearance) ------------------ /
871 #ifdef W3_S
872  INTEGER, SAVE :: ient = 0
873 #endif
874  REAL, PARAMETER :: frqmax = 10. ! Upper freq. limit to extrapolate to.
875  INTEGER, PARAMETER:: itermax = 80 ! Maximum number of iterations to
876  ! find numerical solution for LFACT.
877  INTEGER :: ik, nk10hz, sign_new, sign_old
878  !
879  REAL :: ecos2(nspec), esin2(nspec)
880  REAL, ALLOCATABLE :: ik10hz(:), lf10hz(:), sig10hz(:), cinv10hz(:)
881  REAL, ALLOCATABLE :: sdens10hz(:), sdensx10hz(:), sdensy10hz(:)
882  REAL, ALLOCATABLE :: dsii10hz(:), ucinv10hz(:)
883  REAL :: tau_tot, tau, tau_vis, tau_wav
884  REAL :: tauvx, tauvy, taux, tauy
885  REAL :: tau_nnd, tau_init(2)
886  REAL :: uproxy, rtau, drtau, err
887  LOGICAL :: overshot
888  CHARACTER(LEN=23) :: idtime
889  !
890  !/ ------------------------------------------------------------------- /
891 #ifdef W3_S
892  CALL strace (ient, 'LFACTOR')
893 #endif
894  !
895  !/ 0) --- Find the number of frequencies required to extend arrays
896  !/ up to f=10Hz and allocate arrays --------------------------- /
897  !/ ALOG is the same as LOG
898  nk10hz = ceiling(alog(frqmax/(sig(1)/tpi))/alog(xfr))+1
899  nk10hz = max(nk,nk10hz)
900  !
901  ALLOCATE(ik10hz(nk10hz))
902  ik10hz = real( irange(1,nk10hz,1) )
903  !
904  ALLOCATE(sig10hz(nk10hz))
905  ALLOCATE(cinv10hz(nk10hz))
906  ALLOCATE(dsii10hz(nk10hz))
907  ALLOCATE(lf10hz(nk10hz))
908  ALLOCATE(sdens10hz(nk10hz))
909  ALLOCATE(sdensx10hz(nk10hz))
910  ALLOCATE(sdensy10hz(nk10hz))
911  ALLOCATE(ucinv10hz(nk10hz))
912  !
913  ecos2 = ecos(1:nspec)
914  esin2 = esin(1:nspec)
915  !
916  !/ 1) --- Either extrapolate arrays up to 10Hz or use discrete spectral
917  ! grid per se. Limit the constraint to the positive part of the
918  ! wind input only. ---------------------------------------------- /
919  IF (nk .LT. nk10hz) THEN
920  sdens10hz(1:nk) = sum(s,1) * dth
921  sdensx10hz(1:nk) = sum(max(0.,s)*reshape(ecos2,(/nth,nk/)),1) * dth
922  sdensy10hz(1:nk) = sum(max(0.,s)*reshape(esin2,(/nth,nk/)),1) * dth
923  sig10hz = sig(1)*xfr**(ik10hz-1.0)
924  cinv10hz(1:nk) = cinv
925  cinv10hz(nk+1:nk10hz) = sig10hz(nk+1:nk10hz)*0.101978 ! 1/c=σ/g
926  dsii10hz = 0.5 * sig10hz * (xfr-1.0/xfr)
927  ! The first and last frequency bin:
928  dsii10hz(1) = 0.5 * sig10hz(1) * (xfr-1.0)
929  dsii10hz(nk10hz) = 0.5 * sig10hz(nk10hz) * (xfr-1.0) / xfr
930  !
931  ! --- Spectral slope for S_IN(F) is proportional to F**(-2) ------ /
932  sdens10hz(nk+1:nk10hz) = sdens10hz(nk) * (sig10hz(nk)/sig10hz(nk+1:nk10hz))**2
933  sdensx10hz(nk+1:nk10hz) = sdensx10hz(nk) * (sig10hz(nk)/sig10hz(nk+1:nk10hz))**2
934  sdensy10hz(nk+1:nk10hz) = sdensy10hz(nk) * (sig10hz(nk)/sig10hz(nk+1:nk10hz))**2
935  ELSE
936  sig10hz = sig
937  cinv10hz = cinv
938  dsii10hz = dsii
939  sdens10hz(1:nk) = sum(s,1) * dth
940  sdensx10hz(1:nk) = sum(max(0.,s)*reshape(ecos2,(/nth,nk/)),1) * dth
941  sdensy10hz(1:nk) = sum(max(0.,s)*reshape(esin2,(/nth,nk/)),1) * dth
942  END IF
943  !
944  !/ 2) --- Stress calculation ----------------------------------------- /
945  ! --- The total stress ------------------------------------------- /
946  tau_tot = ustar**2 * dair
947  !
948  ! --- The viscous stress and check that it does not exceed
949  ! the total stress. ------------------------------------------ /
950  tau_vis = max(0.0, -5.0e-5*u10 + 1.1e-3) * u10**2 * dair
951  ! TAU_VIS = MIN(0.9 * TAU_TOT, TAU_VIS)
952  tau_vis = min(0.95 * tau_tot, tau_vis)
953  !
954  tauvx = tau_vis * cos(usdir)
955  tauvy = tau_vis * sin(usdir)
956  !
957  ! --- The wave supported stress. --------------------------------- /
958  tauwx = tauwinds(sdensx10hz,cinv10hz,dsii10hz) ! normal stress (x-component)
959  tauwy = tauwinds(sdensy10hz,cinv10hz,dsii10hz) ! normal stress (y-component)
960  tau_nnd = tauwinds(sdens10hz, cinv10hz,dsii10hz) ! normal stress (non-directional)
961  tau_wav = sqrt(tauwx**2 + tauwy**2) ! normal stress (magnitude)
962  tau_init = (/tauwx,tauwy/) ! unadjusted normal stress components
963  !
964  taux = tauvx + tauwx ! total stress (x-component)
965  tauy = tauvy + tauwy ! total stress (y-component)
966  tau = sqrt(taux**2 + tauy**2) ! total stress (magnitude)
967  err = (tau-tau_tot)/tau_tot ! initial error
968  !
969  !/ 3) --- Find reduced Sin(f) = L(f)*Sin(f) to satisfy our constraint
970  !/ TAU <= TAU_TOT --------------------------------------------- /
971  CALL stme21 ( time , idtime )
972  lf10hz = 1.0
973  ik = 0
974  !
975  IF (tau .GT. tau_tot) THEN
976  overshot = .false.
977  rtau = err / 90.
978  drtau = 2.0
979  sign_new = int(sign(1.0,err))
980 
981  uproxy = sin6ws * ustar
982  ucinv10hz = 1.0 - (uproxy * cinv10hz)
983  !
984 #ifdef W3_T6
985  WRITE (ndst,270) idtime, u10
986  WRITE (ndst,271)
987 #endif
988  DO ik=1,itermax
989  lf10hz = min(1.0, exp(ucinv10hz * rtau) )
990  !
991  tau_nnd = tauwinds(sdens10hz *lf10hz,cinv10hz,dsii10hz)
992  tauwx = tauwinds(sdensx10hz*lf10hz,cinv10hz,dsii10hz)
993  tauwy = tauwinds(sdensy10hz*lf10hz,cinv10hz,dsii10hz)
994  tau_wav = sqrt(tauwx**2 + tauwy**2)
995  !
996  taux = tauvx + tauwx
997  tauy = tauvy + tauwy
998  tau = sqrt(taux**2 + tauy**2)
999  err = (tau-tau_tot) / tau_tot
1000  !
1001  sign_old = sign_new
1002  sign_new = int(sign(1.0, err))
1003 #ifdef W3_T6
1004  WRITE (ndst,272) ik, rtau, drtau, tau, tau_tot, err, &
1005  tauwx, tauwy, tauvx, tauvy, tau_nnd
1006 #endif
1007  !
1008  ! --- Slow down DRTAU when overshot. -------------------------- /
1009  IF (sign_new .NE. sign_old) overshot = .true.
1010  IF (overshot) drtau = max(0.5*(1.0+drtau),1.00010)
1011  !
1012  rtau = rtau * (drtau**sign_new)
1013  !
1014  IF (abs(err) .LT. 1.54e-4) EXIT
1015  END DO
1016  !
1017  IF (ik .GE. itermax) WRITE (ndst,280) idtime(1:19), u10, tau, &
1018  tau_tot, err, tauwx, tauwy, tauvx, tauvy,tau_nnd
1019  END IF
1020  !
1021  lfact(1:nk) = lf10hz(1:nk)
1022  !
1023 #ifdef W3_T6
1024  WRITE (ndst,273) 'Sin ', idtime(1:19), sdens10hz*tpi
1025  WRITE (ndst,273) 'SinR', idtime(1:19), sdens10hz*lf10hz*tpi
1026  WRITE (ndst,274) 'Sin ', sum(sdens10hz(1:nk)*dsii)
1027  WRITE (ndst,274) 'SinR ', sum(sdens10hz(1:nk)*lf10hz(1:nk)*dsii)
1028  WRITE (ndst,274) 'SinR/C', tauwinds(sdens10hz(1:nk)*lfact,cinv,dsii)
1029  !
1030 270 FORMAT (' TEST W3SIN6 : LFACTOR SUBROUTINE CALCULATING FOR ', &
1031  a,' U10=',f5.1 )
1032 271 FORMAT (' TEST W3SIN6 : IK RTAU DRTAU TAU TAU_TOT' &
1033  ' ERR TAUW_X TAUW_Y TAUV_X TAUV_Y TAU1D' )
1034 272 FORMAT (' TEST W3SIN6 : ',i2,2f9.5,2f8.5,e10.2,4f7.4,f7.3 )
1035 273 FORMAT (' TEST W3SIN6 : ',a,'(',a,'):', 70e11.3 )
1036 #endif
1037 274 FORMAT (' TEST W3SIN6 : Total ',a,' =', e13.5 )
1038 280 FORMAT (' WARNING LFACTOR (TIME,U10,TAU,TAU_TOT,ERR,TAUW_XY,' &
1039  'TAUV_XY,TAU_SCALAR): ',a,f6.1,2f7.4,e10.3,4f7.4,f7.3 )
1040  !
1041  DEALLOCATE(ik10hz,sig10hz,cinv10hz,dsii10hz,lf10hz)
1042  DEALLOCATE(sdens10hz,sdensx10hz,sdensy10hz,ucinv10hz)
1043  !/
1044  END SUBROUTINE lfactor
1045  !/ ------------------------------------------------------------------- /
1046  !/
1047 
1066  SUBROUTINE tau_wave_atmos(S, CINV, SIG, DSII, TAUNWX, TAUNWY )
1067  !/
1068  !/ +-----------------------------------+
1069  !/ | WAVEWATCH III NOAA/NCEP |
1070  !/ | S. Zieger |
1071  !/ | Q. Liu |
1072  !/ | FORTRAN 90 |
1073  !/ | Last update : 26-Jun-2018 |
1074  !/ +-----------------------------------+
1075  !/
1076  !/ 24-Oct-2013 : Origination following LFACTOR
1077  !/ (S. Zieger)
1078  !/ 26-Jun-2018 : Updates on DSII10Hz ( version 6.06)
1079  !/ (Q. Liu)
1080  !
1081  ! 1. Purpose :
1082  !
1083  ! Calculated the stress for the negative part of the input term,
1084  ! that is the stress from the waves to the atmosphere. Relevant
1085  ! in the case of opposing winds.
1086  !
1087  ! 2. Method :
1088  ! 1) If required, extend resolved part of the spectrum to 10Hz using
1089  ! an approximation for the spectral slope at the high frequency
1090  ! limit: Sin(F) prop. F**(-2) and for E(F) prop. F**(-5).
1091  ! 2) Calculate stresses:
1092  ! stress components (x,y): /10Hz
1093  ! TAUNW_X,Y = GRAV * DWAT * | [SinX,Y(F)]/C(F) dF
1094  ! /
1095  ! 3. Parameters :
1096  !
1097  ! Parameter list
1098  ! ----------------------------------------------------------------
1099  ! S R.A. I Wind input energy density spectrum
1100  ! CINV R.A. I Inverse phase speed 1/C(sigma)
1101  ! SIG R.A. I Relative frequencies [in rad.]
1102  ! DSII R.A. I Frequency bandwiths [in rad.]
1103  ! TAUNWX-Y Real O Component of the negative wave-supported stress
1104  ! ----------------------------------------------------------------
1105  !
1106  ! 4. Subroutines used :
1107  !
1108  ! Name Type Scope Description
1109  ! ----------------------------------------------------------------
1110  ! STRACE Subr. W3SERVMD Subroutine tracing.
1111  ! IRANGE Func. Private Index generator (ie, array addressing)
1112  ! TAUWINDS Func. Private Normal stress calculation (TAU_NRM)
1113  ! ----------------------------------------------------------------
1114  !
1115  ! 5. Source code :
1116  !
1117  !/
1118  USE constants, ONLY: grav, tpi
1119  USE w3gdatmd, ONLY: nk, nth, nspec, dth, xfr, ecos, esin
1120 #ifdef W3_S
1121  USE w3servmd, ONLY: strace
1122 #endif
1123  IMPLICIT NONE
1124  !
1125  !/ ------ I/O parameters --------------------------------------------- /
1126  REAL, INTENT(IN) :: S(NTH,NK) ! wind-input source term Sin
1127  REAL, INTENT(IN) :: CINV(NK) ! inverse phase speed
1128  REAL, INTENT(IN) :: SIG(NK) ! relative frequencies
1129  REAL, INTENT(IN) :: DSII(NK) ! frequency bandwidths
1130  REAL, INTENT(OUT) :: TAUNWX, TAUNWY ! stress components (wave->atmos)
1131  !
1132  !/ --- local parameters (in order of appearance) ------------------ /
1133 #ifdef W3_S
1134  INTEGER, SAVE :: IENT = 0
1135 #endif
1136  REAL, PARAMETER :: FRQMAX = 10. ! Upper freq. limit to extrapolate to.
1137  INTEGER :: NK10Hz
1138  !
1139  REAL :: ECOS2(NSPEC), ESIN2(NSPEC)
1140  REAL, ALLOCATABLE :: IK10Hz(:), SIG10Hz(:), CINV10Hz(:)
1141  REAL, ALLOCATABLE :: SDENSX10Hz(:), SDENSY10Hz(:)
1142  REAL, ALLOCATABLE :: DSII10Hz(:), UCINV10Hz(:)
1143  !
1144  !/ ------------------------------------------------------------------- /
1145 #ifdef W3_S
1146  CALL strace (ient, 'TAU_WAVE_ATMOS')
1147 #endif
1148  !
1149  !/ 0) --- Find the number of frequencies required to extend arrays
1150  !/ up to f=10Hz and allocate arrays --------------------------- /
1151  nk10hz = ceiling(alog(frqmax/(sig(1)/tpi))/alog(xfr))+1
1152  nk10hz = max(nk,nk10hz)
1153  !
1154  ALLOCATE(ik10hz(nk10hz))
1155  ik10hz = real( irange(1,nk10hz,1) )
1156  !
1157  ALLOCATE(sig10hz(nk10hz))
1158  ALLOCATE(cinv10hz(nk10hz))
1159  ALLOCATE(dsii10hz(nk10hz))
1160  ALLOCATE(sdensx10hz(nk10hz))
1161  ALLOCATE(sdensy10hz(nk10hz))
1162  ALLOCATE(ucinv10hz(nk10hz))
1163  !
1164  ecos2 = ecos(1:nspec)
1165  esin2 = esin(1:nspec)
1166  !
1167  !/ 1) --- Either extrapolate arrays up to 10Hz or use discrete spectral
1168  ! grid per se. Limit the constraint to the positive part of the
1169  ! wind input only. ---------------------------------------------- /
1170  IF (nk .LT. nk10hz) THEN
1171  sdensx10hz(1:nk) = sum(abs(min(0.,s))*reshape(ecos2,(/nth,nk/)),1) * dth
1172  sdensy10hz(1:nk) = sum(abs(min(0.,s))*reshape(esin2,(/nth,nk/)),1) * dth
1173  sig10hz = sig(1)*xfr**(ik10hz-1.0)
1174  cinv10hz(1:nk) = cinv
1175  cinv10hz(nk+1:nk10hz) = sig10hz(nk+1:nk10hz)*0.101978
1176  dsii10hz = 0.5 * sig10hz * (xfr-1.0/xfr)
1177  ! The first and last frequency bin:
1178  dsii10hz(1) = 0.5 * sig10hz(1) * (xfr-1.0)
1179  dsii10hz(nk10hz) = 0.5 * sig10hz(nk10hz) * (xfr-1.0) / xfr
1180  !
1181  ! --- Spectral slope for S_IN(F) is proportional to F**(-2) ------ /
1182  sdensx10hz(nk+1:nk10hz) = sdensx10hz(nk) * (sig10hz(nk)/sig10hz(nk+1:nk10hz))**2
1183  sdensy10hz(nk+1:nk10hz) = sdensy10hz(nk) * (sig10hz(nk)/sig10hz(nk+1:nk10hz))**2
1184  ELSE
1185  sig10hz = sig
1186  cinv10hz = cinv
1187  dsii10hz = dsii
1188  sdensx10hz(1:nk) = sum(abs(min(0.,s))*reshape(ecos2,(/nth,nk/)),1) * dth
1189  sdensy10hz(1:nk) = sum(abs(min(0.,s))*reshape(esin2,(/nth,nk/)),1) * dth
1190  END IF
1191  !
1192  !/ 2) --- Stress calculation ----------------------------------------- /
1193  ! --- The wave supported stress (waves to atmosphere) ------------ /
1194  taunwx = tauwinds(sdensx10hz,cinv10hz,dsii10hz) ! x-component
1195  taunwy = tauwinds(sdensy10hz,cinv10hz,dsii10hz) ! y-component
1196  !/
1197  END SUBROUTINE tau_wave_atmos
1198  !/ ------------------------------------------------------------------- /
1199  !/
1200 
1214  FUNCTION irange(X0,X1,DX) RESULT(IX)
1215  !/
1216  !/ +-----------------------------------+
1217  !/ | WAVEWATCH III NOAA/NCEP |
1218  !/ | S. Zieger |
1219  !/ | FORTRAN 90 |
1220  !/ | Last update : 15-Feb-2011 |
1221  !/ +-----------------------------------+
1222  !/
1223  !/ 15-Feb-2011 : Origination ( version 4.04 )
1224  !/ (S. Zieger)
1225  !/
1226  ! 1. Purpose :
1227  ! Generate a sequence of linear-spaced integer numbers.
1228  ! Used for instance array addressing (indexing).
1229  !
1230  !/
1231  IMPLICIT NONE
1232  INTEGER, INTENT(IN) :: X0, X1, DX
1233  INTEGER, ALLOCATABLE :: IX(:)
1234  INTEGER :: N
1235  INTEGER :: I
1236  !
1237  n = int(real(x1-x0)/real(dx))+1
1238  ALLOCATE(ix(n))
1239  DO i = 1, n
1240  ix(i) = x0+ (i-1)*dx
1241  END DO
1242  !/
1243  END FUNCTION irange
1244  !/ ------------------------------------------------------------------- /
1245  !/
1246 
1267  FUNCTION tauwinds(SDENSIG,CINV,DSII) RESULT(TAU_WINDS)
1268  !/
1269  !/ +-----------------------------------+
1270  !/ | WAVEWATCH III NOAA/NCEP |
1271  !/ | S. Zieger |
1272  !/ | FORTRAN 90 |
1273  !/ | Last update : 13-Aug-2012 |
1274  !/ +-----------------------------------+
1275  !/
1276  !/ 15-Feb-2011 : Origination ( version 4.04 )
1277  !/ (S. Zieger)
1278  !/
1279  ! 1. Purpose :
1280  ! Wind stress (tau) computation from wind-momentum-input
1281  ! function which can be obtained from wind-energy-input (Sin).
1282  !
1283  ! / FRMAX
1284  ! tau = g * rho_water * | Sin(f)/C(f) df
1285  ! /
1286  !/
1287  USE constants, ONLY: grav, dwat ! gravity, density of water
1288  IMPLICIT NONE
1289  REAL, INTENT(IN) :: SDENSIG(:) ! Sin(sigma) in [m2/rad-Hz]
1290  REAL, INTENT(IN) :: CINV(:) ! inverse phase speed
1291  REAL, INTENT(IN) :: DSII(:) ! freq. bandwidths in [radians]
1292  REAL :: TAU_WINDS ! wind stress
1293  !
1294  tau_winds = grav * dwat * sum(sdensig*cinv*dsii)
1295  !/
1296  END FUNCTION tauwinds
1297  !/ ------------------------------------------------------------------- /
1298  !/
1299  !/ End of module W3SRC6MD -------------------------------------------- /
1300  !/
1301 END MODULE w3src6md
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3gdatmd::sds6p2
integer, pointer sds6p2
Definition: w3gdatmd.F90:1337
w3src6md::tau_wave_atmos
subroutine tau_wave_atmos(S, CINV, SIG, DSII, TAUNWX, TAUNWY)
Calculated the stress for the negative part of the input term.
Definition: w3src6md.F90:1067
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
constants::dair
real, parameter dair
DAIR Density of air (kg/m3).
Definition: constants.F90:63
w3wdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: w3wdatmd.F90:18
w3gdatmd::sds6a1
real, pointer sds6a1
Definition: w3gdatmd.F90:1335
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3odatmd::iaproc
integer, pointer iaproc
Definition: w3odatmd.F90:457
w3wdatmd::time
integer, dimension(:), pointer time
Definition: w3wdatmd.F90:172
w3gdatmd::ecos
real, dimension(:), pointer ecos
Definition: w3gdatmd.F90:1234
w3gdatmd::dden2
real, dimension(:), pointer dden2
Definition: w3gdatmd.F90:1234
w3src6md::w3sin6
subroutine, public w3sin6(A, CG, WN2, UABS, USTAR, USDIR, CD, DAIR, TAUWX, TAUWY, TAUNWX, TAUNWY, S, D)
Observation-based source term for wind input.
Definition: w3src6md.F90:292
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3gdatmd::esin
real, dimension(:), pointer esin
Definition: w3gdatmd.F90:1234
w3odatmd::naperr
integer, pointer naperr
Definition: w3odatmd.F90:457
w3gdatmd::sds6a2
real, pointer sds6a2
Definition: w3gdatmd.F90:1335
w3servmd
Definition: w3servmd.F90:3
w3gdatmd::dsii
real, dimension(:), pointer dsii
Definition: w3gdatmd.F90:1234
constants::tpiinv
real, parameter tpiinv
TPIINV Inverse of 2*Pi.
Definition: constants.F90:74
w3timemd::stme21
subroutine stme21(TIME, DTME21)
Definition: w3timemd.F90:682
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::sds6et
logical, pointer sds6et
Definition: w3gdatmd.F90:1338
w3gdatmd::sig2
real, dimension(:), pointer sig2
Definition: w3gdatmd.F90:1234
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3src6md::w3spr6
subroutine, public w3spr6(A, CG, WN, EMEAN, FMEAN, WNMEAN, AMAX, FP)
Calculate mean wave parameters.
Definition: w3src6md.F90:122
w3gdatmd::xfr
real, pointer xfr
Definition: w3gdatmd.F90:1232
w3gdatmd::sin6ws
real, pointer sin6ws
Definition: w3gdatmd.F90:1335
w3gdatmd::fte
real, pointer fte
Definition: w3gdatmd.F90:1232
w3gdatmd::sds6p1
integer, pointer sds6p1
Definition: w3gdatmd.F90:1337
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
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3src6md::w3sds6
subroutine, public w3sds6(A, CG, WN, S, D)
Observation-based source term for dissipation.
Definition: w3src6md.F90:547
w3src6md
Observation-based wind input and dissipation after Donelan et al (2006), and Babanin et al.
Definition: w3src6md.F90:27
w3gdatmd::ftf
real, pointer ftf
Definition: w3gdatmd.F90:1232
w3timemd
Definition: w3timemd.F90:3
w3gdatmd::ftwn
real, pointer ftwn
Definition: w3gdatmd.F90:1232
constants::grav
real, parameter grav
GRAV Acc.
Definition: constants.F90:61
w3gdatmd::sin6a0
real, pointer sin6a0
Definition: w3gdatmd.F90:1335