-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswancom4.ftn
5903 lines (5782 loc) · 204 KB
/
swancom4.ftn
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
!
! SWAN/COMPU file 4 of 5
!
!
! PROGRAM SWANCOM4.FOR
!
!
! This file SWANCOM4 of the main program SWAN
! include the next subroutines
!
! *** nonlinear 4 wave-wave interactions ***
!
! FAC4WW (compute the constants for the nonlinear wave
! interactions)
! RANGE4 (compute the counters for the different types of
! computations for the nonlinear wave interactions)
! SWSNL1 (nonlinear four wave interactions; semi-implicit and computed
! for all bins that fall within a sweep with DIA technique.
! Interaction are calculated per sweep)
! SWSNL2 (nonlinear four wave interactions; fully explicit and computed
! for all bins that fall within a sweep with DIA technique.
! Interaction are calculated per sweep)
! SWSNL3 (calculate nonlinear four wave interactions fully explicitly
! for the full circle per iteration by means of DIA approach
! and store results in auxiliary array MEMNL4)
! SWSNL4 (calculate nonlinear four wave interactions fully explicitly
! for the full circle per iteration by means of MDIA approach
! and store results in auxiliary array MEMNL4)
! SWSNL8 (calculate nonlinear four wave interactions fully explicitly
! for the full circle per iteration by means of DIA approach
! and store results in auxiliary array MEMNL4. Neighbouring
! interactions are interpolated in piecewise constant manner)
! FILNL3 (fill main diagonal and right-hand side of the system with
! results of array MEMNL4)
!
! SWINTFXNL (interface with SWAN model to compute nonlinear transfer
! with the XNL method for given action density spectrum)
!
! *** nonlinear 3 wave-wave interactions ***
!
! TCOEF (compute transfer coefficients)
! FAC3WW (compute scaling factors for the triad-wave interaction)
! SWLTA (triad-wave interactions calculated with the Lumped Triad
! Approximation of Eldeberky, 1996)
! SWDCTA (triad-wave interactions calculated with the Distributed
! Collinear Triad Approximation of Booij et al, 2009)
! SWDNCTA (triad-wave interactions calculated with the Distributed
! NonCollinear Triad Approximation)
! SWFTIM (triad-wave interactions calculated using the full integration
! and the parametrized bispectrum)
! PEREXC (includes periodic exchange between first and second harmonics
! for estimating biphase based on Saprykina et al, 2017)
! SWBIDW (compute the biphase based on the parametrization of De Wit, 2022)
! SWBIPM (spatially filter the De Wit's biphase)
!
!----------------------------------------------------------------------
!
!******************************************************************
!
SUBROUTINE FAC4WW (XIS ,SNLC1 , 40.41 34.00
& DAL1 ,DAL2 ,DAL3 ,SPCSIG, 34.00
& WWINT ,WWAWG ,WWSWG ) 40.17 34.00
!
!******************************************************************
!
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
USE M_SNL4 40.17
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering |
! | Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmers: H.L. Tolman, R.C. Ris |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 30.72: IJsbrand Haagsma
! 40.17: IJsbrand Haagsma
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 30.72, Feb. 98: Introduced generic names XCGRID, YCGRID and SPCSIG for SWAN
! 40.17, Dec. 01: Implementation of Multiple DIA
! 40.41, Sep. 04: compute indices for interactions which will be
! interpolated in piecewise constant manner
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose :
!
! Calculate interpolation constants for Snl.
!
! 3. Method :
!
!
! 4. Argument variables
!
! SPCSIG: Relative frequencies in computational domain in sigma-space 30.72
!
REAL SPCSIG(MSC) 30.72
!
! INTEGERS:
! ---------
! MSC2,MSC1 Auxiliary variables
! MSC,MDC Maximum counters in spectral space
! IDP,IDP1 Positive range for ID
! IDM,IDM1 Negative range for ID
! ISP,ISP1 idem for IS
! ISM,ISM1 idem for IS
! ISCLW,ISCHG Minimum and maximum counter for discrete
! computations in frequency space
! ISLOW,ISHGH Minimum and maximum range in frequency space
! IDLOW,IDHGH idem in directional space
! IS Frequency counter
! MSC4MI,MSC4MA Array dimensions in frequency space
! MDC4MI,MDC4MA Array dimensions in direction space
!
! REALS:
! ------
! LAMBDA Coefficient set 0.25
! GRAV Gravitational acceleration
! SNLC1 Coefficient for the subroutines SWSNLn
! LAMM2,LAMP2
! DELTH3,DELTH4 Angles between the interacting wavenumbers
! DAL1,DAL2,DAL3 Coefficients for the non linear interactions
! CIDP,CIDM
! WIDP,WIDP1,WIDM,WIDM1 Weight factors
! WISP,WISP1,WISM,WISM1 idem
! AWGn Interpolation weight factors
! SWGn Quadratic interpolation weight factors
! XIS,XISLN Difference between succeeding frequencies
! PI 3.14
! FREQ Auxiliary frequency to fill scaling array
! DDIR,RADE band width in directional space and factor 34.00
!
! ARRAYS
! ------
! AF11 1D Scaling frequency
! WWINT 1D counters for 4WAVE interactions
! WWAWG 1D values for the interpolation
! WWSWG 1D vaules for the interpolation
!
! WWINT ( 1 = IDP WWAWG ( = AGW1 WWSWG ( = SWG1
! 2 = IDP1 = AWG2 = SWG2
! 3 = IDM = AWG3 = SWG3
! 4 = IDM1 = AWG4 = SWG4
! 5 = ISP = AWG5 = SWG5
! 6 = ISP1 = AWG6 = SWG6
! 7 = ISM = AWG7 = SWG7
! 8 = ISM1 = AWG8 ) = SWG8 )
! 9 = ISLOW
! 10= ISHGH
! 11= ISCLW
! 12= ISCHG
! 13= IDLOW
! 14= IDHGH
! 15= MSC4MI
! 16= MSC4MA
! 17= MDC4MI
! 18= MDC4MA
! 19= MSCMAX
! 20= MDCMAX
! 21= IDPP
! 22= IDMM
! 23= ISPP
! 24= ISMM )
!
! 7. Common blocks used
!
!
! 9. Source code :
!
! -----------------------------------------------------------------
! Calculate :
! 1. counters for frequency and direction for NL-interaction
! 2. weight factors
! 3. the minimum and maximum counter in IS and ID space
! 4. the interpolation weights
! 5. the quadratic interpolation rates
! 6. fill the array for the frequency**11
! ----------------------------------------------------------
!
!****************************************************************
!
INTEGER MSC2 ,MSC1 ,IS ,IDP ,IDP1 , 40.41 34.00
& IDM ,IDM1 ,ISP ,ISP1 ,ISM ,ISM1 , 34.00
& IDPP ,IDMM ,ISPP ,ISMM , 40.41
& ISLOW ,ISHGH ,ISCLW ,ISCHG ,IDLOW ,IDHGH ,
& MSCMAX,MDCMAX 34.00
!
REAL SNLC1 ,LAMM2 ,LAMP2 ,DELTH3, 40.17 34.00
& AUX1 ,DELTH4,DAL1 ,DAL2 ,DAL3 ,CIDP ,WIDP ,
& WIDP1 ,CIDM ,WIDM ,WIDM1 ,XIS ,XISLN ,WISP ,
& WISP1 ,WISM ,WISM1 ,AWG1 ,AWG2 ,AWG3 ,AWG4 ,
& AWG5 ,AWG6 ,AWG7 ,AWG8 ,SWG1 ,SWG2 ,SWG3 ,
& SWG4 ,SWG5 ,SWG6 ,SWG7 ,SWG8 ,FREQ , 34.00
& RADE 34.00
!
REAL WWAWG(*) , 40.17
& WWSWG(*)
!
INTEGER WWINT(*)
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'FAC4WW')
IF (ALLOCATED(AF11)) DEALLOCATE(AF11) 40.17
! *** Compute frequency indices ***
! *** XIS is the relative increment of the relative frequency ***
!
MSC2 = INT ( FLOAT(MSC) / 2.0 )
MSC1 = MSC2 - 1
XIS = SPCSIG(MSC2) / SPCSIG(MSC1) 30.72
!
! *** set values for the nonlinear four-wave interactions ***
!
SNLC1 = 1. / GRAV**4 40.17 34.00
!
LAMM2 = (1.-PQUAD(1))**2 40.17
LAMP2 = (1.+PQUAD(1))**2 40.17
DELTH3 = ACOS( (LAMM2**2+4.-LAMP2**2) / (4.*LAMM2) )
AUX1 = SIN(DELTH3)
DELTH4 = ASIN(-AUX1*LAMM2/LAMP2)
!
DAL1 = 1. / (1.+PQUAD(1))**4 40.17
DAL2 = 1. / (1.-PQUAD(1))**4 40.17
DAL3 = 2. * DAL1 * DAL2
!
! *** Compute directional indices in sigma and theta space ***
!
CIDP = ABS(DELTH4/DDIR) 40.00
IDP = INT(CIDP)
IDP1 = IDP + 1
WIDP = CIDP - REAL(IDP)
WIDP1 = 1.- WIDP
!
CIDM = ABS(DELTH3/DDIR) 40.00
IDM = INT(CIDM)
IDM1 = IDM + 1
WIDM = CIDM - REAL(IDM)
WIDM1 = 1.- WIDM
XISLN = LOG( XIS )
!
ISP = INT( LOG(1.+PQUAD(1)) / XISLN ) 40.17
ISP1 = ISP + 1
WISP = (1.+PQUAD(1) - XIS**ISP) / (XIS**ISP1 - XIS**ISP) 40.17
WISP1 = 1. - WISP
!
ISM = INT( LOG(1.-PQUAD(1)) / XISLN ) 40.17
ISM1 = ISM - 1
WISM = (XIS**ISM -(1.-PQUAD(1))) / (XIS**ISM - XIS**ISM1) 40.17
WISM1 = 1. - WISM
!
! *** Range of calculations ***
!
ISLOW = 1 + ISM1
ISHGH = MSC + ISP1 - ISM1
ISCLW = 1
ISCHG = MSC - ISM1
IDLOW = 1 - MDC - MAX(IDM1,IDP1)
IDHGH = MDC + MDC + MAX(IDM1,IDP1)
!
MSC4MI = ISLOW
MSC4MA = ISHGH
MDC4MI = IDLOW
MDC4MA = IDHGH
MSCMAX = MSC4MA - MSC4MI + 1
MDCMAX = MDC4MA - MDC4MI + 1
!
! *** Interpolation weights ***
!
AWG1 = WIDP * WISP
AWG2 = WIDP1 * WISP
AWG3 = WIDP * WISP1
AWG4 = WIDP1 * WISP1
!
AWG5 = WIDM * WISM
AWG6 = WIDM1 * WISM
AWG7 = WIDM * WISM1
AWG8 = WIDM1 * WISM1
!
! *** quadratic interpolation ***
!
SWG1 = AWG1**2
SWG2 = AWG2**2
SWG3 = AWG3**2
SWG4 = AWG4**2
!
SWG5 = AWG5**2
SWG6 = AWG6**2
SWG7 = AWG7**2
SWG8 = AWG8**2
!
! --- determine discrete counters for piecewise 40.41
! constant interpolation 40.41
!
IF (AWG1.LT.AWG2) THEN
IF (AWG2.LT.AWG3) THEN
IF (AWG3.LT.AWG4) THEN
ISPP=ISP
IDPP=IDP
ELSE
ISPP=ISP
IDPP=IDP1
END IF
ELSE IF (AWG2.LT.AWG4) THEN
ISPP=ISP
IDPP=IDP
ELSE
ISPP=ISP1
IDPP=IDP
END IF
ELSE IF (AWG1.LT.AWG3) THEN
IF (AWG3.LT.AWG4) THEN
ISPP=ISP
IDPP=IDP
ELSE
ISPP=ISP
IDPP=IDP1
END IF
ELSE IF (AWG1.LT.AWG4) THEN
ISPP=ISP
IDPP=IDP
ELSE
ISPP=ISP1
IDPP=IDP1
END IF
IF (AWG5.LT.AWG6) THEN
IF (AWG6.LT.AWG7) THEN
IF (AWG7.LT.AWG8) THEN
ISMM=ISM
IDMM=IDM
ELSE
ISMM=ISM
IDMM=IDM1
END IF
ELSE IF (AWG6.LT.AWG8) THEN
ISMM=ISM
IDMM=IDM
ELSE
ISMM=ISM1
IDMM=IDM
END IF
ELSE IF (AWG5.LT.AWG7) THEN
IF (AWG7.LT.AWG8) THEN
ISMM=ISM
IDMM=IDM
ELSE
ISMM=ISM
IDMM=IDM1
END IF
ELSE IF (AWG5.LT.AWG8) THEN
ISMM=ISM
IDMM=IDM
ELSE
ISMM=ISM1
IDMM=IDM1
END IF
!
! *** fill the arrays *
!
WWINT(1) = IDP
WWINT(2) = IDP1
WWINT(3) = IDM
WWINT(4) = IDM1
WWINT(5) = ISP
WWINT(6) = ISP1
WWINT(7) = ISM
WWINT(8) = ISM1
WWINT(9) = ISLOW
WWINT(10)= ISHGH
WWINT(11)= ISCLW
WWINT(12)= ISCHG
WWINT(13)= IDLOW
WWINT(14)= IDHGH
WWINT(15)= MSC4MI
WWINT(16)= MSC4MA
WWINT(17)= MDC4MI
WWINT(18)= MDC4MA
WWINT(19)= MSCMAX
WWINT(20)= MDCMAX
WWINT(21)= IDPP 40.41
WWINT(22)= IDMM 40.41
WWINT(23)= ISPP 40.41
WWINT(24)= ISMM 40.41
!
WWAWG(1) = AWG1
WWAWG(2) = AWG2
WWAWG(3) = AWG3
WWAWG(4) = AWG4
WWAWG(5) = AWG5
WWAWG(6) = AWG6
WWAWG(7) = AWG7
WWAWG(8) = AWG8
!
WWSWG(1) = SWG1
WWSWG(2) = SWG2
WWSWG(3) = SWG3
WWSWG(4) = SWG4
WWSWG(5) = SWG5
WWSWG(6) = SWG6
WWSWG(7) = SWG7
WWSWG(8) = SWG8
ALLOCATE (AF11(MSC4MI:MSC4MA)) 40.17
! *** Fill scaling array (f**11) ***
! *** compute the radian frequency**11 for IS=1, MSC ***
!
DO 100 IS=1, MSC
AF11(IS) = ( SPCSIG(IS) / ( 2. * PI ) )**11 30.72
100 CONTINUE
!
! *** compute the radian frequency for the IS = MSC+1, ISHGH ***
!
FREQ = SPCSIG(MSC) / ( 2. * PI ) 30.72
DO 110 IS = MSC+1, ISHGH
FREQ = FREQ * XIS
AF11(IS) = FREQ**11
110 CONTINUE
!
! *** compute the radian frequency for IS = 0, ISLOW ***
!
FREQ = SPCSIG(1) / ( 2. * PI ) 30.72
DO 120 IS = 0, ISLOW, -1
FREQ = FREQ / XIS
AF11(IS) = FREQ**11
120 CONTINUE
!
! *** test output ***
!
IF (ISLOW .LT. MSC4MI .OR. ISHGH .GT. MSC4MA .OR.
& IDLOW .LT. MDC4MI .OR. IDHGH .GT. MDC4MA) THEN
WRITE (PRINTF,900) IXCGRD(1), IYCGRD(1),
& ISLOW, ISHGH, IDLOW, IDHGH,
& MSC4MI,MSC4MA, MDC4MI, MDC4MA
900 FORMAT ( ' ** Error : array bounds and maxima in subr FAC4WW, ',
& ' point ', 2I5,
& /,' ISL,ISH : ',2I4, ' IDL,IDH : ',2I4,
& /,' SMI,SMA : ',2I4, ' DMI,DMA : ',2I4)
ENDIF
!
IF (ITEST .GE. 40) THEN
RADE = 360.0 / ( 2. * PI )
WRITE(PRINTF,*)
WRITE(PRINTF,*) ' FAC4WW subroutine '
WRITE(PRINTF,9000) DELTH4*RADE, DELTH3*RADE, DDIR*RADE, XIS
9000 FORMAT (' THET3 THET4 DDIR XIS :',4E12.4)
WRITE(PRINTF,9011) IDP, IDP1, IDM, IDM1
9011 FORMAT (' IDP IDP1 IDM IDM1 :',4I5)
WRITE(PRINTF,9012) WIDP, WIDP1, WIDM, WIDM1
9012 FORMAT (' WIDP WIDP1 WIDM WIDM1 :',4E12.4)
WRITE (PRINTF,9013) ISP, ISP1, ISM, ISM1
9013 FORMAT (' ISP ISP1 ISM ISM1 :',4I5)
WRITE (PRINTF,9014) WISP, WISP1, WISM, WISM1
9014 FORMAT (' WISP WISP1 WISM WISM1 :',4E12.4)
WRITE(PRINTF,9016) ISCLW, ISCHG
9016 FORMAT (' ICLW ICHG :',2I5)
WRITE (PRINTF,9017) AWG1, AWG2, AWG3, AWG4
9017 FORMAT (' AWG1 AWG2 AWG3 AWG4 :',4E12.4)
WRITE (PRINTF,9018) AWG5, AWG6, AWG7, AWG8
9018 FORMAT (' AWG5 AWG6 AWG7 AWG8 :',4E12.4)
WRITE (PRINTF,9019) MSC4MI, MSC4MA, MDC4MI, MDC4MA
9019 FORMAT (' S4MI S4MA D4MI D4MA :',4I6)
WRITE (PRINTF,9015) ISLOW, ISHGH, IDLOW,IDHGH
9015 FORMAT (' ISLOW ISHG IDLOW IDHG :',4I5)
WRITE(PRINTF,*)
END IF
!
RETURN
! End of FAC4WW
END
!
!******************************************************************
!
SUBROUTINE RANGE4 (WWINT ,IDDLOW,IDDTOP) 40.00
!
!******************************************************************
!
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
!
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering and Geosciences |
! | Environmental Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmers: The SWAN team |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 40.00: Nico Booij
! 40.10: IJsbrand Haagsma
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 40.10, Mar. 00: Made modification for exact quadruplets
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. Purpose :
!
! calculate the minimum and maximum counters in frequency and
! directional space which fall with the calculation for the
! nonlinear wave-wave interactions.
!
! 3. Method : review for the counters :
!
! Frequencies -->
! +---+---------------------+---------+- IDHGH
! d | 3 : 2 : 2 |
! i + - + - - - - - - - - - - + - - - - +- MDC
! r | : : |
! e | 3 : original spectrum : 1 |
! c | : : |
! t. + - + - - - - - - - - - - + - - - - +- 1
! | 3 : 2 : 2 |
! +---+---------------------+---------+- IDLOW
! | | | ^ |
! ISLOW 1 MSC | ISHGH
! ^ |
! | |
! ISCLW ISCHG
! lowest discrete highest discrete
! central bin central bin
!
!
! The directional counters depend on the numerical method that
! is used.
!
! 4. Parameters :
!
! INTEGER
! -------
! IQUAD Counter for 4 wave interactions
! ISLOW,ISHGH Minimum and maximum counter in frequency space
! ISCLW,ISCHG idem for discrete computations
! IDLOW,IDHGH Minimum and maximum counters in directional space
! MSC,MDC Range of the original arrays
! ISM1,ISP1,
! IDM1,IDP1 see subroutine FAC4WW
! IDDLOW minimum counter of the bin that is propagated
! within a sweep
! IDDTOP minimum counter of the bin that is propagated
! within a sweep
!
! array:
! ------
! WWINT counters for the nonlinear interactions
!
! WWINT ( 1 = IDP 2 = IDP1 3 = IDM 4 = IDM1
! 5 = ISP 6 = ISP1 7 = ISM 8 = ISM1
! 9 = ISLOW 10 = ISHGH 11 = ISCLW 12 = ISCHG
! 13 = IDLOW 14 = IDHGH 15 = MSC4MI 16 = MSC4MA
! 17 = MDC4MI 18 = MDC4MA
! 19 = MSCMAX 20 = MDCMAX )
!
! 5. Subroutines used :
!
! ---
!
! 6. Called by :
!
! SOURCE
!
! 7. Common blocks used
!
!
! 9. Source code :
!
! -----------------------------------------------------------------
! Calculate :
! In absence of a current there are always four sectors
! equal 90 degrees within a sweep that are propagated
! Extend the boundaries to calculate the source term
! In presence of a current and if IDTOT .eq. MDC then calculate
! boundaries for calculation of interaction using the
! unfolded area.
! ----------------------------------------------------------
!
!****************************************************************
!
INTEGER IDDLOW,IDDTOP 40.00
!
INTEGER WWINT(*)
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'RANGE4')
!
! *** Range in directional domain ***
!
IF ( IQUAD .LT. 3 .AND. IQUAD .GT. 0 ) THEN 40.10
! *** counters based on bins which fall within a sweep ***
WWINT(13) = IDDLOW - MAX( WWINT(4), WWINT(2) )
WWINT(14) = IDDTOP + MAX( WWINT(4), WWINT(2) )
ELSE
! *** counters initially based on full circle ***
WWINT(13) = 1 - MAX( WWINT(4), WWINT(2) )
WWINT(14) = MDC + MAX( WWINT(4), WWINT(2) )
END IF
!
! *** error message ***
!
IF (WWINT(9) .LT. WWINT(15) .OR. WWINT(10) .GT. WWINT(16) .OR.
& WWINT(13) .LT. WWINT(17) .OR. WWINT(14) .GT. WWINT(18) ) THEN
WRITE (PRINTF,900) IXCGRD(1), IYCGRD(1),
& WWINT(9) ,WWINT(10) ,WWINT(13) ,WWINT(14),
& WWINT(15),WWINT(16) ,WWINT(17) ,WWINT(18)
900 FORMAT ( ' ** Error : array bounds and maxima in subr RANGE4, ',
& ' point ', 2I5,
& /,' ISL,ISH : ',2I4, ' IDL,IDH : ',2I4,
& /,' SMI,SMA : ',2I4, ' DMI,DMA : ',2I4)
IF (ITEST.GE.50) WRITE (PRTEST, 901) MSC, MDC, IDDLOW, IDDTOP
901 FORMAT (' MSC, MDC, IDDLOW, IDDTOP: ', 4I5)
ENDIF
!
! test output
!
IF (TESTFL .AND. ITEST .GE. 60) THEN
WRITE(PRTEST,911) WWINT(4), WWINT(2), WWINT(8), WWINT(6)
911 FORMAT (' RANGE4: IDM1 IDP1 ISM1 ISP1 :',4I5)
WRITE(PRTEST,916) WWINT(11), WWINT(12), IQUAD
916 FORMAT (' RANGE4: ISCLW ISCHG IQUAD :',3I5)
WRITE (PRTEST,917) WWINT(9), WWINT(10), WWINT(13), WWINT(14)
917 FORMAT (' RANGE4: ISLOW ISHGH IDLOW IDHGH:',4I5)
WRITE (PRTEST,919) WWINT(15), WWINT(16), WWINT(17), WWINT(18)
919 FORMAT (' RANGE4: MS4MI MS4MA MD4MI MD4MA:',4I5)
WRITE(PRINTF,*)
END IF
!
RETURN
! End of RANGE4
END
!
!********************************************************************
!
SUBROUTINE SWSNL1 (WWINT ,WWAWG ,WWSWG , 34.00
& IDCMIN ,IDCMAX ,UE ,SA1 , 40.17
& SA2 ,DA1C ,DA1P ,DA1M ,DA2C ,
& DA2P ,DA2M ,SPCSIG ,SNLC1 ,KMESPC , 30.72
& FACHFR ,ISSTOP ,DAL1 ,DAL2 ,DAL3 ,
& SFNL ,DSNL ,DEP2 ,AC2 ,IMATDA ,
& IMATRA ,PLNL4S ,PLNL4D , 34.00
& IDDLOW ,IDDTOP ,REDC0 ,REDC1 ) 40.85 34.00
!
!********************************************************************
!
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
USE M_SNL4 40.17
!
! --|-----------------------------------------------------------|--
! | Delft University of Technology |
! | Faculty of Civil Engineering |
! | Fluid Mechanics Section |
! | P.O. Box 5048, 2600 GA Delft, The Netherlands |
! | |
! | Programmers: H.L. Tolman, R.C. Ris |
! --|-----------------------------------------------------------|--
!
!
! SWAN (Simulating WAves Nearshore); a third generation wave model
! Copyright (C) 1993-2024 Delft University of Technology
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
!
! 0. Authors
!
! 30.72: IJsbrand Haagsma
! 40.13: Nico Booij
! 40.17: IJsbrand Haagsma
! 40.23: Marcel Zijlema
! 40.41: Marcel Zijlema
! 40.85: Marcel Zijlema
!
! 1. Updates
!
! 30.72, Feb. 98: Introduced generic names XCGRID, YCGRID and SPCSIG for SWAN
! 40.17, Dec. 01: Implentation of Multiple DIA
! 40.23, Aug. 02: some corrections
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
! 40.85, Aug. 08: store quadruplets for output purposes
!
! 2. Purpose
!
! Calculate non-linear interaction using the discrete interaction
! approximation (Hasselmann and Hasselmann 1985; WAMDI group 1988),
! including the diagonal term for the implicit integration.
!
! The interactions are calculated for all bin's that fall
! within a sweep. No additional auxiliary array is required (see
! SWSNL3)
!
! 3. Method
!
! Discrete interaction approximation.
!
! Since the domain in directional domain is by definition not
! periodic, the spectral space can not beforehand
! folded to the side angles. This can only be done if the
! full circle has to be calculated
!
!
! Frequencies -->
! +---+---------------------+---------+- IDHGH
! d | 3 : 2 : 2 |
! i + - + - - - - - - - - - - + - - - - +- MDC
! r | : : |
! e | 3 : original spectrum : 1 |
! c | : : |
! t. + - + - - - - - - - - - - + - - - - +- 1
! | 3 : 2 : 2 |
! +---+---------------------+---------+- IDLOW
! | | | ^ |
! ISLOW 1 MSC | ISHGH
! ^ |
! | |
! ISCLW ISCHG
! lowest discrete highest discrete
! central bin central bin
!
! 1 : Extra tail added beyond MSC
! 2 : Spectrum copied outside ID range
! 3 : Empty bins at low frequencies
!
! ISLOW = 1 + ISM1
! ISHGH = MSC + ISP1 - ISM1
! ISCLW = 1
! ISCHG = MSC - ISM1
! IDLOW = IDDLOW - MAX(IDM1,IDP1)
! IDHGH = IDDTOP + MAX(IDM1,IDP1)
!
! For the meaning of the counters on the right hand side of the
! above equations see section 4.
!
! 4. Argument variables
!
! SPCSIG: Relative frequencies in computational domain in sigma-space 30.72
!
REAL SPCSIG(MSC) 30.72
!
! Data in PARAMETER statements :
! ----------------------------------------------------------------
! DAL1 Real LAMBDA dependend weight factors (see FAC4WW)
! DAL2 Real
! DAL3 Real
! ITHP, ITHP1, ITHM, ITHM1, IFRP, IFRP1, IFRM, IFRM1
! Int. Counters of interpolation point relative to
! central bin, see figure below (set in FAC4WW).
! NFRLOW, NFRHGH, NFRCHG, NTHLOW, NTHHGH
! Int. Range of calculations, see section 2.
! AF11 R.A. Scaling array (Freq**11).
! AWGn Real Interpolation weights, see numbers in fig.
! SWGn Real Id. squared.
! UE R.A. "Unfolded" spectrum.
! SA1 R.A. Interaction constribution of first and second
! SA2 R.A. quadr. respectively (unfolded space).
! DA1C, DA1P, DA1M, DA2C, DA2P, DA2M
! R.A. Idem for diagonal matrix.
! PERCIR full circle or sector
! ----------------------------------------------------------------
!
! Relative offsets of interpolation points around central bin
! "#" and corresponding numbers of AWGn :
!
! ISM1 ISM
! 5 7 T |
! IDM1 +------+ H +
! | | E | ISP ISP1
! | \ | T | 3 1
! IDM +------+ A + +---------+ IDP1
! 6 \8 | | |
! | | / |
! \ + +---------+ IDP
! | /4 2
! \ | /
! -+-----+------+-------#--------+---------+----------+
! | FREQ.
!
! 7. Common blocks used
!
!
! 8. Subroutines used
!
! ---
!
! 9. Subroutines calling
!
! SOURCE (in SWANCOM1)
!
! 12. Structure
!
! -------------------------------------------
! Initialisations.
! Calculate proportionality constant.
! Prepare auxiliary spectrum.
! Calculate interactions :
! -----------------------------------------
! Energy at interacting bins
! Contribution to interactions
! Fold interactions to side angles
! -----------------------------------------
! Put source term together
! -------------------------------------------
!
! 13. Source text
!
!*************************************************************
!
INTEGER IS ,ID ,I ,J , 34.00
& ISHGH ,IDLOW ,ISP ,ISP1 ,IDP ,IDP1 ,
& ISM ,ISM1 ,IDHGH ,IDM ,IDM1 ,ISCLW ,
& ISCHG ,IDDLOW ,IDDTOP 34.00
!
REAL X ,X2 ,CONS ,FACTOR ,SNLCS1 ,SNLCS2 ,SNLCS3,
& E00 ,EP1 ,EM1 ,EP2 ,EM2 ,SA1A ,SA1B ,
& SA2A ,SA2B ,KMESPC ,FACHFR ,AWG1 ,AWG2 ,AWG3 ,
& AWG4 ,AWG5 ,AWG6 ,AWG7 ,AWG8 ,DAL1 ,DAL2 ,
& DAL3 ,SNLC1 ,SWG1 ,SWG2 ,SWG3 ,SWG4 ,SWG5 ,
& SWG6 ,SWG7 ,SWG8 ,JACOBI ,SIGPI 34.00
!
REAL AC2(MDC,MSC,MCGRD) ,
& DEP2(MCGRD) ,
& UE(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& SA1(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& SA2(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA1C(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA1P(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA1M(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA2C(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA2P(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DA2M(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& SFNL(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& DSNL(MSC4MI:MSC4MA , MDC4MI:MDC4MA ) ,
& IMATDA(MDC,MSC) ,
& IMATRA(MDC,MSC) ,
& PLNL4S(MDC,MSC,NPTST) , 40.00
& PLNL4D(MDC,MSC,NPTST) ,
& WWAWG(*) ,
& WWSWG(*)
REAL :: REDC0 (MDC,MSC,MREDS) 40.85
REAL :: REDC1 (MDC,MSC,MREDS) 40.85
!
INTEGER IDCMIN(MSC) ,
& IDCMAX(MSC) ,
& WWINT(*)
!
LOGICAL PERCIR
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWSNL1')
!
IDP = WWINT(1)
IDP1 = WWINT(2)
IDM = WWINT(3)
IDM1 = WWINT(4)
ISP = WWINT(5)
ISP1 = WWINT(6)
ISM = WWINT(7)
ISM1 = WWINT(8)
ISLOW = WWINT(9)
ISHGH = WWINT(10)
ISCLW = WWINT(11)
ISCHG = WWINT(12)
IDLOW = WWINT(13)
IDHGH = WWINT(14)
!
AWG1 = WWAWG(1)
AWG2 = WWAWG(2)
AWG3 = WWAWG(3)
AWG4 = WWAWG(4)
AWG5 = WWAWG(5)
AWG6 = WWAWG(6)
AWG7 = WWAWG(7)
AWG8 = WWAWG(8)
!
SWG1 = WWSWG(1)
SWG2 = WWSWG(2)
SWG3 = WWSWG(3)
SWG4 = WWSWG(4)
SWG5 = WWSWG(5)
SWG6 = WWSWG(6)
SWG7 = WWSWG(7)
SWG8 = WWSWG(8)
!
! *** Initialize auxiliary arrays per gridpoint ***
!
DO ID = MDC4MI, MDC4MA
DO IS = MSC4MI, MSC4MA
UE(IS,ID) = 0.
SA1(IS,ID) = 0.
SA2(IS,ID) = 0.
SFNL(IS,ID) = 0.
DA1C(IS,ID) = 0.
DA1P(IS,ID) = 0.
DA1M(IS,ID) = 0.
DA2C(IS,ID) = 0.
DA2P(IS,ID) = 0.
DA2M(IS,ID) = 0.
DSNL(IS,ID) = 0.
ENDDO
ENDDO
!
! *** Calculate factor R(X) to calculate the NL wave-wave ***
! *** interaction for shallow water ***
! *** SNLC1 = 1/GRAV**4 *** 40.17
!
SNLCS1 = PQUAD(3) 34.00
SNLCS2 = PQUAD(4) 34.00
SNLCS3 = PQUAD(5) 34.00
X = MAX ( 0.75 * DEP2(KCGRD(1)) * KMESPC , 0.5 )
X2 = MAX ( -1.E15, SNLCS3*X)
CONS = SNLC1 * ( 1. + SNLCS1/X * (1.-SNLCS2*X) * EXP(X2))
JACOBI = 2. * PI
!
! *** check whether the spectral domain is periodic in ***
! *** directional space and if so, modify boundaries ***
!
PERCIR = .FALSE.
IF ( IDDLOW .EQ. 1 .AND. IDDTOP .EQ. MDC ) THEN
! *** periodic in theta -> spectrum can be folded ***
! *** (can only be present in presence of a current) ***
IDCLOW = 1
IDCHGH = MDC
IIID = 0
PERCIR = .TRUE.
ELSE
! *** different sectors per sweep -> extend range with IIID ***
IIID = MAX ( IDM1 , IDP1 )
IDCLOW = IDLOW
IDCHGH = IDHGH
ENDIF
!
! *** Prepare auxiliary spectrum ***
! *** set action original spectrum in array UE ***
!
DO IDDUM = IDLOW - IIID, IDHGH + IIID