summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/77bit/77bit.txt6
-rw-r--r--lib/77bit/encode77.f9019
-rw-r--r--lib/77bit/g85
-rw-r--r--lib/77bit/messages.txt22
-rw-r--r--lib/77bit/packjt77.f90501
-rw-r--r--lib/77bit/test28.f9046
-rw-r--r--lib/77bit/test28.txt23
-rw-r--r--lib/Makefile71
-rw-r--r--lib/Makefile.MinGW153
-rw-r--r--lib/Makefile.MinGW.qt4122
-rw-r--r--lib/Makefile.jt6584
-rw-r--r--lib/Makefile.jt65_Win76
-rw-r--r--lib/Makefile.jt65_osx74
-rw-r--r--lib/Makefile.jt9w58
-rw-r--r--lib/Makefile.jt9w_Win58
-rw-r--r--lib/Makefile.jtsdk137
-rw-r--r--lib/Makefile.linux115
-rw-r--r--lib/Makefile.msk71
-rw-r--r--lib/addit.f9048
-rw-r--r--lib/afc65b.f9010
-rw-r--r--lib/allsim.f90111
-rw-r--r--lib/bpdecode128_90.f901
-rw-r--r--lib/decode65a.f9012
-rw-r--r--lib/decode65b.f907
-rw-r--r--lib/decoder.f90108
-rw-r--r--lib/extract.f906
-rw-r--r--lib/fano232.f904
-rw-r--r--lib/fast_decode.f908
-rw-r--r--lib/fil3.f902
-rw-r--r--lib/fil3c.f902
-rw-r--r--lib/fil6521.f902
-rw-r--r--lib/filbig.f9011
-rw-r--r--lib/ft4/ft4_downsample.f902
-rw-r--r--lib/ft4/ft4_testmsg.f9050
-rw-r--r--lib/ft4/ft4code.f90101
-rw-r--r--lib/ft4/ft4sim.f9052
-rw-r--r--lib/ft4/gen_ft4wave.f902
-rw-r--r--lib/ft4/get_ft4_bitmetrics.f902
-rw-r--r--lib/ft4/getcandidates4.f90166
-rw-r--r--lib/ft4/subtractft4.f902
-rw-r--r--lib/ft4/sync4d.f90192
-rw-r--r--lib/ft4_decode.f90114
-rw-r--r--lib/ft8.f9049
-rw-r--r--lib/ft8/baseline.f901
-rw-r--r--lib/ft8/bpdecode174_91.f906
-rw-r--r--lib/ft8/decode174_91.f90155
-rw-r--r--lib/ft8/encode174_91.f9092
-rw-r--r--lib/ft8/encode174_91_nocrc.f9049
-rw-r--r--lib/ft8/extractmessage174.f9040
-rw-r--r--lib/ft8/extractmessage174_91.f9040
-rw-r--r--lib/ft8/filt8.f904
-rw-r--r--lib/ft8/foxfilt.f902
-rw-r--r--lib/ft8/ft8_testmsg.f9096
-rw-r--r--lib/ft8/ft8apset.f9036
-rw-r--r--lib/ft8/ft8b.f90261
-rw-r--r--lib/ft8/ft8code.f9047
-rw-r--r--lib/ft8/ft8sim.f9045
-rw-r--r--lib/ft8/ft8sim_gfsk.f90131
-rw-r--r--lib/ft8/gen_ft8wave.f9024
-rw-r--r--lib/ft8/get_crc14.f9025
-rw-r--r--lib/ft8/get_spectrum_baseline.f9043
-rw-r--r--lib/ft8/ldpc_174_91_c_parity.f90351
-rw-r--r--lib/ft8/ldpc_174_91_c_reordered_parity.f90270
-rw-r--r--lib/ft8/ldpcsim174_91.f90134
-rw-r--r--lib/ft8/osd174_91.f90627
-rw-r--r--lib/ft8/subtractft8.f90116
-rw-r--r--lib/ft8/sync8.f9032
-rw-r--r--lib/ft8/sync8d.f908
-rw-r--r--lib/ft8_decode.f90160
-rw-r--r--lib/ft8dec.f90111
-rw-r--r--lib/hint65.f9012
-rw-r--r--lib/hspec.f9012
-rw-r--r--lib/ipcomm.cpp48
-rw-r--r--lib/iscat.f906
-rw-r--r--lib/jt49sim.f90116
-rw-r--r--lib/jt4_decode.f905
-rw-r--r--lib/jt65_decode.f90126
-rw-r--r--lib/jt65sim.f9020
-rw-r--r--lib/jt9.f9026
-rw-r--r--lib/jt9a.f9099
-rw-r--r--lib/jt9com.f901
-rw-r--r--lib/ldpcsim128_90.f9027
-rw-r--r--lib/lpf1.f902
-rw-r--r--lib/msk144code.f90164
-rw-r--r--lib/msk144decodeframe.f903
-rw-r--r--lib/msk144sim.f901
-rw-r--r--lib/mskrtd.f907
-rw-r--r--lib/osd128_90.f90375
-rw-r--r--lib/qra64a.f907
-rw-r--r--lib/qra64code.f906
-rw-r--r--lib/qratest.f902
-rw-r--r--lib/refspectrum.f906
-rw-r--r--lib/sh65.f9051
-rw-r--r--lib/shmem.cpp20
-rw-r--r--lib/shmem.f9045
-rw-r--r--lib/spec64.f902
-rw-r--r--lib/sumsim.f9041
-rw-r--r--lib/sync65.f905
-rw-r--r--lib/synciscat.f908
-rw-r--r--lib/timf2.f902
-rw-r--r--lib/wav11.f904
-rw-r--r--lib/wav12.f902
-rw-r--r--lib/wqdecode.f908
-rw-r--r--lib/wqencode.f903
-rw-r--r--lib/wsprcode/nhash.c22
-rw-r--r--lib/wsprcode/wspr_old_subs.f9016
-rw-r--r--lib/wsprd/jelinek.h2
-rw-r--r--lib/wsprd/nhash.c11
-rw-r--r--lib/wsprd/osdwspr.f9012
-rw-r--r--lib/wsprd/wsprd.c508
-rw-r--r--lib/wsprd/wsprd_utils.c7
-rw-r--r--lib/wsprd/wsprd_utils.h2
-rw-r--r--lib/wsprd/wsprsim.c7
-rw-r--r--lib/wsprd/wsprsim_utils.c4
-rw-r--r--lib/wsprd/wsprsim_utils.h2
115 files changed, 3659 insertions, 3807 deletions
diff --git a/lib/77bit/77bit.txt b/lib/77bit/77bit.txt
index 89b481b6..ae8f3dd3 100644
--- a/lib/77bit/77bit.txt
+++ b/lib/77bit/77bit.txt
@@ -11,18 +11,18 @@ i3.n3 Example message Bits Total Purpose
----------------------------------------------------------------------------------
0.0 FREE TEXT MSG 71 71 Free text
0.1 K1ABC RR73; W9XYZ <KH1/KH7Z> -12 28 28 10 5 71 DXpedition Mode
-0.2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest
+0.2 ... tbd
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
0.5 123456789ABCDEF012 71 71 Telemetry (18 hex)
-0.6 K1ABC RR73; CQ W9XYZ EN37 28 28 15 71 Contesting
+0.6 Temporarily hijacked in packjt77 for WSPR-LF. This is not necessary!
0.7 ... tbd
1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg
2 PA3XYZ/P GM4ABC/P R JO22 28 1 28 1 1 15 74 EU VHF contest
3 TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74 ARRL RTTY Roundup
4 <WA9XYZ> PJ4/KA1ABC RR73 12 58 1 2 1 74 Nonstandard calls
-5 TU; W9XYZ K1ABC R-07 FN 1 28 28 1 7 9 74 WWROF contest ?
+5 <G4ABC/P> <PA9XYZ> R 570007 JO22DB 12 22 1 3 11 25 74 EU VHF Contest
6 ... tbd
7 ... tbd
----------------------------------------------------------------------------------
diff --git a/lib/77bit/encode77.f90 b/lib/77bit/encode77.f90
index 4b2a1355..99af70cd 100644
--- a/lib/77bit/encode77.f90
+++ b/lib/77bit/encode77.f90
@@ -6,6 +6,8 @@ program encode77
character msg*37,cerr*1
character*77 c77
character*80 infile
+ character*13 w(19)
+ integer nw(19)
logical unpk77_success
nargs=iargc()
@@ -15,6 +17,7 @@ program encode77
go to 999
endif
call getarg(1,msg0)
+ call fmtmsg(msg0,iz)
if(nargs.eq.2) then
call getarg(2,infile)
open(10,file=infile,status='old')
@@ -37,10 +40,18 @@ program encode77
call unpack77(c77,1,msg,unpk77_success)
cerr=' '
if(msg.ne.msg0(1:37)) cerr='*'
- if(i3.eq.0) write(*,1004) i3,n3,cerr,msg0(1:37),msg
-1004 format(i2,'.',i1,2x,a1,3x,a37,1x,a37)
- if(i3.ge.1) write(*,1005) i3,cerr,msg0(1:37),msg
-1005 format(i2,'.',3x,a1,3x,a37,1x,a37)
+ if(i3.eq.0 .and.n3.ne.6) write(*,1004) i3,n3,cerr,msg0(1:37),msg
+1004 format(i2,'.',i1,4x,a1,1x,a37,1x,a37)
+ if(i3.eq.0 .and.n3.eq.6) then
+ call split77(msg,nwords,nw,w)
+ j2=0
+ if(nwords.eq.2 .and. len(trim(w(2))).le.2) j2=1
+ if(nwords.eq.2 .and. len(trim(w(2))).eq.6) j2=2
+ write(*,1005) i3,n3,j2,cerr,msg0(1:37),msg
+1005 format(i2,'.',i1,'.',i1,2x,a1,1x,a37,1x,a37)
+ endif
+ if(i3.ge.1) write(*,1006) i3,cerr,msg0(1:37),msg
+1006 format(i2,'.',5x,a1,1x,a37,1x,a37)
if(nargs.eq.1) exit
enddo
diff --git a/lib/77bit/g8 b/lib/77bit/g8
index 2258817d..33819134 100644
--- a/lib/77bit/g8
+++ b/lib/77bit/g8
@@ -1,2 +1,3 @@
-gfortran -o test28 -fbounds-check -Wall -Wno-conversion test28.f90 pack28.f90 \
- unpack28.f90 ihashcall.f90 hash22.f90 save_hash_call.f90
+gfortran -c packjt77.f90
+gfortran -o test28 -fbounds-check -Wall -Wno-conversion test28.f90 \
+ ../chkcall.f90 packjt77.o
diff --git a/lib/77bit/messages.txt b/lib/77bit/messages.txt
index aa4ab078..9554b357 100644
--- a/lib/77bit/messages.txt
+++ b/lib/77bit/messages.txt
@@ -51,8 +51,8 @@ TU; G3AAA K1ABC R 559 MA
-----------------------------------------------------------
CQ G4ABC/P IO91
G4ABC/P PA9XYZ JO22
-PA9XYZ 590003 IO91NP
- G4ABC/P R 570007 JO22DB
+<PA9XYZ> <G4ABC/P> 590003 IO91NP
+ <G4ABC/P> <PA9XYZ> R 570007 JO22DB
PA9XYZ G4ABC/P RR73
8. Compound or nonstandard calls CQ
@@ -73,17 +73,7 @@ CQ W9XYZ EN37
YW18FIFA <W9XYZ> RRR
<W9XYZ> YW18FIFA 73
-10. WWROF FT8/FT4 contest
------------------------------------------------------------
-CQ TEST K1ABC FN42
- K1ABC W9XYZ -16 EN
-W9XYZ K1ABC R-07 FN
- K1ABC W9XYZ RR73
- K1ABC G3AAA -11 IO
-TU; G3AAA K1ABC R-09 FN
- K1ABC G3AAA RR73
-
-11. Other stuff
+10. Other stuff
-----------------------------------------------------------
TNX BOB 73 GL
CQ YW18FIFA
@@ -93,3 +83,9 @@ KA1ABC <YW18FIFA> -11
<KA1ABC> YW18FIFA RR73
<YW18FIFA> KA1ABC 73
123456789ABCDEF012
+K1ABC FN42 37
+PJ4/K1ABC 37
+K1ABC/VE3 37
+KA1ABC/VEX 37
+<PJ4/K1ABC> FK52UD
+<K1ABC/W4> FK52UD
diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90
index 1f9ed9a1..707e86e9 100644
--- a/lib/77bit/packjt77.f90
+++ b/lib/77bit/packjt77.f90
@@ -136,8 +136,8 @@ subroutine pack77(msg0,i3,n3,c77)
call pack77_01(nwords,w,i3,n3,c77)
if(i3.ge.0 .or. n3.ge.1) go to 900
! Check 0.2 (EU VHF contest exchange)
- call pack77_02(nwords,w,i3,n3,c77)
- if(i3.ge.0) go to 900
+! call pack77_02(nwords,w,i3,n3,c77)
+! if(i3.ge.0) go to 900
! Check 0.3 and 0.4 (ARRL Field Day exchange)
call pack77_03(nwords,w,i3,n3,c77)
@@ -160,8 +160,11 @@ subroutine pack77(msg0,i3,n3,c77)
go to 900
endif
+100 call pack77_06(nwords,w,i3,n3,c77)
+ if(i3.ge.0) go to 900
+
! Check Type 1 (Standard 77-bit message) or Type 2, with optional "/P"
-100 call pack77_1(nwords,w,i3,n3,c77)
+ call pack77_1(nwords,w,i3,n3,c77)
if(i3.ge.0) go to 900
! Check Type 3 (ARRL RTTY contest exchange)
@@ -172,7 +175,7 @@ subroutine pack77(msg0,i3,n3,c77)
call pack77_4(nwords,w,i3,n3,c77)
if(i3.ge.0) go to 900
-! Check Type 5 (WWROF contest exchange)
+! Check Type 5 (EU VHF Contest with 2 hashed calls, report, serial, and grid6)
call pack77_5(nwords,w,i3,n3,c77)
if(i3.ge.0) go to 900
@@ -203,17 +206,18 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
character*13 call_1,call_2,call_3
character*13 mycall13_0,dxcall13_0
character*11 c11
- character*3 crpt,cntx
+ character*3 crpt,cntx,cpfx
character*3 cmult(NUSCAN)
character*6 cexch,grid6
character*4 grid4,cserial
character*3 csec(NSEC)
- character*2 cfield
character*38 c
+ character*36 a2
integer hashmy10,hashmy12,hashmy22,hashdx10,hashdx12,hashdx22
logical unpk28_success,unpk77_success
logical dxcall13_set,mycall13_set
+ data a2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/,nzzz/46656/
data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/
data csec/ &
"AB ","AK ","AL ","AR ","AZ ","BC ","CO ","CT ","DE ","EB ", &
@@ -298,35 +302,6 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
mycall13_set .and. &
n10.eq.hashmy10) call_3='<'//trim(mycall13)//'>'
msg=trim(call_1)//' RR73; '//trim(call_2)//' '//trim(call_3)//' '//crpt
- else if(i3.eq.0 .and. n3.eq.2) then
-! 0.2 PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest
- read(c77,1020) n28a,ip,ir,irpt,iserial,igrid6
-1020 format(b28,2b1,b3,b12,b25)
- call unpack28(n28a,call_1,unpk28_success)
- if(.not.unpk28_success .or. n28a.le.2) unpk77_success=.false.
- nrs=52+irpt
- if(ip.eq.1) call_1=trim(call_1)//'/P'
- write(cexch,1022) nrs,iserial
-1022 format(i2,i4.4)
- n=igrid6
- j1=n/(18*10*10*24*24)
- n=n-j1*18*10*10*24*24
- j2=n/(10*10*24*24)
- n=n-j2*10*10*24*24
- j3=n/(10*24*24)
- n=n-j3*10*24*24
- j4=n/(24*24)
- n=n-j4*24*24
- j5=n/24
- j6=n-j5*24
- grid6(1:1)=char(j1+ichar('A'))
- grid6(2:2)=char(j2+ichar('A'))
- grid6(3:3)=char(j3+ichar('0'))
- grid6(4:4)=char(j4+ichar('0'))
- grid6(5:5)=char(j5+ichar('A'))
- grid6(6:6)=char(j6+ichar('A'))
- msg=trim(call_1)//' '//cexch//' '//grid6
- if(ir.eq.1) msg=trim(call_1)//' R '//cexch//' '//grid6
else if(i3.eq.0 .and. (n3.eq.3 .or. n3.eq.4)) then
! 0.3 WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71 ARRL Field Day
@@ -367,6 +342,70 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
enddo
msg=adjustl(msg)
+ else if(i3.eq.0 .and. n3.eq.6) then
+ read(c77(50:50),'(b1)') j2a
+ j2b=0
+ if(j2a.eq.0) read(c77(49:49),'(b1)') j2b
+ j2=2*j2a+j2b
+ if(j2.eq.0) then
+! WSPR Type 1
+ read(c77,2010) n28,igrid4,idbm
+2010 format(b28.28,b15.15,b5.5)
+ idbm=nint(idbm*10.0/3.0)
+ call unpack28(n28,call_1,unpk28_success)
+ if(.not.unpk28_success) unpk77_success=.false.
+ call to_grid4(igrid4,grid4)
+ write(crpt,'(i3)') idbm
+ msg=trim(call_1)//' '//grid4//' '//trim(adjustl(crpt))
+
+ else if(j2.eq.1) then
+! WSPR Type 2
+ read(c77,2030) n28,igrid6
+2030 format(b22.22,b25.25)
+ call unpack28(n28,call_1,unpk28_success)
+ if(.not.unpk28_success) unpk77_success=.false.
+ call to_grid6(igrid6,grid6)
+ msg=trim(call_1)//' '//grid6
+
+ else if(j2.eq.2) then
+! WSPR Type 3
+ read(c77,2020) n28,npfx,idbm
+2020 format(b28.28,b16.16,b5.5)
+ idbm=nint(idbm*10.0/3.0)
+ call unpack28(n28,call_1,unpk28_success)
+ if(.not.unpk28_success) unpk77_success=.false.
+ write(crpt,'(i3)') idbm
+ if(npfx.lt.nzzz) then
+! Prefix
+ do i=3,1,-1
+ j=mod(npfx,36)+1
+ cpfx(i:i)=a2(j:j)
+ npfx=npfx/36
+ if(npfx.eq.0) exit
+ enddo
+ msg=trim(adjustl(cpfx))//'/'//trim(call_1)//' '//trim(adjustl(crpt))
+ else
+! Suffix
+ npfx=npfx-nzzz
+ cpfx=' '
+ if(npfx.le.35) then
+ cpfx(1:1)=a2(npfx+1:npfx+1)
+ else if(npfx.gt.35 .and. npfx.le.1295) then
+ cpfx(1:1)=a2(npfx/36+1:npfx/36+1)
+ cpfx(2:2)=a2(mod(npfx,36)+1:mod(npfx,36)+1)
+ else if(npfx.gt.1295 .and. npfx.le.12959) then
+ cpfx(1:1)=a2(npfx/360+1:npfx/360+1)
+ cpfx(2:2)=a2(mod(npfx/10,36)+1:mod(npfx/10,36)+1)
+ cpfx(3:3)=a2(mod(npfx,10)+1:mod(npfx,10)+1)
+ else
+ unpk77_success=.false.
+ return
+ endif
+ msg=trim(call_1)//'/'//trim(adjustl(cpfx))//' '//trim(adjustl(crpt))
+ endif
+
+ endif
+
else if(i3.eq.1 .or. i3.eq.2) then
! Type 1 (standard message) or Type 2 ("/P" form for EU VHF contest)
read(c77,1000) n28a,ipa,n28b,ipb,ir,igrid4,i3
@@ -389,17 +428,7 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
if(i.ge.4) call add_call_to_recent_calls(call_2)
endif
if(igrid4.le.MAXGRID4) then
- n=igrid4
- j1=n/(18*10*10)
- n=n-j1*18*10*10
- j2=n/(10*10)
- n=n-j2*10*10
- j3=n/10
- j4=n-j3*10
- grid4(1:1)=char(j1+ichar('A'))
- grid4(2:2)=char(j2+ichar('A'))
- grid4(3:3)=char(j3+ichar('0'))
- grid4(4:4)=char(j4+ichar('0'))
+ call to_grid4(igrid4,grid4)
if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//grid4
if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R '//grid4
if(msg(1:3).eq.'CQ ' .and. ir.eq.1) unpk77_success=.false.
@@ -460,6 +489,7 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
' R '//crpt//' '//cserial
endif
else if(i3.eq.4) then
+! Type 4
read(c77,1050) n12,n58,iflip,nrpt,icq
1050 format(b12,b58,b1,b2,b1)
do i=11,1,-1
@@ -470,7 +500,7 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
call hash12(n12,call_3)
if(iflip.eq.0) then ! 12 bit hash for TO call
call_1=call_3
- call_2=adjustl(c11)//' '
+ call_2=adjustl(c11)//' '
call add_call_to_recent_calls(call_2)
if(nrx.eq.1 .and. &
dxcall13_set .and. mycall13_set .and. &
@@ -496,29 +526,24 @@ subroutine unpack77(c77,nrx,msg,unpk77_success)
else
msg='CQ '//trim(call_2)
endif
-
+
else if(i3.eq.5) then
-! 5 TU; W9XYZ K1ABC R-09 FN 1 28 28 1 7 9 74 WWROF contest
- read(c77,1041) itu,n28a,n28b,ir,irpt,nexch,i3
-1041 format(b1,2b28.28,b1,b7.7,b9.9,b3.3)
- call unpack28(n28a,call_1,unpk28_success)
- if(.not.unpk28_success) unpk77_success=.false.
- call unpack28(n28b,call_2,unpk28_success)
- if(.not.unpk28_success) unpk77_success=.false.
- write(crpt,'(i3.2)') irpt-35
- if(crpt(1:1).eq.' ') crpt(1:1)='+'
- n1=nexch/18
- n2=nexch - 18*n1
- cfield(1:1)=char(ichar('A')+n1)
- cfield(2:2)=char(ichar('A')+n2)
- if(itu.eq.0 .and. ir.eq.0) msg=trim(call_1)//' '//trim(call_2)// &
- ' '//crpt//' '//cfield
- if(itu.eq.1 .and. ir.eq.0) msg='TU; '//trim(call_1)//' '//trim(call_2)// &
- ' '//crpt//' '//cfield
- if(itu.eq.0 .and. ir.eq.1) msg=trim(call_1)//' '//trim(call_2)// &
- ' R'//crpt//' '//cfield
- if(itu.eq.1 .and. ir.eq.1) msg='TU; '//trim(call_1)//' '//trim(call_2)// &
- ' R'//crpt//' '//cfield
+
+! Type 5 <PA3XYZ> <G4ABC/P> R 590003 IO91NP h12 h22 r1 s3 S11 g25
+! EU VHF contest
+ read(c77,1060) n12,n22,ir,irpt,iserial,igrid6
+1060 format(b12,b22,b1,b3,b11,b25)
+ call hash12(n12,call_1)
+ call hash22(n22,call_2)
+ nrs=52+irpt
+ write(cexch,1022) nrs,iserial
+1022 format(i2,i4.4)
+ call to_grid6(igrid6,grid6)
+ if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//cexch//' '//grid6
+ if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R '//cexch//' '//grid6
+
+ else if(i3.ge.6) then ! i3 values 6 and 7 are not yet defined
+ unpk77_success=.false.
endif
! if(msg(1:4).eq.'CQ <') unpk77_success=.false.
@@ -633,7 +658,7 @@ subroutine pack28(c13,n28)
npdig.ge.iarea-1 .or. nslet.gt.3) then
! Treat this as a nonstandard callsign: compute its 22-bit hash
call save_hash_call(c13,n10,n12,n22) !Save callsign in hash table
- n22=ihashcall(c13,n22)
+ n22=ihashcall(c13,22)
n28=NTOKENS + n22
go to 900
endif
@@ -806,7 +831,7 @@ subroutine pack77_01(nwords,w,i3,n3,c77)
call chkcall(w(3),bcall_2,ok2)
if(.not.ok2) go to 900 !3rd word must be a valid basecall
-! Type 0.1: K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 71 DXpedition Mode
+! Type 0.1: K1ABC RR73; W9XYZ <KH1/KH7Z> -11 28 28 10 5 71
i3=0
n3=1
call pack28(w(1),n28a)
@@ -822,62 +847,10 @@ subroutine pack77_01(nwords,w,i3,n3,c77)
end subroutine pack77_01
-subroutine pack77_02(nwords,w,i3,n3,c77)
-
- character*13 w(19),c13
- character*77 c77
- character*6 bcall_1,grid6
- logical ok1,is_grid6
-
- is_grid6(grid6)=len(trim(grid6)).eq.6 .and. &
- grid6(1:1).ge.'A' .and. grid6(1:1).le.'R' .and. &
- grid6(2:2).ge.'A' .and. grid6(2:2).le.'R' .and. &
- grid6(3:3).ge.'0' .and. grid6(3:3).le.'9' .and. &
- grid6(4:4).ge.'0' .and. grid6(4:4).le.'9' .and. &
- grid6(5:5).ge.'A' .and. grid6(5:5).le.'X' .and. &
- grid6(6:6).ge.'A' .and. grid6(6:6).le.'X'
-
- call chkcall(w(1),bcall_1,ok1)
- if(.not.ok1) return !bcall_1 must be a valid basecall
- if(nwords.lt.3 .or. nwords.gt.4) return !nwords must be 3 or 4
- nx=-1
- if(nwords.ge.2) read(w(nwords-1),*,err=2) nx
-2 if(nx.lt.520001 .or. nx.gt.594095) return !Exchange between 520001 - 594095
- if(.not.is_grid6(w(nwords)(1:6))) return !Last word must be a valid grid6
-
-! Type 0.2: PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25 70 EU VHF contest
- i3=0
- n3=2
- i=index(w(1)//' ','/P ')
- if(i.ge.4) then
- ip=1
- c13=w(1)(1:i-1)
- else
- ip=0
- c13=w(1)
- end if
- call pack28(c13,n28a)
- ir=0
- if(w(2)(1:2).eq.'R ') ir=1
- irpt=nx/10000 - 52
- iserial=mod(nx,10000)
- grid6=w(nwords)(1:6)
- j1=(ichar(grid6(1:1))-ichar('A'))*18*10*10*24*24
- j2=(ichar(grid6(2:2))-ichar('A'))*10*10*24*24
- j3=(ichar(grid6(3:3))-ichar('0'))*10*24*24
- j4=(ichar(grid6(4:4))-ichar('0'))*24*24
- j5=(ichar(grid6(5:5))-ichar('A'))*24
- j6=(ichar(grid6(6:6))-ichar('A'))
- igrid6=j1+j2+j3+j4+j5+j6
- write(c77,1010) n28a,ip,ir,irpt,iserial,igrid6,n3,i3
-1010 format(b28.28,2b1,b3.3,b12.12,b25.25,b4.4,b3.3)
-
- return
-end subroutine pack77_02
-
-
subroutine pack77_03(nwords,w,i3,n3,c77)
+
! Check 0.3 and 0.4 (ARRL Field Day exchange)
+! Example message: WA9XYZ KA1ABC R 16A EMA 28 28 1 4 3 7 71
parameter (NSEC=84) !Number of ARRL Sections
character*13 w(19)
@@ -939,8 +912,129 @@ subroutine pack77_03(nwords,w,i3,n3,c77)
return
end subroutine pack77_03
+
+subroutine pack77_06(nwords,w,i3,n3,c77)
+
+ character*13 w(19)
+ character*77 c77
+ character*6 bcall,grid6
+ character*4 grid4
+ character*1 c
+ character*36 a2
+ data a2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/,nzzz/46656/
+
+ logical is_grid4,is_grid6,is_digit,ok
+ is_grid4(grid4)=len(trim(grid4)).eq.4 .and. &
+ grid4(1:1).ge.'A' .and. grid4(1:1).le.'R' .and. &
+ grid4(2:2).ge.'A' .and. grid4(2:2).le.'R' .and. &
+ grid4(3:3).ge.'0' .and. grid4(3:3).le.'9' .and. &
+ grid4(4:4).ge.'0' .and. grid4(4:4).le.'9'
+
+ is_grid6(grid6)=len(trim(grid6)).eq.6 .and. &
+ grid6(1:1).ge.'A' .and. grid6(1:1).le.'R' .and. &
+ grid6(2:2).ge.'A' .and. grid6(2:2).le.'R' .and. &
+ grid6(3:3).ge.'0' .and. grid6(3:3).le.'9' .and. &
+ grid6(4:4).ge.'0' .and. grid6(4:4).le.'9' .and. &
+ grid6(5:5).ge.'A' .and. grid6(5:5).le.'X' .and. &
+ grid6(6:6).ge.'A' .and. grid6(6:6).le.'X'
+
+ is_digit(c)=c.ge.'0' .and. c.le.'9'
+
+ m1=len(trim(w(1)))
+ m2=len(trim(w(2)))
+ m3=len(trim(w(3)))
+ if(nwords.eq.3 .and. m1.ge.3 .and. m1.le.6 .and. m2.eq.4 .and. m3.le.2) then
+! WSPR Type 1
+ if(.not.is_grid4(w(2)(1:4))) go to 900
+ if(.not.is_digit(w(3)(1:1))) go to 900
+ if(m3.eq.2) then
+ if(.not.is_digit(w(3)(2:2))) go to 900
+ endif
+ i3=0
+ n3=6
+ call pack28(w(1),n28)
+ grid4=w(2)(1:4)
+ k1=(ichar(grid4(1:1))-ichar('A'))*18*10*10
+ k2=(ichar(grid4(2:2))-ichar('A'))*10*10
+ k3=(ichar(grid4(3:3))-ichar('0'))*10
+ k4=(ichar(grid4(4:4))-ichar('0'))
+ igrid4=k1+k2+k3+k4
+ read(w(3),*) idbm
+ if(idbm.lt.0) idbm=0
+ if(idbm.gt.60) idbm=60
+ idbm=nint(0.3*idbm)
+ write(c77,1010) n28,igrid4,idbm,0,0,0,n3,i3
+1010 format(b28.28,b15.15,b5.5,2i1,b21.21,2b3.3)
+ go to 900
+ endif
+ if(nwords.eq.2 .and. m1.ge.5 .and. m1.le.10 .and. m2.le.2) then
+! WSPR Type 2
+ i1=index(w(1),'/')
+ if(i1.lt.2 .or. i1.eq.m1) go to 900
+ if(.not.is_digit(w(2)(1:1))) go to 900
+ if(i1.eq.(m1-3) .and. .not.is_digit(w(1)(m1:m1))) go to 900
+ if(m2.eq.2) then
+ if(.not.is_digit(w(2)(2:2))) go to 900
+ endif
+ call chkcall(w(1),bcall,ok)
+ if(.not.ok) go to 900
+ if(i1.le.4) then
+! We have a prefix
+ npfx=index(a2,w(1)(1:1))-1
+ if(i1.ge.3) npfx=36*npfx + index(a2,w(1)(2:2))-1
+ if(i1.eq.4) npfx=36*npfx + index(a2,w(1)(3:3))-1
+ else
+! We have a suffix
+ if((m1-i1).eq.1) npfx=index(a2,w(1)(i1+1:i1+1))-1
+ if((m1-i1).eq.2) npfx=36*(index(a2,w(1)(i1+1:i1+1))-1) + &
+ index(a2,w(1)(i1+2:i1+2))-1
+ if((m1-i1).eq.3) then
+! Third character of a suffix must be a digit
+ if(.not.is_digit(w(1)(i1+3:i1+3))) go to 900
+ npfx=36*10*(index(a2,w(1)(i1+1:i1+1))-1) + &
+ 10*(index(a2,w(1)(i1+2:i1+2))-1) + index(a2,w(1)(i1+3:i1+3))-1
+ endif
+ npfx=npfx + nzzz
+ endif
+ i3=0
+ n3=6
+ call pack28(bcall//' ',n28)
+ read(w(2),*) idbm
+ if(idbm.lt.0) idbm=0
+ if(idbm.gt.60) idbm=60
+ idbm=nint(0.3*idbm)
+ write(c77,1020) n28,npfx,idbm,1,0,n3,i3
+1020 format(b28.28,b16.16,b5.5,i1,b21.21,2b3.3)
+ go to 900
+ endif
+
+ if(nwords.eq.2 .and. m1.ge.5 .and. m1.le.12 .and. m2.le.6) then
+! WSPR Type 3
+ if(index(w(1),'<').lt.1 .or. index(w(1),'>').lt.1) go to 900
+ grid6=w(2)(1:6)
+ if(.not.is_grid6(grid6)) go to 900
+ i3=0
+ n3=6
+ call pack28(w(1),n28)
+ k1=(ichar(grid6(1:1))-ichar('A'))*18*10*10*24*24
+ k2=(ichar(grid6(2:2))-ichar('A'))*10*10*24*24
+ k3=(ichar(grid6(3:3))-ichar('0'))*10*24*24
+ k4=(ichar(grid6(4:4))-ichar('0'))*24*24
+ k5=(ichar(grid6(5:5))-ichar('A'))*24
+ k6=(ichar(grid6(6:6))-ichar('A'))
+ igrid6=k1+k2+k3+k4+k5+k6
+ write(c77,1030) n28,igrid6,2,0,n3,i3
+1030 format(b22.22,b25.25,b3.3,b21.21,2b3.3)
+ endif
+
+900 return
+end subroutine pack77_06
+
+
subroutine pack77_1(nwords,w,i3,n3,c77)
+
! Check Type 1 (Standard 77-bit message) and Type 2 (ditto, with a "/P" call)
+! Example message: WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74
parameter (MAXGRID4=32400)
character*13 w(19),c13
@@ -1041,10 +1135,12 @@ end subroutine pack77_1
subroutine pack77_3(nwords,w,i3,n3,c77)
-! Check Type 2 (ARRL RTTY contest exchange)
-!ARRL RTTY - US/Can: rpt state/prov R 579 MA
-! - DX: rpt serial R 559 0013
-
+
+! Check Type 3 (ARRL RTTY contest exchange)
+! ARRL RTTY - US/Can: rpt state/prov R 579 MA
+! - DX: rpt serial R 559 0013
+! Example message: TU; W9XYZ K1ABC R 579 MA 1 28 28 1 3 13 74
+
parameter (NUSCAN=65) !Number of US states and Canadian provinces/territories
character*13 w(19)
character*77 c77
@@ -1109,8 +1205,11 @@ subroutine pack77_3(nwords,w,i3,n3,c77)
900 return
end subroutine pack77_3
+
subroutine pack77_4(nwords,w,i3,n3,c77)
-! Check Type 3 (One nonstandard call and one hashed call)
+
+! Check Type 4 (One nonstandard call and one hashed call)
+! Example message: <WA9XYZ> PJ4/KA1ABC RR73 12 58 1 2 1 74
integer*8 n58
logical ok1,ok2
@@ -1178,59 +1277,67 @@ subroutine pack77_4(nwords,w,i3,n3,c77)
end subroutine pack77_4
subroutine pack77_5(nwords,w,i3,n3,c77)
-! Check Type 5 (WWROF contest exchange)
- character*13 w(19)
+! Pack a Type 0.2 message: EU VHF Contest mode
+! Example message: PA3XYZ/P R 590003 IO91NP 28 1 1 3 12 25
+! <PA3XYZ> <G4ABC/P> R 590003 IO91NP h10 h20 r1 s3 s12 g25
+
+ character*13 w(19),c13
character*77 c77
- character*6 bcall_1,bcall_2
- character*3 mult
- character crpt*4
- character c1*1,c2*2
- logical ok1,ok2
+ character*6 grid6
+ logical is_grid6
- if(nwords.eq.4 .or. nwords.eq.5 .or. nwords.eq.6) then
- i1=1
- if(trim(w(1)).eq.'TU;') i1=2
- call chkcall(w(i1),bcall_1,ok1)
- call chkcall(w(i1+1),bcall_2,ok2)
- if(.not.ok1 .or. .not.ok2) go to 900
- crpt=w(nwords-1)(1:4)
- if(index(crpt,'-').lt.1 .and. index(crpt,'+').lt.1) go to 900
+ is_grid6(grid6)=len(trim(grid6)).eq.6 .and. &
+ grid6(1:1).ge.'A' .and. grid6(1:1).le.'R' .and. &
+ grid6(2:2).ge.'A' .and. grid6(2:2).le.'R' .and. &
+ grid6(3:3).ge.'0' .and. grid6(3:3).le.'9' .and. &
+ grid6(4:4).ge.'0' .and. grid6(4:4).le.'9' .and. &
+ grid6(5:5).ge.'A' .and. grid6(5:5).le.'X' .and. &
+ grid6(6:6).ge.'A' .and. grid6(6:6).le.'X'
- c1=crpt(1:1)
- c2=crpt(1:2)
- irpt=-1
- if(c1.eq.'+' .or. c1.eq.'-') then
- ir=0
- read(w(nwords-1),*,err=900) irpt
- irpt=irpt+35
- else if(c2.eq.'R+' .or. c2.eq.'R-') then
- ir=1
- read(w(nwords-1)(2:),*) irpt
- irpt=irpt+35
- endif
- if(irpt.eq.-1 .or. len(trim(w(nwords))).ne.2) go to 900
- c2=w(nwords)(1:2)
- n1=ichar(c2(1:1)) - ichar('A')
- n2=ichar(c2(2:2)) - ichar('A')
- if(n1.lt.0 .or. n1.gt.17) go to 900
- if(n2.lt.0 .or. n2.gt.17) go to 900
- nexch=18*n1 + n2
- i3=5
- n3=0
- itu=0
- if(trim(w(1)).eq.'TU;') itu=1
- call pack28(w(1+itu),n28a)
- call pack28(w(2+itu),n28b)
-! 5 TU; W9XYZ K1ABC R-09 FN 1 28 28 1 7 9 74 WWROF contest
- write(c77,1010) itu,n28a,n28b,ir,irpt,nexch,i3
-1010 format(b1,2b28.28,b1,b7.7,b9.9,b3.3)
-
- end if
-
-900 return
+ if(nwords.lt.4 .or. nwords.gt.5) return !nwords must be 4 or 5
+ if(w(1)(1:1).ne.'<' .or. w(2)(1:1).ne.'<') return !Both calls must be hashed
+ nx=-1
+ read(w(nwords-1),*,err=2) nx
+2 if(nx.lt.520001 .or. nx.gt.594095) return !Exchange between 520001 - 594095
+ if(.not.is_grid6(w(nwords)(1:6))) return !Last word must be a valid grid6
+
+! Type 0.2: <PA3XYZ> <G4ABC/P> R 590003 IO91NP h10 h20 r1 s3 s12 g25
+
+ i3=5
+ n3=0
+
+ call save_hash_call(w(1),n10,n12,n22)
+ i2=index(w(1),'>')
+ c13=w(1)(2:i2-1)
+ n12=ihashcall(c13,12)
+
+ call save_hash_call(w(2),n10a,n12a,n22)
+ i2=index(w(2),'>')
+ c13=w(2)(2:i2-1)
+ n22=ihashcall(c13,22)
+
+ ir=0
+ if(w(3)(1:2).eq.'R ') ir=1
+ irpt=nx/10000 - 52
+ iserial=mod(nx,10000)
+ if(iserial.gt.2047) iserial=2047
+ grid6=w(nwords)(1:6)
+ j1=(ichar(grid6(1:1))-ichar('A'))*18*10*10*24*24
+ j2=(ichar(grid6(2:2))-ichar('A'))*10*10*24*24
+ j3=(ichar(grid6(3:3))-ichar('0'))*10*24*24
+ j4=(ichar(grid6(4:4))-ichar('0'))*24*24
+ j5=(ichar(grid6(5:5))-ichar('A'))*24
+ j6=(ichar(grid6(6:6))-ichar('A'))
+ igrid6=j1+j2+j3+j4+j5+j6
+
+ write(c77,1010) n12,n22,ir,irpt,iserial,igrid6,i3
+1010 format(b12.12,b22.22,b1,b3.3,b11.11,b25.25,b3.3)
+
+ return
end subroutine pack77_5
+
subroutine packtext77(c13,c71)
character*13 c13,w
@@ -1347,4 +1454,44 @@ subroutine add_call_to_recent_calls(callsign)
return
end subroutine add_call_to_recent_calls
+subroutine to_grid4(n,grid4)
+ character*4 grid4
+
+ j1=n/(18*10*10)
+ n=n-j1*18*10*10
+ j2=n/(10*10)
+ n=n-j2*10*10
+ j3=n/10
+ j4=n-j3*10
+ grid4(1:1)=char(j1+ichar('A'))
+ grid4(2:2)=char(j2+ichar('A'))
+ grid4(3:3)=char(j3+ichar('0'))
+ grid4(4:4)=char(j4+ichar('0'))
+
+ return
+end subroutine to_grid4
+
+subroutine to_grid6(n,grid6)
+ character*6 grid6
+
+ j1=n/(18*10*10*24*24)
+ n=n-j1*18*10*10*24*24
+ j2=n/(10*10*24*24)
+ n=n-j2*10*10*24*24
+ j3=n/(10*24*24)
+ n=n-j3*10*24*24
+ j4=n/(24*24)
+ n=n-j4*24*24
+ j5=n/24
+ j6=n-j5*24
+ grid6(1:1)=char(j1+ichar('A'))
+ grid6(2:2)=char(j2+ichar('A'))
+ grid6(3:3)=char(j3+ichar('0'))
+ grid6(4:4)=char(j4+ichar('0'))
+ grid6(5:5)=char(j5+ichar('A'))
+ grid6(6:6)=char(j6+ichar('A'))
+
+ return
+end subroutine to_grid6
+
end module packjt77
diff --git a/lib/77bit/test28.f90 b/lib/77bit/test28.f90
index 67bde4af..30ce1544 100644
--- a/lib/77bit/test28.f90
+++ b/lib/77bit/test28.f90
@@ -1,11 +1,20 @@
program test28
+ use packjt77
parameter (NTOKENS=2063592,MAX22=4194304)
- character*13 call_0,call_1,bare_call_1
+ character*13 arg,call_00,call_0,call_1
character*1 cerr
+ logical unpk28_success
nargs=iargc()
- open(10,file='test28.txt',status='old')
+ n28=-1
+ if(nargs.eq.1) then
+ call getarg(1,arg)
+ read(arg,'(i13)',err=2) n28
+ endif
+ if(n28.ge.0) go to 100
+
+2 open(10,file='test28.txt',status='old')
write(*,1000)
1000 format('Encoded text Recovered text n28 Err? Type'/60('-'))
@@ -14,30 +23,41 @@ program test28
if(nargs.eq.0) then
read(10,'(a13)',end=999) call_0
else
- call getarg(1,call_0)
+ call_0=arg
endif
if(call_0.eq.' ') exit
if(call_0(1:3).eq.'CQ ' .and. call_0(4:4).ne.' ') call_0(3:3)='_'
call_1=' '
- call pack28(call_0,n28)
- call unpack28(n28,call_1)
+ call_00=call_0
+ call pack28(call_00,n28)
+ call unpack28(n28,call_1,unpk28_success)
cerr=' '
if(call_0.ne.call_1) cerr='*'
- if(call_1(1:1).eq.'<') then
- i=index(call_1,'>')
- bare_call_1=call_1(2:i-1)//' '
- endif
- if(call_0.eq.bare_call_1) cerr=' '
if(call_0(1:3).eq.'CQ_') call_0(3:3)=' '
if(call_1(1:3).eq.'CQ_') call_1(3:3)=' '
if(n28.lt.NTOKENS) write(*,1010) call_0,call_1,n28,cerr
1010 format(a13,2x,a13,i10,2x,a1,2x,'Special token')
- if(n28.ge.NTOKENS .and. n28.lt.NTOKENS+MAX22) write(*,1012) call_0, &
- call_1,n28,cerr
-1012 format(a13,2x,a13,i10,2x,a1,2x,'22-bit hash')
+ if(n28.ge.NTOKENS .and. n28.lt.NTOKENS+MAX22) then
+ call_00=call_0
+ call save_hash_call(call_00,n10,n12,n22)
+ write(*,1012) call_0,call_1,n28,cerr,n22
+1012 format(a13,2x,a13,i10,2x,a1,2x,'22-bit hash',i15)
+ endif
if(n28.ge.NTOKENS+MAX22) write(*,1014) call_0,call_1,n28,cerr
1014 format(a13,2x,a13,i10,2x,a1,2x,'Standard callsign')
if(nargs.gt.0) exit
enddo
+ go to 999
+
+100 call unpack28(n28,call_1,unpk28_success)
+ cerr=' '
+ if(.not.unpk28_success) cerr='*'
+ if(call_1(1:3).eq.'CQ_') call_1(3:3)=' '
+ if(n28.lt.NTOKENS) write(*,2010) n28,call_1,cerr
+2010 format(i10,2x,a13,2x,a1,2x,'Special token')
+ if(n28.ge.NTOKENS .and. n28.lt.NTOKENS+MAX22) write(*,2012) n28,call_1,cerr
+2012 format(i10,2x,a13,2x,a1,2x,'22-bit hash')
+ if(n28.ge.NTOKENS+MAX22) write(*,2014) n28,call_1,cerr
+2014 format(i10,2x,a13,2x,a1,2x,'Standard callsign')
999 end program test28
diff --git a/lib/77bit/test28.txt b/lib/77bit/test28.txt
index 442215b6..b2801121 100644
--- a/lib/77bit/test28.txt
+++ b/lib/77bit/test28.txt
@@ -12,23 +12,16 @@ CQ_AAA
CQ_ZZZ
CQ_AAAA
CQ_ZZZZ
-EI30T
-YW18FIFA
-KH1/KH7Z
+<EI30T>
+<YW18FIFA>
<KH1/KH7Z>
-ZS9YOTA
-YB50ST
-00A
-99ZZZ
-000A
-009ZZZ
-999ZZZ
-HA70BAY
-WB2000XYZ
-WB2000XYZABCD
-ZM90DX
+<ZS9YOTA>
+<YB50ST>
+<HA70BAY>
+<WB2000XYZ>
+<ZM90DX>
<VP2E/KA1ABC>
-HB9GOLD
+<HB9GOLD>
A0
A0A
K1ABC
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644
index c4d6279a..00000000
--- a/lib/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-CC = gcc
-CXX = g++
-FC = gfortran
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion
-CFLAGS = -O2 -I.
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-#all: qratest.exe tplt.exe
-all: qra64d.exe
-
-OBJS1 = qratest.o qra64a.o ana64.o sync64a.o four2a.o smo.o smo121.o averms.o \
- timer_module.o packjt.o twkfreq.o spec64.o fmtmsg.o pctile.o \
- grid2deg.o deg2grid.o shell.o badmsg.o qra64_subs.o \
- qracodes.o npfwht.o pdmath.o qra12_63_64_irr_b.o \
- qra13_64_64_irr_e.o qra64.o image.o \
- zplt64a.o zplt64b.o lorentzian.o fchisq0.o peakup.o sync64.o
-
-qra64_subs.o: qra/qra64/qra64_subs.c
- gcc -c -O2 -o qra64_subs.o qra/qra64/qra64_subs.c
-
-qracodes.o: qra/qracodes/qracodes.c
- gcc -c -O2 -o qracodes.o qra/qracodes/qracodes.c
-
-qra64.o: qra/qra64/qra64.c
- gcc -c -O2 -o qra64.o qra/qra64/qra64.c
-
-npfwht.o: qra/qracodes/npfwht.c
- gcc -c -O2 -o npfwht.o qra/qracodes/npfwht.c
-
-pdmath.o: qra/qracodes/pdmath.c
- gcc -c -O2 -o pdmath.o qra/qracodes/pdmath.c
-
-qra12_63_64_irr_b.o: qra/qracodes/qra12_63_64_irr_b.c
- gcc -c -O2 -o qra12_63_64_irr_b.o qra/qracodes/qra12_63_64_irr_b.c
-
-qra13_64_64_irr_e.o: qra/qracodes/qra13_64_64_irr_e.c
- gcc -c -O2 -o qra13_64_64_irr_e.o qra/qracodes/qra13_64_64_irr_e.c
-
-qratest.exe: $(OBJS1)
- $(FC) -o qratest.exe $(OBJS1) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS2 = tplt.o zplt64.o image.o
-tplt.exe: $(OBJS2)
- $(FC) -o tplt.exe $(OBJS2)
-
-OBJS3 = qra64d.o sync64a.o four2a.o smo.o smo121.o averms.o \
- timer_module.o packjt.o twkfreq.o spec64.o fmtmsg.o pctile.o \
- grid2deg.o deg2grid.o shell.o badmsg.o qra64_subs.o \
- qracodes.o npfwht.o pdmath.o qra12_63_64_irr_b.o \
- qra13_64_64_irr_e.o qra64.o image.o \
- zplt64a.o zplt64b.o lorentzian.o fchisq0.o peakup.o sync64.o
-
-qra64d.exe: $(OBJS3)
- $(FC) -o qra64d.exe $(OBJS3) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-.PHONY : clean
-
-clean:
- $(RM) *.o qratest.exe tplt.exe
diff --git a/lib/Makefile.MinGW b/lib/Makefile.MinGW
deleted file mode 100644
index 1cdc665e..00000000
--- a/lib/Makefile.MinGW
+++ /dev/null
@@ -1,153 +0,0 @@
-# Makefile for MinGW on Windows
-#
-# Needed libraries are located using the following variables:
-#
-# QT_DIR - point this at the root of your Qt installation
-# FFTW3_DIR - point this at the fftw v3 installation directory
-#
-# e.g.
-# make -f Makefile.MinGW \
-# QT_DIR=c:/Qt/5.2.1/mingw48_32 \
-# FFTW3_DIR = c:/fftw-3.3.3-dll32-2
-#
-# Windows re-direct:
-# C> make > junk1 2>&1
-
-# Set paths
-EXE_DIR = ..\\..\\wsjtx_install
-QT_DIR = C:/wsjt-env/Qt5/5.2.1/mingw48_32
-FFTW3_DIR = ..
-
-INCPATH = -I${QT_DIR}/include/QtCore -I${QT_DIR}/include
-
-# Compilers
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-RANLIB = ranlib
-MKDIR = mkdir -p
-CP = cp
-RM = rm -f
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-precision-loss -fno-second-underscore
-CFLAGS = -I. -fbounds-check -mno-stack-arg-probe
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a libastro.a jt9.exe jt9code.exe jt65code.exe
-
-OBJS1 = prog_args.o options.o pctile.o graycode.o sort.o ssort.o chkmsg.o \
- unpackmsg.o igray.o unpackcall.o unpackgrid.o \
- fmtmsg.o grid2k.o unpacktext.o getpfx2.o packmsg.o deg2grid.o \
- packtext.o getpfx1.o packcall.o k2grid.o packgrid.o \
- nchar.o four2a.o grid2deg.o pfxdump.o f77_wisdom.o \
- symspec.o analytic.o db.o genjt9.o flat1.o smo.o \
- packbits.o unpackbits.o encode232.o interleave9.o \
- entail.o fano232.o gran.o sync9.o decode9.o \
- fil3.o decoder.o grid2n.o n2grid.o timer.o \
- softsym.o getlags.o afc9.o fchisq.o twkfreq.o downsam9.o \
- peakdt9.o symspec2.o stdmsg.o morse.o azdist.o geodist.o \
- fillcom.o chkss2.o zplot9.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat3.o polfit.o determ.o baddata.o
-
-libjt9.a: $(OBJS1)
- $(AR) libjt9.a $(OBJS1)
- $(RANLIB) libjt9.a
-
-OBJS2 = jt9.o jt9a.o jt9b.o jt9c.o ipcomm.o sec_midn.o usleep.o
-LIBS2 = -L${QT_DIR}/lib -lQt5Core
-jt9.exe: $(OBJS2) libjt9.a
- $(CXX) -o jt9.exe $(OBJS2) $(LIBS2) libjt9.a \
- -L$(FFTW3_DIR) -lfftw3f-3 $(shell $(FC) -print-file-name=lib$(FC).a)
- -$(MKDIR) $(EXE_DIR)
- $(CP) jt9.exe $(EXE_DIR)
-
-OBJS3 = jt9sim.o
-jt9sim.exe: $(OBJS3) libjt9.a
- $(FC) -o jt9sim.exe $(OBJS3) libjt9.a
-
-OBJS4 = jt9code.o
-jt9code.exe: $(OBJS4) libjt9.a
- $(FC) -o jt9code.exe $(OBJS4) libjt9.a
- $(CP) jt9code.exe $(EXE_DIR)
-
-OBJS5 = jt65.o
-jt65.exe: $(OBJS5) libjt9.a
- $(FC) -o jt65.exe $(OBJS5) libjt9.a -L$(FFTW3_DIR) -lfftw3f-3
-
-OBJS7 = astrosub.o astro0.o astro.o tm2.o grid2deg.o sun.o moondop.o \
- coord.o dot.o moon2.o tmoonsub.o toxyz.o geocentric.o \
- dcoord.o
-
-libastro.a: $(OBJS7)
- $(AR) libastro.a $(OBJS7)
- $(RANLIB) libastro.a
-
-OBJS6 = jt65code.o
-jt65code.exe: $(OBJS6) libjt9.a
- $(FC) -o jt65code.exe $(OBJS6) libjt9.a
- $(CP) jt65code.exe $(EXE_DIR)
-
-sync9.o: sync9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c sync9.f90
-
-spec9.o: spec9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c spec9.f90
-
-peakdt9.o: peakdt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c peakdt9.f90
-
-jt9sim.o: jt9sim.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c jt9sim.f90
-
-genjt9.o: genjt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c genjt9.f90
-
-redsync.o: redsync.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c redsync.f90
-
-unpackmsg.o: unpackmsg.f90
- $(FC) -c -O0 -fbounds-check -Wall -Wno-precision-loss unpackmsg.f90
-
-ipcomm.o: ipcomm.cpp
- $(CXX) -c $(INCPATH) ipcomm.cpp
-
-sec_midn.o: sec_midn.f90
- $(FC) -c -fno-second-underscore sec_midn.f90
-
-#rig_control.o: rig_control.c
-# $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include rig_control.c
-
-tstrig.o: tstrig.c
- $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include tstrig.c
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-
-.PHONY : clean
-
-clean:
- $(RM) *.o libjt9.a wsjtx.exe jt9sim.exe jt9.exe jt65.exe
diff --git a/lib/Makefile.MinGW.qt4 b/lib/Makefile.MinGW.qt4
deleted file mode 100644
index df907459..00000000
--- a/lib/Makefile.MinGW.qt4
+++ /dev/null
@@ -1,122 +0,0 @@
-# Makefile for MinGW on Windows
-# Windows re-direct:
-# C> make > junk1 2>&1
-
-# Set paths
-EXE_DIR = ../../wsjtx_install
-INCPATH = -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include/QtCore' \
- -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include' \
- -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include/ActiveQt' \
- -I'release' -I'.' -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/mkspecs/win32-g++'
-
-# Compilers
-CC = gcc
-CXX = g++
-FC = g95
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-precision-loss -fno-second-underscore
-CFLAGS = -I. -fbounds-check -mno-stack-arg-probe
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a jt9sim.exe jt9.exe jt9code.exe jt65.exe
-
-OBJS1 = pctile.o graycode.o sort.o ssort.o \
- unpackmsg.o igray.o unpackcall.o unpackgrid.o \
- grid2k.o unpacktext.o getpfx2.o packmsg.o deg2grid.o \
- packtext.o getpfx1.o packcall.o k2grid.o packgrid.o \
- nchar.o four2a.o grid2deg.o pfxdump.o f77_wisdom.o \
- symspec.o analytic.o db.o genjt9.o \
- packbits.o unpackbits.o encode232.o interleave9.o \
- entail.o fano232.o gran.o sync9.o decode9.o \
- fil3.o decoder.o grid2n.o n2grid.o timer.o \
- softsym.o getlags.o afc9.o fchisq.o twkfreq.o downsam9.o \
- peakdt9.o symspec2.o stdmsg.o morse.o azdist.o geodist.o \
- fillcom.o chkss2.o zplot9.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o
-
-libjt9.a: $(OBJS1)
- ar cr libjt9.a $(OBJS1)
- ranlib libjt9.a
-
-OBJS2 = jt9.o jt9a.o jt9b.o jt9c.o ipcomm.o sec_midn.o usleep.o
-LIBS2 = -L'c:/QtSDK/Desktop/Qt/4.7.4/mingw/lib' -lQtCore4
-jt9.exe: $(OBJS2) libjt9.a
- $(CXX) -o jt9.exe $(OBJS2) $(LIBS2) libjt9.a ../libfftw3f_win.a \
- c:/MinGW/lib/libf95.a
- mkdir -p $(EXE_DIR)
- cp jt9.exe $(EXE_DIR)
-
-OBJS3 = jt9sim.o
-jt9sim.exe: $(OBJS3) libjt9.a
- $(FC) -o jt9sim.exe $(OBJS3) libjt9.a
-
-OBJS4 = jt9code.o
-jt9code.exe: $(OBJS4) libjt9.a
- $(FC) -o jt9code.exe $(OBJS4) libjt9.a
-
-OBJS5 = jt65.o
-jt65.exe: $(OBJS5) libjt9.a
- $(FC) -o jt65.exe $(OBJS5) libjt9.a ../libfftw3f_win.a
-
-sync9.o: sync9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c sync9.f90
-
-spec9.o: spec9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c spec9.f90
-
-peakdt9.o: peakdt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c peakdt9.f90
-
-jt9sim.o: jt9sim.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c jt9sim.f90
-
-genjt9.o: genjt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c genjt9.f90
-
-redsync.o: redsync.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c redsync.f90
-
-unpackmsg.o: unpackmsg.f90
- $(FC) -c -O0 -fbounds-check -Wall -Wno-precision-loss unpackmsg.f90
-
-ipcomm.o: ipcomm.cpp
- $(CXX) -c $(INCPATH) ipcomm.cpp
-
-sec_midn.o: sec_midn.f90
- $(FC) -c -fno-second-underscore sec_midn.f90
-
-#rig_control.o: rig_control.c
-# $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include rig_control.c
-
-tstrig.o: tstrig.c
- $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include tstrig.c
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-
-.PHONY : clean
-
-clean:
- rm -f *.o libjt9.a wsjtx.exe jt9sim.exe jt9.exe jt65.exe
diff --git a/lib/Makefile.jt65 b/lib/Makefile.jt65
deleted file mode 100644
index 7409b5c1..00000000
--- a/lib/Makefile.jt65
+++ /dev/null
@@ -1,84 +0,0 @@
-# Set paths
-EXE_DIR = ../../wsjtx_exp_install_latest
-QT_DIR = /usr/include/qt5
-INCPATH = -I${QT_DIR} -I${QT_DIR}/QtCore
-
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-MKDIR = mkdir -p
-CP = cp
-RANLIB = ranlib
-RM = rm -f
-
-FFLAGS = -I/opt/local/include -O3 -funroll-loops -Wall -Wno-conversion -fno-second-underscore -DUNIX
-CFLAGS = -I. -fbounds-check -fPIE
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a jt65 jt65sim t3
-
-OBJS1 = astrosub.o astro0.o astro.o sun.o coord.o tmoonsub.o \
- fmtmsg.o deg2grid.o\
- prog_args.o options.o pctile.o graycode.o sort.o chkmsg.o \
- igray.o fftw3mod.o packjt.o\
- four2a.o grid2deg.o wisdom.o \
- symspec.o analytic.o db.o \
- encode232.o interleave9.o\
- entail.o fano232.o gran.o sync9.o \
- fil3.o decoder.o fqso_first.o \
- twkfreq.o symspec2.o shell.o sync65.o peakup.o slope.o xcor.o\
- chkss2.o zplot9.o flat1.o flat2.o \
- symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat4.o determ.o baddata.o subtract65.o
-
-libjt9.a: $(OBJS1)
- $(AR) libjt9.a $(OBJS1)
- $(RANLIB) libjt9.a
-
-OBJS7 = jt65.o
-jt65: $(OBJS7) libjt9.a libsfrsd.a
- $(FC) -o jt65 $(OBJS7) -L. -L/opt/local/lib -L./sfrsd2 -ljt9 -lsfrsd -lfftw3f_threads -lfftw3f
- $(CP) jt65 $(EXE_DIR)
-
-OBJS2 = jt65sim.o wavhdr.o
-jt65sim: $(OBJS2) libjt9.a
- $(FC) -o jt65sim $(OBJS2) -L. -L/opt/local/lib -ljt9 -lfftw3f
- $(CP) jt65sim $(EXE_DIR)
-
-OBJS3 = t3.o
-t3: $(OBJS3) libjt9.a
- $(FC) -o t3 $(OBJS3) -L. -L/opt/local/lib -ljt9
-
-OBJS6 = jt65code.o
-jt65code: $(OBJS6) libjt9.a
- $(FC) -o jt65code $(OBJS6) libjt9.a
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-.PHONY : clean
-
-clean:
- $(RM) *.o libjt9.a jt65
diff --git a/lib/Makefile.jt65_Win b/lib/Makefile.jt65_Win
deleted file mode 100644
index 08a4d22c..00000000
--- a/lib/Makefile.jt65_Win
+++ /dev/null
@@ -1,76 +0,0 @@
-# Set paths
-EXE_DIR = C:/JTSDK/wsjtx_exp/install/Debug/bin
-QT_DIR = /usr/include/qt5
-INCPATH = -I${QT_DIR} -I${QT_DIR}/QtCore
-
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-MKDIR = mkdir -p
-CP = cp
-RANLIB = ranlib
-RM = rm -f
-
-FFLAGS = -O2 -Wall -Wno-conversion -fno-second-underscore
-CFLAGS = -I. -fbounds-check -fPIE -DBIGSYM
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a jt65 jt65sim
-
-OBJS1 = astrosub.o astro0.o astro.o sun.o coord.o tmoonsub.o \
- fmtmsg.o deg2grid.o\
- prog_args.o options.o pctile.o graycode.o sort.o chkmsg.o \
- igray.o fftw3mod.o packjt.o\
- four2a.o grid2deg.o wisdom.o \
- symspec.o analytic.o db.o \
- encode232.o interleave9.o \
- entail.o fano232.o gran.o sync9.o decjt9.o \
- fil3.o decoder.o timer.o exp_decode65.o fqso_first.o \
- twkfreq.o symspec2.o shell.o sync65.o peakup.o slope.o xcor.o\
- fillcom.o chkss2.o zplot9.o flat1.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat4.o determ.o baddata.o subtract65.o
-
-libjt9.a: $(OBJS1)
- $(AR) libjt9.a $(OBJS1)
- $(RANLIB) libjt9.a
-
-OBJS7 = jt65.o
-jt65: $(OBJS7) libjt9.a libsfrsd.a
- $(FC) -o jt65 $(OBJS7) -L. -L./sfrsd2 -ljt9 -lsfrsd \
- C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS2 = jt65sim.o wavhdr.o
-jt65sim: $(OBJS2) libjt9.a
- $(FC) -o jt65sim $(OBJS2) -L. -ljt9 C:\JTSDK\fftw3f\libfftw3f-3.dll
- $(CP) jt65sim.exe $(EXE_DIR)
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-.PHONY : clean
-
-clean:
- $(RM) *.o libjt9.a jt65
diff --git a/lib/Makefile.jt65_osx b/lib/Makefile.jt65_osx
deleted file mode 100644
index c831e70f..00000000
--- a/lib/Makefile.jt65_osx
+++ /dev/null
@@ -1,74 +0,0 @@
-# Set paths
-EXE_DIR = ../../wsjtx_install
-
-CC = clang
-CXX = g++
-FC = gfortran
-AR = ar cr
-MKDIR = mkdir -p
-CP = cp
-RANLIB = ranlib
-RM = rm -f
-
-FFLAGS = -I/opt/local/include -Wall -Wno-conversion -fno-second-underscore -DUNIX
-CFLAGS = -I. -fbounds-check -fPIE
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a jt65 jt65sim
-
-OBJS1 = astrosub.o astro0.o astro.o sun.o coord.o tmoonsub.o \
- fmtmsg.o deg2grid.o\
- prog_args.o options.o pctile.o graycode.o sort.o chkmsg.o \
- igray.o fftw3mod.o packjt.o\
- four2a.o grid2deg.o wisdom.o \
- symspec.o analytic.o db.o \
- encode232.o interleave9.o\
- entail.o fano232.o sgran.o gran.o sync9.o decjt9.o \
- fil3.o decoder.o timer.o exp_decode65.o fqso_first.o\
- twkfreq.o symspec2.o shell.o sync65.o peakup.o slope.o xcor.o\
- fillcom.o chkss2.o zplot9.o flat1.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat4.o determ.o baddata.o subtract65.o
-
-libjt9.a: $(OBJS1)
- $(AR) libjt9.a $(OBJS1)
- $(RANLIB) libjt9.a
-
-OBJS7 = jt65.o
-jt65: $(OBJS7) libjt9.a libftrsd.a
- $(FC) -o jt65 $(OBJS7) -L. -L/opt/local/lib -L./ftrsd -ljt9 -lftrsd -lfftw3f_threads -lfftw3f
- $(CP) jt65 $(EXE_DIR)
-
-OBJS2 = jt65sim.o wavhdr.o
-jt65sim: $(OBJS2) libjt9.a
- $(FC) -o jt65sim $(OBJS2) -L. -L/opt/local/lib -ljt9 -lfftw3f
- $(CP) jt65sim $(EXE_DIR)
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-.PHONY : clean
-
-clean:
- $(RM) *.o libjt9.a jt65
diff --git a/lib/Makefile.jt9w b/lib/Makefile.jt9w
deleted file mode 100644
index db7bd548..00000000
--- a/lib/Makefile.jt9w
+++ /dev/null
@@ -1,58 +0,0 @@
-
-# Set paths
-EXE_DIR = ..\\..\\wsjtx_install
-QT_DIR = C:/wsjt-env/Qt5/5.2.1/mingw48_32
-FFTW3_DIR = ..
-
-INCPATH = -I${QT_DIR}/include/QtCore -I${QT_DIR}/include
-
-# Compilers
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-RANLIB = ranlib
-MKDIR = mkdir -p
-CP = cp
-RM = rm -f
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion
-CFLAGS = -O2 -I.
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: jt9w
-
-OBJS1 = jt9w.o smo.o sync9w.o pctile.o shell.o lorentzian.o fchisq0.o \
- softsym9w.o four2a.o interleave9.o jt9fano.o fano232.o packjt.o \
- deg2grid.o grid2deg.o fmtmsg.o db.o decode9w.o
-
-jt9w: $(OBJS1)
- $(FC) -o jt9w $(OBJS1) -lfftw3f
-
-OBJS2 = t1.o four2a.o db.o
-t1: $(OBJS2)
- $(FC) -o t1 $(OBJS2) -lfftw3f
-
-OBJS3 = t2.o four2a.o db.o
-t2: $(OBJS3)
- $(FC) -o t2 $(OBJS3) -lfftw3f
-
-OBJS4 = t3.o four2a.o db.o
-t3: $(OBJS4)
- $(FC) -o t3 $(OBJS4) -lfftw3f
-
-.PHONY : clean
-
-clean:
- $(RM) *.o JTMSKcode JTMSKcode.exe
diff --git a/lib/Makefile.jt9w_Win b/lib/Makefile.jt9w_Win
deleted file mode 100644
index 28dbe304..00000000
--- a/lib/Makefile.jt9w_Win
+++ /dev/null
@@ -1,58 +0,0 @@
-
-# Set paths
-EXE_DIR = ..\\..\\wsjtx_install
-QT_DIR = C:/wsjt-env/Qt5/5.2.1/mingw48_32
-FFTW3_DIR = ..
-
-INCPATH = -I${QT_DIR}/include/QtCore -I${QT_DIR}/include
-
-# Compilers
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-RANLIB = ranlib
-MKDIR = mkdir -p
-CP = cp
-RM = rm -f
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion
-CFLAGS = -O2 -I.
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: jt9w
-
-OBJS1 = jt9w.o smo.o sync9w.o pctile.o shell.o lorentzian.o fchisq0.o \
- softsym9w.o four2a.o interleave9.o jt9fano.o fano232.o packjt.o \
- deg2grid.o grid2deg.o fmtmsg.o db.o decode9w.o
-
-jt9w: $(OBJS1)
- $(FC) -o jt9w $(OBJS1) -lfftw3f
-
-OBJS2 = t1.o four2a.o db.o
-t1: $(OBJS2)
- $(FC) -o t1 $(OBJS2) -lfftw3f
-
-OBJS3 = t2.o four2a.o db.o
-t2: $(OBJS3)
- $(FC) -o t2 $(OBJS3) -lfftw3f
-
-OBJS4 = t3.o
-t3: $(OBJS4)
- $(FC) -o t3 $(OBJS4) -L. -ljt9 C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-.PHONY : clean
-
-clean:
- $(RM) *.o JTMSKcode JTMSKcode.exe
diff --git a/lib/Makefile.jtsdk b/lib/Makefile.jtsdk
deleted file mode 100644
index ce113a57..00000000
--- a/lib/Makefile.jtsdk
+++ /dev/null
@@ -1,137 +0,0 @@
-# Makefile for MinGW on Windows
-# Windows re-direct:
-# C> make > junk1 2>&1
-
-# Set paths
-EXE_DIR = ../../wsjtx_install
-
-INCPATH = -I'C:/JTSDK/Qt5/5.2.1/mingw48_32/include/QtCore' \
- -I'C:/JTSDK/Qt5/5.2.1/mingw48_32/include/'
-
-# Compilers
-CC = c:/JTSDK/Qt5/Tools/mingw48_32/bin/gcc
-FC = c:/JTSDK/Qt5/Tools/mingw48_32/bin/gfortran
-CXX = c:/JTSDK/Qt5/Tools/mingw48_32/bin/g++
-
-FFLAGS = -O3 -Wall -Wno-conversion -fno-second-underscore -DWIN32
-CFLAGS = -I. -DWIN32
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a libastro.a jt9.exe jt9code.exe jt65code.exe jt9sim.exe
-
-OBJS1 = pctile.o graycode.o sort.o chkmsg.o \
- unpackmsg.o igray.o unpackcall.o unpackgrid.o \
- grid2k.o unpacktext.o getpfx2.o packmsg.o deg2grid.o \
- packtext.o getpfx1.o packcall.o k2grid.o packgrid.o \
- nchar.o four2a.o grid2deg.o pfxdump.o wisdom.o \
- symspec.o analytic.o db.o genjt9.o flat1.o smo.o \
- packbits.o unpackbits.o encode232.o interleave9.o \
- entail.o fano232.o gran.o sync9.o jt9fano.o \
- fil3.o decoder.o grid2n.o n2grid.o timer.o \
- softsym.o getlags.o afc9.o fchisq.o twkfreq.o downsam9.o \
- peakdt9.o symspec2.o stdmsg.o morse.o azdist.o geodist.o \
- fillcom.o chkss2.o zplot9.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat4.o polfit.o determ.o baddata.o prog_args.o \
- options.o fmtmsg.o decjt9.o
-
-libjt9.a: $(OBJS1)
- ar cr libjt9.a $(OBJS1)
- ranlib libjt9.a
-
-OBJS2 = jt9.o jt9a.o jt9b.o jt9c.o ipcomm.o sec_midn.o usleep.o
-LIBS2 = -L'C:/JTSDK/Qt5/5.2.1/mingw48_32/lib' -lQt5Core
-jt9.exe: $(OBJS2) libjt9.a
- $(CXX) -o jt9.exe -static $(OBJS2) $(LIBS2) libjt9.a \
- C:\JTSDK\fftw3f\libfftw3f-3.dll -lgfortran
-# mkdir -p $(EXE_DIR)
- cp jt9.exe $(EXE_DIR)
-
-OBJS3 = jt9sim.o
-jt9sim.exe: $(OBJS3) libjt9.a
- $(FC) -o jt9sim.exe $(OBJS3) libjt9.a
-
-OBJS4 = jt9code.o
-jt9code.exe: $(OBJS4) libjt9.a
- $(FC) -o jt9code.exe $(OBJS4) libjt9.a
- cp jt9code.exe $(EXE_DIR)
-
-OBJS5 = jt65.o
-jt65.exe: $(OBJS5) libjt9.a
- $(FC) -o jt65.exe $(OBJS5) libjt9.a ../libfftw3f_win.a
-
-OBJS7 = astrosub.o astro0.o astro.o tm2.o grid2deg.o sun.o moondop.o \
- coord.o dot.o moon2.o tmoonsub.o toxyz.o geocentric.o \
- dcoord.o
-
-libastro.a: $(OBJS7)
- ar cr libastro.a $(OBJS7)
- ranlib libastro.a
-
-OBJS6 = jt65code.o
-jt65code.exe: $(OBJS6) libjt9.a
- $(FC) -o jt65code.exe $(OBJS6) libjt9.a
- cp jt65code.exe $(EXE_DIR)
-
-sync9.o: sync9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c sync9.f90
-
-spec9.o: spec9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c spec9.f90
-
-peakdt9.o: peakdt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c peakdt9.f90
-
-jt9sim.o: jt9sim.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c jt9sim.f90
-
-genjt9.o: genjt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c genjt9.f90
-
-redsync.o: redsync.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c redsync.f90
-
-unpackmsg.o: unpackmsg.f90
- $(FC) -c -O0 -fbounds-check -Wall -Wno-precision-loss unpackmsg.f90
-
-ipcomm.o: ipcomm.cpp
- $(CXX) -c $(INCPATH) ipcomm.cpp
-
-sec_midn.o: sec_midn.f90
- $(FC) -c -fno-second-underscore sec_midn.f90
-
-#rig_control.o: rig_control.c
-# $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include rig_control.c
-
-tstrig.o: tstrig.c
- $(CC) -c -Wall -I..\..\..\hamlib-1.2.15.3\include tstrig.c
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-
-.PHONY : clean
-
-clean:
- rm -f *.o libjt9.a wsjtx.exe jt9sim.exe jt9.exe jt65.exe
diff --git a/lib/Makefile.linux b/lib/Makefile.linux
deleted file mode 100644
index 14bc077a..00000000
--- a/lib/Makefile.linux
+++ /dev/null
@@ -1,115 +0,0 @@
-# Set paths
-EXE_DIR = ../../wsjtx_install
-QT_DIR = /usr/include/qt5
-INCPATH = -I${QT_DIR} -I${QT_DIR}/QtCore
-
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-MKDIR = mkdir -p
-CP = cp
-RANLIB = ranlib
-RM = rm -f
-
-FFLAGS = -O3 -funroll-loops -Wall -Wno-conversion -fno-second-underscore -DUNIX
-CFLAGS = -I. -fbounds-check -fPIE
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-all: libjt9.a jt9sim jt9 jt9code jt65code
-
-OBJS1 = astrosub.o astro0.o astro.o tm2.o sun.o moondop.o coord.o tmoonsub.o \
- fmtmsg.o geocentric.o moon2.o toxyz.o dot.o dcoord.o \
- prog_args.o options.o pctile.o graycode.o sort.o chkmsg.o \
- unpackmsg.o igray.o unpackcall.o unpackgrid.o \
- grid2k.o unpacktext.o getpfx2.o packmsg.o deg2grid.o \
- packtext.o getpfx1.o packcall.o k2grid.o packgrid.o \
- nchar.o four2a.o grid2deg.o pfxdump.o wisdom.o \
- symspec.o analytic.o db.o genjt9.o jt9fano.o \
- packbits.o unpackbits.o encode232.o interleave9.o \
- entail.o fano232.o gran.o sync9.o decjt9.o \
- fil3.o decoder.o grid2n.o n2grid.o timer.o \
- softsym.o peakdt9.o getlags.o afc9.o fchisq.o \
- twkfreq.o downsam9.o symspec2.o ipcomm.o sleep_msec.o \
- stdmsg.o sec_midn.o usleep.o azdist.o geodist.o morse.o \
- fillcom.o chkss2.o zplot9.o flat1.o flat2.o \
- jt65a.o symspec65.o flat65.o ccf65.o decode65a.o \
- filbig.o fil6521.o afc65b.o decode65b.o setup65.o \
- extract.o fchisq65.o demod64a.o chkhist.o interleave63.o ccf2.o \
- move.o indexx.o graycode65.o twkfreq65.o smo.o smo121.o \
- wrapkarn.o init_rs.o encode_rs.o decode_rs.o gen65.o fil4.o \
- flat4.o polfit.o determ.o baddata.o
-
-libjt9.a: $(OBJS1)
- $(AR) libjt9.a $(OBJS1)
- $(RANLIB) libjt9.a
-
-OBJS2 = jt9.o jt9a.o jt9b.o jt9c.o
-
-jt9: $(OBJS2) libjt9.a
- $(CXX) -o jt9 $(OBJS2) -L. -ljt9 -lQt5Core -lfftw3f_threads -lfftw3f `$(FC) -print-file-name=libgfortran.so`
- $(MKDIR) -p $(EXE_DIR)
- $(CP) jt9 $(EXE_DIR)
-
-OBJS3 = jt9sim.o
-jt9sim: $(OBJS3) libjt9.a
- $(FC) -o jt9sim $(OBJS3) -L. -ljt9
-
-OBJS4 = jt9code.o
-jt9code: $(OBJS4) libjt9.a
- $(FC) -o jt9code $(OBJS4) -L. -ljt9
- $(CP) jt9code $(EXE_DIR)
-
-OBJS6 = jt65code.o
-jt65code: $(OBJS6) libjt9.a
- $(FC) -o jt65code $(OBJS6) libjt9.a
- $(CP) jt65code $(EXE_DIR)
-
-sync9.o: sync9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c sync9.f90
-
-peakdf9.o: peakdf9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c peakdf9.f90
-
-peakdt9.o: peakdt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c peakdt9.f90
-
-jt9sim.o: jt9sim.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c jt9sim.f90
-
-genjt9.o: genjt9.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c genjt9.f90
-
-redsync.o: redsync.f90 jt9sync.f90
- $(FC) $(FFLAGS) -c redsync.f90
-
-ipcomm.o: ipcomm.cpp
- $(CXX) -c $(INCPATH) -fPIE ipcomm.cpp
-
-sec_midn.o: sec_midn.f90
- $(FC) -c -fno-second-underscore sec_midn.f90
-
-init_rs.o: init_rs.c
- $(CC) -c -DBIGSYM=1 -o init_rs.o init_rs.c
-
-encode_rs.o: encode_rs.c
- $(CC) -c -DBIGSYM=1 -o encode_rs.o encode_rs.c
-
-decode_rs.o: decode_rs.c
- $(CC) -c -DBIGSYM=1 -o decode_rs.o decode_rs.c
-
-.PHONY : clean
-
-clean:
- $(RM) *.o libjt9.a wsjtx jt9sim jt9 jt9code
diff --git a/lib/Makefile.msk b/lib/Makefile.msk
deleted file mode 100644
index 333b36ca..00000000
--- a/lib/Makefile.msk
+++ /dev/null
@@ -1,71 +0,0 @@
-
-# Set paths
-EXE_DIR = ..\\..\\wsjtx_install
-QT_DIR = C:/wsjt-env/Qt5/5.2.1/mingw48_32
-FFTW3_DIR = ..
-
-INCPATH = -I${QT_DIR}/include/QtCore -I${QT_DIR}/include
-
-# Compilers
-CC = gcc
-CXX = g++
-FC = gfortran
-AR = ar cr
-RANLIB = ranlib
-MKDIR = mkdir -p
-CP = cp
-RM = rm -f
-
-FFLAGS = -O2 -fbounds-check -Wall -Wno-conversion
-CFLAGS = -O2 -I.
-
-# Default rules
-%.o: %.c
- ${CC} ${CFLAGS} -c $<
-%.o: %.f
- ${FC} ${FFLAGS} -c $<
-%.o: %.F
- ${FC} ${FFLAGS} -c $<
-%.o: %.f90
- ${FC} ${FFLAGS} -c $<
-%.o: %.F90
- ${FC} ${FFLAGS} -c $<
-
-#all: jt9code JTMSKcode
-all: jtmsk JTMSKcode
-
-OBJS4 = jt9code.o packjt.o fmtmsg.o gen9.o deg2grid.o grid2deg.o \
- entail.o encode232.o interleave9.o graycode.o igray.o
-jt9code: $(OBJS4)
- $(FC) -o jt9code $(OBJS4)
-
-OBJS5 = JTMSKcode.o packjt.o fmtmsg.o genmsk.o deg2grid.o grid2deg.o \
- entail.o nhash.o tab.o vit213.o
-JTMSKcode: $(OBJS5)
- $(FC) -o JTMSKcode $(OBJS5)
-
-OBJS6 = jtmsk.o jtmsk.o analytic.o four2a.o db.o mskdf.o pctile.o \
- sort.o tweak1.o syncmsk.o genmsk.o packjt.o fmtmsg.o indexx.o \
- deg2grid.o grid2deg.o entail.o nhash.o tab.o vit213.o
-jtmsk: $(OBJS6)
- $(FC) -o jtmsk $(OBJS6) -lfftw3f
-
-OBJS1 = t1.o four2a.o db.o
-t1: $(OBJS1)
- $(FC) -o t1 $(OBJS1) -lfftw3f
-
-OBJS2 = t2.o four2a.o db.o
-t2: $(OBJS2)
- $(FC) -o t2 $(OBJS2) -lfftw3f
-
-OBJS6 = t6.o four2a.o db.o
-t6: $(OBJS6)
- $(FC) -o t6 $(OBJS6) -lfftw3f
-
-nhash.o: wsprd/nhash.h wsprd/nhash.c
- $(CC) -c -O2 wsprd/nhash.c
-
-.PHONY : clean
-
-clean:
- $(RM) *.o JTMSKcode JTMSKcode.exe
diff --git a/lib/addit.f90 b/lib/addit.f90
index 33ed5a28..28f3cf64 100644
--- a/lib/addit.f90
+++ b/lib/addit.f90
@@ -11,34 +11,26 @@ subroutine addit(itone,nfsample,nsym,nsps,ifreq,sig,dat)
twopi=8.d0*atan(1.d0)
dphi=0.
- iters=1
- if(nsym.eq.79) iters=2 !FT8
- if(nsym.eq.103) iters=5 !FT4
-
- do iter=1,iters
- f=ifreq
- phi=0.
- ntot=nsym*tsym/dt
- k=12000 !Start audio at t = 1.0 s
- t=0.
- if(nsym.eq.79) k=12000 + (iter-1)*12000*30 !Special case for FT8
- if(nsym.eq.103) k=12000 + (iter-1)*12000*10 !Special case for FT4
- isym0=-1
- do i=1,ntot
- t=t+dt
- isym=nint(t/tsym) + 1
- if(isym.gt.nsym) exit
- if(isym.ne.isym0) then
- freq=f + itone(isym)*baud
- dphi=twopi*freq*dt
- isym0=isym
- endif
- phi=phi + dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- k=k+1
- dat(k)=dat(k) + sig*sin(xphi)
- enddo
+ f=ifreq
+ phi=0.
+ ntot=nsym*tsym/dt
+ k=12000 !Start audio at t = 1.0 s
+ t=0.
+ isym0=-1
+ do i=1,ntot
+ t=t+dt
+ isym=nint(t/tsym) + 1
+ if(isym.gt.nsym) exit
+ if(isym.ne.isym0) then
+ freq=f + itone(isym)*baud
+ dphi=twopi*freq*dt
+ isym0=isym
+ endif
+ phi=phi + dphi
+ if(phi.gt.twopi) phi=phi-twopi
+ xphi=phi
+ k=k+1
+ dat(k)=dat(k) + sig*sin(xphi)
enddo
return
diff --git a/lib/afc65b.f90 b/lib/afc65b.f90
index 9599b689..18bbb691 100644
--- a/lib/afc65b.f90
+++ b/lib/afc65b.f90
@@ -6,6 +6,8 @@ subroutine afc65b(cx,npts,fsample,nflip,mode65,a,ccfbest,dtbest)
real a(5),deltaa(5)
a=0.
+ a1=0.
+ a2=0.
i2=8*mode65
i1=-i2
j2=8*mode65
@@ -27,10 +29,10 @@ subroutine afc65b(cx,npts,fsample,nflip,mode65,a,ccfbest,dtbest)
!3081 format(7i4,5f8.2)
enddo
enddo
- i1=a1-istep
- i2=a1+istep
- j1=a2-istep
- j2=a2+istep
+ i1=int(a1)-istep
+ i2=int(a1)+istep
+ j1=int(a2)-istep
+ j2=int(a2)+istep
istep=1
enddo
diff --git a/lib/allsim.f90 b/lib/allsim.f90
index 59d3fa26..3735a449 100644
--- a/lib/allsim.f90
+++ b/lib/allsim.f90
@@ -2,83 +2,114 @@ program allsim
! Generate simulated data for WSJT-X modes: JT4, JT9, JT65, FT8, FT4, QRA64,
! and WSPR. Also unmodulated carrier and 20 WPM CW.
-
use wavhdr
use packjt
parameter (NMAX=60*12000)
- type(hdr) h
+ type(hdr) h !Header for the .wav file
integer*2 iwave(NMAX) !Generated waveform (no noise)
integer itone(206) !Channel symbols (values 0-8)
- integer icw(250)
- integer*1 msgbits(87)
- logical*1 bcontest
- real*4 dat(NMAX)
- character message*22,msgsent*22,arg*8,mygrid*6
+ integer icw(250) !Encoded CW message bits
+ integer*1 msgbits(77) !Encoded message bits for FT8, FT4
+ real dat(NMAX) !Audio waveform
+ complex cwave(NMAX)
+ real wave(NMAX)
+ character message*22,msgsent*22,arg*8
character*37 msg37,msgsent37
nargs=iargc()
- if(nargs.ne.1) then
- print*,'Usage: allsim <snr>'
+ if(nargs.ne.1 .and. nargs.ne.2) then
+ print*,'Usage: allsim snr [isig]'
+ print*,'Examples: allsim -10 #Include all signal types'
+ print*,' allsim -10 6 #Include FT8 only'
+ print*,'isig order: 1 2 3 4 5 6 7 8 9'
+ print*,' Carrier CW WSPR JT9 JT4 FT8 FT4 QRA64 JT65'
go to 999
endif
call getarg(1,arg)
read(arg,*) snrdb !S/N in dB (2500 hz reference BW)
+ isig=0
+ if(nargs.eq.2) then
+ call getarg(2,arg)
+ read(arg,*) isig
+ endif
message='CQ KA2ABC FN20'
- mygrid='FN20 '
- bcontest=.false.
+ msg37=message//' '
rmsdb=25.
rms=10.0**(0.05*rmsdb)
sig=10.0**(0.05*snrdb)
- npts=NMAX
call init_random_seed() !Seed Fortran RANDOM_NUMBER generator
call sgran() !Seed C rand generator (used in gran)
- h=default_header(12000,npts)
+ h=default_header(12000,NMAX)
open(10,file='000000_0000.wav',access='stream',status='unknown')
- do i=1,npts !Generate gaussian noise
+ do i=1,NMAX !Generate gaussian noise
dat(i)=gran()
enddo
itone=0
- call addit(itone,12000,85,6912,400,sig,dat) !Unmodulated carrier
+ if(isig.eq.0 .or. isig.eq.1) then
+ call addit(itone,12000,85,6912,400,sig,dat) !Unmodulated carrier
+ endif
- call morse('CQ CQ DE KA2ABC KA2ABC',icw,ncw)
-! print*,ncw
-! write(*,3001) icw(1:ncw)
-!3001 format(50i1)
- call addcw(icw,ncw,600,sig,dat) !CW
+ if(isig.eq.0 .or. isig.eq.2) then
+ call morse('CQ CQ DE KA2ABC KA2ABC',icw,ncw)
+ call addcw(icw,ncw,600,sig,dat) !CW
+ endif
- call genwspr(message,msgsent,itone)
- call addit(itone,12000,86,8192,800,sig,dat) !WSPR (only 59 s of data)
+ if(isig.eq.0 .or. isig.eq.3) then
+ call genwspr(message,msgsent,itone)
+ call addit(itone,12000,86,8192,800,sig,dat) !WSPR (only 59 s of data)
+ endif
- call gen9(message,0,msgsent,itone,itype)
- call addit(itone,12000,85,6912,1000,sig,dat) !JT9
+ if(isig.eq.0 .or. isig.eq.4) then
+ call gen9(message,0,msgsent,itone,itype)
+ call addit(itone,12000,85,6912,1000,sig,dat) !JT9
+ endif
- call gen4(message,0,msgsent,itone,itype)
- call addit(itone,11025,206,2520,1200,sig,dat) !JT4
+ if(isig.eq.0 .or. isig.eq.5) then
+ call gen4(message,0,msgsent,itone,itype)
+ call addit(itone,11025,206,2520,1200,sig,dat) !JT4
+ endif
- i3=-1
- n3=-1
- call genft8(message,i3,n3,msgsent,msgbits,itone)
- call addit(itone,12000,79,1920,1400,sig,dat) !FT8
+ if(isig.eq.0 .or. isig.eq.6) then
+ call genft8(msg37,i3,n3,msgsent37,msgbits,itone) !FT8
+ nwave=79*1920
+ call gen_ft8wave(itone,79,1920,2.0,12000.0,1400.0,cwave,wave,0,nwave)
+ dat(6001:6000+nwave)=dat(6001:6000+nwave) + sig*wave(1:nwave)
+ k=30*12000
+ dat(6001+k:6000+nwave+k)=dat(6001+k:6000+nwave+k) + sig*wave(1:nwave)
+ endif
- msg37=message//' '
- call genft4(msg37,0,msgsent37,itone)
- call addit(itone,12000,103,512,1600,sig,dat) !FT4
+ if(isig.eq.0 .or. isig.eq.7) then
+ call genft4(msg37,0,msgsent37,msgbits,itone) !FT4
+ nwave=105*576
+ call gen_ft4wave(itone,103,576,12000.0,1600.0,cwave,wave,0,nwave)
+ dat(6001:6000+nwave)=dat(6001:6000+nwave) + sig*wave(1:nwave)
+ k=15*12000
+ dat(6001+k:6000+nwave+k)=dat(6001+k:6000+nwave+k) + sig*wave(1:nwave)
+ k=30*12000
+ dat(6001+k:6000+nwave+k)=dat(6001+k:6000+nwave+k) + sig*wave(1:nwave)
+ k=45*12000
+ dat(6001+k:6000+nwave+k)=dat(6001+k:6000+nwave+k) + sig*wave(1:nwave)
+
+ endif
- call genqra64(message,0,msgsent,itone,itype)
- call addit(itone,12000,84,6912,1800,sig,dat) !QRA64
+ if(isig.eq.0 .or. isig.eq.8) then
+ call genqra64(message,0,msgsent,itone,itype)
+ call addit(itone,12000,84,6912,1800,sig,dat) !QRA64
+ endif
- call gen65(message,0,msgsent,itone,itype)
- call addit(itone,11025,126,4096,2000,sig,dat) !JT65
+ if(isig.eq.0 .or. isig.eq.9) then
+ call gen65(message,0,msgsent,itone,itype)
+ call addit(itone,11025,126,4096,2000,sig,dat) !JT65
+ endif
- iwave(1:npts)=nint(rms*dat(1:npts))
-
- write(10) h,iwave(1:npts)
+ iwave=nint(rms*dat)
+ write(10) h,iwave
close(10)
999 end program allsim
diff --git a/lib/bpdecode128_90.f90 b/lib/bpdecode128_90.f90
index c48ba1fa..9e018dc7 100644
--- a/lib/bpdecode128_90.f90
+++ b/lib/bpdecode128_90.f90
@@ -33,6 +33,7 @@ subroutine bpdecode128_90(llr,apmask,maxiterations,message77,cw,nharderror,iter)
enddo
ncnt=0
+ nclast=0
do iter=0,maxiterations
diff --git a/lib/decode65a.f90 b/lib/decode65a.f90
index c41136a5..ec9fbd31 100644
--- a/lib/decode65a.f90
+++ b/lib/decode65a.f90
@@ -1,7 +1,6 @@
subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, &
naggressive,ndepth,ntol,mycall,hiscall,hisgrid,nQSOProgress, &
- ljt65apon, nexp_decode, &
- bVHF,sync2,a,dt,nft,nspecial,qual,nhist,nsmo,decoded)
+ ljt65apon,bVHF,sync2,a,dt,nft,nspecial,qual,nhist,nsmo,decoded)
! Apply AFC corrections to a candidate JT65 signal, then decode it.
@@ -94,6 +93,7 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, &
call timer('dec65b ',0)
qualbest=0.
+ nftbest=0
qual0=-1.e30
minsmo=0
maxsmo=0
@@ -125,10 +125,8 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, &
enddo
nadd=ismo !### ??? ###
call decode65b(s2,nflip,nadd,mode65,ntrials,naggressive,ndepth, &
- mycall,hiscall,hisgrid,nQSOProgress,ljt65apon,nexp_decode, &
- nqd,nft,qual, &
+ mycall,hiscall,hisgrid,nQSOProgress,ljt65apon,nqd,nft,qual, &
nhist,decoded)
-
if(nft.eq.1) then
nsmo=ismo
param(9)=nsmo
@@ -140,18 +138,20 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, &
qualbest=qual
nnbest=nn
nsmobest=ismo
+ nftbest=nft
endif
endif
if(qual.lt.qual0) exit
qual0=qual
enddo
- if(nft.eq.2) then
+ if(nftbest.eq.2) then
decoded=decoded_best
qual=qualbest
nsmo=nsmobest
param(9)=nsmo
nn=nnbest
+ nft=nftbest
endif
call timer('dec65b ',1)
diff --git a/lib/decode65b.f90 b/lib/decode65b.f90
index 215b6bac..0ff169bc 100644
--- a/lib/decode65b.f90
+++ b/lib/decode65b.f90
@@ -1,6 +1,5 @@
subroutine decode65b(s2,nflip,nadd,mode65,ntrials,naggressive,ndepth, &
- mycall,hiscall,hisgrid,nQSOProgress,ljt65apon,nexp_decode,nqd, &
- nft,qual, &
+ mycall,hiscall,hisgrid,nQSOProgress,ljt65apon,nqd,nft,qual, &
nhist,decoded)
use jt65_mod
@@ -21,8 +20,8 @@ subroutine decode65b(s2,nflip,nadd,mode65,ntrials,naggressive,ndepth, &
enddo
call extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip,mycall, &
- hiscall,hisgrid,nQSOProgress,ljt65apon,nexp_decode,ncount, &
- nhist,decoded,ltext,nft,qual)
+ hiscall,hisgrid,nQSOProgress,ljt65apon,ncount, &
+ nhist,decoded,ltext,nft,qual)
! Suppress "birdie messages" and other garbage decodes:
if(decoded(1:7).eq.'000AAA ') ncount=-1
diff --git a/lib/decoder.f90 b/lib/decoder.f90
index 8abdcb75..c7b3585b 100644
--- a/lib/decoder.f90
+++ b/lib/decoder.f90
@@ -1,6 +1,6 @@
subroutine multimode_decoder(ss,id2,params,nfsample)
- !$ use omp_lib
+!$ use omp_lib
use prog_args
use timer_module, only: timer
use jt4_decode
@@ -40,6 +40,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
character(len=20) :: datetime
character(len=12) :: mycall, hiscall
character(len=6) :: mygrid, hisgrid
+ character*60 line
+ data ndec8/0/
save
type(counting_jt4_decoder) :: my_jt4
type(counting_jt65_decoder) :: my_jt65
@@ -60,7 +62,23 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
my_jt9%decoded = 0
my_ft8%decoded = 0
my_ft4%decoded = 0
+
+! For testing only: return Rx messages stored in a file as decodes
+ inquire(file='rx_messages.txt',exist=ex)
+ if(ex) then
+ if(params%nzhsym.eq.41) then
+ open(39,file='rx_messages.txt',status='old')
+ do i=1,9999
+ read(39,'(a60)',end=5) line
+ if(line(1:1).eq.' ' .or. line(1:1).eq.'-') go to 800
+ write(*,'(a)') trim(line)
+ enddo
+5 close(39)
+ endif
+ go to 800
+ endif
+ ncontest=iand(params%nexp_decode,7)
single_decode=iand(params%nexp_decode,32).ne.0
bVHF=iand(params%nexp_decode,64).ne.0
if(mod(params%nranera,2).eq.0) ntrials=10**(params%nranera/2)
@@ -85,7 +103,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
if(params%nmode.eq.8) then
! We're in FT8 mode
- if(ncontest.eq.5) then
+ if(ncontest.eq.6) then
! Fox mode: initialize and open houndcallers.txt
inquire(file=trim(temp_dir)//'/houndcallers.txt',exist=ex)
if(.not.ex) then
@@ -102,12 +120,16 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
call timer('decft8 ',0)
newdat=params%newdat
- ncontest=iand(params%nexp_decode,7)
+ if(params%emedelay.ne.0.0) then
+ id2(1:156000)=id2(24001:180000) ! Drop the first 2 seconds of data
+ id2(156001:180000)=0
+ endif
call my_ft8%decode(ft8_decoded,id2,params%nQSOProgress,params%nfqso, &
params%nftx,newdat,params%nutc,params%nfa,params%nfb, &
- params%ndepth,ncontest,logical(params%nagain), &
- logical(params%lft8apon),logical(params%lapcqonly), &
- params%napwid,mycall,hiscall,hisgrid)
+ params%nzhsym,params%ndepth,params%emedelay,ncontest, &
+ logical(params%nagain),logical(params%lft8apon), &
+ logical(params%lapcqonly),params%napwid,mycall,hiscall, &
+ params%ndiskdat)
call timer('decft8 ',1)
if(nfox.gt.0) then
n30min=minval(n30fox(1:nfox))
@@ -115,7 +137,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
endif
j=0
- if(ncontest.eq.5) then
+ if(ncontest.eq.6) then
! Fox mode: save decoded Hound calls for possible selection by FoxOp
rewind 19
if(nfox.eq.0) then
@@ -133,7 +155,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
n30fox(j)=n
m=n30max-n
if(len(trim(g2fox(j))).eq.4) then
- call azdist(mygrid,g2fox(j)//' ',0.d0,nAz,nEl,nDmiles, &
+ call azdist(mygrid,g2fox(j)//' ',0.d0,nAz,nEl,nDmiles, &
nDkm,nHotAz,nHotABetter)
else
nDkm=9999
@@ -152,7 +174,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
if(params%nmode.eq.5) then
call timer('decft4 ',0)
call my_ft4%decode(ft4_decoded,id2,params%nQSOProgress,params%nfqso, &
- params%nutc,params%nfa,params%nfb,params%ndepth, &
+ params%nfa,params%nfb,params%ndepth, &
logical(params%lapcqonly),ncontest,mycall,hiscall)
call timer('decft4 ',1)
go to 800
@@ -194,6 +216,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
if(params%newdat) then
if(nfsample.eq.12000) call wav11(id2,jz,dd)
if(nfsample.eq.11025) dd(1:jz)=id2(1:jz)
+ else
+ jz=52*11025
endif
call my_jt4%decode(jt4_decoded,dd,jz,params%nutc,params%nfqso, &
params%ntol,params%emedelay,params%dttol,logical(params%nagain), &
@@ -276,11 +300,19 @@ subroutine multimode_decoder(ss,id2,params,nfsample)
! JT65 is not yet producing info for nsynced, ndecoded.
800 ndecoded = my_jt4%decoded + my_jt65%decoded + my_jt9%decoded + &
my_ft8%decoded + my_ft4%decoded
- write(*,1010) nsynced,ndecoded
+ if(params%nmode.eq.8 .and. params%nzhsym.eq.41) ndec41=ndecoded
+ if(params%nmode.eq.8 .and. params%nzhsym.eq.47) ndec47=ndecoded
+ if(params%nmode.eq.8 .and. params%nzhsym.eq.50) then
+ ndecoded=ndec41+ndec47+ndecoded
+ endif
+ if(params%nmode.ne.8 .or. params%nzhsym.eq.50 .or. &
+ .not.params%ndiskdat) then
+ write(*,1010) nsynced,ndecoded
1010 format('<DecodeFinished>',2i4)
- call flush(6)
+ call flush(6)
+ endif
close(13)
- if(ncontest.eq.5) close(19)
+ if(ncontest.eq.6) close(19)
if(params%nmode.eq.4 .or. params%nmode.eq.65) close(14)
return
@@ -310,16 +342,19 @@ contains
if (have_sync) then
decoded=decoded0
cflags=' '
- if(decoded.ne.' ') cflags='f '
- if(is_deep) then
- cflags(1:2)='d1'
- write(cflags(3:3),'(i1)') min(int(qual),9)
- if(qual.ge.10.0) cflags(3:3)='*'
- if(qual.lt.3.0) decoded(22:22)='?'
- endif
- if(is_average) then
- write(cflags(2:2),'(i1)') min(ave,9)
- if(ave.ge.10) cflags(2:2)='*'
+ if(decoded.ne.' ') then
+ cflags='f '
+ if(is_deep) then
+ cflags='d '
+ write(cflags(2:2),'(i1)') min(int(qual),9)
+ if(qual.ge.10.0) cflags(2:2)='*'
+ if(qual.lt.3.0) decoded(22:22)='?'
+ endif
+ if(is_average) then
+ write(cflags(3:3),'(i1)') min(ave,9)
+ if(ave.ge.10) cflags(3:3)='*'
+ if(cflags(1:1).eq.'f') cflags=cflags(1:1)//cflags(3:3)//' '
+ endif
endif
write(*,1000) params%nutc,snr,dt,freq,sync,decoded,cflags
1000 format(i4.4,i4,f5.1,i5,1x,'$',a1,1x,a22,1x,a3)
@@ -398,7 +433,9 @@ contains
1011 format(i4.4,i4,i5,f6.2,f8.0,i4,3x,a22,' QRA64',i3)
go to 100
endif
-
+
+! write(*,3001) ft,nsum,qual,sync,bVHF
+!3001 format('a',3i3,f5.1,L3)
if(ft.eq.0 .and. minsync.ge.0 .and. int(sync).lt.minsync) then
write(*,1010) params%nutc,snr,dt,freq
else
@@ -406,18 +443,19 @@ contains
if(bVHF .and. ft.gt.0) then
cflags='f '
if(is_deep) then
- cflags(1:2)='d1'
- write(cflags(3:3),'(i1)') min(qual,9)
- if(qual.ge.10) cflags(3:3)='*'
+ cflags='d '
+ write(cflags(2:2),'(i1)') min(qual,9)
+ if(qual.ge.10) cflags(2:2)='*'
if(qual.lt.3) decoded(22:22)='?'
endif
if(is_average) then
- write(cflags(2:2),'(i1)') min(nsum,9)
- if(nsum.ge.10) cflags(2:2)='*'
+ write(cflags(3:3),'(i1)') min(nsum,9)
+ if(nsum.ge.10) cflags(3:3)='*'
endif
nap=ishft(ft,-2)
if(nap.ne.0) then
- write(cflags(1:3),'(a1,i1)') 'a',nap
+ if(nsum.lt.2) write(cflags(1:3),'(a1,i1," ")') 'a',nap
+ if(nsum.ge.2) write(cflags(1:3),'(a1,2i1)') 'a',nap,min(nsum,9)
endif
endif
csync='# '
@@ -436,6 +474,12 @@ contains
endif
endif
endif
+ n=len(trim(decoded))
+ if(n.eq.2 .or. n.eq.3) csync='# '
+ if(cflags(1:1).eq.'f') then
+ cflags(2:2)=cflags(3:3)
+ cflags(3:3)=' '
+ endif
write(*,1010) params%nutc,snr,dt,freq,csync,decoded,cflags
1010 format(i4.4,i4,f5.1,i5,1x,a2,1x,a22,1x,a3)
endif
@@ -534,7 +578,7 @@ contains
write(13,1002) params%nutc,nint(sync),snr,dt,freq,0,decoded0
1002 format(i6.6,i4,i5,f6.1,f8.0,i4,3x,a37,' FT8')
- if(ncontest.eq.5) then
+ if(ncontest.eq.6) then
i1=index(decoded0,' ')
i2=i1 + index(decoded0(i1+1:),' ')
i3=i2 + index(decoded0(i2+1:),' ')
@@ -588,9 +632,7 @@ contains
real, intent(in) :: dt
real, intent(in) :: freq
character(len=37), intent(in) :: decoded
- character c1*12,c2*12,g2*4,w*4
- integer i0,i1,i2,i3,i4,i5,n30,nwrap
- integer, intent(in) :: nap
+ integer, intent(in) :: nap
real, intent(in) :: qual
character*2 annot
character*37 decoded0
diff --git a/lib/extract.f90 b/lib/extract.f90
index d1a483d3..234f5137 100644
--- a/lib/extract.f90
+++ b/lib/extract.f90
@@ -1,7 +1,6 @@
subroutine extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip, &
mycall_12,hiscall_12,hisgrid,nQSOProgress,ljt65apon, &
- nexp_decode,ncount, &
- nhist,decoded,ltext,nft,qual)
+ ncount,nhist,decoded,ltext,nft,qual)
! Input:
! s3 64-point spectra for each of 63 data symbols
@@ -180,7 +179,6 @@ subroutine extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip, &
if(nft.gt.0) exit
enddo
-!write(*,*) nft
if(nft.eq.0 .and. iand(ndepth,32).eq.32) then
qmin=2.0 - 0.1*naggressive
call timer('hint65 ',0)
@@ -209,7 +207,7 @@ subroutine extract(s3,nadd,mode65,ntrials,naggressive,ndepth,nflip, &
tmp(i)=correct(64-i)
enddo
correct(1:63)=tmp(1:63)
- call interleave63(correct,63,1)
+ call interleave63(correct,1)
call graycode65(correct,63,1)
call unpackmsg(dat4,decoded) !Unpack the user message
ncount=0
diff --git a/lib/fano232.f90 b/lib/fano232.f90
index dc3c639f..8888624c 100644
--- a/lib/fano232.f90
+++ b/lib/fano232.f90
@@ -6,7 +6,7 @@ subroutine fano232(symbol,nbits,mettab,ndelta,maxcycles,dat, &
! written by Phil Karn, KA9Q.
parameter (MAXBITS=103)
- parameter (MAXBYTES=(MAXBITS+7)/8)
+ parameter (MAXBYTES=13) !(MAXBITS+7)/8
integer*1 symbol(0:2*MAXBITS-1) !Soft symbols (as unsigned i*1)
integer*1 dat(MAXBYTES) !Decoded user data, 8 bits per byte
integer mettab(-128:127,0:1) !Metric table
@@ -126,7 +126,7 @@ subroutine fano232(symbol,nbits,mettab,ndelta,maxcycles,dat, &
np=7
do j=1,nbytes-1
i4a=nstate(np)
- dat(j)=i4a
+ dat(j)=int(i4a,1)
np=np+8
enddo
dat(nbytes)=0
diff --git a/lib/fast_decode.f90 b/lib/fast_decode.f90
index c3cadb6a..d32314b9 100644
--- a/lib/fast_decode.f90
+++ b/lib/fast_decode.f90
@@ -87,11 +87,11 @@ subroutine fast_decode(id2,narg,trperiod,line,mycall_12, &
jz=ib-ia+1
line(1:100)(1:1)=char(0)
if(npick.eq.2) then
- call iscat(cdat2(ia),jz,3,40,t2,pick,cfile6,minsync,ntol,NFreeze, &
- MouseDF,mousebutton,mode4,nafc,ndebug,psavg,nmax,nlines,line)
+ call iscat(cdat2(ia),jz,3,40,t2,pick,cfile6,minsync,ntol, &
+ mousebutton,mode4,nafc,ndebug,psavg,nmax,nlines,line)
else
- call iscat(cdat(ia),jz,3,40,t2,pick,cfile6,minsync,ntol,NFreeze, &
- MouseDF,mousebutton,mode4,nafc,ndebug,psavg,maxlines,nlines,line)
+ call iscat(cdat(ia),jz,3,40,t2,pick,cfile6,minsync,ntol, &
+ mousebutton,mode4,nafc,ndebug,psavg,maxlines,nlines,line)
endif
900 return
diff --git a/lib/fil3.f90 b/lib/fil3.f90
index 0d660610..4a90c779 100644
--- a/lib/fil3.f90
+++ b/lib/fil3.f90
@@ -18,7 +18,7 @@ subroutine fil3(x1,n1,c2,n2)
! of 1500 Hz output samples.
parameter (NTAPS=113)
- parameter (NH=NTAPS/2)
+ parameter (NH=56) !NTAPS/2
parameter (NDOWN=8) !Downsample ratio = 1/8
real x1(n1)
complex z
diff --git a/lib/fil3c.f90 b/lib/fil3c.f90
index 6000253f..0b4a85f1 100644
--- a/lib/fil3c.f90
+++ b/lib/fil3c.f90
@@ -15,7 +15,7 @@ subroutine fil3c(c1,n1,c2,n2)
! of 1500 Hz output samples.
parameter (NTAPS=113)
- parameter (NH=NTAPS/2)
+ parameter (NH=56) !NTAPS/2
parameter (NDOWN=8) !Downsample ratio = 1/8
complex c1(n1)
complex c2(n1/NDOWN)
diff --git a/lib/fil6521.f90 b/lib/fil6521.f90
index ef4b5435..0bd7ae72 100644
--- a/lib/fil6521.f90
+++ b/lib/fil6521.f90
@@ -13,7 +13,7 @@ subroutine fil6521(c1,n1,c2,n2)
! fout (Hz) 344.531 Output sample rate
parameter (NTAPS=21)
- parameter (NH=NTAPS/2)
+ parameter (NH=10) !NTAPS/2
parameter (NDOWN=4) !Downsample ratio = 1/4
complex c1(n1)
complex c2(n1/NDOWN)
diff --git a/lib/filbig.f90 b/lib/filbig.f90
index 26a5edf5..b1d026f2 100644
--- a/lib/filbig.f90
+++ b/lib/filbig.f90
@@ -8,7 +8,7 @@ subroutine filbig(dd,npts,f0,newdat,c4a,n4,sq0)
use timer_module, only: timer
parameter (NSZ=3413)
- parameter (NFFT1=672000,NFFT2=77175)
+ parameter (NFFT1=672000,NFFT2=77175,NH2=38587)
parameter (NZ2=1000)
real*4 dd(npts) !Input data
real*4 rca(NFFT1)
@@ -59,7 +59,7 @@ subroutine filbig(dd,npts,f0,newdat,c4a,n4,sq0)
enddo
call fftwf_execute_dft(plan3,cfilt,cfilt)
- base=real(cfilt(nfft2/2+1))
+ base=real(cfilt(NH2+1))
do i=1,nfft2
rfilt(i)=real(cfilt(i))-base
enddo
@@ -93,8 +93,7 @@ subroutine filbig(dd,npts,f0,newdat,c4a,n4,sq0)
! i0 is the bin number in ca closest to f0.
call timer('loops ',0)
i0=nint(f0/df) + 1
- nh=nfft2/2
- do i=1,nh !Copy data into c4a and apply
+ do i=1,NH2 !Copy data into c4a and apply
j=i0+i-1 !the filter function
if(j.ge.1 .and. j.le.nfft1/2+1) then
c4a(i)=rfilt(i)*ca(j)
@@ -102,7 +101,7 @@ subroutine filbig(dd,npts,f0,newdat,c4a,n4,sq0)
c4a(i)=0.
endif
enddo
- do i=nh+1,nfft2
+ do i=NH2+1,nfft2
j=i0+i-1-nfft2
! if(j.lt.1) j=j+nfft1 !nfft1 was nfft2
if(j.ge.1) then
@@ -112,7 +111,7 @@ subroutine filbig(dd,npts,f0,newdat,c4a,n4,sq0)
endif
enddo
- nadd=nfft2/NZ2
+ nadd=77 !nfft2/NZ2=77
i=0
do j=1,NZ2
s(j)=0.
diff --git a/lib/ft4/ft4_downsample.f90 b/lib/ft4/ft4_downsample.f90
index bbe53a2a..a6305c83 100644
--- a/lib/ft4/ft4_downsample.f90
+++ b/lib/ft4/ft4_downsample.f90
@@ -31,7 +31,7 @@ subroutine ft4_downsample(dd,newdata,f0,c)
if(newdata) then
x=dd
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
+ call four2a(cx,NMAX,1,-1,0) !r2c FFT to freq domain
endif
i0=nint(f0/df)
c1=0.
diff --git a/lib/ft4/ft4_testmsg.f90 b/lib/ft4/ft4_testmsg.f90
new file mode 100644
index 00000000..0d700ead
--- /dev/null
+++ b/lib/ft4/ft4_testmsg.f90
@@ -0,0 +1,50 @@
+ parameter (MAXTEST=75,NTEST=47)
+ character*37 testmsg(MAXTEST)
+ data testmsg(1:NTEST)/ &
+ "TNX BOB 73 GL", & ! 0.0
+ "PA9XYZ 590003 IO91NP", & ! 0.2
+ "G4ABC/P R 570007 JO22DB", & ! 0.2
+ "K1ABC W9XYZ 6A WI", & ! 0.3
+ "W9XYZ K1ABC R 17B EMA", & ! 0.3
+ "123456789ABCDEF012", & ! 0.5
+ "CQ K1ABC FN42", & ! 1.
+ "K1ABC W9XYZ EN37", & ! 1.
+ "W9XYZ K1ABC -11", & ! 1.
+ "K1ABC W9XYZ R-09", & ! 1.
+ "W9XYZ K1ABC RRR", & ! 1.
+ "K1ABC W9XYZ 73", & ! 1.
+ "K1ABC W9XYZ RR73", & ! 1.
+ "CQ FD K1ABC FN42", & ! 1.
+ "CQ TEST K1ABC/R FN42", & ! 1.
+ "K1ABC/R W9XYZ EN37", & ! 1.
+ "W9XYZ K1ABC/R R FN42", & ! 1.
+ "K1ABC/R W9XYZ RR73", & ! 1.
+ "CQ TEST K1ABC FN42", & ! 1.
+ "W9XYZ <PJ4/K1ABC> -11", & ! 1.
+ "<PJ4/K1ABC> W9XYZ R-09", & ! 1.
+ "CQ W9XYZ EN37", & ! 1.
+ "<YW18FIFA> W9XYZ -11", & ! 1.
+ "W9XYZ <YW18FIFA> R-09", & ! 1.
+ "<YW18FIFA> KA1ABC", & ! 1.
+ "KA1ABC <YW18FIFA> -11", & ! 1.
+ "<YW18FIFA> KA1ABC R-17", & ! 1.
+ "<YW18FIFA> KA1ABC 73", & ! 1.
+ "CQ G4ABC/P IO91", & ! 2.
+ "G4ABC/P PA9XYZ JO22", & ! 2.
+ "PA9XYZ G4ABC/P RR73", & ! 2.
+ "K1ABC W9XYZ 579 WI", & ! 3.
+ "W9XYZ K1ABC R 589 MA", & ! 3.
+ "K1ABC KA0DEF 559 MO", & ! 3.
+ "TU; KA0DEF K1ABC R 569 MA", & ! 3.
+ "KA1ABC G3AAA 529 0013", & ! 3.
+ "TU; G3AAA K1ABC R 559 MA", & ! 3.
+ "CQ KH1/KH7Z", & ! 4.
+ "CQ PJ4/K1ABC", & ! 4.
+ "PJ4/K1ABC <W9XYZ>", & ! 4.
+ "<W9XYZ> PJ4/K1ABC RRR", & ! 4.
+ "PJ4/K1ABC <W9XYZ> 73", & ! 4.
+ "<W9XYZ> YW18FIFA", & ! 4.
+ "YW18FIFA <W9XYZ> RRR", & ! 4.
+ "<W9XYZ> YW18FIFA 73", & ! 4.
+ "CQ YW18FIFA", & ! 4.
+ "<KA1ABC> YW18FIFA RR73"/
diff --git a/lib/ft4/ft4code.f90 b/lib/ft4/ft4code.f90
new file mode 100644
index 00000000..a7b2ccdd
--- /dev/null
+++ b/lib/ft4/ft4code.f90
@@ -0,0 +1,101 @@
+program ft4code
+
+! Provides examples of message packing, LDPC(174,91) encoding, bit and
+! symbol ordering, and other details of the FT8 protocol.
+
+ use packjt77
+ include 'ft4_params.f90' !Set various constants
+ include 'ft4_testmsg.f90'
+ parameter (NWAVE=NN*NSPS)
+
+ character*37 msg,msgsent
+ character*77 c77
+ character*9 comment
+ character bad*1,msgtype*18
+ integer itone(NN)
+ integer*1 msgbits(77),rvec(77),codeword(174)
+ data rvec/0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,1,1,0, &
+ 1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1, &
+ 0,1,0,1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,1/
+
+! Get command-line argument(s)
+ nargs=iargc()
+ if(nargs.ne.1 .and. nargs.ne.3) then
+ print*
+ print*,'Program ft4code: Provides examples of message packing, ', &
+ 'LDPC(174,91) encoding,'
+ print*,'bit and symbol ordering, and other details of the FT4 protocol.'
+ print*
+ print*,'Usage: ft4code [-c grid] "message" # Results for specified message'
+ print*,' ft4code -t # Examples of all message types'
+ go to 999
+ endif
+
+ call getarg(1,msg) !Message to be transmitted
+ if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-t') then
+ nmsg=NTEST
+ else
+ call fmtmsg(msg,iz) !To upper case; collapse multiple blanks
+ nmsg=1
+ endif
+
+ write(*,1010)
+1010 format(4x,'Message',31x,'Decoded',29x,'Err i3.n3'/100('-'))
+
+ do imsg=1,nmsg
+ if(nmsg.gt.1) msg=testmsg(imsg)
+
+! Generate msgsent, msgbits, and itone
+ i3=-1
+ n3=-1
+ call pack77(msg,i3,n3,c77)
+ call genft4(msg,0,msgsent,msgbits,itone)
+ call encode174_91(msgbits,codeword)
+ msgtype=""
+ if(i3.eq.0) then
+ if(n3.eq.0) msgtype="Free text"
+ if(n3.eq.1) msgtype="DXpedition mode"
+ if(n3.eq.2) msgtype="EU VHF Contest"
+ if(n3.eq.3) msgtype="ARRL Field Day"
+ if(n3.eq.4) msgtype="ARRL Field Day"
+ if(n3.eq.5) msgtype="Telemetry"
+ if(n3.ge.6) msgtype="Undefined type"
+ endif
+ if(i3.eq.1) msgtype="Standard msg"
+ if(i3.eq.2) msgtype="EU VHF Contest"
+ if(i3.eq.3) msgtype="ARRL RTTY Roundup"
+ if(i3.eq.4) msgtype="Nonstandard calls"
+ if(i3.ge.5) msgtype="Undefined msg type"
+ if(i3.ge.1) n3=-1
+ bad=" "
+ comment=' '
+ if(msg.ne.msgsent) bad="*"
+ if(n3.ge.0) then
+ write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype,comment
+1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9)
+ else
+ write(*,1022) imsg,msg,msgsent,bad,i3,msgtype,comment
+1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9)
+ endif
+ enddo
+
+ if(nmsg.eq.1) then
+ write(*,1030) ieor(msgbits,rvec)
+1030 format(/'Source-encoded message before scrambling, 77 bits: ',/77i1)
+ write(*,1032) rvec
+1032 format(/'Scrambling vector, 77 bits: ',/77i1)
+ write(*,1034) msgbits
+1034 format(/'Source-encoded message after scrambling, 77 bits:'/77i1)
+ write(*,1036) codeword(78:91)
+1036 format(/'14-bit CRC: ',/14i1)
+ write(*,1038) codeword(92:174)
+1038 format(/'83 Parity bits: ',/83i1)
+ write(*,1040) 0,itone,0
+1040 format(/'Channel symbols (105 tones):'/ &
+ 'R Sync',13x,'Data',13x, &
+ ' Sync',13x,'Data',13x, &
+ ' Sync',13x,'Data',13x,' Sync R'/ &
+ i1,1x,4i1,1x,29i1,1x,4i1,1x,29i1,1x,4i1,1x,29i1,1x,4i1,i2)
+ endif
+
+999 end program ft4code
diff --git a/lib/ft4/ft4sim.f90 b/lib/ft4/ft4sim.f90
index 959cf423..cef22303 100644
--- a/lib/ft4/ft4sim.f90
+++ b/lib/ft4/ft4sim.f90
@@ -5,27 +5,23 @@ program ft4sim
use wavhdr
use packjt77
include 'ft4_params.f90' !Set various constants
- parameter (NWAVE=NN*NSPS)
- parameter (NZZ=21*3456) !72576
type(hdr) h !Header for .wav file
character arg*12,fname*17
character msg37*37,msgsent37*37
character c77*77
- complex c0(0:NZZ-1)
- complex c(0:NZZ-1)
- real wave(NZZ)
- real dphi(0:NZZ-1)
- real pulse(3*NSPS)
+ complex c0(0:NMAX-1)
+ complex c(0:NMAX-1)
+ real wave(NMAX)
integer itone(NN)
integer*1 msgbits(77)
- integer*2 iwave(NZZ) !Generated full-length waveform
+ integer*2 iwave(NMAX) !Generated full-length waveform
integer icos4(4)
data icos4/0,1,3,2/
! Get command-line argument(s)
nargs=iargc()
if(nargs.ne.7) then
- print*,'Usage: ft4sim "message" f0 DT fdop del nfiles snr'
+ print*,'Usage: ft4sim "message" f0 DT fdop del nfiles snr'
print*,'Examples: ft4sim "CQ W9XYZ EN37" 1500 0.0 0.1 1.0 10 -15'
print*,' ft4sim "K1ABC W9XYZ R 539 WI" 1500 0.0 0.1 1.0 10 -15'
go to 999
@@ -82,49 +78,25 @@ program ft4sim
call sgran()
-! The filtered frequency pulse
- do i=1,3*NSPS
- tt=(i-1.5*NSPS)/real(NSPS)
- pulse(i)=gfsk_pulse(1.0,tt)
- enddo
-
-! Define the instantaneous frequency waveform
- dphi_peak=twopi*hmod/real(NSPS)
- dphi=0.0
- do j=1,NN
- ib=(j-1)*NSPS
- ie=ib+3*NSPS-1
- dphi(ib:ie)=dphi(ib:ie)+dphi_peak*pulse*itone(j)
- enddo
-
- phi=0.0
- c0=0.0
- dphi=dphi+twopi*f0*dt
-! do j=0,NMAX-1 !### ??? ###
- do j=0,(NN+2)*NSPS-1
- c0(j)=cmplx(cos(phi),sin(phi))
- phi=mod(phi+dphi(j),twopi)
- enddo
-
- c0(0:NSPS-1)=c0(0:NSPS-1)*(1.0-cos(twopi*(/(i,i=0,NSPS-1)/)/(2.0*NSPS)) )/2.0
- c0((NN+1)*NSPS:(NN+2)*NSPS-1)=c0((NN+1)*NSPS:(NN+2)*NSPS-1)*(1.0+cos(twopi*(/(i,i=0,NSPS-1)/)/(2.0*NSPS) ))/2.0
- c0((NN+2)*NSPS:)=0.
+ fsample=12000.0
+ icmplx=1
+ call gen_ft4wave(itone,NN,NSPS,fsample,f0,c0,wave,icmplx,NMAX)
k=nint((xdt+0.5)/dt)-NSPS
c0=cshift(c0,-k)
if(k.gt.0) c0(0:k-1)=0.0
- if(k.lt.0) c0(NZZ+k:NZZ-1)=0.0
+ if(k.lt.0) c0(NMAX+k:NMAX-1)=0.0
do ifile=1,nfiles
c=c0
- if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c,NZZ,NWAVE,fs,delay,fspread)
+ if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c,NMAX,NZ,fs,delay,fspread)
c=sig*c
wave=real(c)
peak=maxval(abs(wave))
nslots=1
if(snrdb.lt.90) then
- do i=1,NZZ !Add gaussian noise at specified SNR
+ do i=1,NMAX !Add gaussian noise at specified SNR
xnoise=gran()
wave(i)=wave(i) + xnoise
enddo
@@ -140,7 +112,7 @@ program ft4sim
endif
if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped."
iwave=nint(wave)
- h=default_header(12000,NZZ)
+ h=default_header(12000,NMAX)
write(fname,1102) ifile
1102 format('000000_',i6.6,'.wav')
open(10,file=fname,status='unknown',access='stream')
diff --git a/lib/ft4/gen_ft4wave.f90 b/lib/ft4/gen_ft4wave.f90
index 82399361..13018242 100644
--- a/lib/ft4/gen_ft4wave.f90
+++ b/lib/ft4/gen_ft4wave.f90
@@ -37,7 +37,7 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave)
wave=0.
if(icmplx.eq.1) cwave=0.
k=0
- do j=0,nwave-1
+ do j=0,(nsym+2)*nsps-1
k=k+1
if(icmplx.eq.0) then
wave(k)=sin(phi)
diff --git a/lib/ft4/get_ft4_bitmetrics.f90 b/lib/ft4/get_ft4_bitmetrics.f90
index eba86a41..9c8a4ab4 100644
--- a/lib/ft4/get_ft4_bitmetrics.f90
+++ b/lib/ft4/get_ft4_bitmetrics.f90
@@ -47,6 +47,8 @@ subroutine get_ft4_bitmetrics(cd,bitmetrics,badsync)
is3=0
is4=0
badsync=.false.
+ ibmax=0
+
do k=1,4
ip=maxloc(s4(:,k))
if(icos4a(k-1).eq.(ip(1)-1)) is1=is1+1
diff --git a/lib/ft4/getcandidates4.f90 b/lib/ft4/getcandidates4.f90
index 3f62e814..8ff80642 100644
--- a/lib/ft4/getcandidates4.f90
+++ b/lib/ft4/getcandidates4.f90
@@ -1,83 +1,83 @@
-subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
- ncand,sbase)
-
- include 'ft4_params.f90'
- real s(NH1,NHSYM)
- real savg(NH1),savsm(NH1)
- real sbase(NH1)
- real x(NFFT1)
- real window(NFFT1)
- complex cx(0:NH1)
- real candidate(2,maxcand),candidatet(2,maxcand)
- real dd(NMAX)
- equivalence (x,cx)
- logical first
- data first/.true./
- save first,window
-
- if(first) then
- first=.false.
- pi=4.0*atan(1.)
- window=0.
- call nuttal_window(window,NFFT1)
- endif
-
-! Compute symbol spectra, stepping by NSTEP steps.
- savg=0.
- df=12000.0/NFFT1
- fac=1.0/300.0
- do j=1,NHSYM
- ia=(j-1)*NSTEP + 1
- ib=ia+NFFT1-1
- if(ib.gt.NMAX) exit
- x=fac*dd(ia:ib)*window
- call four2a(x,NFFT1,1,-1,0) !r2c FFT
- s(1:NH1,j)=abs(cx(1:NH1))**2
- savg=savg + s(1:NH1,j) !Average spectrum
- enddo
- savg=savg/NHSYM
- savsm=0.
- do i=8,NH1-7
- savsm(i)=sum(savg(i-7:i+7))/15.
- enddo
-
- nfa=fa/df
- if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df)
- nfb=fb/df
- if(nfb.gt.nint(4910.0/df)) nfb=nint(4910.0/df)
- call ft4_baseline(savg,nfa,nfb,sbase)
- if(any(sbase(nfa:nfb).le.0)) return
- savsm(nfa:nfb)=savsm(nfa:nfb)/sbase(nfa:nfb)
- f_offset = -1.5*12000.0/NSPS
- ncand=0
- candidatet=0
- do i=nfa+1,nfb-1
- if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. &
- savsm(i).ge.syncmin) then
- den=savsm(i-1)-2*savsm(i)+savsm(i+1)
- del=0.
- if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den
- fpeak=(i+del)*df+f_offset
- if(fpeak.lt.200.0 .or. fpeak.gt.4910.0) cycle
- speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
- ncand=ncand+1
- candidatet(1,ncand)=fpeak
- candidatet(2,ncand)=speak
- if(ncand.eq.maxcand) exit
- endif
- enddo
- candidate=0
- nq=count(abs(candidatet(1,1:ncand)-nfqso).le.20.0)
- n1=1
- n2=nq+1
- do i=1,ncand
- if(abs(candidatet(1,i)-nfqso).le.20.0) then
- candidate(1:2,n1)=candidatet(1:2,i)
- n1=n1+1
- else
- candidate(1:2,n2)=candidatet(1:2,i)
- n2=n2+1
- endif
- enddo
-return
-end subroutine getcandidates4
+subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
+ ncand,sbase)
+
+ include 'ft4_params.f90'
+ real s(NH1,NHSYM)
+ real savg(NH1),savsm(NH1)
+ real sbase(NH1)
+ real x(NFFT1)
+ real window(NFFT1)
+ complex cx(0:NH1)
+ real candidate(2,maxcand),candidatet(2,maxcand)
+ real dd(NMAX)
+ equivalence (x,cx)
+ logical first
+ data first/.true./
+ save first,window
+
+ if(first) then
+ first=.false.
+ pi=4.0*atan(1.)
+ window=0.
+ call nuttal_window(window,NFFT1)
+ endif
+
+! Compute symbol spectra, stepping by NSTEP steps.
+ savg=0.
+ df=12000.0/NFFT1
+ fac=1.0/300.0
+ do j=1,NHSYM
+ ia=(j-1)*NSTEP + 1
+ ib=ia+NFFT1-1
+ if(ib.gt.NMAX) exit
+ x=fac*dd(ia:ib)*window
+ call four2a(x,NFFT1,1,-1,0) !r2c FFT
+ s(1:NH1,j)=abs(cx(1:NH1))**2
+ savg=savg + s(1:NH1,j) !Average spectrum
+ enddo
+ savg=savg/NHSYM
+ savsm=0.
+ do i=8,NH1-7
+ savsm(i)=sum(savg(i-7:i+7))/15.
+ enddo
+
+ nfa=fa/df
+ if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df)
+ nfb=fb/df
+ if(nfb.gt.nint(4910.0/df)) nfb=nint(4910.0/df)
+ call ft4_baseline(savg,nfa,nfb,sbase)
+ if(any(sbase(nfa:nfb).le.0)) return
+ savsm(nfa:nfb)=savsm(nfa:nfb)/sbase(nfa:nfb)
+ f_offset = -1.5*12000.0/NSPS
+ ncand=0
+ candidatet=0
+ do i=nfa+1,nfb-1
+ if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. &
+ savsm(i).ge.syncmin) then
+ den=savsm(i-1)-2*savsm(i)+savsm(i+1)
+ del=0.
+ if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den
+ fpeak=(i+del)*df+f_offset
+ if(fpeak.lt.200.0 .or. fpeak.gt.4910.0) cycle
+ speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
+ ncand=ncand+1
+ candidatet(1,ncand)=fpeak
+ candidatet(2,ncand)=speak
+ if(ncand.eq.maxcand) exit
+ endif
+ enddo
+ candidate=0
+ nq=count(abs(candidatet(1,1:ncand)-nfqso).le.20.0)
+ n1=1
+ n2=nq+1
+ do i=1,ncand
+ if(abs(candidatet(1,i)-nfqso).le.20.0) then
+ candidate(1:2,n1)=candidatet(1:2,i)
+ n1=n1+1
+ else
+ candidate(1:2,n2)=candidatet(1:2,i)
+ n2=n2+1
+ endif
+ enddo
+return
+end subroutine getcandidates4
diff --git a/lib/ft4/subtractft4.f90 b/lib/ft4/subtractft4.f90
index ae104ddb..8fb16532 100644
--- a/lib/ft4/subtractft4.f90
+++ b/lib/ft4/subtractft4.f90
@@ -16,7 +16,7 @@ subroutine subtractft4(dd,itone,f0,dt)
integer itone(103)
logical first
data first/.true./
- common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME)
+ common/heap4/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME)
save first
nstart=dt*12000+1-NSPS
diff --git a/lib/ft4/sync4d.f90 b/lib/ft4/sync4d.f90
index 8d78f66a..50ae5d9f 100644
--- a/lib/ft4/sync4d.f90
+++ b/lib/ft4/sync4d.f90
@@ -1,96 +1,96 @@
-subroutine sync4d(cd0,i0,ctwk,itwk,sync)
-
-! Compute sync power for a complex, downsampled FT4 signal.
-
- include 'ft4_params.f90'
- parameter(NP=NMAX/NDOWN,NSS=NSPS/NDOWN)
- complex cd0(0:NP-1)
- complex csynca(2*NSS),csyncb(2*NSS),csyncc(2*NSS),csyncd(2*NSS)
- complex csync2(2*NSS)
- complex ctwk(2*NSS)
- complex z1,z2,z3,z4
- logical first
- integer icos4a(0:3),icos4b(0:3),icos4c(0:3),icos4d(0:3)
- data icos4a/0,1,3,2/
- data icos4b/1,0,2,3/
- data icos4c/2,3,1,0/
- data icos4d/3,2,0,1/
- data first/.true./
- save first,twopi,csynca,csyncb,csyncc,csyncd,fac
-
- p(z1)=(real(z1*fac)**2 + aimag(z1*fac)**2)**0.5 !Statement function for power
-
- if( first ) then
- twopi=8.0*atan(1.0)
- k=1
- phia=0.0
- phib=0.0
- phic=0.0
- phid=0.0
- do i=0,3
- dphia=2*twopi*icos4a(i)/real(NSS)
- dphib=2*twopi*icos4b(i)/real(NSS)
- dphic=2*twopi*icos4c(i)/real(NSS)
- dphid=2*twopi*icos4d(i)/real(NSS)
- do j=1,NSS/2
- csynca(k)=cmplx(cos(phia),sin(phia))
- csyncb(k)=cmplx(cos(phib),sin(phib))
- csyncc(k)=cmplx(cos(phic),sin(phic))
- csyncd(k)=cmplx(cos(phid),sin(phid))
- phia=mod(phia+dphia,twopi)
- phib=mod(phib+dphib,twopi)
- phic=mod(phic+dphic,twopi)
- phid=mod(phid+dphid,twopi)
- k=k+1
- enddo
- enddo
- first=.false.
- fac=1.0/(2.0*NSS)
- endif
-
- i1=i0 !four Costas arrays
- i2=i0+33*NSS
- i3=i0+66*NSS
- i4=i0+99*NSS
-
- z1=0.
- z2=0.
- z3=0.
- z4=0.
-
- if(itwk.eq.1) csync2=ctwk*csynca !Tweak the frequency
- z1=0.
- if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) then
- z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2))
- elseif( i1.lt.0 ) then
- npts=(i1+4*NSS-1)/2
- if(npts.le.16) then
- z1=0.
- else
- z1=sum(cd0(0:i1+4*NSS-1:2)*conjg(csync2(2*NSS-npts:)))
- endif
- endif
-
- if(itwk.eq.1) csync2=ctwk*csyncb !Tweak the frequency
- if(i2.ge.0 .and. i2+4*NSS-1.le.NP-1) z2=sum(cd0(i2:i2+4*NSS-1:2)*conjg(csync2))
-
- if(itwk.eq.1) csync2=ctwk*csyncc !Tweak the frequency
- if(i3.ge.0 .and. i3+4*NSS-1.le.NP-1) z3=sum(cd0(i3:i3+4*NSS-1:2)*conjg(csync2))
-
- if(itwk.eq.1) csync2=ctwk*csyncd !Tweak the frequency
- z4=0.
- if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) then
- z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2))
- elseif( i4+4*NSS-1.gt.NP-1 ) then
- npts=(NP-1-i4+1)/2
- if(npts.le.16) then
- z4=0.
- else
- z4=sum(cd0(i4:i4+2*npts-1:2)*conjg(csync2(1:npts)))
- endif
- endif
-
- sync = p(z1) + p(z2) + p(z3) + p(z4)
-
- return
-end subroutine sync4d
+subroutine sync4d(cd0,i0,ctwk,itwk,sync)
+
+! Compute sync power for a complex, downsampled FT4 signal.
+
+ include 'ft4_params.f90'
+ parameter(NP=NMAX/NDOWN,NSS=NSPS/NDOWN)
+ complex cd0(0:NP-1)
+ complex csynca(2*NSS),csyncb(2*NSS),csyncc(2*NSS),csyncd(2*NSS)
+ complex csync2(2*NSS)
+ complex ctwk(2*NSS)
+ complex z1,z2,z3,z4
+ logical first
+ integer icos4a(0:3),icos4b(0:3),icos4c(0:3),icos4d(0:3)
+ data icos4a/0,1,3,2/
+ data icos4b/1,0,2,3/
+ data icos4c/2,3,1,0/
+ data icos4d/3,2,0,1/
+ data first/.true./
+ save first,twopi,csynca,csyncb,csyncc,csyncd,fac
+
+ p(z1)=(real(z1*fac)**2 + aimag(z1*fac)**2)**0.5 !Statement function for power
+
+ if( first ) then
+ twopi=8.0*atan(1.0)
+ k=1
+ phia=0.0
+ phib=0.0
+ phic=0.0
+ phid=0.0
+ do i=0,3
+ dphia=2*twopi*icos4a(i)/real(NSS)
+ dphib=2*twopi*icos4b(i)/real(NSS)
+ dphic=2*twopi*icos4c(i)/real(NSS)
+ dphid=2*twopi*icos4d(i)/real(NSS)
+ do j=1,NSS/2
+ csynca(k)=cmplx(cos(phia),sin(phia))
+ csyncb(k)=cmplx(cos(phib),sin(phib))
+ csyncc(k)=cmplx(cos(phic),sin(phic))
+ csyncd(k)=cmplx(cos(phid),sin(phid))
+ phia=mod(phia+dphia,twopi)
+ phib=mod(phib+dphib,twopi)
+ phic=mod(phic+dphic,twopi)
+ phid=mod(phid+dphid,twopi)
+ k=k+1
+ enddo
+ enddo
+ first=.false.
+ fac=1.0/(2.0*NSS)
+ endif
+
+ i1=i0 !four Costas arrays
+ i2=i0+33*NSS
+ i3=i0+66*NSS
+ i4=i0+99*NSS
+
+ z1=0.
+ z2=0.
+ z3=0.
+ z4=0.
+
+ if(itwk.eq.1) csync2=ctwk*csynca !Tweak the frequency
+ z1=0.
+ if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) then
+ z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2))
+ elseif( i1.lt.0 ) then
+ npts=(i1+4*NSS-1)/2
+ if(npts.le.16) then
+ z1=0.
+ else
+ z1=sum(cd0(0:i1+4*NSS-1:2)*conjg(csync2(2*NSS-npts:)))
+ endif
+ endif
+
+ if(itwk.eq.1) csync2=ctwk*csyncb !Tweak the frequency
+ if(i2.ge.0 .and. i2+4*NSS-1.le.NP-1) z2=sum(cd0(i2:i2+4*NSS-1:2)*conjg(csync2))
+
+ if(itwk.eq.1) csync2=ctwk*csyncc !Tweak the frequency
+ if(i3.ge.0 .and. i3+4*NSS-1.le.NP-1) z3=sum(cd0(i3:i3+4*NSS-1:2)*conjg(csync2))
+
+ if(itwk.eq.1) csync2=ctwk*csyncd !Tweak the frequency
+ z4=0.
+ if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) then
+ z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2))
+ elseif( i4+4*NSS-1.gt.NP-1 ) then
+ npts=(NP-1-i4+1)/2
+ if(npts.le.16) then
+ z4=0.
+ else
+ z4=sum(cd0(i4:i4+2*npts-1:2)*conjg(csync2(1:npts)))
+ endif
+ endif
+
+ sync = p(z1) + p(z2) + p(z3) + p(z4)
+
+ return
+end subroutine sync4d
diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90
index c60ee179..fe6ce086 100644
--- a/lib/ft4_decode.f90
+++ b/lib/ft4_decode.f90
@@ -24,10 +24,11 @@ module ft4_decode
contains
subroutine decode(this,callback,iwave,nQSOProgress,nfqso, &
- nutc,nfa,nfb,ndepth,lapcqonly,ncontest,mycall,hiscall)
+ nfa,nfb,ndepth,lapcqonly,ncontest,mycall,hiscall)
use timer_module, only: timer
use packjt77
include 'ft4/ft4_params.f90'
+ parameter (MAXCAND=100)
class(ft4_decoder), intent(inout) :: this
procedure(ft4_decode_callback) :: callback
parameter (NSS=NSPS/NDOWN,NDMAX=NMAX/NDOWN)
@@ -38,7 +39,6 @@ contains
character*12 mycall,hiscall
character*12 mycall0,hiscall0
character*6 hhmmss
- character*4 cqstr,cqstr0
complex cd2(0:NDMAX-1) !Complex waveform
complex cb(0:NDMAX-1)
@@ -49,18 +49,19 @@ contains
real bitmetrics(2*NN,3)
real dd(NMAX)
real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND)
- real candidate(2,100)
+ real candidate(2,MAXCAND)
real savg(NH1),sbase(NH1)
integer apbits(2*ND)
integer apmy_ru(28),aphis_fd(28)
integer*2 iwave(NMAX) !Raw received data
integer*1 message77(77),rvec(77),apmask(2*ND),cw(2*ND)
+ integer*1 message91(91)
integer*1 hbits(2*NN)
integer i4tone(103)
integer nappasses(0:5) ! # of decoding passes for QSO States 0-5
integer naptypes(0:5,4) ! nQSOProgress, decoding pass
- integer mcq(29)
+ integer mcq(29),mcqru(29),mcqfd(29),mcqtest(29),mcqww(29)
integer mrrr(19),m73(19),mrr73(19)
logical nohiscall,unpk77_success
@@ -71,6 +72,10 @@ contains
data first/.true./
data mcq/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,1,0,0/
+ data mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/
+ data mcqfd/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0/
+ data mcqtest/0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0/
+ data mcqww/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,1,1,1,1,0/
data mrrr/0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1/
data m73/0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,0,0,0,1/
data mrr73/0,1,1,1,1,1,1,0,0,1,1,1,0,1,0,1,0,0,1/
@@ -78,12 +83,12 @@ contains
1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1, &
0,1,0,1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,1/
save fs,dt,tt,txt,twopi,h,first,apbits,nappasses,naptypes, &
- mycall0,hiscall0,cqstr0,ctwk2
+ mycall0,hiscall0,ctwk2
this%callback => callback
hhmmss=cdatetime0(8:13)
- dxcall13=hiscall
- mycall13=mycall
+ smax1=0.
+ nd1=0
if(first) then
fs=12000.0/NDOWN !Sample rate after downsampling
@@ -100,6 +105,11 @@ contains
call twkfreq1(ctwk,2*NSS,fs/2.0,a,ctwk2(:,idf))
enddo
+ mcq=2*mod(mcq+rvec(1:29),2)-1
+ mcqru=2*mod(mcqru+rvec(1:29),2)-1
+ mcqfd=2*mod(mcqfd+rvec(1:29),2)-1
+ mcqtest=2*mod(mcqtest+rvec(1:29),2)-1
+ mcqww=2*mod(mcqww+rvec(1:29),2)-1
mrrr=2*mod(mrrr+rvec(59:77),2)-1
m73=2*mod(m73+rvec(59:77),2)-1
mrr73=2*mod(mrr73+rvec(59:77),2)-1
@@ -128,26 +138,9 @@ contains
mycall0=''
hiscall0=''
- cqstr0=''
first=.false.
endif
- if(cqstr.ne.cqstr0) then
- i0=index(cqstr,' ')
- if(i0.le.1) then
- message='CQ A1AA AA01'
- else
- message='CQ '//cqstr(1:i0-1)//' A1AA AA01'
- endif
- i3=-1
- n3=-1
- call pack77(message,i3,n3,c77)
- call unpack77(c77,1,msgsent,unpk77_success)
- read(c77,'(29i1)') mcq
- mcq=2*mod(mcq+rvec(1:29),2)-1
- cqstr0=cqstr
- endif
-
l1=index(mycall,char(0))
if(l1.ne.0) mycall(l1:)=" "
l1=index(hiscall,char(0))
@@ -185,7 +178,6 @@ contains
mycall0=mycall
hiscall0=hiscall
endif
- maxcand=100
ndecodes=0
decodes=' '
fa=nfa
@@ -222,7 +214,7 @@ contains
candidate=0.0
ncand=0
call timer('getcand4',0)
- call getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
+ call getcandidates4(dd,fa,fb,syncmin,nfqso,MAXCAND,savg,candidate, &
ncand,sbase)
call timer('getcand4',1)
dobigfft=.true.
@@ -329,7 +321,7 @@ contains
npasses=3+nappasses(nQSOProgress)
if(lapcqonly) npasses=4
if(ndepth.eq.1) npasses=3
- if(ncontest.ge.5) npasses=3 ! Don't support Fox and Hound
+ if(ncontest.ge.6) npasses=3 ! Don't support Fox and Hound
do ipass=1,npasses
if(ipass.eq.1) llr=llra
if(ipass.eq.2) llr=llrb
@@ -340,7 +332,7 @@ contains
endif
if(ipass .gt. 3) then
- llrd=llra
+ llrd=llrc
iaptype=naptypes(nQSOProgress,ipass-3)
if(lapcqonly) iaptype=1
@@ -349,24 +341,30 @@ contains
! 2 : EU_VHF
! 3 : FIELD DAY
! 4 : RTTY
-! 5 : FOX
-! 6 : HOUND
+! 5 : WW_DIGI
+! 6 : FOX
+! 7 : HOUND
!
! Conditions that cause us to bail out of AP decoding
- napwid=50
- if(ncontest.le.4 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid) ) cycle
+ napwid=80
+ if(ncontest.le.5 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid) ) cycle
if(iaptype.ge.2 .and. apbits(1).gt.1) cycle ! No, or nonstandard, mycall
if(iaptype.ge.3 .and. apbits(30).gt.1) cycle ! No, or nonstandard, dxcall
- if(iaptype.eq.1) then ! CQ or CQ TEST or CQ FD or CQ RU or CQ SCC
+ if(iaptype.eq.1) then ! CQ or CQ TEST or CQ FD or CQ RU or CQ WW
apmask=0
apmask(1:29)=1
- llrd(1:29)=apmag*mcq(1:29)
+ if( ncontest.eq.0 ) llrd(1:29)=apmag*mcq(1:29)
+ if( ncontest.eq.1 ) llrd(1:29)=apmag*mcqtest(1:29)
+ if( ncontest.eq.2 ) llrd(1:29)=apmag*mcqtest(1:29)
+ if( ncontest.eq.3 ) llrd(1:29)=apmag*mcqfd(1:29)
+ if( ncontest.eq.4 ) llrd(1:29)=apmag*mcqru(1:29)
+ if( ncontest.eq.5 ) llrd(1:29)=apmag*mcqww(1:29)
endif
if(iaptype.eq.2) then ! MyCall,???,???
apmask=0
- if(ncontest.eq.0.or.ncontest.eq.1) then
+ if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.5) then
apmask(1:29)=1
llrd(1:29)=apmag*apbits(1:29)
else if(ncontest.eq.2) then
@@ -383,14 +381,14 @@ contains
if(iaptype.eq.3) then ! MyCall,DxCall,???
apmask=0
- if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2) then
+ if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.5) then
apmask(1:58)=1
llrd(1:58)=apmag*apbits(1:58)
else if(ncontest.eq.3) then ! Field Day
apmask(1:56)=1
llrd(1:28)=apmag*apbits(1:28)
llrd(29:56)=apmag*aphis_fd(1:28)
- else if(ncontest.eq.4) then ! RTTY RU
+ else if(ncontest.eq.4) then
apmask(2:57)=1
llrd(2:29)=apmag*apmy_ru(1:28)
llrd(30:57)=apmag*apbits(30:57)
@@ -399,7 +397,7 @@ contains
if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then
apmask=0
- if(ncontest.le.4) then
+ if(ncontest.le.5) then
apmask(1:77)=1 ! mycall, hiscall, RRR|73|RR73
if(iaptype.eq.6) llrd(1:77)=apmag*apbits(1:77)
endif
@@ -409,27 +407,28 @@ contains
endif
message77=0
dmin=0.0
- call timer('bpdec174',0)
- call bpdecode174_91(llr,apmask,max_iterations,message77, &
- cw,nharderror,niterations)
- call timer('bpdec174',1)
-
- if(doosd .and. nharderror.lt.0) then
- ndeep=3
-! if(abs(nfqso-f1).le.napwid) then
-! ndeep=4
-! endif
- call timer('osd174_91 ',0)
- call osd174_91(llr,apmask,ndeep,message77,cw,nharderror,dmin)
- call timer('osd174_91 ',1)
+
+ ndeep=2
+ maxosd=2
+ if(abs(nfqso-f1).le.napwid) then
+ ndeep=2
+ maxosd=3
endif
+ if(.not.doosd) maxosd = -1
+ call timer('dec174_91 ',0)
+ Keff=91
+ call decode174_91(llr,Keff,maxosd,ndeep,apmask,message91,cw, &
+ ntype,nharderror,dmin)
+ message77=message91(1:77)
+ call timer('dec174_91 ',1)
if(sum(message77).eq.0) cycle
if( nharderror.ge.0 ) then
message77=mod(message77+rvec,2) ! remove rvec scrambling
write(c77,'(77i1)') message77(1:77)
call unpack77(c77,1,message,unpk77_success)
- if(unpk77_success.and.dosubtract) then
+ if(.not.unpk77_success) exit
+ if(dosubtract) then
call get_ft4_tones_from_77bits(message77,i4tone)
dt=real(ibest)/666.67
call timer('subtract',0)
@@ -450,16 +449,15 @@ contains
endif
nsnr=nint(max(-21.0,xsnr))
xdt=ibest/666.67 - 0.5
-!write(21,'(i6.6,i5,2x,f4.1,i6,2x,a37,2x,f4.1,3i3,f5.1,i4,i4,i4)') &
-! nutc,nsnr,xdt,nint(f1),message,smax,iaptype,ipass,isp,dmin,nsync_qual,nharderror,iseg
+ qual=1.0-(nharderror+dmin)/60.0
call this%callback(smax,nsnr,xdt,f1,message,iaptype,qual)
exit
endif
- enddo !Sequence estimation
+ enddo !Sequence estimation
if(nharderror.ge.0) exit
- enddo !3 DT segments
- enddo !Candidate list
- enddo !Subtraction loop
+ enddo !3 DT segments
+ enddo !Candidate list
+ enddo !Subtraction loop
return
end subroutine decode
diff --git a/lib/ft8.f90 b/lib/ft8.f90
deleted file mode 100644
index aacff17d..00000000
--- a/lib/ft8.f90
+++ /dev/null
@@ -1,49 +0,0 @@
-program ft8
-
- integer*2 iwave(15*12000)
- logical lft8apon,lapcqonly,nagain,newdat
- character*12 mycall12,hiscall12
- character*6 hisgrid6
- character arg*8,infile*80
- integer ihdr(11)
-
- nargs=iargc()
- if(nargs.lt.3) then
- print*,'Usage: ft8 nfa nfb ndepth infile'
- print*,'Example: ft8 200 4000 3 181201_180315.wav'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) nfa
- call getarg(2,arg)
- read(arg,*) nfb
- call getarg(3,arg)
- read(arg,*) ndepth
- nfiles=nargs-3
-
- nQSOProgress=0
- nfqso=1500
- nftx=0
- newdat=.true.
- nutc=0
- ncontest=0
- nagain=.false.
- lft8apon=.false.
- lapcqonly=.false.
- napwid=75
- mycall12='K1ABC'
- hiscall12='W9XYZ'
- hisgrid6='EN37wb'
-
- do ifile=1,nfiles
- call getarg(3+ifile,infile)
- open(10,file=infile,status='old',access='stream')
- read(10) ihdr,iwave
- close(10)
-
- call ft8dec(iwave,nQSOProgress,nfqso,nftx,newdat, &
- nutc,nfa,nfb,ndepth,ncontest,nagain,lft8apon,lapcqonly, &
- napwid,mycall12,hiscall12,hisgrid6)
- enddo
-
-999 end program ft8
diff --git a/lib/ft8/baseline.f90 b/lib/ft8/baseline.f90
index 035f9ab4..49679510 100644
--- a/lib/ft8/baseline.f90
+++ b/lib/ft8/baseline.f90
@@ -37,6 +37,7 @@ subroutine baseline(s,nfa,nfb,sbase)
kz=k
a=0.
call polyfit(x,y,y,kz,nterms,0,a,chisqr) !Fit a low-order polynomial
+ sbase=0.0
do i=ia,ib
t=i-i0
sbase(i)=a(1)+t*(a(2)+t*(a(3)+t*(a(4)+t*(a(5))))) + 0.65
diff --git a/lib/ft8/bpdecode174_91.f90 b/lib/ft8/bpdecode174_91.f90
index 78809f19..a7c6f95b 100644
--- a/lib/ft8/bpdecode174_91.f90
+++ b/lib/ft8/bpdecode174_91.f90
@@ -1,4 +1,4 @@
-subroutine bpdecode174_91(llr,apmask,maxiterations,message77,cw,nharderror,iter)
+subroutine bpdecode174_91(llr,apmask,maxiterations,message77,cw,nharderror,iter,ncheck)
!
! A log-domain belief propagation decoder for the (174,91) code.
!
@@ -19,7 +19,7 @@ real zn(N)
real llr(N)
real Tmn
-include "ldpc_174_91_c_reordered_parity.f90"
+include "ldpc_174_91_c_parity.f90"
decoded=0
toc=0
@@ -33,6 +33,7 @@ do j=1,M
enddo
ncnt=0
+nclast=0
do iter=0,maxiterations
@@ -76,6 +77,7 @@ do iter=0,maxiterations
! write(*,*) iter,ncheck,nd,ncnt
if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then
nharderror=-1
+
return
endif
endif
diff --git a/lib/ft8/decode174_91.f90 b/lib/ft8/decode174_91.f90
new file mode 100644
index 00000000..134864d9
--- /dev/null
+++ b/lib/ft8/decode174_91.f90
@@ -0,0 +1,155 @@
+subroutine decode174_91(llr,Keff,maxosd,norder,apmask,message91,cw,ntype,nharderror,dmin)
+!
+! A hybrid bp/osd decoder for the (174,91) code.
+!
+! maxosd<0: do bp only
+! maxosd=0: do bp and then call osd once with channel llrs
+! maxosd>1: do bp and then call osd maxosd times with saved bp outputs
+! norder : osd decoding depth
+!
+ integer, parameter:: N=174, K=91, M=N-K
+ integer*1 cw(N),apmask(N)
+ integer*1 nxor(N),hdec(N)
+ integer*1 message91(91),m96(96)
+ integer nrw(M),ncw
+ integer Nm(7,M)
+ integer Mn(3,N) ! 3 checks per bit
+ integer synd(M)
+ real tov(3,N)
+ real toc(7,M)
+ real tanhtoc(7,M)
+ real zn(N),zsum(N),zsave(N,3)
+ real llr(N)
+ real Tmn
+
+ include "ldpc_174_91_c_parity.f90"
+
+ maxiterations=30
+ nosd=0
+ if(maxosd.gt.3) maxosd=3
+ if(maxosd.eq.0) then ! osd with channel llrs
+ nosd=1
+ zsave(:,1)=llr
+ elseif(maxosd.gt.0) then !
+ nosd=maxosd
+ elseif(maxosd.lt.0) then ! just bp
+ nosd=0
+ endif
+
+ toc=0
+ tov=0
+ tanhtoc=0
+! initialize messages to checks
+ do j=1,M
+ do i=1,nrw(j)
+ toc(i,j)=llr((Nm(i,j)))
+ enddo
+ enddo
+
+ ncnt=0
+ nclast=0
+ zsum=0.0
+ do iter=0,maxiterations
+! Update bit log likelihood ratios (tov=0 in iteration 0).
+ do i=1,N
+ if( apmask(i) .ne. 1 ) then
+ zn(i)=llr(i)+sum(tov(1:ncw,i))
+ else
+ zn(i)=llr(i)
+ endif
+ enddo
+ zsum=zsum+zn
+ if(iter.gt.0 .and. iter.le.maxosd) then
+ zsave(:,iter)=zsum
+ endif
+
+! Check to see if we have a codeword (check before we do any iteration).
+ cw=0
+ where( zn .gt. 0. ) cw=1
+ ncheck=0
+ do i=1,M
+ synd(i)=sum(cw(Nm(1:nrw(i),i)))
+ if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1
+ enddo
+ if( ncheck .eq. 0 ) then ! we have a codeword - if crc is good, return it
+ m96=0
+ m96(1:77)=cw(1:77)
+ m96(83:96)=cw(78:91)
+ call get_crc14(m96,96,nbadcrc)
+ nharderror=count( (2*cw-1)*llr .lt. 0.0 )
+ if(nbadcrc.eq.0) then
+ message91=cw(1:91)
+ hdec=0
+ where(llr .ge. 0) hdec=1
+ nxor=ieor(hdec,cw)
+ dmin=sum(nxor*abs(llr))
+ ntype=1
+ return
+ endif
+ endif
+
+ if( iter.gt.0 ) then ! this code block implements an early stopping criterion
+! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion
+ nd=ncheck-nclast
+ if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased
+ ncnt=0 ! reset counter
+ else
+ ncnt=ncnt+1
+ endif
+! write(*,*) iter,ncheck,nd,ncnt
+ if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then
+ nharderror=-1
+ exit
+ endif
+ endif
+ nclast=ncheck
+
+! Send messages from bits to check nodes
+ do j=1,M
+ do i=1,nrw(j)
+ ibj=Nm(i,j)
+ toc(i,j)=zn(ibj)
+ do kk=1,ncw ! subtract off what the bit had received from the check
+ if( Mn(kk,ibj) .eq. j ) then
+ toc(i,j)=toc(i,j)-tov(kk,ibj)
+ endif
+ enddo
+ enddo
+ enddo
+
+! send messages from check nodes to variable nodes
+ do i=1,M
+ tanhtoc(1:7,i)=tanh(-toc(1:7,i)/2)
+ enddo
+
+ do j=1,N
+ do i=1,ncw
+ ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j
+ Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j)
+ call platanh(-Tmn,y)
+! y=atanh(-Tmn)
+ tov(i,j)=2*y
+ enddo
+ enddo
+
+ enddo ! bp iterations
+
+ do i=1,nosd
+ zn=zsave(:,i)
+ call osd174_91(zn,Keff,apmask,norder,message91,cw,nharderror,dminosd)
+ if(nharderror.gt.0) then
+ hdec=0
+ where(llr .ge. 0) hdec=1
+ nxor=ieor(hdec,cw)
+ dmin=sum(nxor*abs(llr))
+ ntype=2
+ return
+ endif
+ enddo
+
+ ntype=0
+ nharderror=-1
+ dminosd=0.0
+
+ return
+end subroutine decode174_91
diff --git a/lib/ft8/encode174_91.f90 b/lib/ft8/encode174_91.f90
index 0ffa4841..5bae7d56 100644
--- a/lib/ft8/encode174_91.f90
+++ b/lib/ft8/encode174_91.f90
@@ -2,57 +2,57 @@ subroutine encode174_91(message77,codeword)
!
! Add a 14-bit CRC to a 77-bit message and return a 174-bit codeword
!
-use, intrinsic :: iso_c_binding
-use iso_c_binding, only: c_loc,c_size_t
-use crc
+ use, intrinsic :: iso_c_binding
+ use iso_c_binding, only: c_loc,c_size_t
+ use crc
-integer, parameter:: N=174, K=91, M=N-K
-character*91 tmpchar
-integer*1 codeword(N)
-integer*1 gen(M,K)
-integer*1 message77(77),message(K)
-integer*1 pchecks(M)
-integer*1, target :: i1MsgBytes(12)
-include "ldpc_174_91_c_generator.f90"
-logical first
-data first/.true./
-save first,gen
+ integer, parameter:: N=174, K=91, M=N-K
+ character*91 tmpchar
+ integer*1 codeword(N)
+ integer*1 gen(M,K)
+ integer*1 message77(77),message(K)
+ integer*1 pchecks(M)
+ integer*1, target :: i1MsgBytes(12)
+ include "ldpc_174_91_c_generator.f90"
+ logical first
+ data first/.true./
+ save first,gen
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,M
- do j=1,23
- read(g(i)(j:j),"(Z1)") istr
- ibmax=4
- if(j.eq.23) ibmax=3
- do jj=1, ibmax
- icol=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(i,icol)=1
- enddo
- enddo
- enddo
-first=.false.
-endif
+ if( first ) then ! fill the generator matrix
+ gen=0
+ do i=1,M
+ do j=1,23
+ read(g(i)(j:j),"(Z1)") istr
+ ibmax=4
+ if(j.eq.23) ibmax=3
+ do jj=1, ibmax
+ icol=(j-1)*4+jj
+ if( btest(istr,4-jj) ) gen(i,icol)=1
+ enddo
+ enddo
+ enddo
+ first=.false.
+ endif
! Add 14-bit CRC to form 91-bit message+CRC14
-write(tmpchar,'(77i1)') message77
-tmpchar(78:80)='000'
-i1MsgBytes=0
-read(tmpchar,'(10b8)') i1MsgBytes(1:10)
-ncrc14 = crc14 (c_loc (i1MsgBytes), 12)
-write(tmpchar(78:91),'(b14)') ncrc14
-read(tmpchar,'(91i1)') message
+ write(tmpchar,'(77i1)') message77
+ tmpchar(78:80)='000'
+ i1MsgBytes=0
+ read(tmpchar,'(10b8)') i1MsgBytes(1:10)
+ ncrc14 = crc14 (c_loc (i1MsgBytes), 12)
+ write(tmpchar(78:91),'(b14)') ncrc14
+ read(tmpchar,'(91i1)') message
-do i=1,M
- nsum=0
- do j=1,K
- nsum=nsum+message(j)*gen(i,j)
- enddo
- pchecks(i)=mod(nsum,2)
-enddo
+ do i=1,M
+ nsum=0
+ do j=1,K
+ nsum=nsum+message(j)*gen(i,j)
+ enddo
+ pchecks(i)=mod(nsum,2)
+ enddo
-codeword(1:K)=message
-codeword(K+1:N)=pchecks
+ codeword(1:K)=message
+ codeword(K+1:N)=pchecks
-return
+ return
end subroutine encode174_91
diff --git a/lib/ft8/encode174_91_nocrc.f90 b/lib/ft8/encode174_91_nocrc.f90
new file mode 100644
index 00000000..371e8317
--- /dev/null
+++ b/lib/ft8/encode174_91_nocrc.f90
@@ -0,0 +1,49 @@
+subroutine encode174_91_nocrc(message,codeword)
+!
+! Encode a 91-bit message and return a 174-bit codeword.
+!
+ use, intrinsic :: iso_c_binding
+ use iso_c_binding, only: c_loc,c_size_t
+ use crc
+
+ integer, parameter:: N=174, K=91, M=N-K
+ character*91 tmpchar
+ integer*1 codeword(N)
+ integer*1 gen(M,K)
+ integer*1 message(K)
+ integer*1 pchecks(M)
+ integer*1, target :: i1MsgBytes(12)
+ include "ldpc_174_91_c_generator.f90"
+ logical first
+ data first/.true./
+ save first,gen
+
+ if( first ) then ! fill the generator matrix
+ gen=0
+ do i=1,M
+ do j=1,23
+ read(g(i)(j:j),"(Z1)") istr
+ ibmax=4
+ if(j.eq.23) ibmax=3
+ do jj=1, ibmax
+ icol=(j-1)*4+jj
+ if( btest(istr,4-jj) ) gen(i,icol)=1
+ enddo
+ enddo
+ enddo
+ first=.false.
+ endif
+
+ do i=1,M
+ nsum=0
+ do j=1,K
+ nsum=nsum+message(j)*gen(i,j)
+ enddo
+ pchecks(i)=mod(nsum,2)
+ enddo
+
+ codeword(1:K)=message
+ codeword(K+1:N)=pchecks
+
+ return
+end subroutine encode174_91_nocrc
diff --git a/lib/ft8/extractmessage174.f90 b/lib/ft8/extractmessage174.f90
deleted file mode 100644
index 252547c4..00000000
--- a/lib/ft8/extractmessage174.f90
+++ /dev/null
@@ -1,40 +0,0 @@
-subroutine extractmessage174(decoded,msgreceived,ncrcflag)
- use iso_c_binding, only: c_loc,c_size_t
- use crc
- use packjt
-
- character*22 msgreceived
- character*87 cbits
- integer*1 decoded(87)
- integer*1, target:: i1Dec8BitBytes(11)
- integer*4 i4Dec6BitWords(12)
-
-! Write decoded bits into cbits: 75-bit message plus 12-bit CRC
- write(cbits,1000) decoded
-1000 format(87i1)
- read(cbits,1001) i1Dec8BitBytes
-1001 format(11b8)
- read(cbits,1002) ncrc12 !Received CRC12
-1002 format(75x,b12)
-
- i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),transfer(128+64+32,0_1))
- i1Dec8BitBytes(11)=0
- icrc12=crc12(c_loc(i1Dec8BitBytes),11) !CRC12 computed from 75 msg bits
-
- if(ncrc12.eq.icrc12 .or. sum(decoded(57:87)).eq.0) then !### Kludge ###
-! CRC12 checks out --- unpack 72-bit message
- do ibyte=1,12
- itmp=0
- do ibit=1,6
- itmp=ishft(itmp,1)+iand(1_1,decoded((ibyte-1)*6+ibit))
- enddo
- i4Dec6BitWords(ibyte)=itmp
- enddo
- call unpackmsg(i4Dec6BitWords,msgreceived)
- ncrcflag=1
- else
- msgreceived=' '
- ncrcflag=-1
- endif
- return
- end subroutine extractmessage174
diff --git a/lib/ft8/extractmessage174_91.f90 b/lib/ft8/extractmessage174_91.f90
deleted file mode 100644
index ecc14246..00000000
--- a/lib/ft8/extractmessage174_91.f90
+++ /dev/null
@@ -1,40 +0,0 @@
-subroutine extractmessage174_91(decoded,msgreceived,ncrcflag)
- use iso_c_binding, only: c_loc,c_size_t
- use crc
- use packjt
-
- character*22 msgreceived
- character*91 cbits
- integer*1 decoded(91)
- integer*1, target:: i1Dec8BitBytes(12)
- integer*4 i4Dec6BitWords(12)
-
-! Write decoded bits into cbits: 77-bit message plus 14-bit CRC
- write(cbits,1000) decoded
-1000 format(91i1)
- read(cbits,1001) i1Dec8BitBytes
-1001 format(12b8)
- read(cbits,1002) ncrc14 !Received CRC12
-1002 format(77x,b14)
-
- i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),transfer(128+64+32+16+8,0_1))
- i1Dec8BitBytes(11:12)=0
- icrc14=crc14(c_loc(i1Dec8BitBytes),12) !CRC12 computed from 75 msg bits
-
- if(ncrc14.eq.icrc14 .or. sum(decoded(57:87)).eq.0) then !### Kludge ###
-! CRC14 checks out --- unpack 72-bit message
- do ibyte=1,12
- itmp=0
- do ibit=1,6
- itmp=ishft(itmp,1)+iand(1_1,decoded((ibyte-1)*6+ibit))
- enddo
- i4Dec6BitWords(ibyte)=itmp
- enddo
- call unpackmsg(i4Dec6BitWords,msgreceived)
- ncrcflag=1
- else
- msgreceived=' '
- ncrcflag=-1
- endif
- return
- end subroutine extractmessage174_91
diff --git a/lib/ft8/filt8.f90 b/lib/ft8/filt8.f90
index aeacf2a7..6b39c043 100644
--- a/lib/ft8/filt8.f90
+++ b/lib/ft8/filt8.f90
@@ -9,7 +9,7 @@ subroutine filt8(f0,nslots,width,wave)
equivalence (x,cx)
x=wave
- call four2a(x,NFFT,1,-1,0) !r2c
+ call four2a(cx,NFFT,1,-1,0) !r2c
df=12000.0/NFFT
fa=f0 - 0.5*6.25
fb=f0 + 7.5*6.25 + (nslots-1)*60.0
@@ -35,7 +35,7 @@ subroutine filt8(f0,nslots,width,wave)
!###
if(nslots.ne.99) return
x=wave
- call four2a(x,NFFT,1,-1,0) !r2c
+ call four2a(cx,NFFT,1,-1,0) !r2c
do i=0,NH
s1(i)=real(cx(i))**2 + aimag(cx(i))**2
enddo
diff --git a/lib/ft8/foxfilt.f90 b/lib/ft8/foxfilt.f90
index d97923a8..6ad46a47 100644
--- a/lib/ft8/foxfilt.f90
+++ b/lib/ft8/foxfilt.f90
@@ -9,7 +9,7 @@ subroutine foxfilt(nslots,nfreq,width,wave)
x(1:NWAVE)=wave
x(NWAVE+1:)=0.
- call four2a(x,NFFT,1,-1,0) !r2c
+ call four2a(cx,NFFT,1,-1,0) !r2c
df=48000.0/NFFT
fa=nfreq - 0.5*6.25
fb=nfreq + 7.5*6.25 + (nslots-1)*60.0
diff --git a/lib/ft8/ft8_testmsg.f90 b/lib/ft8/ft8_testmsg.f90
index 2a1bf8f9..253641d2 100644
--- a/lib/ft8/ft8_testmsg.f90
+++ b/lib/ft8/ft8_testmsg.f90
@@ -1,51 +1,51 @@
parameter (MAXTEST=75,NTEST=48)
character*37 testmsg(MAXTEST)
data testmsg(1:NTEST)/ &
- "CQ K1ABC FN42", &
- "K1ABC W9XYZ EN37", &
- "W9XYZ K1ABC -11", &
- "K1ABC W9XYZ R-09", &
- "W9XYZ K1ABC RRR", &
- "K1ABC W9XYZ 73", &
- "K1ABC W9XYZ RR73", &
- "CQ KH1/KH7Z", &
- "K1ABC RR73; W9XYZ <KH1/KH7Z> -08", &
- "CQ FD K1ABC FN42", &
- "K1ABC W9XYZ 6A WI", &
- "W9XYZ K1ABC R 2B EMA", &
- "CQ TEST K1ABC/R FN42", &
- "K1ABC/R W9XYZ EN37", &
- "W9XYZ K1ABC/R R FN42", &
- "K1ABC/R W9XYZ RR73", &
- "CQ TEST K1ABC FN42", &
- "K1ABC W9XYZ 579 WI", &
- "W9XYZ K1ABC R 589 MA", &
- "K1ABC KA0DEF 559 MO", &
- "TU; KA0DEF K1ABC R 569 MA", &
- "KA1ABC G3AAA 529 0013", &
- "TU; G3AAA K1ABC R 559 MA", &
- "CQ G4ABC/P IO91", &
- "G4ABC/P PA9XYZ JO22", &
- "PA9XYZ 590003 IO91NP", &
- "G4ABC/P R 570007 JO22DB", &
- "PA9XYZ G4ABC/P RR73", &
- "CQ PJ4/K1ABC", &
- "PJ4/K1ABC <W9XYZ>", &
- "W9XYZ <PJ4/K1ABC> -11", &
- "<PJ4/K1ABC> W9XYZ R-09", &
- "<W9XYZ> PJ4/K1ABC RRR", &
- "PJ4/K1ABC <W9XYZ> 73", &
- "CQ W9XYZ EN37", &
- "<W9XYZ> YW18FIFA", &
- "<YW18FIFA> W9XYZ -11", &
- "W9XYZ <YW18FIFA> R-09", &
- "YW18FIFA <W9XYZ> RRR", &
- "<W9XYZ> YW18FIFA 73", &
- "TNX BOB 73 GL", &
- "CQ YW18FIFA", &
- "<YW18FIFA> KA1ABC", &
- "KA1ABC <YW18FIFA> -11", &
- "<YW18FIFA> KA1ABC R-17", &
- "<KA1ABC> YW18FIFA RR73", &
- "<YW18FIFA> KA1ABC 73", &
- "123456789ABCDEF012"/
+ "TNX BOB 73 GL", & ! 0.0
+ "K1ABC RR73; W9XYZ <KH1/KH7Z> -08", & ! 0.1
+ "PA9XYZ 590003 IO91NP", & ! 0.2
+ "G4ABC/P R 570007 JO22DB", & ! 0.2
+ "K1ABC W9XYZ 6A WI", & ! 0.3
+ "W9XYZ K1ABC R 17B EMA", & ! 0.3
+ "123456789ABCDEF012", & ! 0.5
+ "CQ K1ABC FN42", & ! 1.
+ "K1ABC W9XYZ EN37", & ! 1.
+ "W9XYZ K1ABC -11", & ! 1.
+ "K1ABC W9XYZ R-09", & ! 1.
+ "W9XYZ K1ABC RRR", & ! 1.
+ "K1ABC W9XYZ 73", & ! 1.
+ "K1ABC W9XYZ RR73", & ! 1.
+ "CQ FD K1ABC FN42", & ! 1.
+ "CQ TEST K1ABC/R FN42", & ! 1.
+ "K1ABC/R W9XYZ EN37", & ! 1.
+ "W9XYZ K1ABC/R R FN42", & ! 1.
+ "K1ABC/R W9XYZ RR73", & ! 1.
+ "CQ TEST K1ABC FN42", & ! 1.
+ "W9XYZ <PJ4/K1ABC> -11", & ! 1.
+ "<PJ4/K1ABC> W9XYZ R-09", & ! 1.
+ "CQ W9XYZ EN37", & ! 1.
+ "<YW18FIFA> W9XYZ -11", & ! 1.
+ "W9XYZ <YW18FIFA> R-09", & ! 1.
+ "<YW18FIFA> KA1ABC", & ! 1.
+ "KA1ABC <YW18FIFA> -11", & ! 1.
+ "<YW18FIFA> KA1ABC R-17", & ! 1.
+ "<YW18FIFA> KA1ABC 73", & ! 1.
+ "CQ G4ABC/P IO91", & ! 2.
+ "G4ABC/P PA9XYZ JO22", & ! 2.
+ "PA9XYZ G4ABC/P RR73", & ! 2.
+ "K1ABC W9XYZ 579 WI", & ! 3.
+ "W9XYZ K1ABC R 589 MA", & ! 3.
+ "K1ABC KA0DEF 559 MO", & ! 3.
+ "TU; KA0DEF K1ABC R 569 MA", & ! 3.
+ "KA1ABC G3AAA 529 0013", & ! 3.
+ "TU; G3AAA K1ABC R 559 MA", & ! 3.
+ "CQ KH1/KH7Z", & ! 4.
+ "CQ PJ4/K1ABC", & ! 4.
+ "PJ4/K1ABC <W9XYZ>", & ! 4.
+ "<W9XYZ> PJ4/K1ABC RRR", & ! 4.
+ "PJ4/K1ABC <W9XYZ> 73", & ! 4.
+ "<W9XYZ> YW18FIFA", & ! 4.
+ "YW18FIFA <W9XYZ> RRR", & ! 4.
+ "<W9XYZ> YW18FIFA 73", & ! 4.
+ "CQ YW18FIFA", & ! 4.
+ "<KA1ABC> YW18FIFA RR73"/
diff --git a/lib/ft8/ft8apset.f90 b/lib/ft8/ft8apset.f90
index 56a18c4f..90f05b70 100644
--- a/lib/ft8/ft8apset.f90
+++ b/lib/ft8/ft8apset.f90
@@ -1,14 +1,18 @@
-subroutine ft8apset(mycall12,hiscall12,apsym)
+subroutine ft8apset(mycall12,hiscall12,ncontest,apsym,aph10)
use packjt77
character*77 c77
character*37 msg,msgchk
character*12 mycall12,hiscall12,hiscall
- integer apsym(58)
+ character*13 hc13
+ character*10 c10
+ integer apsym(58),aph10(10)
logical nohiscall,unpk77_success
apsym=0
apsym(1)=99
apsym(30)=99
+ aph10=0
+ aph10(1)=99
if(len(trim(mycall12)).lt.3) return
@@ -17,23 +21,41 @@ subroutine ft8apset(mycall12,hiscall12,apsym)
if(len(trim(hiscall)).lt.3) then
hiscall=mycall12 ! use mycall for dummy hiscall - mycall won't be hashed.
nohiscall=.true.
+ else
+ hc13=hiscall
+ n10=0
+ n12=0
+ n22=0
+ call save_hash_call(hc13,n10,n12,n22)
+ write(c10,'(b10.10)') iand(n10,Z'3FF')
+ read(c10,'(10i1.1)',err=1) aph10
+ aph10=2*aph10-1
endif
! Encode a dummy standard message: i3=1, 28 1 28 1 1 15
!
msg=trim(mycall12)//' '//trim(hiscall)//' RRR'
+ i3=0
+ n3=0
call pack77(msg,i3,n3,c77)
call unpack77(c77,1,msgchk,unpk77_success)
+ if(ncontest.eq.7.and. (i3.ne.1 .or. .not.unpk77_success)) return
+ if(ncontest.le.5.and. (i3.ne.1 .or. msg.ne.msgchk .or. .not.unpk77_success)) return
- if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_success) return
-
- read(c77,'(58i1)',err=1) apsym(1:58)
+ read(c77,'(58i1)',err=2) apsym(1:58)
apsym=2*apsym-1
- if(nohiscall) apsym(30)=99
+ if(nohiscall) then
+ apsym(30)=99
+ aph10(1)=99
+ endif
return
-1 apsym=0
+1 aph10=0
+ aph10(1)=99
+ return
+2 apsym=0
apsym(1)=99
apsym(30)=99
return
+
end subroutine ft8apset
diff --git a/lib/ft8/ft8b.f90 b/lib/ft8/ft8b.f90
index 0376311f..b92bde34 100644
--- a/lib/ft8/ft8b.f90
+++ b/lib/ft8/ft8b.f90
@@ -1,6 +1,7 @@
-subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
- napwid,lsubtract,nagain,ncontest,iaptype,mycall12,hiscall12, &
- sync0,f1,xdt,xbase,apsym,nharderrors,dmin,nbadcrc,ipass,iera,msg37,xsnr)
+subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,nzhsym,lapon, &
+ lapcqonly,napwid,lsubtract,nagain,ncontest,iaptype,mycall12,hiscall12, &
+ f1,xdt,xbase,apsym,aph10,nharderrors,dmin,nbadcrc,ipass, &
+ msg37,xsnr,itone)
use crc
use timer_module, only: timer
@@ -13,12 +14,13 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
real a(5)
real s8(0:7,NN)
real s2(0:511)
- real bmeta(174),bmetb(174),bmetc(174)
- real llra(174),llrb(174),llrc(174),llrd(174) !Soft symbols
+ real bmeta(174),bmetb(174),bmetc(174),bmetd(174)
+ real llra(174),llrb(174),llrc(174),llrd(174),llrz(174) !Soft symbols
real dd0(15*12000)
- integer*1 message77(77),apmask(174),cw(174)
- integer apsym(58)
- integer mcq(29),mcqru(29),mcqfd(29),mcqtest(29)
+ real ss(9)
+ integer*1 message77(77),message91(91),apmask(174),cw(174)
+ integer apsym(58),aph10(10)
+ integer mcq(29),mcqru(29),mcqfd(29),mcqtest(29),mcqww(29)
integer mrrr(19),m73(19),mrr73(19)
integer itone(NN)
integer icos7(0:6),ip(1)
@@ -27,6 +29,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
integer ncontest,ncontest0
logical one(0:511,0:8)
integer graymap(0:7)
+ integer iloc(1)
complex cd0(0:3199)
complex ctwk(32)
complex csymb(32)
@@ -37,6 +40,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
data mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/
data mcqfd/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0/
data mcqtest/0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0/
+ data mcqww/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,1,1,1,1,0/
data mrrr/0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1/
data m73/0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,0,0,0,1/
data mrr73/0,1,1,1,1,1,1,0,0,1,1,1,0,1,0,1,0,0,1/
@@ -44,12 +48,12 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
data graymap/0,1,3,2,5,6,4,7/
save nappasses,naptypes,ncontest0,one
-
if(first.or.(ncontest.ne.ncontest0)) then
mcq=2*mcq-1
mcqfd=2*mcqfd-1
mcqru=2*mcqru-1
mcqtest=2*mcqtest-1
+ mcqww=2*mcqww-1
mrrr=2*mrrr-1
m73=2*m73-1
mrr73=2*mrr73-1
@@ -86,7 +90,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
ncontest0=ncontest
endif
- dxcall13=hiscall12
+ dxcall13=hiscall12 ! initialize for use in packjt77
mycall13=mycall12
max_iterations=30
@@ -104,17 +108,15 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
i0=nint((xdt+0.5)*fs2) !Initial guess for start of signal
smax=0.0
- do idt=i0-8,i0+8 !Search over +/- one quarter symbol
+ do idt=i0-10,i0+10 !Search over +/- one quarter symbol
call sync8d(cd0,idt,ctwk,0,sync)
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
do ifr=-5,5 !Search over +/- 2.5 Hz
delf=ifr*0.5
@@ -124,7 +126,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
ctwk(i)=cmplx(cos(phi),sin(phi))
phi=mod(phi+dphi,twopi)
enddo
- call sync8d(cd0,i0,ctwk,1,sync)
+ call sync8d(cd0,ibest,ctwk,1,sync)
if( sync .gt. smax ) then
smax=sync
delfbest=delf
@@ -133,9 +135,22 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
a=0.0
a(1)=-delfbest
call twkfreq1(cd0,NP2,fs2,a,cd0)
- xdt=xdt2
f1=f1+delfbest !Improved estimate of DF
- call sync8d(cd0,i0,ctwk,0,sync)
+
+ call timer('ft8_down',0)
+ call ft8_downsample(dd0,.false.,f1,cd0) !Mix f1 to baseband and downsample
+ call timer('ft8_down',1)
+
+ smax=0.0
+ do idt=-4,4 !Search over +/- one quarter symbol
+ call sync8d(cd0,ibest+idt,ctwk,0,sync)
+ ss(idt+5)=sync
+ enddo
+ smax=maxval(ss)
+ iloc=maxloc(ss)
+ ibest=iloc(1)-5+ibest
+ xdt=(ibest-1)*dt2
+ sync=smax
do k=1,NN
i1=ibest+(k-1)*32
@@ -196,6 +211,14 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
if(i32+ib .gt.174) cycle
if(nsym.eq.1) then
bmeta(i32+ib)=bm
+ den=max(maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)), &
+ maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib)))
+ if(den.gt.0.0) then
+ cm=bm/den
+ else ! erase it
+ cm=0.0
+ endif
+ bmetd(i32+ib)=cm
elseif(nsym.eq.2) then
bmetb(i32+ib)=bm
elseif(nsym.eq.3) then
@@ -208,11 +231,13 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
call normalizebmet(bmeta,174)
call normalizebmet(bmetb,174)
call normalizebmet(bmetc,174)
+ call normalizebmet(bmetd,174)
scalefac=2.83
llra=scalefac*bmeta
llrb=scalefac*bmetb
llrc=scalefac*bmetc
+ llrd=scalefac*bmetd
apmag=maxval(abs(llra))*1.01
@@ -221,34 +246,36 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
! 1 regular decoding, nsym=1
! 2 regular decoding, nsym=2
! 3 regular decoding, nsym=3
-! 4 ap pass 1, nsym=1 (for now?)
-! 5 ap pass 2
-! 6 ap pass 3
-! 7 ap pass 4
+! 4 regular decoding, nsym=1, bit-by-bit normalized
+! 5 ap pass 1, nsym=1
+! 6 ap pass 2
+! 7 ap pass 3
+! 8 ap pass 4
- if(lapon.or.ncontest.eq.6) then !Hounds always use AP
+ if(lapon.or.ncontest.eq.7) then !Hounds always use AP
if(.not.lapcqonly) then
- npasses=3+nappasses(nQSOProgress)
+ npasses=4+nappasses(nQSOProgress)
else
- npasses=4
+ npasses=5
endif
else
- npasses=3
+ npasses=4
endif
-
+ if(nzhsym.lt.50) npasses=4
+
do ipass=1,npasses
- llrd=llra
- if(ipass.eq.2) llrd=llrb
- if(ipass.eq.3) llrd=llrc
- if(ipass.le.3) then
+ llrz=llra
+ if(ipass.eq.2) llrz=llrb
+ if(ipass.eq.3) llrz=llrc
+ if(ipass.eq.4) llrz=llrd
+ if(ipass.le.4) then
apmask=0
iaptype=0
endif
-
- if(ipass .gt. 3) then
- llrd=llra
+ if(ipass .gt. 4) then
+ llrz=llra
if(.not.lapcqonly) then
- iaptype=naptypes(nQSOProgress,ipass-3)
+ iaptype=naptypes(nQSOProgress,ipass-4)
else
iaptype=1
endif
@@ -258,129 +285,138 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
! 2 : EU_VHF
! 3 : FIELD DAY
! 4 : RTTY
-! 5 : FOX
-! 6 : HOUND
+! 5 : WW_DIGI
+! 6 : FOX
+! 7 : HOUND
!
! Conditions that cause us to bail out of AP decoding
- if(ncontest.le.4 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle
- if(ncontest.eq.5) cycle ! No AP for Foxes
- if(ncontest.eq.6.and.f1.gt.950.0) cycle ! Hounds use AP only for signals below 950 Hz
+ if(ncontest.le.5 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle
+ if(ncontest.eq.6) cycle ! No AP for Foxes
+ if(ncontest.eq.7.and.f1.gt.950.0) cycle ! Hounds use AP only for signals below 950 Hz
if(iaptype.ge.2 .and. apsym(1).gt.1) cycle ! No, or nonstandard, mycall
+ if(ncontest.eq.7 .and. iaptype.ge.2 .and. aph10(1).gt.1) cycle
if(iaptype.ge.3 .and. apsym(30).gt.1) cycle ! No, or nonstandard, dxcall
if(iaptype.eq.1) then ! CQ or CQ RU or CQ TEST or CQ FD
apmask=0
apmask(1:29)=1
- if(ncontest.eq.0) llrd(1:29)=apmag*mcq(1:29)
- if(ncontest.eq.1) llrd(1:29)=apmag*mcqtest(1:29)
- if(ncontest.eq.2) llrd(1:29)=apmag*mcqtest(1:29)
- if(ncontest.eq.3) llrd(1:29)=apmag*mcqfd(1:29)
- if(ncontest.eq.4) llrd(1:29)=apmag*mcqru(1:29)
- if(ncontest.eq.6) llrd(1:29)=apmag*mcq(1:29)
+ if(ncontest.eq.0) llrz(1:29)=apmag*mcq(1:29)
+ if(ncontest.eq.1) llrz(1:29)=apmag*mcqtest(1:29)
+ if(ncontest.eq.2) llrz(1:29)=apmag*mcqtest(1:29)
+ if(ncontest.eq.3) llrz(1:29)=apmag*mcqfd(1:29)
+ if(ncontest.eq.4) llrz(1:29)=apmag*mcqru(1:29)
+ if(ncontest.eq.5) llrz(1:29)=apmag*mcqww(1:29)
+ if(ncontest.eq.7) llrz(1:29)=apmag*mcq(1:29)
apmask(75:77)=1
- llrd(75:76)=apmag*(-1)
- llrd(77)=apmag*(+1)
+ llrz(75:76)=apmag*(-1)
+ llrz(77)=apmag*(+1)
endif
if(iaptype.eq.2) then ! MyCall,???,???
apmask=0
- if(ncontest.eq.0.or.ncontest.eq.1) then
+ if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.5) then
apmask(1:29)=1
- llrd(1:29)=apmag*apsym(1:29)
+ llrz(1:29)=apmag*apsym(1:29)
apmask(75:77)=1
- llrd(75:76)=apmag*(-1)
- llrd(77)=apmag*(+1)
+ llrz(75:76)=apmag*(-1)
+ llrz(77)=apmag*(+1)
else if(ncontest.eq.2) then
apmask(1:28)=1
- llrd(1:28)=apmag*apsym(1:28)
+ llrz(1:28)=apmag*apsym(1:28)
apmask(72:74)=1
- llrd(72)=apmag*(-1)
- llrd(73)=apmag*(+1)
- llrd(74)=apmag*(-1)
+ llrz(72)=apmag*(-1)
+ llrz(73)=apmag*(+1)
+ llrz(74)=apmag*(-1)
apmask(75:77)=1
- llrd(75:77)=apmag*(-1)
+ llrz(75:77)=apmag*(-1)
else if(ncontest.eq.3) then
apmask(1:28)=1
- llrd(1:28)=apmag*apsym(1:28)
+ llrz(1:28)=apmag*apsym(1:28)
apmask(75:77)=1
- llrd(75:77)=apmag*(-1)
+ llrz(75:77)=apmag*(-1)
else if(ncontest.eq.4) then
apmask(2:29)=1
- llrd(2:29)=apmag*apsym(1:28)
+ llrz(2:29)=apmag*apsym(1:28)
apmask(75:77)=1
- llrd(75)=apmag*(-1)
- llrd(76:77)=apmag*(+1)
- else if(ncontest.eq.6) then ! ??? RR73; MyCall <???> ???
+ llrz(75)=apmag*(-1)
+ llrz(76:77)=apmag*(+1)
+ else if(ncontest.eq.7) then ! ??? RR73; MyCall <Fox Call hash10> ???
apmask(29:56)=1
- llrd(29:56)=apmag*apsym(1:28)
+ llrz(29:56)=apmag*apsym(1:28)
+ apmask(57:66)=1
+ llrz(57:66)=apmag*aph10(1:10)
apmask(72:77)=1
- llrd(72:73)=apmag*(-1)
- llrd(74)=apmag*(+1)
- llrd(75:77)=apmag*(-1)
+ llrz(72:73)=apmag*(-1)
+ llrz(74)=apmag*(+1)
+ llrz(75:77)=apmag*(-1)
endif
endif
if(iaptype.eq.3) then ! MyCall,DxCall,???
apmask=0
- if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.6) then
+ if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.5.or.ncontest.eq.7) then
apmask(1:58)=1
- llrd(1:58)=apmag*apsym
+ llrz(1:58)=apmag*apsym
apmask(75:77)=1
- llrd(75:76)=apmag*(-1)
- llrd(77)=apmag*(+1)
+ llrz(75:76)=apmag*(-1)
+ llrz(77)=apmag*(+1)
else if(ncontest.eq.3) then ! Field Day
apmask(1:56)=1
- llrd(1:28)=apmag*apsym(1:28)
- llrd(29:56)=apmag*apsym(30:57)
+ llrz(1:28)=apmag*apsym(1:28)
+ llrz(29:56)=apmag*apsym(30:57)
apmask(72:74)=1
apmask(75:77)=1
- llrd(75:77)=apmag*(-1)
- else if(ncontest.eq.4) then ! RTTY RU
+ llrz(75:77)=apmag*(-1)
+ else if(ncontest.eq.4) then
apmask(2:57)=1
- llrd(2:29)=apmag*apsym(1:28)
- llrd(30:57)=apmag*apsym(30:57)
+ llrz(2:29)=apmag*apsym(1:28)
+ llrz(30:57)=apmag*apsym(30:57)
apmask(75:77)=1
- llrd(75)=apmag*(-1)
- llrd(76:77)=apmag*(+1)
+ llrz(75)=apmag*(-1)
+ llrz(76:77)=apmag*(+1)
endif
endif
- if(iaptype.eq.5.and.ncontest.eq.6) cycle !Hound
+ if(iaptype.eq.5.and.ncontest.eq.7) cycle !Hound
if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then
apmask=0
- if(ncontest.le.4 .or. (ncontest.eq.6.and.iaptype.eq.6)) then
+ if(ncontest.le.5 .or. (ncontest.eq.7.and.iaptype.eq.6)) then
apmask(1:77)=1 ! mycall, hiscall, RRR|73|RR73
- llrd(1:58)=apmag*apsym
- if(iaptype.eq.4) llrd(59:77)=apmag*mrrr
- if(iaptype.eq.5) llrd(59:77)=apmag*m73
- if(iaptype.eq.6) llrd(59:77)=apmag*mrr73
- else if(ncontest.eq.6.and.iaptype.eq.4) then ! Hound listens for MyCall RR73;...
+ llrz(1:58)=apmag*apsym
+ if(iaptype.eq.4) llrz(59:77)=apmag*mrrr
+ if(iaptype.eq.5) llrz(59:77)=apmag*m73
+ if(iaptype.eq.6) llrz(59:77)=apmag*mrr73
+ else if(ncontest.eq.7.and.iaptype.eq.4) then ! Hound listens for MyCall RR73;...
apmask(1:28)=1
- llrd(1:28)=apmag*apsym(1:28)
+ llrz(1:28)=apmag*apsym(1:28)
+ apmask(57:66)=1
+ llrz(57:66)=apmag*aph10(1:10)
apmask(72:77)=1
- llrd(72:73)=apmag*(-1)
- llrd(74)=apmag*(1)
- llrd(75:77)=apmag*(-1)
+ llrz(72:73)=apmag*(-1)
+ llrz(74)=apmag*(1)
+ llrz(75:77)=apmag*(-1)
endif
endif
endif
cw=0
- call timer('bpd174_91 ',0)
- call bpdecode174_91(llrd,apmask,max_iterations,message77,cw,nharderrors, &
- niterations)
- call timer('bpd174_91 ',1)
dmin=0.0
- if(ndepth.eq.3 .and. nharderrors.lt.0) then
- ndeep=3
- if(abs(nfqso-f1).le.napwid .or. abs(nftx-f1).le.napwid) then
- ndeep=4
- endif
- if(nagain) ndeep=5
- call timer('osd174_91 ',0)
- call osd174_91(llrd,apmask,ndeep,message77,cw,nharderrors,dmin)
- call timer('osd174_91 ',1)
+ norder=2
+ maxosd=2
+ if(ndepth.lt.3) maxosd=1
+ if(abs(nfqso-f1).le.napwid .or. abs(nftx-f1).le.napwid .or. ncontest.eq.7) then
+ maxosd=2
+ endif
+ if(nagain) then
+ norder=3
+ maxosd=1
endif
+ call timer('dec174_91 ',0)
+ Keff=91
+ call decode174_91(llrz,Keff,maxosd,norder,apmask,message91,cw, &
+ ntype,nharderrors,dmin)
+ if(nharderrors.ge.0) message77=message91(1:77)
+ call timer('dec174_91 ',1)
msg37=' '
if(nharderrors.lt.0 .or. nharderrors.gt.36) cycle
@@ -388,16 +424,18 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
write(c77,'(77i1)') message77
read(c77(72:74),'(b3)') n3
read(c77(75:77),'(b3)') i3
- if(i3.gt.4 .or. (i3.eq.0.and.n3.gt.5)) then
- cycle
- endif
+ if(i3.gt.5 .or. (i3.eq.0.and.n3.gt.6)) cycle
call unpack77(c77,1,msg37,unpk77_success)
if(.not.unpk77_success) then
cycle
endif
nbadcrc=0 ! If we get this far: valid codeword, valid (i3,n3), nonquirky message.
call get_ft8_tones_from_77bits(message77,itone)
- if(lsubtract) call subtractft8(dd0,itone,f1,xdt)
+ if(lsubtract) then
+ call timer('sub_ft8a',0)
+ call subtractft8(dd0,itone,f1,xdt,.false.)
+ call timer('sub_ft8a',1)
+ endif
xsig=0.0
xnoi=0.0
do i=1,79
@@ -409,16 +447,19 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
xsnr2=0.001
arg=xsig/xnoi-1.0
if(arg.gt.0.1) xsnr=arg
- arg=xsig/xbase/2.6e6-1.0
+ arg=xsig/xbase/3.0e6-1.0
if(arg.gt.0.1) xsnr2=arg
xsnr=10.0*log10(xsnr)-27.0
xsnr2=10.0*log10(xsnr2)-27.0
if(.not.nagain) then
xsnr=xsnr2
- endif
- if(xsnr .lt. -24.0) xsnr=-24.0
-
- return
+ endif
+ if(nsync.le.7 .and. xsnr.lt.-24.0) then !bail out, likely false decode
+ nbadcrc=1
+ return
+ endif
+ if(xsnr .lt. -24.0) xsnr=-24.0
+ return
enddo
return
end subroutine ft8b
diff --git a/lib/ft8/ft8code.f90 b/lib/ft8/ft8code.f90
index cbafd34b..8d5b5279 100644
--- a/lib/ft8/ft8code.f90
+++ b/lib/ft8/ft8code.f90
@@ -12,7 +12,8 @@ program ft8code
character*9 comment
character bad*1,msgtype*18
integer itone(NN)
- integer*1 msgbits(77)
+ integer*1 msgbits(77),codeword(174)
+ logical short
! Get command-line argument(s)
nargs=iargc()
@@ -23,19 +24,22 @@ program ft8code
print*,'bit and symbol ordering, and other details of the FT8 protocol.'
print*
print*,'Usage: ft8code [-c grid] "message" # Results for specified message'
- print*,' ft8code -t # Examples of all message types'
+ print*,' ft8code -T # Examples of all message types'
+ print*,' ft8code -t # Short format examples'
go to 999
endif
call getarg(1,msg) !Message to be transmitted
- if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-t') then
+ short=.false.
+ if(len(trim(msg)).eq.2 .and. (msg(1:2).eq.'-T' .or. msg(1:2).eq.'-t')) then
nmsg=NTEST
+ short=msg(1:2).eq.'-t'
else
call fmtmsg(msg,iz) !To upper case; collapse multiple blanks
nmsg=1
endif
- write(*,1010)
+ if(.not.short) write(*,1010)
1010 format(4x,'Message',31x,'Decoded',29x,'Err i3.n3'/100('-'))
do imsg=1,nmsg
@@ -45,6 +49,7 @@ program ft8code
i3=-1
n3=-1
call genft8(msg,i3,n3,msgsent,msgbits,itone)
+ call encode174_91(msgbits,codeword)
msgtype=""
if(i3.eq.0) then
if(n3.eq.0) msgtype="Free text"
@@ -58,26 +63,42 @@ program ft8code
if(i3.eq.1) msgtype="Standard msg"
if(i3.eq.2) msgtype="EU VHF Contest"
if(i3.eq.3) msgtype="ARRL RTTY Roundup"
- if(i3.eq.4) msgtype="Nonstandard calls"
- if(i3.ge.5) msgtype="Undefined msg type"
+ if(i3.eq.4) msgtype="Nonstandard call"
+ if(i3.ge.5) msgtype="Undefined type"
if(i3.ge.1) n3=-1
bad=" "
comment=' '
if(msg.ne.msgsent) bad="*"
- if(n3.ge.0) then
- write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype,comment
-1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9)
+ if(short) then
+ if(n3.ge.0) then
+ write(*,1020) i3,n3,msg,bad,msgtype
+1020 format(i1,'.',i1,2x,a37,1x,a1,1x,a18)
+ else
+ write(*,1022) i3,msg,bad,msgtype
+1022 format(i1,'.',3x,a37,1x,a1,1x,a18)
+ endif
else
- write(*,1022) imsg,msg,msgsent,bad,i3,msgtype,comment
-1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9)
+ if(n3.ge.0) then
+ write(*,1024) imsg,msg,msgsent,bad,i3,n3,msgtype,comment
+1024 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9)
+ else
+ write(*,1026) imsg,msg,msgsent,bad,i3,msgtype,comment
+1026 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9)
+ endif
endif
enddo
if(nmsg.eq.1) then
write(*,1030) msgbits
-1030 format(/'Message bits: ',/77i1)
+1030 format(/'Source-encoded message, 77 bits: ',/77i1)
+ write(*,1031) codeword(78:91)
+1031 format(/'14-bit CRC: ',/14i1)
+ write(*,1032) codeword(92:174)
+1032 format(/'83 Parity bits: ',/83i1)
write(*,1034) itone
-1034 format(/'Channel symbols (tones):'/79i1)
+1034 format(/'Channel symbols (79 tones):'/ &
+ ' Sync ',14x,'Data',15x,'Sync',15x,'Data',15x,'Sync'/ &
+ 7i1,1x,29i1,1x,7i1,1x,29i1,1x,7i1)
endif
999 end program ft8code
diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90
index c5dd82bb..42931635 100644
--- a/lib/ft8/ft8sim.f90
+++ b/lib/ft8/ft8sim.f90
@@ -1,4 +1,4 @@
-program ft8sim
+program ft8sim_gfsk
! Generate simulated "type 2" ft8 files
! Output is saved to a *.wav file.
@@ -13,18 +13,21 @@ program ft8sim
character c77*77
complex c0(0:NMAX-1)
complex c(0:NMAX-1)
+ complex cwave(0:NWAVE-1)
real wave(NMAX)
+ real xjunk(NWAVE)
integer itone(NN)
integer*1 msgbits(77)
integer*2 iwave(NMAX) !Generated full-length waveform
! Get command-line argument(s)
nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: ft8sim "message" f0 DT fdop del width nfiles snr'
- print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18'
- print*,' ft8sim "WA9XYZ/R KA1ABC/R FN42" 1500.0 0.0 0.1 1.0 0 10 -18'
+ if(nargs.ne.7) then
+ print*,'Usage: ft8sim "message" f0 DT fdop del nfiles snr'
+ print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 10 -18'
+ print*,' ft8sim "WA9XYZ/R KA1ABC/R FN42" 1500.0 0.0 0.1 1.0 10 -18'
print*,' ft8sim "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 300 0 0 0 25 1 -10'
+ print*,' ft8sim "<G4ABC/P> <PA9XYZ> R 570007 JO22DB" 1500 0 0 0 1 -10'
go to 999
endif
call getarg(1,msg37) !Message to be transmitted
@@ -37,10 +40,8 @@ program ft8sim
call getarg(5,arg)
read(arg,*) delay !Watterson delay (ms)
call getarg(6,arg)
- read(arg,*) width !Filter transition width (Hz)
- call getarg(7,arg)
read(arg,*) nfiles !Number of files
- call getarg(8,arg)
+ call getarg(7,arg)
read(arg,*) snrdb !SNR_2500
nsig=1
@@ -57,6 +58,7 @@ program ft8sim
baud=1.0/tt !Keying rate (baud)
bw=8*baud !Occupied bandwidth (Hz)
txt=NZ*dt !Transmission length (s)
+ bt=2.0
bandwidth_ratio=2500.0/(fs/2.0)
sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0
@@ -67,9 +69,10 @@ program ft8sim
n3=-1
call pack77(msg37,i3,n3,c77)
call genft8(msg37,i3,n3,msgsent37,msgbits,itone)
+ call gen_ft8wave(itone,NN,NSPS,bt,fs,f0,cwave,xjunk,1,NWAVE) !Generate complex cwave
write(*,*)
- write(*,'(a23,a37,3x,a7,i1,a1,i1)') 'New Style FT8 Message: ',msgsent37,'i3.n3: ',i3,'.',n3
+ write(*,'(a23,a37,3x,a7,i1,a1,i1)') 'Decoded message: ',msgsent37,'i3.n3: ',i3,'.',n3
write(*,1000) f0,xdt,txt,snrdb,bw
1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, &
' BW:',f4.1)
@@ -90,26 +93,15 @@ program ft8sim
msg0=msg
do ifile=1,nfiles
- k=nint((xdt+0.5)/dt)
- ia=max(1,k)
- phi=0.0
- c0=0.0
- do j=1,NN !Generate complex waveform
- dphi=twopi*(f0*dt+itone(j)/real(NSPS))
- do i=1,NSPS
- if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi))
- k=k+1
- phi=mod(phi+dphi,twopi)
- enddo
- enddo
+ c0=0.
+ c0(0:NWAVE-1)=cwave
+ c0=cshift(c0,-nint((xdt+0.5)/dt))
if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,NWAVE,fs,delay,fspread)
c=sig*c0
- ib=min(k,NMAX)
- wave=real(c)
- peak=maxval(abs(wave(ia:ib)))
+ wave=imag(c)
+ peak=maxval(abs(wave))
nslots=1
- if(width.gt.0.0) call filt8(f0,nslots,width,wave)
if(snrdb.lt.90) then
do i=1,NMAX !Add gaussian noise at specified SNR
@@ -128,7 +120,6 @@ program ft8sim
endif
if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped."
iwave=nint(wave)
-
h=default_header(12000,NMAX)
write(fname,1102) ifile
1102 format('000000_',i6.6,'.wav')
@@ -138,4 +129,4 @@ program ft8sim
write(*,1110) ifile,xdt,f0,snrdb,fname
1110 format(i4,f7.2,f8.2,f7.1,2x,a17)
enddo
-999 end program ft8sim
+999 end program ft8sim_gfsk
diff --git a/lib/ft8/ft8sim_gfsk.f90 b/lib/ft8/ft8sim_gfsk.f90
deleted file mode 100644
index 4cca67e4..00000000
--- a/lib/ft8/ft8sim_gfsk.f90
+++ /dev/null
@@ -1,131 +0,0 @@
-program ft8sim_gfsk
-
-! Generate simulated "type 2" ft8 files
-! Output is saved to a *.wav file.
-
- use wavhdr
- use packjt77
- include 'ft8_params.f90' !Set various constants
- parameter (NWAVE=NN*NSPS)
- type(hdr) h !Header for .wav file
- character arg*12,fname*17
- character msg37*37,msgsent37*37
- character c77*77
- complex c0(0:NMAX-1)
- complex c(0:NMAX-1)
- complex cwave(0:NWAVE-1)
- real wave(NMAX)
- real xjunk(NWAVE)
- integer itone(NN)
- integer*1 msgbits(77)
- integer*2 iwave(NMAX) !Generated full-length waveform
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.7) then
- print*,'Usage: ft8sim "message" f0 DT fdop del nfiles snr'
- print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 10 -18'
- print*,' ft8sim "WA9XYZ/R KA1ABC/R FN42" 1500.0 0.0 0.1 1.0 10 -18'
- print*,' ft8sim "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 300 0 0 0 25 1 -10'
- go to 999
- endif
- call getarg(1,msg37) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Frequency (only used for single-signal)
- call getarg(3,arg)
- read(arg,*) xdt !Time offset from nominal (s)
- call getarg(4,arg)
- read(arg,*) fspread !Watterson frequency spread (Hz)
- call getarg(5,arg)
- read(arg,*) delay !Watterson delay (ms)
- call getarg(6,arg)
- read(arg,*) nfiles !Number of files
- call getarg(7,arg)
- read(arg,*) snrdb !SNR_2500
-
- nsig=1
- if(f0.lt.100.0) then
- nsig=f0
- f0=1500
- endif
-
- nfiles=abs(nfiles)
- twopi=8.0*atan(1.0)
- fs=12000.0 !Sample rate (Hz)
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of symbols (s)
- baud=1.0/tt !Keying rate (baud)
- bw=8*baud !Occupied bandwidth (Hz)
- txt=NZ*dt !Transmission length (s)
- bt=2.0
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS/12000.0
-
- ! Source-encode, then get itone()
- i3=-1
- n3=-1
- call pack77(msg37,i3,n3,c77)
- call genft8(msg37,i3,n3,msgsent37,msgbits,itone)
- call gen_ft8wave(itone,NN,NSPS,bt,fs,f0,cwave,xjunk,1,NWAVE) !Generate complex cwave
-
- write(*,*)
- write(*,'(a23,a37,3x,a7,i1,a1,i1)') 'New Style FT8 Message: ',msgsent37,'i3.n3: ',i3,'.',n3
- write(*,1000) f0,xdt,txt,snrdb,bw
-1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, &
- ' BW:',f4.1)
- write(*,*)
- if(i3.eq.1) then
- write(*,*) ' mycall hiscall hisgrid'
- write(*,'(28i1,1x,i1,1x,28i1,1x,i1,1x,i1,1x,15i1,1x,3i1)') msgbits(1:77)
- else
- write(*,'(a14)') 'Message bits: '
- write(*,'(77i1)') msgbits
- endif
- write(*,*)
- write(*,'(a17)') 'Channel symbols: '
- write(*,'(79i1)') itone
- write(*,*)
-
- call sgran()
-
- msg0=msg
- do ifile=1,nfiles
- c0=0.
- c0(0:NWAVE-1)=cwave
- c0=cshift(c0,-nint((xdt+0.5)/dt))
- if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,NWAVE,fs,delay,fspread)
- c=sig*c0
-
- wave=imag(c)
- peak=maxval(abs(wave))
- nslots=1
-
- if(snrdb.lt.90) then
- do i=1,NMAX !Add gaussian noise at specified SNR
- xnoise=gran()
- wave(i)=wave(i) + xnoise
- enddo
- endif
-
- gain=100.0
- if(snrdb.lt.90.0) then
- wave=gain*wave
- else
- datpk=maxval(abs(wave))
- fac=32766.9/datpk
- wave=fac*wave
- endif
- if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped."
- iwave=nint(wave)
- h=default_header(12000,NMAX)
- write(fname,1102) ifile
-1102 format('000000_',i6.6,'.wav')
- open(10,file=fname,status='unknown',access='stream')
- write(10) h,iwave !Save to *.wav file
- close(10)
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a17)
- enddo
-999 end program ft8sim_gfsk
diff --git a/lib/ft8/gen_ft8wave.f90 b/lib/ft8/gen_ft8wave.f90
index 10edc994..02e7fdbd 100644
--- a/lib/ft8/gen_ft8wave.f90
+++ b/lib/ft8/gen_ft8wave.f90
@@ -2,15 +2,15 @@ subroutine gen_ft8wave(itone,nsym,nsps,bt,fsample,f0,cwave,wave,icmplx,nwave)
!
! generate ft8 waveform using Gaussian-filtered frequency pulses.
!
-
- parameter(MAX_SECONDS=20)
+ use timer_module, only: timer
+ parameter(MAX_SECONDS=20,NTAB=65536)
real wave(nwave)
- complex cwave(nwave)
+ complex cwave(nwave),ctab(0:NTAB-1)
real pulse(23040)
real dphi(0:(nsym+2)*nsps-1)
integer itone(nsym)
data ibt0/0/
- save pulse,twopi,dt,hmod,ibt0
+ save pulse,twopi,dt,hmod,ibt0,ctab
ibt=nint(10*bt)
if(ibt0.ne.ibt) then
@@ -23,6 +23,10 @@ subroutine gen_ft8wave(itone,nsym,nsps,bt,fsample,f0,cwave,wave,icmplx,nwave)
pulse(i)=gfsk_pulse(bt,tt)
enddo
ibt0=nint(10*bt)
+ do i=0,NTAB-1
+ phi=i*twopi/NTAB
+ ctab(i)=cmplx(cos(phi),sin(phi))
+ enddo
endif
! Compute the smoothed frequency waveform.
@@ -40,19 +44,23 @@ subroutine gen_ft8wave(itone,nsym,nsps,bt,fsample,f0,cwave,wave,icmplx,nwave)
! Calculate and insert the audio waveform
phi=0.0
- dphi = dphi + twopi*f0*dt !Shift frequency up by f0
+ dphi = dphi + twopi*f0*dt !Shift frequency up by f0
wave=0.
- if (icmplx .ne. 0) cwave=0. ! avoid writing to memory we may not have access to
+ if(icmplx .ne. 0) cwave=0. !Avoid writing to memory we may not have access to
+
+ call timer('gen_loop',0)
k=0
- do j=nsps,nsps+nwave-1 !Don't include dummy symbols
+ do j=nsps,nsps+nwave-1 !Don't include dummy symbols
k=k+1
if(icmplx.eq.0) then
wave(k)=sin(phi)
else
- cwave(k)=cmplx(cos(phi),sin(phi))
+ i=phi*float(NTAB)/twopi
+ cwave(k)=ctab(i)
endif
phi=mod(phi+dphi(j),twopi)
enddo
+ call timer('gen_loop',1)
! Apply envelope shaping to the first and last symbols
nramp=nint(nsps/8.0)
diff --git a/lib/ft8/get_crc14.f90 b/lib/ft8/get_crc14.f90
new file mode 100644
index 00000000..63580897
--- /dev/null
+++ b/lib/ft8/get_crc14.f90
@@ -0,0 +1,25 @@
+subroutine get_crc14(mc,len,ncrc)
+!
+! 1. To calculate 14-bit CRC, mc(1:len-14) is the message and mc(len-13:len) are zero.
+! 2. To check a received CRC, mc(1:len is the received message plus CRC.
+! ncrc will be zero if the received message/CRC are consistent
+!
+ character c14*14
+ integer*1 mc(len)
+ integer*1 r(15),p(15)
+ integer ncrc
+! polynomial for 14-bit CRC 0x6757
+ data p/1,1,0,0,1,1,1,0,1,0,1,0,1,1,1/
+
+! divide by polynomial
+ r=mc(1:15)
+ do i=0,len-15
+ r(15)=mc(i+15)
+ r=mod(r+r(1)*p,2)
+ r=cshift(r,1)
+ enddo
+
+ write(c14,'(14b1)') r(1:14)
+ read(c14,'(b14.14)') ncrc
+
+end subroutine get_crc14
diff --git a/lib/ft8/get_spectrum_baseline.f90 b/lib/ft8/get_spectrum_baseline.f90
new file mode 100644
index 00000000..9cf4e637
--- /dev/null
+++ b/lib/ft8/get_spectrum_baseline.f90
@@ -0,0 +1,43 @@
+subroutine get_spectrum_baseline(dd,nfa,nfb,sbase)
+
+ include 'ft8_params.f90'
+ parameter(NST=NFFT1/2,NF=93) !NF=NMAX/NST-1
+ real s(NH1,NF)
+ real savg(NH1)
+ real sbase(NH1)
+ real x(NFFT1)
+ real window(NFFT1)
+ complex cx(0:NH1)
+ real dd(NMAX)
+ equivalence (x,cx)
+ logical first
+ data first/.true./
+ save first,window
+
+ if(first) then
+ first=.false.
+ pi=4.0*atan(1.)
+ window=0.
+ call nuttal_window(window,NFFT1)
+ window=window/sum(window)*NSPS*2/300.0
+ endif
+
+! Compute symbol spectra, stepping by NSTEP steps.
+ savg=0.
+ df=12000.0/NFFT1
+ do j=1,NF
+ ia=(j-1)*NST + 1
+ ib=ia+NFFT1-1
+ if(ib.gt.NMAX) exit
+ x=dd(ia:ib)*window
+ call four2a(x,NFFT1,1,-1,0) !r2c FFT
+ s(1:NH1,j)=abs(cx(1:NH1))**2
+ savg=savg + s(1:NH1,j) !Average spectrum
+ enddo
+
+ if(nfa.lt.100) nfa=100
+ if(nfb.gt.4910) nfb=4910
+ call baseline(savg,nfa,nfb,sbase)
+
+return
+end subroutine get_spectrum_baseline
diff --git a/lib/ft8/ldpc_174_91_c_parity.f90 b/lib/ft8/ldpc_174_91_c_parity.f90
index 6210ee26..2309ad8e 100644
--- a/lib/ft8/ldpc_174_91_c_parity.f90
+++ b/lib/ft8/ldpc_174_91_c_parity.f90
@@ -1,88 +1,5 @@
-data Mn/ &
- 1, 24, 66, &
- 2, 5, 70, &
- 3, 31, 65, &
- 4, 49, 58, &
- 6, 60, 67, &
- 7, 32, 75, &
- 8, 48, 82, &
- 9, 35, 41, &
- 10, 39, 62, &
- 11, 14, 61, &
- 12, 71, 74, &
- 13, 23, 78, &
- 15, 16, 79, &
- 17, 54, 63, &
- 18, 50, 57, &
- 19, 30, 47, &
- 20, 64, 80, &
- 21, 28, 69, &
- 22, 25, 43, &
- 26, 34, 72, &
- 27, 36, 37, &
- 29, 40, 44, &
- 33, 52, 53, &
- 38, 55, 83, &
- 42, 51, 59, &
- 45, 76, 81, &
- 46, 68, 77, &
- 56, 67, 73, &
- 1, 4, 5, &
- 2, 47, 51, &
- 3, 46, 82, &
- 6, 24, 76, &
- 7, 9, 16, &
- 8, 10, 78, &
- 11, 35, 55, &
- 12, 38, 64, &
- 13, 22, 37, &
- 14, 15, 58, &
- 17, 50, 53, &
- 18, 29, 56, &
- 19, 26, 57, &
- 20, 39, 77, &
- 21, 36, 63, &
- 23, 54, 74, &
- 25, 69, 73, &
- 27, 33, 65, &
- 28, 44, 79, &
- 30, 43, 52, &
- 31, 45, 61, &
- 32, 48, 71, &
- 34, 60, 62, &
- 40, 41, 70, &
- 42, 66, 68, &
- 49, 75, 83, &
- 59, 72, 80, &
- 36, 64, 81, &
- 1, 65, 74, &
- 2, 8, 81, &
- 3, 26, 79, &
- 4, 22, 72, &
- 5, 38, 50, &
- 6, 9, 52, &
- 7, 18, 77, &
- 10, 28, 55, &
- 11, 56, 59, &
- 12, 67, 68, &
- 13, 29, 47, &
- 14, 39, 54, &
- 15, 60, 70, &
- 16, 37, 66, &
- 17, 25, 82, &
- 19, 21, 71, &
- 20, 30, 31, &
- 23, 75, 80, &
- 24, 69, 75, &
- 27, 32, 62, &
- 33, 59, 76, &
- 34, 53, 61, &
- 35, 46, 47, &
- 40, 43, 83, &
- 41, 42, 63, &
- 20, 44, 48, &
+data Mn/ &
16, 45, 73, &
- 42, 49, 57, &
25, 51, 62, &
33, 58, 78, &
1, 44, 45, &
@@ -172,98 +89,182 @@ data Mn/ &
14, 66, 72, &
22, 60, 74, &
35, 39, 79, &
- 1, 46, 64/
+ 1, 46, 64, &
+ 1, 24, 66, &
+ 2, 5, 70, &
+ 3, 31, 65, &
+ 4, 49, 58, &
+ 1, 4, 5, &
+ 6, 60, 67, &
+ 7, 32, 75, &
+ 8, 48, 82, &
+ 9, 35, 41, &
+ 10, 39, 62, &
+ 11, 14, 61, &
+ 12, 71, 74, &
+ 13, 23, 78, &
+ 11, 35, 55, &
+ 15, 16, 79, &
+ 7, 9, 16, &
+ 17, 54, 63, &
+ 18, 50, 57, &
+ 19, 30, 47, &
+ 20, 64, 80, &
+ 21, 28, 69, &
+ 22, 25, 43, &
+ 13, 22, 37, &
+ 2, 47, 51, &
+ 23, 54, 74, &
+ 26, 34, 72, &
+ 27, 36, 37, &
+ 21, 36, 63, &
+ 29, 40, 44, &
+ 19, 26, 57, &
+ 3, 46, 82, &
+ 14, 15, 58, &
+ 33, 52, 53, &
+ 30, 43, 52, &
+ 6, 9, 52, &
+ 27, 33, 65, &
+ 25, 69, 73, &
+ 38, 55, 83, &
+ 20, 39, 77, &
+ 18, 29, 56, &
+ 32, 48, 71, &
+ 42, 51, 59, &
+ 28, 44, 79, &
+ 34, 60, 62, &
+ 31, 45, 61, &
+ 46, 68, 77, &
+ 6, 24, 76, &
+ 8, 10, 78, &
+ 40, 41, 70, &
+ 17, 50, 53, &
+ 42, 66, 68, &
+ 4, 22, 72, &
+ 36, 64, 81, &
+ 13, 29, 47, &
+ 2, 8, 81, &
+ 56, 67, 73, &
+ 5, 38, 50, &
+ 12, 38, 64, &
+ 59, 72, 80, &
+ 3, 26, 79, &
+ 45, 76, 81, &
+ 1, 65, 74, &
+ 7, 18, 77, &
+ 11, 56, 59, &
+ 14, 39, 54, &
+ 16, 37, 66, &
+ 10, 28, 55, &
+ 15, 60, 70, &
+ 17, 25, 82, &
+ 20, 30, 31, &
+ 12, 67, 68, &
+ 23, 75, 80, &
+ 27, 32, 62, &
+ 24, 69, 75, &
+ 19, 21, 71, &
+ 34, 53, 61, &
+ 35, 46, 47, &
+ 33, 59, 76, &
+ 40, 43, 83, &
+ 41, 42, 63, &
+ 49, 75, 83, &
+ 20, 44, 48, &
+ 42, 49, 57/
-data Nm/ &
- 1, 29, 57, 87, 114, 142, 174, &
- 2, 30, 58, 88, 115, 143, 0, &
- 3, 31, 59, 89, 107, 144, 0, &
- 4, 29, 60, 90, 116, 145, 0, &
- 2, 29, 61, 91, 108, 146, 166, &
- 5, 32, 62, 89, 115, 147, 0, &
- 6, 33, 63, 88, 117, 148, 161, &
- 7, 34, 58, 92, 118, 149, 0, &
- 8, 33, 62, 93, 119, 150, 0, &
- 9, 34, 64, 94, 120, 150, 170, &
- 10, 35, 65, 95, 121, 151, 0, &
- 11, 36, 66, 96, 122, 152, 0, &
- 12, 37, 67, 91, 123, 153, 165, &
- 10, 38, 68, 97, 124, 154, 171, &
- 13, 38, 69, 98, 125, 142, 0, &
- 13, 33, 70, 83, 116, 155, 0, &
- 14, 39, 71, 99, 126, 156, 0, &
- 15, 40, 63, 100, 120, 157, 164, &
- 16, 41, 72, 94, 127, 158, 0, &
- 17, 42, 73, 82, 128, 138, 147, &
- 18, 43, 72, 91, 129, 154, 0, &
- 19, 37, 60, 101, 119, 159, 172, &
- 12, 44, 74, 102, 121, 160, 0, &
- 1, 32, 75, 103, 130, 153, 0, &
- 19, 45, 71, 85, 131, 157, 0, &
- 20, 41, 59, 104, 128, 161, 166, &
- 21, 46, 76, 105, 130, 141, 0, &
- 18, 47, 64, 99, 122, 145, 0, &
- 22, 40, 67, 106, 126, 162, 0, &
- 16, 48, 73, 102, 118, 142, 156, &
- 3, 49, 73, 103, 119, 146, 0, &
- 6, 50, 76, 97, 114, 162, 0, &
- 23, 46, 77, 86, 127, 163, 0, &
- 20, 51, 78, 102, 129, 164, 0, &
- 8, 35, 79, 90, 132, 141, 173, &
- 21, 43, 56, 95, 133, 144, 0, &
- 21, 37, 70, 96, 134, 147, 0, &
- 24, 36, 61, 107, 135, 159, 0, &
- 9, 42, 68, 108, 136, 152, 173, &
- 22, 52, 80, 103, 129, 148, 163, &
- 8, 52, 81, 104, 137, 160, 0, &
- 25, 53, 81, 84, 118, 165, 0, &
- 19, 48, 80, 97, 113, 166, 0, &
- 22, 47, 82, 87, 112, 151, 0, &
- 26, 49, 83, 87, 135, 140, 169, &
- 27, 31, 79, 109, 134, 139, 174, &
- 16, 30, 67, 79, 135, 167, 0, &
- 7, 50, 82, 90, 133, 164, 0, &
- 4, 54, 84, 106, 138, 150, 0, &
- 15, 39, 61, 109, 124, 160, 0, &
- 25, 30, 85, 110, 124, 144, 145, &
- 23, 48, 62, 110, 123, 139, 0, &
- 23, 39, 78, 101, 132, 138, 0, &
- 14, 44, 68, 89, 116, 168, 0, &
- 24, 35, 64, 111, 131, 153, 168, &
- 28, 40, 65, 92, 137, 146, 0, &
- 15, 41, 84, 105, 136, 151, 0, &
- 4, 38, 86, 96, 131, 161, 0, &
- 25, 55, 65, 77, 114, 152, 0, &
- 5, 51, 69, 95, 126, 149, 172, &
- 10, 49, 78, 88, 122, 158, 0, &
- 9, 51, 76, 85, 137, 169, 0, &
- 14, 43, 81, 98, 139, 170, 0, &
- 17, 36, 56, 93, 127, 165, 174, &
- 3, 46, 57, 106, 117, 154, 0, &
- 1, 53, 70, 94, 132, 171, 0, &
- 5, 28, 66, 112, 117, 170, 0, &
- 27, 53, 66, 113, 133, 143, 169, &
- 18, 45, 75, 93, 136, 149, 167, &
- 2, 52, 69, 105, 140, 168, 0, &
- 11, 50, 72, 111, 115, 155, 0, &
- 20, 55, 60, 111, 112, 167, 171, &
- 28, 45, 83, 109, 128, 163, 0, &
- 11, 44, 57, 100, 110, 172, 0, &
- 6, 54, 74, 75, 134, 140, 0, &
- 26, 32, 77, 104, 120, 156, 0, &
- 27, 42, 63, 99, 130, 159, 0, &
- 12, 34, 86, 107, 113, 155, 0, &
- 13, 47, 59, 92, 123, 173, 0, &
- 17, 55, 74, 98, 141, 143, 157, &
- 26, 56, 58, 101, 125, 162, 0, &
- 7, 31, 71, 108, 121, 148, 0, &
- 24, 54, 80, 100, 125, 158, 0/
+data Nm/ &
+ 4, 31, 59, 91, 92, 96, 153, &
+ 5, 32, 60, 93, 115, 146, 0, &
+ 6, 24, 61, 94, 122, 151, 0, &
+ 7, 33, 62, 95, 96, 143, 0, &
+ 8, 25, 63, 83, 93, 96, 148, &
+ 6, 32, 64, 97, 126, 138, 0, &
+ 5, 34, 65, 78, 98, 107, 154, &
+ 9, 35, 66, 99, 139, 146, 0, &
+ 10, 36, 67, 100, 107, 126, 0, &
+ 11, 37, 67, 87, 101, 139, 158, &
+ 12, 38, 68, 102, 105, 155, 0, &
+ 13, 39, 69, 103, 149, 162, 0, &
+ 8, 40, 70, 82, 104, 114, 145, &
+ 14, 41, 71, 88, 102, 123, 156, &
+ 15, 42, 59, 106, 123, 159, 0, &
+ 1, 33, 72, 106, 107, 157, 0, &
+ 16, 43, 73, 108, 141, 160, 0, &
+ 17, 37, 74, 81, 109, 131, 154, &
+ 11, 44, 75, 110, 121, 166, 0, &
+ 45, 55, 64, 111, 130, 161, 173, &
+ 8, 46, 71, 112, 119, 166, 0, &
+ 18, 36, 76, 89, 113, 114, 143, &
+ 19, 38, 77, 104, 116, 163, 0, &
+ 20, 47, 70, 92, 138, 165, 0, &
+ 2, 48, 74, 113, 128, 160, 0, &
+ 21, 45, 78, 83, 117, 121, 151, &
+ 22, 47, 58, 118, 127, 164, 0, &
+ 16, 39, 62, 112, 134, 158, 0, &
+ 23, 43, 79, 120, 131, 145, 0, &
+ 19, 35, 59, 73, 110, 125, 161, &
+ 20, 36, 63, 94, 136, 161, 0, &
+ 14, 31, 79, 98, 132, 164, 0, &
+ 3, 44, 80, 124, 127, 169, 0, &
+ 19, 46, 81, 117, 135, 167, 0, &
+ 7, 49, 58, 90, 100, 105, 168, &
+ 12, 50, 61, 118, 119, 144, 0, &
+ 13, 51, 64, 114, 118, 157, 0, &
+ 24, 52, 76, 129, 148, 149, 0, &
+ 25, 53, 69, 90, 101, 130, 156, &
+ 20, 46, 65, 80, 120, 140, 170, &
+ 21, 54, 77, 100, 140, 171, 0, &
+ 35, 82, 133, 142, 171, 174, 0, &
+ 14, 30, 83, 113, 125, 170, 0, &
+ 4, 29, 68, 120, 134, 173, 0, &
+ 1, 4, 52, 57, 86, 136, 152, &
+ 26, 51, 56, 91, 122, 137, 168, &
+ 52, 84, 110, 115, 145, 168, 0, &
+ 7, 50, 81, 99, 132, 173, 0, &
+ 23, 55, 67, 95, 172, 174, 0, &
+ 26, 41, 77, 109, 141, 148, 0, &
+ 2, 27, 41, 61, 62, 115, 133, &
+ 27, 40, 56, 124, 125, 126, 0, &
+ 18, 49, 55, 124, 141, 167, 0, &
+ 6, 33, 85, 108, 116, 156, 0, &
+ 28, 48, 70, 85, 105, 129, 158, &
+ 9, 54, 63, 131, 147, 155, 0, &
+ 22, 53, 68, 109, 121, 174, 0, &
+ 3, 13, 48, 78, 95, 123, 0, &
+ 31, 69, 133, 150, 155, 169, 0, &
+ 12, 43, 66, 89, 97, 135, 159, &
+ 5, 39, 75, 102, 136, 167, 0, &
+ 2, 54, 86, 101, 135, 164, 0, &
+ 15, 56, 87, 108, 119, 171, 0, &
+ 10, 44, 82, 91, 111, 144, 149, &
+ 23, 34, 71, 94, 127, 153, 0, &
+ 11, 49, 88, 92, 142, 157, 0, &
+ 29, 34, 87, 97, 147, 162, 0, &
+ 30, 50, 60, 86, 137, 142, 162, &
+ 10, 53, 66, 84, 112, 128, 165, &
+ 22, 57, 85, 93, 140, 159, 0, &
+ 28, 32, 72, 103, 132, 166, 0, &
+ 28, 29, 84, 88, 117, 143, 150, &
+ 1, 26, 45, 80, 128, 147, 0, &
+ 17, 27, 89, 103, 116, 153, 0, &
+ 51, 57, 98, 163, 165, 172, 0, &
+ 21, 37, 73, 138, 152, 169, 0, &
+ 16, 47, 76, 130, 137, 154, 0, &
+ 3, 24, 30, 72, 104, 139, 0, &
+ 9, 40, 90, 106, 134, 151, 0, &
+ 15, 58, 60, 74, 111, 150, 163, &
+ 18, 42, 79, 144, 146, 152, 0, &
+ 25, 38, 65, 99, 122, 160, 0, &
+ 17, 42, 75, 129, 170, 172, 0/
-data nrw/ &
-7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6,6, &
-7,6,7,6,7,6,6,6,7,6,6,6,7,6,6,6,6, &
-7,6,6,6,7,7,6,6,6,6,7,7,6,6,6,6,7, &
-6,6,6,7,6,6,6,6,7,6,6,6,7,6,6,6,7, &
-7,6,6,7,6,6,6,6,6,6,6,7,6,6,6/
+data nrw/ &
+7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6, &
+6,7,6,7,6,7,6,6,6,7,6,6,6,7,6,6, &
+6,6,7,6,6,6,7,7,6,6,6,6,7,7,6,6, &
+6,6,7,6,6,6,7,6,6,6,6,7,6,6,6,7, &
+6,6,6,7,7,6,6,7,6,6,6,6,6,6,6,7, &
+6,6,6/
ncw=3
diff --git a/lib/ft8/ldpc_174_91_c_reordered_parity.f90 b/lib/ft8/ldpc_174_91_c_reordered_parity.f90
deleted file mode 100644
index 2309ad8e..00000000
--- a/lib/ft8/ldpc_174_91_c_reordered_parity.f90
+++ /dev/null
@@ -1,270 +0,0 @@
-data Mn/ &
- 16, 45, 73, &
- 25, 51, 62, &
- 33, 58, 78, &
- 1, 44, 45, &
- 2, 7, 61, &
- 3, 6, 54, &
- 4, 35, 48, &
- 5, 13, 21, &
- 8, 56, 79, &
- 9, 64, 69, &
- 10, 19, 66, &
- 11, 36, 60, &
- 12, 37, 58, &
- 14, 32, 43, &
- 15, 63, 80, &
- 17, 28, 77, &
- 18, 74, 83, &
- 22, 53, 81, &
- 23, 30, 34, &
- 24, 31, 40, &
- 26, 41, 76, &
- 27, 57, 70, &
- 29, 49, 65, &
- 3, 38, 78, &
- 5, 39, 82, &
- 46, 50, 73, &
- 51, 52, 74, &
- 55, 71, 72, &
- 44, 67, 72, &
- 43, 68, 78, &
- 1, 32, 59, &
- 2, 6, 71, &
- 4, 16, 54, &
- 7, 65, 67, &
- 8, 30, 42, &
- 9, 22, 31, &
- 10, 18, 76, &
- 11, 23, 82, &
- 12, 28, 61, &
- 13, 52, 79, &
- 14, 50, 51, &
- 15, 81, 83, &
- 17, 29, 60, &
- 19, 33, 64, &
- 20, 26, 73, &
- 21, 34, 40, &
- 24, 27, 77, &
- 25, 55, 58, &
- 35, 53, 66, &
- 36, 48, 68, &
- 37, 46, 75, &
- 38, 45, 47, &
- 39, 57, 69, &
- 41, 56, 62, &
- 20, 49, 53, &
- 46, 52, 63, &
- 45, 70, 75, &
- 27, 35, 80, &
- 1, 15, 30, &
- 2, 68, 80, &
- 3, 36, 51, &
- 4, 28, 51, &
- 5, 31, 56, &
- 6, 20, 37, &
- 7, 40, 82, &
- 8, 60, 69, &
- 9, 10, 49, &
- 11, 44, 57, &
- 12, 39, 59, &
- 13, 24, 55, &
- 14, 21, 65, &
- 16, 71, 78, &
- 17, 30, 76, &
- 18, 25, 80, &
- 19, 61, 83, &
- 22, 38, 77, &
- 23, 41, 50, &
- 7, 26, 58, &
- 29, 32, 81, &
- 33, 40, 73, &
- 18, 34, 48, &
- 13, 42, 64, &
- 5, 26, 43, &
- 47, 69, 72, &
- 54, 55, 70, &
- 45, 62, 68, &
- 10, 63, 67, &
- 14, 66, 72, &
- 22, 60, 74, &
- 35, 39, 79, &
- 1, 46, 64, &
- 1, 24, 66, &
- 2, 5, 70, &
- 3, 31, 65, &
- 4, 49, 58, &
- 1, 4, 5, &
- 6, 60, 67, &
- 7, 32, 75, &
- 8, 48, 82, &
- 9, 35, 41, &
- 10, 39, 62, &
- 11, 14, 61, &
- 12, 71, 74, &
- 13, 23, 78, &
- 11, 35, 55, &
- 15, 16, 79, &
- 7, 9, 16, &
- 17, 54, 63, &
- 18, 50, 57, &
- 19, 30, 47, &
- 20, 64, 80, &
- 21, 28, 69, &
- 22, 25, 43, &
- 13, 22, 37, &
- 2, 47, 51, &
- 23, 54, 74, &
- 26, 34, 72, &
- 27, 36, 37, &
- 21, 36, 63, &
- 29, 40, 44, &
- 19, 26, 57, &
- 3, 46, 82, &
- 14, 15, 58, &
- 33, 52, 53, &
- 30, 43, 52, &
- 6, 9, 52, &
- 27, 33, 65, &
- 25, 69, 73, &
- 38, 55, 83, &
- 20, 39, 77, &
- 18, 29, 56, &
- 32, 48, 71, &
- 42, 51, 59, &
- 28, 44, 79, &
- 34, 60, 62, &
- 31, 45, 61, &
- 46, 68, 77, &
- 6, 24, 76, &
- 8, 10, 78, &
- 40, 41, 70, &
- 17, 50, 53, &
- 42, 66, 68, &
- 4, 22, 72, &
- 36, 64, 81, &
- 13, 29, 47, &
- 2, 8, 81, &
- 56, 67, 73, &
- 5, 38, 50, &
- 12, 38, 64, &
- 59, 72, 80, &
- 3, 26, 79, &
- 45, 76, 81, &
- 1, 65, 74, &
- 7, 18, 77, &
- 11, 56, 59, &
- 14, 39, 54, &
- 16, 37, 66, &
- 10, 28, 55, &
- 15, 60, 70, &
- 17, 25, 82, &
- 20, 30, 31, &
- 12, 67, 68, &
- 23, 75, 80, &
- 27, 32, 62, &
- 24, 69, 75, &
- 19, 21, 71, &
- 34, 53, 61, &
- 35, 46, 47, &
- 33, 59, 76, &
- 40, 43, 83, &
- 41, 42, 63, &
- 49, 75, 83, &
- 20, 44, 48, &
- 42, 49, 57/
-
-data Nm/ &
- 4, 31, 59, 91, 92, 96, 153, &
- 5, 32, 60, 93, 115, 146, 0, &
- 6, 24, 61, 94, 122, 151, 0, &
- 7, 33, 62, 95, 96, 143, 0, &
- 8, 25, 63, 83, 93, 96, 148, &
- 6, 32, 64, 97, 126, 138, 0, &
- 5, 34, 65, 78, 98, 107, 154, &
- 9, 35, 66, 99, 139, 146, 0, &
- 10, 36, 67, 100, 107, 126, 0, &
- 11, 37, 67, 87, 101, 139, 158, &
- 12, 38, 68, 102, 105, 155, 0, &
- 13, 39, 69, 103, 149, 162, 0, &
- 8, 40, 70, 82, 104, 114, 145, &
- 14, 41, 71, 88, 102, 123, 156, &
- 15, 42, 59, 106, 123, 159, 0, &
- 1, 33, 72, 106, 107, 157, 0, &
- 16, 43, 73, 108, 141, 160, 0, &
- 17, 37, 74, 81, 109, 131, 154, &
- 11, 44, 75, 110, 121, 166, 0, &
- 45, 55, 64, 111, 130, 161, 173, &
- 8, 46, 71, 112, 119, 166, 0, &
- 18, 36, 76, 89, 113, 114, 143, &
- 19, 38, 77, 104, 116, 163, 0, &
- 20, 47, 70, 92, 138, 165, 0, &
- 2, 48, 74, 113, 128, 160, 0, &
- 21, 45, 78, 83, 117, 121, 151, &
- 22, 47, 58, 118, 127, 164, 0, &
- 16, 39, 62, 112, 134, 158, 0, &
- 23, 43, 79, 120, 131, 145, 0, &
- 19, 35, 59, 73, 110, 125, 161, &
- 20, 36, 63, 94, 136, 161, 0, &
- 14, 31, 79, 98, 132, 164, 0, &
- 3, 44, 80, 124, 127, 169, 0, &
- 19, 46, 81, 117, 135, 167, 0, &
- 7, 49, 58, 90, 100, 105, 168, &
- 12, 50, 61, 118, 119, 144, 0, &
- 13, 51, 64, 114, 118, 157, 0, &
- 24, 52, 76, 129, 148, 149, 0, &
- 25, 53, 69, 90, 101, 130, 156, &
- 20, 46, 65, 80, 120, 140, 170, &
- 21, 54, 77, 100, 140, 171, 0, &
- 35, 82, 133, 142, 171, 174, 0, &
- 14, 30, 83, 113, 125, 170, 0, &
- 4, 29, 68, 120, 134, 173, 0, &
- 1, 4, 52, 57, 86, 136, 152, &
- 26, 51, 56, 91, 122, 137, 168, &
- 52, 84, 110, 115, 145, 168, 0, &
- 7, 50, 81, 99, 132, 173, 0, &
- 23, 55, 67, 95, 172, 174, 0, &
- 26, 41, 77, 109, 141, 148, 0, &
- 2, 27, 41, 61, 62, 115, 133, &
- 27, 40, 56, 124, 125, 126, 0, &
- 18, 49, 55, 124, 141, 167, 0, &
- 6, 33, 85, 108, 116, 156, 0, &
- 28, 48, 70, 85, 105, 129, 158, &
- 9, 54, 63, 131, 147, 155, 0, &
- 22, 53, 68, 109, 121, 174, 0, &
- 3, 13, 48, 78, 95, 123, 0, &
- 31, 69, 133, 150, 155, 169, 0, &
- 12, 43, 66, 89, 97, 135, 159, &
- 5, 39, 75, 102, 136, 167, 0, &
- 2, 54, 86, 101, 135, 164, 0, &
- 15, 56, 87, 108, 119, 171, 0, &
- 10, 44, 82, 91, 111, 144, 149, &
- 23, 34, 71, 94, 127, 153, 0, &
- 11, 49, 88, 92, 142, 157, 0, &
- 29, 34, 87, 97, 147, 162, 0, &
- 30, 50, 60, 86, 137, 142, 162, &
- 10, 53, 66, 84, 112, 128, 165, &
- 22, 57, 85, 93, 140, 159, 0, &
- 28, 32, 72, 103, 132, 166, 0, &
- 28, 29, 84, 88, 117, 143, 150, &
- 1, 26, 45, 80, 128, 147, 0, &
- 17, 27, 89, 103, 116, 153, 0, &
- 51, 57, 98, 163, 165, 172, 0, &
- 21, 37, 73, 138, 152, 169, 0, &
- 16, 47, 76, 130, 137, 154, 0, &
- 3, 24, 30, 72, 104, 139, 0, &
- 9, 40, 90, 106, 134, 151, 0, &
- 15, 58, 60, 74, 111, 150, 163, &
- 18, 42, 79, 144, 146, 152, 0, &
- 25, 38, 65, 99, 122, 160, 0, &
- 17, 42, 75, 129, 170, 172, 0/
-
-data nrw/ &
-7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6, &
-6,7,6,7,6,7,6,6,6,7,6,6,6,7,6,6, &
-6,6,7,6,6,6,7,7,6,6,6,6,7,7,6,6, &
-6,6,7,6,6,6,7,6,6,6,6,7,6,6,6,7, &
-6,6,6,7,7,6,6,7,6,6,6,6,6,6,6,7, &
-6,6,6/
-
-ncw=3
diff --git a/lib/ft8/ldpcsim174_91.f90 b/lib/ft8/ldpcsim174_91.f90
new file mode 100644
index 00000000..994b7837
--- /dev/null
+++ b/lib/ft8/ldpcsim174_91.f90
@@ -0,0 +1,134 @@
+program ldpcsim174_91
+! End to end test of the (174,91)/crc14 encoder and decoder.
+ use packjt77
+
+ integer, parameter:: N=174, K=91, M=N-K
+ character*37 msg,msgsent,msgreceived
+ character*77 c77
+ character*8 arg
+ character*6 grid
+ character*96 tmpchar
+ integer*1, allocatable :: codeword(:), decoded(:), message(:)
+ integer*1 msgbits(77)
+ integer*1 message77(77),message91(91)
+ integer*1 apmask(N), cw(N)
+ integer nerrtot(0:N),nerrdec(0:N)
+ logical unpk77_success
+ real*8, allocatable :: rxdata(:)
+ real, allocatable :: llr(:)
+
+ nerrtot=0
+ nerrdec=0
+
+ nargs=iargc()
+ if(nargs.ne.6) then
+ print*,'Usage: ldpcsim niter ndepth #trials s Keff nbposd'
+ print*,'eg: ldpcsim 10 2 1000 0.84 91 1'
+ print*,'niter: max BP iterations'
+ print*,'ndepth: OSD order'
+ print*,'s: noise sigma; if negative value is ignored and sigma is calculated from SNR.'
+ print*,'nbposd=0, no coupling. nbposd>0, maxsuper=nbposd; nbposd<0, no OSD'
+ return
+ endif
+ call getarg(1,arg)
+ read(arg,*) max_iterations
+ call getarg(2,arg)
+ read(arg,*) ndepth
+ call getarg(3,arg)
+ read(arg,*) ntrials
+ call getarg(4,arg)
+ read(arg,*) s
+ call getarg(5,arg)
+ read(arg,*) Keff
+ call getarg(6,arg)
+ read(arg,*) nbposd
+
+! scale Eb/No for a (174,91) code
+ rate=real(K)/real(N)
+
+ write(*,*) "rate: ",rate
+ write(*,*) "niter= ",max_iterations," s= ",s
+
+ allocate ( codeword(N), decoded(K), message(K) )
+ allocate ( rxdata(N), llr(N) )
+
+ msg="K9ABC K1ABC FN20"
+ i3=0
+ n3=1
+ call pack77(msg,i3,n3,c77) !Pack into 12 6-bit bytes
+ call unpack77(c77,1,msgsent,unpk77_success) !Unpack to get msgsent
+ write(*,*) "message sent ",msgsent
+
+ read(c77,'(77i1)') msgbits(1:77)
+ write(*,*) 'message'
+ write(*,'(a71,1x,a3,1x,a3)') c77(1:71),c77(72:74),c77(75:77)
+
+ call init_random_seed()
+
+ call encode174_91(msgbits,codeword)
+ write(*,*) 'crc14'
+ write(*,'(14i1)') codeword(78:91)
+ write(*,*) 'codeword'
+ write(*,'(22(8i1,1x))') codeword
+
+ write(*,*) "Eb/N0 Es/N0 ngood nundetected sigma psymerr"
+ do idb = 10,-4,-1
+ db=idb/2.0-1.0
+ sigma=1/sqrt( 2*rate*(10**(db/10.0)) )
+ ngood=0
+ nue=0
+ nsumerr=0
+
+ do itrial=1, ntrials
+! Create a realization of a noisy received word
+ do i=1,N
+ rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
+ enddo
+ nerr=0
+ do i=1,N
+ if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
+ enddo
+ if(nerr.ge.1) nerrtot(nerr)=nerrtot(nerr)+1
+
+ rxav=sum(rxdata)/N
+ rx2av=sum(rxdata*rxdata)/N
+ rxsig=sqrt(rx2av-rxav*rxav)
+ rxdata=rxdata/rxsig
+ if( s .lt. 0 ) then
+ ss=sigma
+ else
+ ss=s
+ endif
+
+ llr=2.0*rxdata/(ss*ss)
+ nap=0 ! number of AP bits
+ llr(1:nap)=5*(2.0*msgbits(1:nap)-1.0)
+ apmask=0
+ apmask(1:nap)=1
+ call decode174_91(llr,Keff,nbposd,ndepth,apmask,message91,cw,ntype,nharderrors,dmin)
+! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
+ if( nharderrors.ge.0 ) then
+ nhw=count(cw.ne.codeword)
+ if(nhw.eq.0) then ! this is a good decode
+ ngood=ngood+1
+ nerrdec(nerr)=nerrdec(nerr)+1
+ else
+ nue=nue+1
+ endif
+ endif
+ nsumerr=nsumerr+nerr
+ enddo
+
+ esn0=db+10.0*log10(rate)
+ pberr=real(nsumerr)/(real(ntrials*N))
+ write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,esn0,ngood,nue,ss,pberr
+
+ enddo
+
+ open(unit=23,file='nerrhisto.dat',status='unknown')
+ do i=1,174
+ write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
+ enddo
+ close(23)
+
+end program ldpcsim174_91
diff --git a/lib/ft8/osd174_91.f90 b/lib/ft8/osd174_91.f90
index 958b0c9f..d9584f56 100644
--- a/lib/ft8/osd174_91.f90
+++ b/lib/ft8/osd174_91.f90
@@ -1,234 +1,269 @@
-subroutine osd174_91(llr,apmask,ndeep,message77,cw,nhardmin,dmin)
+subroutine osd174_91(llr,k,apmask,ndeep,message91,cw,nhardmin,dmin)
!
! An ordered-statistics decoder for the (174,91) code.
-!
-integer, parameter:: N=174, K=91, M=N-K
-integer*1 apmask(N),apmaskr(N)
-integer*1 gen(K,N)
-integer*1 genmrb(K,N),g2(N,K)
-integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K)
-integer*1 r2pat(N-K)
-integer indices(N),nxor(N)
-integer*1 cw(N),ce(N),c0(N),hdec(N)
-integer*1 decoded(K)
-integer*1 message77(77)
-integer indx(N)
-real llr(N),rx(N),absrx(N)
+! Message payload is 77 bits. Any or all of a 14-bit CRC can be
+! used for detecting incorrect codewords. The remaining CRC bits are
+! cascaded with the LDPC code for the purpose of improving the
+! distance spectrum of the code.
+!
+! If p1 (0.le.p1.le.14) is the number of CRC14 bits that are
+! to be used for bad codeword detection, then the argument k should
+! be set to 77+p1.
+!
+! Valid values for k are in the range [77,91].
+!
+ character*14 c14
+ integer, parameter:: N=174
+ integer*1 apmask(N),apmaskr(N)
+ integer*1, allocatable, save :: gen(:,:)
+ integer*1, allocatable :: genmrb(:,:),g2(:,:)
+ integer*1, allocatable :: temp(:),m0(:),me(:),mi(:),misub(:),e2sub(:),e2(:),ui(:)
+ integer*1, allocatable :: r2pat(:)
+ integer indices(N),nxor(N)
+ integer*1 cw(N),ce(N),c0(N),hdec(N)
+ integer*1, allocatable :: decoded(:)
+ integer*1 message91(91),m96(96)
+ integer indx(N)
+ real llr(N),rx(N),absrx(N)
-include "ldpc_174_91_c_generator.f90"
+ logical first,reset
+ data first/.true./
+ save first
-logical first,reset
-data first/.true./
-save first,gen
+ allocate( genmrb(k,N), g2(N,k) )
+ allocate( temp(k), m0(k), me(k), mi(k), misub(k), e2sub(N-k), e2(N-k), ui(N-k) )
+ allocate( r2pat(N-k), decoded(k) )
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,M
- do j=1,23
- read(g(i)(j:j),"(Z1)") istr
- ibmax=4
- if(j.eq.23) ibmax=3
- do jj=1, ibmax
- irow=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(irow,K+i)=1
+ if( first ) then ! fill the generator matrix
+!
+! Create generator matrix for partial CRC cascaded with LDPC code.
+!
+! Let p2=91-k and p1+p2=14.
+!
+! The last p2 bits of the CRC14 are cascaded with the LDPC code.
+!
+! The first p1=k-77 CRC14 bits will be used for error detection.
+!
+ allocate( gen(k,N) )
+ gen=0
+ do i=1,k
+ message91=0
+ message91(i)=1
+ if(i.le.77) then
+ m96=0
+ m96(1:91)=message91
+ call get_crc14(m96,96,ncrc14)
+ write(c14,'(b14.14)') ncrc14
+ read(c14,'(14i1)') message91(78:91)
+ message91(78:k)=0
+ endif
+ call encode174_91_nocrc(message91,cw)
+ gen(i,:)=cw
enddo
- enddo
- enddo
- do irow=1,K
- gen(irow,irow)=1
- enddo
-first=.false.
-endif
-rx=llr
-apmaskr=apmask
+ first=.false.
+ endif
+
+ rx=llr
+ apmaskr=apmask
! Hard decisions on the received word.
-hdec=0
-where(rx .ge. 0) hdec=1
+ hdec=0
+ where(rx .ge. 0) hdec=1
! Use magnitude of received symbols as a measure of reliability.
-absrx=abs(rx)
-call indexx(absrx,N,indx)
+ absrx=abs(rx)
+ call indexx(absrx,N,indx)
! Re-order the columns of the generator matrix in order of decreasing reliability.
-do i=1,N
- genmrb(1:K,i)=gen(1:K,indx(N+1-i))
- indices(i)=indx(N+1-i)
-enddo
+ do i=1,N
+ genmrb(1:k,i)=gen(1:k,indx(N+1-i))
+ indices(i)=indx(N+1-i)
+ enddo
! Do gaussian elimination to create a generator matrix with the most reliable
-! received bits in positions 1:K in order of decreasing reliability (more or less).
-do id=1,K ! diagonal element indices
- do icol=id,K+20 ! The 20 is ad hoc - beware
- iflag=0
- if( genmrb(id,icol) .eq. 1 ) then
- iflag=1
- if( icol .ne. id ) then ! reorder column
- temp(1:K)=genmrb(1:K,id)
- genmrb(1:K,id)=genmrb(1:K,icol)
- genmrb(1:K,icol)=temp(1:K)
- itmp=indices(id)
- indices(id)=indices(icol)
- indices(icol)=itmp
- endif
- do ii=1,K
- if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then
- genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N))
- endif
+! received bits in positions 1:k in order of decreasing reliability (more or less).
+ do id=1,k ! diagonal element indices
+ do icol=id,k+20 ! The 20 is ad hoc - beware
+ iflag=0
+ if( genmrb(id,icol) .eq. 1 ) then
+ iflag=1
+ if( icol .ne. id ) then ! reorder column
+ temp(1:k)=genmrb(1:k,id)
+ genmrb(1:k,id)=genmrb(1:k,icol)
+ genmrb(1:k,icol)=temp(1:k)
+ itmp=indices(id)
+ indices(id)=indices(icol)
+ indices(icol)=itmp
+ endif
+ do ii=1,k
+ if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then
+ genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N))
+ endif
+ enddo
+ exit
+ endif
enddo
- exit
- endif
- enddo
-enddo
+ enddo
-g2=transpose(genmrb)
+ g2=transpose(genmrb)
-! The hard decisions for the K MRB bits define the order 0 message, m0.
-! Encode m0 using the modified generator matrix to find the "order 0" codeword.
+! The hard decisions for the k MRB bits define the order 0 message, m0.
+! Encode m0 using the modified generator matrix to find the "order 0" codeword.
! Flip various combinations of bits in m0 and re-encode to generate a list of
! codewords. Return the member of the list that has the smallest Euclidean
-! distance to the received word.
-
-hdec=hdec(indices) ! hard decisions from received symbols
-m0=hdec(1:K) ! zero'th order message
-absrx=absrx(indices)
-rx=rx(indices)
-apmaskr=apmaskr(indices)
+! distance to the received word.
-call mrbencode91(m0,c0,g2,N,K)
-nxor=ieor(c0,hdec)
-nhardmin=sum(nxor)
-dmin=sum(nxor*absrx)
+ hdec=hdec(indices) ! hard decisions from received symbols
+ m0=hdec(1:k) ! zero'th order message
+ absrx=absrx(indices)
+ rx=rx(indices)
+ apmaskr=apmaskr(indices)
-cw=c0
-ntotal=0
-nrejected=0
+ call mrbencode91(m0,c0,g2,N,k)
+ nxor=ieor(c0,hdec)
+ nhardmin=sum(nxor)
+ dmin=sum(nxor*absrx)
-if(ndeep.eq.0) goto 998 ! norder=0
-if(ndeep.gt.5) ndeep=5
-if( ndeep.eq. 1) then
- nord=1
+ cw=c0
+ ntotal=0
+ nrejected=0
npre1=0
npre2=0
- nt=40
- ntheta=12
-elseif(ndeep.eq.2) then
- nord=1
- npre1=1
- npre2=0
- nt=40
- ntheta=12
-elseif(ndeep.eq.3) then
- nord=1
- npre1=1
- npre2=1
- nt=40
- ntheta=12
- ntau=14
-elseif(ndeep.eq.4) then
- nord=2
- npre1=1
- npre2=0
- nt=40
- ntheta=12
- ntau=19
-elseif(ndeep.eq.5) then
- nord=2
- npre1=1
- npre2=1
- nt=40
- ntheta=12
- ntau=19
-endif
-do iorder=1,nord
- misub(1:K-iorder)=0
- misub(K-iorder+1:K)=1
- iflag=K-iorder+1
- do while(iflag .ge.0)
- if(iorder.eq.nord .and. npre1.eq.0) then
- iend=iflag
- else
- iend=1
- endif
- do n1=iflag,iend,-1
- mi=misub
- mi(n1)=1
- if(any(iand(apmaskr(1:K),mi).eq.1)) cycle
- ntotal=ntotal+1
- me=ieor(m0,mi)
- if(n1.eq.iflag) then
- call mrbencode91(me,ce,g2,N,K)
- e2sub=ieor(ce(K+1:N),hdec(K+1:N))
- e2=e2sub
- nd1Kpt=sum(e2sub(1:nt))+1
- d1=sum(ieor(me(1:K),hdec(1:K))*absrx(1:K))
+ if(ndeep.eq.0) goto 998 ! norder=0
+ if(ndeep.gt.6) ndeep=6
+ if( ndeep.eq. 1) then
+ nord=1
+ npre1=0
+ npre2=0
+ nt=40
+ ntheta=12
+ elseif(ndeep.eq.2) then
+ nord=1
+ npre1=1
+ npre2=0
+ nt=40
+! ntheta=12
+ ntheta=10
+ elseif(ndeep.eq.3) then
+ nord=1
+ npre1=1
+ npre2=1
+ nt=40
+ ntheta=12
+ ntau=14
+ elseif(ndeep.eq.4) then
+ nord=2
+ npre1=1
+ npre2=1
+ nt=40
+ ntheta=12
+ ntau=17
+ elseif(ndeep.eq.5) then
+ nord=3
+ npre1=1
+ npre2=1
+ nt=40
+ ntheta=12
+ ntau=15
+ elseif(ndeep.eq.6) then
+ nord=4
+ npre1=1
+ npre2=1
+ nt=95
+ ntheta=12
+ ntau=15
+ endif
+
+ do iorder=1,nord
+ misub(1:k-iorder)=0
+ misub(k-iorder+1:k)=1
+ iflag=k-iorder+1
+ do while(iflag .ge.0)
+ if(iorder.eq.nord .and. npre1.eq.0) then
+ iend=iflag
else
- e2=ieor(e2sub,g2(K+1:N,n1))
- nd1Kpt=sum(e2(1:nt))+2
+ iend=1
endif
- if(nd1Kpt .le. ntheta) then
- call mrbencode91(me,ce,g2,N,K)
- nxor=ieor(ce,hdec)
+ d1=0.
+ do n1=iflag,iend,-1
+ mi=misub
+ mi(n1)=1
+ if(any(iand(apmaskr(1:k),mi).eq.1)) cycle
+ ntotal=ntotal+1
+ me=ieor(m0,mi)
if(n1.eq.iflag) then
- dd=d1+sum(e2sub*absrx(K+1:N))
+ call mrbencode91(me,ce,g2,N,k)
+ e2sub=ieor(ce(k+1:N),hdec(k+1:N))
+ e2=e2sub
+ nd1kpt=sum(e2sub(1:nt))+1
+ d1=sum(ieor(me(1:k),hdec(1:k))*absrx(1:k))
else
- dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(K+1:N))
+ e2=ieor(e2sub,g2(k+1:N,n1))
+ nd1kpt=sum(e2(1:nt))+2
endif
- if( dd .lt. dmin ) then
- dmin=dd
- cw=ce
- nhardmin=sum(nxor)
- nd1Kptbest=nd1Kpt
+ if(nd1kpt .le. ntheta) then
+ call mrbencode91(me,ce,g2,N,k)
+ nxor=ieor(ce,hdec)
+ if(n1.eq.iflag) then
+ dd=d1+sum(e2sub*absrx(k+1:N))
+ else
+ dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(k+1:N))
+ endif
+ if( dd .lt. dmin ) then
+ dmin=dd
+ cw=ce
+ nhardmin=sum(nxor)
+ nd1kptbest=nd1kpt
+ endif
+ else
+ nrejected=nrejected+1
endif
- else
- nrejected=nrejected+1
- endif
- enddo
+ enddo
! Get the next test error pattern, iflag will go negative
! when the last pattern with weight iorder has been generated.
- call nextpat91(misub,k,iorder,iflag)
+ call nextpat91(misub,k,iorder,iflag)
+ enddo
enddo
-enddo
-if(npre2.eq.1) then
- reset=.true.
- ntotal=0
- do i1=K,1,-1
- do i2=i1-1,1,-1
- ntotal=ntotal+1
- mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2))
- call boxit91(reset,mi(1:ntau),ntau,ntotal,i1,i2)
+ if(npre2.eq.1) then
+ reset=.true.
+ ntotal=0
+ do i1=k,1,-1
+ do i2=i1-1,1,-1
+ ntotal=ntotal+1
+ mi(1:ntau)=ieor(g2(k+1:k+ntau,i1),g2(k+1:k+ntau,i2))
+ call boxit91(reset,mi(1:ntau),ntau,ntotal,i1,i2)
+ enddo
enddo
- enddo
- ncount2=0
- ntotal2=0
- reset=.true.
+ ncount2=0
+ ntotal2=0
+ reset=.true.
! Now run through again and do the second pre-processing rule
- misub(1:K-nord)=0
- misub(K-nord+1:K)=1
- iflag=K-nord+1
- do while(iflag .ge.0)
- me=ieor(m0,misub)
- call mrbencode91(me,ce,g2,N,K)
- e2sub=ieor(ce(K+1:N),hdec(K+1:N))
- do i2=0,ntau
- ntotal2=ntotal2+1
- ui=0
- if(i2.gt.0) ui(i2)=1
- r2pat=ieor(e2sub,ui)
-778 continue
+ misub(1:k-nord)=0
+ misub(k-nord+1:k)=1
+ iflag=k-nord+1
+ do while(iflag .ge.0)
+ me=ieor(m0,misub)
+ call mrbencode91(me,ce,g2,N,k)
+ e2sub=ieor(ce(k+1:N),hdec(k+1:N))
+ do i2=0,ntau
+ ntotal2=ntotal2+1
+ ui=0
+ if(i2.gt.0) ui(i2)=1
+ r2pat=ieor(e2sub,ui)
+778 continue
call fetchit91(reset,r2pat(1:ntau),ntau,in1,in2)
if(in1.gt.0.and.in2.gt.0) then
ncount2=ncount2+1
- mi=misub
+ mi=misub
mi(in1)=1
mi(in2)=1
- if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle
+ if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:k),mi).eq.1)) cycle
me=ieor(m0,mi)
- call mrbencode91(me,ce,g2,N,K)
+ call mrbencode91(me,ce,g2,N,k)
nxor=ieor(ce,hdec)
dd=sum(nxor*absrx)
if( dd .lt. dmin ) then
@@ -237,136 +272,138 @@ if(npre2.eq.1) then
nhardmin=sum(nxor)
endif
goto 778
- endif
+ endif
+ enddo
+ call nextpat91(misub,k,nord,iflag)
enddo
- call nextpat91(misub,K,nord,iflag)
- enddo
-endif
+ endif
998 continue
-! Re-order the codeword to [message bits][parity bits] format.
-cw(indices)=cw
-hdec(indices)=hdec
-decoded=cw(1:K)
-call chkcrc14a(decoded,nbadcrc)
-message77=decoded(1:77)
-if(nbadcrc.eq.1) nhardmin=-nhardmin
+! Re-order the codeword to [message bits][parity bits] format.
+ cw(indices)=cw
+ hdec(indices)=hdec
+ message91=cw(1:91)
+ m96=0
+ m96(1:77)=cw(1:77)
+ m96(83:96)=cw(78:91)
+ call get_crc14(m96,96,nbadcrc)
+ if(nbadcrc.ne.0) nhardmin=-nhardmin
-return
+ return
end subroutine osd174_91
subroutine mrbencode91(me,codeword,g2,N,K)
-integer*1 me(K),codeword(N),g2(N,K)
+ integer*1 me(K),codeword(N),g2(N,K)
! fast encoding for low-weight test patterns
- codeword=0
- do i=1,K
- if( me(i) .eq. 1 ) then
- codeword=ieor(codeword,g2(1:N,i))
- endif
- enddo
-return
+ codeword=0
+ do i=1,K
+ if( me(i) .eq. 1 ) then
+ codeword=ieor(codeword,g2(1:N,i))
+ endif
+ enddo
+ return
end subroutine mrbencode91
subroutine nextpat91(mi,k,iorder,iflag)
- integer*1 mi(k),ms(k)
+ integer*1 mi(k),ms(k)
! generate the next test error pattern
- ind=-1
- do i=1,k-1
- if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i
- enddo
- if( ind .lt. 0 ) then ! no more patterns of this order
- iflag=ind
- return
- endif
- ms=0
- ms(1:ind-1)=mi(1:ind-1)
- ms(ind)=1
- ms(ind+1)=0
- if( ind+1 .lt. k ) then
- nz=iorder-sum(ms)
- ms(k-nz+1:k)=1
- endif
- mi=ms
- do i=1,k ! iflag will point to the lowest-index 1 in mi
- if(mi(i).eq.1) then
- iflag=i
- exit
- endif
- enddo
- return
+ ind=-1
+ do i=1,k-1
+ if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i
+ enddo
+ if( ind .lt. 0 ) then ! no more patterns of this order
+ iflag=ind
+ return
+ endif
+ ms=0
+ ms(1:ind-1)=mi(1:ind-1)
+ ms(ind)=1
+ ms(ind+1)=0
+ if( ind+1 .lt. k ) then
+ nz=iorder-sum(ms)
+ ms(k-nz+1:k)=1
+ endif
+ mi=ms
+ do i=1,k ! iflag will point to the lowest-index 1 in mi
+ if(mi(i).eq.1) then
+ iflag=i
+ exit
+ endif
+ enddo
+ return
end subroutine nextpat91
subroutine boxit91(reset,e2,ntau,npindex,i1,i2)
- integer*1 e2(1:ntau)
- integer indexes(5000,2),fp(0:525000),np(5000)
- logical reset
- common/boxes/indexes,fp,np
+ integer*1 e2(1:ntau)
+ integer indexes(5000,2),fp(0:525000),np(5000)
+ logical reset
+ common/boxes/indexes,fp,np
+
+ if(reset) then
+ patterns=-1
+ fp=-1
+ np=-1
+ sc=-1
+ indexes=-1
+ reset=.false.
+ endif
- if(reset) then
- patterns=-1
- fp=-1
- np=-1
- sc=-1
- indexes=-1
- reset=.false.
- endif
-
- indexes(npindex,1)=i1
- indexes(npindex,2)=i2
- ipat=0
- do i=1,ntau
- if(e2(i).eq.1) then
- ipat=ipat+ishft(1,ntau-i)
- endif
- enddo
+ indexes(npindex,1)=i1
+ indexes(npindex,2)=i2
+ ipat=0
+ do i=1,ntau
+ if(e2(i).eq.1) then
+ ipat=ipat+ishft(1,ntau-i)
+ endif
+ enddo
- ip=fp(ipat) ! see what's currently stored in fp(ipat)
- if(ip.eq.-1) then
- fp(ipat)=npindex
- else
- do while (np(ip).ne.-1)
- ip=np(ip)
- enddo
- np(ip)=npindex
- endif
- return
+ ip=fp(ipat) ! see what's currently stored in fp(ipat)
+ if(ip.eq.-1) then
+ fp(ipat)=npindex
+ else
+ do while (np(ip).ne.-1)
+ ip=np(ip)
+ enddo
+ np(ip)=npindex
+ endif
+ return
end subroutine boxit91
subroutine fetchit91(reset,e2,ntau,i1,i2)
- integer indexes(5000,2),fp(0:525000),np(5000)
- integer lastpat
- integer*1 e2(ntau)
- logical reset
- common/boxes/indexes,fp,np
- save lastpat,inext
+ integer indexes(5000,2),fp(0:525000),np(5000)
+ integer lastpat
+ integer*1 e2(ntau)
+ logical reset
+ common/boxes/indexes,fp,np
+ save lastpat,inext
- if(reset) then
- lastpat=-1
- reset=.false.
- endif
+ if(reset) then
+ lastpat=-1
+ reset=.false.
+ endif
- ipat=0
- do i=1,ntau
- if(e2(i).eq.1) then
- ipat=ipat+ishft(1,ntau-i)
- endif
- enddo
- index=fp(ipat)
+ ipat=0
+ do i=1,ntau
+ if(e2(i).eq.1) then
+ ipat=ipat+ishft(1,ntau-i)
+ endif
+ enddo
+ index=fp(ipat)
- if(lastpat.ne.ipat .and. index.gt.0) then ! return first set of indices
- i1=indexes(index,1)
- i2=indexes(index,2)
- inext=np(index)
- elseif(lastpat.eq.ipat .and. inext.gt.0) then
- i1=indexes(inext,1)
- i2=indexes(inext,2)
- inext=np(inext)
- else
- i1=-1
- i2=-1
- inext=-1
- endif
- lastpat=ipat
- return
+ if(lastpat.ne.ipat .and. index.gt.0) then ! return first set of indices
+ i1=indexes(index,1)
+ i2=indexes(index,2)
+ inext=np(index)
+ elseif(lastpat.eq.ipat .and. inext.gt.0) then
+ i1=indexes(inext,1)
+ i2=indexes(inext,2)
+ inext=np(inext)
+ else
+ i1=-1
+ i2=-1
+ inext=-1
+ endif
+ lastpat=ipat
+ return
end subroutine fetchit91
-
+
diff --git a/lib/ft8/subtractft8.f90 b/lib/ft8/subtractft8.f90
index ec0beea9..7c3b5908 100644
--- a/lib/ft8/subtractft8.f90
+++ b/lib/ft8/subtractft8.f90
@@ -1,4 +1,4 @@
-subroutine subtractft8(dd,itone,f0,dt)
+subroutine subtractft8(dd0,itone,f0,dt,lrefinedt)
! Subtract an ft8 signal
!
@@ -7,60 +7,98 @@ subroutine subtractft8(dd,itone,f0,dt)
! Complex amp : cfilt(t) = LPF[ dd(t)*CONJG(cref(t)) ]
! Subtract : dd(t) = dd(t) - 2*REAL{cref*cfilt}
- use timer_module, only: timer
-
parameter (NMAX=15*12000,NFRAME=1920*79)
- parameter (NFFT=NMAX,NFILT=1400)
- real*4 dd(NMAX), window(-NFILT/2:NFILT/2), xjunk
- complex cref,camp,cfilt,cw
+ parameter (NFFT=NMAX,NFILT=4000)
+ real dd(NMAX),dd0(NMAX)
+ real window(-NFILT/2:NFILT/2)
+ real x(NFFT+2)
+ real endcorrection(NFILT/2+1)
+ complex cx(0:NFFT/2)
+ complex cref,camp,cfilt,cw,z
integer itone(79)
- logical first
+ logical first,lrefinedt,ldt
data first/.true./
- common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME)
- save first
-
- nstart=dt*12000+1
- nsym=79
- nsps=1920
- fs=12000.0
- icmplx=1
- bt=2.0
- call gen_ft8wave(itone,nsym,nsps,bt,fs,f0,cref,xjunk,icmplx,NFRAME)
- camp=0.
- do i=1,nframe
- id=nstart-1+i
- if(id.ge.1.and.id.le.NMAX) camp(i)=dd(id)*conjg(cref(i))
- enddo
+ common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX)
+ equivalence (x,cx)
+ save first,/heap8/,endcorrection
- if(first) then
-! Create and normalize the filter
+ if(first) then ! Create and normalize the filter
pi=4.0*atan(1.0)
fac=1.0/float(nfft)
- sum=0.0
+ sumw=0.0
do j=-NFILT/2,NFILT/2
window(j)=cos(pi*j/NFILT)**2
- sum=sum+window(j)
+ sumw=sumw+window(j)
enddo
cw=0.
- cw(1:NFILT+1)=window/sum
+ cw(1:NFILT+1)=window/sumw
cw=cshift(cw,NFILT/2+1)
call four2a(cw,nfft,1,-1,1)
cw=cw*fac
first=.false.
+ do j=1,NFILT/2+1
+ endcorrection(j)=1.0/(1.0-sum(window(j-1:NFILT/2))/sumw)
+ enddo
endif
- cfilt=0.0
- cfilt(1:nframe)=camp(1:nframe)
- call four2a(cfilt,nfft,1,-1,1)
- cfilt(1:nfft)=cfilt(1:nfft)*cw(1:nfft)
- call four2a(cfilt,nfft,1,1,1)
-
-! Subtract the reconstructed signal
- do i=1,nframe
- j=nstart+i-1
- if(j.ge.1 .and. j.le.NMAX) dd(j)=dd(j)-2*REAL(cfilt(i)*cref(i))
- enddo
+! Generate complex reference waveform cref
+ call gen_ft8wave(itone,79,1920,2.0,12000.0,f0,cref,xjunk,1,NFRAME)
+ ldt=lrefinedt
+ if(ldt) then !Are we refining DT ?
+ sqa=sqf(-90)
+ sqb=sqf(+90)
+ sq0=sqf(0)
+ call peakup(sqa,sq0,sqb,dx)
+ if(abs(dx).gt.1.0) return !No acceptable minimum: do not subtract
+ i2=nint(90.0*dx) !Best estimate of idt
+ ldt=.false.
+ sq0=sqf(i2) !Do the subtraction with idt=i2
+ else
+ sq0=sqf(0) !Do the subtraction with idt=0
+ endif
+ dd0=dd !Return dd0 with this signal subtracted
return
-end subroutine subtractft8
+contains
+
+ real function sqf(idt) !Internal function: all variables accessible
+ nstart=dt*12000+1 + idt
+ camp=0.
+ dd=dd0
+ do i=1,nframe
+ j=nstart-1+i
+ if(j.ge.1.and.j.le.NMAX) camp(i)=dd(j)*conjg(cref(i))
+ enddo
+
+ cfilt(1:nframe)=camp(1:nframe)
+ cfilt(nframe+1:)=0.0
+ call four2a(cfilt,nfft,1,-1,1)
+ cfilt(1:nfft)=cfilt(1:nfft)*cw(1:nfft)
+ call four2a(cfilt,nfft,1,1,1)
+ cfilt(1:NFILT/2+1)=cfilt(1:NFILT/2+1)*endcorrection
+ cfilt(nframe:nframe-NFILT/2:-1)=cfilt(nframe:nframe-NFILT/2:-1)*endcorrection
+ x=0.
+ do i=1,nframe
+ j=nstart+i-1
+ if(j.ge.1 .and. j.le.NMAX) then
+ z=cfilt(i)*cref(i)
+ dd(j)=dd(j)-2.0*real(z) !Subtract the reconstructed signal
+ x(i)=dd(j)
+ endif
+ enddo
+ sqq=0.
+ if(ldt) then
+ call four2a(cx,NFFT,1,-1,0) !Forward FFT, r2c
+ df=12000.0/NFFT
+ ia=(f0-1.5*6.25)/df
+ ib=(f0+8.5*6.25)/df
+ do i=ia,ib
+ sqq=sqq + real(cx(i))*real(cx(i)) + aimag(cx(i))*aimag(cx(i))
+ enddo
+ endif
+ sqf=sqq
+ return
+ end function sqf
+
+end subroutine subtractft8
diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90
index 219c6ebf..5ea2254a 100644
--- a/lib/ft8/sync8.f90
+++ b/lib/ft8/sync8.f90
@@ -2,6 +2,7 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
ncand,sbase)
include 'ft8_params.f90'
+ parameter (MAXPRECAND=500)
! Search over +/- 2.5s relative to 0.5s TX start time.
parameter (JZ=62)
complex cx(0:NH1)
@@ -11,7 +12,7 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
real x(NFFT1)
real sync2d(NH1,-JZ:JZ)
real red(NH1)
- real candidate0(3,maxcand)
+ real candidate0(3,MAXPRECAND)
real candidate(3,maxcand)
real dd(NMAX)
integer jpeak(NH1)
@@ -37,7 +38,7 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
enddo
savg=savg + s(1:NH1,j) !Average spectrum
enddo
- call baseline(savg,nfa,nfb,sbase)
+ call get_spectrum_baseline(dd,nfa,nfb,sbase)
ia=max(1,nint(nfa/df))
ib=nint(nfb/df)
@@ -100,19 +101,18 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
base=red(ibase)
red=red/base
- do i=1,min(maxcand,iz)
+ do i=1,min(MAXPRECAND,iz)
n=ia + indx(iz+1-i) - 1
- if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.maxcand) exit
+ if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.MAXPRECAND) exit
k=k+1
candidate0(1,k)=n*df
- candidate0(2,k)=(jpeak(n)-1)*tstep
+ candidate0(2,k)=(jpeak(n)-0.5)*tstep
candidate0(3,k)=red(n)
enddo
ncand=k
-! Put nfqso at top of list, and save only the best of near-dupe freqs.
+! Save only the best of near-dupe freqs.
do i=1,ncand
- if(abs(candidate0(1,i)-nfqso).lt.10.0) candidate0(1,i)=-candidate0(1,i)
if(i.ge.2) then
do j=1,i-1
fdiff=abs(candidate0(1,i))-abs(candidate0(1,j))
@@ -123,25 +123,31 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
enddo
endif
enddo
-
fac=20.0/maxval(s)
s=fac*s
! Sort by sync
-! call indexx(candidate0(3,1:ncand),ncand,indx)
-! Sort by frequency
- call indexx(candidate0(1,1:ncand),ncand,indx)
+ call indexx(candidate0(3,1:ncand),ncand,indx)
+! Place candidates within 10 Hz of nfqso at the top of the list
k=1
-! do i=ncand,1,-1
do i=1,ncand
+ if( abs( candidate0(1,i)-nfqso ).le.10.0 .and. candidate0(3,i).ge.syncmin ) then
+ candidate(1:3,k)=candidate0(1:3,i)
+ candidate0(3,i)=0.0
+ k=k+1
+ endif
+ enddo
+
+ do i=ncand,1,-1
j=indx(i)
-! if( candidate0(3,j) .ge. syncmin .and. candidate0(2,j).ge.-1.5 ) then
if( candidate0(3,j) .ge. syncmin ) then
candidate(2:3,k)=candidate0(2:3,j)
candidate(1,k)=abs(candidate0(1,j))
k=k+1
+ if(k.gt.maxcand) exit
endif
enddo
ncand=k-1
+
return
end subroutine sync8
diff --git a/lib/ft8/sync8d.f90 b/lib/ft8/sync8d.f90
index 798f2831..556acead 100644
--- a/lib/ft8/sync8d.f90
+++ b/lib/ft8/sync8d.f90
@@ -12,20 +12,16 @@ subroutine sync8d(cd0,i0,ctwk,itwk,sync)
integer icos7(0:6)
data icos7/3,1,4,0,6,5,2/
data first/.true./
- save first,twopi,fs2,dt2,taus,baud,csync
+ save first,twopi,csync
p(z1)=real(z1)**2 + aimag(z1)**2 !Statement function for power
! Set some constants and compute the csync array.
if( first ) then
twopi=8.0*atan(1.0)
- fs2=12000.0/NDOWN !Sample rate after downsampling
- dt2=1/fs2 !Corresponding sample interval
- taus=32*dt2 !Symbol duration
- baud=1.0/taus !Keying rate
do i=0,6
phi=0.0
- dphi=twopi*icos7(i)*baud*dt2
+ dphi=twopi*icos7(i)/32.0
do j=1,32
csync(i,j)=cmplx(cos(phi),sin(phi)) !Waveform for 7x7 Costas array
phi=mod(phi+dphi,twopi)
diff --git a/lib/ft8_decode.f90 b/lib/ft8_decode.f90
index 8cfd8600..34bce1bf 100644
--- a/lib/ft8_decode.f90
+++ b/lib/ft8_decode.f90
@@ -8,7 +8,7 @@ module ft8_decode
integer n30fox(MAXFOX)
integer n30z
integer nfox
-
+
type :: ft8_decoder
procedure(ft8_decode_callback), pointer :: callback
contains
@@ -33,46 +33,93 @@ module ft8_decode
contains
subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, &
- nutc,nfa,nfb,ndepth,ncontest,nagain,lft8apon,lapcqonly, &
- napwid,mycall12,hiscall12,hisgrid6)
-! use wavhdr
+ nutc,nfa,nfb,nzhsym,ndepth,emedelay,ncontest,nagain,lft8apon, &
+ lapcqonly,napwid,mycall12,hiscall12,ldiskdat)
+ use iso_c_binding, only: c_bool, c_int
use timer_module, only: timer
+ use shmem, only: shmem_lock, shmem_unlock
+
include 'ft8/ft8_params.f90'
-! type(hdr) h
class(ft8_decoder), intent(inout) :: this
procedure(ft8_decode_callback) :: callback
- parameter (MAXCAND=300)
+ parameter (MAXCAND=300,MAX_EARLY=100)
+ real*8 tsec,tseq
real s(NH1,NHSYM)
real sbase(NH1)
real candidate(3,MAXCAND)
- real dd(15*12000)
+ real dd(15*12000),dd1(15*12000)
logical, intent(in) :: lft8apon,lapcqonly,nagain
- logical newdat,lsubtract,ldupe
- character*12 mycall12,hiscall12,mycall12_0
- character*6 hisgrid6
+ logical newdat,lsubtract,ldupe,lrefinedt
+ logical*1 ldiskdat
+ logical lsubtracted(MAX_EARLY)
+ character*12 mycall12,hiscall12
integer*2 iwave(15*12000)
- integer apsym2(58)
+ integer apsym2(58),aph10(10)
character datetime*13,msg37*37
-! character message*22
character*37 allmessages(100)
+ character*12 ctime
integer allsnrs(100)
- data mycall12_0/'dummy'/
- save s,dd,mycall12_0
-
- if(mycall12.ne.mycall12_0) then
- mycall12_0=mycall12
- endif
+ integer itone(NN)
+ integer itone_save(NN,MAX_EARLY)
+ real f1_save(MAX_EARLY)
+ real xdt_save(MAX_EARLY)
+ save s,dd,dd1,ndec_early,itone_save,f1_save,xdt_save,lsubtracted,allmessages
+
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
1001 format("000000_",i6.6)
- call ft8apset(mycall12,hiscall12,apsym2)
- dd=iwave
- ndecodes=0
- allmessages=' '
- allsnrs=0
+ call ft8apset(mycall12,hiscall12,ncontest,apsym2,aph10)
+ if(nzhsym.le.47) then
+ dd=iwave
+ dd1=dd
+ endif
+ if(nzhsym.eq.41) then
+ ndecodes=0
+ allmessages=' '
+ allsnrs=0
+ else
+ ndecodes=ndec_early
+ endif
+ if(nzhsym.eq.47 .and. ndec_early.eq.0) then
+ dd1=dd
+ go to 800
+ endif
+ if(nzhsym.eq.47 .and. ndec_early.ge.1) then
+ lsubtracted=.false.
+ lrefinedt=.true.
+ if(ndepth.le.2) lrefinedt=.false.
+ call timer('sub_ft8b',0)
+ do i=1,ndec_early
+ if(xdt_save(i)-0.5.lt.0.396) then
+ call subtractft8(dd,itone_save(1,i),f1_save(i),xdt_save(i), &
+ lrefinedt)
+ lsubtracted(i)=.true.
+ endif
+ call timestamp(tsec,tseq,ctime)
+ if(.not.ldiskdat .and. tseq.ge.14.3d0) then !Bail out before done
+ call timer('sub_ft8b',1)
+ dd1=dd
+ go to 800
+ endif
+ enddo
+ call timer('sub_ft8b',1)
+ dd1=dd
+ go to 900
+ endif
+ if(nzhsym.eq.50 .and. ndec_early.ge.1) then
+ n=47*3456
+ dd(1:n)=dd1(1:n)
+ dd(n+1:)=iwave(n+1:)
+ call timer('sub_ft8c',0)
+ do i=1,ndec_early
+ if(lsubtracted(i)) cycle
+ call subtractft8(dd,itone_save(1,i),f1_save(i),xdt_save(i),.true.)
+ enddo
+ call timer('sub_ft8c',1)
+ endif
ifa=nfa
ifb=nfb
if(nagain) then
@@ -81,24 +128,26 @@ contains
endif
! For now:
-! ndepth=1: no subtraction, 1 pass, belief propagation only
-! ndepth=2: subtraction, 3 passes, belief propagation only
+! ndepth=1: subtraction, 3 passes, bp (no subtract refinement)
+! ndepth=2: subtraction, 3 passes, bp+osd (no subtract refinement)
! ndepth=3: subtraction, 3 passes, bp+osd
- if(ndepth.eq.1) npass=1
- if(ndepth.ge.2) npass=3
+ npass=3
do ipass=1,npass
- newdat=.true. ! Is this a problem? I hijacked newdat.
- syncmin=1.5
+ newdat=.true.
+ syncmin=1.3
if(ipass.eq.1) then
lsubtract=.true.
- if(ndepth.eq.1) lsubtract=.false.
+ ndeep=ndepth
+ if(ndepth.eq.3) ndeep=2
elseif(ipass.eq.2) then
n2=ndecodes
if(ndecodes.eq.0) cycle
lsubtract=.true.
+ ndeep=ndepth
elseif(ipass.eq.3) then
if((ndecodes-n2).eq.0) cycle
- lsubtract=.false.
+ lsubtract=.true.
+ ndeep=3
endif
call timer('sync8 ',0)
maxc=MAXCAND
@@ -110,12 +159,12 @@ contains
f1=candidate(1,icand)
xdt=candidate(2,icand)
xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0))
- nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
+ msg37=' '
call timer('ft8b ',0)
- call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
+ call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndeep,nzhsym,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,ncontest,iaptype,mycall12, &
- hiscall12,sync,f1,xdt,xbase,apsym2,nharderrors,dmin, &
- nbadcrc,iappass,iera,msg37,xsnr)
+ hiscall12,f1,xdt,xbase,apsym2,aph10,nharderrors,dmin, &
+ nbadcrc,iappass,msg37,xsnr,itone)
call timer('ft8b ',1)
nsnr=nint(xsnr)
xdt=xdt-0.5
@@ -123,26 +172,49 @@ contains
if(nbadcrc.eq.0) then
ldupe=.false.
do id=1,ndecodes
- if(msg37.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true.
+ if(msg37.eq.allmessages(id)) ldupe=.true.
enddo
if(.not.ldupe) then
ndecodes=ndecodes+1
allmessages(ndecodes)=msg37
allsnrs(ndecodes)=nsnr
+ f1_save(ndecodes)=f1
+ xdt_save(ndecodes)=xdt+0.5
+ itone_save(1:NN,ndecodes)=itone
endif
-! write(81,1004) nutc,ncand,icand,ipass,iaptype,iappass, &
-! nharderrors,dmin,hd,min(sync,999.0),nint(xsnr), &
-! xdt,nint(f1),msg37
-!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a37)
-! flush(81)
if(.not.ldupe .and. associated(this%callback)) then
qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0]
+ if(emedelay.ne.0) xdt=xdt+2.0
call this%callback(sync,nsnr,xdt,f1,msg37,iaptype,qual)
endif
endif
- enddo
- enddo
+ call timestamp(tsec,tseq,ctime)
+ if(.not.ldiskdat .and. nzhsym.eq.41 .and. &
+ tseq.ge.13.4d0) go to 800 !Bail out before done
+ enddo ! icand
+ enddo ! ipass
+
+800 ndec_early=0
+ if(nzhsym.lt.50) ndec_early=ndecodes
+
+900 return
+end subroutine decode
+
+subroutine timestamp(tsec,tseq,ctime)
+ real*8 tsec,tseq
+ character*12 ctime
+ integer itime(8)
+ call date_and_time(values=itime)
+ tsec=3600.d0*(itime(5)-itime(4)/60.d0) + 60.d0*itime(6) + &
+ itime(7) + 0.001d0*itime(8)
+ tsec=mod(tsec+2*86400.d0,86400.d0)
+ tseq=mod(itime(7)+0.001d0*itime(8),15.d0)
+ if(tseq.lt.10.d0) tseq=tseq+15.d0
+ sec=itime(7)+0.001*itime(8)
+ write(ctime,1000) itime(5)-itime(4)/60,itime(6),sec
+1000 format(i2.2,':',i2.2,':',f6.3)
+ if(ctime(7:7).eq.' ') ctime(7:7)='0'
return
- end subroutine decode
+end subroutine timestamp
end module ft8_decode
diff --git a/lib/ft8dec.f90 b/lib/ft8dec.f90
deleted file mode 100644
index 2dea2a91..00000000
--- a/lib/ft8dec.f90
+++ /dev/null
@@ -1,111 +0,0 @@
-subroutine ft8dec(iwave,nQSOProgress,nfqso,nftx,newdat, &
- nutc,nfa,nfb,ndepth,ncontest,nagain,lft8apon,lapcqonly, &
- napwid,mycall12,hiscall12,hisgrid6)
-! use wavhdr
- use timer_module, only: timer
- include 'ft8/ft8_params.f90'
-! type(hdr) h
-
- parameter (MAXCAND=300)
- real s(NH1,NHSYM)
- real sbase(NH1)
- real candidate(3,MAXCAND)
- real dd(15*12000)
- logical, intent(in) :: lft8apon,lapcqonly,nagain
- logical newdat,lsubtract,ldupe
- character*12 mycall12,hiscall12,mycall12_0
- character*6 hisgrid6
- integer*2 iwave(15*12000)
- integer apsym2(58)
- character datetime*13,msg37*37
-! character message*22
- character*37 allmessages(100)
- integer allsnrs(100)
- data mycall12_0/'dummy'/
- save s,dd,mycall12_0
-
- if(mycall12.ne.mycall12_0) then
- mycall12_0=mycall12
- endif
-
- write(datetime,1001) nutc !### TEMPORARY ###
-1001 format("000000_",i6.6)
-
- call ft8apset(mycall12,hiscall12,apsym2)
- dd=iwave
- ndecodes=0
- allmessages=' '
- allsnrs=0
- ifa=nfa
- ifb=nfb
- if(nagain) then
- ifa=nfqso-10
- ifb=nfqso+10
- endif
-
-! For now:
-! ndepth=1: no subtraction, 1 pass, belief propagation only
-! ndepth=2: subtraction, 3 passes, belief propagation only
-! ndepth=3: subtraction, 3 passes, bp+osd
- if(ndepth.eq.1) npass=1
- if(ndepth.ge.2) npass=3
- do ipass=1,npass
- newdat=.true. ! Is this a problem? I hijacked newdat.
- syncmin=1.5
- if(ipass.eq.1) then
- lsubtract=.true.
- if(ndepth.eq.1) lsubtract=.false.
- elseif(ipass.eq.2) then
- n2=ndecodes
- if(ndecodes.eq.0) cycle
- lsubtract=.true.
- elseif(ipass.eq.3) then
- if((ndecodes-n2).eq.0) cycle
- lsubtract=.false.
- endif
- call timer('sync8 ',0)
- maxc=MAXCAND
- call sync8(dd,ifa,ifb,syncmin,nfqso,maxc,s,candidate, &
- ncand,sbase)
- call timer('sync8 ',1)
- do icand=1,ncand
- sync=candidate(3,icand)
- f1=candidate(1,icand)
- xdt=candidate(2,icand)
- xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0))
- nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
- call timer('ft8b ',0)
- call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
- lapcqonly,napwid,lsubtract,nagain,ncontest,iaptype,mycall12, &
- hiscall12,sync,f1,xdt,xbase,apsym2,nharderrors,dmin, &
- nbadcrc,iappass,iera,msg37,xsnr)
- call timer('ft8b ',1)
- nsnr=nint(xsnr)
- xdt=xdt-0.5
- hd=nharderrors+dmin
- if(nbadcrc.eq.0) then
- ldupe=.false.
- do id=1,ndecodes
- if(msg37.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true.
- enddo
- if(.not.ldupe) then
- ndecodes=ndecodes+1
- allmessages(ndecodes)=msg37
- allsnrs(ndecodes)=nsnr
- endif
-! write(81,1004) nutc,ncand,icand,ipass,iaptype,iappass, &
-! nharderrors,dmin,hd,min(sync,999.0),nint(xsnr), &
-! xdt,nint(f1),msg37
-!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a37)
-! flush(81)
- if(.not.ldupe) then
- qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0]
- write(*,1010) min(sync,999.0),nsnr,xdt,nint(f1), &
- iaptype,qual,msg37
-1010 format(f5.1,i4,f5.2,i5,i3,f5.1,1x,a37)
- endif
- endif
- enddo
- enddo
- return
-end subroutine ft8dec
diff --git a/lib/hint65.f90 b/lib/hint65.f90
index ec414a23..00eaf40c 100644
--- a/lib/hint65.f90
+++ b/lib/hint65.f90
@@ -62,10 +62,6 @@ subroutine hint65(s3,mrs,mrs2,nadd,nflip,mycall,hiscall,hisgrid,qual,decoded)
grid2(j)=grid
enddo
10 ncalls=j
- if(ncalls.lt.10) then
- write(*,1010) ncalls
-1010 format('CALL3.TXT very short (N =',i2,') or missing?')
- endif
close(23)
! NB: generation of test messages is not yet complete!
@@ -146,19 +142,11 @@ subroutine hint65(s3,mrs,mrs2,nadd,nflip,mycall,hiscall,hisgrid,qual,decoded)
endif
enddo
-!### Just in case ???
-! rewind 77
-! write(77,*) u1,u2,ipk,ipk2
-! call flush(77)
-!###
-
decoded=' '
bias=max(1.12*u2,0.35)
if(nadd.ge.4) bias=max(1.08*u2,0.45)
if(nadd.ge.8) bias=max(1.04*u2,0.60)
qual=100.0*(u1-bias)
-! write(*,3301) u1,u2,u1/u2,bias,qual,nadd,ipk,ipk2
-!3301 format(5f6.2,i3,2i6)
qmin=1.0
if(qual.ge.qmin) decoded=msg0(ipk)
diff --git a/lib/hspec.f90 b/lib/hspec.f90
index da30e021..144ddf19 100644
--- a/lib/hspec.f90
+++ b/lib/hspec.f90
@@ -1,6 +1,6 @@
-subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, &
- btrain,pcoeffs,ingain,mycall,hiscall,bshmsg,bswl,datadir,green,s, &
- jh,pxmax,dbNoGain,line1,mygrid)
+subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144, &
+ btrain,pcoeffs,ingain,mycall,hiscall,bshmsg,bswl,datadir,green,s, &
+ jh,pxmax,dbNoGain,line1)
! Input:
! k pointer to the most recent new data
@@ -8,7 +8,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, &
! ntrpdepth TR period and 1000*ndepth
! nrxfreq Rx audio center frequency
! ntol Decoding range is +/- ntol
-! ncontest Contest type (0=NONE 1=NA_VHF 2=EU_VHF 3=FIELD_DAY 4=RTTY)
+! ncontest Contest type (0=NONE 1=NA_VHF 2=EU_VHF 3=FIELD_DAY 4=RTTY 5=WW_DIGI)
! bmsk144 Boolean, true if in MSK144 mode
! btrain Boolean, turns on training in MSK144 mode
! ingain Relative gain for spectra
@@ -22,7 +22,6 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, &
character*80 line1
character*512 datadir
character*12 mycall,hiscall
- character*6 mygrid
integer*2 id2(0:120*12000-1)
logical*1 bmsk144,bshmsg,btrain,bswl
real green(0:JZ-1)
@@ -97,8 +96,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, &
tt2=sum(float(abs(id2(k0:k0+3583))))
if(tt1.ne.0.0 .and. tt2.ne.0) then
call mskrtd(id2(k-7168+1:k),nutc0,tsec,ntol,nrxfreq,ndepth, &
- mycall,mygrid,hiscall,bshmsg,btrain,pcoeffs,bswl, &
- datadir,line1)
+ mycall,hiscall,bshmsg,btrain,pcoeffs,bswl,datadir,line1)
endif
endif
endif
diff --git a/lib/ipcomm.cpp b/lib/ipcomm.cpp
deleted file mode 100644
index 6f65dcae..00000000
--- a/lib/ipcomm.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <QDebug>
-#include <QString>
-#include <QSharedMemory>
-#include <QSystemSemaphore>
-
-#include "../commons.h"
-
-// Multiple instances: KK1D, 17 Jul 2013
-QSharedMemory mem_jt9;
-
-// Semaphore not changed, as the acquire/release calls do not
-// appear to be used anywhere.
-QSystemSemaphore sem_jt9("sem_jt9", 1, QSystemSemaphore::Open);
-
-extern "C" {
- bool attach_jt9_();
- bool create_jt9_(int nsize);
- bool detach_jt9_();
- bool lock_jt9_();
- bool unlock_jt9_();
- struct jt9com * address_jt9_();
- int size_jt9_();
-// Multiple instances: wrapper for QSharedMemory::setKey()
- bool setkey_jt9_(char* mykey, int mykey_len);
-
- bool acquire_jt9_();
- bool release_jt9_();
-}
-
-bool attach_jt9_() {return mem_jt9.attach();}
-bool create_jt9_(int nsize) {return mem_jt9.create(nsize);}
-bool detach_jt9_() {return mem_jt9.detach();}
-bool lock_jt9_() {return mem_jt9.lock();}
-bool unlock_jt9_() {return mem_jt9.unlock();}
-struct jt9com * address_jt9_() {return reinterpret_cast<struct jt9com *>(mem_jt9.data());}
-int size_jt9_() {return (int)mem_jt9.size();}
-
-// Multiple instances:
-bool setkey_jt9_(char* mykey, int mykey_len) {
- char *tempstr = (char *)calloc(mykey_len+1,1);
- memset(tempstr, 0, mykey_len+1);
- strncpy(tempstr, mykey, mykey_len);
- QString s1 = QString(QLatin1String(tempstr));
- mem_jt9.setKey(s1);
- return true;}
-
-bool acquire_jt9_() {return sem_jt9.acquire();}
-bool release_jt9_() {return sem_jt9.release();}
diff --git a/lib/iscat.f90 b/lib/iscat.f90
index c02a0fbe..17d1454f 100644
--- a/lib/iscat.f90
+++ b/lib/iscat.f90
@@ -1,5 +1,5 @@
subroutine iscat(cdat0,npts0,nh,npct,t2,pick,cfile6,minsync,ntol, &
- NFreeze,MouseDF,mousebutton,mode4,nafc,nmore,psavg,maxlines,nlines,line)
+ mousebutton,mode4,nafc,nmore,psavg,maxlines,nlines,line)
! Decode an ISCAT signal
@@ -55,8 +55,8 @@ subroutine iscat(cdat0,npts0,nh,npct,t2,pick,cfile6,minsync,ntol, &
if(pick) t3=t2+t3
! Compute symbol spectra and establish sync:
- call synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol,NFreeze, &
- MouseDF,mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, &
+ call synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol, &
+ mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, &
ipk,jpk,idf,df1)
nfdot=nint(idf*df1)
diff --git a/lib/jt49sim.f90 b/lib/jt49sim.f90
index 6d3ea51a..e8aff69d 100644
--- a/lib/jt49sim.f90
+++ b/lib/jt49sim.f90
@@ -1,7 +1,8 @@
program jt49sim
! Generate simulated data for testing JT4 and JT9
-
+! April 26, 2020: changed to Watterson channel simulator (K9AN)
+!
use wavhdr
use packjt
use jt4
@@ -13,21 +14,21 @@ program jt49sim
real*4 xnoise(NMAX) !Generated random noise
real*4 dat(NMAX) !Generated real data
complex cdat(NMAX) !Generated complex waveform
- complex cspread(0:NFFT-1) !Complex amplitude for Rayleigh fading
+ complex c0(NMAX) !Waveform multipled by fading realization
complex z
real*8 f0,dt,twopi,phi,dphi,baud,fsample,freq,dnsps
character message*22,fname*11,csubmode*2,arg*12
character msgsent*22
nargs=iargc()
- if(nargs.ne. 7) then
- print *, 'Usage: jt49sim "msg" nA-nE Nsigs fDop DT Nfiles SNR'
- print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4G 10 0.2 0.0 1 0'
- print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 9A 1 0.0 0.0 1 -20'
+ if(nargs.ne. 8) then
+ print *, 'Usage: jt49sim "msg" nA-nE Nsigs fDop delay DT Nfiles SNR'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4G 10 0.2 1.0 0.0 1 0'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 9A 1 0.0 0.0 0.0 1 -20'
print *, 'Use msg=@nnnn to generate a tone at nnnn Hz:'
- print *, 'Example: jt49sim "@1500" 9A 1 10.0 0.0 1 -20'
+ print *, 'Example: jt49sim "@1500" 9A 1 10.0 0.0 0.0 1 -20'
print *, 'If Nsigs > 100, generate one signal with f0=Nsigs'
- print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4F 1800 0.2 0.0 1 -20'
+ print *, 'Example: jt49sim "K1ABC W9XYZ EN37" 4F 1800 0.2 0.0 0.0 1 -20'
go to 999
endif
call getarg(1,message)
@@ -42,20 +43,24 @@ program jt49sim
call getarg(4,arg)
read(arg,*) fspread
call getarg(5,arg)
- read(arg,*) xdt
+ read(arg,*) delay
call getarg(6,arg)
- read(arg,*) nfiles
+ read(arg,*) xdt
call getarg(7,arg)
+ read(arg,*) nfiles
+ call getarg(8,arg)
read(arg,*) snrdb
rms=100.
fsample=12000.d0 !Sample rate (Hz)
dt=1.d0/fsample !Sample interval (s)
twopi=8.d0*atan(1.d0)
- npts=60*12000 !Total samples in .wav file
- h=default_header(12000,npts)
+ h=default_header(12000,NMAX)
dfsig=2000.0/nsigs !Freq spacing between sigs in file (Hz)
ichk=0
+ nsym=0
+ dnsps=0.
+ baud=0.
if(imode.eq.4) then
nsym=206 !Number of channel symbols (JT4)
@@ -66,9 +71,10 @@ program jt49sim
dnsps=6912.d0 !Samples per symbol
baud=12000.d0/dnsps !Keying rate = 1.736...
endif
-
+ NZ=nsym*dnsps
+
write(*,1000)
-1000 format('File Sig Freq Mode S/N DT Dop Message'/60('-'))
+1000 format('File Sig Freq Mode S/N DT fDop delay Message'/60('-'))
do ifile=1,nfiles !Loop over requested number of files
write(fname,1002) ifile !Output filename
@@ -77,7 +83,7 @@ program jt49sim
xnoise=0.
cdat=0.
if(snrdb.lt.90) then
- do i=1,npts
+ do i=1,NMAX
xnoise(i)=gran() !Generate gaussian noise
enddo
endif
@@ -85,7 +91,7 @@ program jt49sim
do isig=1,nsigs !Generate requested number of sigs
if(mod(nsigs,2).eq.0) f0=1500.0 + dfsig*(isig-0.5-nsigs/2)
if(mod(nsigs,2).eq.1) f0=1500.0 + dfsig*(isig-(nsigs+1)/2)
- if(nsigs.eq.1) f0=1000.0
+ if(nsigs.eq.1) f0=1500.0
if(nsigs.gt.100) f0=nsigs
xsnr=snrdb
if(snrdb.eq.0.0) xsnr=-20 - isig
@@ -96,15 +102,14 @@ program jt49sim
bandwidth_ratio=2500.0/6000.0
sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*xsnr)
if(xsnr.gt.90.0) sig=1.0
- write(*,1020) ifile,isig,f0,csubmode,xsnr,xdt,fspread,message
-1020 format(i4,i4,f10.3,2x,a2,2x,f5.1,f6.2,f6.1,1x,a22)
+ write(*,1020) ifile,isig,f0,csubmode,xsnr,xdt,fspread,delay,message
+1020 format(i4,i4,f10.3,2x,a2,2x,f5.1,f6.2,f6.1,1x,f6.1,2x,a22)
phi=0.d0
dphi=0.d0
k=(xdt+1.0)*12000 !Start audio at t = xdt + 1.0 s
- isym0=-99
-
- do i=1,npts !Add this signal into cdat()
+ isym0=-99
+ do i=1,NMAX !Add this signal into cdat()
isym=i/dnsps + 1
if(isym.gt.nsym) exit
if(isym.ne.isym0) then
@@ -122,73 +127,22 @@ program jt49sim
xphi=phi
z=cmplx(cos(xphi),sin(xphi))
k=k+1
- if(k.ge.1) cdat(k)=cdat(k) + sig*z
+ if(k.ge.1) cdat(k)=cdat(k) + z
enddo
if(nsigs.gt.100) exit
enddo
- if(fspread.ne.0) then !Apply specified Doppler spread
- df=12000.0/nfft
- twopi=8*atan(1.0)
- cspread(0)=1.0
- cspread(NH)=0.
- b=6.0 !Lorenzian 3/28 onward
- do i=1,NH
- f=i*df
- x=b*f/fspread
- z=0.
- a=0.
- if(x.lt.3.0) then !Cutoff beyond x=3
- a=sqrt(1.111/(1.0+x*x)-0.1) !Lorentzian
- call random_number(r1)
- phi1=twopi*r1
- z=a*cmplx(cos(phi1),sin(phi1))
- endif
- cspread(i)=z
- z=0.
- if(x.lt.50.0) then
- call random_number(r2)
- phi2=twopi*r2
- z=a*cmplx(cos(phi2),sin(phi2))
- endif
- cspread(NFFT-i)=z
- enddo
-
- do i=0,NFFT-1
- f=i*df
- if(i.gt.NH) f=(i-nfft)*df
- s=real(cspread(i))**2 + aimag(cspread(i))**2
-! write(13,3000) i,f,s,cspread(i)
-!3000 format(i5,f10.3,3f12.6)
- enddo
-! s=real(cspread(0))**2 + aimag(cspread(0))**2
-! write(13,3000) 1024,0.0,s,cspread(0)
-
- call four2a(cspread,NFFT,1,1,1) !Transform to time domain
-
- sum=0.
- do i=0,NFFT-1
- p=real(cspread(i))**2 + aimag(cspread(i))**2
- sum=sum+p
- enddo
- avep=sum/NFFT
- fac=sqrt(1.0/avep)
- cspread=fac*cspread !Normalize to constant avg power
- cdat(1:NFFT)=cspread*cdat(1:NFFT) !Apply Rayleigh fading
-
-! do i=0,NFFT-1
-! p=real(cspread(i))**2 + aimag(cspread(i))**2
-! write(14,3010) i,p,cspread(i)
-!3010 format(i8,3f12.6)
-! enddo
-
+ c0=cdat
+ if(fspread.ne.0 .or. delay.ne.0) then !Apply specified Doppler spread
+ fs=12000.0
+ call watterson(c0,NMAX,NZ,fs,delay,fspread)
endif
- dat=aimag(cdat) + xnoise !Add the generated noise
+ dat=sig*aimag(c0) + xnoise !Add the generated noise
fac=32767.0/nsigs
- if(snrdb.ge.90.0) iwave(1:npts)=nint(fac*dat(1:npts))
- if(snrdb.lt.90.0) iwave(1:npts)=nint(rms*dat(1:npts))
- write(10) h,iwave(1:npts) !Save the .wav file
+ if(snrdb.ge.90.0) iwave(1:NMAX)=nint(fac*dat(1:NMAX))
+ if(snrdb.lt.90.0) iwave(1:NMAX)=nint(rms*dat(1:NMAX))
+ write(10) h,iwave(1:NMAX) !Save the .wav file
close(10)
enddo
diff --git a/lib/jt4_decode.f90 b/lib/jt4_decode.f90
index ff0b33c4..0b825990 100644
--- a/lib/jt4_decode.f90
+++ b/lib/jt4_decode.f90
@@ -194,7 +194,7 @@ contains
call this%decode_callback(nsnr,dtx,nfreq,.true.,csync, &
.false.,decoded,99.,ich,.false.,0)
end if
- nsave=0
+!### nsave=0
go to 990
else !Fano failed
@@ -299,6 +299,7 @@ contains
nfsave=0
dtdiff=0.2
first=.false.
+ nsave=1 ! ### Should this be here? ###
endif
do i=1,64
@@ -311,7 +312,7 @@ contains
dtsave(nsave)=dtxx
nfsave(nsave)=nfreq
flipsave(nsave)=flip
- ppsave(1:207,1:7,nsave)=rsymbol(1:207,1:7)
+ ppsave(1:207,1:7,nsave)=rsymbol(1:207,1:7)
10 sym=0.
syncsum=0.
diff --git a/lib/jt65_decode.f90 b/lib/jt65_decode.f90
index 4a899b8b..6177492c 100644
--- a/lib/jt65_decode.f90
+++ b/lib/jt65_decode.f90
@@ -76,7 +76,7 @@ contains
character*22 decoded
end type accepted_decode
type(accepted_decode) dec(50)
- logical :: first_time,prtavg,single_decode,bVHF
+ logical :: first_time,prtavg,single_decode,bVHF,clear_avg65
integer h0(0:11),d0(0:11)
real r0(0:11)
@@ -90,24 +90,20 @@ contains
! 0 1 2 3 4 5 6 7 8 9 10 11
data r0/0.70,0.72,0.74,0.76,0.78,0.80,0.82,0.84,0.86,0.88,0.90,0.90/
- data nutc0/-999/,nfreq0/-999/,nsave/0/
+ data nutc0/-999/,nfreq0/-999/,nsave/0/,clear_avg65/.true./
save
this%callback => callback
+ first_time=nrobust !Silence compiler warning
first_time=newdat
dd=dd0
ndecoded=0
+ ndecoded0=0
if(nsubmode.ge.100) then
! This is QRA64 mode
mode64=2**(nsubmode-100)
-!###
-! open(60,file='qra64_data.bin',access='stream',position='append')
-! write(60) dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
-! mycall,hiscall,hisgrid
-! close(60)
-!###
- call qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
+ call qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
emedelay,mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft)
if (associated(this%callback)) then
ndrift=0
@@ -124,7 +120,7 @@ contains
single_decode=iand(nexp_decode,32).ne.0 .or. nagain
bVHF=iand(nexp_decode,64).ne.0
- if( bVHF ) then
+ if(bVHF) then
nvec=ntrials
npass=1
if(n2pass.gt.1) npass=2
@@ -192,16 +188,10 @@ contains
ncand=0
call timer('sync65 ',0)
- call sync65(nfa,nfb,naggressive,ntol,nqsym,ca,ncand,nrob,bVHF)
+ call sync65(nfa,nfb,ntol,nqsym,ca,ncand,nrob,bVHF)
+ ncand=min(ncand,50/ipass)
call timer('sync65 ',1)
-! If a candidate was found within +/- ntol of nfqso, move it into ca(1).
- call fqso_first(nfqso,ntol,ca,ncand)
- if(single_decode) then
- if(ncand.eq.0) ncand=1
- if(abs(ca(1)%freq - f0).gt.width) width=2*df !### ??? ###
- endif
-
mode65=2**nsubmode
nflip=1
nqd=0
@@ -213,6 +203,7 @@ contains
if(clearave) then
nsum=0
nsave=0
+ clear_avg65=.true.
endif
if(bVHF) then
@@ -221,6 +212,7 @@ contains
ca(ncand)%sync=5.0
ca(ncand)%dt=2.5
ca(ncand)%freq=nfqso
+ ca(ncand)%flip=0
endif
do icand=1,ncand
sync1=ca(icand)%sync
@@ -228,7 +220,7 @@ contains
freq=ca(icand)%freq
if(bVHF) then
flip=ca(icand)%flip
- nflip=flip
+ nflip=int(flip)
endif
if(sync1.lt.float(minsync)) nflip=0
if(ipass.eq.1) ntry65a=ntry65a + 1
@@ -238,21 +230,32 @@ contains
nspecial=0
call decode65a(dd,npts,first_time,nqd,freq,nflip,mode65,nvec, &
naggressive,ndepth,ntol,mycall,hiscall,hisgrid,nQSOProgress, &
- ljt65apon,nexp_decode,bVHF,sync2,a,dtx,nft,nspecial,qual, &
+ ljt65apon,bVHF,sync2,a,dtx,nft,nspecial,qual, &
nhist,nsmo,decoded)
+ call timer('decod65a',1)
+
+ if(.not.bVHF) then
+ if(abs(a(1)).gt.10.0/ipass) cycle
+ ibad=0
+ if(abs(a(1)).gt.5.0) ibad=1
+ if(abs(a(2)).gt.2.0) ibad=ibad+1
+ if(abs(dtx-1.0).gt.2.5) ibad=ibad+1
+ if(ibad.ge.2) cycle
+ endif
+
+ if(nspecial.eq.0 .and. sync1.eq.5.0 .and. dtx.eq.2.5) cycle
if(nspecial.eq.2) decoded='RO'
if(nspecial.eq.3) decoded='RRR'
if(nspecial.eq.4) decoded='73'
- call timer('decod65a',1)
if(sync1.lt.float(minsync) .and. &
decoded.eq.' ') nflip=0
if(nft.ne.0) nsum=1
-
+
nhard_min=param(1)
nrtt1000=param(4)
ntotal_min=param(5)
nsmo=param(9)
-
+
nfreq=nint(freq+a(1))
ndrift=nint(2.0*a(2))
if(bVHF) then
@@ -267,9 +270,9 @@ contains
if(nsnr.lt.-30) nsnr=-30
if(nsnr.gt.-1) nsnr=-1
nftt=0
-
!********* DOES THIS STILL WORK WHEN NFT INCLUDES # OF AP SYMBOLS USED??
- if(nft.ne.1 .and. iand(ndepth,16).eq.16 .and. (.not.prtavg)) then
+ if(nft.ne.1 .and. iand(ndepth,16).eq.16 .and. &
+ sync1.ge.float(minsync) .and. (.not.prtavg)) then
! Single-sequence FT decode failed, so try for an average FT decode.
if(nutc.ne.nutc0 .or. abs(nfreq-nfreq0).gt.ntol) then
! This is a new minute or a new frequency, so call avg65.
@@ -278,13 +281,14 @@ contains
nsave=nsave+1
nsave=mod(nsave-1,64)+1
call avg65(nutc,nsave,sync1,dtx,nflip,nfreq,mode65,ntol, &
- ndepth,nagain,ntrials,naggressive,clearave,neme,mycall, &
- hiscall,hisgrid,nftt,avemsg,qave,deepave,nsum,ndeepave, &
- nQSOProgress,ljt65apon)
+ ndepth,nagain,ntrials,naggressive,clear_avg65,neme, &
+ mycall,hiscall,hisgrid,nftt,avemsg,qave,deepave,nsum, &
+ ndeepave,nQSOProgress,ljt65apon)
nsmo=param(9)
- nqave=qave
+ nqave=int(qave)
- if (associated(this%callback) .and. nsum.ge.2) then
+ if (associated(this%callback) .and.nftt.ge.1 .and. nsum.ge.2) then
+! Display a decoded message obtained by averaging 2 or more transmissions
call this%callback(sync1,nsnr,dtx-1.0,nfreq,ndrift, &
nflip,width,avemsg,nftt,nqave,nsmo,nsum,minsync)
prtavg=.true.
@@ -293,14 +297,15 @@ contains
endif
endif
- if(nftt.eq.1) then
-! nft=1
- decoded=avemsg
- go to 5
- endif
+ if(nftt.eq.0) go to 5
+! if(nftt.eq.1) then
+!! nft=1
+! decoded=avemsg
+! go to 5
+! endif
n=naggressive
rtt=0.001*nrtt1000
- if(nft.lt.2 .and. minsync.ge.0 .and. nspecial.eq.0) then
+ if(nft.lt.2 .and. minsync.ge.0 .and. nspecial.eq.0 .and. .not.bVHF) then
if(nhard_min.gt.50) cycle
if(nhard_min.gt.h0(n)) cycle
if(ntotal_min.gt.d0(n)) cycle
@@ -310,7 +315,8 @@ contains
5 continue
if(decoded.eq.decoded0 .and. abs(freq-freq0).lt. 3.0 .and. &
minsync.ge.0) cycle !Don't display dupes
- if(decoded.ne.' ' .or. minsync.lt.0) then
+! if(decoded.ne.' ' .or. minsync.lt.0) then
+ if(decoded.ne.' ' .or. bVHF) then
if(nsubtract.eq.1) then
call timer('subtr65 ',0)
call subtract65(dd,npts,freq,dtx)
@@ -324,7 +330,7 @@ contains
exit
endif
enddo
- if(ndupe.ne.1 .and. sync1.ge.float(minsync)) then
+ if(ndupe.ne.1 .and. ((sync1.ge.float(minsync)) .or. bVHF)) then
if(ipass.eq.1) n65a=n65a + 1
if(ipass.eq.2) n65b=n65b + 1
if(ndecoded.lt.50) ndecoded=ndecoded+1
@@ -332,9 +338,9 @@ contains
dec(ndecoded)%dt=dtx
dec(ndecoded)%sync=sync2
dec(ndecoded)%decoded=decoded
- nqual=min(qual,9999.0)
+ nqual=min(int(qual),9999)
- if (associated(this%callback)) then
+ if(associated(this%callback)) then
call this%callback(sync1,nsnr,dtx-1.0,nfreq,ndrift, &
nflip,width,decoded,nft,nqual,nsmo,1,minsync)
end if
@@ -342,16 +348,18 @@ contains
decoded0=decoded
freq0=freq
if(decoded0.eq.' ') decoded0='*'
+ if(single_decode .and. ndecoded.gt.0) go to 900
endif
- enddo !Candidate loop
- if(ipass.eq.2 .and. ndecoded.lt.1) exit
- enddo !Multiple-pass loop
+ enddo ! icand
+ if(ipass.gt.1 .and. ndecoded.eq.ndecoded0) exit
+ ndecoded0=ndecoded
+ enddo ! ipass
900 return
end subroutine decode
subroutine avg65(nutc,nsave,snrsync,dtxx,nflip,nfreq,mode65,ntol,ndepth, &
- nagain, ntrials,naggressive,clearave,neme,mycall,hiscall,hisgrid,nftt, &
- avemsg,qave,deepave,nsum,ndeepave,nQSOProgress,ljt65apon)
+ nagain, ntrials,naggressive,clear_avg65,neme,mycall,hiscall,hisgrid, &
+ nftt,avemsg,qave,deepave,nsum,ndeepave,nQSOProgress,ljt65apon)
! Decodes averaged JT65 data
@@ -374,20 +382,21 @@ contains
real s3c(64,63)
real dtsave(MAXAVE)
real syncsave(MAXAVE)
- logical first,clearave,ljt65apon
+ logical first,clear_avg65,ljt65apon
data first/.true./
save
- if(first .or. clearave) then
+ if(first .or. clear_avg65) then
iutc=-1
nfsave=0
dtdiff=0.2
- first=.false.
s3save=0.
s1save=0.
nsave=1 !### ???
! Silence compiler warnings
if(nagain .and. ndeepave.eq.-99 .and. neme.eq.-99) stop
+ first=.false.
+ clear_avg65=.false.
endif
do i=1,64
@@ -403,7 +412,10 @@ contains
nflipsave(nsave)=nflip
s1save(-255:256,1:126,nsave)=s1
s3save(1:64,1:63,nsave)=s3a
-
+ avemsg=' '
+ deepbest=' '
+ nfttbest=0
+
10 syncsum=0.
dtsum=0.
nfsum=0
@@ -414,11 +426,13 @@ contains
do i=1,MAXAVE !Consider all saved spectra
cused(i)='.'
- if(iutc(i).lt.0) cycle
+ if(iutc(i).lt.0) exit
if(mod(iutc(i),2).ne.mod(nutc,2)) cycle !Use only same (odd/even) seq
if(abs(dtxx-dtsave(i)).gt.dtdiff) cycle !DT must match
if(abs(nfreq-nfsave(i)).gt.ntol) cycle !Freq must match
+ if(nflipsave(i).eq.0) cycle !No sync
if(nflip.ne.nflipsave(i)) cycle !Sync type (*/#) must match
+
s3b=s3b + s3save(1:64,1:63,i)
s1b=s1b + s1save(-255:256,1:126,i)
syncsum=syncsum + syncsave(i)
@@ -440,14 +454,14 @@ contains
endif
do i=1,nsave
- csync='*'
+ csync=' '
if(nflipsave(i).lt.0.0) csync='#'
+ if(nflipsave(i).gt.0.0) csync='*'
write(14,1000) cused(i),iutc(i),syncsave(i),dtsave(i)-1.0,nfsave(i),csync
1000 format(a1,i5.4,f6.1,f6.2,i6,1x,a1)
enddo
if(nsum.lt.2) go to 900
- nftt=0
df=1378.125/512.0
! Do the smoothing loop
@@ -460,6 +474,7 @@ contains
endif
nn=0
do ismo=minsmo,maxsmo
+ nftt=0
if(ismo.gt.0) then
do j=1,126
call smo121(s1b(-255,j),512)
@@ -491,13 +506,13 @@ contains
nadd=nsum*ismo
call extract(s3c,nadd,mode65,ntrials,naggressive,ndepth,nflip,mycall, &
- hiscall,hisgrid,nQSOProgress,ljt65apon,nexp_decode,ncount,nhist, &
+ hiscall,hisgrid,nQSOProgress,ljt65apon,ncount,nhist, &
avemsg,ltext,nftt,qual)
if(nftt.eq.1) then
nsmo=ismo
param(9)=nsmo
go to 900
- else if(nftt.eq.2) then
+ else if(nftt.ge.2) then
if(qual.gt.qualbest) then
deepbest=avemsg
qualbest=qual
@@ -507,7 +522,6 @@ contains
endif
endif
enddo
-
if(nfttbest.eq.2) then
avemsg=deepbest !### ???
deepave=deepbest
@@ -517,7 +531,7 @@ contains
nftt=nfttbest
endif
900 continue
-
+
return
end subroutine avg65
diff --git a/lib/jt65sim.f90 b/lib/jt65sim.f90
index 6f7030cf..623a0fca 100644
--- a/lib/jt65sim.f90
+++ b/lib/jt65sim.f90
@@ -169,23 +169,19 @@ program jt65sim
if(csubmode.eq.'B' .and. snrdb.eq.0.0) xsnr=-21 - isig
if(csubmode.eq.'C' .and. snrdb.eq.0.0) xsnr=-21 - isig
-!###
-! call1="K1ABC"
-! ic3=65+mod(isig-1,26)
-! ic2=65+mod((isig-1)/26,26)
-! ic1=65
-! call2="W9"//char(ic1)//char(ic2)//char(ic3)
-! write(msg,1010) call1,call2,nint(xsnr)
-!1010 format(a5,1x,a5,1x,i3.2)
-!###
call packmsg(msg,dgen,itype) !Pack message into 12 six-bit bytes
call rs_encode(dgen,sent) !Encode using RS(63,12)
call interleave63(sent,1) !Interleave channel symbols
call graycode65(sent,63,1) !Apply Gray code
+ nprc_test=0
+ i1=len(trim(msg))
+ if(i1.gt.10) then
+ if(msg(i1-3:i1).eq.' OOO') nprc_test=1
+ endif
k=0
do j=1,nsym !Insert sync and data into itone()
- if(nprc(j).eq.0) then
+ if(nprc(j).eq.nprc_test) then
k=k+1
itone(j)=sent(k)+2
else
@@ -200,9 +196,11 @@ program jt65sim
if(msg(1:2).eq.'73') nshorthand=4
if(nshorthand.gt.0) then
ntoggle=0
- do i=1,nsym,2
+ do i=1,nsym,4
itone(i)=ntoggle*10*nshorthand
if(i+1.le.126) itone(i+1)=ntoggle*10*nshorthand
+ if(i+2.le.126) itone(i+2)=ntoggle*10*nshorthand
+ if(i+3.le.126) itone(i+3)=ntoggle*10*nshorthand
ntoggle=mod(ntoggle+1,2)
enddo
endif
diff --git a/lib/jt9.f90 b/lib/jt9.f90
index 2e8dbd0f..7656f51e 100644
--- a/lib/jt9.f90
+++ b/lib/jt9.f90
@@ -13,6 +13,7 @@ program jt9
include 'jt9com.f90'
+ integer*2 id2a(180000)
integer(C_INT) iret
type(wav_header) wav
real*4 s(NSMAX)
@@ -301,7 +302,30 @@ program jt9
datetime="2013-Apr-16 15:13" !### Temp
shared_data%params%datetime=transfer(datetime,shared_data%params%datetime)
if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit
- call multimode_decoder(shared_data%ss,shared_data%id2,shared_data%params,nfsample)
+ if(mode.eq.8) then
+! "Early" decoding pass, FT8 only, when jt9 reads data from disk
+ nearly=41
+ shared_data%params%nzhsym=nearly
+ id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
+ id2a(nearly*3456+1:)=0
+ call multimode_decoder(shared_data%ss,id2a, &
+ shared_data%params,nfsample)
+ nearly=47
+ shared_data%params%nzhsym=nearly
+ id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
+ id2a(nearly*3456+1:)=0
+ call multimode_decoder(shared_data%ss,id2a, &
+ shared_data%params,nfsample)
+ id2a(nearly*3456+1:50*3456)=shared_data%id2(nearly*3456+1:50*3456)
+ id2a(50*3456+1:)=0
+ shared_data%params%nzhsym=50
+ call multimode_decoder(shared_data%ss,id2a, &
+ shared_data%params,nfsample)
+ cycle
+ endif
+! Normal decoding pass
+ call multimode_decoder(shared_data%ss,shared_data%id2, &
+ shared_data%params,nfsample)
enddo
call timer('jt9 ',1)
diff --git a/lib/jt9a.f90 b/lib/jt9a.f90
index 9729e080..b0df912c 100644
--- a/lib/jt9a.f90
+++ b/lib/jt9a.f90
@@ -1,30 +1,17 @@
subroutine jt9a()
- use, intrinsic :: iso_c_binding, only: c_f_pointer
+ use, intrinsic :: iso_c_binding, only: c_f_pointer, c_null_char, c_bool
use prog_args
use timer_module, only: timer
use timer_impl, only: init_timer !, limtrace
+ use shmem
include 'jt9com.f90'
-! These routines connect the shared memory region to the decoder.
- interface
- function address_jt9()
- use, intrinsic :: iso_c_binding, only: c_ptr
- type(c_ptr) :: address_jt9
- end function address_jt9
- end interface
-
- integer*1 attach_jt9
-! integer*1 lock_jt9,unlock_jt9
- integer size_jt9
+ integer*2 id2a(180000)
! Multiple instances:
- character*80 mykey
- type(dec_data), pointer :: shared_data
+ type(dec_data), pointer, volatile :: shared_data !also makes target volatile
type(params_block) :: local_params
- logical fileExists
-
-! Multiple instances:
- i0 = len(trim(shm_key))
+ logical(c_bool) :: ok
call init_timer (trim(data_dir)//'/timer.out')
! open(23,file=trim(data_dir)//'/CALL3.TXT',status='unknown')
@@ -32,43 +19,75 @@ subroutine jt9a()
! limtrace=-1 !Disable all calls to timer()
! Multiple instances: set the shared memory key before attaching
- mykey=trim(repeat(shm_key,1))
- i0 = len(mykey)
- i0=setkey_jt9(trim(mykey))
- i1=attach_jt9()
- msdelay=10
+ call shmem_setkey(trim(shm_key)//c_null_char)
+ ok=shmem_attach()
+ if(.not.ok) call abort
+ msdelay=30
+ call c_f_pointer(shmem_address(),shared_data)
-10 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
- if(fileExists) then
+! Terminate if ipc(2) is 999
+10 ok=shmem_lock()
+ if(.not.ok) call abort
+ if(shared_data%ipc(2).eq.999.0) then
+ ok=shmem_unlock()
+ ok=shmem_detach()
+ go to 999
+ endif
+! Wait here until GUI has set ipc(2) to 1
+ if(shared_data%ipc(2).ne.1) then
+ ok=shmem_unlock()
+ if(.not.ok) call abort
call sleep_msec(msdelay)
go to 10
endif
+ shared_data%ipc(2)=0
- inquire(file=trim(temp_dir)//'/.quit',exist=fileExists)
- if(fileExists) then
- i1=detach_jt9()
- go to 999
- endif
- if(i1.eq.999999) stop !Silence compiler warning
-
- nbytes=size_jt9()
+ nbytes=shmem_size()
if(nbytes.le.0) then
- print*,'jt9a: Shared memory mem_jt9 does not exist.'
+ ok=shmem_unlock()
+ ok=shmem_detach()
+ print*,'jt9a: Shared memory does not exist.'
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
go to 999
endif
- call c_f_pointer(address_jt9(),shared_data)
- local_params=shared_data%params !save a copy because wsjtx carries on accessing
+ local_params=shared_data%params !save a copy because wsjtx carries on accessing
+ ok=shmem_unlock()
+ if(.not.ok) call abort
call flush(6)
call timer('decoder ',0)
+ if(local_params%nmode.eq.8 .and. local_params%ndiskdat) then
+! Early decoding pass, FT8 only, when wsjtx reads from disk
+ nearly=41
+ local_params%nzhsym=nearly
+ id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
+ id2a(nearly*3456+1:)=0
+ call multimode_decoder(shared_data%ss,id2a,local_params,12000)
+ nearly=47
+ local_params%nzhsym=nearly
+ id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
+ id2a(nearly*3456+1:)=0
+ call multimode_decoder(shared_data%ss,id2a,local_params,12000)
+ local_params%nzhsym=50
+ endif
+! Normal decoding pass
call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
call timer('decoder ',1)
-100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
- if(fileExists) go to 10
- call sleep_msec(msdelay)
- go to 100
+! Wait here until GUI routine decodeDone() has set ipc(3) to 1
+100 ok=shmem_lock()
+ if(.not.ok) call abort
+ if(shared_data%ipc(3).ne.1) then
+ ok=shmem_unlock()
+ if(.not.ok) call abort
+ call sleep_msec(msdelay)
+ go to 100
+ endif
+ shared_data%ipc(3)=0
+ ok=shmem_unlock()
+ if(.not.ok) call abort
+ go to 10
+
999 call timer('decoder ',101)
return
diff --git a/lib/jt9com.f90 b/lib/jt9com.f90
index c595582d..3a6b8759 100644
--- a/lib/jt9com.f90
+++ b/lib/jt9com.f90
@@ -49,6 +49,7 @@
end type params_block
type, bind(C) :: dec_data
+ integer(c_int) :: ipc(3)
real(c_float) :: ss(184,NSMAX)
real(c_float) :: savg(NSMAX)
real(c_float) :: sred(5760)
diff --git a/lib/ldpcsim128_90.f90 b/lib/ldpcsim128_90.f90
index 2b6baf40..28e7fef0 100644
--- a/lib/ldpcsim128_90.f90
+++ b/lib/ldpcsim128_90.f90
@@ -4,8 +4,8 @@ program ldpcsim128_90
! the second incarnation of MSK144.
use packjt77
- integer, parameter:: NRECENT=10, N=128, K=90, M=N-K
- character*12 recent_calls(NRECENT)
+ integer, parameter:: N=128, K=90, M=N-K
+! character*12 recent_calls(NRECENT)
character*37 msg,msgsent,msgreceived
character*77 c77
character*8 arg
@@ -16,27 +16,29 @@ program ldpcsim128_90
integer nerrtot(0:N),nerrdec(0:N)
logical unpk77_success
real*8 rxdata(N), rxavgd(N)
- real llr(N)
+ real llr(N),llra(N)
- do i=1,NRECENT
+ do i=1,MAXNRECENT
recent_calls(i)=' '
enddo
nerrtot=0
nerrdec=0
nargs=iargc()
- if(nargs.ne.4) then
- print*,'Usage: ldpcsim niter navg #trials s '
- print*,'eg: ldpcsim 10 1 1000 0.75'
+ if(nargs.ne.5) then
+ print*,'Usage: ldpcsim niter ndeep navg #trials s '
+ print*,'eg: ldpcsim 10 2 1 1000 0.75'
return
endif
call getarg(1,arg)
read(arg,*) max_iterations
call getarg(2,arg)
- read(arg,*) navg
+ read(arg,*) ndeep
call getarg(3,arg)
- read(arg,*) ntrials
+ read(arg,*) navg
call getarg(4,arg)
+ read(arg,*) ntrials
+ call getarg(5,arg)
read(arg,*) s
rate=real(77)/real(N)
@@ -62,7 +64,7 @@ program ldpcsim128_90
! call init_random_seed()
write(*,*) "Eb/N0 SNR2500 ngood nundetected sigma psymerr"
- do idb = 14,0,-1
+ do idb = 6,6,-1
db=idb/2.0-1.0
sigma=1/sqrt( 2*rate*(10**(db/10.0)) )
ngood=0
@@ -103,8 +105,13 @@ program ldpcsim128_90
apmask=0
! max_iterations is max number of belief propagation iterations
+
call bpdecode128_90(llr, apmask, max_iterations, message77, cw, nharderrors, niterations)
+ if(ndeep.ge.0 .and. nharderrors.lt.0) then
+ call osd128_90(llr, apmask, ndeep, message77, cw, nharderrors, dmin)
+ endif
+
! If the decoder finds a valid codeword, nharderrors will be .ge. 0.
if( nharderrors .ge. 0 ) then
write(c77,'(77i1)') message77
diff --git a/lib/lpf1.f90 b/lib/lpf1.f90
index f2bb2377..a620e9a5 100644
--- a/lib/lpf1.f90
+++ b/lib/lpf1.f90
@@ -11,7 +11,7 @@ subroutine lpf1(dd,jz,dat,jz2)
fac=1.0/float(NFFT1)
x(1:jz)=fac*dd(1:jz)
x(jz+1:NFFT1)=0.0
- call four2a(x,NFFT1,1,-1,0) !Forwarxd FFT, r2c
+ call four2a(cx,NFFT1,1,-1,0) !Forwarxd FFT, r2c
cx(NFFT2/2:)=0.0
! df=11025.0/NFFT1
diff --git a/lib/msk144code.f90 b/lib/msk144code.f90
index 81a18515..e75ebf3d 100644
--- a/lib/msk144code.f90
+++ b/lib/msk144code.f90
@@ -1,82 +1,82 @@
-program msk144code
-
-! Provides examples of message packing, bit and symbol ordering,
-! LDPC encoding, and other necessary details of the MSK144 protocol.
-
- use packjt77
- character*77 c77
- character msg*37,msgsent*37,decoded,bad*1,msgtype*18
- integer*4 i4tone(144)
- include 'msk144_testmsg.f90'
-
- nargs=iargc()
- if(nargs.ne.1) then
- print*,'Usage: msk144code "message"'
- print*,' msk144code -t'
- print*,' '
- print*,'Examples:'
- print*,' msk144code "KA1ABC WB9XYZ EN37"'
- print*,' msk144code "<KA1ABC WB9XYZ> R-03"'
- print*,' msk144code "KA1ABC WB9XYZ R EN37"'
- go to 999
- endif
-
- call getarg(1,msg)
- nmsg=1
- if(msg(1:2).eq."-t") then
- nmsg=NTEST
- endif
-
- write(*,1010)
-1010 format(4x,"Message",31x,"Decoded",29x,"Err i3.n3"/100("-"))
-
- do imsg=1,nmsg
- if(nmsg.gt.1) msg=testmsg(imsg)
- call fmtmsg(msg,iz) !To upper case, collapse multiple blanks
- call genmsk_128_90(msg,ichk,msgsent,i4tone,itype)
- i3=-1
- n3=-1
- call pack77(msg,i3,n3,c77)
- msgtype=""
- if(i3.eq.0) then
- if(n3.eq.0) msgtype="Free text"
- if(n3.eq.1) msgtype="DXpedition mode"
- if(n3.eq.2) msgtype="EU VHF Contest"
- if(n3.eq.3) msgtype="ARRL Field Day"
- if(n3.eq.4) msgtype="ARRL Field Day"
- if(n3.eq.5) msgtype="Telemetry"
- if(n3.ge.6) msgtype="Undefined type"
- endif
- if(i3.eq.1) msgtype="Standard msg"
- if(i3.eq.2) msgtype="EU VHF Contest"
- if(i3.eq.3) msgtype="ARRL RTTY Roundup"
- if(i3.eq.4) msgtype="Nonstandard calls"
- if(i3.ge.5) msgtype="Undefined msg type"
- if(i3.ge.1) n3=-1
- if(i4tone(41).lt.0) then
- msgtype="Sh msg"
- i3=-1
- endif
- bad=" "
- if(msg.ne.msgsent) bad="*"
- if(i3.eq.0.and.n3.ge.0) then
- write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype
-1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18)
- elseif(i3.ge.1) then
- write(*,1022) imsg,msg,msgsent,bad,i3,msgtype
-1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18)
- elseif(i3.lt.0) then
- write(*,1024) imsg,msg,msgsent,bad,msgtype
-1024 format(i2,'.',1x,a37,1x,a37,1x,a1,6x,a18)
- endif
-
- enddo
-
- if(nmsg.eq.1) then
- n=144
- if(i4tone(41).lt.0) n=40
- write(*,1030) i4tone(1:n)
-1030 format(/'Channel symbols'/(72i1))
- endif
-
-999 end program msk144code
+program msk144code
+
+! Provides examples of message packing, bit and symbol ordering,
+! LDPC encoding, and other necessary details of the MSK144 protocol.
+
+ use packjt77
+ character*77 c77
+ character msg*37,msgsent*37,bad*1,msgtype*18
+ integer*4 i4tone(144)
+ include 'msk144_testmsg.f90'
+
+ nargs=iargc()
+ if(nargs.ne.1) then
+ print*,'Usage: msk144code "message"'
+ print*,' msk144code -t'
+ print*,' '
+ print*,'Examples:'
+ print*,' msk144code "KA1ABC WB9XYZ EN37"'
+ print*,' msk144code "<KA1ABC WB9XYZ> R-03"'
+ print*,' msk144code "KA1ABC WB9XYZ R EN37"'
+ go to 999
+ endif
+
+ call getarg(1,msg)
+ nmsg=1
+ if(msg(1:2).eq."-t") then
+ nmsg=NTEST
+ endif
+
+ write(*,1010)
+1010 format(4x,"Message",31x,"Decoded",29x,"Err i3.n3"/100("-"))
+
+ do imsg=1,nmsg
+ if(nmsg.gt.1) msg=testmsg(imsg)
+ call fmtmsg(msg,iz) !To upper case, collapse multiple blanks
+ call genmsk_128_90(msg,ichk,msgsent,i4tone,itype)
+ i3=-1
+ n3=-1
+ call pack77(msg,i3,n3,c77)
+ msgtype=""
+ if(i3.eq.0) then
+ if(n3.eq.0) msgtype="Free text"
+ if(n3.eq.1) msgtype="DXpedition mode"
+ if(n3.eq.2) msgtype="EU VHF Contest"
+ if(n3.eq.3) msgtype="ARRL Field Day"
+ if(n3.eq.4) msgtype="ARRL Field Day"
+ if(n3.eq.5) msgtype="Telemetry"
+ if(n3.ge.6) msgtype="Undefined type"
+ endif
+ if(i3.eq.1) msgtype="Standard msg"
+ if(i3.eq.2) msgtype="EU VHF Contest"
+ if(i3.eq.3) msgtype="ARRL RTTY Roundup"
+ if(i3.eq.4) msgtype="Nonstandard calls"
+ if(i3.ge.5) msgtype="Undefined msg type"
+ if(i3.ge.1) n3=-1
+ if(i4tone(41).lt.0) then
+ msgtype="Sh msg"
+ i3=-1
+ endif
+ bad=" "
+ if(msg.ne.msgsent) bad="*"
+ if(i3.eq.0.and.n3.ge.0) then
+ write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype
+1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18)
+ elseif(i3.ge.1) then
+ write(*,1022) imsg,msg,msgsent,bad,i3,msgtype
+1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18)
+ elseif(i3.lt.0) then
+ write(*,1024) imsg,msg,msgsent,bad,msgtype
+1024 format(i2,'.',1x,a37,1x,a37,1x,a1,6x,a18)
+ endif
+
+ enddo
+
+ if(nmsg.eq.1) then
+ n=144
+ if(i4tone(41).lt.0) n=40
+ write(*,1030) i4tone(1:n)
+1030 format(/'Channel symbols'/(72i1))
+ endif
+
+999 end program msk144code
diff --git a/lib/msk144decodeframe.f90 b/lib/msk144decodeframe.f90
index a2dbd0df..24119b9b 100644
--- a/lib/msk144decodeframe.f90
+++ b/lib/msk144decodeframe.f90
@@ -93,10 +93,9 @@ subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess)
llr=2.0*llr/(sigma*sigma)
max_iterations=10
-! call timer('bpdec128_90 ',0)
apmask=0
+ dmin=0.0
call bpdecode128_90(llr,apmask,max_iterations,decoded77,cw,nharderror,niterations)
-! call timer('bpdec128_90 ',1)
if( nharderror .ge. 0 .and. nharderror .lt. 18 ) then
nsuccess=1
write(c77,'(77i1)') decoded77
diff --git a/lib/msk144sim.f90 b/lib/msk144sim.f90
index 3472d882..a19d7443 100644
--- a/lib/msk144sim.f90
+++ b/lib/msk144sim.f90
@@ -34,6 +34,7 @@ program msk144sim
i1=len(trim(msg))-5
ichk=0
itype=1
+ call fmtmsg(msg,iz)
call genmsk_128_90(msg,ichk,msgsent,itone,itype)
write(*,*) 'Requested message: ',msg
write(*,*) 'Message sent : ',msgsent
diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90
index 7cc68807..3bf62180 100644
--- a/lib/mskrtd.f90
+++ b/lib/mskrtd.f90
@@ -1,4 +1,4 @@
-subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, &
+subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,hiscall, &
bshmsg,btrain,pcoeffs,bswl,datadir,line)
! Real-time decoder for MSK144.
@@ -18,7 +18,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, &
character*37 msglast,msglastswl !Used for dupechecking
character*80 line !Formatted line with UTC dB T Freq Msg
character*12 mycall,hiscall
- character*6 mygrid
character*37 recent_shmsgs(NSHMEM)
character*512 datadir
@@ -71,8 +70,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, &
msglastswl=' '
nsnrlast=-99
nsnrlastswl=-99
- mycall13=mycall//' '
- dxcall13=hiscall//' '
+ mycall13=mycall//' '
+ dxcall13=hiscall//' '
first=.false.
endif
diff --git a/lib/osd128_90.f90 b/lib/osd128_90.f90
new file mode 100644
index 00000000..75082bf5
--- /dev/null
+++ b/lib/osd128_90.f90
@@ -0,0 +1,375 @@
+subroutine osd128_90(llr,apmask,ndeep,message77,cw,nhardmin,dmin)
+
+! Ordered-statistics decoder for the (128,90) code.
+
+ integer, parameter:: N=128, K=90, M=N-K
+ integer*1 apmask(N),apmaskr(N)
+ integer*1 gen(K,N)
+ integer*1 genmrb(K,N),g2(N,K)
+ integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K)
+ integer*1 r2pat(N-K)
+ integer indices(N),nxor(N)
+ integer*1 cw(N),ce(N),c0(N),hdec(N)
+ integer*1 decoded(K)
+ integer*1 message77(77)
+ integer indx(N)
+ real llr(N),rx(N),absrx(N)
+
+ include "ldpc_128_90_generator.f90"
+
+ logical first,reset
+ data first/.true./
+ save first,gen
+
+ if( first ) then ! fill the generator matrix
+ gen=0
+ do i=1,M
+ do j=1,23
+ read(g(i)(j:j),"(Z1)") istr
+ ibmax=4
+ if(j.eq.23) ibmax=2
+ do jj=1, ibmax
+ irow=(j-1)*4+jj
+ if( btest(istr,4-jj) ) gen(irow,K+i)=1
+ enddo
+ enddo
+ enddo
+ do irow=1,K
+ gen(irow,irow)=1
+ enddo
+ first=.false.
+ endif
+
+ rx=llr
+ apmaskr=apmask
+ d1=0.
+ ntheta=0
+ npre1=0
+ npre2=0
+ nt=0
+
+! Hard decisions on the received word.
+ hdec=0
+ where(rx .ge. 0) hdec=1
+
+! Use magnitude of received symbols as a measure of reliability.
+ absrx=abs(rx)
+ call indexx(absrx,N,indx)
+
+! Re-order columns of generator matrix in order of decreasing reliability.
+ do i=1,N
+ genmrb(1:K,i)=gen(1:K,indx(N+1-i))
+ indices(i)=indx(N+1-i)
+ enddo
+
+! Do gaussian elimination to create a generator matrix with the most reliable
+! received bits in positions 1:K in order of decreasing reliability (more or less).
+ do id=1,K ! diagonal element indices
+ do icol=id,K+20 ! The 20 is ad hoc - beware
+ iflag=0
+ if( genmrb(id,icol) .eq. 1 ) then
+ iflag=1
+ if( icol .ne. id ) then ! reorder column
+ temp(1:K)=genmrb(1:K,id)
+ genmrb(1:K,id)=genmrb(1:K,icol)
+ genmrb(1:K,icol)=temp(1:K)
+ itmp=indices(id)
+ indices(id)=indices(icol)
+ indices(icol)=itmp
+ endif
+ do ii=1,K
+ if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then
+ genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N))
+ endif
+ enddo
+ exit
+ endif
+ enddo
+ enddo
+
+ g2=transpose(genmrb)
+
+! The hard decisions for the K MRB bits define the order 0 message, m0.
+! Encode m0 using the modified generator matrix to find the "order 0" codeword.
+! Flip various combinations of bits in m0 and re-encode to generate a list of
+! codewords. Return the member of the list that has the smallest Euclidean
+! distance to the received word.
+
+ hdec=hdec(indices) ! hard decisions from received symbols
+ m0=hdec(1:K) ! zero'th order message
+ absrx=absrx(indices)
+ rx=rx(indices)
+ apmaskr=apmaskr(indices)
+
+ call mrbencode90(m0,c0,g2,N,K)
+ nxor=ieor(c0,hdec)
+ nhardmin=sum(nxor)
+ dmin=sum(nxor*absrx)
+
+ cw=c0
+ ntotal=0
+ nrejected=0
+
+ if(ndeep.eq.0) goto 998 ! norder=0
+ if(ndeep.gt.5) ndeep=5
+ if( ndeep.eq. 1) then
+ nord=1
+ npre1=0
+ npre2=0
+ nt=12
+ ntheta=3
+ elseif(ndeep.eq.2) then
+ nord=1
+ npre1=1
+ npre2=0
+ nt=18
+ ntheta=4
+ elseif(ndeep.eq.3) then
+ nord=1
+ npre1=1
+ npre2=0
+ nt=12
+ ntheta=4
+ elseif(ndeep.eq.4) then
+ nord=1
+ npre1=1
+ npre2=1
+ nt=12
+ ntheta=4
+ ntau=15
+ elseif(ndeep.eq.5) then
+ nord=1
+ npre1=1
+ npre2=1
+ nt=12
+ ntheta=4
+ ntau=5
+ endif
+
+ do iorder=1,nord
+ misub(1:K-iorder)=0
+ misub(K-iorder+1:K)=1
+ iflag=K-iorder+1
+ do while(iflag .ge.0)
+ if(iorder.eq.nord .and. npre1.eq.0) then
+ iend=iflag
+ else
+ iend=1
+ endif
+ do n1=iflag,iend,-1
+ mi=misub
+ mi(n1)=1
+ if(any(iand(apmaskr(1:K),mi).eq.1)) cycle
+ ntotal=ntotal+1
+ me=ieor(m0,mi)
+ if(n1.eq.iflag) then
+ call mrbencode90(me,ce,g2,N,K)
+ e2sub=ieor(ce(K+1:N),hdec(K+1:N))
+ e2=e2sub
+ nd1Kpt=sum(e2sub(1:nt))+1
+ d1=sum(ieor(me(1:K),hdec(1:K))*absrx(1:K))
+ else
+ e2=ieor(e2sub,g2(K+1:N,n1))
+ nd1Kpt=sum(e2(1:nt))+2
+ endif
+ if(nd1Kpt .le. ntheta) then
+ call mrbencode90(me,ce,g2,N,K)
+ nxor=ieor(ce,hdec)
+ if(n1.eq.iflag) then
+ dd=d1+sum(e2sub*absrx(K+1:N))
+ else
+ dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(K+1:N))
+ endif
+ if( dd .lt. dmin ) then
+ dmin=dd
+ cw=ce
+ nhardmin=sum(nxor)
+ nd1Kptbest=nd1Kpt
+ endif
+ else
+ nrejected=nrejected+1
+ endif
+ enddo
+! Get the next test error pattern, iflag will go negative
+! when the last pattern with weight iorder has been generated.
+ call nextpat90(misub,k,iorder,iflag)
+ enddo
+ enddo
+
+ if(npre2.eq.1) then
+ reset=.true.
+ ntotal=0
+ do i1=K,1,-1
+ do i2=i1-1,1,-1
+ ntotal=ntotal+1
+ mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2))
+ call boxit90(reset,mi(1:ntau),ntau,ntotal,i1,i2)
+ enddo
+ enddo
+
+ ncount2=0
+ ntotal2=0
+ reset=.true.
+! Now run through again and do the second pre-processing rule
+ misub(1:K-nord)=0
+ misub(K-nord+1:K)=1
+ iflag=K-nord+1
+ do while(iflag .ge.0)
+ me=ieor(m0,misub)
+ call mrbencode90(me,ce,g2,N,K)
+ e2sub=ieor(ce(K+1:N),hdec(K+1:N))
+ do i2=0,ntau
+ ntotal2=ntotal2+1
+ ui=0
+ if(i2.gt.0) ui(i2)=1
+ r2pat=ieor(e2sub,ui)
+778 continue
+ call fetchit90(reset,r2pat(1:ntau),ntau,in1,in2)
+ if(in1.gt.0.and.in2.gt.0) then
+ ncount2=ncount2+1
+ mi=misub
+ mi(in1)=1
+ mi(in2)=1
+ if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle
+ me=ieor(m0,mi)
+ call mrbencode90(me,ce,g2,N,K)
+ nxor=ieor(ce,hdec)
+ dd=sum(nxor*absrx)
+ if( dd .lt. dmin ) then
+ dmin=dd
+ cw=ce
+ nhardmin=sum(nxor)
+ endif
+ goto 778
+ endif
+ enddo
+ call nextpat90(misub,K,nord,iflag)
+ enddo
+ endif
+
+998 continue
+! Re-order the codeword to [message bits][parity bits] format.
+ cw(indices)=cw
+ hdec(indices)=hdec
+ decoded=cw(1:K)
+ call chkcrc13a(decoded,nbadcrc)
+ message77=decoded(1:77)
+ if(nbadcrc.eq.1) nhardmin=-nhardmin
+
+ return
+end subroutine osd128_90
+
+subroutine mrbencode90(me,codeword,g2,N,K)
+ integer*1 me(K),codeword(N),g2(N,K)
+! fast encoding for low-weight test patterns
+ codeword=0
+ do i=1,K
+ if( me(i) .eq. 1 ) then
+ codeword=ieor(codeword,g2(1:N,i))
+ endif
+ enddo
+ return
+end subroutine mrbencode90
+
+subroutine nextpat90(mi,k,iorder,iflag)
+ integer*1 mi(k),ms(k)
+! generate the next test error pattern
+ ind=-1
+ do i=1,k-1
+ if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i
+ enddo
+ if( ind .lt. 0 ) then ! no more patterns of this order
+ iflag=ind
+ return
+ endif
+ ms=0
+ ms(1:ind-1)=mi(1:ind-1)
+ ms(ind)=1
+ ms(ind+1)=0
+ if( ind+1 .lt. k ) then
+ nz=iorder-sum(ms)
+ ms(k-nz+1:k)=1
+ endif
+ mi=ms
+ do i=1,k ! iflag will point to the lowest-index 1 in mi
+ if(mi(i).eq.1) then
+ iflag=i
+ exit
+ endif
+ enddo
+ return
+end subroutine nextpat90
+
+subroutine boxit90(reset,e2,ntau,npindex,i1,i2)
+ integer*1 e2(1:ntau)
+ integer indexes(5000,2),fp(0:525000),np(5000)
+ logical reset
+ common/boxes/indexes,fp,np
+
+ if(reset) then
+ patterns=-1
+ fp=-1
+ np=-1
+ sc=-1
+ indexes=-1
+ reset=.false.
+ endif
+
+ indexes(npindex,1)=i1
+ indexes(npindex,2)=i2
+ ipat=0
+ do i=1,ntau
+ if(e2(i).eq.1) then
+ ipat=ipat+ishft(1,ntau-i)
+ endif
+ enddo
+
+ ip=fp(ipat) ! see what's currently stored in fp(ipat)
+ if(ip.eq.-1) then
+ fp(ipat)=npindex
+ else
+ do while (np(ip).ne.-1)
+ ip=np(ip)
+ enddo
+ np(ip)=npindex
+ endif
+ return
+end subroutine boxit90
+
+subroutine fetchit90(reset,e2,ntau,i1,i2)
+ integer indexes(5000,2),fp(0:525000),np(5000)
+ integer lastpat
+ integer*1 e2(ntau)
+ logical reset
+ common/boxes/indexes,fp,np
+ save lastpat,inext
+
+ if(reset) then
+ lastpat=-1
+ reset=.false.
+ endif
+
+ ipat=0
+ do i=1,ntau
+ if(e2(i).eq.1) then
+ ipat=ipat+ishft(1,ntau-i)
+ endif
+ enddo
+ index=fp(ipat)
+
+ if(lastpat.ne.ipat .and. index.gt.0) then ! return first set of indices
+ i1=indexes(index,1)
+ i2=indexes(index,2)
+ inext=np(index)
+ elseif(lastpat.eq.ipat .and. inext.gt.0) then
+ i1=indexes(inext,1)
+ i2=indexes(inext,2)
+ inext=np(inext)
+ else
+ i1=-1
+ i2=-1
+ inext=-1
+ endif
+ lastpat=ipat
+ return
+end subroutine fetchit90
diff --git a/lib/qra64a.f90 b/lib/qra64a.f90
index 56d59e52..5d314f2b 100644
--- a/lib/qra64a.f90
+++ b/lib/qra64a.f90
@@ -1,4 +1,4 @@
-subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
+subroutine qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
emedelay,mycall_12,hiscall_12,hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft)
use packjt
@@ -86,7 +86,7 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
idt=itry0/2
if(mod(itry0,2).eq.0) idt=-idt
jpk=jpk0 + 750*idt
- call spec64(c0,npts2,mode64,jpk,s3a,LL,NN)
+ call spec64(c0,jpk,s3a,LL,NN)
call pctile(s3a,LL*NN,40,base)
s3a=s3a/base
where(s3a(1:LL*NN)>s3lim) s3a(1:LL*NN)=s3lim
@@ -151,8 +151,5 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
endif
call timer('qra64a ',1)
-! write(71,3001) nutc,dtx,f0,sync,sync2,width,minsync,decoded
-!3001 format(i4.4,f7.2,4f8.1,i3,2x,a22)
-
return
end subroutine qra64a
diff --git a/lib/qra64code.f90 b/lib/qra64code.f90
index 5846ec8d..188b5f0b 100644
--- a/lib/qra64code.f90
+++ b/lib/qra64code.f90
@@ -5,10 +5,8 @@ program QRA64code
! protocol.
use packjt
- character*22 msg,msg0,msg1,decoded,cok*3,msgtype*10,arg*12
- character*6 mycall
- logical ltext
- integer dgen(12),sent(63),dec(12)
+ character*22 msg,msg0,msg1,decoded,cok*3,msgtype*10
+ integer dgen(12),sent(63)
integer icos7(0:6)
data icos7/2,5,6,0,4,1,3/ !Defines a 7x7 Costas array
diff --git a/lib/qratest.f90 b/lib/qratest.f90
index 2b5de8c1..8e46c805 100644
--- a/lib/qratest.f90
+++ b/lib/qratest.f90
@@ -39,7 +39,7 @@ program qratest
if(nfqso0.ne.-1) nfqso=nfqso0
if(ntol0.ne.-1) ntol=ntol0
- call qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
+ call qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft)
c='a'
if(mode64.eq.2) c='b'
diff --git a/lib/refspectrum.f90 b/lib/refspectrum.f90
index bc5bede3..fdd302ae 100644
--- a/lib/refspectrum.f90
+++ b/lib/refspectrum.f90
@@ -40,7 +40,7 @@ subroutine refspectrum(id2,bclear,brefspec,buseref,fname)
if(brefspec) then
x(0:NH-1)=0.001*id2(1:NH)
x(NH:NFFT-1)=0.0
- call four2a(x,NFFT,1,-1,0) !r2c FFT
+ call four2a(cx,NFFT,1,-1,0) !r2c FFT
do i=1,NH
s(i)=s(i) + real(cx(i))**2 + aimag(cx(i))**2
@@ -134,7 +134,7 @@ subroutine refspectrum(id2,bclear,brefspec,buseref,fname)
! Make the filter causal for overlap and add.
cx(0)=0.0
cx(1:NH)=fil(1:NH)/NFFT
- call four2a(x,NFFT,1,1,-1)
+ call four2a(cx,NFFT,1,1,-1)
x=cshift(x,-400)
x(800:NH)=0.0
call four2a(cx,NFFT,1,-1,0)
@@ -146,7 +146,7 @@ subroutine refspectrum(id2,bclear,brefspec,buseref,fname)
x(0:NH-1)=id2(1:NH)
x(NH:NFFT-1)=0.0
x=x/NFFT
- call four2a(x,NFFT,1,-1,0)
+ call four2a(cx,NFFT,1,-1,0)
cx=cfil*cx
call four2a(cx,NFFT,1,1,-1)
x(0:NH-1)=x(0:NH-1)+xs
diff --git a/lib/sh65.f90 b/lib/sh65.f90
index 8f13fdc3..09bef9c2 100644
--- a/lib/sh65.f90
+++ b/lib/sh65.f90
@@ -1,20 +1,19 @@
subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
- parameter(NFFT=2048,NH=NFFT/2,MAXSTEPS=150)
- complex cx(90000)
+ parameter(NFFT=2048,NH=NFFT/2)
+ complex cx(n5) !Centered on nfqso, sample rate 1378.125
complex c(0:NFFT-1)
real s(-NH+1:NH)
- real s2(-NH+1:NH,MAXSTEPS)
- real ss(-NH+1:NH,8)
- real sigmax(8)
- integer ipk(8)
+ real ss(-NH+1:NH,16)
+ real sigmax(16)
+ integer ipk(16)
- s=0.
ss=0.
- jstep=NFFT/4
- nblks=n5/jstep - 3
+ jstep=NFFT/8
+ nblks=272
ia=-jstep+1
do iblk=1,nblks
+ n=mod(iblk-1,16) + 1
ia=ia+jstep
ib=ia+NFFT-1
c=cx(ia:ib)
@@ -22,34 +21,37 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
do i=0,NFFT-1
j=i
if(j.gt.NH) j=j-NFFT
- p=real(c(i))**2 + aimag(c(i))**2
- s(j)=s(j) + p
- s2(j,iblk)=p
+ ss(j,n)=ss(j,n) + real(c(i))**2 + aimag(c(i))**2
enddo
- n=mod(iblk-1,8) +1
- ss(-NH+1:NH,n)=ss(-NH+1:NH,n) + s2(-NH+1:NH,iblk)
enddo
- s=1.e-6*s
- ss=1.e-6*ss
+ s=1.e-5*s
+ ss=1.e-5*ss
df=1378.1285/NFFT
nfac=40*mode65
dtstep=0.25/df
-! Define range of frequencies to be searched
+ do i=1,2*mode65
+ call smo121(ss,16*NFFT)
+ enddo
+
+! do i=-NH+1,NH
+! write(72,3072) i*df,(ss(i,j),j=1,16)
+!3072 format(17f7.1)
+! enddo
+
+! Define freq range to be searched. Upper tone is at sync freq + 4*nfac*df Hz
fa=-ntol
fb=ntol
ia2=max(-NH+1,nint(fa/df))
-! Upper tone is above sync tone by 4*nfac*df Hz
ib2=min(NH,nint(fb/df + 4.1*nfac))
-! Find strongest line in each of the 4 phases, repeating for each drift rate.
+! Find strongest line in each of the 16 phases
sbest=0.
snrbest=0.
nbest=1
ipk=0
-
- do n=1,8
+ do n=1,16
sigmax(n)=0.
do i=ia2,ib2
sig=ss(i,n)
@@ -63,8 +65,8 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
endif
enddo
enddo
- n2best=nbest+4
- if(n2best.gt.8) n2best=nbest-4
+ n2best=nbest+8
+ if(n2best.gt.16) n2best=nbest-8
xdf=min(ipk(nbest),ipk(n2best))*df
nspecial=0
if(abs(xdf).le.ntol) then
@@ -74,6 +76,9 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
iderr=nint((xk-k)*nfac)
! maxerr=nint(0.008*abs(idiff) + 0.51)
maxerr=nint(0.02*abs(idiff) + 0.51) !### Better test ??? ###
+! write(71,3001) nbest,n2best,idiff,iderr,maxerr,k, &
+! ipk(nbest)*df,ipk(n2best)*df,sbest
+!3001 format(6i4,2f7.1,f7.2)
if(abs(iderr).le.maxerr .and. k.ge.2 .and. k.le.4) nspecial=k
snrdb=-30.0
if(nspecial.gt.0) then
diff --git a/lib/shmem.cpp b/lib/shmem.cpp
new file mode 100644
index 00000000..95a86614
--- /dev/null
+++ b/lib/shmem.cpp
@@ -0,0 +1,20 @@
+#include <QSharedMemory>
+#include <QLatin1String>
+
+// Multiple instances: KK1D, 17 Jul 2013
+QSharedMemory shmem;
+
+struct jt9com;
+
+// C wrappers for a QSharedMemory class instance
+extern "C"
+{
+ bool shmem_create (int nsize) {return shmem.create(nsize);}
+ void shmem_setkey (char * const mykey) {shmem.setKey(QLatin1String{mykey});}
+ bool shmem_attach () {return shmem.attach();}
+ int shmem_size () {return static_cast<int> (shmem.size());}
+ struct jt9com * shmem_address () {return reinterpret_cast<struct jt9com *>(shmem.data());}
+ bool shmem_lock () {return shmem.lock();}
+ bool shmem_unlock () {return shmem.unlock();}
+ bool shmem_detach () {return shmem.detach();}
+}
diff --git a/lib/shmem.f90 b/lib/shmem.f90
new file mode 100644
index 00000000..8d9db7d6
--- /dev/null
+++ b/lib/shmem.f90
@@ -0,0 +1,45 @@
+module shmem
+ ! external routines wrapping the Qt QSharedMemory class
+ interface
+ function shmem_create (size) bind(C, name="shmem_create")
+ use iso_c_binding, only: c_bool, c_int
+ logical(c_bool) :: shmem_create
+ integer(c_int), value, intent(in) :: size
+ end function shmem_create
+
+ subroutine shmem_setkey (key) bind(C, name="shmem_setkey")
+ use iso_c_binding, only: c_bool, c_char
+ character(kind=c_char), intent(in) :: key(*)
+ end subroutine shmem_setkey
+
+ function shmem_attach () bind(C, name="shmem_attach")
+ use iso_c_binding, only: c_bool
+ logical(c_bool) :: shmem_attach
+ end function shmem_attach
+
+ function shmem_address() bind(C, name="shmem_address")
+ use, intrinsic :: iso_c_binding, only: c_ptr
+ type(c_ptr) :: shmem_address
+ end function shmem_address
+
+ function shmem_size() bind(C, name="shmem_size")
+ use, intrinsic :: iso_c_binding, only: c_int
+ integer(c_int) :: shmem_size
+ end function shmem_size
+
+ function shmem_lock () bind(C, name="shmem_lock")
+ use iso_c_binding, only: c_bool
+ logical(c_bool) :: shmem_lock
+ end function shmem_lock
+
+ function shmem_unlock () bind(C, name="shmem_unlock")
+ use iso_c_binding, only: c_bool
+ logical(c_bool) :: shmem_unlock
+ end function shmem_unlock
+
+ function shmem_detach () bind(C, name="shmem_detach")
+ use iso_c_binding, only: c_bool
+ logical(c_bool) :: shmem_detach
+ end function shmem_detach
+ end interface
+end module shmem
diff --git a/lib/spec64.f90 b/lib/spec64.f90
index a0c0a04c..3404243c 100644
--- a/lib/spec64.f90
+++ b/lib/spec64.f90
@@ -1,4 +1,4 @@
-subroutine spec64(c0,npts2,mode64,jpk,s3,LL,NN)
+subroutine spec64(c0,jpk,s3,LL,NN)
parameter (NSPS=3456) !Samples per symbol at 6000 Hz
complex c0(0:360000) !Complex spectrum of dd()
diff --git a/lib/sumsim.f90 b/lib/sumsim.f90
new file mode 100644
index 00000000..e05f8d4d
--- /dev/null
+++ b/lib/sumsim.f90
@@ -0,0 +1,41 @@
+program sumsim
+
+! Sum a number of *.wav files so that multiple signals are present
+
+ use wavhdr
+ parameter (NMAX=60*12000)
+ type(hdr) h !Header for the .wav file
+ integer*2 iwave(NMAX) !i*2 data
+ real wave(NMAX) !r*4 data
+ character*80 fname
+
+ nargs=iargc()
+ if(nargs.lt.1) then
+ print*,'Usage: sumsim file1 [file2, ...]'
+ go to 999
+ endif
+ wave=0.
+
+ do ifile=1,nargs
+ call getarg(ifile,fname)
+ open(10,file=trim(fname),status='old',access='stream')
+ read(10) h
+ npts=h%ndata/2
+ nfsample=h%nsamrate
+ read(10) iwave(1:npts)
+ n=len(trim(fname))
+ wave(1:npts)=wave(1:npts)+iwave(1:npts)
+ rms=sqrt(dot_product(wave(1:npts),wave(1:npts))/npts)
+ write(*,1000) ifile,npts,float(npts)/nfsample,rms,fname(n-14:n)
+1000 format(i3,i8,f6.1,f10.3,2x,a15)
+ close(10)
+ enddo
+
+ fac=1.0/sqrt(float(nargs))
+ iwave(1:npts)=nint(fac*wave(1:npts))
+
+ open(12,file='000000_0000.wav',access='stream',status='unknown')
+ write(12) h,iwave(1:npts)
+ close(12)
+
+999 end program sumsim
diff --git a/lib/sync65.f90 b/lib/sync65.f90
index 4a681a0a..cfb3accb 100644
--- a/lib/sync65.f90
+++ b/lib/sync65.f90
@@ -1,5 +1,4 @@
-subroutine sync65(nfa,nfb,naggressive,ntol,nqsym,ca,ncand,nrobust, &
- bVHF)
+subroutine sync65(nfa,nfb,ntol,nqsym,ca,ncand,nrobust,bVHF)
parameter (NSZ=3413,NFFT=8192,MAXCAND=300)
real ss(552,NSZ)
@@ -56,8 +55,6 @@ subroutine sync65(nfa,nfb,naggressive,ntol,nqsym,ca,ncand,nrobust, &
do i=ia,ib
freq=i*df
itry=0
-! if(naggressive.gt.0 .and. ntol.lt.1000 .and. ccfmax.ge.thresh0) then
-! if(naggressive.gt.0 .and. ccfmax.ge.thresh0) then
if(bVHF) then
if(i.ne.ipk .or. ccfmax.lt.thresh0) cycle
itry=1
diff --git a/lib/synciscat.f90 b/lib/synciscat.f90
index 5ce27acf..747eeca6 100644
--- a/lib/synciscat.f90
+++ b/lib/synciscat.f90
@@ -1,5 +1,5 @@
-subroutine synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol,NFreeze, &
- MouseDF,mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, &
+subroutine synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol, &
+ mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, &
ipk,jpk,idf,df1)
! Synchronize an ISCAT signal
@@ -86,8 +86,8 @@ subroutine synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol,NFreeze, &
ttot=npts/fsample !Length of record (s)
df1=df/ttot !Step size for f1=fdot
- idf1=-25.0/df1
- idf2=5.0/df1
+ idf1=int(-25.0/df1)
+ idf2=int(5.0/df1)
if(nafc.eq.0) then
idf1=0
idf2=0
diff --git a/lib/timf2.f90 b/lib/timf2.f90
index 07f50983..bec391e2 100644
--- a/lib/timf2.f90
+++ b/lib/timf2.f90
@@ -59,7 +59,7 @@ subroutine timf2(x0,k,nfft,nwindow,nb,peaklimit,x1, &
x(0:nfft-1)=x0
if(nwindow.eq.2) x(0:nfft-1)=w(0:nfft-1)*x(0:nfft-1)
- call four2a(x,nfft,1,-1,0) !First forward FFT, r2c
+ call four2a(cx,nfft,1,-1,0) !First forward FFT, r2c
cxt(0:nh)=cx(0:nh)
! Identify frequencies with strong signals.
diff --git a/lib/wav11.f90 b/lib/wav11.f90
index 3bba0bf8..1311d251 100644
--- a/lib/wav11.f90
+++ b/lib/wav11.f90
@@ -6,7 +6,7 @@ subroutine wav11(d2,npts,dd)
parameter (NFFT1=64*12000,NFFT2=64*11025)
integer*2 d2(NZ12)
real*4 dd(NZ11)
- real x(NFFT2)
+ real x(NFFT1)
complex cx(0:NFFT1/2)
equivalence (x,cx)
save x,cx
@@ -14,7 +14,7 @@ subroutine wav11(d2,npts,dd)
jz=min(NZ12,npts)
x(1:jz)=d2(1:jz)
x(jz+1:)=0.0
- call four2a(x,nfft1,1,-1,0) !Forward FFT, r2c
+ call four2a(cx,nfft1,1,-1,0) !Forward FFT, r2c
df=12000.0/NFFT1
ia=5000.0/df
cx(ia:)=0.0
diff --git a/lib/wav12.f90 b/lib/wav12.f90
index 31fe1d59..ff655436 100644
--- a/lib/wav12.f90
+++ b/lib/wav12.f90
@@ -34,7 +34,7 @@ subroutine wav12(d2,d1,npts,nbitsam2)
x(1:jz)=d2(1:jz)
x(jz+1:)=0.0
- call four2a(x,nfft1,1,-1,0) !Forwarxd FFT, r2c
+ call four2a(cx,nfft1,1,-1,0) !Forwarxd FFT, r2c
cx(nfft1/2:)=0.0
call four2a(cx,nfft2,1,1,-1) !Inverse FFT, c2r
diff --git a/lib/wqdecode.f90 b/lib/wqdecode.f90
index baa68cb1..ec2c53c2 100644
--- a/lib/wqdecode.f90
+++ b/lib/wqdecode.f90
@@ -56,7 +56,7 @@ subroutine wqdecode(data0,message,ntype)
if(ntype.ge.0 .and. ntype.le.62) then
nu=mod(ntype,10)
if(nu.eq.0 .or. nu.eq.3 .or. nu.eq.7) then
- write(cdbm,'(i3)'),ntype
+ write(cdbm,'(i3)') ntype
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
message=callsign(1:i1)//grid4//' '//cdbm
@@ -69,7 +69,7 @@ subroutine wqdecode(data0,message,ntype)
ng=n2/128 + 32768*(nadd-1)
call unpackpfx(ng,callsign)
ndbm=ntype-nadd
- write(cdbm,'(i3)'),ndbm
+ write(cdbm,'(i3)') ndbm
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
i2=index(callsign,' ')
@@ -82,7 +82,7 @@ subroutine wqdecode(data0,message,ntype)
grid6=callsign(6:6)//callsign(1:5)
ih=(n2-ntype-64)/128
callsign=dcall(ih)
- write(cdbm,'(i3)'),ndbm
+ write(cdbm,'(i3)') ndbm
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
i2=index(callsign,' ')
@@ -316,7 +316,7 @@ subroutine unpackpfx(ng,call1)
endif
n=n/37
enddo
- call1=pfx//'/'//call1
+ call1=pfx//'/'//call1(1:8)
if(call1(1:1).eq.' ') call1=call1(2:)
if(call1(1:1).eq.' ') call1=call1(2:)
else
diff --git a/lib/wqencode.f90 b/lib/wqencode.f90
index 3ca87f31..59b24706 100644
--- a/lib/wqencode.f90
+++ b/lib/wqencode.f90
@@ -59,8 +59,7 @@ subroutine wqencode(msg,ntype,data0)
n2=128*ih + ntype + 64
call pack50(n1,n2,data0)
endif
- go to 900
-
900 continue
+
return
end subroutine wqencode
diff --git a/lib/wsprcode/nhash.c b/lib/wsprcode/nhash.c
index 675022b4..8aabb4ff 100644
--- a/lib/wsprcode/nhash.c
+++ b/lib/wsprcode/nhash.c
@@ -360,17 +360,17 @@ uint32_t nhash_( const void *key, int *length0, uint32_t *initval0)
/*-------------------------------- last block: affect all 32 bits of (c) */
switch(length) /* all the case statements fall through */
{
- case 12: c+=((uint32_t)k[11])<<24;
- case 11: c+=((uint32_t)k[10])<<16;
- case 10: c+=((uint32_t)k[9])<<8;
- case 9 : c+=k[8];
- case 8 : b+=((uint32_t)k[7])<<24;
- case 7 : b+=((uint32_t)k[6])<<16;
- case 6 : b+=((uint32_t)k[5])<<8;
- case 5 : b+=k[4];
- case 4 : a+=((uint32_t)k[3])<<24;
- case 3 : a+=((uint32_t)k[2])<<16;
- case 2 : a+=((uint32_t)k[1])<<8;
+ case 12: c+=((uint32_t)k[11])<<24; /* fall through */
+ case 11: c+=((uint32_t)k[10])<<16; /* fall through */
+ case 10: c+=((uint32_t)k[9])<<8; /* fall through */
+ case 9 : c+=k[8]; /* fall through */
+ case 8 : b+=((uint32_t)k[7])<<24; /* fall through */
+ case 7 : b+=((uint32_t)k[6])<<16; /* fall through */
+ case 6 : b+=((uint32_t)k[5])<<8; /* fall through */
+ case 5 : b+=k[4]; /* fall through */
+ case 4 : a+=((uint32_t)k[3])<<24; /* fall through */
+ case 3 : a+=((uint32_t)k[2])<<16; /* fall through */
+ case 2 : a+=((uint32_t)k[1])<<8; /* fall through */
case 1 : a+=k[0];
break;
case 0 : return c;
diff --git a/lib/wsprcode/wspr_old_subs.f90 b/lib/wsprcode/wspr_old_subs.f90
index b1bbb7e1..a8b5c503 100644
--- a/lib/wsprcode/wspr_old_subs.f90
+++ b/lib/wsprcode/wspr_old_subs.f90
@@ -131,7 +131,7 @@ subroutine fano232(symbol,nbits,mettab,ndelta,maxcycles,dat,ncycles,metric,ierr)
! written by Phil Karn, KA9Q.
parameter (MAXBITS=103)
- parameter (MAXDAT=(MAXBITS+7)/8)
+ parameter (MAXDAT=13) !(MAXBITS+7)/8
integer*1 symbol(0:2*MAXBITS-1)
integer*1 dat(MAXDAT) !Decoded user data, 8 bits per byte
integer mettab(0:255,0:1) !Metric table
@@ -509,7 +509,7 @@ subroutine packcall(callsign,ncall,text)
text=.true.
return
endif
- tmp=' '//callsign
+ tmp=' '//callsign(1:5)
else
text=.true.
return
@@ -631,8 +631,8 @@ subroutine packpfx(call1,n1,ng,nadd)
else
! Prefix of 1 to 3 characters
pfx=call1(:i1-1)
- if(pfx(3:3).eq.' ') pfx=' '//pfx
- if(pfx(3:3).eq.' ') pfx=' '//pfx
+ if(pfx(3:3).eq.' ') pfx=' '//pfx(1:2)
+ if(pfx(3:3).eq.' ') pfx=' '//pfx(1:2)
call0=call1(i1+1:)
call packcall(call0,n1,text)
@@ -778,7 +778,7 @@ subroutine unpackpfx(ng,call1)
endif
n=n/37
enddo
- call1=pfx//'/'//call1
+ call1=pfx//'/'//call1(1:8)
if(call1(1:1).eq.' ') call1=call1(2:)
if(call1(1:1).eq.' ') call1=call1(2:)
else
@@ -831,7 +831,7 @@ subroutine wqdecode(data0,message,ntype)
if(ntype.ge.0 .and. ntype.le.62) then
nu=mod(ntype,10)
if(nu.eq.0 .or. nu.eq.3 .or. nu.eq.7) then
- write(cdbm,'(i3)'),ntype
+ write(cdbm,'(i3)') ntype
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
message=callsign(1:i1)//grid4//' '//cdbm
@@ -844,7 +844,7 @@ subroutine wqdecode(data0,message,ntype)
ng=n2/128 + 32768*(nadd-1)
call unpackpfx(ng,callsign)
ndbm=ntype-nadd
- write(cdbm,'(i3)'),ndbm
+ write(cdbm,'(i3)') ndbm
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
i2=index(callsign,' ')
@@ -857,7 +857,7 @@ subroutine wqdecode(data0,message,ntype)
grid6=callsign(6:6)//callsign(1:5)
ih=(n2-ntype-64)/128
callsign=dcall(ih)
- write(cdbm,'(i3)'),ndbm
+ write(cdbm,'(i3)') ndbm
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
if(cdbm(1:1).eq.' ') cdbm=cdbm(2:)
i2=index(callsign,' ')
diff --git a/lib/wsprd/jelinek.h b/lib/wsprd/jelinek.h
index 64ecdb96..82ce1deb 100644
--- a/lib/wsprd/jelinek.h
+++ b/lib/wsprd/jelinek.h
@@ -10,8 +10,6 @@ struct snode {
unsigned int jpointer;
};
-struct snode *stack;
-
int jelinek(unsigned int *metric,
unsigned int *cycles,
unsigned char *data,
diff --git a/lib/wsprd/nhash.c b/lib/wsprd/nhash.c
index 9376954f..5bf6ce04 100644
--- a/lib/wsprd/nhash.c
+++ b/lib/wsprd/nhash.c
@@ -349,16 +349,27 @@ uint32_t nhash( const void *key, size_t length, uint32_t initval)
switch(length) /* all the case statements fall through */
{
case 12: c+=((uint32_t)k[11])<<24;
+ /* fall through */
case 11: c+=((uint32_t)k[10])<<16;
+ /* fall through */
case 10: c+=((uint32_t)k[9])<<8;
+ /* fall through */
case 9 : c+=k[8];
+ /* fall through */
case 8 : b+=((uint32_t)k[7])<<24;
+ /* fall through */
case 7 : b+=((uint32_t)k[6])<<16;
+ /* fall through */
case 6 : b+=((uint32_t)k[5])<<8;
+ /* fall through */
case 5 : b+=k[4];
+ /* fall through */
case 4 : a+=((uint32_t)k[3])<<24;
+ /* fall through */
case 3 : a+=((uint32_t)k[2])<<16;
+ /* fall through */
case 2 : a+=((uint32_t)k[1])<<8;
+ /* fall through */
case 1 : a+=k[0];
break;
case 0 : return c;
diff --git a/lib/wsprd/osdwspr.f90 b/lib/wsprd/osdwspr.f90
index 42b8e949..2a2d712d 100644
--- a/lib/wsprd/osdwspr.f90
+++ b/lib/wsprd/osdwspr.f90
@@ -110,11 +110,12 @@ elseif(ndeep.eq.2) then
npre1=1
npre2=0
nt=66
- ntheta=16
+ ntheta=22
+ ntau = 16
elseif(ndeep.eq.3) then
- nord=2
+ nord=1
npre1=1
- npre2=0
+ npre2=1
nt=66
ntheta=22
ntau=16
@@ -128,10 +129,10 @@ elseif(ndeep.eq.4) then
elseif(ndeep.eq.5) then
nord=3
npre1=1
- npre2=0
+ npre2=1
nt=66
ntheta=22
- ntau=20
+ ntau=16
endif
do iorder=1,nord
@@ -144,6 +145,7 @@ do iorder=1,nord
else
iend=1
endif
+ d1=0.
do n1=iflag,iend,-1
mi=misub
mi(n1)=1
diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c
index 3fb15f5a..2e3b385d 100644
--- a/lib/wsprd/wsprd.c
+++ b/lib/wsprd/wsprd.c
@@ -72,6 +72,7 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat,
double dfreq;
int i,ntrmin;
char *c2file[15];
+ size_t nr;
FILE* fp;
fp = fopen(ptr_to_infile,"rb");
@@ -79,13 +80,13 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat,
fprintf(stderr, "Cannot open data file '%s'\n", ptr_to_infile);
return 1;
}
- fread(c2file,sizeof(char),14,fp);
- fread(&ntrmin,sizeof(int),1,fp);
- fread(&dfreq,sizeof(double),1,fp);
+ nr=fread(c2file,sizeof(char),14,fp);
+ nr=fread(&ntrmin,sizeof(int),1,fp);
+ nr=fread(&dfreq,sizeof(double),1,fp);
*freq=dfreq;
-
+
buffer=calloc(2*65536,sizeof(float));
- unsigned long nread=fread(buffer,sizeof(float),2*45000,fp);
+ nr=fread(buffer,sizeof(float),2*45000,fp);
fclose(fp);
*wspr_type=ntrmin;
@@ -96,8 +97,8 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat,
}
free(buffer);
- if( nread == 2*45000 ) {
- return nread/2;
+ if( nr == 2*45000 ) {
+ return (unsigned long) nr/2;
} else {
return 1;
}
@@ -106,7 +107,7 @@ unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat,
//***************************************************************************
unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *qdat )
{
- size_t i, j, npoints;
+ size_t i, j, npoints, nr;
int nfft1, nfft2, nh2, i0;
double df;
@@ -139,11 +140,15 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *q
fprintf(stderr, "Cannot open data file '%s'\n", ptr_to_infile);
return 1;
}
-
+
buf2 = calloc(npoints,sizeof(short int));
- fread(buf2,2,22,fp); //Read and ignore header
- fread(buf2,2,npoints,fp); //Read raw data
+ nr=fread(buf2,2,22,fp); //Read and ignore header
+ nr=fread(buf2,2,npoints,fp); //Read raw data
fclose(fp);
+ if( nr == 0 ) {
+ fprintf(stderr, "No data in file '%s'\n", ptr_to_infile);
+ return 1;
+ }
realin=(float*) fftwf_malloc(sizeof(float)*nfft1);
fftout=(fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex)*(nfft1/2+1));
@@ -202,7 +207,7 @@ void sync_and_demodulate(float *id, float *qd, long np,
static float dt=1.0/375.0, df=375.0/256.0;
static float pi=3.14159265358979323846;
float twopidt, df15=df*1.5, df05=df*0.5;
-
+
int i, j, k, lag;
float i0[162],q0[162],i1[162],q1[162],i2[162],q2[162],i3[162],q3[162];
float p0,p1,p2,p3,cmet,totp,syncmax,fac;
@@ -211,7 +216,7 @@ void sync_and_demodulate(float *id, float *qd, long np,
dphi3, cdphi3, sdphi3;
float f0=0.0, fp, ss, fbest=0.0, fsum=0.0, f2sum=0.0, fsymb[162];
int best_shift = 0, ifreq;
-
+
syncmax=-1e30;
if( mode == 0 ) {ifmin=0; ifmax=0; fstep=0.0; f0=*f1;}
if( mode == 1 ) {lagmin=*shift1;lagmax=*shift1;f0=*f1;}
@@ -282,7 +287,7 @@ void sync_and_demodulate(float *id, float *qd, long np,
p1=i1[i]*i1[i] + q1[i]*q1[i];
p2=i2[i]*i2[i] + q2[i]*q2[i];
p3=i3[i]*i3[i] + q3[i]*q3[i];
-
+
p0=sqrt(p0);
p1=sqrt(p1);
p2=sqrt(p2);
@@ -334,12 +339,12 @@ void sync_and_demodulate(float *id, float *qd, long np,
}
void noncoherent_sequence_detection(float *id, float *qd, long np,
- unsigned char *symbols, float *f1, int *shift1,
- float *drift1, int symfac, int *nblocksize)
+ unsigned char *symbols, float *f1, int *shift1,
+ float *drift1, int symfac, int *nblocksize, int *bitmetric)
{
/************************************************************************
* Noncoherent sequence detection for wspr. *
- * Allowed block lengths are nblock=1,2,3,6, or 9 symbols. *
+ * Allowed block lengths are nblock=1,2,3,6, or 9 symbols. *
* Longer block lengths require longer channel coherence time. *
* The whole block is estimated at once. *
* nblock=1 corresponds to noncoherent detection of individual symbols *
@@ -364,31 +369,32 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
lag=*shift1;
nblock=*nblocksize;
nseq=1<<nblock;
-
+ int bitbybit=*bitmetric;
+
for (i=0; i<162; i++) {
fp = f0 + (*drift1/2.0)*((float)i-81.0)/81.0;
if( i==0 || (fp != fplast) ) { // only calculate sin/cos if necessary
dphi0=twopidt*(fp-df15);
cdphi0=cos(dphi0);
sdphi0=sin(dphi0);
-
+
dphi1=twopidt*(fp-df05);
cdphi1=cos(dphi1);
sdphi1=sin(dphi1);
-
+
dphi2=twopidt*(fp+df05);
cdphi2=cos(dphi2);
sdphi2=sin(dphi2);
-
+
dphi3=twopidt*(fp+df15);
cdphi3=cos(dphi3);
sdphi3=sin(dphi3);
-
+
c0[0]=1; s0[0]=0;
c1[0]=1; s1[0]=0;
c2[0]=1; s2[0]=0;
c3[0]=1; s3[0]=0;
-
+
for (j=1; j<257; j++) {
c0[j]=c0[j-1]*cdphi0 - s0[j-1]*sdphi0;
s0[j]=c0[j-1]*sdphi0 + s0[j-1]*cdphi0;
@@ -399,20 +405,20 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
c3[j]=c3[j-1]*cdphi3 - s3[j-1]*sdphi3;
s3[j]=c3[j-1]*sdphi3 + s3[j-1]*cdphi3;
}
-
+
fplast = fp;
}
-
+
cf[0][i]=c0[256]; sf[0][i]=s0[256];
cf[1][i]=c1[256]; sf[1][i]=s1[256];
cf[2][i]=c2[256]; sf[2][i]=s2[256];
cf[3][i]=c3[256]; sf[3][i]=s3[256];
-
+
is[0][i]=0.0; qs[0][i]=0.0;
is[1][i]=0.0; qs[1][i]=0.0;
is[2][i]=0.0; qs[2][i]=0.0;
is[3][i]=0.0; qs[3][i]=0.0;
-
+
for (j=0; j<256; j++) {
k=lag+i*256+j;
if( (k>0) && (k<np) ) {
@@ -427,7 +433,7 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
}
}
}
-
+
for (i=0; i<162; i=i+nblock) {
for (j=0;j<nseq;j++) {
xi[j]=0.0; xq[j]=0.0;
@@ -456,6 +462,9 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
}
}
fsymb[i+ib]=xm1-xm0;
+ if( bitbybit == 1 ) {
+ fsymb[i+ib]=fsymb[i+ib]/(xm1 > xm0 ? xm1 : xm0);
+ }
}
}
for (i=0; i<162; i++) { //Normalize the soft symbols
@@ -529,26 +538,26 @@ void subtract_signal(float *id, float *qd, long np,
return;
}
/******************************************************************************
- Fully coherent signal subtraction
+ Subtract the coherent component of a signal
*******************************************************************************/
void subtract_signal2(float *id, float *qd, long np,
float f0, int shift0, float drift0, unsigned char* channel_symbols)
{
float dt=1.0/375.0, df=375.0/256.0;
float pi=4.*atan(1.0), twopidt, phi=0, dphi, cs;
- int i, j, k, ii, nsym=162, nspersym=256, nfilt=256; //nfilt must be even number.
+ int i, j, k, ii, nsym=162, nspersym=256, nfilt=360; //nfilt must be even number.
int nsig=nsym*nspersym;
int nc2=45000;
float *refi, *refq, *ci, *cq, *cfi, *cfq;
-
+
refi=calloc(nc2,sizeof(float));
refq=calloc(nc2,sizeof(float));
ci=calloc(nc2,sizeof(float));
cq=calloc(nc2,sizeof(float));
cfi=calloc(nc2,sizeof(float));
cfq=calloc(nc2,sizeof(float));
-
+
twopidt=2.0*pi*dt;
/******************************************************************************
@@ -578,22 +587,9 @@ void subtract_signal2(float *id, float *qd, long np,
phi=phi+dphi;
}
}
-
- // s(t) * conjugate(r(t))
- // beginning of first symbol in reference signal is at i=0
- // beginning of first symbol in received data is at shift0.
- // filter transient lasts nfilt samples
- // leave nfilt zeros as a pad at the beginning of the unfiltered reference signal
- for (i=0; i<nsym*nspersym; i++) {
- k=shift0+i;
- if( (k>0) && (k<np) ) {
- ci[i+nfilt] = id[k]*refi[i] + qd[k]*refq[i];
- cq[i+nfilt] = qd[k]*refi[i] - id[k]*refq[i];
- }
- }
-
+
+ float w[nfilt], norm=0, partialsum[nfilt];
//lowpass filter and remove startup transient
- float w[nfilt], norm=0, partialsum[nfilt];
for (i=0; i<nfilt; i++) partialsum[i]=0.0;
for (i=0; i<nfilt; i++) {
w[i]=sin(pi*(float)i/(float)(nfilt-1));
@@ -605,7 +601,20 @@ void subtract_signal2(float *id, float *qd, long np,
for (i=1; i<nfilt; i++) {
partialsum[i]=partialsum[i-1]+w[i];
}
-
+
+ // s(t) * conjugate(r(t))
+ // beginning of first symbol in reference signal is at i=0
+ // beginning of first symbol in received data is at shift0.
+ // filter transient lasts nfilt samples
+ // leave nfilt zeros as a pad at the beginning of the unfiltered reference signal
+ for (i=0; i<nsym*nspersym; i++) {
+ k=shift0+i;
+ if( (k>0) && (k<np) ) {
+ ci[i+nfilt] = id[k]*refi[i] + qd[k]*refq[i];
+ cq[i+nfilt] = qd[k]*refi[i] - id[k]*refq[i];
+ }
+ }
+
// LPF
for (i=nfilt/2; i<45000-nfilt/2; i++) {
cfi[i]=0.0; cfq[i]=0.0;
@@ -614,9 +623,9 @@ void subtract_signal2(float *id, float *qd, long np,
cfq[i]=cfq[i]+w[j]*cq[i-nfilt/2+j];
}
}
-
+
// subtract c(t)*r(t) here
- // (ci+j*cq)(refi+j*refq)=(ci*refi-cq*refq)+j(ci*refq)+cq*refi)
+ // (ci+j*cq)(refi+j*refq)=(ci*refi-cq*refq)+j(ci*refq+cq*refi)
// beginning of first symbol in reference signal is at i=nfilt
// beginning of first symbol in received data is at shift0.
for (i=0; i<nsig; i++) {
@@ -641,7 +650,7 @@ void subtract_signal2(float *id, float *qd, long np,
free(cq);
free(cfi);
free(cfq);
-
+
return;
}
@@ -675,6 +684,23 @@ unsigned long writec2file(char *c2filename, int trmin, double freq
}
}
+unsigned int count_hard_errors( unsigned char *symbols, unsigned char *channel_symbols)
+{
+ int i,is;
+ unsigned char cw[162];
+ unsigned int nerrors;
+ for (i=0; i<162; i++) {
+ cw[i] = channel_symbols[i] >=2 ? 1:0;
+ }
+ deinterleave(cw);
+ nerrors=0;
+ for (i=0; i<162; i++) {
+ is = symbols[i] > 127 ? 1:0;
+ nerrors = nerrors + (is == cw[i] ? 0:1);
+ }
+ return nerrors;
+}
+
//***************************************************************************
void usage(void)
{
@@ -710,23 +736,22 @@ int main(int argc, char *argv[])
int i,j,k;
unsigned char *symbols, *decdata, *channel_symbols, *apmask, *cw;
signed char message[]={-9,13,-35,123,57,-39,64,0,0,0,0};
- char *callsign, *call_loc_pow;
+ char *callsign, *grid, *call_loc_pow;
char *ptr_to_infile,*ptr_to_infile_suffix;
char *data_dir=NULL;
char wisdom_fname[200],all_fname[200],spots_fname[200];
char timer_fname[200],hash_fname[200];
char uttime[5],date[7];
int c,delta,maxpts=65536,verbose=0,quickmode=0,more_candidates=0, stackdecoder=0;
- int writenoise=0,usehashtable=1,wspr_type=2, ipass, nblocksize;
+ int usehashtable=1,wspr_type=2, ipass, nblocksize;
int nhardmin,ihash;
int writec2=0,maxdrift;
- int shift1, lagmin, lagmax, lagstep, ifmin, ifmax, worth_a_try, not_decoded;
+ int shift1, lagmin, lagmax, lagstep, ifmin, ifmax, not_decoded;
unsigned int nbits=81, stacksize=200000;
- unsigned int npoints, metric, cycles, maxnp;
+ struct snode * stack=NULL;
+ unsigned int npoints, cycles, maxnp, metric;
float df=375.0/256.0/2;
- float freq0[200],snr0[200],drift0[200],sync0[200];
float fsymbs[162];
- int shift0[200];
float dt=1.0/375.0, dt_print;
double dialfreq_cmdline=0.0, dialfreq, freq_print;
double dialfreq_error=0.0;
@@ -737,16 +762,21 @@ int main(int argc, char *argv[])
float *idat, *qdat;
clock_t t0,t00;
float tfano=0.0,treadwav=0.0,tcandidates=0.0,tsync0=0.0;
- float tsync1=0.0,tsync2=0.0,ttotal=0.0;
+ float tsync1=0.0,tsync2=0.0,tosd=0.0,ttotal=0.0;
+
+ struct cand { float freq; float snr; int shift; float drift; float sync; };
+ struct cand candidates[200];
struct result { char date[7]; char time[5]; float sync; float snr;
- float dt; double freq; char message[23]; float drift;
- unsigned int cycles; int jitter; int blocksize; unsigned int metric;
- unsigned char osd_decode; };
+ float dt; double freq; char message[23]; float drift;
+ unsigned int cycles; int jitter; int blocksize; unsigned int metric;
+ int nhardmin; int ipass; int decodetype;};
struct result decodes[50];
char *hashtab;
hashtab=calloc(32768*13,sizeof(char));
+ char *loctab;
+ loctab=calloc(32768*5,sizeof(char));
int nh;
symbols=calloc(nbits*2,sizeof(unsigned char));
apmask=calloc(162,sizeof(unsigned char));
@@ -754,6 +784,7 @@ int main(int argc, char *argv[])
decdata=calloc(11,sizeof(unsigned char));
channel_symbols=calloc(nbits*2,sizeof(unsigned char));
callsign=calloc(13,sizeof(char));
+ grid=calloc(5,sizeof(char));
call_loc_pow=calloc(23,sizeof(char));
float allfreqs[100];
char allcalls[100][13];
@@ -768,11 +799,10 @@ int main(int argc, char *argv[])
float minsync2=0.12; //Second sync limit
int iifac=8; //Step size in final DT peakup
int symfac=50; //Soft-symbol normalizing factor
- int block_demod=1; //Default is to use block demod on pass 2
int subtraction=1;
- int npasses=2;
- int ndepth=-1; //Depth for OSD
-
+ int npasses=3;
+ int ndepth=-1; //Depth for OSD
+
float minrms=52.0 * (symfac/64.0); //Final test for plausible decoding
delta=60; //Fano threshold step
float bias=0.45; //Fano metric bias (used for both Fano and stack algorithms)
@@ -791,8 +821,8 @@ int main(int argc, char *argv[])
case 'a':
data_dir = optarg;
break;
- case 'B':
- block_demod=0;
+ case 'B':
+ npasses=2;
break;
case 'c':
writec2=1;
@@ -825,7 +855,7 @@ int main(int argc, char *argv[])
case 'q': //no shift jittering
quickmode = 1;
break;
- case 's': //single pass mode
+ case 's': //single pass mode
subtraction = 0;
npasses = 1;
break;
@@ -891,10 +921,11 @@ int main(int argc, char *argv[])
// fdiag=fopen("wsprd_diag","a");
if((ftimer=fopen(timer_fname,"r"))) {
- //Accumulate timing data
- fscanf(ftimer,"%f %f %f %f %f %f %f",
- &treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&ttotal);
- fclose(ftimer);
+ //Accumulate timing data
+ int nr=fscanf(ftimer,"%f %f %f %f %f %f %f %f",
+ &treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&tosd,&ttotal);
+ fclose(ftimer);
+ if(nr == 0) fprintf(stderr, "Empty timer file: '%s'\n", timer_fname);
}
ftimer=fopen(timer_fname,"w");
@@ -927,7 +958,7 @@ int main(int argc, char *argv[])
strncpy(uttime,ptr_to_infile_suffix-4,4);
date[6]='\0';
uttime[4]='\0';
-
+
// Do windowed ffts over 2 symbols, stepped by half symbols
int nffts=4*floor(npoints/512)-1;
fftin=(fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex)*512);
@@ -941,35 +972,32 @@ int main(int argc, char *argv[])
}
if( usehashtable ) {
- char line[80], hcall[12];
+ char line[80], hcall[13], hgrid[5];
if( (fhash=fopen(hash_fname,"r+")) ) {
while (fgets(line, sizeof(line), fhash) != NULL) {
- sscanf(line,"%d %s",&nh,hcall);
+ hgrid[0]='\0';
+ sscanf(line,"%d %s %s",&nh,hcall,hgrid);
strcpy(hashtab+nh*13,hcall);
+ if(strlen(hgrid)>0) strcpy(loctab+nh*5,hgrid);
}
} else {
fhash=fopen(hash_fname,"w+");
}
fclose(fhash);
}
-
+
//*************** main loop starts here *****************
for (ipass=0; ipass<npasses; ipass++) {
- if(ipass == 0) {
+ if(ipass==1 && ndecodes_pass == 0 && npasses>2) ipass=2;
+ if(ipass < 2) {
nblocksize=1;
maxdrift=4;
minsync2=0.12;
}
- if(ipass == 1 ) {
- if(block_demod == 1) {
- nblocksize=3; // try all blocksizes up to 3
- maxdrift=0; // no drift for smaller frequency estimator variance
- minsync2=0.10;
- } else { // if called with -B, revert to "classic" wspr params
- nblocksize=1;
- maxdrift=4;
- minsync2=0.12;
- }
+ if(ipass == 2 ) {
+ nblocksize=4; // try 3 blocksizes plus bitbybit normalization
+ maxdrift=0; // no drift for smaller frequency estimator variance
+ minsync2=0.10;
}
ndecodes_pass=0; // still needed?
@@ -1023,7 +1051,6 @@ int main(int argc, char *argv[])
* The corresponding threshold is -42.3 dB in 2500 Hz bandwidth for WSPR-15. */
float min_snr, snr_scaling_factor;
-// min_snr = pow(10.0,-7.0/10.0); //this is min snr in wspr bw
min_snr = pow(10.0,-8.0/10.0); //this is min snr in wspr bw
if( wspr_type == 2 ) {
snr_scaling_factor=26.3;
@@ -1038,37 +1065,36 @@ int main(int argc, char *argv[])
// Find all local maxima in smoothed spectrum.
for (i=0; i<200; i++) {
- freq0[i]=0.0;
- snr0[i]=0.0;
- drift0[i]=0.0;
- shift0[i]=0;
- sync0[i]=0.0;
+ candidates[i].freq=0.0;
+ candidates[i].snr=0.0;
+ candidates[i].drift=0.0;
+ candidates[i].shift=0;
+ candidates[i].sync=0.0;
}
int npk=0;
unsigned char candidate;
+ for(j=1; j<410; j++) {
+ candidate = (smspec[j]>smspec[j-1]) &&
+ (smspec[j]>smspec[j+1]) &&
+ (npk<200);
+ if ( candidate ) {
+ candidates[npk].freq = (j-205)*df;
+ candidates[npk].snr = 10*log10(smspec[j])-snr_scaling_factor;
+ npk++;
+ }
+ }
if( more_candidates ) {
- for(j=0; j<411; j=j+2) {
+ for(j=0; j<411; j=j+3) {
candidate = (smspec[j]>min_snr) && (npk<200);
if ( candidate ) {
- freq0[npk]=(j-205)*df;
- snr0[npk]=10*log10(smspec[j])-snr_scaling_factor;
- npk++;
- }
- }
- } else {
- for(j=1; j<410; j++) {
- candidate = (smspec[j]>smspec[j-1]) &&
- (smspec[j]>smspec[j+1]) &&
- (npk<200);
- if ( candidate ) {
- freq0[npk]=(j-205)*df;
- snr0[npk]=10*log10(smspec[j])-snr_scaling_factor;
+ candidates[npk].freq = (j-205)*df;
+ candidates[npk].snr = 10*log10(smspec[j])-snr_scaling_factor;
npk++;
}
}
}
-
+
// Compute corrected fmin, fmax, accounting for dial frequency error
fmin += dialfreq_error; // dialfreq_error is in units of Hz
fmax += dialfreq_error;
@@ -1076,32 +1102,28 @@ int main(int argc, char *argv[])
// Don't waste time on signals outside of the range [fmin,fmax].
i=0;
for( j=0; j<npk; j++) {
- if( freq0[j] >= fmin && freq0[j] <= fmax ) {
- freq0[i]=freq0[j];
- snr0[i]=snr0[j];
+ if( candidates[j].freq >= fmin && candidates[j].freq <= fmax ) {
+ candidates[i]=candidates[j];
i++;
}
}
npk=i;
- // bubble sort on snr, bringing freq along for the ride
+ // bubble sort on snr
int pass;
- float tmp;
+ struct cand tmp;
for (pass = 1; pass <= npk - 1; pass++) {
for (k = 0; k < npk - pass ; k++) {
- if (snr0[k] < snr0[k+1]) {
- tmp = snr0[k];
- snr0[k] = snr0[k+1];
- snr0[k+1] = tmp;
- tmp = freq0[k];
- freq0[k] = freq0[k+1];
- freq0[k+1] = tmp;
+ if (candidates[k].snr < candidates[k+1].snr) {
+ tmp = candidates[k];
+ candidates[k]=candidates[k+1];
+ candidates[k+1] = tmp;
}
}
}
t0=clock();
-
+
/* Make coarse estimates of shift (DT), freq, and drift
* Look for time offsets up to +/- 8 symbols (about +/- 5.4 s) relative
@@ -1121,13 +1143,13 @@ int main(int argc, char *argv[])
span of 162 symbols, with deviation equal to 0 at the center of the
signal vector.
*/
-
+
int idrift,ifr,if0,ifd,k0;
int kindex;
float smax,ss,pow,p0,p1,p2,p3;
for(j=0; j<npk; j++) { //For each candidate...
smax=-1e30;
- if0=freq0[j]/df+256;
+ if0=candidates[j].freq/df+256;
for (ifr=if0-2; ifr<=if0+2; ifr++) { //Freq search
for( k0=-10; k0<22; k0++) { //Time search
for (idrift=-maxdrift; idrift<=maxdrift; idrift++) { //Drift search
@@ -1154,17 +1176,17 @@ int main(int argc, char *argv[])
sync1=ss/pow;
if( sync1 > smax ) { //Save coarse parameters
smax=sync1;
- shift0[j]=128*(k0+1);
- drift0[j]=idrift;
- freq0[j]=(ifr-256)*df;
- sync0[j]=sync1;
+ candidates[j].shift=128*(k0+1);
+ candidates[j].drift=idrift;
+ candidates[j].freq=(ifr-256)*df;
+ candidates[j].sync=sync1;
}
}
}
}
}
tcandidates += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
+
/*
Refine the estimates of freq, shift using sync as a metric.
Sync is calculated such that it is a float taking values in the range
@@ -1182,15 +1204,12 @@ int main(int argc, char *argv[])
could each work on one candidate at a time.
*/
for (j=0; j<npk; j++) {
- memset(symbols,0,sizeof(char)*nbits*2);
- memset(callsign,0,sizeof(char)*13);
- memset(call_loc_pow,0,sizeof(char)*23);
-
- f1=freq0[j];
- drift1=drift0[j];
- shift1=shift0[j];
- sync1=sync0[j];
-
+
+ f1=candidates[j].freq;
+ drift1=candidates[j].drift;
+ shift1=candidates[j].shift;
+ sync1=candidates[j].sync;
+
// coarse-grid lag and freq search, then if sync>minsync1 continue
fstep=0.0; ifmin=0; ifmax=0;
lagmin=shift1-128;
@@ -1200,24 +1219,24 @@ int main(int argc, char *argv[])
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 0);
tsync0 += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
+
fstep=0.25; ifmin=-2; ifmax=2;
t0 = clock();
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1);
-
- if(ipass == 0) {
+
+ if(ipass < 2) {
// refine drift estimate
fstep=0.0; ifmin=0; ifmax=0;
float driftp,driftm,syncp,syncm;
driftp=drift1+0.5;
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
- lagmin, lagmax, lagstep, &driftp, symfac, &syncp, 1);
-
+ lagmin, lagmax, lagstep, &driftp, symfac, &syncp, 1);
+
driftm=drift1-0.5;
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
- lagmin, lagmax, lagstep, &driftm, symfac, &syncm, 1);
-
+ lagmin, lagmax, lagstep, &driftm, symfac, &syncm, 1);
+
if(syncp>sync1) {
drift1=driftp;
sync1=syncp;
@@ -1227,80 +1246,118 @@ int main(int argc, char *argv[])
}
}
tsync1 += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
+
// fine-grid lag and freq search
if( sync1 > minsync1 ) {
-
+
lagmin=shift1-32; lagmax=shift1+32; lagstep=16;
t0 = clock();
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 0);
tsync0 += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
+
// fine search over frequency
fstep=0.05; ifmin=-2; ifmax=2;
t0 = clock();
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
- lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1);
+ lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1);
tsync1 += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
- worth_a_try = 1;
- } else {
- worth_a_try = 0;
+
+ candidates[j].freq=f1;
+ candidates[j].shift=shift1;
+ candidates[j].drift=drift1;
+ candidates[j].sync=sync1;
}
-
- int idt, ii, jittered_shift;
- float y,sq,rms;
+ }
+
+ int nwat=0;
+ int idupe;
+ for ( j=0; j<npk; j++) {
+ idupe=0;
+ for (k=0;k<nwat;k++) {
+ if( fabsf(candidates[j].freq - candidates[k].freq) < 0.05 &&
+ abs(candidates[j].shift - candidates[k].shift) < 16 ) {
+ idupe=1;
+ break;
+ }
+ }
+ if( idupe == 1 ) {
+ if(candidates[j].sync > candidates[k].sync) candidates[k]=candidates[j];
+ } else if ( candidates[j].sync > minsync2 ) {
+ candidates[nwat]=candidates[j];
+ nwat++;
+ }
+ }
+
+ int idt, ii, jittered_shift;
+ float y,sq,rms;
+ int ib, blocksize, bitmetric;
+ int n1,n2,n3,nadd,nu,ntype;
+ int osd_decode;
+ for (j=0; j<nwat; j++) {
+ memset(symbols,0,sizeof(char)*nbits*2);
+ memset(callsign,0,sizeof(char)*13);
+ memset(grid,0,sizeof(char)*5);
+ memset(call_loc_pow,0,sizeof(char)*23);
+ f1=candidates[j].freq;
+ shift1=candidates[j].shift;
+ drift1=candidates[j].drift;
not_decoded=1;
- int osd_decode=0;
- int ib=1, blocksize;
- int n1,n2,n3,nadd,nu,ntype;
+ osd_decode=0;
+
+ ib=1;
while( ib <= nblocksize && not_decoded ) {
- blocksize=ib;
+ if (ib < 4) { blocksize=ib; bitmetric=0; }
+ if (ib == 4) { blocksize=1; bitmetric=1; }
+
idt=0; ii=0;
- while ( worth_a_try && not_decoded && idt<=(128/iifac)) {
+ while ( not_decoded && idt<=(128/iifac)) {
ii=(idt+1)/2;
if( idt%2 == 1 ) ii=-ii;
ii=iifac*ii;
jittered_shift=shift1+ii;
-
- // Use mode 2 to get soft-decision symbols
+ nhardmin=0; dmin=0.0;
+
+ // Get soft-decision symbols
t0 = clock();
noncoherent_sequence_detection(idat, qdat, npoints, symbols, &f1,
- &jittered_shift, &drift1, symfac, &blocksize);
+ &jittered_shift, &drift1, symfac, &blocksize, &bitmetric);
tsync2 += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
+
sq=0.0;
for(i=0; i<162; i++) {
y=(float)symbols[i] - 128.0;
sq += y*y;
}
rms=sqrt(sq/162.0);
-
- if((sync1 > minsync2) && (rms > minrms)) {
+
+ if(rms > minrms) {
deinterleave(symbols);
t0 = clock();
-
- if ( stackdecoder ) {
+
+ if ( stack ) {
not_decoded = jelinek(&metric, &cycles, decdata, symbols, nbits,
- stacksize, stack, mettab,maxcycles);
+ stacksize, stack, mettab,maxcycles);
} else {
not_decoded = fano(&metric,&cycles,&maxnp,decdata,symbols,nbits,
- mettab,delta,maxcycles);
+ mettab,delta,maxcycles);
}
-
+
tfano += (float)(clock()-t0)/CLOCKS_PER_SEC;
-
- if( (ndepth >= 0) && not_decoded ) {
+
+ if( (ndepth >= 0) && not_decoded ) {
for(i=0; i<162; i++) {
- fsymbs[i]=symbols[i]-127;
+ fsymbs[i]=symbols[i]-128.0;
}
+ t0 = clock();
osdwspr_(fsymbs,apmask,&ndepth,cw,&nhardmin,&dmin);
+ tosd += (float)(clock()-t0)/CLOCKS_PER_SEC;
+
for(i=0; i<162; i++) {
- symbols[i]=255*cw[i];
+ symbols[i]=255*cw[i];
}
fano(&metric,&cycles,&maxnp,decdata,symbols,nbits,
- mettab,delta,maxcycles);
+ mettab,delta,maxcycles);
for(i=0; i<11; i++) {
if( decdata[i]>127 ) {
message[i]=decdata[i]-256;
@@ -1311,33 +1368,42 @@ int main(int argc, char *argv[])
unpack50(message,&n1,&n2);
if( !unpackcall(n1,callsign) ) break;
callsign[12]=0;
+ if( !unpackgrid(n2, grid) ) break;
+ grid[4]=0;
ntype = (n2&127) - 64;
+ int itype;
if( (ntype >= 0) && (ntype <= 62) ) {
nu = ntype%10;
+ itype=1;
if( !(nu == 0 || nu == 3 || nu == 7) ) {
- nadd=nu;
- if( nu > 3 ) nadd=nu-3;
- if( nu > 7 ) nadd=nu-7;
- n3=n2/128+32768*(nadd-1);
- if( !unpackpfx(n3,callsign) ) break;
+ nadd=nu;
+ if( nu > 3 ) nadd=nu-3;
+ if( nu > 7 ) nadd=nu-7;
+ n3=n2/128+32768*(nadd-1);
+ if( !unpackpfx(n3,callsign) ) {
+ break;
+ }
+ itype=2;
}
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
- if(strncmp(hashtab+ihash*13,callsign,13)==0) {
- not_decoded=0;
- osd_decode =1;
- break;
+ if(strncmp(hashtab+ihash*13,callsign,13)==0) {
+ if( (itype==1 && strncmp(loctab+ihash*5,grid,5)==0) ||
+ (itype==2) ) {
+ not_decoded=0;
+ osd_decode =1;
+ }
}
- }
+ }
}
-
+
}
idt++;
if( quickmode ) break;
}
ib++;
- }
-
- if( worth_a_try && !not_decoded ) {
+ }
+
+ if( !not_decoded ) {
ndecodes_pass++;
for(i=0; i<11; i++) {
@@ -1349,26 +1415,25 @@ int main(int argc, char *argv[])
}
}
-
+
// Unpack the decoded message, update the hashtable, apply
// sanity checks on grid and power, and return
// call_loc_pow string and also callsign (for de-duping).
- noprint=unpk_(message,hashtab,call_loc_pow,callsign);
-
- // subtract even on last pass
- if( subtraction && (ipass < npasses ) && !noprint ) {
- if( get_wspr_channel_symbols(call_loc_pow, hashtab, channel_symbols) ) {
+ noprint=unpk_(message,hashtab,loctab,call_loc_pow,callsign);
+ if( subtraction && !noprint ) {
+ if( get_wspr_channel_symbols(call_loc_pow, hashtab, loctab, channel_symbols) ) {
subtract_signal2(idat, qdat, npoints, f1, shift1, drift1, channel_symbols);
+ if(!osd_decode) nhardmin=count_hard_errors(symbols,channel_symbols);
} else {
break;
}
}
-
- // Remove dupes (same callsign and freq within 3 Hz)
+
+ // Remove dupes (same callsign and freq within 4 Hz)
int dupe=0;
for (i=0; i<uniques; i++) {
if(!strcmp(callsign,allcalls[i]) &&
- (fabs(f1-allfreqs[i]) <3.0)) dupe=1;
+ (fabs(f1-allfreqs[i]) <4.0)) dupe=1;
}
if( (verbose || !dupe) && !noprint) {
strcpy(allcalls[uniques],callsign);
@@ -1388,17 +1453,19 @@ int main(int argc, char *argv[])
strcpy(decodes[uniques-1].date,date);
strcpy(decodes[uniques-1].time,uttime);
- decodes[uniques-1].sync=sync1;
- decodes[uniques-1].snr=snr0[j];
+ decodes[uniques-1].sync=candidates[j].sync;
+ decodes[uniques-1].snr=candidates[j].snr;
decodes[uniques-1].dt=dt_print;
decodes[uniques-1].freq=freq_print;
strcpy(decodes[uniques-1].message,call_loc_pow);
decodes[uniques-1].drift=drift1;
decodes[uniques-1].cycles=cycles;
decodes[uniques-1].jitter=ii;
- decodes[uniques-1].blocksize=blocksize;
+ decodes[uniques-1].blocksize=blocksize+3*bitmetric;
decodes[uniques-1].metric=metric;
- decodes[uniques-1].osd_decode=osd_decode;
+ decodes[uniques-1].nhardmin=nhardmin;
+ decodes[uniques-1].ipass=ipass;
+ decodes[uniques-1].decodetype=osd_decode;
}
}
}
@@ -1412,7 +1479,7 @@ int main(int argc, char *argv[])
writec2file(c2filename, wsprtype, carrierfreq, idat, qdat);
}
}
-
+
// sort the result in order of increasing frequency
struct result temp;
for (j = 1; j <= uniques - 1; j++) {
@@ -1430,11 +1497,13 @@ int main(int argc, char *argv[])
decodes[i].time, decodes[i].snr,decodes[i].dt, decodes[i].freq,
(int)decodes[i].drift, decodes[i].message);
fprintf(fall_wspr,
- "%6s %4s %3d %3.0f %5.2f %11.7f %-22s %2d %5u %4d %4d %4d %2u\n",
- decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync),
- decodes[i].snr, decodes[i].dt, decodes[i].freq,
- decodes[i].message, (int)decodes[i].drift, decodes[i].cycles/81,
- decodes[i].jitter,decodes[i].blocksize,decodes[i].metric,decodes[i].osd_decode);
+ "%6s %4s %3.0f %5.2f %11.7f %-22s %2d %5.2f %2d %2d %4d %2d %3d %5u %5d\n",
+ decodes[i].date, decodes[i].time, decodes[i].snr,
+ decodes[i].dt, decodes[i].freq, decodes[i].message,
+ (int)decodes[i].drift, decodes[i].sync,
+ decodes[i].ipass+1,decodes[i].blocksize,decodes[i].jitter,
+ decodes[i].decodetype,decodes[i].nhardmin,decodes[i].cycles/81,
+ decodes[i].metric);
fprintf(fwsprd,
"%6s %4s %3d %3.0f %4.1f %10.6f %-22s %2d %5u %4d\n",
decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync),
@@ -1452,11 +1521,11 @@ int main(int argc, char *argv[])
fftwf_export_wisdom_to_file(fp_fftwf_wisdom_file);
fclose(fp_fftwf_wisdom_file);
}
-
+
ttotal += (float)(clock()-t00)/CLOCKS_PER_SEC;
-
- fprintf(ftimer,"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n\n",
- treadwav,tcandidates,tsync0,tsync1,tsync2,tfano,ttotal);
+
+ fprintf(ftimer,"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n\n",
+ treadwav,tcandidates,tsync0,tsync1,tsync2,tfano,tosd,ttotal);
fprintf(ftimer,"Code segment Seconds Frac\n");
fprintf(ftimer,"-----------------------------------\n");
@@ -1467,6 +1536,7 @@ int main(int argc, char *argv[])
fprintf(ftimer,"sync_and_demod(1) %7.2f %7.2f\n",tsync1,tsync1/ttotal);
fprintf(ftimer,"sync_and_demod(2) %7.2f %7.2f\n",tsync2,tsync2/ttotal);
fprintf(ftimer,"Stack/Fano decoder %7.2f %7.2f\n",tfano,tfano/ttotal);
+ fprintf(ftimer,"OSD decoder %7.2f %7.2f\n",tosd,tosd/ttotal);
fprintf(ftimer,"-----------------------------------\n");
fprintf(ftimer,"Total %7.2f %7.2f\n",ttotal,1.0);
@@ -1482,24 +1552,22 @@ int main(int argc, char *argv[])
fhash=fopen(hash_fname,"w");
for (i=0; i<32768; i++) {
if( strncmp(hashtab+i*13,"\0",1) != 0 ) {
- fprintf(fhash,"%5d %s\n",i,hashtab+i*13);
+ fprintf(fhash,"%5d %s %s\n",i,hashtab+i*13,loctab+i*5);
}
}
fclose(fhash);
}
-
+
free(hashtab);
+ free(loctab);
free(symbols);
free(decdata);
free(channel_symbols);
free(callsign);
free(call_loc_pow);
free(idat);
- free(qdat);
- if( stackdecoder ) {
- free(stack);
- }
+ free(qdat);
+ free(stack);
- if(writenoise == 999) return -1; //Silence compiler warning
return 0;
}
diff --git a/lib/wsprd/wsprd_utils.c b/lib/wsprd/wsprd_utils.c
index 65485d4b..5a1d4974 100644
--- a/lib/wsprd/wsprd_utils.c
+++ b/lib/wsprd/wsprd_utils.c
@@ -240,7 +240,7 @@ int floatcomp(const void* elem1, const void* elem2)
return *(const float*)elem1 > *(const float*)elem2;
}
-int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsign)
+int unpk_(signed char *message, char *hashtab, char *loctab, char *call_loc_pow, char *callsign)
{
int n1,n2,n3,ndbm,ihash,nadd,noprint=0;
char grid[5],grid6[7],cdbm[3];
@@ -279,6 +279,7 @@ int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsig
strncat(call_loc_pow,"\0",1);
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
strcpy(hashtab+ihash*13,callsign);
+ strcpy(loctab+ihash*5,grid);
} else {
nadd=nu;
if( nu > 3 ) nadd=nu-3;
@@ -312,8 +313,8 @@ int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsig
// not testing 4'th and 5'th chars because of this case: <PA0SKT/2> JO33 40
// grid is only 4 chars even though this is a hashed callsign...
// isalpha(grid6[4]) && isalpha(grid6[5]) ) ) {
- noprint=1;
- }
+ noprint=1;
+ }
ihash=(n2-ntype-64)/128;
if( strncmp(hashtab+ihash*13,"\0",1) != 0 ) {
diff --git a/lib/wsprd/wsprd_utils.h b/lib/wsprd/wsprd_utils.h
index d6708363..db6ba946 100644
--- a/lib/wsprd/wsprd_utils.h
+++ b/lib/wsprd/wsprd_utils.h
@@ -24,6 +24,6 @@ void deinterleave(unsigned char *sym);
int doublecomp(const void* elem1, const void* elem2);
int floatcomp(const void* elem1, const void* elem2);
-int unpk_( signed char *message, char* hashtab, char *call_loc_pow, char *callsign);
+int unpk_( signed char *message, char* hashtab, char* loctab, char *call_loc_pow, char *callsign);
#endif
diff --git a/lib/wsprd/wsprsim.c b/lib/wsprd/wsprsim.c
index b3af9980..f6633c1c 100644
--- a/lib/wsprd/wsprsim.c
+++ b/lib/wsprd/wsprsim.c
@@ -128,10 +128,12 @@ int main(int argc, char *argv[])
int i, c, printchannel=0, writec2=0;
float snr=50.0;
float f0=0.0, t0=1.0;
- char *message, *c2filename, *hashtab;
+ char *message, *c2filename, *hashtab, *loctab;
c2filename=malloc(sizeof(char)*15);
hashtab=malloc(sizeof(char)*32768*13);
+ loctab=malloc(sizeof(char)*32768*5);
memset(hashtab,0,sizeof(char)*32768*13);
+ memset(hashtab,0,sizeof(char)*32768*5);
// message length is 22 characters
message=malloc(sizeof(char)*23);
@@ -150,6 +152,7 @@ int main(int argc, char *argv[])
break;
case 'f':
f0 = atof(optarg);
+ break;
case 'o':
c2filename = optarg;
writec2=1;
@@ -169,7 +172,7 @@ int main(int argc, char *argv[])
}
unsigned char channel_symbols[162];
- get_wspr_channel_symbols(message, hashtab, channel_symbols);
+ get_wspr_channel_symbols(message, hashtab, loctab, channel_symbols);
if( printchannel ) {
printf("Channel symbols:\n");
diff --git a/lib/wsprd/wsprsim_utils.c b/lib/wsprd/wsprsim_utils.c
index f65efba4..b6b95c49 100644
--- a/lib/wsprd/wsprsim_utils.c
+++ b/lib/wsprd/wsprsim_utils.c
@@ -162,7 +162,7 @@ void interleave(unsigned char *sym)
}
}
-int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* symbols) {
+int get_wspr_channel_symbols(char* rawmessage, char* hashtab, char* loctab, unsigned char* symbols) {
int m=0, ntype=0;
long unsigned int n=0;
int i, j, ihash;
@@ -292,7 +292,7 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
signed char check_data[11];
memcpy(check_data,data,sizeof(char)*11);
- unpk_(check_data,hashtab,check_call_loc_pow,check_callsign);
+ unpk_(check_data,hashtab,loctab,check_call_loc_pow,check_callsign);
// printf("Will decode as: %s\n",check_call_loc_pow);
unsigned int nbytes=11; // The message with tail is packed into almost 11 bytes.
diff --git a/lib/wsprd/wsprsim_utils.h b/lib/wsprd/wsprsim_utils.h
index acffdee9..7f1f62e9 100644
--- a/lib/wsprd/wsprsim_utils.h
+++ b/lib/wsprd/wsprsim_utils.h
@@ -11,6 +11,6 @@
extern int printdata;
-int get_wspr_channel_symbols(char* message, char* hashtab, unsigned char* symbols);
+int get_wspr_channel_symbols(char* message, char* hashtab, char*loctab, unsigned char* symbols);
#endif