-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3triamd.ftn
executable file
·2725 lines (2591 loc) · 86.1 KB
/
w3triamd.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 W3TRIAMD
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | F. Ardhuin and A. Roland |
!/ | FORTRAN 90 |
!/ | Last update : 26-Jan-2014|
!/ +-----------------------------------+
!/
!/ 15-Mar-2007 : Origination. ( version 3.13 )
!/ 25-Aug-2011 : Modification of boundary treatment ( version 4.04 )
!/ 30-Aug-2012 : Automatic detection of open BC ( version 4.08 )
!/ 02-Sep-2012 : Clean up of open BC for UG grids ( version 4.08 )
!/ 14-Oct-2013 : Correction of latitude factor ( version 4.12 )
!/ 26-Jan-2014 : Correction interpolation weights ( version 4.18 )
!/ 21-Apr-2016 : New algorithm to detect boundary ( version 5.12 )
!/
!
! 1. Purpose :
!
! Reads triangle and unstructured grid information
!
! 2. Method :
!
! Look for namelist with name NAME in unit NDS and read if found.
!
! 3. Parameters :
!
!
! 4. Subroutines used :
!
! Name Type Module Description
! ------------------------------------------------------------------------------------
! READTRI Subr. Internal Read unstructured grid data from .grd .tri formatted files.
! READMSH Subr. Id. Read unstructured grid data from MSH format
! COUNT Subr. Internal Count connection.
! SPATIAL_GRID Subr. Id. Calculate surfaces.
! NVECTRI Subr. Id. Define cell normals and angles and edge length
! COORDMAX Subr. Id. Calculate useful grid elements
! AREA_SI Subr. Id. Define Connections
! ------------------------------------------------------------------------------------
!
!
! 5. Called by :
!
! Program in which it is contained.
!
! 6. Error messages :
!
! 7. Remarks :
! The only point index which is needed is IX and NX stands for the total number of grid point.
! IY and NY are not needed anymore, they are set to 1 in the unstructured case
! Some noticeable arrays are:
! XYB : give the 2D coordinates of all grid points
! TRIGP : give the vertices of each triangle
! 8. Structure :
!
! 9. Switches :
! !/PR3 : Enables unstructured meshes (temporary, will be replace by Unstructured switch)
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
PUBLIC
! USE CONSTANTS
! USE W3GDATMD, ONLY: W3NMOD, W3SETG
! USE W3ODATMD, ONLY: W3NOUT, W3SETO, W3DMO5
! USE W3IOGRMD, ONLY: W3IOGR
! USE W3SERVMD, ONLY: ITRACE, NEXTLN, EXTCDE
!!/S USE W3SERVMD, ONLY: STRACE
! USE W3ARRYMD, ONLY: INA2R, INA2I
!!/T USE W3ARRYMD, ONLY: PRTBLK
! USE W3DISPMD, ONLY: DISTAB
! USE W3GDATMD
! USE W3ODATMD, ONLY: NDSE, NDST, NDSO
! USE W3ODATMD, ONLY: NBI, NBI2, NFBPO, NBO, NBO2, FLBPI, FLBPO, &
! IPBPO, ISBPO, XBPO, YBPO, RDBPO, FNMPRE
!---------------------------------------------------------------------
!
!C
integer :: node_num
integer :: dim_num
integer :: triangle_order
integer :: triangle_num
integer :: bound_edge_num
integer :: bound_num
!C
logical,save, allocatable :: edge_boundary(:)
logical,save, allocatable :: node_boundary(:)
integer,save, allocatable :: edge_nums(:)
integer,save, allocatable :: boundary_node_index(:)
!C
integer,save, allocatable :: triangle_node(:,:)
integer,save, allocatable :: edge(:,:)
integer,save, allocatable :: edge_index(:,:)
integer,save, allocatable :: iobp_aux(:)
INTEGER, SAVE :: N_OUTSIDE_BOUNDARY
INTEGER, SAVE, ALLOCATABLE :: OUTSIDE_BOUNDARY(:)
real (kind = 8), save, allocatable :: node_xy(:,:)
real (kind = 8), save, allocatable :: edge_angle(:,:)
CONTAINS
!/ -------------------------------------------------------------------/
SUBROUTINE READMSH(NDS,FNAME)
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 06-Jun-2018|
!/ +-----------------------------------+
!/
!/ 15-Feb-2008 : Origination. ( version 3.13 )
!/ 25-Aug-2011 : Change of method for IOBPD ( version 4.04 )
!/ 06-Jun-2018 : Add DEBUGINIT/PDLIB/DEBUGSTP/DEBUGSETIOBP
!/ ( version 6.04 )
!/
!
! 1. Purpose :
!
! Reads triangle and unstructured grid information from GMSH files
! Calls the subroutines needed to compute grid connectivity
!
! 2. Method :
!
! Look for namelist with name NAME in unit NDS and read if found.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDS Int. I Data set number used for search.
! NAME C*4 I Name of namelist.
! STATUS C*20 O Status at end of routine,
! '(default values) ' if no namelist found.
! '(user def. values)' if namelist read.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ------------------------------------------------------------------------------------
! NEXTLN Subr.
! COUNT Subr. Internal Count connection.
! SPATIAL_GRID Subr. Id. Calculate surfaces.
! NVECTRI Subr. Id. Define cell normals and angles and edge length
! COORDMAX Subr. Id. Calculate useful grid elements
! AREA_SI Subr. Id. Define Connections
! ----------------------------------------------------------------
!
!
!
! 5. Called by :
! Name Type Module Description
! ----------------------------------------------------------------
! W3GRID Prog. Model configuration program
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
! The only point index which is needed is IX and NX stands for the total number of grid point.
! IY and NY are not needed anymore, they are set to 1 in the unstructured case
! Some noticeable arrays are:
! XYB : give the 2D coordinates of all grid points
! TRIGP : give the vertices of each triangle
! GMSH file gives too much information that is not necessarily required so data processing is needed (data sort and nesting).
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3ODATMD, ONLY: NDSE, NDST, NDSO
USE W3GDATMD
USE W3SERVMD, ONLY: ITRACE, NEXTLN, EXTCDE
USE CONSTANTS, only: LPDLIB
USE W3ODATMD, ONLY: IAPROC
!
IMPLICIT NONE
!/
!/ Parameter list
!/
INTEGER, INTENT(IN) :: NDS
CHARACTER(60), INTENT(IN) :: FNAME
!/
!/ local parameters
!/
INTEGER :: i,j,k, NODES, NELTS, ID, KID
INTEGER :: ID1, ID2, KID1, ITMP(3)
INTEGER :: I1, I2, I3
INTEGER(KIND=4) :: Ind,eltype,ntag, INode
CHARACTER :: COMSTR*1, SPACE*1 = ' ', CELS*64
REAL, ALLOCATABLE :: TAGS(:)
CHARACTER(LEN=64), ALLOCATABLE :: ELS(:)
CHARACTER(LEN=120) :: LINE
CHARACTER(LEN=50) :: CHTMP
CHARACTER(LEN=10) :: A, B, C
INTEGER,ALLOCATABLE :: NELS(:), TRIGPTMP1(:,:), TRIGPTMP2(:,:)
INTEGER(KIND=4),ALLOCATABLE :: IFOUND(:), VERTEX(:), BOUNDTMP(:)
DOUBLE PRECISION, ALLOCATABLE :: XYBTMP1(:,:),XYBTMP2(:,:)
REAL :: z
!/DEBUGINIT WRITE(740+IAPROC,*) 'Beginning of READMSH routine'
!/DEBUGINIT FLUSH(740+IAPROC)
OPEN(NDS,FILE = FNAME,STATUS='old')
READ (NDS,'(A)') COMSTR
IF (COMSTR.EQ.' ') COMSTR = '$'
CALL NEXTLN(COMSTR, NDS, NDSE)
READ(NDS,*) i,j,k
CALL NEXTLN(COMSTR, NDS, NDSE)
LPDLIB = .FALSE.
!/PDLIB LPDLIB = .TRUE.
!
! read number of nodes and nodes from Gmsh files
!
READ(NDS,*) NODES
ALLOCATE(XYBTMP1(NODES,3))
DO I= 1, NODES
READ(NDS,*) j, XYBTMP1(I,1), XYBTMP1(I,2), XYBTMP1(I,3)
END DO
!
! read number of elements and elements from Gmsh files
!
ALLOCATE(BOUNDTMP(NODES))
N_OUTSIDE_BOUNDARY = 0
CALL NEXTLN(COMSTR, NDS, NDSE)
READ(NDS,*) NELTS
ALLOCATE(TRIGPTMP1(NELTS, 3))
J = 0
DO I= 1, NELTS
READ(NDS,'(A100)') LINE
READ(LINE,*) Ind,eltype,ntag
ALLOCATE(TAGS(ntag))
SELECT CASE (eltype)
!
! eltype = 15 : boundary points (this is used to make the difference
! between the outside polygon and islands)
!
CASE(15)
READ(LINE,*) Ind,eltype,ntag,TAGS,INODE
N_OUTSIDE_BOUNDARY = N_OUTSIDE_BOUNDARY +1
BOUNDTMP(N_OUTSIDE_BOUNDARY)=INODE
!
! eltype = 2 : triangles
!
CASE (2)
J = J + 1
READ(LINE,*) Ind,eltype,ntag,tags,ITMP
TRIGPTMP1(J,1:3) = ITMP
END SELECT
DEALLOCATE(TAGS)
END DO
!
! organizes the grid data structure
!
ALLOCATE(OUTSIDE_BOUNDARY(N_OUTSIDE_BOUNDARY))
OUTSIDE_BOUNDARY(:)=BOUNDTMP(1:N_OUTSIDE_BOUNDARY)
NTRI = J
ALLOCATE(IFOUND(NODES))
IFOUND = 0
!
! Verifies that the nodes are used in at least one triangle
!
DO K = 1, NTRI
I1 = TRIGPTMP1(K,1)
I2 = TRIGPTMP1(K,2)
I3 = TRIGPTMP1(K,3)
IFOUND(I1)= IFOUND(I1) + 1
IFOUND(I2)= IFOUND(I2) + 1
IFOUND(I3)= IFOUND(I3) + 1
END DO
J = 0
ALLOCATE(TRIGPTMP2(NTRI,3),VERTEX(NODES),XYBTMP2(NODES,3))
VERTEX(:)=0
XYBTMP2 = 0
DO I = 1, NODES
IF( IFOUND(I) .GT. 0) THEN
J = J+1
XYBTMP2(J,:) = XYBTMP1(I,:)
VERTEX(I) = J
END IF
END DO
!
! Number of nodes after clean up
!
NX = J
!
DO I = 1, NTRI
I1 = TRIGPTMP1(I,1)
I2 = TRIGPTMP1(I,2)
I3 = TRIGPTMP1(I,3)
TRIGPTMP2(I,1) = VERTEX(I1)
TRIGPTMP2(I,2) = VERTEX(I2)
TRIGPTMP2(I,3) = VERTEX(I3)
END DO
!
DEALLOCATE(XYBTMP1, IFOUND,TRIGPTMP1)
DEALLOCATE(VERTEX)
!
!count points connections to allocate array in W3DIMUG
!
CALL COUNT(TRIGPTMP2)
!/DEBUGINIT WRITE(*,*) 'Call W3DIMUG from READMSH'
!/DEBUGINIT WRITE(740+IAPROC,*) 'Call W3DIMUG from READMSH'
!/DEBUGINIT FLUSH(740+IAPROC)
CALL W3DIMUG ( 1, NTRI, NX, COUNTOT, NNZ, NDSE, NDST )
!
! fills arrays
!
DO I = 1, NX
XYB(I,1) = XYBTMP2(I,1)
XYB(I,2) = XYBTMP2(I,2)
XYB(I,3) = XYBTMP2(I,3)
END DO
!
!/DEBUGSTP WRITE(740,*) 'Writing XYB(:,3)'
!/DEBUGSTP DO I=1,NX
!/DEBUGSTP WRITE(740,*) 'I,XYB(I,3)=', I, XYB(I,3)
!/DEBUGSTP END DO
!/DEBUGSTP FLUSH(740)
!
DO I=1, NTRI
ITMP = TRIGPTMP2(I,:)
TRIGP(I,:) = ITMP
END DO
!
DEALLOCATE(TRIGPTMP2,XYBTMP2)
!
! call the various routines which define the point spotting strategy
!
CALL SPATIAL_GRID
CALL NVECTRI
CALL COORDMAX
!
!READMSH is only called by ww3_grid, thus the grid index is always 1.
!
CALL AREA_SI(1)
!
CLOSE(NDS)
END SUBROUTINE READMSH
!/--------------------------------------------------------------------/
SUBROUTINE GET_BOUNDARY_STATUS(STATUS)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | |
!/ | Mathieu Dutour-Sikiric (IRB) |
!/ | Aron Roland (BGS IT&E GmbH) |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 01-Mai-2018 |
!/ +-----------------------------------+
!/
!/ 01-Mai-2018 : Origination. ( version 6.04 )
!/
! 1. Purpose : boundary status (code duplication)
! 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
!
!/PDLIB use yowElementpool, only: ne_global, INE_global
!/PDLIB use yowNodepool, only: np_global
USE W3GDATMD, ONLY : TRIGP, NTRI, NX
IMPLICIT NONE
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
!/ ------------------------------------------------------------------- /
!/ Local PARAMETERs
!/
!/S INTEGER, SAVE :: IENT = 0
!/
!/ ------------------------------------------------------------------- /
!/
!
integer, intent(out) :: STATUS(NX)
INTEGER :: COLLECTED(NX), NEXTVERT(NX), PREVVERT(NX)
INTEGER :: ISFINISHED, INEXT, IPREV
INTEGER :: IPNEXT, IPPREV, ZNEXT, IP, I, IE
!/S CALL STRACE (IENT, 'VA_SETUP_IOBPD')
STATUS(:) = 0
DO IE=1,NTRI
DO I=1,3
IF (I.EQ.1) THEN
IPREV=3
ELSE
IPREV=I-1
END IF
IF (I.EQ.3) THEN
INEXT=1
ELSE
INEXT=I+1
END IF
IP=TRIGP(IE,I)
IPNEXT=TRIGP(IE,INEXT)
IPPREV=TRIGP(IE,IPREV)
IF (STATUS(IP).EQ.0) THEN
STATUS(IP)=1
PREVVERT(IP)=IPPREV
NEXTVERT(IP)=IPNEXT
END IF
END DO
END DO
STATUS(:)=0
DO
COLLECTED(:)=0
DO IE=1,NTRI
DO I=1,3
IF (I.EQ.1) THEN
IPREV=3
ELSE
IPREV=I-1
END IF
IF (I.EQ.3) THEN
INEXT=1
ELSE
INEXT=I+1
END IF
IP=TRIGP(IE,I)
IPNEXT=TRIGP(IE,INEXT)
IPPREV=TRIGP(IE,IPREV)
IF (STATUS(IP).eq.0) THEN
ZNEXT=NEXTVERT(IP)
IF (ZNEXT.eq.IPPREV) THEN
COLLECTED(IP)=1
NEXTVERT(IP)=IPNEXT
IF (NEXTVERT(IP).eq.PREVVERT(IP)) THEN
STATUS(IP)=1
END IF
END IF
END IF
END DO
END DO
ISFINISHED=1
DO IP=1,NX
IF ((COLLECTED(IP).eq.0).and.(STATUS(IP).eq.0)) THEN
STATUS(IP)=-1
END IF
IF (STATUS(IP).eq.0) THEN
ISFINISHED=0
END IF
END DO
IF (ISFINISHED.eq.1) THEN
EXIT
END IF
END DO
END SUBROUTINE
!/ -------------------------------------------------------------------/
SUBROUTINE READMSHOBC(NDS, FNAME, TMPSTA, UGOBCOK)
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 14-Mar-2018|
!/ +-----------------------------------+
!/
!/ 14-Mar-2018 : Origination. ( version 6.02 )
!/
!
! 1. Purpose :
!
! Reads open boundary information for UNST grids following GMESH type format
!
! 2. Method :
!
! Reads an ASCII file
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDS Int. I Data set number used for search.
! FNAME Char*60 I File name
! TMPSTA Char*60 I/O status map to be updated (for OBC, TMPSTA = 2)
! UGOBCOK Logical O flag for proper reading of OBC file
! ----------------------------------------------------------------
!
! 4. Subroutines used : NONE
!
! 5. Called by :
! Name Type Module Description
! ----------------------------------------------------------------
! W3GRID Prog. Model configuration program
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3GDATMD, ONLY: NX, NY, CCON , COUNTCON
USE W3ODATMD, ONLY: NDSE, NDST, NDSO
USE W3SERVMD, ONLY: ITRACE, NEXTLN, EXTCDE
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: NDS
CHARACTER(60), INTENT(IN) :: FNAME
INTEGER, INTENT(INOUT) :: TMPSTA(NY,NX)
LOGICAL, INTENT(OUT) :: UGOBCOK
!/
!/ local parameters
!/
INTEGER :: I, IERR
INTEGER(KIND=4) :: Ind,ntag, INode
CHARACTER :: COMSTR*1, SPACE*1 = ' ', CELS*64
REAL, ALLOCATABLE :: TAGS(:)
CHARACTER(LEN=120) :: LINE
UGOBCOK=.FALSE.
OPEN(NDS,FILE = FNAME,STATUS='old')
READ (NDS,'(A)') COMSTR
IF (COMSTR.EQ.' ') COMSTR = '$'
CALL NEXTLN(COMSTR, NDS, NDSE)
IERR = 0
DO WHILE (IERR.EQ.0)
READ (NDS,'(A100)',END=2001,ERR=2002,IOSTAT=IERR) LINE
READ(LINE,*,IOSTAT=IERR) Ind,ntag
IF (IERR.EQ.0) THEN
ALLOCATE(TAGS(ntag))
READ(LINE,*,IOSTAT=IERR) Ind,ntag,TAGS,INODE
IF (IERR.EQ.0) THEN
TMPSTA(1,INODE)=2
DEALLOCATE(TAGS)
ELSE
GOTO 2001
END IF
END IF
END DO
CLOSE(NDS)
UGOBCOK=.TRUE.
RETURN
!
2001 CONTINUE
WRITE (NDSE,1001)
CALL EXTCDE ( 61 )
!
2002 CONTINUE
WRITE (NDSE,1002) IERR
CALL EXTCDE ( 62 )
1001 FORMAT (/' *** WAVEWATCH III ERROR IN READMSHOBC : '/ &
' PREMATURE END OF FILE IN READING ',A/)
1002 FORMAT (/' *** WAVEWATCH III ERROR IN READMSHOBC : '/ &
' ERROR IN READING ',A,' IOSTAT =',I8/)
END SUBROUTINE READMSHOBC
!/ ------------------------------------------------------------------- /
!/ ------------------------------------------------------------------- /
SUBROUTINE UG_GETOPENBOUNDARY(TMPSTA,ZBIN,ZLIM)
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 30-Aug-2012|
!/ +-----------------------------------+
!/
!/ 30-Aug-2012 : Adpatation from SHOM-Ifremer program( version 4.07 )
!/
!
! 1. purpose: defines open boundary points based on depth
! 2. Method : a boundary node has more node around it than triangles
!
!
!
! 3. Parameters :
! TMPSTA: status map to be updated (for OBC, TMPSTA = 2)
!
! 4. Subroutines used :
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! w3GRID Prog. Model configuration program
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
!
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
USE W3GDATMD, ONLY: NX, NY, CCON, COUNTCON, IOBP
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(INOUT) :: TMPSTA(NY,NX)
!/S INTEGER, SAVE :: IENT = 0
REAL , INTENT(IN) :: ZBIN(NY,NX)
REAL , INTENT(IN) :: ZLIM
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IBC, IX
INTEGER :: MASK(NX), STATUS(NX)
!
MASK(:)=1
CALL SET_IOBP (MASK, STATUS)
!
!/S CALL STRACE (IENT, 'UG_GETOPENBOUNDARY')
DO IBC = 1, N_OUTSIDE_BOUNDARY
IX = OUTSIDE_BOUNDARY(IBC)
!write(*,*) 'TEST1', IX, TMPSTA(1,IX), CCON(IX), COUNTCON(IX), ZBIN(1,IX), ZLIM
IF (IX.NE.0) THEN ! There was a bug in the mesh conversion, OUTSIDE_BOUNDARY(IBC) should not be zero
IF ((TMPSTA(1,IX).EQ.1).AND.(STATUS(IX).EQ.0) &
.AND.(ZBIN(1,IX).LT.ZLIM)) TMPSTA(1,IX)=2
END IF
END DO
!
END SUBROUTINE UG_GETOPENBOUNDARY
!/ ------------------------------------------------------------------- /
!/----------------------------------------------------------------------
SUBROUTINE SPATIAL_GRID
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Roland (BGS IT&E GbmH) |
!/ | F. Ardhuin (IFREMER) |
!/ | FORTRAN 90 |
!/ | Last update : 31-Aug-2011|
!/ +-----------------------------------+
!/
!/ 15-May-2007 : Origination: adjustment from the WWM code ( version 3.13 )
!/ 31-Aug-2011 : Simplfies the cross products ( version 4.05 )
!/
!
! 1. Purpose :
!
! Calculates triangle areas and reorders the triangles to have them
! oriented counterclockwise
!
! 2. Method :
!
! The triangle surface calculation is based on cross product.
!
! 3. Parameters :
!
! 4. Subroutines used :
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! READTRI Subr. Internal Unstructured mesh definition.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
!
! This part of code is adapted from the WWM wave model develop at the Darmstadt University
! (Aaron Roland)
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3GDATMD
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
!
!local parameters
!
REAL :: TL1, TL2, TL3, TMPTRIGP
INTEGER :: I1, I2, I3
INTEGER :: K
!/S INTEGER :: IENT = 0
!/ ------------------------------------------------------------------- /
!/S CALL STRACE (IENT, 'SPATIAL_GRID')
DO K = 1, NTRI
I1 = TRIGP(K,1)
I2 = TRIGP(K,2)
I3 = TRIGP(K,3)
!
! cross product of edge-vector (orientated anticlockwise)
!
TRIA(K) = REAL( (XYB(I2,2)-XYB(I1,2)) & ! (Y2-Y1)
*(XYB(I1,1)-XYB(I3,1)) & ! *(X1-X3)
+(XYB(I3,2)-XYB(I1,2)) & ! (Y3-Y1)*(X2-X1)
*(XYB(I2,1)-XYB(I1,1)) )*0.5
!
! test on negative triangle area, which means that the orientiation is not as assumed to be anticw.
! therefore we swap the nodes !!!
!
IF (TRIA(K) .lt. TINY(1.)) THEN
TMPTRIGP = TRIGP(K,2)
TRIGP(K,2) = TRIGP(K,3)
TRIGP(K,3) = TMPTRIGP
I2 = TRIGP(K,2)
I3 = TRIGP(K,3)
TRIA(K) = -1.d0*TRIA(K)
STOP 'WRONG TRIANGLE'
END IF
END DO
END SUBROUTINE
!/--------------------------------------------------------------------/
!
!/--------------------------------------------------------------------/
SUBROUTINE NVECTRI
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Roland |
!/ | FORTRAN 90 |
!/ | Last update : 15-May-2008|
!/ +-----------------------------------+
!/
!/ 15-May-2007 : Origination: adjustment from the WWM code ( version 3.13 )
!/
!
! 1. Purpose :
!
! Calculate cell tools: inward normal, angles and length of edges.
!
! 2. Method :
! To get inward pointing normals, triangle are glanced through anti-clockwisely
!
!
! 3. Parameters :
!
! 4. Subroutines used :
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! READTRI Subr. Internal Unstructured mesh definition.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3GDATMD
!/S USE W3SERVMD, ONLY: STRACE
USE CONSTANTS
IMPLICIT NONE
!
!local parameter
!
INTEGER :: IP, IE
INTEGER :: I1, I2, I3, I11, I22, I33
REAL*8 :: P1(2), P2(2), P3(2)
REAL*8 :: R1(2), R2(2), R3(2)
REAL*8 :: N1(2), N2(2), N3(2)
REAL*8 :: TMP(3)
REAL*8 :: TMPINV(3)
!/S INTEGER :: IENT = 0
!/ ------------------------------------------------------------------- /
!/S CALL STRACE (IENT, 'NVECTRI')
DO IE = 1, NTRI
!
! vertices
!
I1 = TRIGP(IE,1)
I2 = TRIGP(IE,2)
I3 = TRIGP(IE,3)
P1(1) = XYB(I1,1)
P1(2) = XYB(I1,2)
P2(1) = XYB(I2,1)
P2(2) = XYB(I2,2)
P3(1) = XYB(I3,1)
P3(2) = XYB(I3,2)
!
! I1 -> I2, I2 -> I3, I3 -> I1 (anticlockwise orientation is preserved)
!
R1 = P3-P2
R2 = P1-P3
R3 = P2-P1
N1(1) = (-R1(2))
N1(2) = ( R1(1))
N2(1) = (-R2(2))
N2(2) = ( R2(1))
N3(1) = (-R3(2))
N3(2) = ( R3(1))
!
! edges length
!
LEN(IE,1) = DSQRT(R1(1)**2+R1(2)**2)
LEN(IE,2) = DSQRT(R2(1)**2+R2(2)**2)
LEN(IE,3) = DSQRT(R3(1)**2+R3(2)**2)
!
! inward normal used for propagation (not normalized)
!
IEN(IE,1) = N1(1)
IEN(IE,2) = N1(2)
IEN(IE,3) = N2(1)
IEN(IE,4) = N2(2)
IEN(IE,5) = N3(1)
IEN(IE,6) = N3(2)
END DO
END SUBROUTINE
!/---------------------------------------------------------------------------
!/------------------------------------------------------------------------
SUBROUTINE COUNT(TRIGPTEMP)
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Roland |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 15-May-2008|
!/ +-----------------------------------+
!/
!/ 15-May-2007 : Origination. ( version 3.13 )
!/
!
! 1. Purpose :
!
! Calculate global and maximum number of connection for array allocations .
!
! 2. Method :
!
! 3. Parameters :
! Parameter list
! ----------------------------------------------------------------
! NTRI Int. I Total number of triangle.
! TRIGPTEMP Int I Temporary array of triangle vertices
! COUNTRI Int O Maximum number of connected triangle
! for a given points
! COUNTOT Int O Global number of triangle connection
! for the whole grid.
! ----------------------------------------------------------------
! 4. Subroutines used :
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! READTRI Subr. Internal Unstructured mesh definition.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! 7. Remarks :
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3GDATMD
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
!/ parameter list
INTEGER,INTENT(IN) :: TRIGPTEMP(:,:)
!/ ------------------------------------------------------------------- /
!/ local parameter
INTEGER :: CONN(NX)
INTEGER :: COUNTER, IP, IE, I, J, N(3)
!/S INTEGER :: IENT = 0
!/------------------------------------------------------------------------
!/S CALL STRACE (IENT, 'COUNT')
COUNTRI=0
COUNTOT=0
CONN(:)= 0
!
!calculate the number of connected triangles for a given point.
!
DO IE = 1,NTRI
N(:) = 0.
N(1) = TRIGPTEMP(IE,1)
N(2) = TRIGPTEMP(IE,2)
N(3) = TRIGPTEMP(IE,3)
CONN(N(1)) = CONN(N(1)) + 1
CONN(N(2)) = CONN(N(2)) + 1
CONN(N(3)) = CONN(N(3)) + 1
ENDDO
COUNTRI = MAXVAL(CONN)
!
! calculate the global number of connections available through the mesh
!
J=0
DO IP=1,NX
DO I=1,CONN(IP)
J=J+1
ENDDO
ENDDO
COUNTOT=J
END SUBROUTINE
!/----------------------------------------------------------------------------
SUBROUTINE COORDMAX
!/ -------------------------------------------------------------------
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | F. Ardhuin |
!/ | FORTRAN 90 |
!/ | Last update : 15-May-2008|
!/ +-----------------------------------+
!/
!/ 15-May-2007 : Origination. ( version 3.13 )
!/
! 1. Purpose :
!
! Calculate first point and last point coordinates, and minimum and maximum edge length.
!
! 2. Method :
!