-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwwm_snl4_tsa.F90.aron
2986 lines (2958 loc) · 134 KB
/
wwm_snl4_tsa.F90.aron
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
!!
MODULE W3SNLXMD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 29-May-2009 |
!/ +-----------------------------------+
!/
!/ 20-Dec-2004 : Origination. ( version 3.06 )
!/ 23-Jun-2006 : Formatted for submitting code for ( version 3.09 )
!/ inclusion in WAVEWATCH III.
!/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
!/
!/ Copyright 2009 National Weather Service (NWS),
!/ National Oceanic and Atmospheric Administration. All rights
!/ reserved. WAVEWATCH III is a trademark of the NWS.
!/ No unauthorized use without permission.
!!
!! -----------------------------------------------------------------#
!! !
!! Generic shallow-water Boltzmann integral for !
!! "read-in" log-spaced E(f,theta) plus TSA estimate !
!! passed in from ww3 log-spaced action spectrum A(theta,k) !
!! !
!! This is a new program for wave-wave interactions (TSA or FBI) !
!! This is the time-stepping version. !
!! !
!! -----------------------------------------------------------------!
!! !
!! Nov. 2010; It was blended inside WAVEWATCH III ver. 3.14 !
!! by Bash Toulany !
!! -----------------------------------------------------------------!
!! !
!! March/April 2005 added two-scale analysis !
!! !
!! February/March 2004 - fiddled with by Redwing !
!! !
!! March 2003 version !
!! !
!! This is Resio version of the Boltzmann code as of March 2003. !
!! It should contain all changes/mods from Tracy's version. !
!! !
!! Computes over the full-circle, and includes fluxes. !
!! !
!! Runs best on Thursdays; !
!! usually doesn't work too well on Fridays !
!! !
!! !
!! S h a l l o w - W a t e r B o l t z m a n n C o d e !
!! !
!! !
!! -----------------------------------------------------------------!
!! !
!! The included file 'parfile_2.f' (below) contains just !
!! parameters that sets the dimensions nrng, nang, npts and NZZ !
!! for some arrays (below) !
!! !
!! parameters in 'parfile_2.f' are: !
!! nrng = 67 = maximum number of rings !
!! nang = 36 = maximum number of angles !
!! npts = 30 = maximum number of points around locus !
!! NZZ = 2278 = NZZ = (nrng*(nrng+1))/2 !
!! !
!a include 'parfile_2.f'
!! !
!! -----------------------------------------------------------------#
!!
!!------------------------------------------------------------------------------
!!--------------------------------------------------------------------72------80
!!==============================================================================
!!
!! 1. Purpose :
!! Interface module for TSA type nonlinear interactions.
!! Based on Resio and Perrie (2008) and Perrie and Resio (2009)
!!
!! 2. Variables and types :
!!
!! Name Type Scope Description
!! ------------------------------------------------------------------
!! ------------------------------------------------------------------
!!
!! 3. Subroutines and functions :
!!
!! Name Type Scope Description
!! ------------------------------------------------------------------
!! W3SNLX Subr. Public Main interface for TSA subroutines.
!! Replaces main program "sboltz" in
!! "sbtsa-1-norm-Dec15-08.f" with
!! initialization done in subr. INSNLX
!! INSNLX Subr. Public Corresponding initialization routine.
!!
!!
!! TSA subroutines
!! ---------------
!! gridsetr Subr. Public Setup geometric integration grid
!! shlocr Subr. Public General locus solution
!! shloxr Subr. Public Locus solving routine - must converges
!! cplshr Subr. Public Computes Boltzmann coupling coeff.
!! ------
!! optsa Subr. Public Converts Cart. Energy density (f,theta)
!! to Polar Action density (k,theta)
!! then split it into large and small scale
!! snlr Subr. Public Computes dN(k,theta)/dt due to
!! ------ wave-wave inter.
!!
!! cgf fnc. Public Calculate group velocity "cgf" (m/s)
!! from frequency "f" (Hz), phase speed
!! "c" (m/s) and water depth "d" (m)
!! wkfnc fnc. Public Compute wave number "k" for given
!! ----- freq "f" (Hz) and water depth "d" (m)
!! ------------------------------------------------------------------
!!
!! 4. Subroutines and functions used :
!!
!! Name Type Module Description
!! ------------------------------------------------------------------
!! STRACE Subr. W3SERVMD Subroutine tracing.
!! ------------------------------------------------------------------
!!
PUBLIC
!!
integer, allocatable, dimension(:,:,:) :: kref2, kref4 !* /fr/
integer, allocatable, dimension(:,:,:) :: jref2, jref4 !* /fr/
real, allocatable, dimension(:,:,:) :: wtk2, wtk4 !* /fr/
real, allocatable, dimension(:,:,:) :: wta2, wta4 !* /fr/
real, allocatable, dimension(:,:,:) :: tfac2, tfac4 !* /fr/
real, allocatable, dimension(:,:,:) :: grad !* /dn/
real, allocatable, dimension(:) :: wk2x, wk2y !* /a/
real, allocatable, dimension(:) :: wk4x, wk4y, ds !* /a/
real, allocatable, dimension(:,:) :: dens, dens2 !* /c/ /z/
real, allocatable, dimension(:,:) :: tsa, diag
real, allocatable, dimension(:,:) :: fbi, diag2
!!
CONTAINS
!! ------------------------------------------------------------------
SUBROUTINE INSNLX
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 23-Jun-2006 |
!/ +-----------------------------------+
!/
!/ 20-Dec-2004 : Origination. ( version 3.06 )
!/ 23-Jun-2006 : Origination. ( version 3.09 )
!/
! 1. Purpose :
!
! Initialization for source term routine.
!
! 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
! ----------------------------------------------------------------
! W3SNLX Subr. W3SNLXMD Corresponding source term.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! !/S Enable subroutine tracing.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
#ifdef WW3_TSA
USE W3ODATMD, ONLY: NDSE
USE W3SERVMD, ONLY: EXTCDE
#endif
!/
IMPLICIT NONE
!/
END SUBROUTINE INSNLX
!! --------------------------------------------------------------- &
SUBROUTINE W3SNLX ( A, CG, WN, DEPTH, S, D )
!! --------------------------------------------------------------- &
!!
!! 1. Purpose :
!!
!! Interface module for TSA type nonlinear interactions.
!! Based on Resio and Perrie (2008) and Perrie and Resio (2009)
!!
!! 2. Method :
!!
!! 3. Parameters :
!!
!! Parameter list
!! ------------------------------------------------------------------
!! A R.A. I Action spectrum A(NTH,NK) as a function of
!! direction (rad) and wavenumber.
!! CG R.A. I Group velocities (dimension NK=nrng).
!! WN R.A. I Wavenumbers (dimension NK=nrng).
!! DEPTH Real I Water depth in meters.
!! NZZ Int. I NZZ = (NK*(NK+1))/2
!! S R.A. O Source term.
!! D R.A. O Diagonal term of derivative.
!! ------------------------------------------------------------------
!!
!! 4. Subroutines used :
!!
!! Name Type Module Description
!! ------------------------------------------------------------------
!! STRACE Subr. W3SERVMD Subroutine tracing.
!! ------------------------------------------------------------------
!!
!! 5. Called by :
!!
!! Name Type Module Description
!! ------------------------------------------------------------------
!! W3SRCE Subr. W3SRCEMD Source term integration.
!! W3EXPO Subr. N/A Point output post-processor.
!! GXEXPO Subr. N/A GrADS point output post-processor.
!! ------------------------------------------------------------------
!!
!! 6. Error messages :
!!
!! None.
!!
!! 7. Remarks :
!!
!! 8. Structure :
!!
!! See source code.
!!
!! 9. Switches :
!!
!! !/S Enable subroutine tracing.
!!
!!10. Source code :
!!
!! ==================================================================
!!
#ifdef WW3_TSA
USE CONSTANTS, ONLY: TPI
USE W3GDATMD, ONLY: NK, NTH, XFR, DTH, SIG, TH, ECOS, ESIN
USE W3SERVMD, ONLY: EXTCDE
#else
USE DATAPOOL, ONLY: &
& NK => MSC, &
& NTH => MDC, &
& TPI => PI2, &
& XFR => SFAC, &
& SIG => SPSIG, &
& DTH => DDIR, &
& TH => SPDIR, &
& ECOS => COSTH, &
& ESIN => SINTH, &
& rkind
#endif
!!
IMPLICIT NONE
REAL(rkind), INTENT(IN) :: A(NTH,NK), CG(NK), WN(NK), DEPTH
REAL(rkind), INTENT(OUT) :: S(NTH,NK), D(NTH,NK)
!!
LOGICAL, SAVE :: FIRST_TSA
!!
!! Local Parameters
!!
integer :: nrng, nang, npts, nzz
integer :: npk !* re-calculated npk
real :: fpk !* re-calculated fpk
real :: dep !* get it from WW3 DEPTH
real :: dfrq !* get it from WW3 XFR
real :: ef2(NK,NTH) !* Cartesian Energy(f,theta) get it from WW3 A(NTH,NK) formely /enrgy/
!!
!! Local variables
!!
integer :: irng,iang, ierr_gr
real :: twopi !* get it from WW3 TPI
real :: f0 !* get it from WW3 oma(1)
real :: delfx !* multiplier for bandwidth
real :: ainc !* get it from WW3 DTH
real :: fac
real :: dwka(NK) !* k*dk*dtheta
real :: ef1(NK) !* 1D Energy
real :: e1max, e1sum, h1sig
integer :: npk2 !* bin# of second peak freq.
integer :: nsep !* # of bins that separates npk & npk2
integer :: nbins !* min # of bins > npk or npk2
integer :: nbins1 !* actual # of bins > npk or npk2
integer :: npeaks !* # of peaks (=0, 1, or 2)
integer :: nfs, nfs2 !* bin# of freq. separation
integer :: nfrq !* # of bin per freq. regime
real :: fpk2 !* second peak freq.
real :: e1max2 !* 1D energy at fpk2
real :: sumd1 !* sum dens+dens2 at nfs
real :: sumd2 !* sum dens+dens2 at nfs+1
real :: densat1 !* averaged dens at nfs
real :: densat2 !* averaged dens at nfs+1
real :: dens2sum !* dbl-sum dens2
real :: dens1sum !* dbl-sum dens
real :: dens2ov1 !* ratio of dens2sum/dens1sum
#ifdef PRINT_1
!prt real :: fbia1(NK,NTH), tsaa1(NK,NTH), afac1
!prt real :: fbia2(NK,NTH), tsaa2(NK,NTH), afac2
!prt real :: fbia3(NK,NTH), tsaa3(NK,NTH), afac3
!prt real :: fbia4(NK,NTH), tsaa4(NK,NTH), afac4
!prt real :: fbie1(NK,NTH), tsae1(NK,NTH), efac1
!prt real :: fbie2(NK,NTH), tsae2(NK,NTH), efac2
!prt real :: fbie3(NK,NTH), tsae3(NK,NTH), efac3
!prt real :: fbie4(NK,NTH), tsae4(NK,NTH), efac4
!prt real :: fa1max, fa2max, fa3max, fa4max
!prt real :: fe1max, fe2max, fe3max, fe4max
!prt real :: ta1max, ta2max, ta3max, ta4max
!prt real :: te1max, te2max, te3max, te4max
!prt real :: fa1sum, fa2sum, fa3sum, fa4sum
!prt real :: fe1sum, fe2sum, fe3sum, fe4sum
!prt real :: ta1sum, ta2sum, ta3sum, ta4sum
!prt real :: te1sum, te2sum, te3sum, te4sum
!prt real :: deltaf !* df
#endif
real :: wka(NK), oma(NK), frqa(NK) !* /b/
real :: angl(NTH), sinan(NTH), cosan(NTH) !* /b/
real :: pha(NK) !* /c/
real :: sumint(NK,NTH) !* /dn/
real :: cga(NK), cgnrng !* /dn/
real :: sumintp(NK,NTH) !* /z/
real :: sumintx(NK,NTH), sumintsa(NK,NTH) !* /z/
!!
DATA FIRST_TSA /.true./
nrng = NK
nang = NTH
npts = 30
twopi = TPI !* twopi = 8.*atan(1.)
#ifdef WW3_TSA
S = 0.0
D = 0.0
#endif
!!-----------------------------------------------------------------------------#
!! dep = [m] depth of water !
!! dfrq = frequency multiplier for logarithmic frequency spacing = 1.05 !
!! npk = the magic number 14 ??? (as read from tape9) !
!! fpk = [Hz] peak frequency of initial frequency spectrum and !
!! a parameter of the solution grid !
!!-----------------------------------------------------------------------------#
dep = DEPTH
dfrq = XFR
if (dfrq .le. 1.) then
! print *, ' dfrq </= 1; no longer supported '
! print *, ' use geometric spacing - dfrq > 1 '
#ifdef WW3_TSA
CALL EXTCDE ( 110 )
#endif
STOP 'l.373 wwm_snl4_tsa.F90'
end if
delfx = 0.5 * (dfrq-1./dfrq) !* multiplier for bandwidth
oma = SIG(1:NK)
frqa = oma / twopi
f0 = frqa(1)
wka = WN(1:NK)
cga = CG(1:NK)
cgnrng = cga(nrng) !* group velocity, outer ring
ainc = DTH
angl = TH(1:NTH)
cosan = ECOS(1:NTH)
sinan = ESIN(1:NTH)
!!
!! -----------------------------------------------------------------#
!! !
!! initialize array pha = k*dk*dtheta, the base area at a grid !
!! intersection for use in integration of 2-d density functions; !
!! dk at a given ring here is the spacing between adjacent cell !
!! centers, with edge points consistent with the geometric !
!! spacing of frequency rings !
!! !
!! -----------------------------------------------------------------#
!!
!! In the line below "wkfnc(frqa(1)/dfrq,dep)" is like wka(0)
!!
dwka(1) = (wka(2) - wkfnc(frqa(1)/dfrq,dep)) / 2.
!! !* dk at ring 1
pha(1) = wka(1)*dwka(1)*ainc !* k*dk*dtheta at ring 1
!!
do irng=2,nrng-1
dwka(irng) = (wka(irng+1)-wka(irng-1)) / 2. !* dk at irng
pha(irng) = wka(irng)*dwka(irng)*ainc !* k*dk*dtheta at irng
enddo
!!
!! In the line below "wkfnc(dfrq*frqa(nrng),dep)" is like wka(nrng+1)
!!
dwka(nrng) = (wkfnc(dfrq*frqa(nrng),dep) - wka(nrng-1)) / 2.
!! !* dk at nrng
pha(nrng) = wka(nrng)*dwka(nrng)*ainc !* k*dk*dtheta at nrng
!!
!! -----------------------------------------------------------------#
!! Since this run is for a rectangular ocean with uniform depth |
!! call grid geometry subr "gridsetr" only once (from here) for |
!! all spectra at all grid points and for all the time steps. |
!! |
!!- We can also do cga and wka (both fnc of frqa and dep) once (here)|
!!- and since they are used in gridsetr we have to do them first. |
!!- However, for now ignore this option. |
!! -----------------------------------------------------------------#
!!
NZZ = (NK*(NK+1))/2
IF ( FIRST_TSA ) THEN
allocate(kref2(npts, nang, NZZ)); kref2 = 0.
allocate(kref4(npts, nang, NZZ)); kref4 = 0.
allocate(jref2(npts, nang, NZZ)); jref2 = 0.
allocate(jref4(npts, nang, NZZ)); jref4 = 0.
allocate(wtk2(npts, nang, NZZ)); wtk2 = 0.
allocate(wtk4(npts, nang, NZZ)); wtk4 = 0.
allocate(wta2(npts, nang, NZZ)); wta2 = 0.
allocate(wta4(npts, nang, NZZ)); wta4 = 0.
allocate(tfac2(npts, nang, NZZ)); tfac2 = 0.
allocate(tfac4(npts, nang, NZZ)); tfac4 = 0.
allocate(grad(npts, nang, NZZ)); grad = 0.
allocate(wk2x(npts)); wk2x = 0.
allocate(wk2y(npts)); wk2y = 0.
allocate(wk4x(npts)); wk4x = 0.
allocate(wk4y(npts)); wk4y = 0.
allocate(ds(npts)); ds = 0.
allocate(dens(nrng, nang)); dens = 0.
allocate(dens2(nrng, nang)); dens2 = 0.
allocate(tsa(nrng, nang)); tsa = 0.
allocate(diag(nrng, nang)); diag = 0.
allocate(fbi(nrng, nang)); fbi = 0.
allocate(diag2(nrng, nang)); diag = 0.
!!------------------------------------------------------------------------------------------
call gridsetr ( nrng,nang,npts,NZZ, dep,dfrq,ierr_gr, frqa,wka, cgnrng, sinan,cosan )
!!------------------------------------------------------------------------------------------
if (ierr_gr .ne. 0) then
write(*,'('' error '',i10,'' from gridset; bail'')') ierr_gr
#ifdef WW3_TSA
CALL EXTCDE ( 120 )
#endif
STOP 'l. 459 wwm_snl4_tsa.F90'
end if
!!
FIRST_TSA = .FALSE.
print *, ' Done calling gridsetr OK '
#ifdef PRINT_2
!!wrt Bash; Add test write output kref2()
!wrt open(103, file='kref2_at00.dat', status='unknown') !* Tape103
!wrt write(103,903) 'kref2(npts,NTH,NZZ)'
!wrt do 614 ipt =1,npts
!wrt do 613 iang=1,nang
!wrt write(103,904) ipt, iang
!wrt write(103,940) (kref2(ipt,iang,iz), iz=1,NZZ)
!613 continue
!614 continue
!wrt close(103)
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!
!!wrt Bash; Add test write output kref4()
!wrt open(104, file='kref4_at00.dat', status='unknown') !* Tape104
!wrt write(104,903) 'kref4(npts,NTH,NZZ)'
!wrt do 616 ipt =1,npts
!wrt do 615 iang=1,nang
!wrt write(104,904) ipt, iang
!wrt write(104,940) (kref4(ipt,iang,iz), iz=1,NZZ)
!615 continue
!616 continue
!wrt close(104)
!!
!!wrt Bash; Add test write output jref2()
!wrt open(105, file='jref2_at00.dat', status='unknown') !* Tape105
!wrt write(105,903) 'jref2(npts,NTH,NZZ)'
!wrt do 618 ipt =1,npts
!wrt do 617 iang=1,nang
!wrt write(105,904) ipt, iang
!wrt write(105,940) (jref2(ipt,iang,iz), iz=1,NZZ)
!617 continue
!618 continue
!wrt close(105)
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!wrt Bash; Add test write output jref4()
!wrt open(106, file='jref4_at00.dat', status='unknown') !* Tape106
!wrt write(106,903) 'jref4(npts,NTH,NZZ)'
!wrt do 620 ipt =1,npts
!wrt do 619 iang=1,nang
!wrt write(106,904) ipt, iang
!wrt write(106,940) (jref4(ipt,iang,iz), iz=1,NZZ)
!619 continue
!620 continue
!wrt close(106)
!!
!!wrt Bash; Add test write output wtk2()
!wrt open(107, file='wtk2_at00.dat', status='unknown') !* Tape107
!wrt write(107,903) 'wtk2(npts,NTH,NZZ)'
!wrt do 622 ipt =1,npts
!wrt do 621 iang=1,nang
!wrt write(107,904) ipt, iang
!wrt write(107,950) (wtk2(ipt,iang,iz), iz=1,NZZ)
!621 continue
!622 continue
!wrt close(107)
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!wrt Bash; Add test write output wtk4()
!wrt open(108, file='wtk4_at00.dat', status='unknown') !* Tape108
!wrt write(108,903) 'wtk4(npts,NTH,NZZ)'
!wrt do 624 ipt =1,npts
!wrt do 623 iang=1,nang
!wrt write(108,904) ipt, iang
!wrt write(108,950) (wtk4(ipt,iang,iz), iz=1,NZZ)
!623 continue
!624 continue
!wrt close(108)
!!
!!wrt Bash; Add test write output wta2()
!wrt open(109, file='wta2_at00.dat', status='unknown') !* Tape109
!wrt write(109,903) 'wta2(npts,NTH,NZZ)'
!wrt do 626 ipt =1,npts
!wrt do 625 iang=1,nang
!wrt write(109,904) ipt, iang
!wrt write(109,950) (wta2(ipt,iang,iz), iz=1,NZZ)
!625 continue
!626 continue
!wrt close(109)
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!wrt Bash; Add test write output wta4()
!wrt open(110, file='wta4_at00.dat', status='unknown') !* Tape110
!wrt write(110,903) 'wta4(npts,NTH,NZZ)'
!wrt do 628 ipt =1,npts
!wrt do 627 iang=1,nang
!wrt write(110,904) ipt, iang
!wrt write(110,950) (wta4(ipt,iang,iz), iz=1,NZZ)
!627 continue
!628 continue
!wrt close(110)
!!
!!wrt Bash; Add test write output tfac2()
!wrt open(111, file='tfac2_at00.dat', status='unknown') !* Tape111
!wrt write(111,903) 'tfac2(npts,NTH,NZZ)'
!wrt do 630 ipt =1,npts
!wrt do 629 iang=1,nang
!wrt write(111,904) ipt, iang
!wrt write(111,950) (tfac2(ipt,iang,iz), iz=1,NZZ)
!629 continue
!630 continue
!wrt close(111)
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!wrt Bash; Add test write output tfac4()
!wrt open(112, file='tfac4_at00.dat', status='unknown') !* Tape112
!wrt write(112,903) 'tfac4(npts,NTH,NZZ)'
!wrt do 632 ipt =1,npts
!wrt do 631 iang=1,nang
!wrt write(112,904) ipt, iang
!wrt write(112,950) (tfac4(ipt,iang,iz), iz=1,NZZ)
!631 continue
!632 continue
!wrt close(112)
!!
!!wrt Bash; Add test write output grad()
!wrt open(113, file='grad_at00.dat', status='unknown') !* Tape113
!wrt write(113,903) 'grad(npts,NTH,NZZ)'
!wrt do 634 ipt =1,npts
!wrt do 633 iang=1,nang
!wrt write(113,904) ipt, iang
!wrt write(113,950) (grad(ipt,iang,iz), iz=1,NZZ)
!633 continue
!634 continue
!wrt close(113)
!!
!903 format(2x,A)
!904 format(2x,'ipt=',i4,2x,'iang=',i4)
!940 format(2x,10I5)
!950 format(2x,10E12.5)
!!
#endif PRINT_2
END IF ! FIRST TSA
!!
!! Convert input WW3 Cartesian 2D Action density spectrum A(theta,k)
!! to Cartesian 2D Energy density spectrum ef2(theta,f)
!! and reverse indices to ef2(f,theta)
!! ==> ef2(f,theta) = A(theta,k) * 2*pi*oma(k)/cga(k)
!! It's this ef2(f,theta) that I send to optsa
!! But first I used it to calc. 1D Energy ef1(f)
!!
do irng=1,nrng
fac = twopi*oma(irng)/cga(irng)
write(*,*) fac
do iang=1,nang
ef2(irng,iang) = A(iang,irng) * fac
end do
end do
!!
!! First calculte the 1D Energy density "ef1(f)"
!!
do irng=1,nrng
ef1(irng) = 0.0
do iang=1,nang
ef1(irng) = ef1(irng) + ef2(irng,iang)
end do
ef1(irng) = ef1(irng) * ainc !* sum(ef2(f,theta))*ainc
end do
!!
!!* Bash;
!!* Find 1 or 2 peaks that satisfy TSA min condition (below) ------- *
!!* before calling TSA subrs. otherwise bailout (return) ----------- *
!!* otherwise return with init. values of S & D = 0.0 -------------- *
!!
!!* nsep = # of bins that separates between npk & npk2
!!* nbins = min # of bins (incl nrng) > npk
!!* or min # of bins (incl nfs) > npk2 to guarantee 1 bin in equi. range
!!* nbins1 = actual # of bins > npk or nrng; nbins1 = nfs - npk (or nrng - npk2)
!!
!!* ===> TSA min condition relative to nrng is satisfied when ----- *
!!* ===> npk.le.nrng-nbins guarantee min nbins (incl nrng) > fpk -- * <<<<<
!!* ===> of which we only use 1 in optsa2 equi. range defined ----- * <<<<<
!!* ===> to be between [dfrq**(nbins) -/+ 0.025] * fp ------------ * <<<<<
!!* ===> skip if condition is not met ie if npk.gt.nrng-nbins ---- * <<<<<
!!
!!* ===> In case of 2 peaks we have 2nd condition to satifies ----- *
!!* ===> the TSA min condition for the low freq peak -------------- *
!!
!!* ===> TSA min condition relative to nfs is satisfied when ----- *
!!* ===> npk.le.nfs-nbins guarantee min nbins (incl nfs) > fpk2 --- * <<<<<
!!* ===> of which we only use 1 in optsa2 equi. range defined ----- * <<<<<
!!* ===> to be between dfrq**(nbins-1)*fp & dfrq**(nbins+1)*fp ---- * <<<<<
!!* ===> skip if condition is not met ie if npk2.gt.nfs-nbins ---- * <<<<<
!!*
!!* ===> with:
!!* iabs(npk-npk2) > nsep (min nsep bins separating the 2 peaks) <<<<<
!!
!! With dfrq = 1.05, for a combination of (nsep, nbins);
!! the equi. range used in optsa2 is set to
!!* ===> nsep = 1, nbins = 1 ==> 1.02*fp & 1.07*fp
!!* ===> nsep = 3, nbins = 2 ==> 1.07*fp & 1.13*fp
!!* ===> nsep = 5, nbins = 3 ==> 1.13*fp & 1.18*fp
!!* o o o
!!* ===> nsep = 3, nbins =14 ==> 1.95*fp & 2.00*fp
!!* ===> nsep = 5, nbins =14 ==> 1.95*fp & 2.00*fp
!!
!! The orig equi. range was 1.55*fp & 2.45*fp;
!! The new equi. range is Narrow and close to fp ???
!! ------------------------------------------------------------------
!! Define nsep & nbins
nsep = 1
nbins = 1
!!
!! First find the overall peak with e1max must be > 0.000001
!! Starting from low freq. find the Energy max "e1max" and
!! corresp. peak freq. "fpk" and its freq. number "npk".
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!! sum energy over the 1st bin + the last "nbins-1" excluded from search
!! The 1st bin is before 1st possible peak loc. at 2
!! last nbins are after last possible peak loc. at nrng-nbins <<<<<
e1sum = ef1(1)*delfx*frqa(1)
do irng=nrng-nbins+1,nrng !* nrng-nbins+1,nrng <<<<<
e1sum = e1sum + ef1(irng) * delfx*frqa(irng) !* sum E(f)*df
end do
!!
e1max = 0.0
fpk = 0.0
npk = 0
npeaks = 0
!!
!! look in the freq range that works for TSA call (see condition below)
!!
do irng=2,nrng-nbins !* last peak loc. is at nrng-nbins <<<<<
e1sum = e1sum + ef1(irng) * delfx*frqa(irng) !* sum E(f)*df
if ( ef1(irng).gt.ef1(irng-1) .and. ef1(irng).gt.ef1(irng+1) .and. ef1(irng).gt.e1max ) then
npk = irng !* update npk
fpk = frqa(npk) !* update fpk
e1max = ef1(npk) !* update e1max
npeaks = 1
endif
end do
!!
!!B if a peak is not found (npeaks=0 & e1max=0.0<eps)
!!B if a peak is found with a tiny peak (e1max<eps) or
!!B if a peak is found with a tiny energy (e1sum<eps) or
!!B if TSA min condition is not met rel. to nrng (npk.gt.nrng-nbins) <<<<<
!!B drop everything & return with init. values of S() and D() arrays=0.0
!!
if ( e1max.lt.0.000001 .or. e1sum.lt.0.000001 .or. npk.gt.nrng-nbins ) then
!! --------------------------------------------------------------!* <<<<<
!!* Not suitable spectrum for tsa; don't call tsa routines ------- *
!!* print info line, skip and return (don't stop) ---------------- *
!! --------------------------------------------------------------!* <<<<<
! write(6,206) nbins, npk,fpk,e1max,e1sum !* <<<<<
! 206 format(' *** W3SNLX: e1max,e1sum< or npk>nrng-',I1,' skip tsa;' ' npk, fpk, e1max,e1sum =', I4,f9.6,E14.6,f10.4)
return !* return from here with init. values of S() and D() arrays = 0.0
else
h1sig = 4.0 * sqrt(e1sum)
endif
!!
!! Bash; if we are here (i.e. we did not return) then we must
!! have found the 1st good peak (= overall peak) with e1max>eps
!! then look for new 2nd peak at least 'nsep' bins away from the 1st <<<<<
!! iabs(irng-npk).gt.nsep <<<<<
!! before calling new "optsa2" (thw 2nd peak will have e1max2 < e1max)
!! Again look in the freq range that is in line with TSA min condition
!! and find the 2nd highest peak with eps < e1max2 < e1max
!!
e1max2 = 0.0
fpk2 = 0.0
npk2 = 0
do irng=2,nrng-nbins !* last peak loc. is at nrng-nbins <<<<<
if ( ef1(irng).gt.ef1(irng-1).and.ef1(irng).gt.ef1(irng+1).and.ef1(irng).ge.e1max2.and.iabs(irng-npk).gt.nsep ) then
!! pick new abs. local peak, if 2 equal peaks are found
!! take the higher freq. and update npk2, fpk2 & e1max2
!! then continue the loop to find the biggest e1max2 peak
npk2 = irng !* update npk2
fpk2 = frqa(npk2) !* update fpk2
e1max2 = ef1(npk2) !* update e1max2
npeaks = 2
endif
enddo
!!B if 2nd peak is not found then we have single peak spectrum (npeaks=1)
!!B if 2nd peak is found then make sure:
!!B (1) its e1max2>eps (not tiny) and
!!B (2) it satisfies TSA min condition relative to nrng
!!B if not drop this 2nd peak & stick to the overall one peak spectrum
!!
if ( npeaks.eq.2 .and. (e1max2.lt.0.000001 .or. npk2.gt.nrng-nbins) ) npeaks = 1
!!
!!B if we still have 2 peaks (npeaks=2)
!!B then find the bin in the middle to divide the freq. regime into two
if ( npeaks.eq.2 ) then
nfs = int ( (npk+npk2+1) / 2.0 ) !* give the higher bin # to nfs
endif
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!!B if we still have 2 peaks (npeaks=2)
!!B then check and make sure that:
!!B the lower freq peak satisfies TSA min condition relative to nfs <<<<<
!!B npk2.le.nfs-nbins <<<<<
!!B if not drop the idea of 2 freq regimes & go back to 1 overall peak
!!B which we already know it satisfies TSA min condition rel. to nrng
!! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ( npeaks.eq.2 ) then
!! we have 2 peaks with npk the lager peak & npk2 the smaller peak
!! --------------------------------------------------------------!* <<<<<
if ( npk2.lt.npk .and. npk2.gt.nfs-nbins ) then !* <<<<<
!!B low freq (small) peak npk2 failed TSA min condition relative to nfs
! write(6,216) npk2,fpk2,e1max2,nfs
216 format(' *** W3SNLX: low freq sml peak; failed nfs test ;' ' npk2,fpk2,e1max2,nfs =', I4,f9.6,E14.6,6x,I4)
! write(6,217) npk,fpk,e1max,h1sig
217 format(' *** high freq lrg peak is at ; ' ' npk, fpk, e1max,h1sig =', I4,f9.6,E14.6,f10.4)
npeaks = 1
endif
if ( npk .lt.npk2 .and. npk .gt.nfs-nbins ) then !* <<<<<
!!B low freq (big) peak npk failed TSA min condition relative to nfs
! write(6,218) npk,fpk,e1max,nfs
218 format(' *** W3SNLX: low freq lrg peak; failed nfs test ;' ' npk, fpk, e1max,nfs =', I4,f9.6,E14.6,6x,I4)
! write(6,219) npk2,fpk2,e1max2,h1sig
219 format(' *** high freq sml peak is at ; ' ' npk2,fpk2,e1max2,h1sig=', I4,f9.6,E14.6,f10.4)
npeaks = 1
endif ! npk2.lt.npk .and. npk2.gt.nfs-nbins
endif ! npeaks.eq.2
!!
!!B Here if we still have 2 peaks the 1st is the dominant peak,
!!B re-order the 2 peaks forcing npk to be always < npk2
!!B and re-alligne corresp. fpk,e1max & fpk2,e1max2
!!B This says nothing about which peak is the dominant peak after the shift
!!
if ( npeaks.eq.2 .and. npk2.lt.npk ) then
nfs2 = npk2
npk2 = npk
npk = nfs2
fpk = frqa(npk)
fpk2 = frqa(npk2)
e1max = ef1(npk)
e1max2 = ef1(npk2)
endif !* this way npk < npk2 always
!!
!! Bash; Using the new "optsa2" you are allowed
!! a single call or possibly 2 calls (if 2 peaks)
!! to account for spectra with double peaks.
!!
if ( npeaks.eq.1 ) then
!! Do this this call for the only one peak (if 1 peak)
!! print info line about the 1st peak and continue -------------- *
!! this condition guarantees a min. of 4 bins in the equi. range
! write(6,207) npk,fpk,e1max,h1sig
207 format(' *** W3SNLX: continue - one peak; call tsa subrs ;' ' npk, fpk, e1max,h1sig =', I4,f9.6,E14.6,f10.4)
!!
!! one call to optsa2 for the whole freq. regime ( 1 --> nrng )
!!
nfrq = nrng !* = nrng - 1 +1
nbins1 = nrng - npk
if ( nbins1.gt.14 ) nbins1 = 14 !* to limit equi. range to 1.98*fp
call optsa2 ( 1,nrng, nrng,nang, npk, fpk, frqa, oma,wka,cga, angl,cosan, ef1,ef2, dfrq,nbins1 )
endif ! npeaks
if ( npeaks.eq.2 ) then
!! Now make two calls to new "optsa2" one for each freq regime.
!! 1st call to optsa2 for the lower freq. regime ( 1 --> nfs )
!! print info line about the 1st peak and continue -------------- *
!! this condition guarantees a min. of 4 bins in the equi. range
! write(6,208) npk,fpk,e1max,h1sig
208 format(' *** W3SNLX: low freq 1st peak; call tsa subrs ;' ' npk, fpk, e1max,h1sig =', I4,f9.6,E14.6,f10.4)
!!
nfrq = nfs !* = nfs - 1 +1
nbins1 = nfs - npk
if ( nbins1.gt.14 ) nbins1 = 14 !* to limit equi. range to 1.98*fp
call optsa2 ( 1,nfs, nrng,nang, npk, fpk, frqa, oma,wka,cga, angl,cosan, ef1,ef2, dfrq,nbins1 )
!!
!! 2nd call to optsa2 for the higher freq. regime ( nfs+1 --> nrng )
!! print info line about the 2nd peak and continue -------------- *
!! this condition guarantees a min. of 4 bins in the equi. range
! write(6,209) npk2,fpk2,e1max2,nfs
209 format(' *** high freq 2nd peak; call tsa subrs ;' ' npk2,fpk2,e1max2, nfs =', I4,f9.6,E14.6,6x,I4)
!!
nfrq = nrng - nfs !* = nrng - (nfs+1) + 1
nbins1 = nrng - npk2
if ( nbins1.gt.14 ) nbins1 = 14 !* to limit equi. range to 1.98*fp
call optsa2 ( nfs+1,nrng, nrng,nang, npk2,fpk2, frqa, oma,wka,cga, angl,cosan, ef1,ef2, dfrq,nbins1 )
!!
!! Remove the step like jump (if exist) in dens() between nfs & nfs+1
!!
do iang=1,nang
sumd1 = dens(nfs,iang) + dens2(nfs,iang) !* sum at nfs
sumd2 = dens(nfs+1,iang) + dens2(nfs+1,iang) !* sum at nfs+1
!! do 3 bin average dens() at nfs and store in densat1
densat1 = ( dens(nfs-1,iang) + dens(nfs,iang) + dens(nfs+1,iang) ) / 3.
!! do 3 bin average dens() at nfs+1 and store in densat2
densat2 = ( dens(nfs,iang) + dens(nfs+1,iang) + dens(nfs+2,iang) ) / 3.
!! subtitute back into dens(nfs,iang) & dens(nfs+1,iang)
dens(nfs,iang) = densat1 ! dens at nfs
dens(nfs+1,iang) = densat2 ! dens at nfs+1
!! recalculate dens2(nfs,iang) & dens2(nfs+1,iang)
dens2(nfs,iang) = sumd1 - densat1 ! dens2 at nfs
dens2(nfs+1,iang) = sumd2 - densat2 ! dens2 at nfs+1
end do ! nang
endif ! npeaks == 2
!!
!! Calculate dbl-sum of small-scale Action density dens2(k,theta)
!! and dbl-sum of large-scale Action density dens(k,theta)
!! then calculate their ratio dens2ov1 and write it out
!!
dens2sum = 0.0
dens1sum = 0.0
dens2ov1 = 0.0
do irng=1,nrng
do iang=1,nang
dens2sum = dens2sum + abs(dens2(irng,iang))
dens1sum = dens1sum + dens(irng,iang)
end do
dens2sum = dens2sum * ainc * delfx*frqa(irng)
dens1sum = dens1sum * ainc * delfx*frqa(irng)
end do
dens2ov1 = dens2sum / dens1sum
! write(6,418) dens2ov1
418 format(' *** W3SNLX: dbl-sum(abs(dens2)) / dbl-sum(dens) ;' ' ------------ dens2ov1 =', f11.4,4x,'----------------------')
!! -----------------------------------------------------------------#
!! !
!! Get Snl source term and its diagonal term from "snlr" !
!! !
!! -----------------------------------------------------------------#
call snlr ( nrng,nang,npts,NZZ, frqa,pha,sumint,sumintsa,sumintp,sumintx )
!!
do irng=1,nrng
do iang=1,nang
fac = 1./cg(irng)!1./(twopi*oma(irng))
!! Bash; use tsa() & diag()
!! Convert Polar tsa(k,theta) to Cartesian S(theta,k)
S(iang,irng) = tsa(irng,iang) * wka(irng) !* 1./cg(irng)!1./(tpi*oma(irng)!wka(irng)
D(iang,irng) = diag(irng,iang)
!! Bash; use fbi() & diag2()
!! Convert Polar fbi(k,theta) to Cartesian S(theta,k)
end do
end do
! do irng=1,nrng
! do iang=1,nang
! write(*,'(2I10,5F15.10)') irng, iang, oma(irng), tsa(irng,iang), cg(irng), 1./(tpi*oma(irng)), wka(irng)
! end do
! end do
!! ------------------------------------------------------------------
!! After subroutine "snlr" have returned:
!! Polar fbi(k,theta) and Polar tsa((k,theta) Snl in Action Density Units
!! where fbi() & tsa() were calc. in "snlr" as follow:
!! fbi(k,theta) = sumint(k,tetha)+sumintp(k,tetha)+sumintx(k,tetha)
!! tsa(k,theta) = sumint(k,tetha)+sumintsa(k,tetha)
!!
!! We calculate 8 diff flavors of fbi(k,theta) & fbi(f,theta)
!! by multiplying it by 8 diff factors "fac??"
!!-1 1 * Polar fbia1(k,theta) in Action Density Units
!!-2 k * Cartesian fbia2(k,theta) in Action Density Units
!!-3 2pi/Cg * Polar fbia3(f,theta) in Action Density Units
!!-4 k*2pi/Cg * Cartesian fbia4(f,theta) in Action Density Units
!!-5 w * Polar fbie1(k,theta) in Energy Density Units
!!-6 w*k * Cartesian fbie2(k,theta) in Energy Density Units
!!-7 w*2pi/Cg * Polar fbie3(f,theta) in Energy Density Units
!!-8 w*k*2pi/Cg * Cartesian fbie4(f,theta) in Energy Density Units
!! ------------------------------------------------------------------
!!
!! and
!! We calculate 8 diff flavors of tsa(k,theta) & tsa(f,theta)
!! by multiplying it by 8 diff factors "fac??"
!!-1 1 * Polar tsaa1(k,theta) in Action Density Units
!!-2 k * Cartesian tsaa2(k,theta) in Action Density Units
!!-3 2pi/Cg * Polar tsaa3(f,theta) in Action Density Units
!!-4 k*2pi/Cg * Cartesian tsaa4(f,theta) in Action Density Units
!!-5 w * Polar tsae1(k,theta) in Energy Density Units
!!-6 w*k * Cartesian tsae2(k,theta) in Energy Density Units
!!-7 w*2pi/Cg * Polar tsae3(f,theta) in Energy Density Units
!!-8 w*k*2pi/Cg * Cartesian tsae4(f,theta) in Energy Density Units
!! ------------------------------------------------------------------
!!
!! for fbi dbl sums
#ifdef PRINT_1
!prt fa1sum = 0.0 !* for dbl sum fbia1(k,theta)
!prt fa2sum = 0.0 !* for dbl sum fbia2(k,theta)
!prt fa3sum = 0.0 !* for dbl sum fbia3(f,theta)
!prt fa4sum = 0.0 !* for dbl sum fbia4(f,theta)
!prt fe1sum = 0.0 !* for dbl sum fbie1(k,theta)
!prt fe2sum = 0.0 !* for dbl sum fbie2(k,theta)
!prt fe3sum = 0.0 !* for dbl sum fbie3(f,theta)
!prt fe4sum = 0.0 !* for dbl sum fbie4(f,theta)
!! ------------------------------------------------------------------
!! for tsa dbl sums
!prt ta1sum = 0.0 !* for dbl sum tsaa1(k,theta)
!prt ta2sum = 0.0 !* for dbl sum tsaa2(k,theta)
!prt ta3sum = 0.0 !* for dbl sum tsaa3(f,theta)
!prt ta4sum = 0.0 !* for dbl sum tsaa4(f,theta)
!prt te1sum = 0.0 !* for dbl sum tsae1(k,theta)
!prt te2sum = 0.0 !* for dbl sum tsae2(k,theta)
!prt te3sum = 0.0 !* for dbl sum tsae3(f,theta)
!prt te4sum = 0.0 !* for dbl sum tsae4(f,theta)
!! ------------------------------------------------------------------
!prt do 62 irng=1,nrng
!prt afac1 = 1.0 !* afac1 = 1.0
!prt afac2 = wka(irng) !* afac2 = k
!prt afac3 = twopi/cga(irng) !* afac3 = 2pi/Cg
!prt afac4 = wka(irng)*twopi/cga(irng) !* afac4 = k*2pi/Cg
!prt efac1 = oma(irng)*1.0 !* efac1 = w*1.0
!prt efac2 = oma(irng)*wka(irng) !* efac2 = w*k
!prt efac3 = oma(irng)*twopi/cga(irng) !* efac3 = w*2pi/Cg
!prt efac4 = oma(irng)*wka(irng)*twopi/cga(irng) !* efac4 = w*k*2pi/Cg
!prt deltaf = delfx*frqa(irng)
!! ----------------------------------------------------------------
!!
!!
!prt do 61 iang=1,nang
!!
!! calculate the 8 diff flavors of fbi(k,theta) & fbi(f,theta)
!prt fbia1(irng,iang) = fbi(irng,iang) * afac1 !* fbia1(k,theta)
!prt fbia2(irng,iang) = fbi(irng,iang) * afac2 !* fbia2(k,theta)
!prt fbia3(irng,iang) = fbi(irng,iang) * afac3 !* fbia3(f,theta)
!prt fbia4(irng,iang) = fbi(irng,iang) * afac4 !* fbia4(f,theta)
!prt fbie1(irng,iang) = fbi(irng,iang) * efac1 !* fbie1(k,theta)
!prt fbie2(irng,iang) = fbi(irng,iang) * efac2 !* fbie2(k,theta)
!prt fbie3(irng,iang) = fbi(irng,iang) * efac3 !* fbie3(f,theta)
!prt fbie4(irng,iang) = fbi(irng,iang) * efac4 !* fbie4(f,theta)
!! --------------------------------------------------------------
!!
!! calculate the 8 diff flavors of tsa(k,theta) & tsa(f,theta)
!prt tsaa1(irng,iang) = tsa(irng,iang) * afac1 !* tsaa1(k,theta)
!prt tsaa2(irng,iang) = tsa(irng,iang) * afac2 !* tsaa2(k,theta)
!prt tsaa3(irng,iang) = tsa(irng,iang) * afac3 !* tsaa3(f,theta)
!prt tsaa4(irng,iang) = tsa(irng,iang) * afac4 !* tsaa4(f,theta)
!prt tsae1(irng,iang) = tsa(irng,iang) * efac1 !* tsae1(k,theta)
!prt tsae2(irng,iang) = tsa(irng,iang) * efac2 !* tsae2(k,theta)
!prt tsae3(irng,iang) = tsa(irng,iang) * efac3 !* tsae3(f,theta)
!prt tsae4(irng,iang) = tsa(irng,iang) * efac4 !* tsae4(f,theta)
!! --------------------------------------------------------------
!!
!! calc. sums: dbl sum fbi??(k,theta) or dbl sum fbi??(f,theta)
!prt fa1sum = fa1sum + fbia1(irng,iang)
!prt fa2sum = fa2sum + fbia2(irng,iang)
!prt fa3sum = fa3sum + fbia3(irng,iang)
!prt fa4sum = fa4sum + fbia4(irng,iang)
!prt fe1sum = fe1sum + fbie1(irng,iang)