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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
|
subroutine ft8bvar(residual,spectrum,newdat1,nQSOProgress,nfqso,nftx,napwid, &
lsubtract,tmpcqdec,tmpmyc,nagainfil,iaptype,f1,xdt,nbadcrc,lft8sdec, &
msg37,msg37_2, &
xsnr,stophint,nthr,lFreeText,ipass,lft8subpass,lspecial,lcqcand,ncqsignal, &
nmycsignal,npass,i3bit,lft8s,lmycallstd,lhiscallstd,levenint,loddint,lft8sd, &
i3,n3,nft8rxfsens,ncount,msgsrcvd,lrepliedother,lhashmsg,lqsothread, &
lft8lowth,lhighsens,tmpcqsig,tmpmycsig,tmpqsosig,lnohiscall, &
lnomycall,lnohisgrid,qual,iaptype2,progress_generation,knowledge,evidence)
use packjt77, only : pack77_state,unpack77_configured_for_state,unpack77_options
use ft8_codec_context, only: get_ft8_codec_state
use ft8var_codec_context, only: ft8sd1var,ft8sdvar,ft8svar,ft8mfcqvar,tonesdvar, &
ft8var_tones_from_77bits
use ft8var_work_types
use decoder_engine_types, only: ft8_signal_evidence,engine_payload_decoded
use ft8_mtd_residual, only : mtd_commit_subtraction,mtd_mark_spectrum_current, &
mtd_refresh_candidate
use decode_completion_module, only : write_decode_progress
use ft8_mod1, only : allmessages,ndecodes,apsym,mcq,m73,mrr73,mrrr,icos7, &
naptypes,nhaptypes,one,graymap,oddcopy,evencopy,lastrxmsg,lasthcall, &
nlasttx,calldteven,calldtodd,lqsomsgdcd,mycalllen1,msgroot,msgrootlen, &
allfreq,idtone25,idtone25_valid,lapmyc,idtonemyc,mycall,hiscall,lhound,apsymsp, &
ndxnsaptypes,apsymdxns1,apsymdxnsrrr,lenabledxcsearch,lwidedxcsearch, &
apcqsym,apsymdxnsrr73,apsymdxns73,mybcall,hisbcall,lskiptx1,nft8cycles, &
ctwkw,ctwkn,nincallthr,msgincall,xdtincall,maskincallthr,ctwk256,numcqsig, &
numdeccq,evencq,oddcq,nummycsig,numdecmyc,evenmyc,oddmyc,idtone56, &
idtone56_valid, &
idtonecqdxcns,evenqso,oddqso,nmycnsaptypes,apsymmyns1,apsymmyns2, &
apsymmynsrr73,apsymmyns73,apsymdxstd,apsymdxnsr73,apsymdxns732,ltxing, &
apsymmynsrrr,idtonedxcns73,idtonefox73,idtonespec !ft8md added
include 'ft8_params.f90'
real, intent(inout) :: residual(180000)
complex, intent(inout) :: spectrum(0:96000)
character c77*77,msg37*37,msg37_2*37,msgd*37,msgbase37*37,call_a*12,call_b*12
character callsign*12,grid*12
character*37 msgsrcvd(130)
complex cd0(-800:4000),cd1(-800:4000),cd2(-800:4000),cd3(-800:4000),ctwk(32), &
csymb(32),cs(0:7,79),csymbr(32),csr(0:7,79),csig(32),z1, &
csymb256(256),cstmp2(0:7,79),csold(0:7,79),cscs(0:7,79)
complex, allocatable :: csig0(:)
real a(5),s8(0:7,79),s82(0:7,79),s2(0:511),sp(0:7),s81(0:7),snrsync(21), &
syncw(7),sumkw(7),scoreratiow(7),s256(0:8),s2563(0:26), &
syncavpart(3)
real bmeta(174),bmetb(174),bmetc(174),bmetd(174)
real llra(174),llrb(174),llrc(174),llrd(174),llrz(174)
real qual !ft8md
integer*1 message77(77),apmask(174),cw(174),nsmax(8)
integer itone(79),ip(1),ka(1),nqsoend(3)
integer, intent(in) :: nQSOProgress,nfqso,nftx,napwid,nthr,ipass,nft8rxfsens, &
progress_generation
logical newdat1,lsubtract,lFreeText,nagainfil,lspecial,unpk77_successvar
logical rebuild_spectrum
logical(1), intent(in) :: stophint,lft8subpass,lmycallstd,lhiscallstd, &
lqsothread,lft8lowth,lhighsens,lcqcand,levenint,loddint,lnohiscall, &
lnomycall,lnohisgrid
logical(1) falsedec,lastsync,ldupemsg,lft8s,lft8sdec,lft8sd,lsdone,ldupeft8sd, &
lrepliedother,lhashmsg,lvirtual2,lvirtual3,lsd,lcq,ldeepsync,lcallsstd, &
lfound,lsubptxfreq,lreverse,lchkcall,lgvalid,lwrongcall, &
lcqsignal,loutapwid,lfoundcq,lmycsignal,lfoundmyc,lqsosig,ldxcsig, &
lcqdxcsig,lcqdxcnssig,lqsocandave,lcall1hash,lqsosigtype3,lqso73,lqsorr73, &
lqsorrr,lfoxspecrpt,lfoxstdr73,lapcqonly,lcall2hash,lskipnotap
integer iaptype2
type(pack77_state), target, optional, intent(inout) :: knowledge
type(pack77_state), pointer :: codec
type(ft8_signal_evidence), optional, intent(out) :: evidence
character(len=37) :: decoded_payload_message
logical :: has_decoded_payload
type(tmpcqdec_struct) tmpcqdec(numdeccq)
type(tmpcqsig_struct) tmpcqsig(numcqsig) ! 20 sigs 24 threads
type(tmpmyc_struct) tmpmyc(numdecmyc)
type(tmpmycsig_struct) tmpmycsig(nummycsig) ! 5 sigs
type(tmpqsosig_struct) tmpqsosig(1)
codec => get_ft8_codec_state()
if(present(knowledge)) codec => knowledge
if(present(evidence)) evidence=ft8_signal_evidence()
has_decoded_payload=.false.
decoded_payload_message=''
itone=0
iaptype2 = 99 !ft8md
max_iterations=30
nharderrors=-1
nbadcrc=1
delfbest=0.
ibest=0
dfqso=500.
rrxdt=0.5
fs2=200.
dt2=0.005 ! fs2=12000.0/NDOWN; dt2=1.0/fs2
lcall1hash=.false.
lcall2hash=.false.
lskipnotap=.false.
ldeepsync=.false.
if(lft8lowth .or. lft8subpass) ldeepsync=.true.
lcallsstd=.true.
if(.not.lmycallstd .or. .not.lhiscallstd) lcallsstd=.false.
xdt0=xdt
f10=f1
! apply last freq f1 and last DT criteria here
nqso=1
if(lqsothread .and. .not. lft8sdec .and. .not.lqsomsgdcd .and. .not.stophint &
.and. nlasttx.ge.1 .and. nlasttx.le.4 .and. abs(f10-nfqso).lt.2.51) then
if(lastrxmsg(1)%lstate .and. abs(lastrxmsg(1)%xdt-xdt).lt.0.18) then
nqso=2
elseif(.not.lastrxmsg(1)%lstate) then
nqso=2
endif
endif
lvirtual2=.false.
lvirtual3=.false.
maxlasttx=4
if(lqsothread .and. .not. lft8sdec .and. .not.lqsomsgdcd) then
if(len_trim(hiscall).gt.2) then
if(xdt.gt.4.9 .or. xdt.lt.-4.9) then
if(lastrxmsg(1)%lstate .and. trim(lastrxmsg(1)%lastmsg).eq.trim(msgroot)//&
' RRR') maxlasttx=5
endif
if(xdt.gt.4.9) then
if(.not.stophint .and. nlasttx.ge.1 .and. nlasttx.le.maxlasttx .and. &
abs(f10-nfqso).lt.0.1) then
if(lastrxmsg(1)%lstate) then
xdt0=lastrxmsg(1)%xdt
nqso=2
lvirtual2=.true.
endif
if(.not.lastrxmsg(1)%lstate) then
if(levenint) then
do i=1,150
if(trim(calldteven(i)%call2).eq.trim(hiscall)) then
xdt0=calldteven(i)%dt
nqso=3
lvirtual2=.true.
exit
endif
enddo
else if(loddint) then
do i=1,150
if(trim(calldtodd(i)%call2).eq.trim(hiscall)) then
xdt0=calldtodd(i)%dt
nqso=3
lvirtual2=.true.
exit
endif
enddo
endif
endif
endif
elseif (xdt.lt.-4.9) then
if(.not.stophint .and. nlasttx.ge.1 .and. nlasttx.le.maxlasttx .and. &
abs(f10-nfqso).lt.0.1) then
if(lastrxmsg(1)%lstate) then
xdt0=lastrxmsg(1)%xdt
nqso=3
lvirtual3=.true.
endif
if(.not.lastrxmsg(1)%lstate) then
if(levenint) then
do i=1,150
if(trim(calldteven(i)%call2).eq.trim(hiscall)) then
xdt0=calldteven(i)%dt
nqso=3
lvirtual3=.true.
exit
endif
enddo
else if(loddint) then
do i=1,150
if(trim(calldtodd(i)%call2).eq.trim(hiscall)) then
xdt0=calldtodd(i)%dt
nqso=3
lvirtual3=.true.
exit
endif
enddo
endif
endif
endif
endif
endif
endif
call mtd_refresh_candidate(nthr,f1,newdat1,rebuild_spectrum)
call ft8_downsamplevar(residual,spectrum,newdat1,f1,nqso,cd0,cd2,cd3, &
lhighsens) !Mix f1 to baseband and downsample
if(rebuild_spectrum) call mtd_mark_spectrum_current(nthr)
lsd=.false.
isd=1
lcq=.false.
if(levenint) then
do i=1,130
if(.not.evencopy(i)%lstate) cycle
if(abs(evencopy(i)%freq-f1).lt.3.0 .and. abs(evencopy(i)%dt-xdt).lt.0.19) then
msgd=evencopy(i)%msg
lsd=.true.
isd=i
if(msgd(1:3).eq.'CQ ' .or. msgd(1:3).eq.'DE ' .or. &
msgd(1:4).eq.'QRZ ') lcq=.true.
endif
enddo
elseif(loddint) then
do i=1,130
if(.not.oddcopy(i)%lstate) cycle
if(abs(oddcopy(i)%freq-f1).lt.3.0 .and. abs(oddcopy(i)%dt-xdt).lt.0.19) then
msgd=oddcopy(i)%msg
lsd=.true.
isd=i
if(msgd(1:3).eq.'CQ ' .or. msgd(1:3).eq.'DE ' .or. &
msgd(1:4).eq.'QRZ ') lcq=.true.
endif
enddo
endif
if(lsd .and. nqso.eq.1) nqso=4
!nlasttx last TX message
! 0 Tx was halted
! 1 AA1AA BB1BB PL35
! 2 AA1AA BB1BB -15
! 3 AA1AA BB1BB R-15
! 4 AA1AA BB1BB RRR/RR73
! 5 AA1AA BB1BB 73
! 6 CQ BB1BB PL35
if(nqso.eq.4) cd1=cd0
do iqso=1,nqso
lapcqonly=.false.
if(iqso.gt.1 .and. iqso.lt.4 .and. nqso.eq.4) cycle
if(xdt0.lt.-4.9 .or. xdt0.gt.4.9) cycle
if(lvirtual2 .and. iqso.ne.2) cycle
if(lvirtual3 .and. iqso.lt.2) cycle
if((lvirtual2 .or. lvirtual3) .and. nft8rxfsens.lt.3 .and. iqso.eq.3) cycle
lastsync=.false.
lsdone=.false.
if(.not.lvirtual2 .and. .not.lvirtual3 .and. iqso.eq.2) then
cd0=cd2
elseif(lvirtual2 .and. iqso.eq.2) then
cd0=cd2
elseif(lvirtual3 .and. iqso.eq.2) then
cd0=cd3
endif
if(iqso.eq.4) then
call tonesdvar(msgd,lcq,codec)
if(.not.ldeepsync) go to 32
cd0=cd1
endif
if(iqso.eq.3) go to 16
i0=nint((xdt0+0.5)*fs2) !Initial guess for start of signal
smax=0.0
ctwk=cmplx(1.0,0.0)
do idt=i0-8,i0+8 !Search over +/- one quarter symbol
call sync8dvar(cd0,idt,ctwk,0,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcqcand)
if(sync.gt.smax) then
smax=sync
ibest=idt
endif
enddo
xdt2=ibest*dt2 !Improved estimate for DT
! Now peak up in frequency
i0=nint(xdt2*fs2)
smax=0.0
kstep=1
do ifr=-5,5
if(iqso.eq.1 .or. iqso.eq.4) then
ctwk=ctwkw(kstep,:)
delf=ifr*0.5 ! Search over +/- 2.5 Hz
else
ctwk=ctwkn(kstep,:)
delf=ifr*0.25 ! Search over +/- 1.25 Hz
endif
call sync8dvar(cd0,i0,ctwk,1,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcqcand)
if(sync.gt.smax) then
smax=sync
delfbest=delf
endif
kstep=kstep+1
enddo
a=0.0
a(1)=-delfbest
call twkfreq1var(cd0,-800,3199,4000,fs2,a,cd0)
xdt=xdt2
f1=f10+delfbest !Improved estimate of DF
dfqso=abs(nfqso-f1)
lastsync=.true.
call sync8dvar(cd0,i0,ctwk,2,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcqcand)
16 if(iqso.eq.3) ibest=ibest+1
syncav=3.
syncavpart=3.
snrsync=0.
do k=1,79
i1=ibest+(k-1)*32
csymb=cd0(i1:i1+31)
if((k.ge.1 .and. k.le.7) .or. (k.ge.37 .and. k.le.43) .or. &
(k.ge.73 .and. k.le.79)) then
call four2avar(csymb,32,1,-1,1)
s81(0:7)=abs(csymb(1:8))
if(k.ge.1 .and. k.le.7) then
synclev=s81(icos7(k-1))
snoiselev=(sum(s81)-synclev)/7.0
if(snoiselev.gt.1.E-16) snrsync(k)=synclev/snoiselev
else if(k.ge.37 .and. k.le.43) then
synclev=s81(icos7(k-37))
snoiselev=(sum(s81)-synclev)/7.0
if(snoiselev.gt.1.E-16) snrsync(k-29)=synclev/snoiselev
else if(k.ge.73 .and. k.le.79) then
synclev=s81(icos7(k-73))
snoiselev=(sum(s81)-synclev)/7.0
if(snoiselev.gt.1.E-16) snrsync(k-58)=synclev/snoiselev
endif
else
cycle
endif
enddo
syncav=sum(snrsync)/21.
syncavpart(1)=sum(snrsync(1:7))/7.
syncavpart(2)=sum(snrsync(8:14))/7.
syncavpart(3)=sum(snrsync(15:21))/7.
syncavemax=maxval(syncavpart,1)
! plev=0.0
! do k=1000,1009; abscd=abs(cd0(k)); if(abscd.gt.plev) plev=abscd; enddo
! plev=plev/61.0
! do k=0,3199; xx=plev*gran(); yy=plev*gran(); cd0(k)=cd0(k) + complex(xx,yy); enddo
lreverse=.false.
if(nft8cycles.lt.2) then
if(ipass.eq.2) lreverse=.true.
else
if(ipass.eq.5 .or. ipass.eq.7) lreverse=.true.
endif
do k=1,79
i1=ibest+(k-1)*32
csymb=cd0(i1:i1+31)
if(syncav.lt.2.5) then
csymb(1)=csymb(1)*1.9
csymb(32)=csymb(32)*1.9
scr=SQRT(abs(csymb(1)))/SQRT(abs(csymb(32)))
if(scr.gt.1.0) then
csymb(32)=csymb(32)*scr
else
if(scr.gt.1.E-16) csymb(1)=csymb(1)/scr
endif
endif
do i=1,32
csymbr(i)=cmplx(real(csymb(33-i)),-aimag(csymb(33-i)))
enddo
if(lreverse) then
call four2avar(csymb,32,1,-1,1)
cscs(0:7,k)=csymb(1:8)/1e3
csymb=csymbr
endif
call four2avar(csymb,32,1,-1,1)
cs(0:7,k)=csymb(1:8)/1e3
if(lreverse) then
csr=cs
else
call four2avar(csymbr,32,1,-1,1)
csr(0:7,k)=csymbr(1:8)/1e3
endif
s8(0:7,k)=abs(csymb(1:8))
enddo
sp=0.
do k=0,7
sp(k)=sum(s8(k,1:7))+sum(s8(k,18:79))
enddo
ka=minloc(sp)-1
k=ka(1)
if(k.lt.0) go to 128
do kb=0,7
if(kb.eq.k) cycle
spr=sp(kb)/sp(k)
if(spr.gt.1.5) then
s8(kb,:)=s8(kb,:)/spr
sprsqr=SQRT(spr)
cs(kb,:)=cs(kb,:)/sprsqr
csr(kb,:)=csr(kb,:)/sprsqr
cscs(kb,:)=cscs(kb,:)/sprsqr
endif
enddo
128 continue
if(iqso.gt.1 .and. iqso.lt.4) then
s82=SQRT(s8)
go to 8
endif
if(iqso.eq.4) go to 32
nsyncscorew=0
scoreratiowa=0.
rrxdt=xdt-0.5
if(rrxdt.ge.-0.5 .and. rrxdt.le.2.13) then
do k=1,7
syncw(icos7(k-1)+1)=s8(icos7(k-1),k)+s8(icos7(k-1),k+36) + &
s8(icos7(k-1),k+72)
enddo
do k=1,7
sumkw(k)=(sum(s8(k-1,:))-syncw(k))/25.333
enddo ! (79-3)/3
else if(rrxdt.lt.-0.5) then
do k=1,7
syncw(icos7(k-1)+1)=s8(icos7(k-1),k+36)+s8(icos7(k-1),k+72)
enddo
do k=1,7
sumkw(k)=(sum(s8(k-1,26:79))-syncw(k))/26.
enddo ! (54-2)/2
else if(rrxdt.gt.2.13) then
do k=1,7
syncw(icos7(k-1)+1)=s8(icos7(k-1),k)+s8(icos7(k-1),k+36)
enddo
do k=1,7
sumkw(k)=(sum(s8(k-1,1:54))-syncw(k))/26.
enddo ! (54-2)/2
endif
do k=1,7
if(syncw(k).gt.sumkw(k)) nsyncscorew=nsyncscorew+1
scoreratiow(k)=syncw(k)/sumkw(k)
enddo
scoreratiowa=sum(scoreratiow)/7.
! sync quality check
is1=0
is2=0
is3=0
nsyncscore=0
nsyncscore1=0
nsyncscore2=0
nsyncscore3=0
scoreratio=0.
scoreratio1=0.
scoreratio2=0.
scoreratio3=0.
nsync2=0
do k=1,7
s81(:)=s8(:,k)
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) then
is1=is1+1
else
s81(ip(1)-1)=0.
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) nsync2=nsync2+1
endif
s81=s8(:,k+36)
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) then
is2=is2+1
else
s81(ip(1)-1)=0.
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) nsync2=nsync2+1
endif
s81=s8(:,k+72)
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) then
is3=is3+1
else
s81(ip(1)-1)=0.
ip=maxloc(s81)
if(icos7(k-1).eq.(ip(1)-1)) nsync2=nsync2+1
endif
if(rrxdt.ge.-0.5) then
synck=s8(icos7(k-1),k)
sumk=(sum(s8(:,k))-synck)/7.0
if(synck.gt.sumk) then
nsyncscore1=nsyncscore1+1
scoreratio1=scoreratio1+synck/sumk
endif
endif
synck=s8(icos7(k-1),k+36)
sumk=(sum(s8(:,k+36))-synck)/7.0
if(synck.gt.sumk) then
nsyncscore2=nsyncscore2+1
scoreratio2=scoreratio2+synck/sumk
endif
if(rrxdt.le.2.13) then
synck=s8(icos7(k-1),k+72)
sumk=(sum(s8(:,k+72))-synck)/7.0
if(synck.gt.sumk) then
nsyncscore3=nsyncscore3+1
scoreratio3=scoreratio3+synck/sumk
endif
endif
enddo
nsyncscore=nsyncscore1+nsyncscore2+nsyncscore3
scoreratio=scoreratio1+scoreratio2+scoreratio3
! hard sync sum - max is 21
nsync=is1+is2+is3
! bail out
rscq=0.
if(lcqcand) then
do k11=8,16
ip=maxloc(s8(:,k11))
if(k11.lt.16) then
if(ip(1).eq.1) rscq=rscq+1.
else
if(ip(1).eq.2) rscq=rscq+1.
endif
enddo
ip=maxloc(s8(:,17))
if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
ip=maxloc(s8(:,27))
if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
ip=maxloc(s8(:,33))
if(ip(1).eq.3 .or. ip(1).eq.4) rscq=rscq+0.5
endif
if(lcqcand .and. nsync.eq.4) then
if(nsync+nsync2.lt.12) then
if(rscq.lt.6.6) then
nbadcrc=1
return
endif
endif
lapcqonly=.true.
else if(lcqcand .and. nsync.eq.5) then
if(nsync+nsync2.lt.12) then
if(rscq.lt.6.1) then
nbadcrc=1
return
endif
endif
lapcqonly=.true.
else if(lcqcand .and. nsync.eq.6) then
if(nsync+nsync2.lt.11) then
if(rscq.lt.5.6) then
nbadcrc=1
return
endif
endif
lapcqonly=.true.
else
if(nsync.lt.7) then
nbadcrc=1
return
endif
endif
lskipnotap=.false.
if(.not.lapcqonly .and. nsync.lt.11) then
nsmax=0
do k=1,7
s81=s8(:,k)
include 'syncdist.f90'
s81=s8(:,k+36)
include 'syncdist.f90'
s81=s8(:,k+72)
include 'syncdist.f90'
enddo
if(sum(nsmax(7:8)).gt.sum(nsmax(2:3)) .or. &
sum(nsmax(5:6)).gt.sum(nsmax(2:3))) lskipnotap=.true.
endif
! if(lcqcand .and. nsync.lt.7 .and. nsync.gt.1) then
! if(nsync+nsync2.lt.9) then
! rscq=0.
! do k11=8,16
! ip=maxloc(s8(:,k11))
! if(k11.lt.16) then; if(ip(1).eq.1) rscq=rscq+1.; else; if(ip(1).eq.2) rscq=rscq+1.; endif
! enddo
! ip=maxloc(s8(:,17)); if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
! ip=maxloc(s8(:,27)); if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
! ip=maxloc(s8(:,33)); if(ip(1).eq.3 .or. ip(1).eq.4) rscq=rscq+0.5
! if(rscq.lt.4.9) then; nbadcrc=1; return; endif
! endif
! else
! if(nsync.lt.7) then; nbadcrc=1; return; endif
! endif
if(nsyncscore.gt.0) then
scoreratio=scoreratio/nsyncscore
else
scoreratio=0.
endif
if(nsyncscore1.gt.0) then
scoreratio1=scoreratio1/nsyncscore1
else
scoreratio1=0.
endif
if(nsyncscore3.gt.0) then
scoreratio3=scoreratio3/nsyncscore3
else
scoreratio3=0.
endif
if(dfqso.ge.2.0 .or. (dfqso.lt.2.0 .and. stophint)) then
if(rrxdt.ge.-0.5 .and. rrxdt.le.2.13) then
if(nsyncscore.lt.8 .or. (nsyncscore.lt.10 .and. scoreratio.lt.5.5) .or. &
(nsyncscore.lt.11 .and. scoreratio.lt.3.63)) then
nbadcrc=1
return ! 377 out of 20709
else if(nsyncscore.eq.11 .and. scoreratio.lt.5.37) then
if(nsyncscore1.lt.5 .and. nsyncscore3.lt.5 .and. scoreratio1.lt.4.2 &
.and. scoreratio3.lt.4.2) then
nbadcrc=1
return ! 261
endif
else if(nsyncscore.eq.12 .and. scoreratio.lt.4.6) then
if(nsyncscore1.lt.5 .and. nsyncscore3.lt.5 .and. scoreratio1.lt.4.0 &
.and. scoreratio3.lt.4.0) then
nbadcrc=1
return ! 222
endif
else if(nsyncscore.eq.13 .and. scoreratio.lt.4.4) then
if(nsyncscore1.lt.5 .and. nsyncscore2.lt.6 .and. nsyncscore3.lt.5 &
.and. scoreratio1.lt.4.4 .and. scoreratio3.lt.4.4) then
nbadcrc=1
return ! 98
endif
else if(nsyncscorew.lt.3) then
if((nsyncscore1.gt.5 .and. scoreratio1.gt.13.8) .or. &
(nsyncscore2.gt.5 .and. scoreratio2.gt.13.8) .or. &
(nsyncscore3.gt.5 .and. scoreratio3.gt.13.8)) go to 32
nbadcrc=1
return ! 75
else if(nsyncscorew.eq.3) then
if(scoreratio1.gt.15. .or. scoreratio2.gt.15. .or. scoreratio3.gt.15.) &
go to 32
nbadcrc=1
return ! 125
else if(nsyncscorew.eq.4) then
if(nsyncscore1.eq.7 .or. nsyncscore2.eq.7 .or. nsyncscore3.eq.7 .or. &
scoreratio1.gt.10. .or. scoreratio2.gt.10. .or. &
scoreratio3.gt.10.) go to 32
nbadcrc=1
return ! 94
else if(nsyncscorew.eq.5) then
if(nsyncscore.gt.17 .or. nsyncscore1.eq.7 .or. nsyncscore2.eq.7 .or. &
nsyncscore3.eq.7 .or. scoreratio1.gt.10. .or. &
scoreratio2.gt.10. .or. scoreratio3.gt.10.) go to 32
nbadcrc=1
return ! 131
endif
else if(rrxdt.lt.-0.5) then
if(nsyncscore.lt.6 .or. (nsyncscore.gt.5 .and. nsyncscore.lt.8 .and. &
nsyncscorew.lt.6 .and. scoreratio2.lt.5.5 .and. &
scoreratio3.lt.5.5)) then
nbadcrc=1
return ! 46
else if(nsyncscore.eq.8) then
if(nsyncscore2.lt.6 .and. nsyncscore3.lt.6 .and. scoreratio2.lt.6.6 &
.and. scoreratio3.lt.6.6) then
nbadcrc=1
return ! 20
endif
else if(nsyncscore.eq.9 .and. scoreratio.lt.6.0) then
if(nsyncscore2.lt.6 .and. nsyncscore3.lt.6 .and. scoreratio2.lt.6.6 &
.and. scoreratio3.lt.6.5) then
nbadcrc=1
return ! 5
endif
else if(nsyncscorew.lt.3) then
if((nsyncscore2.gt.5 .and. scoreratio2.gt.13.8) .or. &
(nsyncscore3.gt.5 .and. scoreratio3.gt.13.8)) go to 32
nbadcrc=1
return ! 22
else if(nsyncscorew.eq.3) then
if(scoreratio2.gt.15. .or. nsyncscore3.gt.15) go to 32
nbadcrc=1
return ! 31
else if(nsyncscorew.eq.4) then
if(nsyncscore2.eq.7 .or. nsyncscore3.eq.7 .or. scoreratio2.gt.10. &
.or. nsyncscore3.gt.10) go to 32
nbadcrc=1
return ! 34
else if(nsyncscorew.eq.5) then
if(nsyncscore.gt.11 .or. nsyncscore2.eq.7 .or. nsyncscore3.eq.7 &
.or. scoreratio2.gt.10. .or. scoreratio3.gt.10.) go to 32
nbadcrc=1
return ! 35
endif
else if(rrxdt.gt.2.13) then
if(nsyncscore.lt.6 .or. (nsyncscore.gt.5 .and. nsyncscore.lt.8 .and. &
nsyncscorew.lt.6 .and. scoreratio1.lt.5.5 .and. &
scoreratio2.lt.5.5)) then
nbadcrc=1
return ! 4
else if(nsyncscore.eq.8) then
if(nsyncscore1.lt.6 .and. nsyncscore2.lt.6 .and. scoreratio1.lt.6.6 &
.and. scoreratio2.lt.6.6) then
nbadcrc=1
return ! 8
endif
else if(nsyncscore.eq.9 .and. scoreratio.lt.6.0) then
if(nsyncscore1.lt.6 .and. nsyncscore2.lt.6 .and. scoreratio2.lt.6.6 &
.and. scoreratio1.lt.6.5) then
nbadcrc=1
return ! 2
endif
else if(nsyncscorew.lt.3) then
if((nsyncscore1.gt.5 .and. scoreratio1.gt.13.8) .or. &
(nsyncscore2.gt.5 .and. scoreratio2.gt.13.8)) go to 32
nbadcrc=1
return ! 12
else if(nsyncscorew.eq.3) then
if(scoreratio1.gt.15. .or. scoreratio2.gt.15.) go to 32
nbadcrc=1
return ! 32
else if(nsyncscorew.eq.4) then
if(nsyncscore1.eq.7 .or. nsyncscore2.eq.7 .or. scoreratio1.gt.10. &
.or. nsyncscore2.gt.10) go to 32
nbadcrc=1
return ! 103
else if(nsyncscorew.eq.5) then
if(nsyncscore.gt.11 .or. nsyncscore1.eq.7 .or. nsyncscore2.eq.7 &
.or. scoreratio1.gt.10. .or. scoreratio2.gt.10.) go to 32
nbadcrc=1
return ! 0
endif
endif
endif
32 if(lsd) then
if(iqso.eq.4 .and. .not.ldeepsync) go to 64
call ft8sd1var(s8,itone,msgd,msg37,lft8sd,lcq,codec)
if(lft8sd) then
if(levenint) then
evencopy(isd)%lstate=.false.
elseif(loddint) then
oddcopy(isd)%lstate=.false.
endif
i3=1
n3=1
iaptype2=iaptype
iaptype=0
nbadcrc=0
lsd=.false.
go to 2
endif
64 if(iqso.eq.4) then
if(.not.lcq) then
call ft8mf1var(s8,itone,msgd,msg37,lft8sd)
if(lft8sd) then
if(levenint) then
evencopy(isd)%lstate=.false.
elseif(loddint) then
oddcopy(isd)%lstate=.false.
endif
i3=1
n3=1
iaptype2=iaptype
iaptype=0
nbadcrc=0
lsd=.false.
go to 2
endif
else
call ft8mfcqvar(s8,itone,msgd,msg37,lft8sd,codec)
if(lft8sd) then
if(levenint) then
evencopy(isd)%lstate=.false.
elseif(loddint) then
oddcopy(isd)%lstate=.false.
endif
i3=1
n3=1
iaptype2=iaptype
iaptype=0
nbadcrc=0
lsd=.false.
go to 2
endif
endif
endif
endif
if(iqso.eq.4) then
nbadcrc=1
go to 2
endif
synclev=0.0
snoiselev=1.0
do k=1,7
synclev=synclev+s8(icos7(k-1),k+36)
enddo
snoiselev=(sum(s8(0:7,37:43))- synclev)/7.0
if(snoiselev.lt.0.1) snoiselev=1.0 ! safe division
srr=synclev/snoiselev
! SNR srr range average srr
! -18 1.8...4.0 2.9
! -19 1.7...3.6 2.65
! -20 1.6...3.3 2.43
! -21 1.6...3.0 2.22
! -22 1.55...2.8 2.19
! -23 1.4...2.6 2.03
! -24 1.94
8 if(iqso.gt.1 .and. iqso.lt.4) then
if(.not.lqsomsgdcd .and. .not.(.not.lmycallstd .and. .not.lhiscallstd)) then
if(.not.lft8sdec .and. dfqso.lt.2.0) then
if(lvirtual2 .or. lvirtual3) srr=0.0
call ft8svar(s82,srr,itone,msg37,lft8s,nft8rxfsens,stophint,codec)
if(lft8s) then
if(index(msg37,'<').gt.0) then
lhashmsg=.true.
endif
nbadcrc=0
lft8sdec=.true.
lsdone=.true.
go to 2 ! i3=16 n3=16, any affect?
endif
endif
endif
lsdone=.true.
nbadcrc=1
cycle
endif
i1=ibest+224 ! 7*32
csymb256=cd0(i1:i1+255)*ctwk256
call four2avar(csymb256,256,1,-1,1)
s256(0:8)=abs(csymb256(1:9))
rscq=0.
nmic=0
do k11=8,16
ip=maxloc(s8(:,k11))
if(ip(1).eq.idtonemyc(k11-7)+1) nmic=nmic+1
if(k11.lt.16) then
if(ip(1).eq.1) rscq=rscq+1.
else
if(ip(1).eq.2) rscq=rscq+1.
endif
enddo
ip=maxloc(s8(:,17))
if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
ip=maxloc(s8(:,27))
if(ip(1).eq.1 .or. ip(1).eq.2) rscq=rscq+0.5
ip=maxloc(s8(:,33))
if(ip(1).eq.3 .or. ip(1).eq.4) rscq=rscq+0.5
lqsosig=.false.
lqsosigtype3=.false.
lqso73=.false.
lqsorr73=.false.
lqsorrr=.false. ! 73/rr73/rrr for std/nonstd callsigns
if(.not.lqsomsgdcd .and. (dfqso.lt.napwid .or. abs(nftx-f1).lt.napwid) .and. &
lapmyc .and. len_trim(hiscall).gt.2) then
nqsot=0
if(idtone56_valid(1)) then
do i=1,19
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
enddo
if(nqsot.gt.6) lqsosig=.true. ! decoding depth only
do i=20,22
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
enddo
if(nqsot.gt.3) lqsosigtype3=.true.
endif
nqsoend=0 ! array 73,rr73,rrr
if(dfqso.lt.napwid .and. (nQSOProgress.eq.3 .or. nQSOProgress.eq.4)) then
! QSO RX freq only
do i=24,58
if(i.lt.30) then
ip=maxloc(s8(:,i+7))
else
ip=maxloc(s8(:,i+14))
endif
if(idtone56_valid(56) .and. ip(1).eq.idtone56(56,i)+1) nqsoend(1)=nqsoend(1)+1
if(idtone56_valid(55) .and. ip(1).eq.idtone56(55,i)+1) nqsoend(2)=nqsoend(2)+1
if(idtone56_valid(54) .and. ip(1).eq.idtone56(54,i)+1) nqsoend(3)=nqsoend(3)+1
enddo
ip=maxloc(nqsoend)
if(nqsoend(ip(1)).gt.6) then
if(ip(1).eq.1) then
lqso73=.true.
else if(ip(1).eq.2) then
lqsorr73=.true.
else if(ip(1).eq.3) then
lqsorrr=.true.
endif
endif
endif
endif
lcqsignal=.false.
ip(1)=maxloc(s256,1)
if(ip(1).eq.5 .or. rscq.gt.3.1) lcqsignal=.true.
if(.not.lcqsignal .and. ip(1).eq.4 .or. ip(1).eq.6) then
s2563(0:8)=s256(0:8)
s2563(9:26)=abs(csymb256(9:26))
ip(1)=maxloc(s2563,1)
if(ip(1).eq.4 .or. ip(1).eq.6) lcqsignal=.true.
endif
lmycsignal=.false.
if(lapmyc .and. nmic.gt.2) lmycsignal=.true.
ldxcsig=.false.
lcqdxcsig=.false.
lcqdxcnssig=.false.
ndxt=0
if(lhiscallstd) then
if(idtone56_valid(1)) then
do k11=17,26
ip=maxloc(s8(:,k11))
if(ip(1).eq.idtone56(1,k11-7)+1) ndxt=ndxt+1
enddo
endif
if(ndxt.gt.3) ldxcsig=.true.
if(lcqsignal .and. ldxcsig) lcqdxcsig=.true.
endif
! nonstd DXCall search in idle mode
if(.not.lhiscallstd .and. len_trim(hiscall).gt.2) then ! nonstandard DXCall
ncqdxcnst=0
do i=1,4
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtonecqdxcns(i)+1) ncqdxcnst=ncqdxcnst+1
enddo
ndxt=0
do i=5,23
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtonedxcns73(i)+1) ndxt=ndxt+1
if(ip(1).eq.idtonecqdxcns(i)+1) ncqdxcnst=ncqdxcnst+1
enddo
ldxcsig=.false.
if(dfqso.lt.napwid) then
if(ndxt.gt.4) ldxcsig=.true. ! relaxed threshold for RXF napwid
if(ncqdxcnst.gt.5) lcqdxcnssig=.true.
else
if(ndxt.gt.5) ldxcsig=.true.
if(ncqdxcnst.gt.6) lcqdxcnssig=.true.
endif
endif
lfoxstdr73=.false.
lfoxspecrpt=.false.
nfoxspecrpt=0 ! checking fo special message with report to mybcall
if(lhound) then
nfoxstdbase=0 ! checking for report signal and base of RR73 signal
nfoxspecr73=0 ! checking fo special message with RR73 to mybcall
nfoxr73=0 ! checking for RR73 signal with standard message
fdelta=abs(f1-nfqso)
fdeltam=modulo(fdelta,60.)
if(fdelta.lt.245.0 .and. fdeltam.lt.3.0 .and. (nQSOProgress.eq.1 .or. &
nQSOProgress.eq.3)) then ! calculate on possible Fox frequencies only
do i=1,18
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtonefox73(i)+1) nfoxstdbase=nfoxstdbase+1
if(i.gt.10 .and. ip(1).eq.idtonespec(i)+1) nfoxspecrpt=nfoxspecrpt+1
enddo
do i=20,22 ! hash10
ip=maxloc(s8(:,i+7))
if(ip(1).eq.idtonespec(i)+1) then
nfoxspecrpt=nfoxspecrpt+1
nfoxspecr73=nfoxspecr73+1
endif
enddo
ip=maxloc(s8(:,25+7)) ! i3,n3
if(ip(1).eq.idtonespec(25)+1) then
nfoxspecrpt=nfoxspecrpt+1
nfoxspecr73=nfoxspecr73+1
endif
if(nfoxstdbase.eq.0) then
rspecstdrpt=(nfoxspecrpt*18.)/(1.2)
else
rspecstdrpt=(nfoxspecrpt*18.)/(12.*nfoxstdbase)
endif
if(rspecstdrpt.gt.1.) lfoxspecrpt=.true.
if(nQSOProgress.eq.3) then
do i=24,58
if(i.lt.30) then
ip=maxloc(s8(:,i+7))
else
ip=maxloc(s8(:,i+14))
endif
if(ip(1).eq.idtonefox73(i)+1) nfoxr73=nfoxr73+1
enddo
if(nfoxspecr73.eq.0) then
rstdr73=(nfoxr73*4.)/(3.5)
else
rstdr73=(nfoxr73*4.)/(35.*nfoxspecr73)
endif
if(rstdr73.gt.1.) lfoxstdr73=.true.
endif
endif
endif
lsubptxfreq=.false.
if(lapmyc .and. abs(f1-nftx).lt.2.0 .and. .not.lhound .and. .not.lft8sdec &
.and. .not.lqsomsgdcd .and. ((.not.lskiptx1 .and. nlasttx.eq.1) .or. &
(lskiptx1 .and. nlasttx.eq.2))) lsubptxfreq=.true.
nweak=1
if(lft8subpass .or. dfqso.lt.2.0 .or. lsubptxfreq) nweak=2
nsubpasses=nweak
if(lcqsignal) then
nsubpasses=3
if(levenint) then
do ik=1,numcqsig
if(evencq(ik,nthr)%freq.gt.5001.) exit
if(abs(evencq(ik,nthr)%freq-f1).lt.2.0 .and. &
abs(evencq(ik,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=5
csold=evencq(ik,nthr)%cs
endif
enddo
else if (loddint) then
do ik=1,numcqsig
if(oddcq(ik,nthr)%freq.gt.5001.) exit
if(abs(oddcq(ik,nthr)%freq-f1).lt.2.0 .and. &
abs(oddcq(ik,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=5
csold=oddcq(ik,nthr)%cs
endif
enddo
endif
endif
if(lmycsignal .and. lmycallstd) then
nsubpasses=6
if(levenint) then
do ik=1,nummycsig
if(evenmyc(ik,nthr)%freq.gt.5001.) exit
if(abs(evenmyc(ik,nthr)%freq-f1).lt.2.0 .and. &
abs(evenmyc(ik,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=8
csold=evenmyc(ik,nthr)%cs
endif
enddo
else if (loddint) then
do ik=1,nummycsig
if(oddmyc(ik,nthr)%freq.gt.5001.) exit
if(abs(oddmyc(ik,nthr)%freq-f1).lt.2.0 .and. &
abs(oddmyc(ik,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=8
csold=oddmyc(ik,nthr)%cs
endif
enddo
endif
endif
lqsocandave=.false.
if(lapmyc .and. ndxt.gt.2 .and. nmic.gt.2 .and. .not.lqsomsgdcd .and. &
lmycallstd .and. lhiscallstd .and. dfqso.lt.napwid/2.0) then
lqsocandave=.true.
nsubpasses=9
if(levenint) then
if(abs(evenqso(1,nthr)%freq-f1).lt.2.0 .and. &
abs(evenqso(1,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=11
csold=evenqso(1,nthr)%cs
endif
else if (loddint) then
if(abs(oddqso(1,nthr)%freq-f1).lt.2.0 .and. &
abs(oddqso(1,nthr)%xdt-xdt).lt.0.05) then
nsubpasses=11
csold=oddqso(1,nthr)%cs
endif
endif
endif
do isubp1=1,nsubpasses
call write_decode_progress(progress_generation)
if(nweak.eq.1 .and. isubp1.eq.2) cycle
! skip if it is lmycsignal, can be both lcq and lmy
if(isubp1.gt.2 .and. isubp1.lt.6 .and. lmycsignal) cycle
syncavemax=3.
if(isubp1.eq.2) cs=csr
if(ipass.eq.npass-1 .and. (lcqsignal .or. lmycsignal) .and. &
((nweak.eq.1 .and. isubp1.eq.1) .or. (nweak.eq.2 .and. &
isubp1.eq.2))) cstmp2=cs
if(ipass.eq.npass .and. lapmyc .and. ndxt.gt.2 .and. nmic.gt.2 .and. &
((nweak.eq.1 .and. isubp1.eq.1) .or. &
(nweak.eq.2 .and. isubp1.eq.2))) cstmp2=cs
do nsym=1,3
nt=2**(3*nsym)-1
do ihalf=1,2
do k=1,29,nsym
if(ihalf.eq.1) then
ks=k+7
else
ks=k+43
endif
ks1=ks+1
ks2=ks+2
do i=0,nt
i1=i/64
i2=iand(i,63)/8
i33=iand(i,7)
if(isubp1.lt.3) then
if(nsym.eq.1) then
s2(i)=abs(cs(graymap(i33),ks))
elseif(nsym.eq.2) then
s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i33),ks1))
else
s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks1) + &
cs(graymap(i33),ks2))
endif
else if(isubp1.eq.3 .or. isubp1.eq.6 .or. isubp1.eq.9) then
if(nsym.eq.1) then
s2(i)=abs(cscs(graymap(i33),ks))**2 + &
abs(csr(graymap(i33),ks))**2
elseif(nsym.eq.2) then
s2(i)=abs(cscs(graymap(i2),ks) + &
cscs(graymap(i33),ks1))**2 + &
abs(csr(graymap(i2),ks)+csr(graymap(i33),ks1))**2
else
s2(i)=abs(cscs(graymap(i1),ks) + &
cscs(graymap(i2),ks1)+cscs(graymap(i33),ks2))**2 + &
abs(csr(graymap(i1),ks)+csr(graymap(i2),ks1) + &
csr(graymap(i33),ks2))**2
endif
else if(isubp1.eq.4 .or. isubp1.eq.7 .or. isubp1.eq.10) then
if(nsym.eq.1) then
s2(i)=abs(cs(graymap(i33),ks))**2 + &
abs(csold(graymap(i33),ks))**2
elseif(nsym.eq.2) then
s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i33),ks1))**2 + &
abs(csold(graymap(i2),ks)+csold(graymap(i33),ks1))**2
else
s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks1) + &
cs(graymap(i33),ks2))**2 + &
abs(csold(graymap(i1),ks)+csold(graymap(i2),ks1) + &
csold(graymap(i33),ks2))**2
endif
else if(isubp1.eq.5 .or. isubp1.eq.8 .or. isubp1.eq.11) then
if(nsym.eq.1) then
s2(i)=abs(cs(graymap(i33),ks))+abs(csold(graymap(i33),ks))
elseif(nsym.eq.2) then
s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i33),ks1)) + &
abs(csold(graymap(i2),ks)+csold(graymap(i33),ks1))
else
s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks1) + &
cs(graymap(i33),ks2)) + &
abs(csold(graymap(i1),ks)+csold(graymap(i2),ks1) + &
csold(graymap(i33),ks2))
endif
endif
if(isubp1.eq.1 .and. srr.lt.2.5) then
! srr.lt.2.5 -19dB SNR threshold
if(srr.gt.2.3) then
s2(i)=s2(i)**2
else
ss1=s2(i)
if(ss1.lt.5.77) then
s2(i)=1+8.*ss1**2-0.12*ss1**4
else
s2(i)=(ss1+5.82)**2
endif
endif
endif
if(isubp1.gt.1 .and. srr.lt.2.5) then
s2(i)=(0.5*s2(i))**3 ! -19dB SNR threshold
endif
enddo
i32=1+(k-1)*3+(ihalf-1)*87
if(nsym.eq.1) ibmax=2
if(nsym.eq.2) ibmax=5
if(nsym.eq.3) ibmax=8
do ib=0,ibmax
bm=maxval(s2(0:nt),one(0:nt,ibmax-ib)) - &
maxval(s2(0:nt),.not.one(0:nt,ibmax-ib))
if(i32+ib .gt.174) cycle
if(nsym.eq.1) then
bmeta(i32+ib)=bm
den=max(maxval(s2(0:nt),one(0:nt,ibmax-ib)), &
maxval(s2(0:nt),.not.one(0:nt,ibmax-ib)))
if(den.gt.0.0) then
cm=bm/den
else
cm=0.0
endif
bmetd(i32+ib)=cm
elseif(nsym.eq.2) then
bmetb(i32+ib)=bm
elseif(nsym.eq.3) then
bmetc(i32+ib)=bm
endif
enddo
enddo ! k
enddo ! ihalf
enddo ! nsym
!tests
!call indexx(bmetc(1:174),174,indx)
!src=abs(bmetc(indx(1))/bmetc(indx(174)))
!print *,src
call normalizebmetvar(bmeta,174)
call normalizebmetvar(bmetb,174)
call normalizebmetvar(bmetc,174)
call normalizebmetvar(bmetd,174)
scalefac=2.83
llra=scalefac*bmeta
llrb=scalefac*bmetb
llrc=scalefac*bmetc
llrd=scalefac*bmetd
apmag=maxval(abs(llra))*1.01
! isubp2 #
!------------------------------
! 1 regular decoding, nsym=1
! 2 regular decoding, nsym=2
! 3 regular decoding, nsym=3
! 4 regular decoding, llrd
! 5..18 ap passes
! iaptype Hound OFF, MyCall is standard, DXCall is standard or empty
!------------------------
! 0 cycle
! 1 CQ ??? ??? (29+3=32 ap bits)
! 2 MyCall ??? ??? (29+3=32 ap bits)
! 3 MyCall DxCall ??? (58+3=61 ap bits)
! 4 MyCall DxCall RRR (77 ap bits)
! 5 MyCall DxCall 73 (77 ap bits)
! 6 MyCall DxCall RR73 (77 ap bits)
! naptypes(nQSOProgress, extra decoding pass)
! 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
! 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
! data naptypes(0,1:27)/3,3,3,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx6 CQ
! data naptypes(1,1:27)/3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx1 Grid
! data naptypes(2,1:27)/3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx2 Report
! data naptypes(3,1:27)/3,3,3,6,6,6,5,5,5,4,4,4,0,0,0,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx3 RRreport
! data naptypes(4,1:27)/3,3,3,6,6,6,5,5,5,4,4,4,2,2,2,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx4 RRR,RR73
! data naptypes(5,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx5 73
! iaptype standard DxCall tracking, also valid in Hound mode
!------------------------
! 31 CQ DxCall Grid(???) (77 ap bits)
! 35 ??? DxCall 73 (29+19 ap bits)
! 36 ??? DxCall RR73 (29+19 ap bits)
! iaptype Hound off, MyCall is nonstandard, DXCall is standard or empty
!------------------------
! 0 cycle
! 1 CQ ??? ??? (29+3=32 ap bits)
! 40 <MyCall> ??? ??? (29+3=32 ap bits) incoming call
! 41 <MyCall> DxCall ??? (58 ap bits) REPORT/RREPORT
! 42 MyCall <DxCall> RRR (77 ap bits)
! 43 MyCall <DxCall> 73 (77 ap bits)
! 44 MyCall <DxCall> RR73 (77 ap bits)
! 31 CQ DxCall Grid(???) (77 ap bits) standard DxCall tracking
! 35 ??? DxCall 73 (29+19 ap bits) standard DxCall tracking
! 36 ??? DxCall RR73 (29+19 ap bits) standard DxCall tracking
! nmycnsaptypes(nQSOProgress, extra decoding pass)
! data nmycnsaptypes(0,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,40,40,40,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx6 CQ
! data nmycnsaptypes(1,1:27)/41,41,41,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx1 DXcall MyCall
! data nmycnsaptypes(2,1:27)/41,41,41,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx2 Report
! data nmycnsaptypes(3,1:27)/41,41,41,44,44,44,43,43,43,42,42,42,0,0,0,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx3 RRreport
! data nmycnsaptypes(4,1:27)/41,41,41,44,44,44,43,43,43,42,42,42,40,40,40,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx4 RRR,RR73
! data nmycnsaptypes(5,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,40,40,40,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx5 73
! iaptype Hound off, MyCall is standard, DXCall is not empty and is nonstandard
!------------------------
! 0 cycle
! 1 CQ ??? ??? (29+3=32 ap bits)
! 2 MyCall ??? ??? (29+3=32 ap bits)
! 11 MyCall <DxCall> ??? (58 ap bits) REPORT/RREPORT
! 12 <MyCall> DxCall RRR (77 ap bits)
! 13 <MyCall> DxCall 73 (77 ap bits)
! 14 <MyCall> DxCall RR73 (77 ap bits)
! 31 CQ DxCall (77 ap bits) ! full compound or just nonstandard callsign
! 35 ??? DxCall 73 (64 ap bits) ! full compound or just nonstandard callsign
! 36 ??? DxCall RR73 (64 ap bits) ! full compound or just nonstandard callsign
! ndxnsaptypes(nQSOProgress, extra decoding pass)
! data ndxnsaptypes(0,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx6 CQ
! data ndxnsaptypes(1,1:27)/11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx1 Grid
! data ndxnsaptypes(2,1:27)/11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx2 Report
! data ndxnsaptypes(3,1:27)/11,11,11,14,14,14,13,13,13,12,12,12,0,0,0,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx3 RRreport
! data ndxnsaptypes(4,1:27)/11,11,11,14,14,14,13,13,13,12,12,12,2,2,2,0,0,0,31,31,31,36,36,36,35,35,35/ ! Tx4 RRR,RR73
! data ndxnsaptypes(5,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,31,31,31,36,36,36,35,35,35/ ! Tx5 73
! iaptype Hound mode
!------------------------
! 0 cycle
! 1 CQ ??? ??? (29+3=32 ap bits) standard callsign
! 21 MyBaseCall DxBaseCall ??? (58+3=61 ap bits) Report
! 22 ??? RR73; MyCall <???> ??? (28+6=34 ap bits)
! 23 MyBaseCall DxBaseCall RR73 (77 ap bits)
! 24 MyCall RR73; ??? <???> ??? (28+6=34 ap bits)
! 31 CQ DxCall (DXGrid) (77 ap bits) ! standard/full compound or just nonstandard callsign
! 36 ??? DxCall RR73 (29+19/64 ap bits) ! standard/ full compound or just nonstandard callsign
! 111 CQ ??? (3 last i3 bits) type 4 message with nonstandard callsign
! nhaptypes(nQSOProgress, extra decoding pass)
! data nhaptypes(0,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,111,111,111/ ! Tx6 CQ, possible in idle mode if DXCall is empty
! data nhaptypes(1,1:27)/21,21,21,22,22,22,0,0,0,0,0,0,0,0,0,31,31,31,0,0,0,36,36,36,0,0,0/ ! Tx1 Grid idle mode or transmitting
! data nhaptypes(2,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/ ! Tx2 none
! data nhaptypes(3,1:27)/21,21,21,22,22,22,23,23,23,24,24,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/ ! Tx3 RRreport QSO in progress or QSO is finished
! data nhaptypes(4,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/ ! Tx4 none
! data nhaptypes(5,1:27)/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/ ! Tx5 none
loutapwid=.false.
loutapwid=abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid
scqnr=2.
smycnr=2.
! print*,'stophint is ',stophint,' lft8sdec is ',lft8sdec
! print*,'lnohiscall is ',lnohiscall,' loutapwid is ',loutapwid
! print*,'lenabledxcsearch ',lenabledxcsearch, ' lwidedxcsearch is ',lwidedxcsearch
! print*,'lcqdxcsig is', lcqdxcsig
! print*,'lcqsignal is',lcqsignal
! print*,'ldxcsig',ldxcsig
! print*,'lhiscallstd',lhiscallstd
! print*,'mycall ',mycall,mybcall
! print*,'hiscall ',hiscall,hisbcall
! print*,'hisgrid is ',hisgrid
do isubp2=1,31
call write_decode_progress(progress_generation)
if(isubp2.lt.5) then
if(lapcqonly .or. lskipnotap) cycle
if(ltxing) then
! enabled Tx and transmitted message including CQ at last interval
if(abs(f1-nfqso).lt.3.0) then ! +- 3Hz sync8var QSOfreq candidate list
if(syncavemax.lt.1.8) cycle
else
if(syncavemax.lt.1.9) cycle
endif
else
if(syncavemax.lt.1.8) cycle
endif
endif
if(isubp2.eq.4) cycle
if(isubp1.gt.2 .and. isubp2.lt.5) cycle ! skip regular decoding for extra subpasses
if(lqsocandave) then
if(isubp1.gt.2 .and. isubp1.lt.9) cycle ! skip other extra subpasses if QSO signal, highest priority
if(lqsomsgdcd) cycle
else if(lmycsignal .and. lmycallstd) then
if(isubp1.gt.2 .and. isubp1.lt.6) cycle ! skip CQ signal extra subpasses if MyCall signal
endif
if(isubp2.lt.5) then
apmask=0
iaptype2=iaptype
iaptype=0
if(isubp2.eq.1) then
if(ipass.eq.1) then
llrz=llrd
else
llrz=llra
endif
if(isubp1.gt.1 .and. ipass.gt.1) llrz=llrd
else if(isubp2.eq.2) then
llrz=llrb
if(isubp1.gt.1) llrz=llra
else if(isubp2.eq.3) then
llrz=llrc
else if(isubp2.eq.4) then
llrz=llrd
endif
else
if(.not.lhound) then
if(lmycallstd .and. (lhiscallstd .or. lnohiscall)) then
iaptype=naptypes(nQSOProgress,isubp2-4)
iaptype2=iaptype
! print*,'line 1357 iaptype,isubp1,isubp2 = ',iaptype,isubp1,isubp2
if(iaptype.eq.0) cycle
if(lqsomsgdcd .and. iaptype.gt.2 .and. iaptype.lt.31) cycle ! QSO message already decoded
if(iaptype.eq.2) then
if(.not.lapmyc .or. lapcqonly) cycle ! skip AP for 'mycall ???? ????' in 2..3 minutes after last TX
if(nQSOProgress.ne.0 .and. nmic.lt.2) cycle ! reduce CPU load at QSO
endif
! if(.not.stophint .and. iaptype.gt.30) cycle ! no DXCall searching at QSO, reduce Lag
! if(stophint .and. iaptype.gt.2 .and. iaptype.lt.31) cycle
if(lft8sdec .and. iaptype.gt.2) cycle ! QSO message already decoded
if(iaptype.gt.2 .and. lnohiscall) cycle ! no DXCall
if(iaptype.gt.2 .and. iaptype.lt.31 .and. loutapwid) cycle
! if(iaptype.eq.3 .and. .not.lqsosigtype3) cycle ! not QSO signal
! if(iaptype.eq.4 .and. .not.lqsorrr) cycle ! not RRR signal
! if(iaptype.eq.5 .and. .not.lqso73) cycle ! not 73 signal
! if(iaptype.eq.6 .and. .not.lqsorr73) cycle ! not RR73 signal
if(iaptype.gt.30 .and. .not.lenabledxcsearch) cycle ! in QSO or TXing CQ or last logged is DX Call: searching disabled
if(iaptype.gt.30 .and. .not.lwidedxcsearch .and. loutapwid) cycle ! only RX freq DX Call searching
if(iaptype.eq.31 .and. .not.lcqdxcsig) cycle ! not CQ signal from std DXCall
if(iaptype.eq.31 .and. .not.lhiscallstd .and. lapcqonly) cycle ! skip weak CQ signals with std call
if(iaptype.gt.31 .and. lapcqonly) cycle ! skip weak CQ signals
if(iaptype.eq.35 .and. .not.lqso73) cycle ! DXCall searching, not 73 signal
if(iaptype.eq.36 .and. .not.lqsorr73) cycle ! DXCall searching, not RR73 signal
if(lqsocandave .and. isubp1.gt.8 .and. (iaptype.lt.3 .or. iaptype.gt.6)) cycle ! QSO signal
! if(.not.lqsocandave .and. lmycsignal .and. isubp1.gt.5 .and. isubp1.lt.9 .and. iaptype.ne.2) cycle ! skip other AP if lmycsignal extra subpasses)
if(iaptype.eq.1) then
if(isubp2.eq.20) then
if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-scqlev)/7.0
scqnr=scqlev/snoiselev
if(scqnr.lt.1.0 .and. .not.lcqsignal) cycle
endif
if(isubp2.eq.21) then
if(lft8lowth .or. lft8subpass) then
if(scqnr.lt.1.2 .and. .not.lcqsignal) cycle
endif
if(.not. lft8subpass .and. .not.lft8lowth) then
if(scqnr.lt.1.3 .and. .not.lcqsignal) cycle
endif
endif
endif
if(iaptype.eq.2) then
if(isubp2.eq.17) then
smyclev=0.
do i4=1,9
smyclev=smyclev+s8(idtonemyc(i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-smyclev)/7.0
smycnr=smyclev/snoiselev
if(smycnr.lt.1.0 .and. .not.lmycsignal) cycle
endif
if(isubp2.eq.18) then
if(lft8lowth .or. lft8subpass) then
if(smycnr.lt.1.2 .and. .not.lmycsignal) cycle
endif
endif
endif
if(iaptype.eq.3) then
if(isubp2.eq.5) then
smyclev=0.
do i4=1,9
smyclev=smyclev+s8(idtonemyc(i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-smyclev)/7.0
smycnr=smyclev/snoiselev
if(smycnr.lt.1.0) cycle
else if(isubp2.eq.6) then
if(smycnr.lt.1.2) cycle
endif
endif
apmask=0
if(iaptype.eq.1) then ! CQ
if(isubp2.eq.20) then
llrz=llrc
else if(isubp2.eq.21) then
llrz=llrb
else if(isubp2.eq.22) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.2) then ! MyCall ??? ???
if(isubp2.eq.17) then
llrz=llrc
else if(isubp2.eq.18) then
llrz=llrb
else if(isubp2.eq.19) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*apsym(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.3) then ! MyCall DxCall ???
if(isubp2.eq.5) then
llrz=llrc
else if(isubp2.eq.6) then
llrz=llrb
else if(isubp2.eq.7) then
llrz=llra
endif
apmask(1:58)=1
llrz(1:58)=apmag*apsym
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.gt.3 .and. iaptype.lt.7) then
if(isubp2.eq.8 .or. isubp2.eq.11 .or. isubp2.eq.14) then
llrz=llrc
else if(isubp2.eq.9 .or. isubp2.eq.12 .or. isubp2.eq.15) then
llrz=llrb
else if(isubp2.eq.10 .or. isubp2.eq.13 .or. isubp2.eq.16) then
llrz=llrb
endif
apmask(1:77)=1
llrz(1:58)=apmag*apsym ! mycall hiscall 73|RR73
if(iaptype.eq.5) then
llrz(59:77)=apmag*m73
else if(iaptype.eq.6) then
llrz(59:77)=apmag*mrr73
else if(iaptype.eq.4) then
llrz(59:77)=apmag*mrrr
endif
else if(iaptype.eq.31) then ! CQ DxCall Grid(???)
if(isubp2.eq.23) then
llrz=llrc
else if(isubp2.eq.24) then
llrz=llrb
else if(isubp2.eq.25) then
llrz=llra
endif
if(lnohisgrid) then
apmask(1:58)=1
llrz(1:58)=apmag*apcqsym(1:58)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
endif
else if(iaptype.eq.35) then ! ??? DxCall 73, type 1 std DXCall
if(isubp2.eq.29) then
llrz=llrc
else if(isubp2.eq.30) then
llrz=llrb
else if(isubp2.eq.31) then
llrz=llra
endif
apmask(30:77)=1
llrz(30:58)=apmag*apsym(30:58)
llrz(59:77)=apmag*m73
else if(iaptype.eq.36) then ! ??? DxCall RR73 type 1 std DXCall
if(isubp2.eq.26) then
llrz=llrc
else if(isubp2.eq.27) then
llrz=llrb
else if(isubp2.eq.28) then
llrz=llra
endif
apmask(30:77)=1
llrz(30:58)=apmag*apsym(30:58)
llrz(59:77)=apmag*mrr73
endif
!! print*,'line 1533 iaptype,isubp1,isubp2 = ',iaptype,isubp1,isubp2
else if(lmycallstd .and. .not.lhiscallstd .and. &
len_trim(hiscall).gt.2) then
iaptype=ndxnsaptypes(nQSOProgress,isubp2-4)
iaptype2=iaptype
if(iaptype.eq.0) cycle
if(iaptype.eq.2 .and. lapcqonly) cycle ! skip weak CQ signals
if(.not.stophint .and. iaptype.gt.30) cycle ! no DXCall searching at QSO, reduce Lag
if((lqsomsgdcd .or. .not.lapmyc) .and. iaptype.gt.1 .and. iaptype.lt.15) cycle ! skip AP for mycall in 2..3 minutes after last TX
if(iaptype.eq.12 .and. .not.lqsorrr) cycle ! not RRR signal
if(iaptype.eq.13 .and. .not.lqso73) cycle ! not 73 signal
if(iaptype.eq.14 .and. .not.lqsorr73) cycle ! not RR73 signal
if(iaptype.gt.30 .and. .not.lenabledxcsearch) cycle ! in QSO or TXing CQ or last logged is DX Call: searching disabled
if(iaptype.gt.30 .and. .not.lwidedxcsearch .and. loutapwid) cycle ! only RX freq DX Call searching
if(iaptype.gt.30 .and. lapcqonly) cycle ! skip weak CQ signals
if(iaptype.eq.31 .and. .not.lcqdxcnssig) cycle ! it is not CQ signal of non-standard DXCall
if(iaptype.eq.35 .and. .not.lqso73) cycle ! DXCall searching, not 73 signal
if(iaptype.eq.36 .and. .not.lqsorr73) cycle ! DXCall searching, not RR73 signal
if(lqsocandave .and. isubp1.gt.8 .and. (iaptype.lt.11 .or. iaptype.gt.14)) cycle ! QSO signal
if(iaptype.gt.2 .and. iaptype.lt.15 .and. loutapwid) cycle
if(iaptype.eq.1) then
if(isubp2.eq.20) then
if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-scqlev)/7.0
scqnr=scqlev/snoiselev
if(scqnr.lt.1.0 .and. .not.lcqsignal) cycle
endif
if(isubp2.eq.21) then
if(lft8lowth .or. lft8subpass) then
if(scqnr.lt.1.2 .and. .not.lcqsignal) cycle
endif
if(.not. lft8subpass .and. .not.lft8lowth) then
if(scqnr.lt.1.3 .and. .not.lcqsignal) cycle
endif
endif
endif
if(iaptype.eq.2) then
if(isubp2.eq.17) then
smyclev=0.
do i4=1,9
smyclev=smyclev+s8(idtonemyc(i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-smyclev)/7.0
smycnr=smyclev/snoiselev
if(smycnr.lt.1.0 .and. .not.lmycsignal) cycle
endif
if(isubp2.eq.18) then
if(lft8lowth .or. lft8subpass) then
if(smycnr.lt.1.2 .and. .not.lmycsignal) cycle
endif
endif
endif
apmask=0
if(iaptype.eq.1) then ! CQ ??? ???
if(isubp2.eq.20) then
llrz=llrc
else if(isubp2.eq.21) then
llrz=llrb
else if(isubp2.eq.22) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.2) then ! MyCall ??? ???
if(isubp2.eq.17) then
llrz=llrc
else if(isubp2.eq.18) then
llrz=llrb
else if(isubp2.eq.19) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*apsym(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.11) then ! MyCall <DxCall> ??? ! report rreport type 1 msg
if(isubp2.eq.5) then
llrz=llrc
else if(isubp2.eq.6) then
llrz=llrb
else if(isubp2.eq.7) then
llrz=llra
endif
apmask(1:58)=1
llrz(1:58)=apmag*apsymdxns1
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.12) then ! type 4 <MyCall> DxCall RRR
if(isubp2.eq.14) then
llrz=llrc
else if(isubp2.eq.15) then
llrz=llrb
else if(isubp2.eq.16) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymdxnsrrr
else if(iaptype.eq.13) then ! type 4 <MyCall> DxCall 73
if(isubp2.eq.11) then
llrz=llrc
else if(isubp2.eq.12) then
llrz=llrb
else if(isubp2.eq.13) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymdxns732
else if(iaptype.eq.14) then ! type 4 <MyCall> DxCall RR73
if(isubp2.eq.8) then
llrz=llrc
else if(isubp2.eq.9) then
llrz=llrb
else if(isubp2.eq.10) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymdxnsr73
else if(iaptype.eq.31) then ! CQ DxCall ! full compound or nonstandard
if(isubp2.eq.23) then
llrz=llrc
else if(isubp2.eq.24) then
llrz=llrb
else if(isubp2.eq.25) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
else if(iaptype.eq.35) then ! ??? DxCall 73 ! full compound or nonstandard
if(isubp2.eq.29) then
llrz=llrc
else if(isubp2.eq.30) then
llrz=llrb
else if(isubp2.eq.31) then
llrz=llra
endif
apmask(14:77)=1
llrz(14:77)=apmag*apsymdxns73(14:77)
else if(iaptype.eq.36) then ! ??? DxCall RR73 ! full compound or nonstandard
if(isubp2.eq.26) then
llrz=llrc
else if(isubp2.eq.27) then
llrz=llrb
else if(isubp2.eq.28) then
llrz=llra
endif
apmask(14:77)=1
llrz(14:77)=apmag*apsymdxnsrr73(14:77)
endif
else if(.not.lmycallstd .and. .not.lhiscallstd .and. &
len_trim(hiscall).gt.2) then ! empty mycall or compound/nonstandard both calls
iaptype=ndxnsaptypes(nQSOProgress,isubp2-4)
iaptype2=iaptype
if(iaptype.eq.0) cycle
if(iaptype.gt.1 .and. iaptype.lt.31) cycle
if(.not.stophint .and. iaptype.gt.1) cycle ! on air, QSO is not possible
if(iaptype.gt.30 .and. lapcqonly) cycle ! skip weak CQ signals with std call
if(iaptype.eq.31 .and. .not.lcqdxcnssig) cycle ! it is not CQ signal of non-standard DXCall
if(iaptype.gt.34 .and. .not.ldxcsig) cycle ! not DXCall signal
if(iaptype.eq.1) then
if(isubp2.eq.20) then
if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
enddo
snoiselev=(sum(s8(0:7,8:16))-scqlev)/7.0
scqnr=scqlev/snoiselev
if(scqnr.lt.1.0 .and. .not.lcqsignal) cycle
endif
if(isubp2.eq.21) then
if(lft8lowth .or. lft8subpass)then
if(scqnr.lt.1.2 .and. .not.lcqsignal) cycle
endif
if(.not. lft8subpass .and. .not.lft8lowth) then
if(scqnr.lt.1.3 .and. .not.lcqsignal) cycle
endif
endif
endif
apmask=0
if(iaptype.eq.1) then ! CQ ??? ???
if(isubp2.eq.20) then
llrz=llrc
else if(isubp2.eq.21) then
llrz=llrb
else if(isubp2.eq.22) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
! Nonstandard DXCall search masks below are for monitoring purpose in idle mode,
! QSO is not possible
! wideband searching being used by default
else if(iaptype.eq.31) then ! CQ DxCall ! full compound or nonstandard
if(isubp2.eq.23) then
llrz=llrc
else if(isubp2.eq.24) then
llrz=llrb
else if(isubp2.eq.25) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
else if(iaptype.eq.35) then ! ??? DxCall 73 ! full compound or nonstandard
if(isubp2.eq.29) then
llrz=llrc
else if(isubp2.eq.30) then
llrz=llrb
else if(isubp2.eq.31) then
llrz=llra
endif
apmask(14:77)=1
llrz(14:77)=apmag*apsymdxns73(14:77)
else if(iaptype.eq.36) then ! ??? DxCall RR73 ! full compound or nonstandard
if(isubp2.eq.26) then
llrz=llrc
else if(isubp2.eq.27) then
llrz=llrb
else if(isubp2.eq.28) then
llrz=llra
endif
apmask(14:77)=1
llrz(14:77)=apmag*apsymdxnsrr73(14:77)
endif
else if(.not.lmycallstd .and. (lhiscallstd .or. lnohiscall)) then
iaptype=nmycnsaptypes(nQSOProgress,isubp2-4)
iaptype2=iaptype
if(iaptype.eq.0) cycle
if(isubp1.eq.2 .and. nweak.eq.1) cycle
if(isubp1.gt.5) cycle ! so far CQ averaging only
if(iaptype.eq.40 .and. lapcqonly) cycle ! skip weak CQ signals
if(iaptype.gt.40 .and. iaptype.lt.45 .and. lqsomsgdcd) cycle ! already decoded
if(iaptype.eq.42 .and. .not.lqsorrr) cycle ! not RRR signal
if(iaptype.eq.43 .and. .not.lqso73) cycle ! not 73 signal
if(iaptype.eq.44 .and. .not.lqsorr73) cycle ! not RR73 signal
if(iaptype.gt.39 .and. .not.lapmyc) cycle
if(lnomycall .and. iaptype.gt.39 .and. iaptype.lt.45) cycle ! skip QSO signals if mycall is empty
if(lnohiscall .and. iaptype.ne.1 .and. iaptype.ne.40) cycle ! skip DXCall masks if empty
if(iaptype.gt.30 .and. iaptype.lt.40 .and. .not.stophint) cycle ! in QSO, reduce number of CPU cycles
if(iaptype.eq.31 .and. .not.lcqdxcsig) cycle ! not CQ signal from std DXCall
if(iaptype.gt.34 .and. iaptype.lt.37 .and. (.not.ldxcsig .or. lapcqonly)) cycle ! not DXCall signal, skip weak CQ signals
if(iaptype.gt.30 .and. iaptype.lt.40 .and. .not.lwidedxcsearch .and. loutapwid) cycle ! if wideband DX search disabled
apmask=0
if(lcqsignal .and. iaptype.eq.1) then ! CQ ??? ???
if(isubp2.eq.20) then
llrz=llrc
else if(isubp2.eq.21) then
llrz=llrb
else if(isubp2.eq.22) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.31) then ! CQ DxCall Grid(???) //std DX call type1 with or without grid
if(isubp2.eq.23) then
llrz=llrc
else if(isubp2.eq.24) then
llrz=llrb
else if(isubp2.eq.25) then
llrz=llra
endif
if(lnohisgrid) then
apmask(1:58)=1
llrz(1:58)=apmag*apcqsym(1:58)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
endif
else if(iaptype.eq.35) then ! ??? DxCall 73 //std DX call
if(isubp2.eq.29) then
llrz=llrc
else if(isubp2.eq.30) then
llrz=llrb
else if(isubp2.eq.31) then
llrz=llra
endif
apmask(30:77)=1
llrz(30:58)=apmag*apsymdxstd(30:58)
llrz(59:77)=apmag*m73
else if(iaptype.eq.36) then ! ??? DxCall RR73 //std DX call
if(isubp2.eq.26) then
llrz=llrc
else if(isubp2.eq.27) then
llrz=llrb
else if(isubp2.eq.28) then
llrz=llra
endif
apmask(30:77)=1
llrz(30:58)=apmag*apsymdxstd(30:58)
llrz(59:77)=apmag*mrr73
else if(iaptype.eq.40) then ! <MyCall>,???,??? type 1
if(isubp2.eq.17) then
llrz=llrc
else if(isubp2.eq.18) then
llrz=llrb
else if(isubp2.eq.19) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*apsymmyns1(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.41) then ! <MyCall>,DXCall,??? type 1
if(isubp2.eq.5) then
llrz=llrc
else if(isubp2.eq.6) then
llrz=llrb
else if(isubp2.eq.7) then
llrz=llra
endif
apmask(1:58)=1
llrz(1:58)=apmag*apsymmyns2
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.42) then ! MyCall,<DXCall>,RRR type 4
if(isubp2.eq.14) then
llrz=llrc
else if(isubp2.eq.15) then
llrz=llrb
else if(isubp2.eq.16) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymmynsrrr
else if(iaptype.eq.43) then ! MyCall,<DXCall>,73 type 4
if(isubp2.eq.11) then
llrz=llrc
else if(isubp2.eq.12) then
llrz=llrb
else if(isubp2.eq.13) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymmyns73
else if(iaptype.eq.44) then ! MyCall,<DXCall>,RR73 type 4
if(isubp2.eq.8) then
llrz=llrc
else if(isubp2.eq.9) then
llrz=llrb
else if(isubp2.eq.10) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:77)=apmag*apsymmynsrr73
endif
else
cycle ! fallback
endif
else if(lhound) then
iaptype=nhaptypes(nQSOProgress,isubp2-4)
iaptype2=iaptype
if(iaptype.eq.0) cycle
if(lnomycall .and. iaptype.gt.1 .and. iaptype.lt.31) cycle ! skip AP if mycall is missed in config
if(lhiscallstd .and. iaptype.eq.31 .and. .not.lcqsignal) cycle ! not CQ signal, skip CQ DXCall DXgrid mask
if(lqsomsgdcd .and. iaptype.gt.0 .and. iaptype.lt.25) cycle ! QSO message already decoded
if(.not.stophint .and. (iaptype.eq.31 .or. iaptype.eq.36)) cycle ! CQ and RR73 decoding not needed if TX is on
if(nQSOProgress.eq.1) then
if(lfoxspecrpt) then
if(iaptype.eq.21) cycle ! it is not standard message report signal
if((iaptype.eq.31 .or. iaptype.eq.36) .and. nfoxspecrpt.gt.3) cycle ! probably special message signal
else
if(iaptype.eq.22) cycle ! it is not special message report signal
if((iaptype.eq.31 .or. iaptype.eq.36) .and. nmic.gt.3) cycle ! probably standard message signal with mybcall
endif
endif
if(nQSOProgress.eq.3) then
if(lfoxspecrpt) then
if(iaptype.eq.21) cycle ! it is not standard message report signal
else
if(iaptype.eq.22) cycle ! it is not special message report signal
endif
if(lfoxstdr73) then
if(iaptype.eq.24) cycle ! it is not special message RR73 signal
else
if(iaptype.eq.23) cycle ! it is not standard message RR73 signal
endif
endif
! can be staying in queue, need to process possible incoming report iaptype 21/22 even if TX is switched off
if(.not.lapmyc .and. (iaptype.eq.23 .or. iaptype.eq.24)) cycle ! skip AP for mycall RR73 in 2..3 minutes after last TX
fdelta=abs(f1-nfqso)
fdeltam=modulo(fdelta,60.) ! dupe string to prevent compiler warning
if(nQSOProgress.gt.0 .and. iaptype.lt.31 .and. (fdelta.gt.245.0 .or. &
fdeltam.gt.3.0)) cycle ! AP shall be applied to Fox frequencies only
if((iaptype.eq.31 .or. iaptype.eq.36) .and. .not.lwidedxcsearch .and. &
(fdelta.gt.245.0 .or. fdeltam.gt.3.0)) cycle ! only Fox frequencies DX Call searching
if(iaptype.eq.31 .and. .not.lhiscallstd .and. lapcqonly) cycle ! skip weak CQ signals with std call
if(iaptype.eq.36 .and. lwidedxcsearch .and. lapcqonly) cycle ! skip weak CQ signals
if(iaptype.eq.111 .and. lapcqonly) cycle ! skip weak CQ signals with std call
apmask=0
if(iaptype.eq.1) then ! CQ ??? ??? type 1 msg
if(isubp2.eq.20) then
llrz=llrc
else if(isubp2.eq.21) then
llrz=llrb
else if(isubp2.eq.22) then
llrz=llra
endif
apmask(1:29)=1
llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.21) then ! MyBaseCall DxBaseCall ??? ! report
if(isubp2.eq.5) then
llrz=llrc
else if(isubp2.eq.6) then
llrz=llrb
else if(isubp2.eq.7) then
llrz=llra
endif
apmask(1:58)=1
llrz(1:58)=apmag*apsym
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else if(iaptype.eq.22) then ! ??? RR73; MyCall <???> ??? ! report
if(isubp2.eq.8) then
llrz=llrc
else if(isubp2.eq.9) then
llrz=llrb
else if(isubp2.eq.10) then
llrz=llra
endif
apmask(29:66)=1
llrz(29:66)=apmag*apsymsp(29:66)
apmask(72:77)=1
llrz(72:73)=apmag*(-1)
llrz(74)=apmag*(+1)
llrz(75:77)=apmag*(-1)
else if(iaptype.eq.23) then ! MyBaseCall DxBaseCall RR73
if(isubp2.eq.11) then
llrz=llrc
else if(isubp2.eq.12) then
llrz=llrb
else if(isubp2.eq.13) then
llrz=llra
endif
apmask(1:77)=1
llrz(1:58)=apmag*apsym
llrz(59:77)=apmag*mrr73
else if(iaptype.eq.24) then ! MyCall RR73; ??? <???> ???
if(isubp2.eq.14) then
llrz=llrc
else if(isubp2.eq.15) then
llrz=llrb
else if(isubp2.eq.16) then
llrz=llra
endif
apmask(1:28)=1
apmask(57:66)=1
llrz(1:28)=apmag*apsymsp(1:28)
llrz(57:66)=apmag*apsymsp(57:66)
apmask(72:77)=1
llrz(72:73)=apmag*(-1)
llrz(74)=apmag*(+1)
llrz(75:77)=apmag*(-1)
else if(iaptype.eq.31) then ! CQ DxCall Grid(???)
if(isubp2.eq.23) then
llrz=llrc
else if(isubp2.eq.24) then
llrz=llrb
else if(isubp2.eq.25) then
llrz=llra
endif
if(lhiscallstd) then
if(lnohisgrid) then
apmask(1:58)=1
llrz(1:58)=apmag*apcqsym(1:58)
apmask(75:77)=1
llrz(75:76)=apmag*(-1)
llrz(77)=apmag*(+1)
else
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
endif
else
apmask(1:77)=1
llrz(1:77)=apmag*apcqsym
endif
else if(iaptype.eq.36) then
if(isubp2.eq.26) then
llrz=llrc
else if(isubp2.eq.27) then
llrz=llrb
else if(isubp2.eq.28) then
llrz=llra
endif
if(lhiscallstd .or. (.not.lhiscallstd .and. &
len_trim(hiscall).gt.2 &
.and. index(hiscall,"/").gt.0)) then
apmask(30:77)=1
llrz(30:58)=apmag*apsym(30:58)
llrz(59:77)=apmag*mrr73 ! ??? DxBaseCall RR73
else
cycle ! (noncompound .and. nonstandard) Fox callsign being not supported by Fox WSJT-X
endif
else if(iaptype.eq.111) then ! CQ ??? type 4 msg (iflip,nrpt,icq,i3 001100)
if(isubp2.eq.29) then
llrz=llrc
else if(isubp2.eq.30) then
llrz=llrb
else if(isubp2.eq.31) then
llrz=llra
endif
apmask(72:77)=1
llrz(72:73)=apmag*(-1)
llrz(74:75)=apmag*(1)
llrz(76:77)=apmag*(-1)
endif
else
cycle ! fallback
endif
endif
cw=0
call bpdecode174_91var(llrz,apmask,max_iterations,message77,cw, &
nharderrors,niterations)
dmin=0.0
if(nharderrors.lt.0) then
ndeep=3
if(lqsosig .or. lmycsignal) then
if((dfqso.lt.napwid .or. (abs(nftx-f1).lt.napwid .and. lapmyc)) &
.and. .not.nagainfil) ndeep=4
if(lapmyc .and. lqsomsgdcd .or. iaptype.eq.0) ndeep=3 ! deep is not needed, reduce number of CPU cycles
if(.not.stophint .and. len_trim(hiscall).gt.2) ndeep=3 ! unload CPU, let ft8svar pick up QSO message
endif
if(ldxcsig .and. stophint .and. dfqso.lt.napwid) ndeep=4 ! DXCall search inside RX napwid
if(lhound) ndeep=3 ! we have no enough CPU resources to decode all Fox slots with ndeep=4
! if(nagainfil .or. swl) ndeep=5 ! 30 against 26 -23dB, more than 15sec to decode and many false decodes
! if(swl) ndeep=4 ! 29 decodes -23dB, 7..12sec to decode
if(nagainfil) ndeep=5
!print *,omp_get_nested(),OMP_get_num_threads()
call osd174_91var(llrz,apmask,ndeep,message77,cw,nharderrors,dmin, &
nthr,progress_generation)
endif
nbadcrc=1
msg37=''
if(count(cw.eq.0).eq.174) cycle !Reject the all-zero codeword
if(nharderrors.lt.0 .or. nharderrors+dmin.ge.60.0 .or. (isubp2.gt.2 &
.and. nharderrors.gt.39)) then ! chk isubp2 value
if(nweak.eq.2 .and. isubp1.eq.2) then
if(ipass.eq.npass-1) then
if(lcqsignal) then
if(isubp2.eq.22) then ! last pass, std and nonstd mycall
lfoundcq=.false.
do ik=1,numdeccq
if(tmpcqdec(ik)%freq.gt.5001.0) exit
if(abs(tmpcqdec(ik)%freq-f1).lt.5.0 .and. abs(tmpcqdec(ik)%xdt-xdt).lt.0.05) then ! max signal delay
lfoundcq=.true.
exit
endif
enddo
if(.not.lfoundcq .and. ncqsignal.lt.numcqsig) then
ncqsignal=ncqsignal+1
tmpcqsig(ncqsignal)%freq=f1
tmpcqsig(ncqsignal)%xdt=xdt
tmpcqsig(ncqsignal)%cs=cstmp2
endif
endif
endif
if(lmycsignal .and. isubp2.eq.19) then ! last pass
lfoundmyc=.false.
do ik=1,numdecmyc
if(tmpmyc(ik)%freq.gt.5001.0) exit
if(abs(tmpmyc(ik)%freq-f1).lt.5.0 .and. &
abs(tmpmyc(ik)%xdt-xdt).lt.0.05) then ! max signal delay
lfoundmyc=.true.
exit
endif
enddo
if(.not.lfoundmyc .and. nmycsignal.lt.nummycsig) then
nmycsignal=nmycsignal+1
tmpmycsig(nmycsignal)%freq=f1
tmpmycsig(nmycsignal)%xdt=xdt
tmpmycsig(nmycsignal)%cs=cstmp2
endif
endif
endif
if(ipass.eq.npass) then
if(lqsocandave .and. (iaptype.eq.3 .or. iaptype.eq.6)) then
tmpqsosig(1)%freq=f1
tmpqsosig(1)%xdt=xdt
tmpqsosig(1)%cs=cstmp2
endif
endif
endif
!print*,'line 2149 iaptype,isubp1,isubp2,ndeep = ',iaptype,isubp1,isubp2,ndeep
if(isubp1.gt.1) cycle
! print*,'line 2150 did not cycle'
if(lqsothread .and. (.not.lhound .and. iaptype.ge.3 .or. lhound &
.and. (iaptype.eq.21 .or. iaptype.eq.23)) .and. .not.lsdone) then
if(.not.lqsomsgdcd .and. .not.(.not.lmycallstd .and. &
.not.lhiscallstd)) then
if(.not.lft8sdec .and. .not.stophint .and. dfqso.lt.2.0) then
call ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint,codec)
if(lft8s) then
if(index(msg37,'<').gt.0) then
lhashmsg=.true.
endif
nbadcrc=0
lft8sdec=.true.
endif
endif
endif
lsdone=.true.
endif
if(nbadcrc.eq.0) then
i3=1
n3=1
exit
endif
if(lsd .and. isubp2.eq.3 .and. nbadcrc.eq.1 .and. srr.lt.7.0) then ! low DR setups shall not try FT8SDvar for strong signals
call ft8sdvar(s8,srr,itone,msgd,msg37,lft8sd,lcq,codec)
if(lft8sd) then
if(levenint) then
evencopy(isd)%lstate=.false.
elseif(loddint) then
oddcopy(isd)%lstate=.false.
endif
i3=1
n3=1
iaptype2=iaptype
iaptype=0
nbadcrc=0
lsd=.false.
exit
endif
endif
if(nweak.eq.1 .and. isubp1.eq.1) then
if(ipass.eq.npass-1) then
if(lcqsignal) then
if(isubp2.eq.22) then ! last pass, std and nonstd mycall
lfoundcq=.false.
do ik=1,numdeccq
if(tmpcqdec(ik)%freq.gt.5001.0) exit
if(abs(tmpcqdec(ik)%freq-f1).lt.5.0 .and. &
abs(tmpcqdec(ik)%xdt-xdt).lt.0.05) then ! max signal delay
lfoundcq=.true.
exit
endif
enddo
if(.not.lfoundcq .and. ncqsignal.lt.numcqsig) then
ncqsignal=ncqsignal+1
tmpcqsig(ncqsignal)%freq=f1
tmpcqsig(ncqsignal)%xdt=xdt
tmpcqsig(ncqsignal)%cs=cstmp2
endif
endif
endif
if(lmycsignal .and. isubp2.eq.19) then ! last pass
lfoundmyc=.false.
do ik=1,numdecmyc
if(tmpmyc(ik)%freq.gt.5001.0) exit
if(abs(tmpmyc(ik)%freq-f1).lt.5.0 .and. &
abs(tmpmyc(ik)%xdt-xdt).lt.0.05) then ! max signal delay
lfoundmyc=.true.
exit
endif
enddo
if(.not.lfoundmyc .and. nmycsignal.lt.nummycsig) then
nmycsignal=nmycsignal+1
tmpmycsig(nmycsignal)%freq=f1
tmpmycsig(nmycsignal)%xdt=xdt
tmpmycsig(nmycsignal)%cs=cstmp2
endif
endif
endif
if(ipass.eq.npass) then
if(lqsocandave .and. (iaptype.eq.3 .or. iaptype.eq.6)) then
tmpqsosig(1)%freq=f1
tmpqsosig(1)%xdt=xdt
tmpqsosig(1)%cs=cstmp2
endif
endif
endif
! print*,'line 2242 nbadcrc=',nbadcrc
if(nbadcrc.eq.1) cycle
endif
write(c77,'(77i1)') message77
read(c77(72:74),'(b3)') n3
read(c77(75:77),'(b3)') i3
!print*,'line 2247 iaptype=',iaptype,' i3=',i3,' n3=',n3
if((i3.gt.4 .or. (i3.eq.0 .and. n3.gt.5)) .and. (.not.(i3.eq.5 .and. &
(n3.eq.1 .or. n3.eq.7 .or.n3.eq.6 .or.n3.eq.4 .or.n3.eq.3 .or.n3.eq.0 &
.or.n3.eq.5 .or. n3.eq.2 .or. n3.eq.8 .or. n3.eq.9)))) cycle
! ft8md added n3.eq.6 and n3.eq.4 and n3.eq.3 and n3.eq.0
! and n3.eq.5 for USA calls with EU VHF
! added .or. n3.eq.2 .or. n3.eq.8 .or. n3.eq.9 as test for EU VHF
!print*,'did not cycle at line 2248'
call unpack77_configured_for_state(codec,c77,1,msg37,unpk77_successvar, &
unpack77_options(thread_index=nthr))
if(.not.unpk77_successvar) then
if(lqsothread .and. (.not.lhound .and. iaptype.ge.3 .or. lhound .and. &
(iaptype.eq.21 .or. iaptype.eq.23)) .and. .not.lsdone) then
if(.not.lqsomsgdcd .and. .not.(.not.lmycallstd .and. &
.not.lhiscallstd)) then
if(.not.lft8sdec .and. .not.stophint .and. dfqso.lt.2.0) then
call ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint,codec)
if(lft8s) then
if(index(msg37,'<').gt.0) then
lhashmsg=.true.
endif
nbadcrc=0
lft8sdec=.true.
endif
endif
endif
lsdone=.true.
if(nbadcrc.eq.0) then
i3=1
n3=1
exit
endif
endif
cycle
endif
if(iaptype.eq.1 .and. msg37(1:10).eq.'CQ DE AA00') then
nbadcrc=1
cycle
endif
lcall1hash=.false.
if(msg37(1:1).eq.'<') lcall1hash=.true.
nbadcrc=0 ! If we get this far: valid codeword, valid (i3,n3), nonquirky message.
call ft8var_tones_from_77bits(message77,itone)
has_decoded_payload=.true.
decoded_payload_message=msg37
if(present(evidence)) evidence%payload77=message77
! 0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 71 DXpedition Mode
i3bit=0
if(i3.eq.0 .and. n3.eq.1) i3bit=1
! iFreeText=message77(57)
! 0.0 Free text
if(i3.eq.0 .and. n3.eq.0) then
lFreeText=.true.
else
lFreeText=.false.
endif
! delete braces
lcall2hash=.false.
if(.not.lFreeText .and. i3bit.ne.1 .and. index(msg37,'<').gt.0) then
if(index(msg37,'<').gt.4) lcall2hash=.true.
if(index(msg37,'<').gt.0) then
lhashmsg=.true.
endif
endif
if(nbadcrc.eq.0) exit
enddo ! ap passes
if(nbadcrc.eq.0) exit
enddo ! weak sigs
if(nbadcrc.eq.0) exit
enddo !nqso sync
2 if(nbadcrc.eq.0) then
! check for the false FT8Svar decode
if(lft8s .and. lrepliedother) then
msg37=''
nbadcrc=1
return
endif
msg37_2=''
if(i3bit.eq.1 .and. .not.lft8s .and. .not.lft8sd) then
call msgparservar(msg37,msg37_2)
lspecial=.true. !only in ft8var
!protection against a false FT8Svar decode in Hound mode
if(lhound .and. dfqso.lt.2.0) lqsomsgdcd=.true. !$OMP FLUSH (lqsomsgdcd)
endif
qual=1.0-(nharderrors+dmin)/60.0
xsnr=0.001
xnoi=1.E-8
xsnrtmp=0.001
do i=1,79
xsig=s8(itone(i),i)**2
xnoi=(sum(s8(0:7,i)**2) - xsig)/7.0
if(xnoi.lt.0.01) xnoi=0.01 ! safe division and better accuracy
if(xnoi.lt.xsig) then
xsnr=xsig/xnoi
else
xsnr=1.01
endif
xsnrtmp=xsnrtmp+xsnr
enddo
xsnr=xsnrtmp/79.0-1.0
xsnr=10.0*log10(xsnr)-26.5
if(xsnr.gt.7.0) xsnr=xsnr+(xsnr-7.0)/2.0
if(xsnr.gt.30.0) then
xsnr=xsnr-1.0
if(xsnr.gt.40.0) xsnr=xsnr-1.0
if(xsnr.gt.49.0) xsnr=49.0
endif
xsnrs=xsnr
if(xsnr .lt. -17.0) then
if(xsnr.lt.-22.5 .and. xsnr.gt.-23.5) xsnr=-22.5 ! safe division and better accuracy
xsnr=xsnr-(1.0+1.4/(23.0+xsnr))**2+1.2
endif
if(iaptype.eq.0) then
if(xsnr.lt.-23.0) xsnr=-23.0
else
if(xsnr.lt.-24.0) xsnr=-24.0
endif
if(lft8s .or. lft8sd) then
if(xsnr.lt.-22.0) xsnr=xsnrs-1.0 ! correction offset
if(xsnr.lt.-26.0) xsnr=-26.0
! -26 0.1 1477 ~ AC1MX AC1MX R-17 ^
if(len_trim(mycall).gt.3 .and. index(msg37,' '//trim(mycall)//' ').gt.1) then
msg37=''
return
endif
go to 4 ! bypass checking to false decode
endif
!if(len_trim(msg37)>0) print*,'line 2371 ',msg37
rxdt=xdt-0.5
if(iaptype.gt.34 .and. iaptype.lt.40) then ! DX Call searching false iaptype 35,36: 'CS7CYU/R FO5QB 73', 'T57KWP/R FO5QB RR73'
ispc1=index(msg37,' ')
if(ispc1.gt.5) then
if(msg37((ispc1-2):(ispc1-1)).eq.'/R') then ! have to cascade it to prevent getting out of index range
call_a=''
call_a=msg37(1:(ispc1-3))
lfound=.false.
call searchcallsvar(call_a," ",lfound)
if(.not.lfound) then
nbadcrc=1
msg37=''
return
endif
endif
endif
else if(qual.lt.0.39 .or. xsnr.lt.-20.5 .or. rxdt.lt.-0.5 .or. rxdt.gt.1.9 &
.or. (iaptype.gt.0 .and. iaptype.lt.4) .or. iaptype.eq.11 .or. &
iaptype.eq.21 .or. iaptype.eq.40 .or. iaptype.eq.41) then
if(iaptype.gt.3 .and. iaptype.lt.7) go to 4 ! skip, nothing to check
if(iaptype.ne.2 .and. iaptype.ne.3 .and. iaptype.ne.11 .and. iaptype.ne.21 &
.and. iaptype.ne.40 .and. iaptype.ne.41) then
if((mybcall.ne." " .and. index(msg37,mybcall).gt.0) .or. &
(hisbcall.ne." " .and. index(msg37,hisbcall).gt.0)) go to 256
endif
if(i3bit.eq.1) then
! print*,'nbadcrc line 2400',nbadcrc
call chkspecial8var(msg37,msg37_2,nbadcrc)
! print*,'nbadcrc line 2402',nbadcrc
else
! print*,'nbadcrc line 2404 nbadcrc,i3,n3',nbadcrc,i3,n3
call chkfalse8var(msg37,i3,n3,nbadcrc,iaptype,lcall1hash)
! print*,'nbadcrc line 2406',nbadcrc
endif
if(nbadcrc.eq.1) then
msg37=''
return
endif
endif
if(iaptype.eq.2 .or. iaptype.eq.3 .or. iaptype.eq.11 .or. iaptype.eq.21 .or. &
iaptype.eq.40 .or. iaptype.eq.41) go to 4 ! already checked
! decoded without AP masks:
! CQ PLIB U40OKH FE61
! CQ 000 RO8JSV GJ38
256 if(iaptype.eq.0 .and. i3.eq.1 .and. msg37(1:3).eq.'CQ ') then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
if((ispc2-ispc1).eq.4 .or. (ispc2-ispc1).eq.5) then
ispc3=index(msg37((ispc2+1):),' ')+ispc2
ispc4=index(msg37((ispc3+1):),' ')+ispc3
if((ispc3-ispc2).gt.3 .and. (ispc4-ispc3).eq.5) then
grid=''
if(msg37(ispc3+1:ispc3+1).gt.'@' .and. msg37(ispc3+1:ispc3+1).lt.'S' &
.and. msg37(ispc3+2:ispc3+2).gt.'@' .and. &
msg37(ispc3+2:ispc3+2).lt.'S' .and. &
msg37(ispc3+3:ispc3+3).lt.':' .and. &
msg37(ispc3+4:ispc3+4).lt.':') grid=msg37(ispc3+1:ispc4-1)
if(grid.ne.'') then
callsign=''
callsign=msg37(ispc2+1:ispc3-1)
call chkgridvar(callsign,grid,lchkcall,lgvalid,lwrongcall)
if(lwrongcall .or. .not.lgvalid) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
endif
! i3=1,2 false decodes with ' R '
! 3B4NDC/R C40AUZ/R R IR83 i3=1
! MS8QQS UX3QBS/P R NG63 i3=2
! <...> P32WRF R LR56
! P32WRF <...> R LR56
if((i3.eq.1 .or. i3.eq.2) .and. index(msg37,' R ').gt.0) then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
ispc3=index(msg37((ispc2+1):),' ')+ispc2
if(ispc3-ispc2.eq.2) then
if(msg37(ispc2:ispc3).eq.' R ') then
call_b=''
if((i3.eq.1 .and. msg37(ispc2-2:ispc2-1).eq.'/R') .or. &
(i3.eq.2 .and. msg37(ispc2-2:ispc2-1).eq.'/P')) then
call_b=msg37(ispc1+1:ispc2-3)
else
call_b=msg37(ispc1+1:ispc2-1)
endif
if(lcall2hash) then ! valid call_b can be found in hash table, check call_a then
call_a=''
if((i3.eq.1 .and. msg37(ispc1-2:ispc1-1).eq.'/R') .or. &
(i3.eq.2 .and. msg37(ispc1-2:ispc1-1).eq.'/R')) then
call_a=msg37(1:ispc1-3)
else
call_a=msg37(1:ispc1-1)
endif
falsedec=.false.
call chkflscallvar('CQ ',call_a,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
else if(len_trim(call_b).gt.2) then
ispc4=index(msg37((ispc3+1):),' ')+ispc3
grid=''
if(ispc4-ispc3.eq.5 .and. msg37(ispc3+1:ispc3+1).gt.'@' .and. &
msg37(ispc3+1:ispc3+1).lt.'S' .and. &
msg37(ispc3+2:ispc3+2).gt.'@' .and. &
msg37(ispc3+2:ispc3+2).lt.'S' .and. &
msg37(ispc3+3:ispc3+3).lt.':' .and. &
msg37(ispc3+4:ispc3+4).lt.':') grid=msg37(ispc3+1:ispc4-1)
if(grid.ne.'') then
call chkgridvar(call_b,grid,lchkcall,lgvalid,lwrongcall)
if(lwrongcall .or. .not.lgvalid) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
endif
endif
! 0.3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day
! 0.4 WA9XYZ KA1ABC R 32A EMA 28 28 1 4 3 7 71 ARRL Field Day
! -23 3.1 197 ~ Z67BGE H67HJI 22G EMA i3=0 n3=4
! -3 2.2 FY4IML UV7BEA R 24F NNJ i3=0 n3=4
if(i3.eq.0 .and. n3.gt.2 .and. n3.lt.5) then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
if(ispc1.gt.3 .and. ispc2.gt.7) then
call_a=''
call_b=''
if(msg37(1:ispc1-1).eq.'/R' .or. msg37(1:ispc1-1).eq.'/P') then
call_a=msg37(1:ispc1-3)
else
call_a=msg37(1:ispc1-1)
endif
if(msg37(ispc1+1:ispc2-1).eq.'/R' .or. msg37(ispc1+1:ispc2-1).eq.'/P') then
call_b=msg37(ispc1+1:ispc2-3)
else
call_b=msg37(ispc1+1:ispc2-1)
endif
! operators outside USA and Canada shall transmit ' DX '
if(call_b(1:1).ne.'A' .and. call_b(1:1).ne.'K' .and. call_b(1:1).ne.'N' &
.and. call_b(1:1).ne.'W' .and. call_b(1:1).ne.'V' .and. &
call_b(1:1).ne.'C' .and. call_b(1:1).ne.'X') then
if(index(msg37,' DX ').lt.1) then
nbadcrc=1
msg37=''
return
endif
endif
! USA AA..AL
if(call_b(1:1).eq.'A' .and. (call_b(2:2).lt.'A' .or. call_b(2:2).gt.'L')) then
if(index(msg37,' DX ').lt.1) then
nbadcrc=1
msg37=''
return
endif
endif
! Canada CF..CK,CY,CZ,VA..VG,VO,VX,VY,XJ..XO
if(call_b(1:1).eq.'C' .and. (call_b(2:2).lt.'F' .or. call_b(2:2).gt.'K')) then
if(call_b(2:2).ne.'Y' .and. call_b(2:2).ne.'Z') then
if(index(msg37,' DX ').lt.1) then
nbadcrc=1
msg37=''
return
endif
endif
endif
if(call_b(1:1).eq.'V' .and. (call_b(2:2).lt.'A' .or. call_b(2:2).gt.'G')) then
if(call_b(2:2).ne.'O' .and. call_b(2:2).ne.'X' .and. call_b(2:2).ne.'Y') then
if(index(msg37,' DX ').lt.1) then
nbadcrc=1
msg37=''
return
endif
endif
endif
if(call_b(1:1).eq.'X' .and. (call_b(2:2).lt.'J' .or. call_b(2:2).gt.'O')) then
if(index(msg37,' DX ').lt.1) then
nbadcrc=1
msg37=''
return
endif
endif
if(xsnr.lt.-19.0 .or. rxdt.lt.-0.5 .or. rxdt.gt.1.0) then
falsedec=.false.
call chkflscallvar(call_a,call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
! EU VHF contest exchange i3=5
! <PA3XYZ> <G4ABC/P> R 590003 IO91NP h12 h22 r1 s3 S11 g25
! packing is not implemented in WSJT-X 2.5.4?
! old implementation with i3=0 n3=2
! JL6GSC/P R 571553 CJ76MV i3=5
! G59XTB R 521562 RA82SJ
if(i3.eq.5 .and. n3.eq.1 .and. (xsnr.lt.-19.0 .or. rxdt.lt.-0.5 .or. &
rxdt.gt.1.0)) then ! was if i3-0 and n3=2
ispc1=index(msg37,' ')
if(ispc1.gt.3) then
call_b=''
if(msg37(ispc1-2:ispc1-1).eq.'/P') then
call_b=msg37(1:ispc1-3)
else
call_b=msg37(1:ispc1-1)
endif
falsedec=.false.
call chkflscallvar('CQ ',call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
! FT8OPG/R Z27HRN/R OH12 check all standard messages with contest callsigns
! /P has i3.eq.2 .and. n3.eq.0
if(iaptype.eq.0 .and. i3.eq.1 .and. n3.eq.0 .and. index(msg37,'/R ').gt.3) then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
if(ispc1.gt.3 .and. ispc2.gt.6) then
call_a=''
call_b=''
if(msg37(ispc1-2:ispc1-1).eq.'/R') then
call_a=msg37(1:ispc1-3)
else
call_a=msg37(1:ispc1-1)
endif
if(msg37(ispc2-2:ispc2-1).eq.'/R') then
call_b=msg37(ispc1+1:ispc2-3)
else
call_b=msg37(ispc1+1:ispc2-1)
endif
falsedec=.false.
call chkflscallvar(call_a,call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
! -23 -0.5 2533 ~ <...> W LKNQZG2K4 RR73 invalid message, iaptype=0 this type of message is not allowed for transmission with RR73
! -23 -1.2 1335 ~ <...> Z7VENB8R G9 RRR non AP decode, iaptype=0 invalid message, this type of message is not allowed
! for transmission with RRR
if(msg37(1:2).eq.'<.') then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
ispc3=index(msg37((ispc2+1):),' ')+ispc2
ispc4=index(msg37((ispc3+1):),' ')+ispc3
if((ispc4-ispc3.eq.4 .and. msg37(ispc3+1:ispc4-1).eq.'RRR') .or. &
(ispc4-ispc3.eq.5 .and. msg37(ispc3+1:ispc4-1).eq.'RR73') .or. &
(ispc4-ispc3.eq.3 .and. msg37(ispc3+1:ispc4-1).eq.'73')) then
nbadcrc=1
msg37=''
return
endif
! -19 0.0 2256 ~ <...> 9T4DQZ RP53 non AP decode, iaptype=0 i3=1 n3=1 SAME AS CQ MSG
! <...> 9T4DQZ -15(R-15) message has i3=1 n3=4
if(i3.eq.1 .and. n3.eq.1 .and. (xsnr.lt.-18.0 .or. rxdt.lt.-0.5 .or. &
rxdt.gt.1.0)) then
callsign=' '
callsign=msg37(ispc1+1:ispc2-1)
grid=msg37(ispc2+1:ispc3-1)
include 'callsign_q.f90'
call chkgridvar(callsign,grid,lchkcall,lgvalid,lwrongcall)
if(lwrongcall) then
nbadcrc=1
msg37=''
return
endif
if(lchkcall .or. .not.lgvalid) then
falsedec=.false.
call chkflscallvar('CQ ',callsign,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
! -22 0.3 1000 ~ 9Y4DWY <...> BF70 iaptype=0 i3=1 n3=2 invalid message in FT8
! protocol, can be transmitted manually
if(i3.eq.1) then
ispc1=index(msg37,' ')
if(msg37(ispc1+1:ispc1+2).eq.'<.') then
ispc2=index(msg37((ispc1+1):),' ')+ispc1
ispc3=index(msg37((ispc2+1):),' ')+ispc2
if(ispc3-ispc2.eq.5 .and. msg37(ispc2+1:ispc2+1).gt.'@' .and. &
msg37(ispc2+1:ispc2+1).lt.'S' .and. &
msg37(ispc2+2:ispc2+2).gt.'@' .and. &
msg37(ispc2+2:ispc2+2).lt.'S' .and. &
msg37(ispc2+3:ispc2+3).lt.':' .and. &
msg37(ispc2+4:ispc2+4).lt.':') then ! there is a valid grid in message
call_b=''
call_b=msg37(1:ispc1-1)
falsedec=.false.
call chkflscallvar('CQ ',call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
! i3=3 parse ARRL RTTY contest message
! i3 n3 Bits Total Message type
! 3 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY contest
! 3 TU; W9XYZ G8ABC R 559 0013 1 28 28 1 3 13 74 ARRL RTTY (DX)
! TU; D47IAQ <...> 559 032' does protocol support the message?
if(i3.eq.3 .and. msg37(1:3).eq.'TU;') then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
ispc3=index(msg37((ispc2+1):),' ')+ispc2
call_a=''
call_b=''
call_a=msg37(ispc1+1:ispc2-1)
call_b=msg37(ispc2+1:ispc3-1)
! check for false, too tough, need to rework if contest is supported
falsedec=.false.
call chkflscallvar(call_a,call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
! parse
lspecial=.true.
msg37_2=msg37(5:37)//' '
msg37=''
msg37='DE '//trim(call_b)//' TU'
endif
! DX Call searching false decodes, search for 1st callsign in ALLCALL7
! 6W6VIV EY8MM 73
! 6Y9KOZ EY8MM RR73
if(iaptype.gt.34 .and. iaptype.lt.40 .and. (xsnr.lt.-21.0 .or. rxdt.lt.-0.5 &
.or. rxdt.gt.1.0)) then
ispc1=index(msg37,' ')
if(ispc1.gt.1) then
call_b=''
call_b=msg37(1:ispc1-1)
falsedec=.false.
call chkflscallvar('CQ ',call_b,falsedec)
if(falsedec) then
nbadcrc=1
msg37=''
return
endif
endif
endif
4 continue
!### Possibly call ft8_a8d() here ??? ###
ldupemsg=.false.
if(ndecodes.gt.0) then
do i=1,ndecodes
if(allmessages(i).eq.msg37 .and. abs(allfreq(i)-f1).lt.45.0) then
ldupemsg=.true.
endif
enddo
endif
if(.not.ldupemsg .and. dfqso.lt.2.0 .and. ((i3.eq.1 .and. .not.lft8s) .or. &
lft8s)) then
if(msg37(1:msgrootlen+1).eq.trim(msgroot)//' ') then
lasthcall=hiscall
lastrxmsg(1)%lastmsg=msg37
lastrxmsg(1)%xdt=xdt-0.5
lastrxmsg(1)%lstate=.true.
lqsomsgdcd=.true.
!$OMP FLUSH (lqsomsgdcd)
else if(.not.lft8s .and. mycalllen1.gt.2) then
if(msg37(1:mycalllen1).ne.trim(mycall)//' ' .and. &
index(msg37,' '//trim(hiscall)//' ').gt.0) then
lrepliedother=.true.
endif
endif
endif
if(len_trim(hiscall).gt.3 .and. .not.lqsomsgdcd) then
if(msg37(1:msgrootlen+1).eq.trim(msgroot)//' ') then
lqsomsgdcd=.true.
!$OMP FLUSH (lqsomsgdcd)
endif
endif
if(.not.stophint .and. .not.ldupemsg .and. dfqso.lt.2.0 .and. nlasttx.gt.0 &
.and. nlasttx.lt.6 .and. msg37(1:3).eq.'CQ ') then
nlength=len_trim(hiscall)
if(nlength.gt.2) then
if(msg37(4:4+nlength).eq.trim(hiscall)//' ' .or. &
msg37(7:7+nlength).eq.trim(hiscall)//' ') lrepliedother=.true.
endif
endif
if(mycalllen1.gt.2) then
if(.not.ldupemsg .and. msg37(1:mycalllen1).eq.trim(mycall)//' ') then
nincallthr(nthr)=nincallthr(nthr)+1
nindex=maskincallthr(nthr)+nincallthr(nthr)
if(nindex.lt.maskincallthr(nthr+1)) then
msgincall(nindex)=msg37
xdtincall(nindex)=xdt-0.5
else
nincallthr(nthr)=nincallthr(nthr)-1
endif
endif
endif
ldupeft8sd=.false.
if(ncount.gt.0 .and. lft8sd) then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
msgbase37=''
msgbase37=msg37(1:ispc2-1)
do i=1,ncount
if(trim(msgbase37).eq.trim(msgsrcvd(i))) then
ldupeft8sd=.true.
exit
endif
enddo
endif
if(ldupeft8sd) then
msg37=''
nbadcrc=1
return
endif
if(.not.ldupemsg .and. i3.eq.1 .and. .not.lft8sd .and. .not.lft8s .and. &
msg37(1:3).ne.'CQ ') then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
ncount=ncount+1
msgsrcvd(ncount)=msg37(1:ispc2-1)
endif
! -23 0.0 1606 ~ <...> 3U1TBM/R CC65 i3=4 n3=0
! -18 0.3 1609 ~ CQ 6U6MBL/R IJ90 i3=1 in some noisy setups false decode with any SNR value is possible
if((i3.eq.4 .and. n3.eq.0) .or. (i3.eq.1 .and. msg37(1:3).eq."CQ ")) then
if(index(msg37,'/R ').gt.9) then
ispc1=index(msg37,' ')
ispc2=index(msg37((ispc1+1):),' ')+ispc1
if(ispc2.gt.11) then
ispc3=index(msg37((ispc2+1):),' ')+ispc2
if(msg37((ispc2-2):(ispc2-1)).eq.'/R') then
if((ispc3-ispc2).eq.5) then
grid=msg37(ispc2+1:ispc3-1)
! grid can not be txed, invalid message:
if(i3.eq.4 .and. len_trim(grid).eq.4) then
nbadcrc=1
msg37=''
return
endif
call_b=''
call_b=msg37((ispc1+1):(ispc2-3))
call chkgridvar(call_b,grid,lchkcall,lgvalid,lwrongcall)
if(lwrongcall .or. .not.lgvalid) then
nbadcrc=1
msg37=''
return
endif
endif
endif
endif
endif
endif
! protocol violations
! 713STG 869TK NO05 i3=2 n3=5, false decode, as per protocol type2 shall be /P message
if(i3.eq.2 .and. index(msg37,'/P ').lt.1) then
msg37=''
nbadcrc=1
return
endif
! -18 0.5 584 ~ UA3ALE <...> PR07 * AP decode with grid
if(iaptype.eq.2) then
nhash=index(msg37,"<...>")
if(nhash.gt.4 .and. nhash.lt.13 .and. msg37(nhash+6:nhash+6).gt.'@' .and. &
msg37(nhash+7:nhash+7).gt.'@') then
msg37=''
nbadcrc=1
return
endif
endif
if(lsubtract) then
noff=10
sync0=0.
syncp=0.
syncm=0.
k=1
allocate(csig0(151680))
call gen_ft8wavevar(itone,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
do i=0,78
do j=1,32
csig(j)=csig0(k)
k=k+60
enddo
i21=i0+i*32
z1=0.
z1=sum(cd0(i21:i21+31)*conjg(csig))
sync0 = sync0 + real(z1)**2 + aimag(z1)**2
i21=i0+i*32+noff
z1=0.
z1=sum(cd0(i21:i21+31)*conjg(csig))
syncp = syncp + real(z1)**2 + aimag(z1)**2
i21=i21-noff*2
z1=0.
z1=sum(cd0(i21:i21+31)*conjg(csig))
syncm = syncm + real(z1)**2 + aimag(z1)**2
enddo
deallocate(csig0)
call peakup(syncm,sync0,syncp,dx)
if(abs(dx).gt.1.0) then
scorr=0.
else
scorr=real(noff)*(dx) ! was * dx ft8md
endif
xdt3=xdt+scorr*dt2
call mtd_commit_subtraction(nthr,ipass,itone,f1,xdt3,residual)
endif
endif
if(present(evidence) .and. nbadcrc.eq.0) then
if(all(itone(1:7).eq.icos7)) then
evidence%tones=int(itone,kind=1)
evidence%has_tones=1
endif
evidence%has_waveform_start=1
evidence%waveform_start_seconds=xdt
evidence%method=iaptype2
if(has_decoded_payload .and. msg37.eq.decoded_payload_message) &
evidence%payload_origin=engine_payload_decoded
endif
return
end subroutine ft8bvar
subroutine normalizebmetvar(bmet,n)
real bmet(n)
! bmetav=sum(bmet)/real(n)
bmet2av=sum(bmet*bmet)/real(n)
! var=bmet2av-bmetav*bmetav
! if( var .gt. 0.0 ) then
! bmetsig=sqrt(var)
! else
bmetsig=sqrt(bmet2av)
! endif
bmet=bmet/bmetsig
return
end subroutine normalizebmetvar
|