-
Notifications
You must be signed in to change notification settings - Fork 1
/
wwm_ardhuin_new.F90
2475 lines (2381 loc) · 85.5 KB
/
wwm_ardhuin_new.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
#include "wwm_functions.h"
!/ ------------------------------------------------------------------- /
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 )
!/
! 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 :
!/
!/ ------------------------------------------------------------------- /
!/
USE DATAPOOL, ONLY : rkind
SAVE
PUBLIC
!/
!/ Public variables
!/
INTEGER, PARAMETER :: NHMAX = 25
INTEGER(KIND=4) :: NH(3), THO(2,3,NHMAX)
REAL(rkind) :: HA(NHMAX,3), HD(NHMAX,3), HA2(NHMAX,3)
REAL(rkind), PARAMETER :: kappa = 0.40 !Von Karman's constant
!air kinematic viscosity (used in WAM)
REAL(rkind), PARAMETER :: nu_air = 1.4E-5
INTEGER, PARAMETER :: ITAUMAX=200,JUMAX=200
INTEGER, PARAMETER :: IUSTAR=100,IALPHA=200, ILEVTAIL=50
INTEGER, PARAMETER :: SIZEFWTABLE=300
INTEGER, PARAMETER :: IAB=200
REAL(rkind) :: TAUT(0:ITAUMAX,0:JUMAX), DELTAUW, DELU
! Table for H.F. stress as a function of 2 variables
REAL(rkind) :: TAUHFT(0:IUSTAR,0:IALPHA), DELUST, DELALP
! Table for H.F. stress as a function of 3 variables
REAL(rkind) :: TAUHFT2(0:IUSTAR,0:IALPHA,0:ILEVTAIL)
! Table for swell damping
REAL(rkind) :: SWELLFT(0:IAB)
REAL(rkind) :: DELTAIL
REAL(rkind) :: DELAB
REAL(rkind), PARAMETER :: UMAX = 50._rkind
REAL(rkind), PARAMETER :: TAUWMAX = 2.2361 !SQRT(5.)
REAL(rkind), PARAMETER :: ABMIN = 0.3_rkind
REAL(rkind), PARAMETER :: ABMAX = 8._rkind
REAL(rkind) :: FWTABLE(0:SIZEFWTABLE)
REAL(rkind), ALLOCATABLE :: XSTRESS(:),YSTRESS(:)
REAL(rkind), ALLOCATABLE :: DCKI(:,:), SATWEIGHTS(:,:)
REAL(rkind), ALLOCATABLE :: CUMULW(:,:),QBI(:,:)
INTEGER :: DIKCUMUL
! table and variable for wave breaking dissipation term
INTEGER, PARAMETER :: NDTAB=2000 ! Max depth: convolution calculation in W3SDS4
INTEGER, PARAMETER :: NKHS=2000, NKD=1300, NKHI=100
REAL(rkind), PARAMETER :: PI=3.14157, G=9.81
REAL(rkind), PARAMETER :: FAC_KD1=1.01, FAC_KD2=1000._rkind
REAL(rkind), PARAMETER :: KHSMAX=2., KHMAX=2.
REAL(rkind), PARAMETER ::KDMAX=200000._rkind
! variables for negative wind input (beta from ST2)
!
INTEGER, PARAMETER, PRIVATE :: NRSIGA = 400
INTEGER, PARAMETER, PRIVATE :: NRDRAG = 20
REAL(rkind), PARAMETER, PRIVATE :: SIGAMX = 40._rkind
REAL(rkind), PARAMETER, PRIVATE :: DRAGMX = 1.E-2
!
REAL(rkind), PRIVATE :: DSIGA, DDRAG, &
& BETATB(-NRSIGA:NRSIGA+1,NRDRAG+1)
!/
LOGICAL, PRIVATE :: FIRST = .TRUE.
!
! WWM FIELD INSERT ...
!
LOGICAL :: FLICES = .FALSE.
REAL(rkind) :: TTAUWSHELTER = 1.
REAL(rkind) :: ZZ0RAT = 0.04_rkind
REAL(rkind) :: SSINTHP = 2.
INTEGER :: NK, MK, NTH, MTH, MSPEC
INTEGER, ALLOCATABLE :: IKTAB(:,:)
INTEGER, ALLOCATABLE :: SATINDICES(:,:)
LOGICAL, ALLOCATABLE :: LLWS(:)
REAL(rkind) :: SSDSC(1:9)
REAL(rkind), ALLOCATABLE :: SIG(:), SIG2(:), DDEN(:)
REAL(rkind), ALLOCATABLE :: DDEN2(:), DSII(:)
REAL(rkind), ALLOCATABLE :: DSIP(:), TH(:), ESIN(:)
REAL(rkind), ALLOCATABLE :: ECOS(:), EC2(:), ES2(:), ESC(:)
REAL(rkind) :: ZZWND, AALPHA, BBETA, ZZALP
REAL(rkind) :: DTH, FACHF, SXFR, XFR, FACHFE
REAL(rkind) :: WNMEANP, WNMEANPTAIL
REAL(rkind) :: FTE, FTF
REAL(rkind) :: STXFTF, STXFTWN, STXFTFTAIL
REAL(rkind) :: SSTXFTF, SSTXFTWN, SSTXFTFTAIL
REAL(rkind) :: SSWELLF(7) ,SSWELLFPAR
REAL(rkind) :: SWELLFPAR, SSDSTH
REAL(rkind) :: SSDSDTH, SSDSCOS, SSDSHCK
INTEGER :: SDSNTH ! This is wrongly globally defined ...
REAL(rkind) :: SSDSBCK, SSDSBINT, SSDSPBK, SSDSABK
REAL(rkind) :: SSDSC1, SSDSC2, SSDSC3, SSDSC4
REAL(rkind) :: SSDSC5, SSDSC6, SSDSCUM
REAL(rkind) :: SSDSBR, SSDSBRF1, SSDSBRF2
REAL(rkind) :: SSDSBR2, WHITECAPWIDTH
REAL(rkind) :: SSDSP
INTEGER :: SSDSISO, SSDSBRFDF
REAL(rkind) :: SSDSBM(0:4)
REAL(rkind) :: ZZ0MAX
LOGICAL :: LFIRSTSOURCE = .TRUE.
!/
CONTAINS
!/ ------------------------------------------------------------------- /
SUBROUTINE PREPARE_ARDHUIN
USE DATAPOOL
IMPLICIT NONE
INTEGER :: IK, ISP, ITH, ITH0
REAL(rkind) :: SIGMA, FR1, RTH0
NK = MSC
MK = NK ! ?
NTH = MDC
MTH = NTH ! ?
MSPEC = NSPEC
ALLOCATE(SIG(0:MSC+1), SIG2(NSPEC), DSIP(0:MSC+1), TH(MDC), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 1')
SIG = ZERO
SIG2 = ZERO
DSIP = ZERO
TH = ZERO
ALLOCATE(ESIN(MSPEC+MTH), ECOS(MSPEC+MTH), EC2(MSPEC+MTH), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 2')
ESIN = ZERO
ECOS = ZERO
EC2 = ZERO
ALLOCATE(ES2(MSPEC+MTH),ESC(MSPEC+MTH), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 3')
ES2 = ZERO
ESC = ZERO
ALLOCATE(DSII(MSC), DDEN(MSC), DDEN2(NSPEC), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 4')
DSII = ZERO
DDEN = ZERO
DDEN2 = ZERO
DTH = DDIR
FR1 = SPSIG(1)/PI2
TH = SPDIR
RTH0 = ZERO
DO ITH=1, NTH
TH (ITH) = DTH * ( RTH0 + MyREAL(ITH-1) )
ESIN(ITH) = SIN ( TH(ITH) )
ECOS(ITH) = COS ( TH(ITH) )
IF ( ABS(ESIN(ITH)) .LT. 1.E-5 ) THEN
ESIN(ITH) = ZERO
IF ( ECOS(ITH) .GT. 0.5_rkind ) THEN
ECOS(ITH) = 1._rkind
ELSE
ECOS(ITH) = -1._rkind
END IF
END IF
IF ( ABS(ECOS(ITH)) .LT. 1.E-5 ) THEN
ECOS(ITH) = ZERO
IF ( ESIN(ITH) .GT. 0.5_rkind ) THEN
ESIN(ITH) = 1.
ELSE
ESIN(ITH) = -1.
END IF
END IF
ES2 (ITH) = ESIN(ITH)**2
EC2 (ITH) = ECOS(ITH)**2
ESC (ITH) = ESIN(ITH)*ECOS(ITH)
END DO
!
DO IK=2, NK+1
ITH0 = (IK-1)*NTH
DO ITH=1, NTH
ESIN(ITH0+ITH) = ESIN(ITH)
ECOS(ITH0+ITH) = ECOS(ITH)
ES2 (ITH0+ITH) = ES2 (ITH)
EC2 (ITH0+ITH) = EC2 (ITH)
ESC (ITH0+ITH) = ESC (ITH)
END DO
END DO
! WRITE(5001,*) 'DTH'
! WRITE(5001,*) DTH
! WRITE(5001,*) 'FR1'
! WRITE(5001,*) FR1
! WRITE(5001,*) 'TH'
! WRITE(5001,*) TH
! WRITE(5001,*) 'ESIN, ECOS, EC2'
! WRITE(5001,*) ESIN, ECOS, EC2
WNMEANP = 0.5_rkind
WNMEANPTAIL = -0.5_rkind
! WRITE(5001,*) 'WNMEANP, WNMEANPTAIL'
! WRITE(5001,*) WNMEANP, WNMEANPTAIL
XFR = EXP(FRINTF) ! Check with Fabrice ... should be 1.1
SIGMA = FR1 * TPI / XFR**2 ! What is going on here ?
SXFR = 0.5_rkind * (XFR-1./XFR)
! WRITE(5001,*) 'XFR, SIGMA, SXFR'
! WRITE(5001,*) XFR, SIGMA, SXFR
DO IK=0, NK+1
SIGMA = SIGMA * XFR ! What is going on here ...
SIG (IK) = SIGMA
DSIP(IK) = SIGMA * SXFR
END DO
! WRITE(5001,*) 'SIGMA'
! WRITE(5001,*) SIGMA
! WRITE(5001,*) 'SIG'
! WRITE(5001,*) SIG
! WRITE(5001,*) 'DSIP'
! WRITE(5001,*) DSIP
DSII(1) = 0.5_rkind * SIG( 1) * (XFR-1.)
DO IK = 2, NK - 1
DSII(IK) = DSIP(IK)
END DO
DSII(NK) = 0.5_rkind * SIG(NK) * (XFR-1.) / XFR
DO IK=1, NK
DDEN(IK) = DTH * DSII(IK) * SIG(IK)
END DO
DO ISP=1, NSPEC
IK = 1 + (ISP-1)/NTH
SIG2 (ISP) = SIG (IK)
DDEN2(ISP) = DDEN(IK)
END DO
! WRITE(5001,*) 'SIG2'
! WRITE(5001,*) SIG2
! WRITE(5001,*) 'DSII'
! WRITE(5001,*) DSII
! WRITE(5001,*) 'DDEN'
! WRITE(5001,*) DDEN
! WRITE(5001,*) 'DDEN2'
! WRITE(5001,*) DDEN2
FTE = 0.25_rkind * SIG(NK) * DTH * SIG(NK)
FTF = 0.20_rkind * DTH * SIG(NK)
FACHF = 5.
FACHFE = XFR**(-FACHF)
STXFTFTAIL = 1./(FACHF-1.-WNMEANPTAIL*2)
STXFTF = 1./(FACHF-1.-WNMEANP*2)
STXFTWN = 1./(FACHF-1.-WNMEANP*2) * SIG(NK)**(2)
! WRITE(5001,*) 'FTE, FTF, FACHF, FACHFE'
! WRITE(5001,*) FTE, FTF, FACHF, FACHFE
SSWELLF(1) = 0.8_rkind
SSWELLF(2) = -0.018_rkind
SSWELLF(3) = 0.015_rkind
SSWELLF(4) = 1.E5
SSWELLF(5) = 1.2
SSWELLF(6) = 0._rkind
SSWELLF(7) = 0._rkind
! WRITE(5001,*) 'SSWELLF'
! WRITE(5001,*) SSWELLF
AALPHA = 0.0095_rkind
BBETA = 1.54_rkind ! 1.54 for ECMWF
ZZALP = 0.006_rkind
ZZWND = 10._rkind
SWELLFPAR = 1
SSDSBRF1 = 0.5_rkind
SSDSHCK = 1._rkind
SSDSBCK = 0._rkind
SSDSBINT = 0.3_rkind
SSDSPBK = 4._rkind
SSDSABK = 1.5_rkind
SSDSBR = 9.E-4_rkind
SSDSBRFDF = 0
SSDSBRF1 = 0.5_rkind
SSDSBRF2 = 0._rkind
SSDSBR2 = 0.8_rkind
SSDSP = 2.
SSDSPBK = 4.
SSDSISO = 2
SSDSBM(0) = 1.
SSDSBM(1) = 02428._rkind
SSDSBM(2) = 1.995_rkind
SSDSBM(3) = -2.5709_rkind
SSDSBM(4) = 1.3286_rkind
ZZ0MAX = 0.002_rkind
SSINTHP = 2.0_rkind
SSWELLFPAR = 3
TTAUWSHELTER = 1.0_rkind
ZZ0RAT = 0.04_rkind
SSDSC1 = 0._rkind
SSDSC2 = -2.2E-5_rkind ! AR: was originally 2.2
!SSDSC3 = -0.80_rkind ! overwritten by SSDSCUM
SSDSC4 = 1._rkind
SSDSC5 = 0._rkind
SSDSC6 = 0.30_rkind
WHITECAPWIDTH = 0.8_rkind
SSDSCUM = -0.40344_rkind
SSDSDTH = 80._rkind ! not used ...
SSDSCOS = 2._rkind
SSDSISO = 2 !AR: changes to isotropic breaking ...
SSDSC(1) = SSDSC1
SSDSC(2) = SSDSC2
SSDSC(3) = SSDSCUM
SSDSC(4) = SSDSC4
SSDSC(5) = SSDSC5
SSDSC(6) = SSDSC6
SSDSC(7) = WHITECAPWIDTH
SDSNTH = MIN(NINT(SSDSDTH/(DTH*RADDEG)),NTH/2-1)
DELAB = (ABMAX-ABMIN)/MyREAL(SIZEFWTABLE)
ALLOCATE(IKTAB(MK,NDTAB), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 5')
IKTAB = 0
ALLOCATE(SATINDICES(2*SDSNTH+1,MTH), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 6')
SATINDICES = 0
ALLOCATE(SATWEIGHTS(2*SDSNTH+1,MTH), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 7')
SATWEIGHTS = 0._rkind
ALLOCATE(CUMULW(MK*MTH,MK*MTH), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 8')
CUMULW = 0._rkind
ALLOCATE(DCKI(NKHS,NKD), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 9')
DCKI = 0._rkind
ALLOCATE(LLWS(NSPEC), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 10')
LLWS = .FALSE.
ALLOCATE(QBI(NKHS,NKD), stat=istat)
IF (istat/=0) CALL WWM_ABORT('wwm_ardhuin_new, allocate error 11')
QBI = 0._rkind
TAUWX = ZERO; TAUWY = ZERO; CD = ZERO; Z0 = ZERO; USTDIR = ZERO
INQUIRE(FILE='fort.5002',EXIST=LPRECOMP_EXIST)
IF (.NOT. LPRECOMP_EXIST) THEN
CALL INSIN4(.TRUE.)
ELSE
CALL READ_INSIN4
END IF
END SUBROUTINE
!**********************************************************************
!* *
!**********************************************************************
SUBROUTINE READ_INSIN4
USE DATAPOOL, ONLY : LPRECOMP_EXIST, DBG, MSC, MDC
IMPLICIT NONE
INTEGER :: MSC_TEST, MDC_TEST, ISTAT
IF (LPRECOMP_EXIST) THEN
READ (5002, IOSTAT=ISTAT) &
& MSC_TEST, MDC_TEST, &
& ZZWND, AALPHA, ZZ0MAX, BBETA, SSINTHP, ZZALP, &
& TTAUWSHELTER, SSWELLFPAR, SSWELLF, &
& ZZ0RAT, SSDSC1, SSDSC2, SSDSC3, SSDSC4, SSDSC5, &
& SSDSC6, SSDSISO, SSDSBR, SSDSBR2, SSDSBM, SSDSP, &
& SSDSCOS, SSDSDTH, SSTXFTF, &
& SSTXFTFTAIL, SSTXFTWN, SSTXFTF, SSTXFTWN, &
& SSDSBRF1, SSDSBRF2, SSDSBRFDF,SSDSBCK, SSDSABK, &
& SSDSPBK, SSDSBINT, &
& SSDSHCK, DELUST, DELTAIL, DELTAUW, &
& DELU, DELALP, DELAB, TAUT, TAUHFT, TAUHFT2, &
& SWELLFT, IKTAB, DCKI, SATINDICES, SATWEIGHTS, &
& DIKCUMUL, CUMULW, QBI
IF (ISTAT /= 0) CALL WWM_ABORT('Remove fort.5002 Error while trying to read precomputed array')
IF (MSC_TEST .NE. MSC .OR. MDC_TEST .NE. MDC) THEN
WRITE(DBG%FHNDL,*) 'MSC AND MDC READ FROM FILE AND SET IN WWMINPUT.NML ARE NOT EQUAL -STOP-'
WRITE(DBG%FHNDL,*) MSC_TEST, MSC
WRITE(DBG%FHNDL,*) MDC_TEST, MDC
CALL WWM_ABORT('THE fort.5002 file does not match your specifications. Remove and rerun')
ENDIF
END IF
END SUBROUTINE
!**********************************************************************
!* *
!**********************************************************************
SUBROUTINE W3SPR4 (A, CG, WN, EMEAN, FMEAN, FMEAN1, WNMEAN, AMAX, U, UDIR, USTAR, USDIR, TAUWX, TAUWY, CD, Z0, CHARN, LLWS, FMEANWS)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III SHOM |
!/ ! F. Ardhuin !
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 13-Jun-2011 |
!/ +-----------------------------------+
!/
!/ 03-Oct-2007 : Origination. ( version 3.13 )
!/ 13-Jun-2011 : Adds f_m0,-1 as FMEAN in the outout ( version 4.xx )
!/
! 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.
! 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
! ----------------------------------------------------------------
!
! 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.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE DATAPOOL, ONLY: SPSIG, INVPI2, PI2, RKIND, NSPEC
USE DATAPOOL, ONLY: ZERO, ONE
!/T USE W3ODATMD, ONLY: NDST
!
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
REAL(rkind), INTENT(IN) :: A(NTH,NK), CG(NK), WN(NK)
REAL(rkind), INTENT(IN) :: TAUWX, TAUWY, U, UDIR
LOGICAL, INTENT(IN) :: LLWS(NSPEC)
REAL(rkind), INTENT(INOUT) :: USTAR ,USDIR
REAL(rkind), INTENT(OUT) :: EMEAN, FMEAN, FMEAN1, WNMEAN, &
& AMAX, CD, Z0, CHARN, FMEANWS
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IS, IK, ITH
!/S INTEGER, SAVE :: IENT = 0
REAL(rkind) :: TAUW, EBAND, EMEANWS, RDCH, FXPMC, &
WNP, UNZ, FP, &
R1, CP, EB(NK),EB2(NK),ALFA(NK)
!/
!/ ------------------------------------------------------------------- /
!/
!/S CALL STRACE (IENT, 'W3SPR3')
!
UNZ = MAX ( 0.01_rkind , U )
USTAR = MAX ( 0.0001_rkind , USTAR )
!
EMEAN = ZERO
EMEANWS= ZERO
FMEANWS= ZERO
FMEAN = ZERO
FMEAN1 = ZERO
WNMEAN = ZERO
AMAX = ZERO
!
! 1. Integral over directions and maximum --------------------------- *
!
DO IK=1, NK
EB(IK) = ZERO
EB2(IK) = ZERO
DO ITH=1, NTH
IS=ITH+(IK-1)*NTH
EB(IK) = EB(IK) + A(ITH,IK)
IF (LLWS(IS)) EB2(IK) = EB2(IK) + A(ITH,IK)
AMAX = MAX ( AMAX , A(ITH,IK) )
END DO
! WRITE(DBG%FHNDL,*) IK, EB(IK), IK, ITH, A(ITH,IK)
END DO
!
! 2. Integrate over directions -------------------------------------- *
!
DO IK=1, NK
ALFA(IK) = 2. * DTH * SIG(IK) * EB(IK) * WN(IK)**3
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.*WNMEANPTAIL))
WNMEAN = WNMEAN + EB(IK) *(WN(IK)**WNMEANP)
EMEANWS = EMEANWS+ EB2(IK)
FMEANWS = FMEANWS+ EB2(IK)*(SIG(IK)**(2.*WNMEANPTAIL))
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 = INVPI2 * EMEAN / MAX ( 1.E-7_rkind , FMEAN )
IF (FMEAN1.LT.1.E-7) THEN
FMEAN1=INVPI2 * SIG(NK)
ELSE
FMEAN1 = INVPI2 *( MAX ( 1.E-7_rkind , FMEAN1 ) &
& / MAX ( 1.E-7_rkind , EMEAN ))**(1.d0/(2.*WNMEANPTAIL))
ENDIF
WNMEAN = ( MAX ( 1.E-7_rkind , WNMEAN ) &
& / MAX ( 1.E-7_rkind , EMEAN ) )**(1.d0/WNMEANP)
IF (FMEANWS.LT.1.E-7.OR.EMEANWS.LT.1.E-7) THEN
FMEANWS=INVPI2 * SIG(NK)
ELSE
FMEANWS = INVPI2 *( MAX ( 1.E-7_rkind , FMEANWS ) &
& / MAX ( 1.E-7_rkind , EMEANWS ))**(1/(2.*WNMEANPTAIL))
END IF
!
! 5. Cd and z0 ----------------------------------------------- *
!
TAUW = SQRT(TAUWX**2+TAUWY**2)
Z0=ZERO
CALL CALC_USTAR(U,TAUW,USTAR,Z0,CHARN)
UNZ = MAX ( 0.01_rkind , U )
CD = (USTAR/UNZ)**2
USDIR = UDIR
!
! 6. Final test output ---------------------------------------------- *
!
!/T WRITE (NDST,9060) EMEAN, WNMEAN, TPIINV, CP, CD, Z0
!
!/T 9060 FORMAT (' TEST W3SPR3 : E,WN MN :',F8.3,F8.4/ &
!/T ' FP, CP, CD, Z0 :',F8.3,F7.2,1X,2F9.5)
!/
!/ End of W3SPR3 ----------------------------------------------------- /
!/
END SUBROUTINE
!/ ------------------------------------------------------------------- /
SUBROUTINE W3SIN4 (IP, A, CG, K, U, USTAR, DRAT, AS, USDIR, Z0, CD, TAUWX, TAUWY, TAUWNX, TAUWNY, S, D, LLWS, BRLAMBDA)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III SHOM |
!/ ! F. Ardhuin !
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 16-May-2010 |
!/ +-----------------------------------+
!/
!/ 09-Oct-2007 : Origination. ( version 3.13 )
!/ 16-May-2010 : Adding sea ice ( version 3.14_Ifremer )
!/
! 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.
! ICE Real I Sea ice fraction.
! 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 DATAPOOL, ONLY : ICOMP, G9, PI2, RADDEG, MSC, MDC, &
& MSC, MDC, TAUTOT, RKIND, NSPEC, ZERO, ONE, DBG, THR8, SINBR
!/S USE W3SERVMD, ONLY: STRACE
!/T USE W3ODATMD, ONLY: NDST
!/T0 USE W3ARRYMD, ONLY: PRT2DS
!/T1 USE W3ARRYMD, ONLY: OUTMAT
!
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: IP
REAL(rkind), INTENT(IN) :: A(NSPEC), BRLAMBDA(NSPEC)
REAL(rkind), INTENT(IN) :: CG(NK), K(NSPEC),Z0,U, CD
REAL(rkind), INTENT(IN) :: USTAR, USDIR, AS, DRAT
REAL(rkind), INTENT(OUT) :: S(NSPEC), D(NSPEC), TAUWX, TAUWY, TAUWNX, TAUWNY
LOGICAL, INTENT(OUT) :: LLWS(NSPEC)
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IS,IK,ITH, IOMA, ICL
!/S INTEGER, SAVE :: IENT = 0
REAL(rkind) :: FACLN1, FACLN2, ULAM, CLAM, OMA, &
RD1, RD2, LAMBDA, COSFAC
REAL(rkind) :: COSU, SINU, TAUX, TAUY, USDIRP, USTP
REAL(rkind) :: TAUPX, TAUPY, UST2, TAUW, TAUWB
REAL(rkind) , PARAMETER :: EPS1 = 0.00001, EPS2 = 0.000001
REAL(rkind) :: Usigma !standard deviation of U due to gustiness
REAL(rkind) :: USTARsigma !standard deviation of USTAR due to gustiness
REAL(rkind) :: BETA, mu_janssen, omega_janssen, &
CM,ZCO,UCO,UCN,ZCN, &
Z0VISC, Z0NOZ, EB, &
EBX, EBY, AORB, AORB1, FW, UORB, M2, TH2, &
RE, FU, FUD, SWELLCOEFV, SWELLCOEFT
REAL(rkind) :: HSBLOW, ABJSEA, FACTOR
REAL(rkind) :: PTURB, PVISC, SMOOTH
REAL(rkind) :: XI,DELI1,DELI2
REAL(rkind) :: XJ,DELJ1,DELJ2
REAL(rkind) :: XK,DELK1,DELK2
REAL(rkind) :: CONST, CONST0, CONST2, TAU1
REAL(rkind) :: X,ZARG,ZLOG,UST
REAL(rkind) :: COSWIND, XSTRESS, YSTRESS, TAUHF
REAL(rkind) :: TEMP, TEMP2
INTEGER IND,J,I,ISTAB
REAL(rkind) :: DSTAB(3,NSPEC), DVISC, DTURB
REAL(rkind) :: STRESSSTAB(3,2),STRESSSTABN(3,2)
!/T0 REAL :: DOUT(NK,NTH)
!/
!/ ------------------------------------------------------------------- /
!/
!/S CALL STRACE (IENT, 'W3SIN3')
!
!/T WRITE (NDST,9000) BBETA, USTAR, USDIR*RADE
!
! 1. Preparations
!
!
! 1.a estimation of surface roughness parameters
!
Z0VISC = 0.1_rkind*nu_air/MAX(USTAR,0.0001_rkind)
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 = ZERO
PVISC = ONE
ELSE
PTURB = ONE
PVISC = ZERO
END IF
END IF
ELSE
PTURB=ONE
PVISC=ONE
END IF
!
IF (SSWELLF(2).EQ.0) THEN
FW=MAX(ABS(SSWELLF(3)),ZERO)
FU=ZERO
FUD=ZERO
ELSE
FU=ABS(SSWELLF(3))
FUD=SSWELLF(2)
AORB=2*SQRT(AORB)
XI=(LOG10(MAX(AORB/Z0NOZ,3._rkind))-ABMIN)/DELAB
IND = MIN (SIZEFWTABLE-1, INT(XI))
DELI1= MIN (ONE ,XI-MyREAL(IND))
DELI2= ONE - DELI1
!WRITE(DBG%FHNDL,'(A10,I10,5F15.8)') 'TEST IND',IND, XI, AORB, Z0NOZ, ABMIN, DELAB
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 STAB3
Usigma=MAX(0.,-0.025_rkind*AS)
USTARsigma=(ONE+U/(10._rkind+U))*Usigma
# endif
UST=USTAR
ISTAB=3
# ifdef STAB3
DO ISTAB=1,2
IF (ISTAB.EQ.1) UST=USTAR*(ONE - USTARsigma)
IF (ISTAB.EQ.2) UST=USTAR*(ONE + USTARsigma)
# endif
TAUX = UST**2* MyCOS(USDIR)
TAUY = UST**2* MySIN(USDIR)
!WRITE(DBG%FHNDL,*) 'TAU USTAR', TAUX, TAUY, UST, USDIR, USTAR
!
! Loop over the resolved part of the spectrum
!
STRESSSTAB(ISTAB,:)=ZERO
STRESSSTABN(ISTAB,:)=ZERO
!
! Coupling coefficient times densit ration and fraction of free surface (1-ICE)
!
IF (FLICES) THEN
STOP 'NO ICE HERE'
!CONST0=MIN(ZERO,MAX(ONE,ONE-ICE))*BBETA*DRAT/(kappa**2)
ELSE
CONST0=BBETA*DRAT/(kappa**2)
END IF
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?
! AR: This is ugly ...
USTP=MIN((TAUPX**2+TAUPY**2)**0.25_rkind,MAX(UST,0.3_rkind))
!WRITE(DBG%FHNDL,*) 'USTP', IK, USTP, STRESSSTAB(ISTAB,1), STRESSSTAB(ISTAB,2), TTAUWSHELTER
USDIRP=ATAN2(TAUPY,TAUPX)
COSU = MyCOS(USDIRP)
SINU = MySIN(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
& *G9/(SIG(IK)/K(IS)*DRAT) ! coefficient to get momentum
CONST=SIG2(IS)*CONST0
! this CM parameter is 1 / C_phi
! this is the "correct" shallow-water expression
! here Z0 corresponds to Z0+Z1 of the Janssen eq. 14
#ifdef USE_SINGLE
ZCN=LOG(K(IS)*Z0)
#else
ZCN=DLOG(K(IS)*Z0)
#endif
! below is the original WAM version (OK for deep water) g*z0/C^2
! ZCN=LOG(G*Z0b(I)*CM(I)**2)
!
! precomputes swell factors
!
SWELLCOEFV=-SSWELLF(5)*DRAT*2*K(IS)*SQRT(2*NU_AIR*SIG2(IS))
SWELLCOEFT=-DRAT*SSWELLF(1)*16*SIG2(IS)**2/G9
!
!WRITE(DBG%FHNDL,*) 'UCN', IK, IS, USTP, CM ,K(IK), DDEN2(IS), Z0
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
!WRITE(DBG%FHNDL,*) 'ZLOG', IK, ITH, ZCN, ZARG, X, KAPPA, UCN
IF (ZLOG.LT.0.) THEN
! The source term Sp is beta * omega * X**2
! as given by Janssen 1991 eq. 19
! for a faster performance EXP(X)*X**4 should be tabulated
DSTAB(ISTAB,IS) = CONST*EXP(ZLOG)*ZLOG**4 &
*UCN*UCN*COSWIND**SSINTHP *(1+BRLAMBDA(IS)*20*SINBR)
LLWS(IS)=.TRUE.
ELSE
DSTAB(ISTAB,IS) = 0.
LLWS(IS)=.FALSE.
END IF
!WRITE(DBG%FHNDL,*) 'DSTAB', DSTAB(ISTAB,IS), CONST,EXP(ZLOG),ZLOG**4,UCN**2,COSWIND,SSINTHP
!
! Added for consistency with ECWAM implsch.F
!
IF (28._rkind*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 ! + SSWELLF(7)/SIG2(IS) ! fudge for low frequency
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)
!/STAB3 END DO
!/STAB3 D(:)=0.5*(DSTAB(1,:)+DSTAB(2,:))
!/STAB3 XSTRESS=0.5*(STRESSSTAB(1,1)+STRESSSTAB(2,1))
!/STAB3 YSTRESS=0.5*(STRESSSTAB(1,2)+STRESSSTAB(2,2))
!/STAB3 TAUWNX=0.5*(STRESSSTABN(1,1)+STRESSSTABN(2,1))
!/STAB3 TAUWNY=0.5*(STRESSSTABN(1,2)+STRESSSTABN(2,2))