-
Notifications
You must be signed in to change notification settings - Fork 0
/
w3profsmd_pdlib.ftn
7027 lines (6915 loc) · 260 KB
/
w3profsmd_pdlib.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
#include "w3macros.h"
!/
!/ ------------------------------------------------------------------- /
MODULE PDLIB_W3PROFSMD
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 95 |
!/ | Last update : 1-June-2018 |
!/ +-----------------------------------+
!/
!/ 01-June-2016 : Origination ( version 6.04 )
!/
! 1. Purpose : PDLIB version of UGTYPE including fully implicit
! discretization. This works is based on the thesis
! of Roland, 2008 and represents the continues
! development of the solution of the WAE on unstructured
! grids. Following the quest since one decade we
! continuesly improve the aplicability and robustness of
! the source code and the methods. The development and
! implementation of the involved schemes was funded over
! the past decade by IFREMER, SHOM, USACE, NCEP/NOAA,
! BGS IT&E GmbH, Zanke & Partner and Roland & Partner.
! The PDLIB (Parallel Decomposition Library) library,
! which is used here is courtesy to BGS IT&E GmbH and
! has it's own license, which is the same as WW3. As of
! the origin of the methods, ideas and source code. This
! code was 1st developed in the WWM-III (Roland, 2008) and
! the ported to WW3. This is true for all source code
! related to UGTYPE.
!
!
! 2. Method : We apply here the framework of Residual Distributions
! schemes for hyperbolic problems for nonlinear propagation
! laws based on the work of Richiuotto et al. 2005.
! We supply the N-scheme, PSI-scheme and Lax-FCT-scheme
! as explicit methods ranging from 1st order time space
! to most optimal PSI method up to 2nd order Lax-FCT-scheme.
! For the implicit implementation we used up to now ONLY
! the N-Scheme. Higher order schemes are up to now rather
! a research feature than for practical application. The
! reason is given in Cavalleri et al. 2018, we do not
! resolve enough physics in order to be able to run
! 2nd or even higher order schemes.
! Use the numerical schemes with the needed care and
! do proper convergence analysis on the time step and
! grid size as well as solver threshold depedency.
! Think about the time and spatial scales of your
! u r intending to resolve! Multiscale modelling needs
! much work on the side of the modeler and much more
! time for the grid generation and the validation of the
! final model
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks
! 8. Structure :
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
!/S INTEGER, SAVE :: IENT = 0
!/
!/ ------------------------------------------------------------------- /
!/
!/ ------------------------------------------------------------------- /
!/
PUBLIC
!/
!/ Public variables
!/
LOGICAL :: MAPSTA_HACK = .FALSE.
REAL, ALLOCATABLE :: ASPAR_JAC(:,:), ASPAR_DIAG_SOURCES(:,:)
REAL, ALLOCATABLE :: B_JAC(:,:), CAD_THE(:,:), CAS_SIG(:,:)
REAL, ALLOCATABLE :: CWNB_SIG_M2(:,:)
REAL, ALLOCATABLE :: U_JAC(:,:)
REAL, ALLOCATABLE :: COFRM4(:)
INTEGER, ALLOCATABLE :: IS0_pdlib(:)
INTEGER :: FreqShiftMethod = 2
LOGICAL :: FSGEOADVECT
!/DEBUGSRC INTEGER :: TESTNODE = 1
!
!/ ------------------------------------------------------------------- /
!
CONTAINS
!
!/ ------------------------------------------------------------------- /
!
SUBROUTINE VA_SETUP_IOBPD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 01-Mai-2018 |
!/ +-----------------------------------+
!/
!/ 01-Mai-2018 : Origination. ( version 6.04 )
!/
! 1. Purpose : Setup boundary pointer
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks
! 8. Structure :
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
!
USE W3GDATMD, ONLY: IOBPD, GTYPE, UNGTYPE
USE W3GDATMD, ONLY: NSPEC, NTH, NSEAL
USE W3WDATMD, ONLY: VA
USE YOWNODEPOOL, ONLY: iplg
!/
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
!/S INTEGER, SAVE :: IENT = 0
!/
!/ ------------------------------------------------------------------- /
!/
!
INTEGER JSEA, IP, IP_glob, ITH, ISP
!/S CALL STRACE (IENT, 'VA_SETUP_IOBPD')
IF (GTYPE .eq. UNGTYPE) THEN
DO JSEA=1,NSEAL
IP = JSEA
IP_glob = iplg(IP)
DO ISP=1,NSPEC
ITH = 1 + MOD(ISP-1,NTH)
VA(ISP,JSEA) = VA(ISP,JSEA)*IOBPD(ITH,IP_glob)
END DO
END DO
END IF
END SUBROUTINE
!/ ------------------------------------------------------------------- /
SUBROUTINE PDLIB_STYLE_INIT(IMOD)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 01-June-2018 |
!/ +-----------------------------------+
!/
!/ 01-June-2018 : Origination. ( version 6.04 )
!/
! 1. Purpose : Init pdlib part
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks
! 8. Structure :
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
!
USE W3GDATMD, ONLY: FLCX, FLCY
USE CONSTANTS, ONLY : GRAV, TPI
USE W3GDATMD, ONLY: XYB, XGRD, YGRD, NX, NSEA, NTRI, TRIGP, NSPEC
USE W3GDATMD, ONLY: MAPSTA, MAPFS, GRIDS, NTH
USE W3GDATMD, ONLY: IOBP, IOBPD, IOBP_loc, IOBPD_loc, SIG, NK
USE W3GDATMD, ONLY: TRIA, IEN, LEN, ANGLE, ANGLE0
USE W3GDATMD, ONLY: CCON, COUNTCON, INDEX_CELL, IE_CELL
USE W3GDATMD, ONLY: POS_CELL, SI, IAA, JAA, POSI, I_DIAG, JA_IE
USE W3ADATMD, ONLY: MPI_COMM_WCMP, MPI_COMM_WAVE
USE W3ODATMD, ONLY: IAPROC, NAPROC, NTPROC
USE yowDatapool, ONLY: istatus
USE yowpdlibMain, ONLY: initFromGridDim
USE YOWNODEPOOL, ONLY: npa, iplg
USE W3PARALL, ONLY : PDLIB_NSEAL, PDLIB_NSEALM
USE W3PARALL, ONLY : JX_TO_JSEA, ISEA_TO_JSEA
USE yowfunction, ONLY : ComputeListNP_ListNPA_ListIPLG, pdlib_abort
!/
IMPLICIT NONE
INCLUDE "mpif.h"
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
!/S INTEGER, SAVE :: IENT = 0
!/
!/ ------------------------------------------------------------------- /
!/
!! INCLUDE "mpif.h"
REAL, ALLOCATABLE :: XP_IN(:), YP_IN(:), DEP_IN(:)
INTEGER, ALLOCATABLE :: INE_IN(:,:)
INTEGER :: istat
INTEGER :: I, J, IBND_MAP, ISEA, IP, IX, JSEA, nb
INTEGER :: IP_glob
INTEGER :: myrank, ierr, iproc
INTEGER, ALLOCATABLE :: NSEAL_arr(:)
INTEGER :: IERR_MPI
INTEGER :: IScal(1)
INTEGER, INTENT(in) :: IMOD
INTEGER :: IK, ISP
INTEGER IK0, ISP0, ITH
REAL :: eSIG, eFR
REAL, PARAMETER :: COEF4 = 5.0E-7
!/S CALL STRACE (IENT, 'PDLIB_STYLE_INIT')
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_STYLE_INIT, IMOD (no print)'
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'NAPROC=', NAPROC
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'NTPROC=', NTPROC
!/DEBUGSOLVER FLUSH(740+IAPROC)
PDLIB_NSEAL=0
IF (IAPROC .le. NAPROC) THEN
ALLOCATE(XP_IN(NX), YP_IN(NX), DEP_IN(NX), stat=istat)
if(istat /= 0) CALL PDLIB_ABORT(1)
DO I=1,NX
XP_IN(I)=XYB(I,1)
YP_IN(I)=XYB(I,2)
DEP_IN(I)=XYB(I,3)
END DO
ALLOCATE(INE_IN(3,NTRI), stat=istat)
if(istat /= 0) CALL PDLIB_ABORT(2)
DO I=1,NTRI
DO J=1,3
INE_IN(J,I)=TRIGP(I,J)
END DO
END DO
CALL MPI_COMM_RANK(MPI_COMM_WCMP, myrank, ierr)
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_STYLE_INIT, IAPROC=', IAPROC
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_STYLE_INIT, NAPROC=', NAPROC
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_STYLE_INIT, myrank=', myrank
!/DEBUGSOLVER FLUSH(740+IAPROC)
!
CALL initFromGridDim(NX,XP_IN,YP_IN,DEP_IN,NTRI,INE_IN,NSPEC,0,MPI_COMM_WCMP)
!
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'After initFromGridDim'
!/DEBUGSOLVER FLUSH(740+IAPROC)
DEALLOCATE(XP_IN, YP_IN, DEP_IN, INE_IN)
!
! Now the computation of NSEAL
!
DO IP = 1, npa
IX = iplg(IP)
ISEA = MAPFS(1,IX)
IF (ISEA .gt. 0) PDLIB_NSEAL = PDLIB_NSEAL + 1
END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'npa is augmented domain over NX'
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_NSEAL is basicall npa but ONLY over the wet points'
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'NSEAL is set to PDLIB_NSEAL'
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_NSEAL=', PDLIB_NSEAL
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'npa=', npa
!/DEBUGSOLVER FLUSH(740+IAPROC)
ALLOCATE(JX_TO_JSEA(npa), ISEA_TO_JSEA(NSEA), stat=istat)
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'ISEA_TO_JSEA ALLOCATEd'
!/DEBUGSOLVER FLUSH(740+IAPROC)
if(istat /= 0) CALL PDLIB_ABORT(3)
JSEA = 0
JX_TO_JSEA = 0
ISEA_TO_JSEA = 0
DO IP = 1, npa
IX = iplg(IP)
ISEA = MAPFS(1,IX)
IF (ISEA .gt. 0) THEN
JSEA=JSEA+1
JX_TO_JSEA(IP)=JSEA
ISEA_TO_JSEA(ISEA)=JSEA
END IF
END DO
!
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'After JX_TO_JSEA, ISEA_TO_JSEA and friend computation'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!
! Map a point in (1:PDLIB_NSEAL) to a point in (1:NSEA)
!
nb=0
DO IX=1,NX
IF (MAPFS(1,IX) .gt. 0) nb = nb + 1
END DO
IF (nb .ne. NSEA) THEN
WRITE(*,*) 'Logical error in computation of NSEA / nb'
WRITE(*,*) 'nb=', nb, ' NSEA=', NSEA
STOP
END IF
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'nb / NSEA consistency check'
!/DEBUGSOLVER FLUSH(740+IAPROC)
END IF
FSGEOADVECT=.FALSE.
IF ((FLCX .eqv. .TRUE.).and.(FLCY .eqv. .TRUE.)) THEN
FSGEOADVECT=.TRUE.
END IF
!
! Compute NSEALM
!
IF (IAPROC .le. NAPROC) THEN
IF (IAPROC .eq. 1) THEN
ALLOCATE(NSEAL_arr(NAPROC))
NSEAL_arr(1)=PDLIB_NSEAL
DO IPROC=2,NAPROC
CALL MPI_RECV(IScal,1,MPI_INT, IPROC-1, 23, MPI_COMM_WAVE, istatus, IERR_MPI)
NSEAL_arr(IPROC)=IScal(1)
END DO
PDLIB_NSEALM=maxval(NSEAL_arr)
deALLOCATE(NSEAL_arr)
ELSE
IScal(1)=PDLIB_NSEAL
CALL MPI_SEND(IScal,1,MPI_INT, 0, 23, MPI_COMM_WAVE, IERR_MPI)
END IF
END IF
!
IF (IAPROC .eq. 1) THEN
IScal(1)=PDLIB_NSEALM
DO IPROC = 2 , NTPROC
CALL MPI_SEND(IScal,1,MPI_INT, IPROC-1, 24, MPI_COMM_WAVE, IERR_MPI)
END DO
ELSE
CALL MPI_RECV(IScal,1,MPI_INT, 0, 24, MPI_COMM_WAVE, istatus, IERR_MPI)
PDLIB_NSEALM=IScal(1)
END IF
!
WRITE(*,'(A40,3I20)') 'IAPROC, PDLIB_NSEAL, PDLIB_NSEALM', IAPROC, PDLIB_NSEAL, PDLIB_NSEALM
!
! Computation of IOBP_loc, IOBPD_loc
!
ALLOCATE(GRIDS(IMOD)%IOBP_loc(npa), GRIDS(IMOD)%IOBPD_loc(NTH,npa), stat=istat)
if(istat /= 0) CALL PDLIB_ABORT(4)
DO IP=1,npa
IP_glob=iplg(IP)
GRIDS(IMOD)%IOBP_loc(IP) = IOBP(IP_glob)
GRIDS(IMOD)%IOBPD_loc(:,IP) = IOBPD(:,IP_glob)
END DO
!/DEBUGINIT WRITE(740+IAPROC,*) 'ALLOCATEd(ISEA_TO_JSEA)=', allocated(ISEA_TO_JSEA)
!/DEBUGINIT WRITE(740+IAPROC,*) 'PDLIB_NSEALM=', PDLIB_NSEALM
!/DEBUGINIT FLUSH(740+IAPROC)
! WRITE(*,*) 'Begin, ComputeListNP_ListNPA_ListIPLG'
CALL ComputeListNP_ListNPA_ListIPLG
ALLOCATE(COFRM4(NK))
DO IK=1,NK
eSIG=SIG(IK)
eFR=eSIG/TPI
COFRM4(IK)=COEF4*GRAV/(eFR**4)
END DO
ALLOCATE(IS0_pdlib(NSPEC))
DO ISP=1, NSPEC
IS0_pdlib(ISP) = ISP - 1
END DO
DO ISP=1, NSPEC, NTH
IS0_pdlib(ISP) = IS0_pdlib(ISP) + NTH
END DO
!
! DEALLOCATE USELESS STUFF
!
DEALLOCATE(LEN, ANGLE, ANGLE0, TRIA)
DEALLOCATE(CCON, COUNTCON, INDEX_CELL, IE_CELL)
DEALLOCATE(POS_CELL, SI, IAA, JAA, POSI, I_DIAG, JA_IE)
!/
!/ End of PDLIB_STYLE_INIT ------------------------------------------- /
!/
END SUBROUTINE PDLIB_STYLE_INIT
!/ ------------------------------------------------------------------- /
SUBROUTINE PDLIB_MAPSTA_INIT(IMOD)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 01-June-2018 |
!/ +-----------------------------------+
!/
!/ 01-June-2018 : Origination. ( version 6.04 )
!/
! 1. Purpose : Init mapsta part for pdlib
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks
! 8. Structure :
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
!
USE W3GDATMD, ONLY : INDEX_MAP, NBND_MAP, NSEA, NSEAL, MAPSTA, GRIDS, NX
USE W3ODATMD, ONLY : IAPROC, NAPROC
USE YOWNODEPOOL, ONLY: iplg, npa
USE yowfunction, ONLY: pdlib_abort
USE W3ODATMD, ONLY: IAPROC
!/
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
!/S INTEGER, SAVE :: IENT = 0
!/
!/ ------------------------------------------------------------------- /
!/
INTEGER :: IBND_MAP, ISEA, JSEA, IX, IP, IP_glob
INTEGER, INTENT(in) :: IMOD
INTEGER :: Status(NX), istat
!/S CALL STRACE (IENT, 'PDLIB_MAPSTA_INIT')
!/DEBUGINIT WRITE(*,*) 'Passing by PDLIB_MAPSTA_INIT IAPROC=', IAPROC
IF (IAPROC .gt. NAPROC) THEN
RETURN
END IF
ALLOCATE(GRIDS(IMOD)%MAPSTA_LOC(npa), stat=istat)
if(istat /= 0) CALL PDLIB_ABORT(5)
Status=0
DO IP=1,npa
IP_glob=iplg(IP)
Status(IP_glob)=IP
GRIDS(IMOD)%MAPSTA_LOC(IP)=MAPSTA(1,IP_glob)
END DO
NBND_MAP=0
DO IX=1,NX
IF ((MAPSTA(1,IX) .lt. 1).and.(Status(IX).gt.0)) THEN
NBND_MAP = NBND_MAP + 1
END IF
END DO
ALLOCATE(GRIDS(IMOD)%INDEX_MAP(NBND_MAP), stat=istat)
if(istat /= 0) CALL PDLIB_ABORT(6)
IBND_MAP=0
DO IX=1,NX
IF ((MAPSTA(1,IX) .lt. 1).and.(Status(IX).gt.0)) THEN
IBND_MAP = IBND_MAP + 1
GRIDS(IMOD)%INDEX_MAP(IBND_MAP) = Status(IX)
END IF
END DO
!/
!/ End of W3SPR4 ----------------------------------------------------- /
!/
END SUBROUTINE
!/ ------------------------------------------------------------------- /
SUBROUTINE PDLIB_W3XYPUG ( ISP, FACX, FACY, DTG, VGX, VGY, LCALC )
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 10-Jan-2011 |
!/ +-----------------------------------+
!/
!/ 10-Jan-2008 : Origination. ( version 3.13 )
!/ 10-Jan-2011 : Addition of implicit scheme ( version 3.14.4 )
!/ 06-Feb-2014 : PDLIB parallelization
!/
! 1. Purpose : Explicit advection schemes driver
!
! Propagation in physical space for a given spectral component.
! Gives the choice of scheme on unstructured grid
! Use the geographical parall algorithms for further speed.
!
! 2. Method :
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! Local variables.
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! 5. Called by :
!
! W3WAVE Wave model routine.
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
! make the interface between the WAVEWATCH and the WWM code.
!
! 8. Structure :
!
!
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
!
! 10. Source code :
!/ ------------------------------------------------------------------- /
!/
!
USE CONSTANTS
!
USE W3TIMEMD, ONLY: DSEC21
!
USE W3GDATMD, ONLY: NX, NY, MAPFS, CLATS, &
FLCX, FLCY, NK, NTH, DTH, XFR, &
ECOS, ESIN, SIG, PFMOVE, &
IOBP, IOBPD, &
FSN, FSPSI, FSFCT, FSNIMP, &
GTYPE, UNGTYPE, NBND_MAP, INDEX_MAP
USE YOWNODEPOOL, ONLY: PDLIB_IEN, PDLIB_TRIA
USE YOWNODEPOOL, ONLY: iplg, npa
USE W3WDATMD, ONLY: TIME, VA
USE W3ODATMD, ONLY: TBPI0, TBPIN, FLBPI
USE W3ADATMD, ONLY: CG, CX, CY, ITIME
USE W3IDATMD, ONLY: FLCUR
USE W3GDATMD, ONLY: NSEAL
USE W3ODATMD, ONLY: IAPROC
IMPLICIT NONE
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: ISP
REAL, INTENT(IN) :: FACX, FACY, DTG, VGX, VGY
LOGICAL, INTENT(IN) :: LCALC
LOGICAL :: SCHEME
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
INTEGER :: ITH, IK, ISEA
INTEGER :: I, J, IE, IBND_MAP
INTEGER :: IP_glob
REAL :: CCOS, CSIN, CCURX, CCURY
REAL :: C(npa,2)
REAL :: RD1, RD2
!/
!/ Automatic work arrays
!/
REAL :: VLCFLX(npa), VLCFLY(npa)
REAL :: AC(npa)
REAL :: AC_MAP(NBND_MAP)
INTEGER :: JSEA, IP
!/ ------------------------------------------------------------------- /
!
! 1. Preparations --------------------------------------------------- *
! 1.a Set constants
!
!/S CALL STRACE (IENT, 'W3XYPUG')
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'Begin of PDLIB_W3XYPUG'
!/DEBUGSOLVER FLUSH(740+IAPROC)
ITH = 1 + MOD(ISP-1,NTH)
IK = 1 + (ISP-1)/NTH
CCOS = FACX * ECOS(ITH)
CSIN = FACY * ESIN(ITH)
CCURX = FACX
CCURY = FACY
!
! 1.b Initialize arrays
!
VLCFLX = 0.
VLCFLY = 0.
AC = 0.
CALL SETDEPTH_PDLIB
!
! 2. Calculate velocities ---------------- *
!
DO JSEA = 1, NSEAL
IP = JSEA
IP_glob = iplg(IP)
ISEA = MAPFS(1,IP_glob)
!write(*,*) 'IP TEST', JSEA, ISEA, IP, IP_glob
AC(IP) = VA(ISP,JSEA) / CG(IK,ISEA) * CLATS(ISEA)
VLCFLX(IP) = CCOS * CG(IK,ISEA) / CLATS(ISEA)
VLCFLY(IP) = CSIN * CG(IK,ISEA)
!/MGP VLCFLX(IP) = VLCFLX(IP) - CCURX*VGX/CLATS(ISEA)
!/MGP VLCFLY(IP) = VLCFLY(IP) - CCURY*VGY
END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'ISP=', ISP, ' ITH=', ITH, ' IK=', IK
!/DEBUGSOLVER WRITE(740+IAPROC,*) '1: maxval(VLCFLX)=', maxval(VLCFLX)
!/DEBUGSOLVER WRITE(740+IAPROC,*) '1: maxval(VLCFLY)=', maxval(VLCFLY)
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'FLCUR=', FLCUR
!/DEBUGSOLVER FLUSH(740+IAPROC)
IF ( FLCUR ) THEN
DO JSEA=1, NSEAL
IP = JSEA
IP_glob = iplg(IP)
ISEA = MAPFS(1,IP_glob)
!
! Currents are not included on coastal boundaries (COUNTSEACON(IXY) .NE. PDLIB_CCON(IXY))
!
IF (IOBP(IP_glob) .GT. 0) THEN
VLCFLX(IP) = VLCFLX(IP) + CCURX*CX(ISEA)/CLATS(ISEA)
VLCFLY(IP) = VLCFLY(IP) + CCURY*CY(ISEA)
END IF
END DO
END IF
C(:,1) = VLCFLX(:)
C(:,2) = VLCFLY(:)
!!/DEBUGSOLVER WRITE(740+IAPROC,*) 'CCURXY=', CCURX, CCURY
!!/DEBUGSOLVER WRITE(740+IAPROC,*) 'max(CX)=', maxval(CX)
!!/DEBUGSOLVER WRITE(740+IAPROC,*) 'max(CY)=', maxval(CY)
!!/DEBUGSOLVER WRITE(740+IAPROC,*) 'min(CLATS)=', minval(CLATS)
!!/DEBUGSOLVER WRITE(740+IAPROC,*) '2: maxval(VLCFLX)=', maxval(VLCFLX)
!!/DEBUGSOLVER WRITE(740+IAPROC,*) '2: maxval(VLCFLY)=', maxval(VLCFLY)
!!/DEBUGSOLVER FLUSH(740+IAPROC)
!
! 4. Prepares boundary update
!
IF ( FLBPI ) THEN
RD1 = DSEC21 ( TBPI0, TIME )
RD2 = DSEC21 ( TBPI0, TBPIN )
ELSE
RD1=1.
RD2=0.
END IF
!
! Saving data for MAPSTA business
!
IF (MAPSTA_HACK) THEN
DO IBND_MAP=1,NBND_MAP
IP=INDEX_MAP(IBND_MAP)
AC_MAP(IBND_MAP) = AC(IP)
END DO
END IF
!
! 4. propagate using the selected scheme
!
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'maxval(C)=', maxval(C)
!/DEBUGSOLVER FLUSH(740+IAPROC)
IF (FSN) THEN
CALL PDLIB_W3XYPFSN2(ISP, C, LCALC, RD1, RD2, DTG, AC)
ELSE IF (FSPSI) THEN
CALL PDLIB_W3XYPFSPSI2(ISP, C, LCALC, RD1, RD2, DTG, AC)
ELSE IF (FSFCT) THEN
CALL PDLIB_W3XYPFSFCT2(ISP, C, LCALC, RD1, RD2, DTG, AC)
ELSE IF (FSNIMP) THEN
STOP 'For PDLIB and FSNIMP, no function has been programmed yet'
ENDIF
!
IF (MAPSTA_HACK) THEN
DO IBND_MAP=1,NBND_MAP
IP=INDEX_MAP(IBND_MAP)
AC(IP) = AC_MAP(IBND_MAP)
END DO
END IF
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'After solutioning'
!/DEBUGSOLVER FLUSH(740+IAPROC)
! 6. Store results in VQ in proper format --------------------------- *
!
!/C90/!DIR$ IVDEP
!
DO JSEA=1, NSEAL
IP = JSEA
IP_glob = iplg(IP)
ISEA=MAPFS(1,IP_glob)
VA(ISP,JSEA) = MAX ( 0. , CG(IK,ISEA)/CLATS(ISEA)*AC(IP) )
END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'Leaving PDLIB_W3XYPUG'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!/
!/ End of W3SPR4 ----------------------------------------------------- /
!/
END SUBROUTINE
!/ ------------------------------------------------------------------- /
SUBROUTINE PDLIB_W3XYPFSN2(ISP, C, LCALC, RD10, RD20, DT, AC)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 01-June-2018 |
!/ +-----------------------------------+
!/
!/ 01-June-2018 : Origination. ( version 6.04 )
!/
! 1. Purpose : Explicit N-Scheme
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD Subroutine tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks
! 8. Structure :
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
!
USE W3GDATMD, ONLY : NK, NTH, NX, &
IEN, CLATS, MAPSF, IOBPD, IOBP, IOBDP, IOBPA
USE W3WDATMD, ONLY: TIME
USE W3ADATMD, ONLY: CG, ITER, DW , CFLXYMAX, NSEALM
USE W3ODATMD, ONLY: NDSE, NDST, FLBPI, NBI, TBPIN, ISBPI, BBPI0, BBPIN
USE W3TIMEMD, ONLY: DSEC21
USE W3ADATMD, ONLY: MPI_COMM_WCMP
USE W3GDATMD, ONLY: NSEAL, DMIN, NSEA
!/REF1 USE W3GDATMD, ONLY: REFPARS
USE YOWNODEPOOL, ONLY: PDLIB_SI, PDLIB_IEN, PDLIB_TRIA, ipgl, iplg, npa, np
use yowElementpool, ONLY: ne, INE
use yowDatapool, ONLY: rtype
use yowExchangeModule, ONLY : PDLIB_exchange1DREAL
USE W3ODATMD, ONLY : IAPROC
USE MPI, ONLY : MPI_MIN
USE W3PARALL, ONLY : INIT_GET_JSEA_ISPROC
USE W3PARALL, ONLY : ONESIXTH, ZERO, THR
USE yowRankModule, ONLY : IPGL_npa
IMPLICIT NONE
INTEGER, INTENT(IN) :: ISP ! Actual Frequency/Wavenumber,
! actual Wave Direction
REAL, INTENT(IN) :: DT ! Time intervall for which the
! advection should be computed
! for the given velocity field
REAL, INTENT(IN) :: C(npa,2) ! Velocity field in it's
! X- and Y- Components,
REAL, INTENT(INOUT) :: AC(npa) ! Wave Action before and
! after advection
REAL, INTENT(IN) :: RD10, RD20 ! Time interpolation
! coefficients for boundary
! conditions
LOGICAL, INTENT(IN) :: LCALC ! Switch for the calculation of
! the max. Global Time step
!/S INTEGER, SAVE :: IENT = 0
!/REF1 INTEGER(KIND=1) :: IOBPDR(NX)
INTEGER :: IP, IE, POS, IT, I1, I2, I3, I, J, ITH, IK
INTEGER :: IBI, NI(3)
INTEGER :: JX
!
! local REAL
!
REAL :: RD1, RD2
!:
! local double
!
REAL :: UTILDE
REAL :: SUMTHETA
REAL :: FT, CFLXY
REAL :: FL11, FL12, FL21, FL22, FL31, FL32
REAL :: FL111, FL112, FL211, FL212, FL311, FL312
REAL :: DTSI(npa), U(npa)
REAL :: DTMAX_GL, DTMAX, DTMAXEXP, REST
REAL :: LAMBDA(2), KTMP(3)
REAL :: KELEM(3,NE), FLALL(3,NE)
REAL :: KKSUM(npa), ST(npa)
REAL :: NM(NE)
INTEGER :: ISPROC, JSEA, IP_glob, ierr, IX
REAL :: eSumAC, sumAC, sumBPI0, sumBPIN, sumCG, sumCLATS
LOGICAL :: testWrite
REAL :: FIN(1), FOUT(1)
!/S CALL STRACE (IENT, 'W3XYPFSN')
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 1'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!/DEBUGSOLVER CALL GET_SCAL_INTEGRAL_COH_R4(AC, eSumAC)
!/DEBUGSOLVER testWrite=.FALSE.
!/DEBUGSOLVER IF (eSumAC .gt. 0) THEN
!/DEBUGSOLVER testWrite=.TRUE.
!/DEBUGSOLVER END IF
!/DEBUGSOLVER IF (testWrite) THEN
!/DEBUGSOLVER CALL SCAL_INTEGRAL_PRINT_R4(AC, "AC in input")
!/DEBUGSOLVER END IF
ITH = 1 + MOD(ISP-1,NTH)
IK = 1 + (ISP-1)/NTH
DTMAX = DBLE(10.E10)
! DO IP = 1, npa
! IP_glob = iplg(IP)
! IF (IOBPD(ITH,IP_glob) .EQ. 0) THEN
! if ( AC(IP) .gt. 0.) write(*,*) 'TEST w3profs_pdlib 0', ip, ith, ik, AC(IP)
! endif
! END DO
!
!/REF1 IOBPDR(:)=(1-IOBP(:))*(1-IOBPD(ITH,:))
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'NX=', NX
!/DEBUGSOLVER DO IX=1,NX
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'IX/IOBP=', IX, IOBP(IX)
!/DEBUGSOLVER END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'sum(IOBP)=', sum(IOBP)
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 2'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!
!2 Propagation
!2.a Calculate K-Values and contour based quantities ...
!
DO IE = 1, ne
I1 = INE(1,IE)
I2 = INE(2,IE)
I3 = INE(3,IE)
LAMBDA(1) = ONESIXTH *(C(I1,1)+C(I2,1)+C(I3,1)) ! Linearized advection speed in X and Y direction
LAMBDA(2) = ONESIXTH *(C(I1,2)+C(I2,2)+C(I3,2))
KELEM(1,IE) = LAMBDA(1) * PDLIB_IEN(1,IE) + LAMBDA(2) * PDLIB_IEN(2,IE) ! K-Values - so called Flux Jacobians
KELEM(2,IE) = LAMBDA(1) * PDLIB_IEN(3,IE) + LAMBDA(2) * PDLIB_IEN(4,IE)
KELEM(3,IE) = LAMBDA(1) * PDLIB_IEN(5,IE) + LAMBDA(2) * PDLIB_IEN(6,IE)
KTMP = KELEM(:,IE) ! Copy
NM(IE) = - 1.D0/MIN(-THR,SUM(MIN(ZERO,KTMP))) ! N-Values
KELEM(:,IE) = MAX(ZERO,KTMP)
FL11 = C(I2,1) * PDLIB_IEN(1,IE) + C(I2,2) * PDLIB_IEN(2,IE) ! Weights for Simpson Integration
FL12 = C(I3,1) * PDLIB_IEN(1,IE) + C(I3,2) * PDLIB_IEN(2,IE)
FL21 = C(I3,1) * PDLIB_IEN(3,IE) + C(I3,2) * PDLIB_IEN(4,IE)
FL22 = C(I1,1) * PDLIB_IEN(3,IE) + C(I1,2) * PDLIB_IEN(4,IE)
FL31 = C(I1,1) * PDLIB_IEN(5,IE) + C(I1,2) * PDLIB_IEN(6,IE)
FL32 = C(I2,1) * PDLIB_IEN(5,IE) + C(I2,2) * PDLIB_IEN(6,IE)
FL111 = 2.d0*FL11+FL12
FL112 = 2.d0*FL12+FL11
FL211 = 2.d0*FL21+FL22
FL212 = 2.d0*FL22+FL21
FL311 = 2.d0*FL31+FL32
FL312 = 2.d0*FL32+FL31
FLALL(1,IE) = (FL311 + FL212) * ONESIXTH + KELEM(1,IE)
FLALL(2,IE) = (FL111 + FL312) * ONESIXTH + KELEM(2,IE)
FLALL(3,IE) = (FL211 + FL112) * ONESIXTH + KELEM(3,IE)
END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 3'
!/DEBUGSOLVER FLUSH(740+IAPROC)
IF (LCALC) THEN
KKSUM = ZERO
DO IE = 1, NE
NI = INE(:,IE)
KKSUM(NI) = KKSUM(NI) + KELEM(:,IE)
END DO
DO IP = 1, npa
IP_glob=iplg(IP)
DTMAXEXP = PDLIB_SI(IP)/MAX(DBLE(10.E-10),KKSUM(IP)*IOBDP(IP))
DTMAX = MIN( DTMAX, DTMAXEXP)
CFLXYMAX(IP) = MAX(CFLXYMAX(IP),DBLE(DT)/DTMAXEXP)
END DO
FIN(1)=DTMAX
CALL MPI_ALLREDUCE(FIN,FOUT,1,rtype,MPI_MIN,MPI_COMM_WCMP,ierr)
DTMAX_GL=FOUT(1)
CFLXY = DBLE(DT)/DTMAX_GL
REST = ABS(MOD(CFLXY,1.0d0))
IF (REST .LT. THR) THEN
ITER(IK,ITH) = ABS(NINT(CFLXY))
ELSE IF (REST .GT. THR .AND. REST .LT. 0.5d0) THEN
ITER(IK,ITH) = ABS(NINT(CFLXY)) + 1
ELSE
ITER(IK,ITH) = ABS(NINT(CFLXY))
END IF
END IF ! LCALC
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 4'
!/DEBUGSOLVER FLUSH(740+IAPROC)
DO IP = 1, npa
DTSI(IP) = DBLE(DT)/DBLE(ITER(IK,ITH))/PDLIB_SI(IP) ! Some precalculations for the time integration.
END DO
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 4.1'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!!/DEBUGSOLVER CALL SCAL_INTEGRAL_PRINT_R8(PDLIB_SI, "PDLIB_SI in input")
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 4.2'
!/DEBUGSOLVER FLUSH(740+IAPROC)
!!/DEBUGSOLVER CALL SCAL_INTEGRAL_PRINT_R8(DTSI, "DTSI in input")
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'PDLIB_W3XYPFSN2, step 5'
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'IK=', IK, ' ITH=', ITH
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'ITER=', ITER(IK,ITH)
!/DEBUGSOLVER FLUSH(740+IAPROC)
DO IT = 1, ITER(IK,ITH)
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'IK=', IK, ' ITH=', ITH
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'IT=', IT, ' ITER=', ITER(IK,ITH)
!/DEBUGSOLVER FLUSH(740+IAPROC)
!/DEBUGSOLVER IF (testWrite) THEN
!/DEBUGSOLVER WRITE(740+IAPROC,*) 'IT=', IT
!/DEBUGSOLVER FLUSH(740+IAPROC)
!/DEBUGSOLVER END IF
U = DBLE(AC)
ST = ZERO
DO IE = 1, NE