-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3src4md.F90
2571 lines (2534 loc) · 86.7 KB
/
w3src4md.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!> @file
!> @brief The 'SHOM/Ifremer' source terms based on P.A.E.M.
!>
!> @author F. Ardhuin
!> @date 13-Nov-2013
!>
#include "w3macros.h"
!/ ------------------------------------------------------------------- /
!>
!> @brief The 'SHOM/Ifremer' source terms based on P.A.E.M.
!>
!> @details Janssen's wind input
!> and dissipation functions by Ardhuin et al. (2009,2010)
!> and Filipot & Ardhuin (2010)
!> The wind input is converted from the original
!> WAM codes, courtesy of P.A.E.M. Janssen and J. Bidlot
!>
!> @author F. Ardhuin
!> @date 13-Nov-2013
!>
!> @copyright Copyright 2009-2022 National Weather Service (NWS),
!> National Oceanic and Atmospheric Administration. All rights
!> reserved. WAVEWATCH III is a trademark of the NWS.
!> No unauthorized use without permission.
!>
MODULE W3SRC4MD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III SHOM |
!/ ! F. Ardhuin !
!/ | FORTRAN 90 |
!/ | Last update : 13-Nov-2013 |
!/ +-----------------------------------+
!/
!/ 30-Aug-2010 : Origination. ( version 3.14-Ifremer )
!/ 02-Nov-2010 : Addding fudge factor for low freq. ( version 4.03 )
!/ 02-Sep-2011 : Clean up and time optimization ( version 4.04 )
!/ 04-Sep-2011 : Estimation of whitecap stats. ( version 4.04 )
!/ 13-Nov-2013 : Reduced frequency range with IG ( version 4.13 )
!/
! 1. Purpose :
!
! The 'SHOM/Ifremer' source terms based on P.A.E.M. Janssen's wind input
! and dissipation functions by Ardhuin et al. (2009,2010)
! and Filipot & Ardhuin (2010)
! The wind input is converted from the original
! WAM codes, courtesy of P.A.E.M. Janssen and J. Bidlot
!
!
! 2. Variables and types :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 3. Subroutines and functions :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! W3SPR4 Subr. Public Mean parameters from spectrum.
! W3SIN4 Subr. Public WAM4+ input source term.
! INSIN4 Subr. Public Corresponding initialization routine.
! TABU_STRESS, TABU_TAUHF, TABU_TAUHF2
! Subr. Public Populate various tables.
! CALC_USTAR
! Subr. Public Compute stresses.
! W3SDS4 Subr. Public Dissipation (Ardhuin & al. / Filipot & Ardhuin)
! ----------------------------------------------------------------
!
! 4. Subroutines and functions used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 5. Remarks :
!
! 6. Switches :
!
! 7. Source code :
!/
!/ ------------------------------------------------------------------- /
!/
PUBLIC
!/
!/ Public variables
!/
!air kinematic viscosity (used in WAM)
INTEGER, PARAMETER :: ITAUMAX=200,JUMAX=200
INTEGER, PARAMETER :: IUSTAR=100,IALPHA=200, ILEVTAIL=50
REAL :: TAUT(0:ITAUMAX,0:JUMAX), DELTAUW, DELU
! Table for H.F. stress as a function of 2 variables
REAL :: TAUHFT(0:IUSTAR,0:IALPHA), DELUST, DELALP
! Table for H.F. stress as a function of 3 variables
REAL :: TAUHFT2(0:IUSTAR,0:IALPHA,0:ILEVTAIL)
! Table for swell damping
REAL :: DELTAIL
REAL, PARAMETER :: UMAX = 50.
REAL, PARAMETER :: TAUWMAX = 2.2361 !SQRT(5.)
INTEGER :: DIKCUMUL
! Size of wave height table for integrating the PDF of wave heights
INTEGER, PARAMETER :: NKHI=100, FAC_KD2=1000
REAL, PARAMETER :: FAC_KD1=1.01, KHSMAX=2., KHMAX=2.
REAL, PARAMETER ::KDMAX=200000.
!/
CONTAINS
!/ ------------------------------------------------------------------- /
!>
!> @brief Calculate mean wave parameters for the use in the source term
!> routines.
!>
!> @param[in] A Action density spectrum.
!> @param[in] CG Group velocities.
!> @param[in] WN Wavenumbers.
!> @param[out] EMEAN Energy.
!> @param[out] FMEAN Mean frequency for determination of tail.
!> @param[out] FMEAN1 Mean frequency (fm0,-1) used for reflection.
!> @param[out] WNMEAN Mean wavenumber.
!> @param[out] AMAX Maximum of action spectrum.
!> @param[in] U Wind speed.
!> @param[in] UDIR Wind direction.
!> @param[in] TAUA Atm total stress.
!> @param[in] TAUADIR Atm total stress direction.
!> @param[in] DAIR Air density.
!> @param[inout] USTAR Friction velocity.
!> @param[inout] USDIR Wind stress direction.
!> @param[in] TAUWX Component of wave-supported stress.
!> @param[in] TAUWY Component of wave-supported stress.
!> @param[out] CD Drag coefficient at wind level ZWND.
!> @param[out] Z0 Corresponding z0.
!> @param[out] CHARN Corresponding Charnock coefficient.
!> @param[in] LLWS Wind sea true/false array for each component.
!> @param[out] FMEANWS Mean frequency of wind sea, used for tail.
!> @param[out] DLWMEAN Mean Long wave direction (L. Romero 2019).
!>
!> @author F. Ardhuin
!> @author H. L. Tolman
!> @date 22-Feb-2020
!>
SUBROUTINE W3SPR4 (A, CG, WN, EMEAN, FMEAN, FMEAN1, WNMEAN, &
AMAX, U, UDIR, &
#ifdef W3_FLX5
TAUA, TAUADIR, DAIR, &
#endif
USTAR, USDIR, &
TAUWX, TAUWY, CD, Z0, CHARN, LLWS, FMEANWS, DLWMEAN)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III SHOM |
!/ ! F. Ardhuin !
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 22-Feb-2020 |
!/ +-----------------------------------+
!/
!/ 03-Oct-2007 : Origination. ( version 3.13 )
!/ 13-Jun-2011 : Adds f_m0,-1 as FMEAN in the outout ( version 4.04 )
!/ 08-Jun-2018 : use STRACE and FLUSH ( version 6.04 )
!/ 22-Feb-2020 : Merge Romero (2019) and cleanup ( version 7.06 )
!/ 22-Jun-2021 : Add FLX5 to use stresses with the ST( version 7.14 )
!/
! 1. Purpose :
!
! Calculate mean wave parameters for the use in the source term
! routines.
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! A R.A. I Action density spectrum.
! CG R.A. I Group velocities.
! WN R.A. I Wavenumbers.
! EMEAN Real O Energy
! FMEAN1 Real O Mean frequency (fm0,-1) used for reflection
! FMEAN Real O Mean frequency for determination of tail
! WNMEAN Real O Mean wavenumber.
! AMAX Real O Maximum of action spectrum.
! U Real I Wind speed.
! UDIR Real I Wind direction.
! TAUA Real I Atm. total stress. ( /!FLX5 )
! TAUADIR Real I Atm. total stress direction. ( /!FLX5 )
! DAIR Real I Air density. ( /!FLX5 )
! USTAR Real I/O Friction velocity.
! USDIR Real I/O wind stress direction.
! TAUWX-Y Real I Components of wave-supported stress.
! CD Real O Drag coefficient at wind level ZWND.
! Z0 Real O Corresponding z0.
! CHARN Real O Corresponding Charnock coefficient
! LLWS L.A. I Wind sea true/false array for each component
! FMEANWS Real O Mean frequency of wind sea, used for tail
! DLWMEAN Real O Mean Long wave direction (L. Romero 2019)
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! STRACE Service routine.
!
! 5. Called by :
!
! W3SRCE Source term integration routine.
! W3OUTP Point output program.
! GXEXPO GrADS point output program.
!
! 6. Error messages :
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! !/S Enable subroutine tracing.
! !/T Enable test output.
! !/FLX5 Direct use of stress from atmoshperic model.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3ODATMD, ONLY: IAPROC
USE CONSTANTS, ONLY: TPIINV, GRAV, nu_air
USE W3GDATMD, ONLY: NK, NTH, NSPEC, SIG, DTH, DDEN, WWNMEANP, &
WWNMEANPTAIL, FTE, FTF, SSTXFTF, SSTXFTWN,&
SSTXFTFTAIL, SSWELLF, ESIN, ECOS, AAIRCMIN, &
AAIRGB, AALPHA, ZZWND
#ifdef W3_S
USE W3SERVMD, ONLY: STRACE
#endif
#ifdef W3_T
USE W3ODATMD, ONLY: NDST
USE W3ODATMD, ONLY: NDST
#endif
!
#ifdef W3_FLX5
USE W3FLX5MD
#endif
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
REAL, INTENT(IN) :: A(NTH,NK), CG(NK), WN(NK), U, UDIR
#ifdef W3_FLX5
REAL, INTENT(IN) :: TAUA, TAUADIR, DAIR
#endif
REAL, INTENT(IN) :: TAUWX, TAUWY
LOGICAL, INTENT(IN) :: LLWS(NSPEC)
REAL, INTENT(INOUT) :: USTAR ,USDIR
REAL, INTENT(OUT) :: EMEAN, FMEAN, FMEAN1, WNMEAN, AMAX, &
CD, Z0, CHARN, FMEANWS, DLWMEAN
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IS, IK, ITH
#ifdef W3_S
INTEGER, SAVE :: IENT = 0
#endif
REAL :: TAUW, EBAND, EMEANWS,UNZ, &
EB(NK),EB2(NK),ELCS, ELSN
!/
!/ ------------------------------------------------------------------- /
!/
#ifdef W3_S
CALL STRACE (IENT, 'W3SPR4')
#endif
!
UNZ = MAX ( 0.01 , U )
USTAR = MAX ( 0.0001 , USTAR )
!
EMEAN = 0.
EMEANWS= 0.
FMEANWS= 0.
FMEAN = 0.
FMEAN1 = 0.
WNMEAN = 0.
AMAX = 0.
DLWMEAN =0.
ELCS =0.
ELSN =0.
!
! 1. Integral over directions and maximum --------------------------- *
!
DO IK=1, NK
EB(IK) = 0.
EB2(IK) = 0.
DO ITH=1, NTH
IS=ITH+(IK-1)*NTH
EB(IK) = EB(IK) + A(ITH,IK)
ELCS = ELCS + A(ITH,IK)*ECOS(IS)*DDEN(IK) / CG(IK)
ELSN = ELSN + A(ITH,IK)*ESIN(IS)*DDEN(IK) / CG(IK)
IF (LLWS(IS)) EB2(IK) = EB2(IK) + A(ITH,IK)
AMAX = MAX ( AMAX , A(ITH,IK) )
END DO
END DO
DLWMEAN=ATAN2(ELSN,ELCS);
!
! 2. Integrate over directions -------------------------------------- *
!
DO IK=1, NK
EB(IK) = EB(IK) * DDEN(IK) / CG(IK)
EB2(IK) = EB2(IK) * DDEN(IK) / CG(IK)
EMEAN = EMEAN + EB(IK)
FMEAN = FMEAN + EB(IK) /SIG(IK)
FMEAN1 = FMEAN1 + EB(IK) *(SIG(IK)**(2.*WWNMEANPTAIL))
WNMEAN = WNMEAN + EB(IK) *(WN(IK)**WWNMEANP)
EMEANWS = EMEANWS+ EB2(IK)
FMEANWS = FMEANWS+ EB2(IK)*(SIG(IK)**(2.*WWNMEANPTAIL))
END DO
!
! 3. Add tail beyond discrete spectrum and get mean pars ------------ *
! ( DTH * SIG absorbed in FTxx )
!
EBAND = EB(NK) / DDEN(NK)
EMEAN = EMEAN + EBAND * FTE
FMEAN = FMEAN + EBAND * FTF
FMEAN1 = FMEAN1 + EBAND * SSTXFTFTAIL
WNMEAN = WNMEAN + EBAND * SSTXFTWN
EBAND = EB2(NK) / DDEN(NK)
EMEANWS = EMEANWS + EBAND * FTE
FMEANWS = FMEANWS + EBAND * SSTXFTFTAIL
!
! 4. Final processing
!
FMEAN = TPIINV * EMEAN / MAX ( 1.E-7 , FMEAN )
IF (FMEAN1.LT.1.E-7) THEN
FMEAN1=TPIINV * SIG(NK)
ELSE
FMEAN1 = TPIINV *( MAX ( 1.E-7 , FMEAN1 ) &
/ MAX ( 1.E-7 , EMEAN ))**(1/(2.*WWNMEANPTAIL))
ENDIF
WNMEAN = ( MAX ( 1.E-7 , WNMEAN ) &
/ MAX ( 1.E-7 , EMEAN ) )**(1/WWNMEANP)
IF (FMEANWS.LT.1.E-7.OR.EMEANWS.LT.1.E-7) THEN
FMEANWS=TPIINV * SIG(NK)
ELSE
FMEANWS = TPIINV *( MAX ( 1.E-7 , FMEANWS ) &
/ MAX ( 1.E-7 , EMEANWS ))**(1/(2.*WWNMEANPTAIL))
END IF
!
! 5. Cd and z0 ----------------------------------------------- *
!
TAUW = SQRT(TAUWX**2+TAUWY**2)
!
#ifdef W3_FLX5
CALL W3FLX5 ( ZZWND, U, UDIR, TAUA, TAUADIR, DAIR, &
USTAR, USDIR, Z0, CD, CHARN )
#else
Z0=0.
CALL CALC_USTAR(U,TAUW,USTAR,Z0,CHARN)
UNZ = MAX ( 0.01 , U )
CD = (USTAR/UNZ)**2
USDIR = UDIR
#endif
!
! 6. Final test output ---------------------------------------------- *
!
#ifdef W3_T
WRITE (NDST,9060) EMEAN, WNMEAN, TPIINV, USTAR, CD, Z0
#endif
!
USTAR = .0888
RETURN
!
! Formats
!
#ifdef W3_T
9060 FORMAT (' TEST W3SPR4 : E,WN MN :',F8.3,F8.4/ &
' TPIINV, USTAR, CD, Z0 :',F8.3,F7.2,1X,2F9.5)
#endif
!/
!/ End of W3SPR4 ----------------------------------------------------- /
!/
END SUBROUTINE W3SPR4
!/ ------------------------------------------------------------------- /
!>
!> @brief Calculate diagonal and input source term for WAM4+ approach.
!>
!> @verbatim
!> WAM-4 : Janssen et al.
!> WAM-"4.5" : gustiness effect (Cavaleri et al. )
!> SAT : high-frequency input reduction for balance with
!> saturation dissipation (Ardhuin et al., 2008)
!> SWELL : negative wind input (Ardhuin et al. 2008)
!> @endverbatim
!>
!> @param[in] A Action density spectrum (1-D).
!> @param[in] CG Group speed.
!> @param[in] K Wavenumber for entire spectrum.
!> @param[in] U Wind speed.
!> @param[in] USTAR Friction velocity.
!> @param[in] DRAT Air/water density ratio.
!> @param[in] AS Air-sea temperature difference.
!> @param[in] USDIR Wind stress direction.
!> @param[in] Z0 Air-sea roughness length.
!> @param[in] CD Wind drag coefficient.
!> @param[out] TAUWX Component of the wave-supported stress.
!> @param[out] TAUWY Component of the wave-supported stress.
!> @param[out] TAUWNX Component of the negative wave-supported stress.
!> @param[out] TAUWNY Component of the negative wave-supported stress.
!> @param[out] S Source term (1-D version).
!> @param[out] D Diagonal term of derivative.
!> @param[out] LLWS
!> @param[in] IX
!> @param[in] IY
!> @param[in] BRLAMBDA
!>
!> @author F. Ardhuin
!> @author H. L. Tolman
!> @date 05-Dec-2013
!>
SUBROUTINE W3SIN4 (A, CG, K, U, USTAR, DRAT, AS, USDIR, Z0, CD, &
TAUWX, TAUWY, TAUWNX, TAUWNY, S, D, LLWS, &
IX, IY, BRLAMBDA)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III SHOM |
!/ ! F. Ardhuin !
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 05-Dec-2013 |
!/ +-----------------------------------+
!/
!/ 09-Oct-2007 : Origination. ( version 3.13 )
!/ 24-Jan-2013 : Adding breaking-related input ( version 4.16 )
!/ 05-Dec-2013 : Cleaning up the ICE input ( version 4.16 )
!/
! 1. Purpose :
!
! Calculate diagonal and input source term for WAM4+ approach.
!
! 2. Method :
!
! WAM-4 : Janssen et al.
! WAM-"4.5" : gustiness effect (Cavaleri et al. )
! SAT : high-frequency input reduction for balance with
! saturation dissipation (Ardhuin et al., 2008)
! SWELL : negative wind input (Ardhuin et al. 2008)
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! A R.A. I Action density spectrum (1-D).
! CG R.A. I Group speed *)
! K R.A. I Wavenumber for entire spectrum. *)
! U Real I WIND SPEED
! USTAR Real I Friction velocity.
! DRAT Real I Air/water density ratio.
! AS Real I Air-sea temperature difference
! USDIR Real I wind stress direction
! Z0 Real I Air-side roughness lengh.
! CD Real I Wind drag coefficient.
! USDIR Real I Direction of friction velocity
! TAUWX-Y Real I Components of the wave-supported stress.
! TAUWNX Real I Component of the negative wave-supported stress.
! TAUWNY Real I Component of the negative wave-supported stress.
! S R.A. O Source term (1-D version).
! D R.A. O Diagonal term of derivative. *)
! ----------------------------------------------------------------
! *) Stored as 1-D array with dimension NTH*NK
!
! 4. Subroutines used :
!
! STRACE Subroutine tracing. ( !/S switch )
! PRT2DS Print plot of spectrum. ( !/T0 switch )
! OUTMAT Print out matrix. ( !/T1 switch )
!
! 5. Called by :
!
! W3SRCE Source term integration.
! W3EXPO Point output program.
! GXEXPO GrADS point output program.
!
! 6. Error messages :
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! !/S Enable subroutine tracing.
! !/T Enable general test output.
! !/T0 2-D print plot of source term.
! !/T1 Print arrays.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE CONSTANTS, ONLY: GRAV,nu_air,KAPPA,TPI,FWTABLE,SIZEFWTABLE, &
#ifdef W3_T
RADE, &
#endif
DELAB,ABMIN
USE W3GDATMD, ONLY: NK, NTH, NSPEC, DDEN, SIG, SIG2, TH, &
ESIN, ECOS, EC2, ZZWND, AALPHA, BBETA, ZZALP,&
TTAUWSHELTER, SSWELLF, DDEN2, DTH, SSINTHP, &
ZZ0RAT, SSINBR
#ifdef W3_S
USE W3SERVMD, ONLY: STRACE
#endif
#ifdef W3_T
USE W3ODATMD, ONLY: NDST
#endif
#ifdef W3_T0
USE W3ODATMD, ONLY: NDST
#endif
USE W3ODATMD, ONLY: IAPROC
#ifdef W3_T0
USE W3ARRYMD, ONLY: PRT2DS
#endif
#ifdef W3_T1
USE W3ARRYMD, ONLY: OUTMAT
#endif
!
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
REAL, INTENT(IN) :: A(NSPEC), BRLAMBDA(NSPEC)
REAL, INTENT(IN) :: CG(NK), K(NSPEC),Z0,U, CD
REAL, INTENT(IN) :: USTAR, USDIR, AS, DRAT
REAL, INTENT(OUT) :: S(NSPEC), D(NSPEC), TAUWX, TAUWY, TAUWNX, TAUWNY
LOGICAL, INTENT(OUT) :: LLWS(NSPEC)
INTEGER, INTENT(IN) :: IX, IY
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IS,IK,ITH
#ifdef W3_S
INTEGER, SAVE :: IENT = 0
#endif
REAL :: FACLN1, FACLN2, LAMBDA
REAL :: COSU, SINU, TAUX, TAUY, USDIRP, USTP
REAL :: TAUPX, TAUPY, UST2, TAUW, TAUWB
REAL , PARAMETER :: EPS1 = 0.00001, EPS2 = 0.000001
REAL :: Usigma !standard deviation of U due to gustiness
REAL :: USTARsigma !standard deviation of USTAR due to gustiness
REAL :: CM,UCN,ZCN, &
Z0VISC, Z0NOZ, EB, &
EBX, EBY, AORB, AORB1, FW, UORB, TH2, &
RE, FU, FUD, SWELLCOEFV, SWELLCOEFT
REAL :: PTURB, PVISC, SMOOTH
REAL XI,DELI1,DELI2
REAL XJ,DELJ1,DELJ2
REAL XK,DELK1,DELK2
REAL :: CONST, CONST0, CONST2, TAU1
REAL X,ZARG,ZLOG,UST
REAL :: COSWIND, XSTRESS, YSTRESS, TAUHF
REAL TEMP, TEMP2
INTEGER IND,J,I,ISTAB
REAL DSTAB(3,NSPEC), DVISC, DTURB
REAL STRESSSTAB(3,2),STRESSSTABN(3,2)
#ifdef W3_T0
REAL :: DOUT(NK,NTH)
#endif
!/
!/ ------------------------------------------------------------------- /
!/
#ifdef W3_S
CALL STRACE (IENT, 'W3SIN4')
#endif
!
#ifdef W3_T
WRITE (NDST,9000) BBETA, USTAR, USDIR*RADE
#endif
!
! 1. Preparations
!
!JDM: Initializing values to zero, they shouldn't be used unless
!set in another place, but seems to solve some bugs with certain
!compilers.
DSTAB =0.
STRESSSTAB =0.
STRESSSTABN =0.
!
! 1.a estimation of surface roughness parameters
!
Z0VISC = 0.1*nu_air/MAX(USTAR,0.0001)
Z0NOZ = MAX(Z0VISC,ZZ0RAT*Z0)
FACLN1 = U / LOG(ZZWND/Z0NOZ)
FACLN2 = LOG(Z0NOZ)
!
! 1.b estimation of surface orbital velocity and displacement
!
UORB=0.
AORB=0.
DO IK=1, NK
EB = 0.
EBX = 0.
EBY = 0.
DO ITH=1, NTH
IS=ITH+(IK-1)*NTH
EB = EB + A(IS)
END DO
!
! At this point UORB and AORB are the variances of the orbital velocity and surface elevation
!
UORB = UORB + EB *SIG(IK)**2 * DDEN(IK) / CG(IK)
AORB = AORB + EB * DDEN(IK) / CG(IK) !deep water only
END DO
UORB = 2*SQRT(UORB) ! significant orbital amplitude
AORB1 = 2*AORB**(1-0.5*SSWELLF(6)) ! half the significant wave height ... if SWELLF(6)=1
RE = 4*UORB*AORB1 / NU_AIR ! Reynolds number
!
! Defines the swell dissipation based on the "Reynolds number"
!
IF (SSWELLF(4).GT.0) THEN
IF (SSWELLF(7).GT.0.) THEN
SMOOTH = 0.5*TANH((RE-SSWELLF(4))/SSWELLF(7))
PTURB=(0.5+SMOOTH)
PVISC=(0.5-SMOOTH)
ELSE
IF (RE.LE.SSWELLF(4)) THEN
PTURB = 0.
PVISC = 1.
ELSE
PTURB = 1.
PVISC = 0.
END IF
END IF
ELSE
PTURB=1.
PVISC=1.
END IF
!
IF (SSWELLF(2).EQ.0) THEN
FW=MAX(ABS(SSWELLF(3)),0.)
FU=0.
FUD=0.
ELSE
FU=ABS(SSWELLF(3))
FUD=SSWELLF(2)
AORB=2*SQRT(AORB)
XI=(ALOG10(MAX(AORB/Z0NOZ,3.))-ABMIN)/DELAB
IND = MIN (SIZEFWTABLE-1, INT(XI))
DELI1= MIN (1. ,XI-FLOAT(IND))
DELI2= 1. - DELI1
FW =FWTABLE(IND)*DELI2+FWTABLE(IND+1)*DELI1
END IF
!
! 2. Diagonal
!
! Here AS is the air-sea temperature difference in degrees. Expression given by
! Abdalla & Cavaleri, JGR 2002 for Usigma. For USTARsigma ... I do not see where
! I got it from, maybe just made up from drag law ...
!
#ifdef W3_STAB3
Usigma=MAX(0.,-0.025*AS)
USTARsigma=(1.0+U/(10.+U))*Usigma
#endif
UST=USTAR
ISTAB=3
#ifdef W3_STAB3
DO ISTAB=1,2
IF (ISTAB.EQ.1) UST=USTAR*(1.-USTARsigma)
IF (ISTAB.EQ.2) UST=USTAR*(1.+USTARsigma)
#endif
TAUX = UST**2* COS(USDIR)
TAUY = UST**2* SIN(USDIR)
!
! Loop over the resolved part of the spectrum
!
STRESSSTAB(ISTAB,:)=0.
STRESSSTABN(ISTAB,:)=0.
!
! Coupling coefficient times density ratio DRAT
!
CONST0=BBETA*DRAT/(kappa**2)
!
DO IK=1, NK
TAUPX=TAUX-ABS(TTAUWSHELTER)*STRESSSTAB(ISTAB,1)
TAUPY=TAUY-ABS(TTAUWSHELTER)*STRESSSTAB(ISTAB,2)
! With MIN and MAX the bug should disappear.... but where did it come from?
USTP=MIN((TAUPX**2+TAUPY**2)**0.25,MAX(UST,0.3))
USDIRP=ATAN2(TAUPY,TAUPX)
COSU = COS(USDIRP)
SINU = SIN(USDIRP)
IS=1+(IK-1)*NTH
CM=K(IS)/SIG2(IS) !inverse of phase speed
UCN=USTP*CM+ZZALP !this is the inverse wave age
! the stress is the real stress (N/m^2) divided by
! rho_a, and thus comparable to USTAR**2
! it is the integral of rho_w g Sin/C /rho_a
! (air-> waves momentum flux)
CONST2=DDEN2(IS)/CG(IK) & !Jacobian to get energy in band
*GRAV/(SIG(IK)/K(IS)*DRAT) ! coefficient to get momentum
CONST=SIG2(IS)*CONST0
! CM parameter is 1 / C_phi
! Z0 corresponds to Z0+Z1 of the Janssen eq. 14
ZCN=ALOG(K(IS)*Z0)
!
! precomputes swell factors
!
SWELLCOEFV=-SSWELLF(5)*DRAT*2*K(IS)*SQRT(2*NU_AIR*SIG2(IS))
SWELLCOEFT=-DRAT*SSWELLF(1)*16*SIG2(IS)**2/GRAV
!
DO ITH=1,NTH
IS=ITH+(IK-1)*NTH
COSWIND=(ECOS(IS)*COSU+ESIN(IS)*SINU)
IF (COSWIND.GT.0.01) THEN
X=COSWIND*UCN
! this ZARG term is the argument of the exponential
! in Janssen 1991 eq. 16.
ZARG=KAPPA/X
! ZLOG is ALOG(MU) where MU is defined by Janssen 1991 eq. 15
! MU=
ZLOG=ZCN+ZARG
IF (ZLOG.LT.0.) THEN
! The source term Sp is beta * omega * X**2
! as given by Janssen 1991 eq. 19
! Note that this is slightly diffent from ECWAM code CY45R2 where ZLOG is replaced by ??
DSTAB(ISTAB,IS) = CONST*EXP(ZLOG)*ZLOG**4*UCN*UCN*COSWIND**SSINTHP
! Below is an example with breaking probability feeding back to the input...
!DSTAB(ISTAB,IS) = CONST*EXP(ZLOG)*ZLOG**4 &
! *UCN*UCN*COSWIND**SSINTHP *(1+BRLAMBDA(IS)*20*SSINBR)
LLWS(IS)=.TRUE.
ELSE
DSTAB(ISTAB,IS) = 0.
LLWS(IS)=.FALSE.
END IF
!
! Added for consistency with ECWAM implsch.F
!
IF (28.*CM*USTAR*COSWIND.GE.1) THEN
LLWS(IS)=.TRUE.
END IF
ELSE ! (COSWIND.LE.0.01)
DSTAB(ISTAB,IS) = 0.
LLWS(IS)=.FALSE.
END IF
!
IF ((SSWELLF(1).NE.0.AND.DSTAB(ISTAB,IS).LT.1E-7*SIG2(IS)) &
.OR.SSWELLF(3).GT.0) THEN
!
DVISC=SWELLCOEFV
DTURB=SWELLCOEFT*(FW*UORB+(FU+FUD*COSWIND)*USTP)
!
DSTAB(ISTAB,IS) = DSTAB(ISTAB,IS) + PTURB*DTURB + PVISC*DVISC
END IF
!
! Sums up the wave-supported stress
!
! Wave direction is "direction to"
! therefore there is a PLUS sign for the stress
TEMP2=CONST2*DSTAB(ISTAB,IS)*A(IS)
IF (DSTAB(ISTAB,IS).LT.0) THEN
STRESSSTABN(ISTAB,1)=STRESSSTABN(ISTAB,1)+TEMP2*ECOS(IS)
STRESSSTABN(ISTAB,2)=STRESSSTABN(ISTAB,2)+TEMP2*ESIN(IS)
ELSE
STRESSSTAB(ISTAB,1)=STRESSSTAB(ISTAB,1)+TEMP2*ECOS(IS)
STRESSSTAB(ISTAB,2)=STRESSSTAB(ISTAB,2)+TEMP2*ESIN(IS)
END IF
END DO
END DO
!
D(:)=DSTAB(3,:)
XSTRESS=STRESSSTAB (3,1)
YSTRESS=STRESSSTAB (3,2)
TAUWNX =STRESSSTABN(3,1)
TAUWNY =STRESSSTABN(3,2)
#ifdef W3_STAB3
END DO
D(:)=0.5*(DSTAB(1,:)+DSTAB(2,:))
XSTRESS=0.5*(STRESSSTAB(1,1)+STRESSSTAB(2,1))
YSTRESS=0.5*(STRESSSTAB(1,2)+STRESSSTAB(2,2))
TAUWNX=0.5*(STRESSSTABN(1,1)+STRESSSTABN(2,1))
TAUWNY=0.5*(STRESSSTABN(1,2)+STRESSSTABN(2,2))
#endif
S = D * A
!
! ... Test output of arrays
!
#ifdef W3_T0
DO IK=1, NK
DO ITH=1, NTH
DOUT(IK,ITH) = D(ITH+(IK-1)*NTH)
END DO
END DO
CALL PRT2DS (NDST, NK, NK, NTH, DOUT, SIG(1:NK), ' ', 1., &
0.0, 0.001, 'Diag Sin', ' ', 'NONAME')
#endif
!
#ifdef W3_T1
CALL OUTMAT (NDST, D, NTH, NTH, NK, 'diag Sin')
#endif
!
! Computes the high-frequency contribution
! the difference in spectal density (kx,ky) to (f,theta)
! is integrated in this modified CONST0
CONST0=DTH*SIG(NK)**5/((GRAV**2)*tpi) &
*TPI*SIG(NK) / CG(NK) !conversion WAM (E(f,theta) to WW3 A(k,theta)
TEMP=0.
DO ITH=1,NTH
IS=ITH+(NK-1)*NTH
COSWIND=(ECOS(IS)*COSU+ESIN(IS)*SINU)
TEMP=TEMP+A(IS)*(MAX(COSWIND,0.))**3
END DO
TAUPX=TAUX-ABS(TTAUWSHELTER)*XSTRESS
TAUPY=TAUY-ABS(TTAUWSHELTER)*YSTRESS
USTP=(TAUPX**2+TAUPY**2)**0.25
USDIRP=ATAN2(TAUPY,TAUPX)
UST=USTP
! finds the values in the tabulated stress TAUHFT
XI=UST/DELUST
IND = MAX(1,MIN (IUSTAR-1, INT(XI)))
DELI1= MAX(MIN (1. ,XI-FLOAT(IND)),0.)
DELI2= 1. - DELI1
XJ=MAX(0.,(GRAV*Z0/MAX(UST,0.00001)**2-AALPHA) / DELALP)
J = MAX(1 ,MIN (IALPHA-1, INT(XJ)))
DELJ1= MAX(0.,MIN (1. , XJ-FLOAT(J)))
DELJ2=1. - DELJ1
IF (TTAUWSHELTER.GT.0) THEN
XK = CONST0*TEMP / DELTAIL
I = MIN (ILEVTAIL-1, INT(XK))
DELK1= MIN (1. ,XK-FLOAT(I))
DELK2=1. - DELK1
TAU1 =((TAUHFT2(IND,J,I)*DELI2+TAUHFT2(IND+1,J,I)*DELI1 )*DELJ2 &
+(TAUHFT2(IND,J+1,I)*DELI2+TAUHFT2(IND+1,J+1,I)*DELI1)*DELJ1)*DELK2 &
+((TAUHFT2(IND,J,I+1)*DELI2+TAUHFT2(IND+1,J,I+1)*DELI1 )*DELJ2 &
+(TAUHFT2(IND,J+1,I+1)*DELI2+TAUHFT2(IND+1,J+1,I+1)*DELI1)*DELJ1)*DELK1
ELSE
TAU1 =(TAUHFT(IND,J)*DELI2+TAUHFT(IND+1,J)*DELI1 )*DELJ2 &
+(TAUHFT(IND,J+1)*DELI2+TAUHFT(IND+1,J+1)*DELI1)*DELJ1
END IF
TAUHF = CONST0*TEMP*UST**2*TAU1
TAUWX = XSTRESS+TAUHF*COS(USDIRP)
TAUWY = YSTRESS+TAUHF*SIN(USDIRP)
!
! Reduces tail effect to make sure that wave-supported stress
! is less than total stress, this is borrowed from ECWAM Stresso.F
!
TAUW = SQRT(TAUWX**2+TAUWY**2)
UST2 = MAX(USTAR,EPS2)**2
TAUWB = MIN(TAUW,MAX(UST2-EPS1,EPS2**2))
IF (TAUWB.LT.TAUW) THEN
TAUWX=TAUWX*TAUWB/TAUW
TAUWY=TAUWY*TAUWB/TAUW
END IF
!
RETURN
!
! Formats
!
#ifdef W3_T
9000 FORMAT (' TEST W3SIN4 : COMMON FACT.: ',3E10.3)
#endif
!/
!/ End of W3SIN4 ----------------------------------------------------- /
!/
END SUBROUTINE W3SIN4
!/ ------------------------------------------------------------------- /
!>
!> @brief Initialization for source term routine.
!>
!> @param[in] FLTABS
!>
!> @author F. Ardhuin
!> @date 30-Aug-2010
!>
SUBROUTINE INSIN4(FLTABS)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | SHOM |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 30-Aug-2010 |
!/ +-----------------------------------+
!/
!/ 30-Aug-2010 : Origination. ( version 3.14-Ifremer )
!
! 1. Purpose :
!
! Initialization for source term routine.
!
! 2. Method :
!
! 3. Parameters :
!
! ----------------------------------------------------------------
! FLTABS Logical
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! W3SIN4 Subr. W3SRC3MD Corresponding source term.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE CONSTANTS, ONLY: TPIINV, RADE, GRAV
USE W3ODATMD, ONLY: NDSE
USE W3SERVMD, ONLY: EXTCDE
USE W3DISPMD, ONLY: WAVNU2
USE W3GDATMD, ONLY: SIG, DSIP, NK, NTH, TTAUWSHELTER, &
SSDSDTH, SSDSCOS, TH, DTH, XFR, ECOS, ESIN, &
SSDSC, SSDSBRF1, SSDSBCK, SSDSBINT, SSDSPBK, &
SSDSABK, SSDSHCK, IKTAB, DCKI, SATINDICES, &
SATWEIGHTS, CUMULW, NKHS, NKD, NDTAB, QBI
#ifdef W3_S
USE W3SERVMD, ONLY: STRACE
#endif
!/
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
LOGICAL, INTENT(IN) :: FLTABS
!/
!/ ------------------------------------------------------------------- /
!/
INTEGER SDSNTH, ITH, I_INT, J_INT, IK, IK2, ITH2 , IS, IS2
INTEGER IKL, ID, ICON, IKD, IKHS, IKH, TOTO
REAL C, C2
REAL DIFF1, DIFF2, BINF, BSUP, CGG, PROF
REAL KIK, DHS, KD, KHS, KH, XT, GAM, DKH, PR, W, EPS
REAL DKD
REAL, DIMENSION(:,:) , ALLOCATABLE :: SIGTAB
REAL, DIMENSION(:,:) , ALLOCATABLE :: K1, K2
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
#ifdef W3_S
INTEGER, SAVE :: IENT = 0
#endif
!/
!/ ------------------------------------------------------------------- /
!/
#ifdef W3_S
CALL STRACE (IENT, 'INSIN4')
#endif
!
! 1. Initializations ------------------------------------------------ *
!
!
! These precomputed tables are written in mod_def.ww3
!
IF (FLTABS) THEN
CALL TABU_STRESS
CALL TABU_TAUHF(SIG(NK) ) !tabulate high-frequency stress: 2D table
IF (TTAUWSHELTER.GT.0) THEN
CALL TABU_TAUHF2(SIG(NK) ) !tabulate high-frequency stress: 3D table
END IF
END IF
!
! 2. SPONTANEOUS BREAKING
! 2.a Precomputes the indices for integrating the spectrum to get saturation (TEST 4xx )