-
Notifications
You must be signed in to change notification settings - Fork 0
/
refdif1v25.f
1442 lines (1277 loc) · 43.5 KB
/
refdif1v25.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
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
C FTANGLE v1.30, created with UNIX on "Thursday, June 17, 1993 at 10:46."
C COMMAND LINE: "ftangle -v refdif1v25"
C RUN TIME: "Thursday, April 13, 1995 at 10:13."
C WEB FILE: "refdif1v25.web"
C CHANGE FILE: (none)
C* 1: *
*line 120 "refdif1v25.web"
program refdif1
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 126 "refdif1v25.web"
C Constants which provide for conversion between MKS and English units on
C input and output.
dconv(1)=1.
dconv(2)=0.30488
C read control parameters and reference grid data
call inref
C read control parameters and initializing wave data
call inwave
C Pass program control to subroutine |model|.
C For each frequency component specified in |inwave|, |model| executes
Cthe model throughout the entire grid and then reinitializes the model
Cfor the next frequency.
call model
C All done. Close output data files if |open| and |close| statements are
C being used.
C |outdat|.
close(iun(3))
C |surface|.
if(fname6.NE.'')close(8)
C |angle|.
close(9)
C |refdif1.log|.
close(10)
C |height|.
close(12)
C |sxx|.
if(fname12.NE.' ')close(13)
C |sxy|.
if(fname13.NE.' ')close(14)
C |syy|.
if(fname14.NE.' ')close(15)
C |depth|.
close(16)
C |bottomu|.
if(fname7.NE.' ')close(17)
C |owave|.
if(ioutput.EQ.2)close(33)
stop
end
C* :1 *
C* 2: *
*line 307 "refdif1v25.web"
subroutine inref
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 313 "refdif1v25.web"
C Standard file name choices:
C |fname1| = |refdat.dat|, reference grid data file.
C |fname2| = |outdat.dat|, standard output data file.
C |fname3| = |subdat.dat|, user-specified subgrids.
C |fname4| = |wave.dat|, user-specified complex amplitude on row 1 (for |iinput
C| =2).
C |fname5| = |owave.dat|, complex amplitude on last row (for |ioutput| = 2).
C |fname6| = |surface.dat|, instantaneous water surface at computational
Cresolution.
C |fname7| = |bottomu.dat|, magnitude of bottom velocity at reference grid
C points.
C |fname8| = |angle.dat|, wave directions at reference grid points.
C |fname9| = not used yet.
C |fname10| = |refdif1.log|, run log for |refdif1| program.
C |fname11| = |height.dat|, wave heights at reference grid locations.
C |fname12| = |sxx.dat|, Sxx components at reference grid locations.
C |fname13| = |sxy.dat|, Sxy components at reference grid locations.
C |fname14| = |syy.dat|, Syy components at reference grid locations.
C |fname15| = |depth.dat|, tide-corrected depths at reference grid locations.
C
C |fnamein| = |indat.dat|, input namelist file.
namelist/ingrid/mr,nr,iu,ntype,icur,ibc,dxr,dyr,dt,ispace,nd,iff,i
&sp,iinput,ioutput/inmd/md/fnames/fname1,fname2,fname3,fname4,fname
&5,fname6,fname7,fname8,fname9,fname10,fname11,fname12,fname13,fnam
&e14,fname15
C Constants.
g=9.80621
C* :2 *
C* 3: *
*line 403 "refdif1v25.web"
call infile(fnamein)
iun(5)=5
open(unit=iun(5),file=fnamein,status='old')
C* :3 *
C* 4: *
*line 412 "refdif1v25.web"
iun(1)=1
iun(2)=2
iun(3)=3
read(iun(5),nml=fnames)
open(unit=iun(1),file=fname1,status='old')
open(unit=iun(3),file=fname2)
open(9,file=fname8)
open(10,file=fname10)
open(12,file=fname11)
if(fname12.NE.' '.AND.fname13.NE.' '.AND.fname14.NE.' ')then
open(13,file=fname12)
open(14,file=fname13)
open(15,file=fname14)
endif
open(16,file=fname15)
if(fname7.NE.' ')open(17,file=fname7)
if(fname6.NE.' ')open(8,file=fname6)
C print headers on output
write(10,120)
write(10,106)
C Read control data from unit |iun(5)|.
read(iun(5),nml=ingrid)
if(ispace.EQ.1)read(iun(5),nml=inmd)
write(10,107)mr,nr,dxr,dyr
if(iu.EQ.1)write(10,114)iu
if(iu.EQ.2)write(10,115)iu
if(icur.EQ.0)write(10,200)
if(icur.EQ.1)write(10,201)
if(ibc.EQ.0)write(10,202)
if(ibc.EQ.1)write(10,203)
if(ispace.EQ.0)write(10,108)
if(ispace.EQ.1)write(10,109)
write(10,119)nd
if(ntype.EQ.0)write(10,110)
if(ntype.EQ.1)write(10,111)
if(ntype.EQ.2)write(10,112)
C Check input from unit |iun(5)|.
if((mr.GT.ixr).OR.(nr.GT.iyr))then
write(10,*)'dimensions for reference grid too large, stopping'
call exit(1)
end if
if((iu.NE.1).AND.(iu.NE.2))iu=1
dt=dt*dconv(iu)
dxr=dxr*dconv(iu)
dyr=dyr*dconv(iu)
if(dt.EQ.0.)dt=2.
if(nd.GT.ifix(float(iy-1)/float(nr-1)))then
write(10,102)
call exit(1)
endif
if(ispace.EQ.1)then
test=0.
do 1 i=1,mr-1
if(md(i).GT.(ix-1))then
write(10,103)i
test=1.
endif
1 continue
if(test.EQ.1.)call exit(1)
endif
C read depth grid and velocities from unit iun(1)
do 2 i=1,mr
read(iun(1),101)(dr(i,j),j=1,nr)
2 continue
if(icur.EQ.1)then
do 3 i=1,mr
read(iun(1),101)(ur(i,j),j=1,nr)
3 continue
do 4 i=1,mr
read(iun(1),101)(vr(i,j),j=1,nr)
4 continue
endif
C convert depth and currents
do 5 i=1,mr
do 5 j=1,nr
dr(i,j)=dr(i,j)*dconv(iu)
5 continue
if(icur.EQ.1)then
do 55 i=1,mr
do 55 j=1,nr
ur(i,j)=ur(i,j)*dconv(iu)
vr(i,j)=vr(i,j)*dconv(iu)
55 continue
endif
C check for large depth changes and large currents in reference grid data.
C
do 6 i=2,mr-1
do 6 j=2,nr-1
dcheck=(dr(i+1,j)+dr(i-1,j)+dr(i,j-1)+dr(i,j+1))/4.
if(abs(dcheck-dr(i,j)).GT.dt)write(10,104)dr(i,j),i,j,dt
6 continue
if(icur.EQ.1)then
do 7 i=1,mr
do 7 j=1,nr
if(dr(i,j).LE.0.0)go to 7
fr=(ur(i,j)*ur(i,j)+vr(i,j)*vr(i,j))/(g*dr(i,j))
if(fr.GT.1.)write(10,105)i,j,fr
7 continue
endif
C Establish coordinates for reference grid.
do 8 ir=1,mr
xr(ir)=float(ir-1)*dxr
8 continue
do 9 jr=1,nr
yr(jr)=float(jr-1)*dyr
9 continue
C Establish |y| coordinates for interpolated grid.
n=nd*(nr-1)+1
dy=dyr/float(nd)
do 10 j=1,n
y(j)=float(j-1)*dy
10 continue
C Write grid information on output unit |iun(3)|.
write(iun(3),*)nr,mr
write(iun(3),*)(yr(jr)/dconv(iu),jr=1,nr)
C Check friction values.
C |iff(1)=1|, turbulent boundary layer damping everywhere
C |iff(2)=1|, porous bottom damping everywhere
C |iff(3)=1|, laminar boundary layer damping everywhere
do 11 i=1,3
if((iff(i).NE.0).AND.(iff(i).NE.1))iff(i)=0
11 continue
write(10,116)(iff(i),i=1,3)
C Specify whether or not user specified subgrids are to be read in during
C model operation.
C |isp=0|, no subgrids specified
C |isp=1|, subgrids to be read in later from unit |iun(2)|
if(isp.EQ.0)write(10,117)
if(isp.EQ.1)then
write(10,118)
open(unit=iun(2),file=fname3,status='old')
endif
if((isp.EQ.1).AND.(ispace.EQ.0))write(10,113)
if(isp.EQ.0)then
do 14 ir=1,mr
do 14 jr=1,nr
isd(ir,jr)=0
14 continue
else
do 15 ir=1,mr-1
read(iun(2),100)(isd(ir,jr),jr=1,nr-1)
15 continue
endif
C Input done, return to main program.
return
100 format(15i4)
101 format(20f10.4)
102 format(' y-direction subdivision too fine.'/' maximum number of y
&grid points will be exceeded.'/' execution terminating.')
103 format(' x-direction subdivision too fine on grid block',2x,i3/' e
&xecution terminating')
104 format(' depth',2x,f7.2,'(m) at reference grid location',2(2x,i3)/
&' differs from the average of its neighbors by',' more than',2x,f7
&.2,'(m).'/' execution continuing')
105 format(' ambient current at reference grid location',2(2x,i3),' is
& supercritical with froude number =',f7.4/' execution continuing')
106 format('0'///20x,'input section, reference grid values'///)
107 format(' reference grid dimensions mr=',i3/'
& nr=',i3///' reference grid spacings dxr=',f8.4/'
& dyr=',f8.4)
108 format(' '/' ispace =0 chosen, program will attempt its own ','ref
&erence grid subdivisions')
109 format(' '/' ispace =1 chosen, subdivision spacings will be',' inp
&ut as data')
110 format(' '/' ntype = 0, linear model')
111 format(' '/' ntype = 1, stokes model matched to hedges model')
112 format(' '/' ntype = 2, stokes model')
113 format(' warning: input specifies that user will be supplying',' s
&pecified subgrids (isp=1),'/' while program has been told to gener
&ate its own subgrid',' spacings (ispace=0).'/' possible incompatib
&ility in any or all subgrid blocks')
114 format(' '/' physical unit switch iu=',i1,', input in mks units')
115 format(' '/' physical unit switch iu=',i1,', input in english uni
&ts')
116 format(' '//' switches for dissipation terms'//' ',i1,' turbul
&ent boundary layer'/' ',i1,' porous bottom'/' ',i1,' laminar b
&oundary layer')
120 format(//////20x,'Refraction-Diffraction Model for'/20x,'Weakly No
&nlinear Surface Water Waves'///20x,'REF/DIF 1, Version 2.5'///20x
&,'Center for Applied Coastal Research'/20x,'Department of Civil En
&gineering'/20x,'University of Delaware'/20x,'Newark, Delaware 1971
&6'///10x,'James T. Kirby and Robert A. Dalrymple, November 1994')
117 format(' '/' isp=0, no user defined subgrids')
118 format(' '/' isp=1, user defined subgrids to be read')
119 format(' '/' y-direction subdivision according to nd=',i3)
200 format(' '/' icur=0, no current values read from input files')
201 format(' '/' icur=1, current values read from data files')
202 format(' '/' ibc=0, closed (reflective) lateral boundaries')
203 format(' '/' ibc=1, open lateral boundaries')
end
C* :4 *
C* 5: *
*line 756 "refdif1v25.web"
subroutine inwave
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 762 "refdif1v25.web"
namelist/waves1a/iwave,nfreqs/waves1b/freqs,tide,nwavs,amp,dir/wav
&es1c/thet0,freqs,tide,edens,nwavs,nseed/waves2/freqin,tidein
pi=3.1415927
C Values of |iinput|, |ioutput| already entered in namelist statement in
C|inref|.
if((iinput.NE.1).AND.(iinput.NE.2))then
write(10,*)' invalid value chosen for iinput, check indat.dat'
stop
endif
if((ioutput.NE.1).AND.(ioutput.NE.2))then
write(10,*)' invalid value chosen for ioutput, check indat.dat'
stop
endif
if(ioutput.EQ.2)then
open(33,file=fname5)
endif
if(iinput.EQ.1)then
write(10,*)' iinput = 1, program specifies initial row of a'
C Enter |iwave|, |nfreqs| for |iinput = 1|.
read(iun(5),nml=waves1a)
write(10,102)
C Enter data for case of |iinput=1, iwave=1|.
if(iwave.EQ.1)then
read(iun(5),nml=waves1b)
write(10,103)
endif
C Enter data for case of |iinput=1, iwave=2|.
if(iwave.EQ.2)then
read(iun(5),nml=waves1c)
write(10,104)
endif
write(10,105)nfreqs
if(iwave.EQ.2)then
thet0=thet0*pi/180.
endif
C For each frequency, enter the wave period and tidal offset.
do 3 ifreq=1,nfreqs
write(10,107)ifreq,freqs(ifreq),tide(ifreq)
C Convert angles to radians.
freqs(ifreq)=2.*pi/freqs(ifreq)
tide(ifreq)=tide(ifreq)*dconv(iu)
C If |iwave = 1|, read the number of discrete components.
if(iwave.EQ.1)then
do 1 iwavs=1,nwavs(ifreq)
write(10,106)iwavs,amp(ifreq,iwavs),dir(ifreq,iwavs)
dir(ifreq,iwavs)=dir(ifreq,iwavs)*pi/180.
amp(ifreq,iwavs)=amp(ifreq,iwavs)*dconv(iu)
1 continue
endif
C If |iwave = 2|, read the parameters for each frequency.
if(iwave.EQ.2)then
seed=float(nseed)/9999.
write(10,108)edens(ifreq),nwavs(ifreq),nseed
dir(ifreq,1)=thet0
edens(ifreq)=edens(ifreq)*(dconv(iu)**2.)
endif
3 continue
endif
C If |iinput = 2|, read in wave period and tidal offset.
if(iinput.EQ.2)then
read(iun(5),nml=waves2)
freqs(1)=freqin
tide(1)=tidein
write(10,*)' iinput = 2, user specifies a in wave.dat'
nfreqs=1
write(10,102)
write(10,*)' wave period =',freqs(1),' sec.'
write(10,*)' tidal offset=',tide(1)
freqs(1)=2.*pi/freqs(1)
tide(1)=tide(1)*dconv(iu)
endif
return
100 format(15i4)
101 format(20f10.4)
102 format('1'///20x,' input section, wave data values'///)
103 format(' '///' iwave=1, discrete wave amps and directions')
104 format(' '///' iwave=2, directional spreading model chosen')
105 format(' '///' the model is to be run for',i3,' separate',' freque
&ncy components')
106 format(' '/' wave component ',i2,', amplitude =',f8.4,', direction
&=',f8.4)
107 format(' '//' frequency component ',i2//' wave period=',f8.4,'sec.
&, tidal offset=',f8.4)
108 format(' '/' total variance density =',f8.4,', spreading factor
& n=',i2,' seed number =',i5)
end
C* :5 *
C* 6: *
*line 937 "refdif1v25.web"
subroutine model
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 943 "refdif1v25.web"
dimension dthi(31),thi(31),thet(iy)
integer seed
C Constants.
g=9.80621
rho=1000.
pi=3.1415927
eps=1.0e-05
C Execute model once for each frequency.
C |ifreq| is the controlling index value.
do 200 ifreq=1,nfreqs
psibar=0.
write(10,203)ifreq
C Specify initial nonlinear parameters for each run.
if(ntype.EQ.0)an=0.
if(ntype.NE.0)an=1.
if(ntype.NE.2)anl=0.
if(ntype.EQ.2)anl=1.
C Calculate the mean |kb| on the first row, for use in specifying initial cond
Citions.
npts=0
sumk=0.
do 10 jr=1,nr
d(1,jr)=dr(1,jr)+tide(ifreq)
call wvnum(d(1,jr),ur(1,jr),freqs(ifreq),k(1,jr),eps,icdw,1,1)
if(d(1,jr).GT.0.05)then
sumk=sumk+k(1,jr)
npts=npts+1
endif
10 continue
kb(1)=sumk/float(npts)
C Establish initial wave conditions for the |ifreq| frequency
if(iinput.EQ.1)then
C Compute wave from data given in |indat.dat|.
if(iwave.EQ.1)then
C |iwave.eq.1|, discrete components specified.
do 3 j=1,n
a(1,j)=cmplx(0.,0.)
do 2 iwavs=1,nwavs(ifreq)
thet(j)=dir(ifreq,iwavs)*180./pi
a(1,j)=a(1,j)+amp(ifreq,iwavs)*cexp(cmplx(0.,kb(1)*sin(dir(ifreq,i
&wavs))*y(j)))
2 continue
3 continue
write(9,202)(thet(j),j=1,n,nd)
else
C |iwave.eq.2|, directional spreading model.
sp=float(nwavs(ifreq))
nsp=nwavs(ifreq)
thmax=pi/4.
call acalc(thmax,nsp,a1)
edens(ifreq)=sqrt(edens(ifreq)/a1)
nn=31
ii=(nn-1)/2+1
seed=rand(seed)
C Compute randomly distributed $\Delta\theta$'s.
sum0=0.
do 12 i=1,nn
seed=rand(seed)
dthi(i)=seed
sum0=sum0+seed
12 continue
xnorm=2.*thmax/sum0
do 101 i=1,nn
dthi(i)=dthi(i)*xnorm
101 continue
thi0=-thmax
do 4 i=1,nn
thi0=thi0+dthi(i)
thi(i)=thi0-dthi(i)/2.
dth=dthi(i)
amp(ifreq,i)=edens(ifreq)*sqrt(dth)*sqrt(cos(thi(i)+dth/2.)**(2*ns
&p)+cos(thi(i)-dth/2.)**(2*nsp))
4 continue
do 5 i=1,nn
ip1=i+1
seed=rand(seed)
dir(ifreq,ip1)=2.*pi*seed/100.
5 continue
do 7 j=1,n
a(1,j)=cmplx(0.,0.)
do 6 i=1,nn
a(1,j)=a(1,j)+amp(ifreq,i)*cexp(cmplx(0.,kb(1)*sin(thi(i)-thet0)*y
&(j)+dir(ifreq,i+1)))*2.
6 continue
7 continue
endif
endif
C If |iinput=2|, read |a| from data file |fname4|.
if(iinput.EQ.2)then
open(11,file=fname4)
read(11,*)(a(1,j),j=1,n)
close(11)
endif
C Store first row of wave heights on unit 12.
write(12,202)(2*cabs(a(1,j))/dconv(iu),j=1,n,nd)
C If |fname6| not null, store surface on file |fname6|.
x(1)=0
if(fname6.NE.' ')then
write(8,*)n
write(8,*)(y(j),j=1,n)
write(8,*)x(1)
write(8,*)(real(a(1,j)),j=1,n)
endif
C Now execute model for the |ifreq| frequency over each of |mr| grid bloc
Cks. |ir| is the controlling index value.
do 100 ir=1,(mr-1)
C Establish interpolated grid block for segment |ir|.
call grid(ifreq,ir)
C If |ir=1| write initial values on |iun(3)|.
if(ir.EQ.1)then
write(10,201)x(1)/dconv(iu),psibar
write(iun(3),*)x(1)/dconv(iu),psibar
write(iun(3),*)(a(1,j)/dconv(iu),j=1,n,nd)
write(16,202)(d(1,j)/dconv(iu),j=1,n,nd)
endif
C Calculate constants for each grid block.
call con(ifreq,ir)
C Perform finite difference calculations.
call fdcalc(ifreq,ir)
C Grid block |ir| done, print output and go to next grid.
100 continue
if(ioutput.EQ.2)then
write(33,*)(a(m,j),j=1,n)
endif
C Termination for the |surface.dat| file.
if(fname6.NE.' ')then
x(1)=-100.
write(8,*)x(1)
endif
C Model complete for the |ifreq| frequency component, go to the next frequency
C component.
200 continue
C Runs completed for all frequencies. Return to end of main program.
return
201 format(' x=',f10.2,' psibar=',f20.4)
202 format(' ',200(f10.4))
203 format('1',20x,'model execution, frequency',' component',i4//)
end
C* :6 *
C* 7: *
*line 1178 "refdif1v25.web"
subroutine grid(ifreq,ir)
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 1184 "refdif1v25.web"
C Constants.
pi=3.1415927
eps=1.0e-05
C Perform $y$-interpolation on reference grid.
C Interpolate first row.
do 10 j=1,n,nd
d(1,j)=dr(ir,((j-1)/nd+1))
u(1,j)=ur(ir,((j-1)/nd+1))
v(1,j)=vr(ir,((j-1)/nd+1))
10 continue
do 12 jj=2,nr
do 11 j=1,(nd-1)
jjj=nd*(jj-2)+(j+1)
d(1,jjj)=(dr(ir,jj)-dr(ir,jj-1))*y(jjj)/dyr+(yr(jj)*dr(ir,jj-1)-yr
&(jj-1)*dr(ir,jj))/dyr
u(1,jjj)=(ur(ir,jj)-ur(ir,jj-1))*y(jjj)/dyr+(yr(jj)*ur(ir,jj-1)-yr
&(jj-1)*ur(ir,jj))/dyr
v(1,jjj)=(vr(ir,jj)-vr(ir,jj-1))*y(jjj)/dyr+(yr(jj)*vr(ir,jj-1)-yr
&(jj-1)*vr(ir,jj))/dyr
11 continue
12 continue
C Set number of $x$ points and define $x$ values.
if(ispace.EQ.0)then
C |ispace=0|, program sets subdivisions.
do 13 j=1,n
dref=d(1,j)+tide(ifreq)
if(dref.LT.0.001)dref=0.001
call wvnum(dref,u(1,j),freqs(ifreq),k(1,j),eps,icdw,1,j)
13 continue
npts=0
sumk=0.
do 14 j=1,n
if(d(1,j).GT.0.05)then
sumk=sumk+k(1,j)
npts=npts+1
endif
14 continue
kb(1)=sumk/float(npts)
alw=2.*pi/kb(1)
anw=dxr/alw
np=ifix(5.*anw)
if(np.LT.1)np=1
md(ir)=min((ix-1),np)
if(np.GT.(ix-1))write(10,100)ir
endif
C |ispace=1|, user specified subdivision.
m=md(ir)+1
dx=dxr/float(md(ir))
do 15 i=1,m
x(i)=xr(ir)+float(i-1)*dx
15 continue
C interpolate values on |m| row.
do 16 j=1,n,nd
d(m,j)=dr(ir+1,((j-1)/nd+1))
u(m,j)=ur(ir+1,((j-1)/nd+1))
v(m,j)=vr(ir+1,((j-1)/nd+1))
16 continue
do 18 jj=2,nr
do 17 j=1,(nd-1)
jjj=nd*(jj-2)+(j+1)
d(m,jjj)=(dr(ir+1,jj)-dr(ir+1,jj-1))*y(jjj)/dyr+(yr(jj)*dr(ir+1,jj
&-1)-yr(jj-1)*dr(ir+1,jj))/dyr
u(m,jjj)=(ur(ir+1,jj)-ur(ir+1,jj-1))*y(jjj)/dyr+(yr(jj)*ur(ir+1,jj
&-1)-yr(jj-1)*ur(ir+1,jj))/dyr
v(m,jjj)=(vr(ir+1,jj)-vr(ir+1,jj-1))*y(jjj)/dyr+(yr(jj)*vr(ir+1,jj
&-1)-yr(jj-1)*vr(ir+1,jj))/dyr
17 continue
18 continue
C interpolate values in |x|-direction
do 19 i=2,m-1
do 19 j=1,n
d(i,j)=(d(m,j)-d(1,j))*x(i)/dxr+(x(m)*d(1,j)-x(1)*d(m,j))/dxr
u(i,j)=(u(m,j)-u(1,j))*x(i)/dxr+(x(m)*u(1,j)-x(1)*u(m,j))/dxr
v(i,j)=(v(m,j)-v(1,j))*x(i)/dxr+(x(m)*v(1,j)-x(1)*v(m,j))/dxr
19 continue
C Add in user specified grid subdivisions (read from unit |iun(2)|).
do 30 jr=1,nr-1
if(isd(ir,jr).EQ.1)then
js=nd*jr+(1-nd)
jf=js+nd
read(iun(2),101)((d(i,j),j=js,jf),i=1,m)
if(icur.EQ.1)then
read(iun(2),101)((u(i,j),j=js,jf),i=1,m)
read(iun(2),101)((v(i,j),j=js,jf),i=1,m)
endif
do 31 i=1,m
do 31 j=js,jf
d(i,j)=d(i,j)*dconv(iu)
u(i,j)=u(i,j)*dconv(iu)
v(i,j)=v(i,j)*dconv(iu)
31 continue
end if
30 continue
C Add tidal offset to all rows and establish thin film.
do 20 i=1,m
do 20 j=1,n
d(i,j)=d(i,j)+tide(ifreq)
if(d(i,j).LT.0.001)d(i,j)=0.001
20 continue
C Interpolation complete, return to |model|.
return
100 format(' model tried to put more spaces than allowed in',' grid bl
&ock ',i3)
101 format(20f10.4)
end
C* :7 *
C* 8: *
*line 1350 "refdif1v25.web"
subroutine con(ifreq,ir)
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 1355 "refdif1v25.web"
C Constants.
eps=1.0e-05
g=9.80621
C Calculate constants.
do 1 i=1,m
do 1 j=1,n
call wvnum(d(i,j),u(i,j),freqs(ifreq),k(i,j),eps,icdw,i,j)
sig(i,j)=freqs(ifreq)-k(i,j)*u(i,j)
akd=k(i,j)*d(i,j)
q(i,j)=(1.+akd/(sinh(akd)*cosh(akd)))/2.
p(i,j)=q(i,j)*g*tanh(akd)/k(i,j)
dd(i,j)=(cosh(4.*akd)+8.-2.*(tanh(akd)**2))/(8.*(sinh(akd)**4.))
bottomu(i,j)=g*k(i,j)/(2*freqs(ifreq)*cosh(akd))
1 continue
C Calculate the dissipation term |w|.
call diss
C Calculate the mean |kb| on each row.
do 11 i=1,m
npts=0
sumk=0.
do 10 j=1,n
if(d(i,j).GT.0.05)then
sumk=sumk+k(i,j)
npts=npts+1
endif
10 continue
if(npts.EQ.0)then
kb(i)=k(i,1)
else
kb(i)=sumk/float(npts)
endif
11 continue
return
end
C* :8 *
C* 9: *
*line 1448 "refdif1v25.web"
subroutine fdcalc(ifreq,ir)
include 'param.h'
C* 18: *
*line 2222 "refdif1v25.web"
common/ref1/mr,nr,ispace,nd,md(ixr),iu,dconv(2),iff(3),icur,ibc
common/ref2/dr(ixr,iyr),ur(ixr,iyr),vr(ixr,iyr),iun(8),iinput,iout
&put
common/ref3/dxr,dyr,xr(ixr),yr(iyr),x(ix),y(iy)
common/ref4/isd(ixr,iyr)
common/block1/d(ix,iy),u(ix,iy),v(ix,iy),m,n,dx,dy,ibr(iy)
common/con1/q(ix,iy),p(ix,iy),sig(ix,iy),bottomu(ix,iy)
common/con2/k(ix,iy),kb(ix),w(ix,iy),dd(ix,iy),wb(2,iy)
common/nlin/an,anl,ntype
common/wav1/iwave,nfreqs,freqs(ncomp),edens(ncomp),nwavs(ncomp)
common/wav2/amp(ncomp,ncomp),dir(ncomp,ncomp),tide(ncomp),seed,the
&t0
common/comp/a(ix,iy),psibar,ifilt
common/names/fname1,fname2,fname3,fname4,fname5,fname6,fname7,fnam
&e8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
real k,kb
complex w,a,wb
character*255 fname1,fname2,fname3,fname4,fname5,fname6,fname7,fna
&me8,fname9,fname10,fname11,fname12,fname13,fname14,fname15,fnamein
C* :18 *
*line 1454 "refdif1v25.web"
real kap,ksth1,ksth2
complex c1,c2,c3,cp1,cp2,cp3,ci,damp
complex ac(iy),bc(iy),cc(iy),rhs(iy),sol(iy)
dimension thet(iy),urs(iy)
C* 10: *
*line 1800 "refdif1v25.web"
cg(i,j)=sqrt(p(i,j)*q(i,j))
pv(i,j)=p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