WAVEWATCH III  beta 0.0.1
w3src1md.F90
Go to the documentation of this file.
1 
6 
7 #include "w3macros.h"
8 
14 !/ ------------------------------------------------------------------- /
15 MODULE w3src1md
16  !/
17  !/ +-----------------------------------+
18  !/ | WAVEWATCH III NOAA/NCEP |
19  !/ | H. L. Tolman |
20  !/ | FORTRAN 90 |
21  !/ | Last update : 29-May-2009 |
22  !/ +-----------------------------------+
23  !/
24  !/ 06-Dec-1996 : Final FORTRAN 77 ( version 1.18 )
25  !/ 06-Dec-1999 : Upgrade to FORTRAN 90 ( version 2.00 )
26  !/ 23-Dec-2004 : Multiple grid version. ( version 3.06 )
27  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
28  !/
29  !/ Copyright 2009 National Weather Service (NWS),
30  !/ National Oceanic and Atmospheric Administration. All rights
31  !/ reserved. WAVEWATCH III is a trademark of the NWS.
32  !/ No unauthorized use without permission.
33  !/
34  ! 1. Purpose :
35  !
36  ! Bundle WAM cycle 3 input and dissipation source terms with
37  ! their defining parameters.
38  !
39  ! 2. Variables and types :
40  !
41  ! 3. Subroutines and functions :
42  !
43  ! Name Type Scope Description
44  ! ----------------------------------------------------------------
45  ! W3SPR1 Subr. Public Mean parameters from spectrum.
46  ! W3SIN1 Subr. Public Input source term.
47  ! W3SDS1 Subr. Public Dissipation source term.
48  ! ----------------------------------------------------------------
49  !
50  ! 4. Subroutines and functions used :
51  !
52  ! Name Type Module Description
53  ! ----------------------------------------------------------------
54  ! STRACE Subr. W3SERVMD Subroutine tracing. ( !/S )
55  ! PRT2DS Subr. W3ARRYMD Print plot of spectra. ( !/T0 )
56  ! OUTMAT Subr. W3WRRYMD Print out 2D matrix. ( !/T1 )
57  ! ----------------------------------------------------------------
58  !
59  ! 5. Remarks :
60  !
61  ! 6. Switches :
62  !
63  ! !/S Enable subroutine tracing.
64  ! !/T(n) Test output, see subroutines.
65  !
66  ! 7. Source code :
67  !
68  !/ ------------------------------------------------------------------- /
69  !/
70  PUBLIC
71  !/
72 CONTAINS
73  !/ ------------------------------------------------------------------- /
87  SUBROUTINE w3spr1 (A, CG, WN, EMEAN, FMEAN, WNMEAN, AMAX)
88  !/
89  !/ +-----------------------------------+
90  !/ | WAVEWATCH III NOAA/NCEP |
91  !/ | H. L. Tolman |
92  !/ | FORTRAN 90 |
93  !/ | Last update : 23-Dec-2004 |
94  !/ +-----------------------------------+
95  !/
96  !/ 06-Dec-1996 : Final FORTRAN 77 ( version 1.18 )
97  !/ 06-Dec-1999 : Upgrade to FORTRAN 90 ( version 2.00 )
98  !/ 23-Dec-2004 : Multiple grid version. ( version 3.06 )
99  !/
100  ! 1. Purpose :
101  !
102  ! Calculate mean wave parameters for the use in the source term
103  ! routines. (WAM-3)
104  !
105  ! 2. Method :
106  !
107  ! See source term routines.
108  !
109  ! 3. Parameters :
110  !
111  ! Parameter list
112  ! ----------------------------------------------------------------
113  ! A R.A. I Action as a function of direction and
114  ! wavenumber.
115  ! CG R.A. I Group velocities.
116  ! WN R.A. I Wavenumbers.
117  ! EMEAN Real O Mean wave energy.
118  ! FMEAN Real O Mean wave frequency.
119  ! WNMEAN Real O Mean wavenumber.
120  ! AMAX Real O Maximum action density in spectrum.
121  ! ----------------------------------------------------------------
122  !
123  ! 4. Subroutines used :
124  !
125  ! Name Type Module Description
126  ! ----------------------------------------------------------------
127  ! STRACE Subr. W3SERVMD Subroutine tracing.
128  ! ----------------------------------------------------------------
129  !
130  ! 5. Called by :
131  !
132  ! Name Type Module Description
133  ! ----------------------------------------------------------------
134  ! W3SRCE Subr. W3SRCEMD Source term integration.
135  ! W3EXPO Subr. N/A Point output post-processor.
136  ! GXEXPO Subr. N/A GrADS point output post-processor.
137  ! ----------------------------------------------------------------
138  !
139  ! 6. Error messages :
140  !
141  ! None.
142  !
143  ! 7. Remarks :
144  !
145  ! 8. Structure :
146  !
147  ! See source code.
148  !
149  ! 9. Switches :
150  !
151  ! !/S Enable subroutine tracing.
152  ! !/T Enable test output.
153  !
154  ! 10. Source code :
155  !
156  !/ ------------------------------------------------------------------- /
157  USE constants
158  USE w3gdatmd, ONLY: nk, nth, sig, dden, fte, ftf, ftwn
159 #ifdef W3_T
160  USE w3odatmd, ONLY: ndst
161 #endif
162 #ifdef W3_S
163  USE w3servmd, ONLY: strace
164 #endif
165  !
166  IMPLICIT NONE
167  !/
168  !/ ------------------------------------------------------------------- /
169  !/ Parameter list
170  !/
171  REAL, INTENT(IN) :: A(NTH,NK), CG(NK), WN(NK)
172  REAL, INTENT(OUT) :: EMEAN, FMEAN, WNMEAN, AMAX
173  !/
174  !/ ------------------------------------------------------------------- /
175  !/ Local parameters
176  !/
177  INTEGER :: IK, ITH
178 #ifdef W3_S
179  INTEGER, SAVE :: IENT = 0
180 #endif
181  REAL :: EB(NK), EBAND
182  !/
183  !/ ------------------------------------------------------------------- /
184  !/
185 #ifdef W3_S
186  CALL strace (ient, 'W3SPR1')
187 #endif
188  !
189  emean = 0.
190  fmean = 0.
191  wnmean = 0.
192  amax = 0.
193  !
194  ! 1. Integral over directions
195  !
196  DO ik=1, nk
197  eb(ik) = 0.
198  DO ith=1, nth
199  eb(ik) = eb(ik) + a(ith,ik)
200  amax = max( amax , a(ith,ik) )
201  END DO
202  END DO
203  !
204  ! 2. Integrate over directions
205  !
206  DO ik=1, nk
207  eb(ik) = eb(ik) * dden(ik) / cg(ik)
208  emean = emean + eb(ik)
209  fmean = fmean + eb(ik) / sig(ik)
210  wnmean = wnmean + eb(ik) / sqrt(wn(ik))
211  END DO
212  !
213  ! 3. Add tail beyond discrete spectrum
214  ! ( DTH * SIG absorbed in FTxx )
215  !
216  eband = eb(nk) / dden(nk)
217  emean = emean + eband * fte
218  fmean = fmean + eband * ftf
219  wnmean = wnmean + eband * ftwn
220  !
221  ! 4. Final processing
222  !
223  fmean = tpiinv * emean / max( 1.e-7 , fmean )
224  wnmean = ( emean / max( 1.e-7 , wnmean ) )**2
225  !
226 #ifdef W3_T
227  WRITE (ndst,9000) emean, fmean, wnmean
228 #endif
229  !
230  RETURN
231  !
232  ! Formats
233  !
234 #ifdef W3_T
235 9000 FORMAT (' TEST W3SPR1 : E,F,WN MEAN ',3e10.3)
236 #endif
237  !/
238  !/ End of W3SPR1 ----------------------------------------------------- /
239  !/
240  END SUBROUTINE w3spr1
241  !/ ------------------------------------------------------------------- /
255  SUBROUTINE w3sin1 (A, K, USTAR, USDIR, S, D)
256  !/
257  !/ +-----------------------------------+
258  !/ | WAVEWATCH III NOAA/NCEP |
259  !/ | H. L. Tolman |
260  !/ | FORTRAN 90 |
261  !/ | Last update : 23-Dec-2004 |
262  !/ +-----------------------------------+
263  !/
264  !/ 05-Dec-1996 : Final FORTRAN 77 ( version 1.18 )
265  !/ 08-Dec-1999 : Upgrade to FORTRAN 90 ( version 2.00 )
266  !/ 23-Dec-2004 : Multiple grid version. ( version 3.06 )
267  !/
268  ! 1. Purpose :
269  !
270  ! Calculate diagonal of input source (actual source term put
271  ! together in W3SRCE).
272  !
273  ! 2. Method :
274  !
275  ! WAM-3 : Snyder et al. (1981), Komen et al. (1984).
276  !
277  ! 3. Parameters :
278  !
279  ! Parameter list
280  ! ----------------------------------------------------------------
281  ! A R.A. I Action density spectrum (1-D).
282  ! K R.A. I Wavenumber for entire spectrum. *)
283  ! USTAR Real I Friction velocity.
284  ! USDIR Real I Direction of USTAR.
285  ! S R.A. O Source term (1-D version).
286  ! D R.A. O Diagonal term of derivative. *)
287  ! ----------------------------------------------------------------
288  ! *) Stored as 1-D array with dimension NTH*NK
289  !
290  ! 4. Subroutines used :
291  !
292  ! Name Type Module Description
293  ! ----------------------------------------------------------------
294  ! STRACE Subr. W3SERVMD Subroutine tracing.
295  ! PRT2DS Subr. W3SRRYMD Print plot of spectrum.
296  ! OUTMAT Subr. W3SRRYMD Print out matrix.
297  ! ----------------------------------------------------------------
298  !
299  ! 5. Called by :
300  !
301  ! Name Type Module Description
302  ! ----------------------------------------------------------------
303  ! W3SRCE Subr. W3SRCEMD Source term integration.
304  ! W3EXPO Subr. N/A Point output post-processor.
305  ! GXEXPO Subr. N/A GrADS point output post-processor.
306  ! ----------------------------------------------------------------
307  !
308  ! 6. Error messages :
309  !
310  ! 7. Remarks :
311  !
312  ! 8. Structure :
313  !
314  ! See source code.
315  !
316  ! 9. Switches :
317  !
318  ! !/S Enable subroutine tracing.
319  ! !/T Enable general test output.
320  ! !/T0 2-D print plot of source term.
321  ! !/T1 Print arrays.
322  !
323  ! 10. Source code :
324  !
325  !/ ------------------------------------------------------------------- /
326 #ifdef W3_T
327  USE constants
328 #endif
329  USE w3gdatmd, ONLY: nk, nth, nspec, sig, sig2, esin, ecos, sinc1
330 #ifdef W3_T
331  USE w3odatmd, ONLY: ndst
332 #endif
333 #ifdef W3_S
334  USE w3servmd, ONLY: strace
335 #endif
336 #ifdef W3_T0
337  USE w3arrymd, ONLY: prt2ds
338 #endif
339 #ifdef W3_T1
340  USE w3arrymd, ONLY: outmat
341 #endif
342  !
343  IMPLICIT NONE
344  !/
345  !/ ------------------------------------------------------------------- /
346  !/ Parameter list
347  !/
348  REAL, INTENT(IN) :: A(NSPEC), K(NSPEC), USTAR, USDIR
349  REAL, INTENT(OUT) :: S(NSPEC), D(NSPEC)
350  !/
351  !/ ------------------------------------------------------------------- /
352  !/ Local parameters
353  !/
354  INTEGER :: IS
355 #ifdef W3_S
356  INTEGER, SAVE :: IENT = 0
357 #endif
358 #ifdef W3_T0
359  INTEGER :: IK, ITH
360 #endif
361  REAL :: COSU, SINU
362 #ifdef W3_T0
363  REAL :: DOUT(NK,NTH)
364 #endif
365  !/
366  !/ ------------------------------------------------------------------- /
367  !/
368 #ifdef W3_S
369  CALL strace (ient, 'W3SIN1')
370 #endif
371  !
372 #ifdef W3_T
373  WRITE (ndst,9000) sinc1, ustar, usdir*rade
374 #endif
375  !
376  ! 1. Preparations
377  !
378  cosu = cos(usdir)
379  sinu = sin(usdir)
380  !
381  ! 2. Diagonal
382  !
383  DO is=1, nspec
384  d(is) = sinc1 * sig2(is) * max( 0. , &
385  ( ustar * (ecos(is)*cosu+esin(is)*sinu) &
386  * k(is)/sig2(is) - 0.035714) )
387  END DO
388  !
389  s = d * a
390  !
391  ! ... Test output of arrays
392  !
393 #ifdef W3_T0
394  DO ik=1, nk
395  DO ith=1, nth
396  dout(ik,ith) = d(ith+(ik-1)*nth)
397  END DO
398  END DO
399  CALL prt2ds (ndst, nk, nk, nth, dout, sig(1:), ' ', 1., &
400  0.0, 0.001, 'Diag Sin', ' ', 'NONAME')
401 #endif
402  !
403 #ifdef W3_T1
404  CALL outmat (ndst, d, nth, nth, nk, 'diag Sin')
405 #endif
406  !
407  RETURN
408  !
409  ! Formats
410  !
411 #ifdef W3_T
412 9000 FORMAT (' TEST W3SIN1 : COMMON FACT.: ',3e10.3)
413 #endif
414  !/
415  !/ End of W3SIN1 ----------------------------------------------------- /
416  !/
417  END SUBROUTINE w3sin1
418  !/ ------------------------------------------------------------------- /
432  SUBROUTINE w3sds1 (A, K, EMEAN, FMEAN, WNMEAN, S, D)
433  !/
434  !/ +-----------------------------------+
435  !/ | WAVEWATCH III NOAA/NCEP |
436  !/ | H. L. Tolman |
437  !/ | FORTRAN 90 |
438  !/ | Last update : 23-Dec-2004 |
439  !/ +-----------------------------------+
440  !/
441  !/ 05-Dec-1996 : Final FORTRAN 77 ( version 1.18 )
442  !/ 08-Dec-1999 : Upgrade to FORTRAN 90 ( version 2.00 )
443  !/ 23-Dec-2004 : Multiple grid version. ( version 3.06 )
444  !/
445  ! 1. Purpose :
446  !
447  ! Calculate whitecapping source term and diagonal term of derivative.
448  !
449  ! 2. Method :
450  !
451  ! WAM-3
452  !
453  ! 3. Parameters :
454  !
455  ! Parameter list
456  ! ----------------------------------------------------------------
457  ! A R.A. I Action density spectrum (1-D).
458  ! K R.A. I Wavenumber for entire spectrum. *)
459  ! EMEAN Real I Mean wave energy.
460  ! FMEAN Real I Mean wave frequency.
461  ! WNMEAN Real I Mean wavenumber.
462  ! S R.A. O Source term (1-D version).
463  ! D R.A. O Diagonal term of derivative. *)
464  ! ----------------------------------------------------------------
465  ! *) Stored in 1-D array with dimension NTH*NK
466  !
467  ! 4. Subroutines used :
468  !
469  ! Name Type Module Description
470  ! ----------------------------------------------------------------
471  ! STRACE Subr. W3SERVMD Subroutine tracing.
472  ! PRT2DS Subr. W3SRRYMD Print plot of spectrum.
473  ! OUTMAT Subr. W3SRRYMD Print out matrix.
474  ! ----------------------------------------------------------------
475  !
476  ! 5. Called by :
477  !
478  ! Name Type Module Description
479  ! ----------------------------------------------------------------
480  ! W3SRCE Subr. W3SRCEMD Source term integration.
481  ! W3EXPO Subr. N/A Point output post-processor.
482  ! GXEXPO Subr. N/A GrADS point output post-processor.
483  ! ----------------------------------------------------------------
484  !
485  ! 6. Error messages :
486  !
487  ! 7. Remarks :
488  !
489  ! 8. Structure :
490  !
491  ! See source code.
492  !
493  ! 9. Switches :
494  !
495  ! !/S Enable subroutine tracing.
496  ! !/T Enable general test output.
497  ! !/T0 2-D print plot of source term.
498  ! !/T1 Print arrays.
499  !
500  ! 10. Source code :
501  !
502  !/ ------------------------------------------------------------------- /
503  USE w3gdatmd, ONLY: nk, nth, nspec, sig, sdsc1
504 #ifdef W3_T
505  USE w3odatmd, ONLY: ndst
506 #endif
507 #ifdef W3_S
508  USE w3servmd, ONLY: strace
509 #endif
510 #ifdef W3_T0
511  USE w3arrymd, ONLY: prt2ds
512 #endif
513 #ifdef W3_T1
514  USE w3arrymd, ONLY: outmat
515 #endif
516  !
517  IMPLICIT NONE
518  !/
519  !/ ------------------------------------------------------------------- /
520  !/ Parameter list
521  !/
522  REAL, INTENT(IN) :: A(NSPEC), K(NSPEC), &
523  EMEAN, FMEAN, WNMEAN
524  REAL, INTENT(OUT) :: S(NSPEC), D(NSPEC)
525  !/
526  !/ ------------------------------------------------------------------- /
527  !/ Local parameters
528  !/
529  INTEGER :: IS
530 #ifdef W3_S
531  INTEGER, SAVE :: IENT = 0
532 #endif
533 #ifdef W3_T0
534  INTEGER :: IK, ITH
535 #endif
536  REAL :: FACTOR
537 #ifdef W3_T0
538  REAL :: DOUT(NK,NTH)
539 #endif
540  !/
541  !/ ------------------------------------------------------------------- /
542  !/
543 #ifdef W3_S
544  CALL strace (ient, 'W3SDS1')
545 #endif
546  !
547  ! 1. Common factor
548  !
549  factor = sdsc1 * fmean * wnmean**3 * emean**2
550  !
551 #ifdef W3_T
552  WRITE (ndst,9000) sdsc1, fmean, wnmean, emean, factor
553 #endif
554  !
555  ! 3. Source term
556  !
557  d = factor * k
558  s = d * a
559  !
560  ! ... Test output of arrays
561  !
562 #ifdef W3_T0
563  DO ik=1, nk
564  DO ith=1, nth
565  dout(ik,ith) = d(ith+(ik-1)*nth)
566  END DO
567  END DO
568  CALL prt2ds (ndst, nk, nk, nth, dout, sig(1:), ' ', 1., &
569  0.0, 0.001, 'Diag Sds', ' ', 'NONAME')
570 #endif
571  !
572 #ifdef W3_T1
573  CALL outmat (ndst, d, nth, nth, nk, 'diag Sds')
574 #endif
575  !
576  RETURN
577  !
578  ! Formats
579  !
580 #ifdef W3_T
581 9000 FORMAT (' TEST W3SDS1 : COMMON FACT.: ',5e10.3)
582 #endif
583  !/
584  !/ End of W3SDS1 ----------------------------------------------------- /
585  !/
586  END SUBROUTINE w3sds1
587  !/
588  !/ End of module W3SRC1MD -------------------------------------------- /
589  !/
590 END MODULE w3src1md
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3gdatmd::sdsc1
real, pointer sdsc1
Definition: w3gdatmd.F90:1301
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3gdatmd::ecos
real, dimension(:), pointer ecos
Definition: w3gdatmd.F90:1234
constants::rade
real, parameter rade
RADE Conversion factor from radians to degrees.
Definition: constants.F90:76
w3arrymd::outmat
subroutine outmat(NDS, A, MX, NX, NY, MNAME)
Definition: w3arrymd.F90:988
w3gdatmd::esin
real, dimension(:), pointer esin
Definition: w3gdatmd.F90:1234
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
w3gdatmd::sig2
real, dimension(:), pointer sig2
Definition: w3gdatmd.F90:1234
w3src1md::w3sin1
subroutine w3sin1(A, K, USTAR, USDIR, S, D)
Calculate diagonal of input source (actual source term put together in W3SRCE).
Definition: w3src1md.F90:256
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3arrymd
Definition: w3arrymd.F90:3
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
w3arrymd::prt2ds
subroutine prt2ds(NDS, NFR0, NFR, NTH, E, FR, UFR, FACSP, FSC, RRCUT, PRVAR, PRUNIT, PNTNME)
Definition: w3arrymd.F90:1943
w3gdatmd::sinc1
real, pointer sinc1
Definition: w3gdatmd.F90:1301
w3src1md
Bundle WAM cycle 3 input and dissipation source terms with their defining parameters.
Definition: w3src1md.F90:15
w3gdatmd::ftf
real, pointer ftf
Definition: w3gdatmd.F90:1232
w3gdatmd::ftwn
real, pointer ftwn
Definition: w3gdatmd.F90:1232
w3src1md::w3sds1
subroutine w3sds1(A, K, EMEAN, FMEAN, WNMEAN, S, D)
Calculate whitecapping source term and diagonal term of derivative.
Definition: w3src1md.F90:433
w3src1md::w3spr1
subroutine w3spr1(A, CG, WN, EMEAN, FMEAN, WNMEAN, AMAX)
Definition: w3src1md.F90:88