-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinitialization.f90
2884 lines (2627 loc) · 94.7 KB
/
initialization.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!----------------------------------------------------------------------
SUBROUTINE READ_CONFIG (LO,LA,TEND,TMIN_INV,INI_SURF, &
WAVE_INFO,FAULT_INFO,LANDSLIDE_INFO, &
BCI_INFO,START_TYPE,START_TIME,BC_TYPE, &
OUT_OPT,JOB)
!......................................................................
!DESCRIPTION:
! #. OBTAIN ALL THE PARAMETERS FROM COMCOT.CTL;
! #. START_TYPE =
! 0: COLD START (SIMULATION STARTS FROM T = 0)
! 1: HOT START (SIMULATION STARTS FROM RESUMING TIME)
! 20: COLD START WITH TIDE LEVEL ADJUSTMENT
! 21: HOT START WITH TIDE LEVEL ADJUSTMENT
! #. INI_SURF =
! 0: USE FAULT MODEL TO DETERMINE SEAFLOOR DEFORMATION
! 1: USE DATA FILE TO DETERMINE INITIAL WATER SURFACE
! 2: USE INCIDENT WAVE MODEL TO GENERATE WAVES
! 3: USE TRANSIENT FLOOR MOTION MODEL (LANDSLIDE);
! 4: USE FAULT MODEL + LANDSLIDE;
! FAULT_MULTI.CTL IS REQUIRED FOR MULTI-FAULT SETUP;
! 9: USE MANSINHA AND SMYLIES' MODEL TO CALC DEFORMATION
!INPUT:
! #. COMCOT.CTL (AND FAULT_MULTI.CTL FOR MORE THAN ONE FAULT PLANE)
!OUTPUT:
! #. GENERAL INFORMAITON FOR A SIMULATION;
! #. GRID SETUP;
!NOTES:
! #. CREATED INITIALLY BY TOM LOGAN, ARSC (2005)
! #. MODIFIED BY XIAOMING WANG (SEP 2005)
! #. UPDATED ON SEP17 2006 (XIAOMING WANG, CORNELL UNIV.)
! #. UPDATED ON NOV 21 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON DEC 22 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON JAN05 2009 (XIAOMING WANG, GNS)
! #. UPDATED ON APR03 2009 (XIAOMING WANG)
! 1. IMPROVE COUPLING SCHEME BETWEEN SPHERICAL AND CARTESIAN
! #. UPDATED ON APR09 2009 (XIAOMING WANG, GNS)
! 1. ADD SUPPORT ON IMPORTING MULTIPLE FAULT PLANE PARAMETERS
! FROM A DATA FILE;
!-------------------------------------------------------------------------
USE LAYER_PARAMS
USE WAVE_PARAMS
USE FAULT_PARAMS
USE LANDSLIDE_PARAMS
USE BCI_PARAMS
TYPE (LAYER) :: LO
TYPE (LAYER), DIMENSION(NUM_GRID) :: LA
TYPE (WAVE) :: WAVE_INFO
TYPE (FAULT),DIMENSION(NUM_FLT) :: FAULT_INFO
TYPE (LANDSLIDE) :: LANDSLIDE_INFO
TYPE (BCI) :: BCI_INFO
INTEGER :: INI_SURF
REAL :: TEND, TMIN_INV, FM, DT, H_LIMIT, START_TIME
REAL :: ARC
INTEGER :: I,J,K, LAYNUM,STAT,POS,PARENT
INTEGER :: COUNT
INTEGER :: BC_TYPE
INTEGER :: OUT_OPT
INTEGER :: START_TYPE,START_STEP
CHARACTER(LEN=200) :: LINE,LINE1,LINE2,LINE3
CHARACTER(LEN=200) :: DUMP,TMP,TMPNAME,FNAME
CHARACTER(LEN=200) :: JOB
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
!LOAD CONTROL FILE COMCOT.CTL
WRITE(*,*) 'READING PARAMETERS FOR SIMULATION...'
OPEN(UNIT=666,FILE='comcot.ctl',STATUS='OLD',IOSTAT=ISTAT)
IF (ISTAT /=0) THEN
PRINT *,"ERROR:: CAN'T OPEN CONFIG FILE COMCOT.CTL; EXITING."
STOP
END IF
!----------------------------------------------
! READING GENERAL PARAMETERS FOR SIMULATION
!----------------------------------------------
WRITE (*,*) ' READING GENERAL INFORMATION......'
READ (666,'(8/)')
READ (666,'(A)') DUMP ! READ JOB DESCRIPTION
READ (666,'(49X,F30.6)') TEND ! TOTAL SIMULATED PHYSICAL TIME
READ (666,'(49X,F30.6)') TMIN_INV ! TIME INTERVAL FOR DATA OUTPUT
READ (666,'(49X,I30)') OUT_OPT ! 0-OUTPUT MAX TSUNAI AMP; 1-OUTPUT TIMEHISTORY; 2-OUTPUT BOTH
READ (666,'(49X,I30)') START_TYPE ! 0-COLD START (T=0.0); 1-HOT START (FROM T = START_TIME); 20-COLDSTART WITH TIDE CORRECTION; 21-HOTSTART WITH TIDE CORRECTION
READ (666,'(49X,F30.6)') START_TIME ! STARTING TIME STEP IF HOT START
READ (666,'(49X,F30.6)') H_LIMIT ! LIMITATION ON WATER DEPTH, SHALLOWER THAN THIS WILL BE TREATED AS LAND; 0.0 MEANS ORIGINAL SHORELINE WITHOUT VERTICAL WALL
READ (666,'(49X,I30)') INI_SURF ! INITIAL CONDITION: 0-FAULT; 1-FILE; 2-WAVEMAKER;3-LANDSLIDE;4-FAULT+LANDSLIDE
READ (666,'(49X,I30)') BC_TYPE ! BOUNDARY CONDITION: 0- RADIATION;1-SPONGE;2-WALL;3-FACTS
READ (666,'(A)') LINE1 ! READ FILE NAME OF Z INPUT
READ (666,'(A)') LINE2 ! READ FILE NAME OF U INPUT
READ (666,'(A)') LINE3 ! READ FILE NAME OF V INPUT
JOB = DUMP
POS = INDEX(LINE1,':')
IF (POS>0) THEN
BCI_INFO%FNAMEH = TRIM(LINE1(POS+1:200))
ELSE
BCI_INFO%FNAMEH = ' '
ENDIF
LINE1 = ''
POS = INDEX(LINE2,':')
IF (POS>0) THEN
BCI_INFO%FNAMEU = TRIM(LINE2(POS+1:200))
ELSE
BCI_INFO%FNAMEU = ' '
ENDIF
LINE2 = ''
POS = INDEX(LINE3,':')
IF (POS>0) THEN
BCI_INFO%FNAMEV = TRIM(LINE3(POS+1:200))
ELSE
BCI_INFO%FNAMEV = ' '
ENDIF
LINE3 = ''
IF (BC_TYPE.EQ.3) INI_SURF = 999
!----------------------------------------
! READING PARAMETERS FOR FAULT MODEL
!----------------------------------------
IF (INI_SURF.EQ.0 .OR. INI_SURF.EQ.4) THEN
WRITE (*,*) ' READING PARAMETERS FOR FAULT MODEL......'
ENDIF
READ (666,'(3/)')
READ (666,'(49X,I30)') FAULT_INFO(1)%NUM_FLT ! TOTAL NO. OF FAULT PLANES
IF (INI_SURF.EQ.0 .OR. INI_SURF.EQ.4) THEN
IF (FAULT_INFO(1)%NUM_FLT.GT.1) THEN
WRITE (*,*) ' MULTI-FAULTING CONFIGURATION IS IMPLEMENTED'
IF (FAULT_INFO(1)%NUM_FLT.NE.999) THEN
K = 1
WRITE (*,*) ' READING PARAMETERS FOR FAULT SEGMENT',K
ENDIF
ENDIF
ENDIF
READ (666,'(49X,F30.6)') FAULT_INFO(1)%T0 ! RUPTURING TIME OF FAULT PLANE 01
READ (666,'(49X,I30)') FAULT_INFO(1)%SWITCH ! OPTION: 1 - MODEL; 2 - DATA;
READ (666,'(49X,F30.6)') FAULT_INFO(1)%HH ! FOCAL DEPTH (UNIT: METER)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%L ! LENGTH OF SOURCE AREA (UNIT: METER)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%W ! WIDTH OF SOURCE AREA (UNIT: METER)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%D ! DISLOCATION (UNIT: METER)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%TH ! (=THETA) STRIKE DIRECTION (UNIT: DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%DL ! (=DELTA) DIP ANGLE (UNIT : DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%RD ! (=LAMDA) SLIP ANGLE (UNIT: DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%YO ! ORIGIN OF COMPUTATION (LATITUDE :DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%XO ! ORIGIN OF COMPUTATION (LONGITUDE:DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%Y0 ! EPICENTER (LATITUDE :DEGREE)
READ (666,'(49X,F30.6)') FAULT_INFO(1)%X0 ! EPICENTER (LONGITUDE:DEGREE)
READ (666,'(A)') LINE ! NAME OF DEFORMATION DATA FILE
READ (666,'(49X,I30)') FAULT_INFO(1)%FS ! FORMAT OF DEFORMATION FILE:0-COMCOT;1-MOST;2-XYZ
POS = INDEX(LINE,':')
IF (POS>0) THEN
FAULT_INFO(1)%DEFORM_NAME = TRIM(LINE(POS+1:200))
ELSE
FAULT_INFO(1)%DEFORM_NAME = 'ini_surface.dat'
ENDIF
LINE = ''
SN = SIN(RAD_DEG*FAULT_INFO(1)%DL)
CS = COS(RAD_DEG*FAULT_INFO(1)%DL)
IF (ABS(SN) .LT. EPS) FAULT_INFO(1)%DL = FAULT_INFO(1)%DL+EPS
IF (ABS(CS) .LT. EPS) FAULT_INFO(1)%DL = FAULT_INFO(1)%DL+EPS
! READING PARAMETERS FOR OTHER FAULT PLANES IF > 1
IF (INI_SURF.EQ.0 .OR. INI_SURF.EQ.4) THEN
IF (FAULT_INFO(1)%NUM_FLT.GT.1) THEN
IF (FAULT_INFO(1)%NUM_FLT.NE.999) THEN
CALL GET_MULTIFAULT_PARAMETERS (LO,FAULT_INFO)
ELSE
CALL READ_MULTIFAULT_DATA (LO,FAULT_INFO)
ENDIF
ENDIF
ENDIF
!----------------------------------------
! READING PARAMETERS FOR WAVE MAKER
!----------------------------------------
IF (INI_SURF .EQ. 2) THEN
WRITE (*,*) ' READING PARAMETERS FOR WAVE MAKER......'
ENDIF
READ (666,'(3/)')
READ (666,'(49X,I30)') WAVE_INFO%MK_TYPE ! WAVE TYPE ( 1:SOLITARY WAVE; 2:GIVEN FORM)
READ (666,'(A)') LINE ! FILENAME OF CUSTOMIZED INPUT PROFILE, ONLY FOR WAVE TYPE=2
READ (666,'(49X,I30)') WAVE_INFO%INCIDENT ! WAVE INCIDENT DIRECTION: (1:TOP,2:BOTTOM,3:LEFT,4RIGHT)
READ (666,'(49X,F30.6)') WAVE_INFO%AMP ! CHARACTERISTIC WAVE HEIGHT (UNIT: METER)
READ (666,'(49X,F30.6)') WAVE_INFO%DEPTH ! CHARACTERISTIC WATER DEPTH (IN METERS)
! OBTAIN FILENAME OF GIVEN PROFILE
POS = INDEX(LINE,':')
IF (POS>0) THEN
WAVE_INFO%FORM_NAME = TRIM(LINE(POS+1:200))
ELSE
WAVE_INFO%FORM_NAME = 'fse.dat'
ENDIF
LINE = ''
WAVE_INFO%WK_END = TEND
WAVE_INFO%MK_BC = 0
!-----------------------------------------
!READING PARAMETERS FOR LAND SLIDE MODEL
!----------------------------------------
IF (INI_SURF .EQ. 3) THEN
WRITE (*,*) ' READING PARAMETERS FOR LAND SLIDE MODEL......'
ENDIF
READ (666,'(3/)')
READ (666,'(49X,F30.6)') LANDSLIDE_INFO%X_START ! STARTING X COORD. OF LAND SLIDE REGION
READ (666,'(49X,F30.6)') LANDSLIDE_INFO%X_END ! ENDING X COORD. OF LAND SLIDE REGION
READ (666,'(49X,F30.6)') LANDSLIDE_INFO%Y_START ! STARTING Y COORD. OF LAND SLIDE REGION
READ (666,'(49X,F30.6)') LANDSLIDE_INFO%Y_END ! ENDING Y COORD. OF LAND SLIDE REGION
READ (666,'(A)') LINE ! NAME OF LANDSLIDE SNAPSHOT DATA FILE
READ (666,'(49X,I30)') LANDSLIDE_INFO%OPTION ! FORMAT OF LANDSLIDE:0-OLD COMCOT;1-XYT;2-FUNCTION
POS = INDEX(LINE,':')
IF (POS>0) THEN
LANDSLIDE_INFO%FILENAME = TRIM(LINE(POS+1:200))
ENDIF
! WRITE(*,*) LO%DEPTH_NAME
LINE = ''
!-----------------------------------------
! READING PARAMETERS FOR LAYER 1
!-----------------------------------------
WRITE (*,*) ' READING PARAMETERS FOR GRID LAYER......'
READ (666,'(5/)')
READ (666,'(49X,I30)') LO%LAYSWITCH ! SWITCH TO THIS LAYER:0-RUN THIS LAYER;1-DON'T RUN THIS LAYER
READ (666,'(49X,I30)') LO%LAYCORD ! COORDINATES: 0-SPHERICAL; 1-CARTESIAN
READ (666,'(49X,I30)') LO%LAYGOV ! GOVERNING EQUATION: 0-LINEAR SWE; 1-NONLINEAR SWE; 2-LSWE W/ DISP.; 3-NLSWE W/ DISP.
READ (666,'(49X,F30.6)') LO%DX ! GRID SIZE; IN MUNITES FOR SPHERICAL COORD., IN METERS FOR CARTESIAN
READ (666,'(49X,F30.6)') LO%DT ! TIME STEP SIZE, IN SECONDS; WILL BE ADJUSTED IF CFL STABILITY CONDITION NOT SATISFIED;
READ (666,'(49X,I30)') LO%FRIC_SWITCH ! FRICTION SWITCH: 0-CONSTANT ROUGHNESS;1-NO ROUGHNESS;2-VARIABLE ROUGHNESS, ROUGHNESS DATA FILE REQUIRED;
READ (666,'(49X,F30.6)') LO%FRIC_COEF ! MANNING'S ROUGHNESS COEF FOR FRICTION SWITCH = 0;
READ (666,'(49X,I30)') LO%FLUXSWITCH ! OUTPUT OPTION: 0-Z+HU+HZ; 1-Z; 2-NONE; 9-Z W/ MODIFIED BATHYMETRY;
READ (666,'(49X,F30.6)') LO%X_START ! STARTING X COORDINATE OF COMPUTATIONAL DOMAIN
READ (666,'(49X,F30.6)') LO%X_END ! ENDING X COORDINATE OF COMPUTATIONAL DOMAIN
READ (666,'(49X,F30.6)') LO%Y_START ! STARTING Y COORDINATE OF COMPUTATIONAL DOMAIN
READ (666,'(49X,F30.6)') LO%Y_END ! ENDING Y COORDINATE OF COMPUTATIONAL DOMAIN
READ (666,'(A)') LINE ! NAME OF BATHYMETRY DATA FILE FOR LAYER01
READ (666,'(49X,I30)') LO%FS ! FORMAT OF BATHYMETRY DATA: 0-OLD COMCOT; 1-MOST-FORMATTED; 2-XYZ; 3-ETOPO
READ (666,'(49X,I30)') LO%ID ! GRID IDENTIIFCATION NUMBER
READ (666,'(49X,I30)') LO%LEVEL ! GRID LEVEL IN NESTED GRID HIERACHY
READ (666,'(49X,I30)') LO%PARENT ! ID OF IT'S PARENT GRID
POS = INDEX(LINE,':')
IF (POS>0) THEN
LO%DEPTH_NAME = TRIM(LINE(POS+1:200))
!* TMP = TRIM(LINE(POS+1:200))
!* POS = INDEX(TRIM(TMP),' ',BACK=.TRUE.)
!* LEN_CHAR = LEN_TRIM(TMP(POS+1:200))
!* LO%DEPTH_NAME = TRIM(TMP(POS+1:POS+LEN_CHAR))
ELSE
LO%DEPTH_NAME = 'layer01.dep'
ENDIF
!* WRITE(*,*) LEN_CHAR,LO%DEPTH_NAME
LINE = ''
LO%LAYSWITCH = 0
LO%ID = 1
! TIDAL LEVEL CORRECTION CONTRAL
LO%TIDE_LEVEL = 0.0 ! RUN AT MEAN SEA LEVEL
IF (START_TYPE.EQ.20 .OR. START_TYPE.EQ.21) THEN
IF (START_TYPE.EQ.20) START_TYPE = 0
IF (START_TYPE.EQ.21) START_TYPE = 1
WRITE (*,*) '>>>>PLEASE INPUT TIDAL LEVEL CORRECTION TO MSL:'
READ *, LO%TIDE_LEVEL
ENDIF
! GENERATE 'SQUARE' GRIDS FOR DISPERSION-IMPROVED SCHEME
IF (LO%LAYGOV.GE.2) LO%PARENT = 0
LO%DIM = 2
IF (BC_TYPE.EQ.9) LO%DIM = 1
!* LO%PARENT = -1
LO%H_LIMIT = H_LIMIT
LO%INI_SWITCH = INI_SURF
LO%BC_TYPE = BC_TYPE
LO%UPZ = .TRUE.
LO%SC_OPTION = 0
IF (LO%LAYCORD .EQ. 0) THEN
LO%SOUTH_LAT = LO%Y_START
ELSE
LO%SOUTH_LAT = FAULT_INFO(1)%YO
LO%XO = FAULT_INFO(1)%XO
LO%YO = FAULT_INFO(1)%YO
ENDIF
CALL DX_CALC (LO)
START_STEP = NINT(START_TIME/LO%DT)
IF (LO%LAYCORD.EQ.0) THEN
FAULT_INFO(1)%YO = LO%Y_START
FAULT_INFO(1)%XO = LO%X_START
ENDIF
WRITE (*,*) ' READING PARAMETERS FOR GRID LAYER ID',LO%ID
!----------------------------------------
! READING PARAMETERS FOR SUB-LEVEL GRIDS
!----------------------------------------
!.....READING PARAMETERS FOR SUB GRIDS
!.....READING PARAMETERS FOR SUB-LEVEL GRIDS: LAYER02 TO LAYER13
DO I=1,NUM_GRID
READ (666,'(3/)')
READ (666,'(49X,I30)') LA(I)%LAYSWITCH
READ (666,'(49X,I30)') LA(I)%LAYCORD
READ (666,'(49X,I30)') LA(I)%LAYGOV
READ (666,'(49X,I30)') LA(I)%FRIC_SWITCH
READ (666,'(49X,F30.6)') LA(I)%FRIC_COEF
READ (666,'(49X,I30)') LA(I)%FLUXSWITCH
READ (666,'(49X,I30)') LA(I)%REL_SIZE ! GRID SIZE RATIO OF IT'S PARENT GRID TO THIS GRID
READ (666,'(49X,F30.6)') LA(I)%X_START ! STARTING X COORDINATE OF THIS GRID LAYER IN ITS PARENT GRID
READ (666,'(49X,F30.6)') LA(I)%X_END ! ENDING X COORDINATE OF THIS GRID LAYER IN ITS PARENT GRID
READ (666,'(49X,F30.6)') LA(I)%Y_START ! STARTING Y COORDINATE OF THIS GRID LAYER IN ITS PARENT GRID
READ (666,'(49X,F30.6)') LA(I)%Y_END ! ENDING Y COORDINATE OF THIS GRID LAYER IN ITS PARENT GRID
READ (666,'(A)') LINE ! NAME OF BATHYMETRY DATA FILE FOR LAYER21
READ (666,'(49X,I30)') LA(I)%FS ! FORMAT OF BATHYMETRY DATA
READ (666,'(49X,I30)') LA(I)%ID ! GRID IDENTIFICATION NUMBER
READ (666,'(49X,I30)') LA(I)%LEVEL ! GRID LEVEL IN NESTED GRID CONFIGURATION
READ (666,'(49X,I30)') LA(I)%PARENT ! ID OF ITS PARENT GRID LAYER
POS = INDEX(LINE,':')
IF (POS>0) THEN
LA(I)%DEPTH_NAME = TRIM(LINE(POS+1:200))
ELSE
WRITE (FNAME,1) LA(I)%ID
1 FORMAT('layer',I2.2,'.dep')
LA(I)%DEPTH_NAME = FNAME
FNAME = ''
ENDIF
! WRITE(*,*) LA(I)%DEPTH_NAME
LINE = ''
LA(I)%H_LIMIT = H_LIMIT
LA(I)%TIDE_LEVEL = LO%TIDE_LEVEL
LA(I)%INI_SWITCH = INI_SURF
LA(I)%BC_TYPE = BC_TYPE
LA(I)%DIM = 2
IF (BC_TYPE .EQ. 9) LA(I)%DIM = 1
LA(I)%UPZ = .TRUE. ! UPZ=.TRUE.: SAME COORDINATES (DEFAULT); .FALSE. DIFFERENT COORDINATES DEFAULT
LA(I)%SC_OPTION = 0
IF (LA(I)%LAYSWITCH .EQ. 9) THEN
LA(I)%UPZ = .FALSE.
LA(I)%LAYSWITCH = 0
ENDIF
IF (LA(I)%LAYSWITCH .EQ. 0) THEN
WRITE (*,*) ' READING PARAMETERS FOR GRID LAYER ID',LA(I)%ID
ENDIF
ENDDO
CLOSE(666)
!.... PROCESSING DEPENDENT PARAMETERS FOR TOP LAYER
!DETERMINE THE NUMBER OF ITS CHILD GRID LAYERS
COUNT = 0
DO I=1,NUM_GRID
IF (LA(I)%LAYSWITCH.EQ.0 .and. LA(I)%PARENT.EQ.LO%ID) THEN
COUNT = COUNT+1
ENDIF
ENDDO
LO%NUM_CHILD = COUNT
CALL ALLOC(LO,1)
! READ FRICTION COEF. DATA FROM FILE
IF (LO%FRIC_SWITCH .EQ. 2) CALL READ_FRIC_COEF (LO)
! MATCH 2ND-LEVEL GRIDS WITH 1ST-LEVEL GRID
DO I=1,NUM_GRID
IF (LA(I)%LAYSWITCH.EQ.0 .AND. LA(I)%PARENT.EQ.LO%ID) THEN
IF (LO%LAYCORD.EQ.0 .AND. LA(I)%LAYCORD.EQ.1) THEN
!SC_OPTION = 0: TRADITIONAL COUPLING SCHEME
!SC_OPTION = 1: IMPROVED COUPLING SCHEME
LA(I)%SC_OPTION = 1
IF (LA(I)%UPZ .EQV. .FALSE.) THEN
LA(I)%SC_OPTION = 0
ENDIF
ENDIF
CALL SUBGRID_MATCHING(LO,LA(I))
CALL ALLOC(LA(I),2)
LA(I)%DT = LO%DT/2.0 !TENTATIVE VALUE
! READ FRICTION COEF. DATA FROM FILE
IF (LA(I)%FRIC_SWITCH .EQ. 2) CALL READ_FRIC_COEF (LA(I))
!DETERMINE THE NUMBER OF ITS CHILD GRID LAYERS
COUNT = 0
DO K = 1,NUM_GRID
IF (LA(K)%LAYSWITCH.EQ.0 .AND. &
LA(K)%PARENT.EQ.LA(I)%ID) THEN
COUNT = COUNT + 1
ENDIF
ENDDO
LA(I)%NUM_CHILD = COUNT
ENDIF
ENDDO
! MATCH 3 - 12TH LEVEL GRIDS WITH 2ND-LEVEL GRIDS
NUM_LEVEL = NUM_GRID+1
DO KL = 2,NUM_LEVEL
DO I=1,NUM_GRID
IF (LA(I)%LAYSWITCH.EQ.0 .AND. LA(I)%LEVEL.EQ.KL) THEN
DO J = 1,NUM_GRID
IF (LA(J)%LAYSWITCH.EQ.0 .AND. &
LA(J)%PARENT.EQ.LA(I)%ID) THEN
IF (LA(I)%LAYCORD.EQ.0 .AND. &
LA(J)%LAYCORD.EQ.1) THEN
!SC_OPTION = 0: TRADITIONAL COUPLING SCHEME
!SC_OPTION = 1: IMPROVED COUPLING SCHEME
LA(J)%SC_OPTION = 1
IF (LA(J)%UPZ .EQV. .FALSE.) THEN
LA(I)%SC_OPTION = 0
ENDIF
ENDIF
CALL SUBGRID_MATCHING(LA(I),LA(J))
CALL ALLOC(LA(J),KL+1)
LA(J)%DT = LA(I)%DT/2.0 !TENTATIVE VALUE
!READ FRICTION COEF. DATA FROM FILE
IF (LA(J)%FRIC_SWITCH .EQ. 2) THEN
CALL READ_FRIC_COEF (LA(J))
ENDIF
!DETERMINE THE NUMBER OF ITS CHILD GRID LAYERS
COUNT = 0
DO K = 1,NUM_GRID
IF (LA(K)%LAYSWITCH.EQ.0 .AND. &
LA(K)%PARENT.EQ.LA(J)%ID) THEN
COUNT = COUNT + 1
ENDIF
ENDDO
LA(J)%NUM_CHILD = COUNT
ENDIF
ENDDO
ENDIF
ENDDO
ENDDO
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE GET_INI_SURF (LO,LA,INI_SURF,WAVE_INFO,FAULT_INFO, &
LANDSLIDE_INFO)
!......................................................................
!DESCRIPTION:
! #. OBTAIN INITIAL FREE SURFACE DISPLACEMENT FROM FAULT MODEL,
! CUSTOMIZED DATA FILE OR LANDSLIDE MODEL;
! #. INTERPOLATE FREE SURFACE DISPLACEMENT INTO NESTED GRID LAYERS;
! #. INI_SURF =
! 0: USE OKADA'S FAULT MODEL TO CALCULATE DEFORMATION
! 1: USE AN EXTERNAL FILE TO DETERMINE INITIAL SURFACE
! 2: USE INCIDENT WAVE MODEL TO DETERMINE INITIAL SURFACE
! 3: USE SUBMARINE LANDSLIDE MODEL
! 4: USE MULTIPLE FAULTS + LANDSLIDE (REQUIRE FAULT_MULTI.CTL)
! 9: USE MANSINHA AND SMYLIES' MODEL TO CALCULATE DEFORMATION
! #. FAULT MODELS ARE CALLED IN THIS SUBROUTINE
!INPUT:
! #. GRID INFORMATION, FAULT PARAMETERS
!OUTPUT:
! #. INITIAL WATER SURFACE DISPLACEMENTS OF ALL GRID LAYERS
! #. INITIAL SURFACE DISPLACEMENT IS SAVED IN INI_SURFACE.DAT
! #. SEAFLOOR DISPLACEMENTS ARE SAVED IN DEFORM_SEGXX.DAT
!NOTES:
! #. CREATED INITIALLY BY TOM LOGAN (ARSC,2005)
! #. UPDATED ON DEC 2005 (XIAOMING WANG, CORNELL UNIV.)
! #. UPDATED ON SEP17 2006 (XIAOMING WANG, CORNELL UNIV.)
! #. UPDATED ON NOV 21 2008 (XIAOMING WANG, GNS)
!----------------------------------------------------------------------
USE LAYER_PARAMS
USE WAVE_PARAMS
USE FAULT_PARAMS
USE LANDSLIDE_PARAMS
TYPE (LAYER) :: LO
TYPE (LAYER), DIMENSION(NUM_GRID) :: LA
TYPE (WAVE) :: WAVE_INFO
TYPE (FAULT),DIMENSION(NUM_FLT) :: FAULT_INFO
TYPE (LANDSLIDE) :: LANDSLIDE_INFO
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
SELECT CASE (INI_SURF)
CASE (0)
!GENERATE DEFORMATION PROFILE FROM BUILT-IN FAULT MODEL
!REF.: OKADA (1985)
CALL GET_FLOOR_DEFORM (LO,LA,FAULT_INFO,0.0)
CASE (1)
!LOAD CUSTOMIZED WATER SURFACE DISPLACEMENT FROM A FILE
CALL READ_INI_SURFACE (LO,LA,FAULT_INFO)
CASE (2)
CALL READ_WAVE (WAVE_INFO)
CASE (3)
CALL READ_LANDSLIDE (LO,LANDSLIDE_INFO)
CASE (4)
CALL GET_FLOOR_DEFORM (LO,LA,FAULT_INFO,0.0)
CALL READ_LANDSLIDE (LO,LANDSLIDE_INFO)
CASE (9)
!GENERATE DEFORMATION PROFILE FROM BUILT-IN FAULT MODEL
!REF.: MANSINHA AND SMYLIE (1971)
CALL GET_FLOOR_DEFORM (LO,LA,FAULT_INFO,0.0)
END SELECT
!.....WRITE INITIAL CONDITION INTO DATA FILE NAMED "INI_SURFACE.DAT"
CALL WRITE_INI (LO)
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE GET_MULTIFAULT_PARAMETERS (LO,FLT)
!......................................................................
!DESCRIPTION:
! #. OBTAIN FAULT PARAMETERS FOR SINGLE/MULTIPLE FAULT;
! #. FAULT_MULTI.CTL IS REQUIRED IF TOTAL NUMBER OF FAULT PLANES
! IS LARGER THAN 1
!INPUT:
! #. COMCOT.CTL AND FAULT_MULTI.CTL IF REQUIRED;
!OUTPUT:
! #. FAULT PARAMETERS FOR ALL FAULT PLANES INCLUDED;
!NOTES:
! #. CREATED ON DEC 18, 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON DEC 21 2008 (XIAOMING WANG, GNS)
!----------------------------------------------------------------------
USE LAYER_PARAMS
USE FAULT_PARAMS
TYPE (LAYER) :: LO
TYPE (FAULT), dimension(NUM_FLT) :: FLT
REAL TIME, TEMP(LO%NX)
INTEGER NUM_FLT
CHARACTER(LEN=200) :: line,line1,line2,line3
CHARACTER(LEN=200) :: dump,tmp,tmpname,fname
INTEGER :: POS
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
DATA OSIXTY/0.016666666667/, BIG/-999./
!* WRITE(*,*) ' MULTI-FAULTING CONFIGURATION IS IMPLEMENTED...'
OPEN(UNIT=23,FILE='fault_multi.ctl',STATUS='OLD',IOSTAT=ISTAT)
IF (ISTAT /=0) THEN
PRINT *,"ERROR:: CAN'T OPEN CONFIG FILE FAULT_MULTI.CTL; EXITING."
STOP
END IF
!----------------------------------------------
! READING FAULT PARAMETERS FOR EACH SEGMENT
!----------------------------------------------
READ (23,'(8/)')
!----------------------------------------
! READING PARAMETERS FOR EACH FAULT SEGMENT
!----------------------------------------
DO K = 2,FLT(1)%NUM_FLT
WRITE (*,*) ' READING PARAMETERS FOR FAULT SEGMENT',K
READ (23,'(3/)')
READ (23,'(49X,F30.9)') FLT(K)%T0 ! RUPTURING TIME OF THIS FAULT PLANE
READ (23,'(49X,I30)') FLT(K)%SWITCH ! OPTION OF OBTAINING DEFORMATION: 0-FAULT MODEL; 1-DATA FILE;
READ (23,'(49X,F30.9)') FLT(K)%HH ! FOCAL DEPTH (UNIT: METER)
READ (23,'(49X,F30.9)') FLT(K)%L ! LENGTH OF SOURCE AREA (UNIT: METER)
READ (23,'(49X,F30.9)') FLT(K)%W ! WIDTH OF SOURCE AREA (UNIT: METER)
READ (23,'(49X,F30.9)') FLT(K)%D ! DISLOCATION (UNIT: METER)
READ (23,'(49X,F30.9)') FLT(K)%TH ! (=THETA) STRIKE DIRECTION (UNIT: DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%DL ! (=DELTA) DIP ANGLE (UNIT : DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%RD ! (=LAMDA) SLIP ANGLE (UNIT: DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%YO ! ORIGIN OF COMPUTATION (LATITUDE :DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%XO ! ORIGIN OF COMPUTATION (LONGITUDE:DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%Y0 ! EPICENTER (LATITUDE :DEGREE)
READ (23,'(49X,F30.9)') FLT(K)%X0 ! EPICENTER (LONGITUDE:DEGREE)
READ (23,'(A)') LINE ! NAME OF DEFORMATION DATA FILE
READ (23,'(49X,I30)') FLT(K)%FS ! FORMAT OF DEFORMATION DATA FILE: 0-OLD COMCOT FORMAT;1-MOST;2-XYZ;
POS = INDEX(LINE,':')
IF (POS>0) THEN
FLT(K)%DEFORM_NAME = TRIM(LINE(POS+1:200))
ELSE
FLT(K)%DEFORM_NAME = 'ini_surface.dat'
ENDIF
LINE = ''
SN = SIN(RAD_DEG*FLT(K)%DL)
CS = COS(RAD_DEG*FLT(K)%DL)
IF (ABS(SN) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
IF (ABS(CS) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
! IF (SN .EQ. 0.0) FLT(K)%DL = FLT(K)%DL+EPS
! IF (CS .EQ. 0.0) FLT(K)%DL = FLT(K)%DL+EPS
FLT(K)%NUM_FLT = FLT(1)%NUM_FLT
FLT(K)%XO = FLT(1)%XO
FLT(K)%YO = FLT(1)%YO
ENDDO
CLOSE(23)
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE READ_MULTIFAULT_DATA (LO,FLT)
!......................................................................
!DESCRIPTION:
! #. OBTAIN FAULT PARAMETERS FOR MULTIPLE FAULT SEGMENTS;
! #. PARAMETERS FOR FAULT SEGMENTS ARE OBTAINED FROM AN EXTERNAL
! DATA FILE GIVEN AT LINE 40 IN COMCOT.CTL;
! #. THE DATA FILE CONTAINS ALL THE INFORMATION FOR EACH SEGMENT;
! EACH ROW FOR ONE SEGMENT: TIME,LON,LAT,L,W,H,THETA,DELTA,LAMBDA,SLIP;
! #. TO USE THIS FUNCTION, INPUT 999 AT LINE 26 IN COMCOT.CTL;
!INPUT:
! #. PARAMETER DATA FILE;
!OUTPUT:
! #. FAULT PARAMETERS FOR ALL FAULT PLANES INCLUDED;
!NOTES:
! #. CREATED ON APR 09, 2009 (XIAOMING WANG, GNS)
! #. UPDATED ON APR09 2009 (XIAOMING WANG, GNS)
! 1. ADD SUPPORT ON IMPORTING FAULT PARAMETERS FOR MULTIPLE
! FAULT SEGMENTS FROM A DATA FILE;
!----------------------------------------------------------------------
USE LAYER_PARAMS
USE FAULT_PARAMS
TYPE (LAYER) :: LO
TYPE (FAULT), dimension(NUM_FLT) :: FLT
REAL TIME, TEMP(LO%NX)
INTEGER NUM_FLT,COUNT
CHARACTER(LEN=200) :: line,line1,line2,line3
CHARACTER(LEN=200) :: dump,tmp,tmpname,fname
INTEGER :: RSTAT
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
DATA OSIXTY/0.016666666667/, BIG/-999./
RSTAT = 0
!* WRITE(*,*) ' MULTI-FAULTING CONFIGURATION IS IMPLEMENTED...'
OPEN(UNIT=23,FILE=FLT(1)%DEFORM_NAME,STATUS='OLD',IOSTAT=ISTAT)
IF (ISTAT /=0) THEN
PRINT *,"ERROR:: CAN'T OPEN FAULT PARAMETER DATA FILE; EXITING."
STOP
END IF
!.....DETERMINE THE TOTAL NUMBER OF FAULT SEGMENTS
COUNT = -1
DO WHILE (RSTAT == 0)
COUNT = COUNT + 1
READ (23,*, IOSTAT=RSTAT) T1,T2,T3,T4,T5,T6,T7,T8,T9,T10
ENDDO
FLT(1)%NUM_FLT = COUNT
REWIND(23)
K = 1
WRITE (*,*) ' READING PARAMETERS FOR FAULT SEGMENT ',K,' TO ',COUNT
!----------------------------------------
! READING PARAMETERS FOR EACH FAULT SEGMENT
!----------------------------------------
DO K = 1,FLT(1)%NUM_FLT
READ (23,*) FLT(K)%T0,FLT(K)%X0,FLT(K)%Y0,FLT(K)%L, &
FLT(K)%W,FLT(K)%HH,FLT(K)%TH,FLT(K)%DL, &
FLT(K)%RD,FLT(K)%D
IF (K.EQ.1) THEN
SN = SIN(RAD_DEG*FLT(K)%DL)
CS = COS(RAD_DEG*FLT(K)%DL)
IF (ABS(SN) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
IF (ABS(CS) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
ENDIF
IF (K.GT.1) THEN
FLT(K)%SWITCH = FLT(1)%SWITCH
SN = SIN(RAD_DEG*FLT(K)%DL)
CS = COS(RAD_DEG*FLT(K)%DL)
IF (ABS(SN) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
IF (ABS(CS) .LT. EPS) FLT(K)%DL = FLT(K)%DL+GX
FLT(K)%NUM_FLT = FLT(1)%NUM_FLT
FLT(K)%DEFORM_NAME = FLT(1)%DEFORM_NAME
FLT(K)%FS = FLT(1)%FS
FLT(K)%XO = FLT(1)%XO
FLT(K)%YO = FLT(1)%YO
ENDIF
ENDDO
CLOSE(23)
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE GET_LANDSLIDE_PARAMETERS (LO,LS)
!......................................................................
!DESCRIPTION:
! #. OBTAIN ADDITIONAL PARAMETERS FOR LANDSLIDE CONFIGURATION;
! #. THESE ADDITIONAL PARAMETERS ARE USED TO DETERMINE WATER DEPTH
! VARIATIONS VIA WATTS ET AL (2003)'S LANDSLIDE THEORY;
! #. LANDSLIDE.CTL IS REQUIRED IF THE OPTION IN LANDSLIDE SECTION
! IN COMCOT.CTL IS LARGER THAN 1
!INPUT:
! #. COMCOT.CTL AND LANDSLIDE.CTL IF REQUIRED;
!OUTPUT:
! #. ADDITIONAL LANDSLIDE PARAMETERS FOR LANDSLIDE CONFIGURATION;
!NOTES:
! #. CREATED ON FEB 13, 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON ???
!----------------------------------------------------------------------
USE LAYER_PARAMS
USE LANDSLIDE_PARAMS
TYPE (LAYER) :: LO
TYPE (LANDSLIDE) :: LS
REAL T0,T1
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
DATA OSIXTY/0.016666666667/, BIG/-999./
!----------------------------------------------
! READING PARAMETERS FOR BUILT-IN SLIDING MODEL
!----------------------------------------------
!* WRITE(*,*) ' MULTI-FAULTING CONFIGURATION IS IMPLEMENTED...'
OPEN(UNIT=23,FILE='landslide.ctl',STATUS='OLD',IOSTAT=ISTAT)
IF (ISTAT /=0) THEN
PRINT *,"ERROR:: CAN'T OPEN CONFIG FILE LANDSLIDE.CTL; EXITING."
STOP
END IF
READ (23,'(8/)')
WRITE (*,*) ' READING PARAMETERS FOR LAND SLIDE CONFIGURATION'
READ (23,'(3/)')
READ (23,'(49X,F30.9)') T0 ! LAND SLIDE STARTING TIME (SECONDS)
READ (23,'(49X,F30.9)') T1 ! LAND SLIDE ENDING TIME (SECONDS)
READ (23,'(49X,F30.9)') LS%XS ! X COORD OF STARTING LOCATION (CENTER OF MASS)
READ (23,'(49X,F30.9)') LS%YS ! Y COORD OF STARTING LOCATION (CENTER OF MASS)
READ (23,'(49X,F30.9)') LS%XE ! X COORD OF STOPPING LOCATION (CENTER OF MASS)
READ (23,'(49X,F30.9)') LS%YE ! Y COORD OF STOPPING LOCATION (CENTER OF MASS)
READ (23,'(49X,F30.9)') LS%SLOPE ! TYPICAL SLOPE ANGLE ALONG SLIDING PATH (DEGREE)
READ (23,'(49X,F30.9)') LS%A ! LENGTH OF SLIDING VOLUME (IN METERS ALONG PATH)
READ (23,'(49X,F30.9)') LS%B ! WIDTH OF SLIDING VOLUME (IN METERS CROSS PATH)
READ (23,'(49X,F30.9)') LS%THICKNESS ! TYPICAL THICKNESS OF SLIDE VOLUME (IN METERS)
CLOSE(23)
LS%DURATION = T1 - T0
LS%NT = NINT((T1-T0)/LO%DT)+1
ALLOCATE(LS%T(LS%NT))
LS%T = 0.0
DO K = 1,LS%NT
LS%T(K) = (K-1.0)*LO%DT + T0
ENDDO
WRITE (*,*) 'T0=',T0
WRITE (*,*) 'T1=',T1
WRITE (*,*) 'NT=',LS%NT
WRITE (*,*) 'T(1)=',LS%T(1)
WRITE (*,*) 'T(NT)=',LS%T(LS%NT)
WRITE (*,*) 'SLOPE=',LS%SLOPE
WRITE (*,*) 'THICKNESS=',LS%THICKNESS
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE DX_CALC (LO)
!......................................................................
!DESCRIPTION:
! #. CALCULATE GRID SIZE AND X,Y COORDINATES OF 1ST-LEVEL GRIDS
! FOR 'SQUARE' GRID CELLS WHEN SPHERICAL COORDINATE IS ADOPTED,
! DESIGNED FOR DISPERSION IMPROVEMENT PURPOSE;
! #. GRID_SWITCH - FLAG ONLY FOR SPHERICAL COORDINATES
! 0 - CREATE A 'SQUARE' GRID CELL IN SPHERICAL COORDINATE,
! I.E., LENGTH OF DX = LENGTH OF DY;
! 1 - CREATE A 'NORMAL' GRID CELL IN SPHERICAL COORDINATE,
! I.E., DX = DY IN ARC MINUTES, BUT LENGTH ARE DIFFERENT;
! #. *** HERE, LO%PARENT IS TEMPORARILY USED FOR TEST PURPOSE:
! = 0: 'SQUARE' GRID CELL WILL BE CREATED FOR LO
! = -1: 'NORMAL' GRID CELL WILL BE CREATED FOR LO
!NOTE:
! #. CREATED ON SEP 18 2006 (XIAOMING WANG, CORNELL UNIV.)
! #. UPDATED ON DEC.17 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON JAN03 2009 (XIAOMING WANG, GNS)
!----------------------------------------------------------------------
USE LAYER_PARAMS
TYPE (LAYER) :: LO,LA
REAL X,Y,X0,Y0,DX_ARC
REAL, ALLOCATABLE :: YTMP(:),DEL_Y(:)
INTEGER GRID_SWITCH
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
!.....TENTATIVE VALUES
LO%DY = LO%DX
LO%REL_SIZE = 1
LO%REL_TIME = 1
!.....IF THE CARTESIAN COORDINATE IS ADOPTED,
! CALCULATE THE GRID DIMENSION, X AND Y COORDINATES;
IF (LO%LAYCORD.EQ.1) THEN
LO%NX = NINT((LO%X_END-LO%X_START)/LO%DX)+1
LO%NY = NINT((LO%Y_END-LO%Y_START)/LO%DY)+1
ALLOCATE(LO%X(LO%NX))
ALLOCATE(LO%Y(LO%NY))
ALLOCATE(LO%DEL_X(LO%NX))
ALLOCATE(LO%DEL_Y(LO%NY))
DO I = 1,LO%NX
LO%X(I) = LO%X_START + (I-1)*LO%DX
END DO
DO J = 1,LO%NY
LO%Y(J) = LO%Y_START + (J-1)*LO%DY
END DO
LO%DEL_X(:) = LO%DX
LO%DEL_Y(:) = LO%DY
!SPHERICAL COORDINATES, FOR FACTS INPUT
IF (LO%BC_TYPE.EQ.3) THEN
ALLOCATE(LO%CXY(LO%NX,LO%NY,2))
LO%CXY = 0.0
DO I = 1,LO%NX
DO J = 1,LO%NY
CALL COORD_CONVERT (LO%X(I),LO%Y(J), &
LO%CXY(I,J,1),LO%CXY(I,J,2),LO%XO,LO%YO,1)
ENDDO
ENDDO
ENDIF
ENDIF
!.....IF SPHERICAL COORDINATE IS IMPLEMENTED,
! CALCULATE THE GRID DIMENSION, X AND Y COORDINATES;
!.....IF GRID_SWITCH = 0, GRID SIZE IN Y DIRECTION WILL BE ADJUSTED
! ACCORDING TO LATITUDE SO THAT 'SQUARE' GRID CELLS WILL BE CREATED
! IN SPHERICAL COORDINATES;
!.....GRID_SWITCH - FLAG ONLY FOR SPHERICAL COORDINATES
! 0 - CREATE A 'SQUARE' GRID CELL IN SPHERICAL COORDINATE,
! I.E., LENGTH OF DX = LENGTH OF DY;
! 1 - CREATE A 'NORMAL' GRID CELL IN SPHERICAL COORDINATE,
! I.E., DX = DY IN ARC MINUTES, BUT LENGTH ARE DIFFERENT;
GRID_SWITCH = 0
IF (LO%PARENT .EQ. -1) GRID_SWITCH = 1 !FOR TEST PURPOSE
IF (LO%LAYCORD .EQ. 0) THEN
! WHEN SQUARE GRID IS REQUIRED
IF (GRID_SWITCH.EQ.0) THEN
!CONVERT MINUTES TO DEGREES
DX = LO%DX/60.0
DY = LO%DY/60.0
LO%NX = NINT((LO%X_END-LO%X_START)/DX)+1
ALLOCATE(LO%X(LO%NX))
ALLOCATE(LO%DEL_X(LO%NX))
DO I = 1,LO%NX
LO%X(I) = (I-1)*DX + LO%X_START
END DO
LO%DEL_X(:) = LO%DX
!CREATE 'NON-UNIFORM' GRID SIZE IN Y DIRECTION (LATITUDE)
NY = NINT((LO%Y_END-LO%Y_START)/DY)+1
ALLOCATE(YTMP(5*NY))
ALLOCATE(DEL_Y(5*NY))
YTMP = 0.0
DEL_Y = 0.0
K = 1
YTMP(1) = LO%Y_START
DO WHILE (YTMP(K).LE.LO%Y_END)
ANG_K = YTMP(K)*RAD_DEG
DEL_Y(K) = DX*COS(ANG_K)
DY = DX*COS(ANG_K+0.5*DEL_Y(K)*RAD_DEG)
YTMP(K+1) = YTMP(K) + DY
K = K + 1
END DO
LO%NY = K-1
ALLOCATE(LO%Y(LO%NY))
ALLOCATE(LO%DEL_Y(LO%NY))
LO%Y(:) = YTMP(1:LO%NY)
LO%DEL_Y(:) = DEL_Y(1:LO%NY)*60.0
LO%XO = LO%X(1)
LO%YO = LO%Y(1)
!WHEN SQUARE GRID IS NOT REQUIRED
ELSE
DX = LO%DX/60.0
DY = LO%DY/60.0
LO%NX = NINT((LO%X_END-LO%X_START)/DX)+1
LO%NY = NINT((LO%Y_END-LO%Y_START)/DY)+1
ALLOCATE(LO%X(LO%NX))
ALLOCATE(LO%Y(LO%NY))
ALLOCATE(LO%DEL_X(LO%NX))
ALLOCATE(LO%DEL_Y(LO%NY))
DO I = 1,LO%NX
LO%X(I) = LO%X_START + (I-1)*DX
END DO
DO J = 1,LO%NY
LO%Y(J) = LO%Y_START + (J-1)*DY
END DO
LO%DEL_X(:) = LO%DX
LO%DEL_Y(:) = LO%DY
LO%XO = LO%X(1)
LO%YO = LO%Y(1)
ENDIF
ENDIF
DEALLOCATE(YTMP,DEL_Y,STAT = ISTAT)
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE SUBGRID_MATCHING (LO,LA)
!......................................................................
!DESCRIPTION:
! #. CALCULATE GRID DIMENSION AND COORDINATES OF GRID LAYER LA AND
! ITS POSITION IN ITS PARENT LAYER LO
! #. ARRAYS RELATED TO DIMENSION ARE ALLOCATED HERE
! #. LA%UPZ =
! .TRUE. - PARENT GRID, LO, AND CHILD GRID, LA, ADOPT
! THE SAME COORDINATE SYSTEM;
! .FALSE. - PARENT GRID, LO, AND CHILD GRID, LA, ADOPT
! DIFFERENT COORDINATE SYSTEM;
! #. SC_OPTION: COUPLING SCHEME BETWEEN SPHERICAL AND CARTESIAN
! = 0: TRADITIONAL COUPLING SCHEME BETWEEEN SPH AND CART;
! = 1: IMPROVED COUPLING SCHEME BETWEEN SPH AND CART;
!INPUT:
! LO: PARENT GRID LAYER
!OUTPUT:
! LA: CURRENT GRID LAYER
!NOTE:
! #. CREATED ON NOV 05 2008 (XIAOMING WANG, GNS)
! #. UPDATED ON JAN05 2008 (XIAOMING WANG)
! #. UPDATED ON APR03 2009 (XIAOMING WANG)
! 1. IMPROVE COUPLING SCHEME BETWEEN SPHERICAL AND CARTESIAN
!----------------------------------------------------------------------
USE LAYER_PARAMS
TYPE (LAYER) :: LO,LA
REAL SOUTH_LAT,DX_ARC
REAL LAT,LON,LAT0,LON0,X,Y,X0,Y0
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
WRITE (*,*) ' GENERATING NESTED GRIDS IN LAYER',LO%ID
!.....DETERMINE TIME STEP SIZE OF CHILD GRID
!* LA%REL_TIME = LA%REL_SIZE
!* LA%DT=LO%DT/LA%REL_SIZE
!.....DETERMINE POSITION INDICES OF CHILD GRID IN ITS PARENT GRID LAYER
IS = 2
IE = LO%NX-1
JS = 2
JE = LO%NY-1
DO K = IS,IE
IF (LA%X_START.GE.(LO%X(K-1)+LO%X(K))/2.0 .AND. &
LA%X_START.LT.(LO%X(K)+LO%X(K+1))/2.0) LA%CORNERS(1) = K+1
IF (LA%X_END.GE.(LO%X(K-1)+LO%X(K))/2.0 .AND. &
LA%X_END.LT.(LO%X(K)+LO%X(K+1))/2.0) LA%CORNERS(2) = K-1
ENDDO
DO K = JS,JE
IF (LA%Y_START.GE.(LO%Y(K-1)+LO%Y(K))/2.0 .AND. &
LA%Y_START.LT.(LO%Y(K)+LO%Y(K+1))/2.0) LA%CORNERS(3) = K+1
IF (LA%Y_END.GE.(LO%Y(K-1)+LO%Y(K))/2.0 .AND. &
LA%Y_END.LT.(LO%Y(K)+LO%Y(K+1))/2.0) LA%CORNERS(4) = K-1
ENDDO
!.....DETERMINE THE DIMENSION OF CHILD GRID LAYER
IF (LO%LAYCORD .EQ. LA%LAYCORD) THEN
LA%NX = (LA%CORNERS(2)-LA%CORNERS(1)+1)*LA%REL_SIZE+1
LA%NY = (LA%CORNERS(4)-LA%CORNERS(3)+1)*LA%REL_SIZE+1
ALLOCATE(LA%X(LA%NX))
ALLOCATE(LA%Y(LA%NY))
ALLOCATE(LA%DEL_X(LA%NX))
ALLOCATE(LA%DEL_Y(LA%NY))
LA%X = 0.0
LA%Y = 0.0
LA%DEL_X = 0.0
LA%DEL_Y = 0.0
ENDIF
!DETERMINE GRID SIZE AND X,Y COORDINATES OF CHILD GRID LAYER: LA
!WHEN BOTH LO AND LA ADOPT CARTESIAN COORDINATES
IF (LO%LAYCORD.EQ.1 .AND. LA%LAYCORD.EQ.1) THEN
LA%DX = LO%DX/DBLE(LA%REL_SIZE)
LA%DY = LO%DY/DBLE(LA%REL_SIZE)
XS = 0.5*(LO%X(LA%CORNERS(1))+LO%X(LA%CORNERS(1)-1))-LA%DX/2.0
YS = 0.5*(LO%Y(LA%CORNERS(3))+LO%Y(LA%CORNERS(3)-1))-LA%DY/2.0
DO I = 1,LA%NX
LA%X(I) = (I-1)*LA%DX + XS
ENDDO
DO J = 1,LA%NY
LA%Y(J) = (J-1)*LA%DY + YS
ENDDO
LA%DEL_X(:) = LA%DX
LA%DEL_Y(:) = LA%DY
ENDIF
!WHEN BOTH LO AND LA USE SPHERICAL COORDINATES
IF (LO%LAYCORD .EQ. 0) THEN
IF (LA%LAYCORD .EQ. 0) THEN
LA%DX = LO%DX/DBLE(LA%REL_SIZE)
LA%DY = LO%DY/DBLE(LA%REL_SIZE)
LA%DEL_X(:) = LA%DX
LA%DEL_Y(:) = LA%DY
DX = LA%DX/60.0 !CONVERT MINUTES TO DEGREES
XS = 0.5*(LO%X(LA%CORNERS(1))+LO%X(LA%CORNERS(1)-1))-DX/2.0
DO I = 1,LA%NX
LA%X(I) = (I-1)*DX + XS
ENDDO
JS = LA%CORNERS(3)
JE = LA%CORNERS(4)
DY = LO%DEL_Y(JS-1)/DBLE(LA%REL_SIZE)
LA%SOUTH_LAT = 0.5*(LO%Y(JS)+LO%Y(JS-1)) - 0.5*DY/60.0
LA%Y(1) = LA%SOUTH_LAT
LA%DEL_Y(1) = DY
DO J = JS,JE
DY = LO%DEL_Y(J)/DBLE(LA%REL_SIZE)
YS = 0.5*(LO%Y(J)+LO%Y(J-1))
KS = (J-JS)*LA%REL_SIZE + 1
DO K = 1,LA%REL_SIZE
LA%DEL_Y(KS+K) = DY
LA%Y(KS+K) = YS + (K-0.5)*DY/60.0
ENDDO
ENDDO
! WRITE(*,*) LA%NY,LA%DEL_Y(1),LA%DEL_Y(NINT(LA%NY/2.0)),LA%DEL_Y(LA%NY)
!*!CALCULATE POSITION AND PARAMETERS REQUIRED FOR DATA COMMUNICATION
!*!*BETWEEN LO AND LA
ENDIF