-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswancom5.ftn
6001 lines (5849 loc) · 249 KB
/
swancom5.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 5 of 5
!
!
! PROGRAM SWANCOM5.FOR
!
! This file SWANCOM5 of the main program SWAN
! includes the next subroutines (mainly subroutines for
! the propagation in x,y,s,d space and parameters ) :
!
! SWGEOM ( determines geometric quantities )
! SWPSEL ( determine spectral counters in presence
! or absence of a current )
! SPROXY ( compute spatial propagation velocities CAX, CAY )
! SPROSD ( compute spectral propagation velocities CAS, CAD )
! DSPHER ( compute Ctheta for propagation over the globe ) 33.09
! STRSXY ( compute derivative in space and time )
! SORDUP ( compute spatial derivatives with SORDUP scheme ) 33.10
! SANDL ( compute spatial derivatives with S&L scheme ) 33.08
! STRSSI ( compute derivative in s-space implicit scheme )
! STRSSB ( compute derivative in s-space explicit scheme and
! remove (or dissipate bin's that are blocked) )
! STRSD ( compute derivative in d-space implicit )
! SPREDT ( calculate action density in central point: first guess )
! SWAPAR ( compute wave parameters k, cgo and cg )
! ADDDIS ( adds leak and dissipation to arrays in COMPDA, after
! action densities have been computed )
! SWFLXD ( compute derivative in theta-space by means of 40.23
! flux-limiting )
! DIFPAR ( compute diffraction parameter and its derivatives ) 40.21
!
!****************************************************************
!
SUBROUTINE SWGEOM ( RDX, RDY, XCGRID, YCGRID, SWPDIR )
!
!****************************************************************
!
USE SWCOMM2 40.41
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
USE M_PARALL
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | 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.41: Marcel Zijlema
! 40.98: Marcel Zijlema
!
! 1. Updates
!
! 40.41, Sep. 04: New subroutine (taken from routine SWPSEL)
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
! 40.98, Feb. 09: SORDUP scheme is made consistent
!
! 2. Purpose
!
! Determine geometric quantities due to curvilinear grid
!
! 3. Method
!
! Trivial
!
! 4. Argument variables
!
! RDX contains derivatives of (ksi,eta) to x-direction
! (i.e. first component of contravariant base
! vector RDX(b) = a^(b)_1)
! RDY contains derivatives of (ksi,eta) to y-direction
! (i.e. second component of contravariant base
! vector RDY(b) = a^(b)_2)
! SWPDIR sweep direction
! XCGRID coordinates of computational grid in x-direction
! YCGRID coordinates of computational grid in y-direction
!
INTEGER SWPDIR
REAL XCGRID(MXC,MYC), YCGRID(MXC,MYC),
& RDX(MICMAX) , RDY(MICMAX)
!
! 6. Local variables
!
! DET : determinant or volume of cell
! DX1 : first component of covariant base vector a_(1)
! DX2 : second component of covariant base vector a_(1)
! DY1 : first component of covariant base vector a_(2)
! DY2 : second component of covariant base vector a_(2)
! IC : counter
! IENT : number of entries
! IXY : counter
! VIRT : indicates virtual point for 1D mode
!
INTEGER IC, IENT, IXY
REAL VIRT, DET, DX1, DX2, DY1, DY2
!
! 7. Common blocks used
!
!
! 8. Subroutines used
!
! STRACE Tracing routine for debugging
!
! 9. Subroutines calling
!
! SWOMPU
!
! 13. Source text
!
SAVE IENT
DATA IENT/0/
IF (LTRACE) CALL STRACE (IENT,'SWGEOM')
!
IF (KREPTX.GT.0) THEN 33.09
! repeating x-axis (only regular grids)
IF (SWPDIR.EQ.1 .OR. SWPDIR.EQ.4) THEN
DX1 = DX * COSPC 33.09
DY1 = DX * SINPC 33.09
ELSE
DX1 = -DX * COSPC 33.09
DY1 = -DX * SINPC 33.09
ENDIF
IF ( ONED ) THEN 33.09
! *** Inclusion of virtual point *** 33.09
VIRT = 1.E6 33.09
IF ( SWPDIR .EQ. 1 .OR. SWPDIR .EQ. 3 ) THEN 33.09
DX2 = -VIRT * DY1 33.09
DY2 = VIRT * DX1 33.09
ELSE 33.09
DX2 = VIRT * DY1 33.09
DY2 = -VIRT * DX1 33.09
ENDIF 33.09
ELSE 33.09
IF (SWPDIR.LE.2) THEN 40.13
DX2 = - DY * SINPC 40.13
DY2 = DY * COSPC 40.13
ELSE 40.13
DX2 = DY * SINPC 40.13
DY2 = - DY * COSPC 40.13
ENDIF 40.13
ENDIF 33.09
ELSE 33.09
DX1 = XCGRID(IXCGRD(1),IYCGRD(1)) - XCGRID(IXCGRD(2),IYCGRD(2))
DY1 = YCGRID(IXCGRD(1),IYCGRD(1)) - YCGRID(IXCGRD(2),IYCGRD(2))
IF ( ONED ) THEN 32.02
! *** Inclusion of virtual point *** 32.02
VIRT = 1.E6 32.02
IF ( SWPDIR .EQ. 1 .OR. SWPDIR .EQ. 3 ) THEN 32.02
DX2 = -VIRT * DY1 32.02
DY2 = VIRT * DX1 32.02
ELSE IF ( SWPDIR .EQ. 2 .OR. SWPDIR .EQ. 4 ) THEN 32.02
DX2 = VIRT * DY1 32.02
DY2 = -VIRT * DX1 32.02
ENDIF 32.02
ELSE 32.02
DX2 = XCGRID(IXCGRD(1),IYCGRD(1))-XCGRID(IXCGRD(3),IYCGRD(3))
DY2 = YCGRID(IXCGRD(1),IYCGRD(1))-YCGRID(IXCGRD(3),IYCGRD(3))
ENDIF 32.02
ENDIF 33.09
!
DET = DY2*DX1 - DY1*DX2
RDX(1) = DY2/DET
RDY(1) = -DX2/DET
RDX(2) = -DY1/DET
RDY(2) = DX1/DET
!
! in case of spherical coordinates determine cos of latitude
! note: latitude is in degrees
!
IF (KSPHER.GT.0) THEN
DO IC = 1, ICMAX
IF ( KCGRD(IC).EQ.1 ) CYCLE ! if point is not valid, then cycle
COSLAT(IC) =
& COS(DEGRAD*(YCGRID(IXCGRD(IC),IYCGRD(IC))+YOFFS)) 33.09
ENDDO
DO IXY = 1, 2 40.08
RDY(IXY) = RDY(IXY) / LENDEG 33.09
RDX(IXY) = RDX(IXY) / (COSLAT(1) * LENDEG) 33.09
ENDDO
ENDIF
!
IF (TESTFL .AND. ITEST .GE. 30) THEN
WRITE(PRINTF,186)
186 FORMAT(' ...POINTS IN STENCIL IN SUBROUTINE SWGEOM...',
& /,'Point: IC, Ix, Iy, INDEX, Xc, Yc')
DO IC = 1, 3
WRITE(PRINTF,187) IC, IXCGRD(IC)+MXF-1, IYCGRD(IC)+MYF-1, 40.30
& KCGRD(IC), 40.30
& XCGRID(IXCGRD(IC),IYCGRD(IC)),YCGRID(IXCGRD(IC),IYCGRD(IC))
187 FORMAT(3(1X,I4),3X,I5,5X,F10.2,4X,F10.2)
ENDDO
WRITE(PRINTF,188) DET,RDX(1),RDX(2),RDY(1),RDY(2)
188 FORMAT(' DET, RDX1, RDX2, RDY1, RDY2',/,
& 5(E10.4,1X))
ENDIF
RETURN
END
!
!******************************************************************
!
SUBROUTINE SWPSEL(SWPDIR , IDCMIN , 40.00
& IDCMAX ,CAX ,
& CAY ,ANYBIN ,
& ISCMIN ,
& ISCMAX ,IDTOT ,ISTOT ,
& IDDLOW ,IDDTOP ,ISSTOP ,
& DEP2 ,UX2 ,UY2 ,
& SPCDIR ,RDX ,RDY , 40.41
& KGRPNT 40.41 40.13 30.21
& )
!
!******************************************************************
!
USE SWCOMM1 40.41
USE SWCOMM2 40.41
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
USE M_PARALL 40.31
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | 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
!
! 32.02: Roeland Ris & Cor van der Schelde (1D-version)
! 30.82: IJsbrand Haagsma
! 33.09, 40.00, 40.13: Nico Booij
! 40.30: Marcel Zijlema
! 40.41: Marcel Zijlema
!
! 1. Updates
!
! 20.44, Sep. 96: Subroutine completely reorganised subroutine has new name
! instead of COUNT
! 32.02, Feb. 98: Introduced 1D-version
! 40.00, July 98: common swcomm3 introduced, argument list changed
! 30.82, Oct. 98: Updated description of several variables
! 33.09 : spherical ccordinates introduced
! repeating x-axis introduced
! 40.03, Nov. 99: error messages (see formats 555 and 556) corrected
! 40.13, Mar. 01: argument KGRPNT added in view of debug output
! error severity changed for "blocked" points
! "blocked" points written to error points file
! comments added
! minimal value of ISSTOP is 4 (in view of CGSTAB solver)
! 40.13, July 01: values of DX2 and DY2 corrected in repeating coordinates
! 40.30, Mar. 03: introduction distributed-memory approach using MPI
! 40.41, Sep. 04: part concerning computation of geometric quantities
! moved to new routine SWGEOM
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. PURPOSE
!
! compute the frequency dependent counters in directional space
! in a situation with a current and without a current.
! The counters are only computed for the gridpoint
! considered. This means IC = 1 (see loop with CALL for ICCODE
! function)
!
! 3. METHOD
!
! In absence of a current the fully 360 degrees sector is
! subdivided in 4 sectors of 90 degrees each.
!
! In presence of a current this is not the case anymore. The
! counters of the directional space are frequency dependent.
! It is first determined which bins have to taken into account
! for a particular sweep (unconditionally stable for a specific
! sector). To which sector a bin belongs is determined by its
! propagation velocity Cx and Cy.
!
! For the first sweep, all the bins with a positive propagation
! velocity Cx and Cy have to taken into account.
! For one particular frequency IS:
!
!
! #
! - # + +
! - # + CAX, CAY > 0
! - # |
! IDCMAX # ..*..*..* +
! - #\.....|.....*
! *# \...|.......* +
! - # \.|........
! --*-#------O--------*-- +
! # | \......
! - *# | \...* +
! # # # # # # # # # # # # # # # # # #\# # # # # # # # #
! # * * * IDCMIN
! - # | -
! #
! # -
! - #
! -
! - -
! - - -
!
!
! As can be seen from the figure, the minimum and maximum
! counter of the directional space are determined by the
! vectorial sum of its groupvelocity and its current
! velocity, c_g + U. Especially the higher frequencies are
! modified by the current. The lower frequencies (due to
! the larger propagation velocity) are less modified by a
! current.
!
! In general, we can distinguish 4 cases:
!
! SWEEP 1:
! ..*..
! *.........*
! |. ............ | *..*
! | | *| ..o.......* | *......*
! | *|* |...... ....... | *......*
! | * |..* |*... ....* | *..*
! -----|----- -*---|---*- -----|--*-------*-- ---|-------------
! | * | * | * |
! * * | *|* | |
! * *| | | |
! * *
!
! SECTOR = 0 SECTOR = 2 SECTOR = 4 SECTOR = 1
!
!
! The integer array SECTOR denotes which case is present for
! a certain frequency:
!
! 0 : no bins belongs to first sweep, no sector lies within the
! first sweep
! 2 : circle has 2 intersections with sector boundary
! 4 : circle has 4 intersections with sector boundary
! 1 : full circle lies within the first quadrant, all directions
! have to taken into account
!
! Furthermore it is detemined whether a certain BIN lies within
! a specific quadrant. This is denoted by a logical array ANYBIN
! In case of SECTOR = 4, this array is used to clear the rows
! in the matrix IMATDA, IMATRA, IMATLA, IMATUA, which do not
! belong to the first (or other) sweep (see subroutine SOLPRE).
!
! 4. Argument variables
!
! i SPCDIR: (*,1); spectral directions (radians) 30.82
! (*,2); cosine of spectral directions 30.82
! (*,3); sine of spectral directions 30.82
! (*,4); cosine^2 of spectral directions 30.82
! (*,5); cosine*sine of spectral directions 30.82
! (*,6); sine^2 of spectral directions 30.82
!
REAL SPCDIR(MDC,6) 30.82
!
! INTEGERS:
! --------------------------------------------------------------
! IS Counter of relative frequency band
! ID Counter of directional distribution
! ICUR Indicator for current
! ICMAX Indicator for nearby nodes
! MSC Maximum counter of relative frequency in
! computational model
! MDC Maximum counter of directional distribution in
! computational model
! IDTOT Maximum value between the lowest and highest
! counter in directional space
! ISTOT Maximum value between the lowest and highest
! counter in frequency space
! FULCIR logical: if true, computation on a full circle
!
! REALS:
! --------------------------------------------------------------
! DD input Width of directional band
!
! array's
! -------
!
! CAX 3D propagation velocity
! CAY 3D propagation velocity
! IDCMIN 1D minimum frequency dependent counter (INTEGER)
! IDCMAX 1D maximum frequency dependent counter (INTEGER)
! ISCMIN 1D minimum counter in frequency space
! ISCMAX 1D maximum counter in frequency space
! SECTOR 1D Counter for number enclosed sectors (INTEGER)
! ANYBIN 2D Is a certain bin enclosed in a sweep (LOGICAL)
! SPCDIR 1D spectral directions 20.44
! RDX,RDY 1D array containing spatial derivative coeff
! (determined in routine SWGEOM) 40.41
!
INTEGER, INTENT(IN) :: KGRPNT(1:MXC,1:MYC) ! grid addresses 40.13
!
! 6. Local variables
!
! 7. Common blocks used
!
!
! 8. Subroutines used
!
! ---
!
! 9. Subroutines calling
!
! SWOMPU
!
! 10. Error messages
!
! ---
!
! 11. Remarks
!
! ---
!
! 12. Structure
!
! ----------------------------------------------------------
! If current is on AND the current velocity is not equal zero then
! compute for every frequency for every sweep the minimum
! and maximum counters.
! The minimum counter denotes the conversion from -- to ++
! The maximum counter denotes the conversion from ++ to --
!
! ++++++++++ ---------- +++++++++
! IDCMAX IDCMIN
!
! --------- ++++++++++ ----------
! IDCMIN IDCMAX
!
! else if current is off or Ux=0 m/s and Uy = 0 m/s.
! Without currents, the directional space counters
! are constant during the computation, i.e. 4 sectors
! of 90 degrees each
! --------------------------------------------------------
! End of SWPSEL
! --------------------------------------------------------
!
! 13. Source text
!
INTEGER IS ,ID , SWPDIR, 40.00
& IDSUM ,IDCLOW,IDCHGH,
& IDTOT ,ISTOT ,
& IDDLOW,IDDTOP,ISSLOW,ISSTOP,
& IENT, IDDUM, ISCLOW, ISCHGH, IX, IY ,IC 40.41
!
REAL CAXMID,CAYMID, 40.00
& GROUP, UABS, THDIR 40.41
!
INTEGER IDCMIN(MSC) ,
& IDCMAX(MSC) ,
& ISCMIN(MDC) ,
& ISCMAX(MDC) ,
& SECTOR(MSC)
!
! Changed ICMAX to MICMAX, since MICMAX doesn't vary over gridpoint 40.22
REAL :: CAX(MDC,MSC,MICMAX) 40.22
REAL :: CAY(MDC,MSC,MICMAX) 40.22
REAL :: DEP2(MCGRD) ,
& UX2(MCGRD) ,
& UY2(MCGRD) ,
& RDX(MICMAX), RDY(MICMAX) 40.08
!
LOGICAL ANYBIN(MDC,MSC) ,
& LOWEST, LOWBIN, HGHBIN
!
SAVE IENT
DATA IENT/0/
CALL STRACE (IENT,'SWPSEL')
!
! *** initialize array's in theta direction ***
!
DO 50 IS = 1, MSC
IDCMIN(IS) = 0
IDCMAX(IS) = 0
SECTOR(IS) = 0
DO 49 ID = 1, MDC
ANYBIN(ID,IS) = .FALSE.
49 CONTINUE
50 CONTINUE
!
! *** initialize arrays in frequency direction ***
!
DO 48 ID = 1, MDC
ISCMIN(ID) = 1
ISCMAX(ID) = 1
48 CONTINUE
!
! *** set variables ***
!
IDTOT = 1
ISTOT = 1
ISSLOW = 9999 40.13
ISSTOP = -9999 40.13
!
! --- part of computation of RDXs and RDYs moved to routine SWGEOM 40.41
!
! *** For curvilinear version we do not distinguish if ***
! *** there is current or not, to know if certain bin ***
! *** belongs to certain sweep VER. 30.21 ***
!
! *** calculate minimum and maximum counters in theta space ***
! *** if a current is present: IDCMIN and IDCMAX ***
!
! *** DO LOOP totally organized for curvilinear 30.21 ***
DO 500 IS = 1, MSC
IDCLOW = 0
IDCHGH = 0
IDSUM = 0
DO ID = 1, MDC
IF (IS .EQ. 1 .OR. ICUR .GT. 0) THEN
CAXMID = CAX(ID,IS,1)*RDX(1) + CAY(ID,IS,1)*RDY(1)
CAYMID = CAX(ID,IS,1)*RDX(2) + CAY(ID,IS,1)*RDY(2)
IF (CAXMID .GE. 0. .AND. CAYMID .GE. 0.) THEN
ANYBIN(ID,IS) = .TRUE.
IDSUM = IDSUM + 1
ISSLOW = MIN(IS,ISSLOW) 40.13
ISSTOP = MAX(IS,ISSTOP) 40.13
ENDIF
IF (TESTFL .AND. ITEST .GE. 190) 40.00
& WRITE(PRINTF,333) IS,ID,CAXMID,CAYMID,ANYBIN(ID,IS)
333 FORMAT( ' IS ID CXM CYM ANYBIN :',2(1X,I4),2(1X,E11.4),L2)
ELSE
! no current: if bin IS=1 is in sweep, all with same ID are 40.13
ANYBIN(ID,IS) = ANYBIN(ID,1)
IF (ANYBIN(ID,1)) THEN
IDSUM = IDSUM + 1
ISSTOP = MAX(IS,ISSTOP) 40.13
ENDIF
ENDIF
ENDDO
!
! determine boundaries of sector and array SECTOR
!
DO 400 ID = 1, MDC
LOWBIN = .FALSE.
HGHBIN = .FALSE.
IF (ANYBIN(ID,IS)) THEN
! check if this active bin is a lower Theta-boundary 40.13
IF ( ID .EQ. 1 ) THEN
IF (FULCIR) THEN
IF (.NOT.ANYBIN(MDC,IS)) LOWBIN = .TRUE. 40.00
ELSE
LOWBIN = .TRUE. 40.00
ENDIF
ELSE
IF (.NOT.ANYBIN(ID-1,IS)) LOWBIN = .TRUE.
ENDIF
! check if this active bin is a higher Theta-boundary 40.13
IF ( ID .EQ. MDC ) THEN
IF (FULCIR) THEN
IF (.NOT.ANYBIN(1,IS)) HGHBIN = .TRUE. 40.00
ELSE
HGHBIN = .TRUE. 40.00
ENDIF
ELSE
IF (.NOT.ANYBIN(ID+1,IS)) HGHBIN = .TRUE.
ENDIF
END IF
IF (LOWBIN) THEN
SECTOR(IS) = SECTOR(IS) + 1
IDCLOW = ID
ENDIF
IF (HGHBIN) THEN
SECTOR(IS) = SECTOR(IS) + 1
IDCHGH = ID
ENDIF
400 CONTINUE
! check value of SECTOR
IF (SECTOR(IS).EQ.1 .OR. SECTOR(IS).EQ.3) WRITE (PRTEST, 410)
& SWPDIR, IS, SECTOR(IS), IDSUM, IDCLOW, IDCHGH
410 FORMAT (' error SWPSEL directions ', 6I6)
! *** set the minimum and maximum counters for a sweep ***
!
IF ( IDSUM .EQ. MDC ) THEN
IF (FULCIR .AND. SECTOR(IS).NE.0) WRITE (PRTEST, 410)
& SWPDIR, IS, SECTOR(IS), IDSUM, IDCLOW, IDCHGH
IDCMIN(IS) = 1
IDCMAX(IS) = MDC
SECTOR(IS) = 1
ELSE IF ( IDSUM .EQ. 0 ) THEN
! for this IS there are no active bins
IF (SECTOR(IS).NE.0) WRITE (PRTEST, 410) SWPDIR, IS,
& SECTOR(IS), IDSUM, IDCLOW, IDCHGH
! new values assigned because old ones cause problems in SWSNL2 40.13
IDCMIN(IS) = 9 40.13
IDCMAX(IS) = -9 40.13
SECTOR(IS) = 0
ELSE
IF ( IDCLOW .GT. IDCHGH ) IDCLOW = IDCLOW - MDC
IDCMIN(IS) = IDCLOW
IDCMAX(IS) = IDCHGH
END IF
!
! *** if 4 sectors are present then set counters ***
!
IF ( SECTOR(IS) .GT. 2 ) THEN 10/MAR
IDCMIN(IS) = 1
IDCMAX(IS) = MDC
END IF
!
500 CONTINUE
!
! *** calculate minimum and maximum counters in frequency ***
! *** space if a current is present: ISCMIN and ISCMAX ***
!
IDDLOW = 9999
IDDTOP = -9999
DO IS = 1 , MSC
IF ( SECTOR(IS) .GT. 0 ) THEN
IDDLOW = MIN ( IDDLOW , IDCMIN(IS) )
IDDTOP = MAX ( IDDTOP , IDCMAX(IS) )
END IF
ENDDO
!
! *** Determine counters for a certain sweep ***
!
DO 530 IDDUM = IDDLOW, IDDTOP
ID = MOD ( IDDUM - 1 + MDC , MDC ) + 1
LOWEST = .TRUE.
DO 430 IS = 1, MSC
IF (ANYBIN(ID,IS)) THEN
IF ( LOWEST ) THEN
ISCLOW = IS
LOWEST = .FALSE.
ENDIF
ISCHGH = IS
END IF
430 CONTINUE
!
! *** set the minimum and maximum counters in arrays ***
!
IF (.NOT.LOWEST) THEN
ISCMIN(ID) = ISCLOW
ISCMAX(ID) = ISCHGH
IF (ISCMIN(ID).LT.ISSLOW) WRITE (PRINTF,*)
& ' error SWPSEL, ISSLOW=', ISSLOW, 'ISCMIN=', ISCMIN(ID),
& ' for ID=', ID
IF (ISCMAX(ID).GT.ISSTOP) WRITE (PRINTF,*)
& ' error SWPSEL, ISSTOP=', ISSTOP, 'ISCMAX=', ISCMAX(ID),
& ' for ID=', ID
ELSE
! *** no frequencies fall within the sweep ***
ISCMIN(ID) = 0
ISCMAX(ID) = 0
ENDIF
!
530 CONTINUE
!
! *** calculate the maximum number of counters in both ***
! *** directional space and frequency space ***
!
IF (IDDLOW.NE.9999) THEN
IF (IDDTOP.EQ.-9999) WRITE (PRTEST, 545) IDDLOW, IDDTOP
545 FORMAT (' error SWPSEL min & max dir ', 5I7)
IDTOT = ( IDDTOP - IDDLOW ) + 1
IF (ICUR .EQ. 1) THEN
IF (IDTOT.LT.3) THEN
IDDTOP = IDDTOP + 1
IF (IDTOT.EQ.1) IDDLOW = IDDLOW - 1
IDTOT = 3
ENDIF
ENDIF
ELSE
IF (IDDTOP.NE.-9999) WRITE (PRTEST, 545) IDDLOW, IDDTOP
IDTOT = 0
ENDIF
!
IF (ISSLOW.NE.9999) THEN
IF (ITEST.GE.20) THEN 40.13
IF (ISSLOW.NE.1 .OR. ISSTOP.EQ.-9999)
& WRITE (PRTEST, 555) IXCGRD(1)-1, IYCGRD(1)-1, ISSLOW, ISSTOP 40.13
555 FORMAT (' error SWPSEL in:', 2I5,', min & max freq ', 5I7) 40.13
ENDIF 40.13
ISSLOW = 1
! minimal value of ISSTOP is 4 (or MSC if MSC<4) 40.13
IF (ICUR.GT.0) ISSTOP = MAX(MIN(4,MSC),ISSTOP) 40.13
ISTOT = ( ISSTOP - ISSLOW ) + 1
ELSE
IF (ISSTOP.NE.-9999) WRITE (PRTEST, 555) IXCGRD(1)-1,
& IYCGRD(1)-1, ISSLOW, ISSTOP
ISTOT = 0
IF (IDTOT.NE.0) WRITE (PRTEST, 556) IXCGRD(1)-1,
& IYCGRD(1)-1, ISSLOW, ISSTOP, IDDLOW, IDDTOP 40.03
556 FORMAT (' error SWPSEL in:', 2I5,' min&max freq&dir ', 5I7) 40.03
ENDIF
!
! *** check if IDTOT is less then MDC ***
!
IF ( IDTOT .GT. MDC ) THEN
IDDLOW = 1
IDDTOP = MDC
IDTOT = MDC
END IF
!
! *** check if the lowest frequency is not blocked ! ***
! *** this can occur in real cases if the depth is very ***
! *** small and the current velocity is large ***
! *** the propagation velocity Cg = sqrt (gd) < U ***
!
IF (ICUR .EQ. 1 .AND. FULCIR .AND.
& ISSLOW.NE.1 .AND. ISSLOW.NE.9999) THEN 40.13
CALL MSGERR (2,'The lowest freqency is blocked') 40.13
WRITE (PRINTF, 612) ' at point:', IXCGRD(1)+MXF-2, 40.41
& IYCGRD(1)+MYF-2, 40.41 40.13
& ' dep=', DEP2(KCGRD(1)),
& ' U=', UX2(KCGRD(1)), UY2(KCGRD(1))
612 FORMAT (A, 2I4, A, F6.2, A, 2F6.2) 40.13
IF (ITEST.GE.10) THEN
WRITE (PRINTF, 614) ' spectral limits:', ISTOT, ISSLOW,
& ISSTOP, IDTOT, IDDLOW, IDDTOP, ' sweep=',SWPDIR
614 FORMAT (A, 6I8,A,I1)
IF (ITEST.GE.60) THEN
IF (IXCGRD(1).GT.1 .AND. IXCGRD(1).LT.MXC .AND.
& IYCGRD(1).GT.1 .AND. IYCGRD(1).LT.MYC) THEN
WRITE (PRINTF, *) ' surrounding points'
DO IY=-1,1
WRITE (PRINTF, 621)
& (KGRPNT(IXCGRD(1)+IX,IYCGRD(1)+IY), IX=-1,1),
& (DEP2(KGRPNT(IXCGRD(1)+IX,IYCGRD(1)+IY)), IX=-1,1),
& (UX2(KGRPNT(IXCGRD(1)+IX,IYCGRD(1)+IY)), IX=-1,1),
& (UY2(KGRPNT(IXCGRD(1)+IX,IYCGRD(1)+IY)), IX=-1,1) 40.13
621 FORMAT (1X, 3I6, 3(' | ', 3F9.2))
ENDDO
ENDIF
ENDIF
ENDIF
! write this point to ERRPTS file (BLOCKed option) 40.13
IF (ERRPTS.GT.0.AND.IAMMASTER) THEN 40.95 40.30
WRITE(ERRPTS,7002) IXCGRD(1)+MXF-1, IYCGRD(1)+MYF-1, 3 40.30
END IF 40.13
7002 FORMAT (I4, 1X, I4, 1X, I2) 40.13
IC = 1
GROUP = SQRT ( GRAV * DEP2(KCGRD(IC)) )
UABS = SQRT ( UX2(KCGRD(IC))**2 + UY2(KCGRD(IC))**2 )
IF ( UABS .GT. GROUP ) THEN
WRITE(PRINTF,1002) IXCGRD(IC)-1, IYCGRD(1)-1, UABS, GROUP 40.13
1002 FORMAT(' warning, at point:',2I4,' |U|=',F8.2,' > Cg=',F8.2) 40.13
ENDIF
ENDIF
!
! *** test output ***
!
IF ( TESTFL .AND. ITEST .GE. 30 ) THEN
IC = 1 40.00
WRITE (PRTEST,6020) KCGRD(IC),SWPDIR,ICUR
6020 FORMAT (' subr SWPSEL: Point SWPDIR ICUR :',3I5 ) 40.00
WRITE (PRTEST,6220) IDDLOW, IDDTOP ,ISSLOW, ISSTOP
6220 FORMAT (' IDDLOW IDDTOP ISSLOW ISSTOP:',4I4 )
WRITE (PRTEST,6320) IDTOT , ISTOT
6320 FORMAT (' IDTOT ISTOT :',4I4 )
IF (ITEST.GE.120) THEN 40.00
WRITE(PRTEST,*) ' Counters in directional space '
WRITE(PRTEST,*) ' IS IDCMIN IDCMAX SECTOR' 40.00
DO IS = ISSLOW, ISSTOP
WRITE(PRTEST,509) IS, IDCMIN(IS), IDCMAX(IS) , SECTOR(IS)
509 FORMAT(2X,I5,3X,3I8)
ENDDO
WRITE(PRTEST,*) ' Counters in frequency space '
WRITE(PRTEST,*) ' ID ISCMIN ISCMAX THETA'
DO IDDUM = IDDTOP, IDDLOW, -1
ID = MOD ( IDDUM - 1 + MDC, MDC) + 1
THDIR = SPCDIR(ID,1) * 180. / PI
WRITE(PRTEST,519) ID, ISCMIN(ID), ISCMAX(ID), THDIR
519 FORMAT(2X,I5,3X,2I8,3X,F8.2)
ENDDO
WRITE(PRTEST,*)
ENDIF 40.00
IF (IDTOT.GT.0) THEN
IF (ITEST.GE.90) THEN 40.00
WRITE(PRTEST,122) IDDLOW, IDDTOP
122 FORMAT (' Active bins in spectral space -> ID: ',
& I3,' to ',I3)
DO IDDUM = IDDTOP+1, IDDLOW-1, -1
ID = MOD ( IDDUM - 1 + MDC, MDC) + 1
WRITE(PRTEST,124)
& ID, (ANYBIN(ID,IS),IS=ISSLOW, MIN(ISSTOP,25)) 40.00
124 FORMAT(I4,25L3)
ENDDO
WRITE(PRTEST,125)(IS, IS=ISSLOW+4, MIN(ISSTOP,25), 5 )
125 FORMAT(6X,'1',9X,5(I3,12X))
WRITE(PRTEST,*)
ENDIF 40.00
ELSE
WRITE(PRTEST,123) SWPDIR
123 FORMAT (' No active bins in sweep', I2)
ENDIF
IF ( ICUR .EQ. 0 ) THEN
WRITE (PRTEST,615) IDDLOW, IDDTOP
615 FORMAT (' SWPSEL: IDDLOW IDDTOP :',5(1X,I3))
END IF
END IF
!
! End of the subroutine SWPSEL
!
RETURN
END
!
!****************************************************************
!
SUBROUTINE SPROXY (CAX ,
& CAY ,CGO ,ECOS ,
& ESIN ,UX2 ,UY2 ,
& SWPDIR
& )
!
!****************************************************************
!
USE SWCOMM3 40.41
USE SWCOMM4 40.41
USE OCPCOMM4 40.41
USE M_DIFFR 40.21
!
IMPLICIT NONE
!
!
! --|-----------------------------------------------------------|--
! | 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/>.
!
!
! 1. UPDATE
!
! 40.13, Oct. 01: loop over IC now inside this subroutine
! 40.21, Aug. 01: adaption of velocities in case of diffraction
! 40.41, Oct. 04: common blocks replaced by modules, include files removed
!
! 2. PURPOSE
!
! computes the propagation velocities of energy in X-, Y-
! -space, i.e., CAX, CAY, in the presence or absence of
! currents, for the action balance equation.
!
! The propagation velocities are computed for the fully 360
! degrees sector.
!
! 3. METHOD
!
! The next equation are calculated:
!
! @X _
! CAX = -- = n C cos (id) + Ux = CGO cos(id) + Ux
! @T
!
! @Y _
! CAY = -- = n C sin(id) + Uy = CGO sin(id) + Uy
! @T
! _
! 4. PARAMETERLIST
!
! IC Dummy variable: ICode gridpoint:
! IC = 1 Top or Bottom gridpoint
! IC = 2 Left or Right gridpoint
! IC = 3 Central gridpoint
! Whether which value IC has, depends of the sweep
! If necessary ic can be enlarged by increasing
! the array size of ICMAX
! IX Counter of gridpoints in x-direction
! IY Counter of gridpoints in y-direction
! IS Counter of relative frequency band
! ID Counter of directional distribution
! ICUR Indicator for current
! ICMAX Maximum array size for the points of the molecule
! MXC Maximum counter of gridppoints in x-direction
! MYC Maximum counter of gridppoints in y-direction
! MSC Maximum counter of relative frequency
! MDC Maximum counter of spectral directions
!
! REAL:
! ----
! COEF auxiliary coefficient
! VLSINH value of the SINH for a certain value of 2KD
!
!
! one and more dimensional arrays:
! ---------------------------------
!
! CAX 3D Wave transport velocity in x-dirction, function of
! (ID,IS,IC)
! CAY 3D Wave transport velocity in y-dirction, function of
! (ID,IS,IC)
! CGO 2D group velocity
! DEP2 2D (Nonstationary case) depth as function of X and Y
! at time T+DIT
! ECOS 1D Represent the values of cos(d) of each spectral
! direction
! ESIN 1D Represent the values of sin(d) of each spectral
! direction
! KWAVE 2D wavenumber as function of the relative frequency S
! UX2 2D X-component of current velocity of X and Y at
! time T+1
! UY2 2D Y-component of current velocity of X and Y at
! time T+1
!
! 5. SUBROUTINES CALLING
!
! ---
!
! 6. SUBROUTINES USED
!
! ---
!
! 7. Common blocks used
!
!
! 8. REMARKS
!
! 9. STRUCTURE
!
! ******************************************************************
! * attention! in the action balance equation the term *
! * dx *
! * -- = CGO + U = CX with x, CGO, U and CX vectors *
! * dt *
! * is in the literature the term dx/dt often indicated *
! * with CX and CY in the action balance equation. *
! * In this program we use: CAX = CGO + U *
! ******************************************************************
!
! ------------------------------------------------------------
! If depth is negative ( DEP(IX,IY) <= 0), then,
! For every point in S and D-direction do,
! Give propagation velocities default values :
! CAX(ID,IS,IC) = 0. {propagation velocity of energy in X-dir.}
! CAY(ID,IS,IC) = 0. {propagation velocity of energy in Y-dir.}
! ---------------------------------------------------------
! Else if current is on (ICUR > 0) then,