-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubdomain.F
866 lines (705 loc) · 25.3 KB
/
subdomain.F
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
C
C ADCIRC - SUBDOMAIN MODELING MODULE
C
C ========================================================================
C | |
C | This file contains the subroutines required by Subdomain Modeling, |
C | an approach to reduce the total runtime of a series of hurricane |
C | storm surge simulations on a smaller grid, a subdomain grid, |
C | extracted from the original grid. |
C | |
C | Written by Alper Altuntas, [email protected] |
C | North Carolina State University, |
C | 2013 |
C | |
C ========================================================================
module subdomain
use sizes, only : sz, globaldir
use global, only : DEBUG, ECHO, INFO, WARNING, ERROR, logMessage,
& allMessage, scratchMessage, setMessageSource,
& unsetMessageSource
logical subdomainOn
integer :: NOUTGS, NSPOOLGS, enforceBN
integer :: ncbnr, nobnr, nibnr, localncbnr, localnobnr, localnibnr
integer,allocatable :: cbnr(:), obnr(:), ibnr(:)
integer,allocatable :: localcbnr(:), localobnr(:), localibnr(:)
integer :: sbtiminc, nobn, nibn, ncbn
real(sz),allocatable :: eobn1(:),uobn1(:),vobn1(:),eibn1(:)
real(sz),allocatable :: eobn2(:),uobn2(:),vobn2(:),eibn2(:)
real(sz),allocatable :: ecbn1(:),ucbn1(:),vcbn1(:)
real(sz),allocatable :: ecbn2(:),ucbn2(:),vcbn2(:)
real(sz),allocatable :: setEob(:), setUob(:), setEcb(:), setUcb(:)
real(sz),allocatable :: setVob(:), setVcb(:), setEib(:)
integer,allocatable :: setWDob(:), setWDcb(:)
integer,allocatable :: wdobn1(:),wdobn2(:),wdcbn1(:),wdcbn2(:)
integer,allocatable :: cbn(:),obn(:),ibn(:)
integer :: nlines, bchange
contains
SUBROUTINE readFort015()
C ========================================================================
C This subroutine reads in additional modeling parameters from fort.015
C and initiates the Subdomain Modeling
C
C - NOUTGS: Type of the run:
C NOUTGS=0 => full run
C NOUTGS=1 => subdomain run (old file formatting)
C NOUTGS=2 => subdomain run (new file formatting)
C - NSPOOLGS: The number of timesteps at which information is
C written to output files fort.06*
C - enforceBN: Boundary enforcing flag.
C enforceBN = 0 => no forcing (full domain)
C enforceBN = 1 => forcing (subdomain, old file formatting)
C enforceBN = 2 => forcing (subdomain, new file formatting)
C - nobnr: The number of outer boundary nodes of subdomain grids to be
C recorded to fort.06* during a full run.
C - obnr(i): i.th outer boundary node to be recorded to fort.065 and
C fort.066
C - NIBNR: The number of inner boundary nodes of subdomain grids to be
C recorded to fort.065 and fort.066 during a full run.
C - IBNR(i): i.th inner boundary node to be recorded to fort.065 and
C fort.066
C ========================================================================
Use sizes, only : myproc
#ifdef CMPI
use global, only : nodes_lg
use mesh, only : np
Use MESSENGER
#endif
implicit none
integer :: i,j
logical :: fileFound
call setMessageSource("readFort015")
#if defined(SUBDOMAIN_TRACE) || defined(ALL_TRACE)
call allMessage(DEBUG,"Enter.")
#endif
fileFound = .false.
inquire(file=trim(globaldir)//'/'//'fort.015', Exist=fileFound)
if (fileFound.eqv..false.) then
call allMessage(ERROR,
& 'Subdomain modeling was activated but the fort.015 file '
& // ' was not found in "' // trim(globaldir) // '".')
call subdomainTerminate()
endif
if (myproc.eq.0) print *, "Subdomain Active"
open(1015, file=trim(globaldir)//'/'//'fort.015')
read(1015,*) NOUTGS
read(1015,*) NSPOOLGS
read(1015,*) enforceBN
select case(noutgs)
case(0)
! subdomain run (no b.c. recording)
case(1)
! open ocean boundary nodes:
read(1015,*) ncbnr
allocate(cbnr(ncbnr))
do i=1, ncbnr
read(1015,*) cbnr(i)
enddo
case(2)
! outer boundary nodes:
read(1015,*) nobnr
allocate(obnr(nobnr))
do i=1, nobnr
read(1015,*) obnr(i)
enddo
! inner boundary nodes:
read(1015,*) nibnr
allocate(ibnr(nibnr))
do i=1, nibnr
read(1015,*) ibnr(i)
enddo
case default
call allMessage(ERROR,'The NOUTGS value is invalid.')
call subdomainTerminate()
end select
#ifdef CMPI
! localize global record-node arrays:
select case(noutgs)
case(0)
! subdomain run (no b.c. recording)
case(1)
! open ocean boundary nodes:
localncbnr = 0
do i=1,np
if(any(cbnr.eq.nodes_lg(i))) then
localncbnr = localncbnr+1
endif
enddo
allocate( localcbnr(localncbnr))
j=1
do i=1,np
if(any(cbnr.eq.nodes_lg(i))) then
localcbnr(j) = i
j=j+1
endif
enddo
case(2)
! outer boundary nodes:
localnobnr = 0
do i=1,np
if(any(obnr.eq.nodes_lg(i))) then
localnobnr = localnobnr+1
endif
enddo
allocate( localobnr(localnobnr))
j=1
do i=1,np
if(any(obnr.eq.nodes_lg(i))) then
localobnr(j) = i
j=j+1
endif
enddo
! inner boundary nodes:
localnibnr = 0
do i=1,np
if(any(ibnr.eq.nodes_lg(i))) then
localnibnr = localnibnr+1
endif
enddo
allocate( localibnr(localnibnr))
j=1
do i=1,np
if(any(ibnr.eq.nodes_lg(i))) then
localibnr(j) = i
j=j+1
endif
enddo
case default
call allMessage(ERROR,'The NOUTGS value is invalid.')
call subdomainTerminate()
end select
#endif
#if defined(SUBPREP_TRACE) || defined(ALL_TRACE)
call allMessage(DEBUG,"Return.")
#endif
call unsetMessageSource()
END SUBROUTINE readFort015
SUBROUTINE writeFort065(it)
C | This subroutine writes ETA2, x/y velocity and wet/dry states of
C | open ocean boundary nodes of subdomain grids to fort.065 file,
C | during a full run. This subroutine is called within timestep.F
Use SIZES, only : myproc
Use GLOBAL, only : dt, rnday, eta2, uu2, vv2, nodecode
#ifdef CMPI
& , nodes_lg
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer,intent(in) :: it
integer :: i,n,gn
! open fort.065 at the first timestep
if (it.eq.1) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1065,file=procLoc//'/'//'fort.065', status='REPLACE')
write(1065,*) 'Subdomain Modeling CBN output'
write(1065,*) nspoolgs,localncbnr,int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLGS,lncbnr,tsteps"
#else
open(1065,file='fort.065',status='REPLACE')
write(1065,*) 'Subdomain Modeling CBN output'
write(1065,*) nspoolgs,ncbnr,int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLGS,ncbnr,tsteps"
#endif
close(1065)
endif
if(mod(it,NSPOOLGS).eq.0) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1065,file=procLoc//'/'//'fort.065',
& access='SEQUENTIAL', position='APPEND')
write(1065,*) it, "! Timestep"
do i=1,localncbnr
n = localcbnr(i)
gn = nodes_lg(n)
write(1065,*) gn, eta2(n), uu2(n)
write(1065,*) vv2(n), nodecode(n)
enddo
#else
open(1065,file='fort.065',access='SEQUENTIAL',
& position='APPEND')
write(1065,*) it, "! Timestep"
do i=1,ncbnr
n = cbnr(i)
write(1065,*) n, eta2(n), uu2(n)
write(1065,*) vv2(n), nodecode(n)
enddo
#endif
close(1065)
endif
END SUBROUTINE writeFort065
SUBROUTINE writeFort066(it)
C | This subroutine writes ETAS, x/y velocity and wet/dry states of
C | outer boundary nodes of subdomain grids to fort.066 file,
C | during a full run. This subroutine is called within timestep.F
Use SIZES, only : myproc
Use GLOBAL, only : dt, rnday, etas, uu2, vv2, nodecode
#ifdef CMPI
& , nodes_lg
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer,intent(in) :: it
integer :: i,n,gn
! open fort.066 at the first timestep
if (it.eq.1) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1066,file=procLoc//'/'//'fort.066', status='REPLACE')
write(1066,*) 'Subdomain Modeling OBN output'
write(1066,*) nspoolgs,localnobnr,int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLSG,lnobnr,tsteps"
#else
open(1066,file='fort.066',status='REPLACE')
write(1066,*) 'Subdomain Modeling OBN output'
write(1066,*) nspoolgs, nobnr,int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLGS,nobnr,tsteps"
#endif
close(1066)
endif
if(mod(it,NSPOOLGS).eq.0) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1066,file=procLoc//'/'//'fort.066',
& access='SEQUENTIAL', position='APPEND')
write(1066,*) it, "! Timestep"
do i=1,localnobnr
n = localobnr(i)
gn = nodes_lg(n)
write(1066,*) gn, etas(n), uu2(n)
write(1066,*) vv2(n), nodecode(n)
enddo
#else
open(1066,file='fort.066',access='SEQUENTIAL',
& position='APPEND')
write(1066,*) it, "! Timestep"
do i=1,nobnr
n = obnr(i)
write(1066,*) n, etas(n), uu2(n)
write(1066,*) vv2(n), nodecode(n)
enddo
#endif
close(1066)
endif
END SUBROUTINE writeFort066
SUBROUTINE writeFort067(it)
C | This subroutine writes ETAS of inner boundary nodes of subdomain
C | grids to fort.067 file during a full run. This subroutine is called
C | within timestep.F
Use sizes, only : myproc
Use global, only : dt, rnday, etas
#ifdef CMPI
& , nodes_lg
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer,intent(in) :: it
integer :: i,n,gn
! open fort.067 at the first timestep
if (it.eq.1) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1067,file=procLoc//'/'//'fort.067', status='REPLACE')
write(1067,*) 'Subdomain Modeling IBN output'
write(1067,*) nspoolgs,localnibnr,int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLGS,lnibnr,tsteps"
#else
open(1067,file='fort.067',status='REPLACE')
write(1067,*) 'Subdomain Modeling IBN output'
write(1067,*) nspoolgs, nibnr, int(rnday*86400/(dt*nspoolgs)),
& " ! NSPOOLGS,nibnr,tsteps"
#endif
close(1067)
endif
if(mod(it,NSPOOLGS).eq.0) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1067,file=procLoc//'/'//'fort.067',
& access='SEQUENTIAL', position='APPEND')
write(1067,*) it, "! Timestep"
do i=1,localnibnr
n = localibnr(i)
gn = nodes_lg(n)
write(1067,*) gn, etas(n)
enddo
#else
open(1067,file='fort.067',access='SEQUENTIAL',
& position='APPEND')
write(1067,*) it, "! Timestep"
do i=1,nibnr
n = ibnr(i)
write(1067,*) n, etas(n)
enddo
#endif
close(1067)
endif
END SUBROUTINE writeFort067
SUBROUTINE openFort019H(TimeLoc)
C | This subroutine opens fort.019 for a hot-started model and
C | finds the proper place in the b.c. file.
Use SIZES, only : myproc
Use GLOBAL, only : iths
USE BOUNDARIES, ONLY : neta
#ifdef CMPI
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer :: i,j,n,it,itread
REAL(8), intent(in) :: TimeLoc
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1019, file=procLoc//'/'//'fort.019')
#else
open(1019, file=trim(globaldir)//'/'//'fort.019')
#endif
read(1019,*) ! Header
read(1019,*) sbtiminc, ncbn
allocate(cbn(ncbn))
do i=1,ncbn
read(1019,*) cbn(i)
enddo
if (abs(ncbn-neta).gt.1) then
print *, "WARNING: ncbn=!neta"
print *, ncbn,neta,myproc
CALL subdomainTerminate()
endif
allocate(ecbn1(ncbn),ucbn1(ncbn),vcbn1(ncbn),wdcbn1(ncbn))
allocate(ecbn2(ncbn),ucbn2(ncbn),vcbn2(ncbn),wdcbn2(ncbn))
allocate(setEcb(ncbn),setUcb(ncbn))
allocate(setVcb(ncbn),setWDcb(ncbn))
do i=1,ncbn
ecbn1(i)=0.0
ucbn1(i)=0.0
vcbn1(i)=0.0
wdcbn1(i)=0
enddo
! Read the first set of boundary conditions:
read (1019,*) n
do i=1,ncbn
read (1019,*) n,ecbn2(i),ucbn2(i)
read (1019,*) vcbn2(i),wdcbn2(i)
wdcbn1(i)=wdcbn2(i) !ensure that the wet nodes begin wet
enddo
END SUBROUTINE openFort019H
SUBROUTINE openFort019C()
C | This subroutine opens fort.019 for a cold-started model
Use SIZES, only : myproc
USE BOUNDARIES, ONLY : neta
#ifdef CMPI
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer :: i,n
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1019, file=procLoc//'/'//'fort.019')
#else
open(1019, file=trim(globaldir)//'/'//'fort.019')
#endif
read(1019,*) ! Header
read(1019,*) sbtiminc, ncbn
allocate(cbn(ncbn))
do i=1,ncbn
read(1019,*) cbn(i)
enddo
if (abs(ncbn-neta).gt.1) then
print *, "WARNING: ncbn=!neta"
print *, ncbn,neta,myproc
CALL subdomainTerminate()
endif
allocate(ecbn1(ncbn),ucbn1(ncbn),vcbn1(ncbn),wdcbn1(ncbn))
allocate(ecbn2(ncbn),ucbn2(ncbn),vcbn2(ncbn),wdcbn2(ncbn))
allocate(setEcb(ncbn),setUcb(ncbn))
allocate(setVcb(ncbn),setWDcb(ncbn))
do i=1,ncbn
ecbn1(i)=0.0
ucbn1(i)=0.0
vcbn1(i)=0.0
wdcbn1(i)=0
enddo
! Read the first set of boundary conditions:
read (1019,*) n
do i=1,ncbn
read (1019,*) n,ecbn2(i),ucbn2(i)
read (1019,*) vcbn2(i),wdcbn2(i)
wdcbn1(i)=wdcbn2(i) !ensure that the wet nodes begin wet
enddo
END SUBROUTINE openFort019C
SUBROUTINE readFort019(it)
C | This subroutine reads in ETA2, x/y velocities and wet/dry states of
C | outer boundary nodes of the subdomain grid from fort.019 file during
C | a subdomain run. This subroutine is called within timestep.F.
Use GLOBAL, only : ihot
#ifdef CMPI
Use MESSENGER
#endif
implicit none
character(6) :: procLoc
integer,intent(in) :: it
double precision rateTS
integer :: i,n
if (it.eq.1.and.ihot.eq.0) then ! coldstart
call openFort019C()
endif
if (mod(it,sbtiminc).eq.0) then
read (1019,*) n
! print *, "Reading fort.019 at timestep",n
do i=1,ncbn
ecbn1(i) = ecbn2(i)
ucbn1(i) = ucbn2(i)
vcbn1(i) = vcbn2(i)
wdcbn1(i) = wdcbn2(i)
read (1019,*) n,ecbn2(i),ucbn2(i)
read (1019,*) vcbn2(i),wdcbn2(i)
enddo
endif
! Iteration
rateTS = mod(it,sbtiminc)/dble(sbtiminc)
do i=1,ncbn
setEcb(i) = ecbn1(i) + (ecbn2(i)-ecbn1(i))*ratets
setUcb(i) = ucbn1(i) + (ucbn2(i)-ucbn1(i))*ratets
setVcb(i) = vcbn1(i) + (vcbn2(i)-vcbn1(i))*ratets
setWDcb(i) = wdcbn1(i)
enddo
END SUBROUTINE readFort019
SUBROUTINE readFort020(it)
C | This subroutine reads in ETAS, x/y velocities and wet/dry states of
C | outer boundary nodes of the subdomain grid from fort.020 file during
C | a subdomain run. This subroutine is called within timestep.F.
Use SIZES, only : myproc
#ifdef CMPI
Use MESSENGER
#endif
implicit none
integer,intent(in) :: it
character(6) :: procLoc
integer :: i,n
if (it.eq.1) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1020, file=procLoc//'/'//'fort.020')
#else
open(1020, file=trim(globaldir)//'/'//'fort.020')
#endif
read(1020,*) ! Header
read(1020,*) sbtiminc, nobn
allocate(obn(nobn))
do i=1,nobn
read(1020,*) obn(i)
enddo
allocate(eobn2(nobn),uobn2(nobn),vobn2(nobn))
allocate(wdobn1(nobn),wdobn2(nobn))
allocate(setEob(nobn),setUob(nobn))
allocate(setVob(nobn),setWDob(nobn))
endif
!if (mod(it,sbtiminc).eq.0) then
read (1020,*) n
do i=1,nobn
wdobn1(i) = wdobn2(i)
read (1020,*) n,eobn2(i),uobn2(i)
read (1020,*) vobn2(i),wdobn2(i)
setEob(i) = eobn2(i)
setUob(i) = uobn2(i)
setVob(i) = vobn2(i)
setWDob(i) = wdobn2(i)
enddo
!endif
END SUBROUTINE readFort020
SUBROUTINE readFort021(it)
C | This subroutine reads in ETAS of inner boundary nodes of the
C | subdomain grid from fort.021 file during a subdomain run.
C | This subroutine is called within timestep.F.
Use SIZES, only : myproc
#ifdef CMPI
Use MESSENGER
#endif
implicit none
integer,intent(in) :: it
character(6) :: procLoc
integer :: i,n
if (it.eq.1) then
#ifdef CMPI
write(procLoc,'(A2,I4.4)') "PE",myproc
open(1021, file=procLoc//'/'//'fort.021')
#else
open(1021, file=trim(globaldir)//'/'//'fort.021')
#endif
read(1021,*) ! Header
read(1021,*) sbtiminc, nibn
allocate(ibn(nibn))
do i=1,nibn
read(1021,*) ibn(i)
enddo
allocate(eibn2(nibn),setEib(nibn))
endif
! if (mod(it,sbtiminc).eq.0) then
read (1021,*) n
! print *, "Reading fort.021 at timestep",n
do i=1,nibn
read (1021,*) n,eibn2(i)
setEib(i) = eibn2(i)
enddo
! endif
END SUBROUTINE readFort021
SUBROUTINE enforceEcb()
C | This subroutine enforces ETA2 of opean ocean boundary nodes
C | using setEcb array. Called within timestep.F
Use GLOBAL, only : eta2
implicit none
integer :: i,n
do i=1,ncbn
n = cbn(i)
ETA2(n) = setEcb(i)
enddo
END SUBROUTINE enforceEcb
SUBROUTINE enforceEob()
C | This subroutine enforces ETAS of outer boundary nodes
C | using setEob array. Called within timestep.F
Use GLOBAL, only : etas
implicit none
integer :: i,n
do i=1,nobn
n = obn(i)
ETAS(n) = setEob(i)
enddo
END SUBROUTINE enforceEob
SUBROUTINE enforceUVcb()
C | This subroutine enforces U and V velocities of open ocean boundary
C | nodes using setUcb and setVcb arrays. Called within timestep.F
Use GLOBAL, only : uu2, vv2
implicit none
integer :: i,n
do i=1,ncbn
n = cbn(i)
UU2(n) = setUcb(i)
VV2(n) = setVcb(i)
enddo
END SUBROUTINE enforceUVcb
SUBROUTINE enforceUVob()
C | This subroutine enforces U and V velocities of outer boundary
C | nodes using setUob and setVob arrays. Called within timestep.F
Use GLOBAL, only : uu2, vv2
implicit none
integer :: i,n
do i=1,nobn
n = obn(i)
UU2(n) = setUob(i)
VV2(n) = setVob(i)
enddo
END SUBROUTINE enforceUVob
SUBROUTINE enforceWDcb()
C | This subroutine enforces wet/dry flags of outer boundary
C | nodes using setWDcb. Called within timestep.F
Use GLOBAL, only : nnodecode
implicit none
integer :: i,n
do i=1,ncbn
n = cbn(i)
NNODECODE(n) = setWDcb(i)
enddo
END SUBROUTINE enforceWDcb
SUBROUTINE enforceWDob()
C | This subroutine enforces wet/dry flags of outer boundary
C | nodes using setWDob. Called within timestep.F
Use GLOBAL, only : nnodecode
implicit none
integer :: i,n
do i=1,nobn
n = obn(i)
NNODECODE(n) = setWDob(i)
enddo
END SUBROUTINE enforceWDob
SUBROUTINE enforceEib()
C | This subroutine enforces ETAS of inner boundary nodes
C | using setEib array. Called within timestep.F
Use GLOBAL, only : etas
implicit none
integer :: i,n
do i=1,nibn
n = ibn(i)
ETAS(n) = setEib(i)
enddo
END SUBROUTINE enforceEib
SUBROUTINE enforceGWCELVob()
C | This subroutine changes the value of the GWCE_LV vector
C | elements of the outer boundary nodes of subdomains so
C | that jcg solver leads to the enforced values of ETA for
C | the outer boundary nodes.
use sizes, only : mnei
use global, only : coef, etas, gwce_lv
use mesh, only : neitab
implicit none
integer :: i,j,n,neighbor
real(8) :: newGWCElv
do i=1,nobn
n = obn(i)
newGWCElv = 0.
do j=1,mnei
neighbor = neitab(n,j)
if (neighbor.ne.0) then
newGWCElv = newGWCElv + COEF(n,j)*ETAS(neighbor)
endif
enddo
GWCE_LV(n) = newGWCElv
enddo
END SUBROUTINE enforceGWCELVob
SUBROUTINE checkChange()
C | This subroutine checks if w/d status of any o.b.n. has changed.
C | If a change has detected, ncchange is set to 1 at the next timestep
C | to recalculate COEF of outer-inner boundary nodes
Use GLOBAL, only : ilump
#ifdef CMPI
Use MESSENGER
#endif
integer :: i
if (bchange.eq.1) then
ncchange = 1
bchange = 0
endif
do i=1,nobn
if (wdobn2(i).ne.wdobn1(i)) then
bchange = 1
endif
enddo
#ifdef CMPI
IF ( ILump.eq.0 ) THEN
call WetDrySum(NCCHANGE)
ENDIF
#endif
END SUBROUTINE checkChange
!jgf: Added this subroutine to eliminate dependence on adcirc_mod
! module, which should be built last to simplify the build system.
SUBROUTINE subdomainTerminate(NO_MPI_FINALIZE)
#ifdef CMPI
Use MESSENGER
#endif
implicit none
c
logical, optional :: no_mpi_finalize
C
call setMessageSource("subdomainTerminate")
#if defined(SUBDOMAIN_TRACE) || defined(ALL_TRACE)
call allMessage(DEBUG,"Enter.")
#endif
call allMessage(INFO,"ADCIRC Terminating.")
#ifdef CMPI
subdomainFatalError = .true.
IF (PRESENT(NO_MPI_FINALIZE)) THEN
CALL MSG_FINI(NO_MPI_FINALIZE)
ELSE
CALL MSG_FINI()
ENDIF
#endif
CALL EXIT(1)
C
#if defined(SUBDOMAIN_TRACE) || defined(ALL_TRACE)
call allMessage(DEBUG,"Return.") ! should be unreachable
#endif
call unsetMessageSource()
END SUBROUTINE subdomainTerminate
end module subdomain