summaryrefslogtreecommitdiff
path: root/lib/fsk4hf
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
committerChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
commite0737c56c1e384e05064a0c6e1ac46979371041b (patch)
treea0123d694a2d36c43dabdf0a3907392fce11d457 /lib/fsk4hf
parentb4aebf2d137b892f53503b13785ecae900062ff7 (diff)
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'lib/fsk4hf')
-rw-r--r--lib/fsk4hf/Makefile50
-rw-r--r--lib/fsk4hf/Makefile.win84
-rw-r--r--lib/fsk4hf/bpdecode120.f90306
-rw-r--r--lib/fsk4hf/bpdecode168.f90380
-rw-r--r--lib/fsk4hf/bpdecode204.f90482
-rw-r--r--lib/fsk4hf/bpdecode300.f90708
-rw-r--r--lib/fsk4hf/chkcrc10.f9027
-rw-r--r--lib/fsk4hf/chkcrc12.f9027
-rw-r--r--lib/fsk4hf/cpolyfit.f9076
-rw-r--r--lib/fsk4hf/cpolyfitw.f9068
-rw-r--r--lib/fsk4hf/dbpsksim.f90241
-rw-r--r--lib/fsk4hf/dopspread.f9062
-rw-r--r--lib/fsk4hf/encode120.f90116
-rw-r--r--lib/fsk4hf/encode168.f90141
-rw-r--r--lib/fsk4hf/encode204.f9048
-rw-r--r--lib/fsk4hf/encode300.f90308
-rw-r--r--lib/fsk4hf/extractmessage168.f9048
-rw-r--r--lib/fsk4hf/fftw3.f9064
-rw-r--r--lib/fsk4hf/four2a.f90115
-rw-r--r--lib/fsk4hf/fsk4hf.f90145
-rw-r--r--lib/fsk4hf/fsk4sim.f90185
-rw-r--r--lib/fsk4hf/genbpsk.f9044
-rw-r--r--lib/fsk4hf/genfsk4.f9036
-rw-r--r--lib/fsk4hf/genfsk4hf.f9051
-rw-r--r--lib/fsk4hf/genmskhf.f90126
-rw-r--r--lib/fsk4hf/genwspr5.f90107
-rw-r--r--lib/fsk4hf/genwspr_fsk8.f9045
-rw-r--r--lib/fsk4hf/genwsprcpm.f9070
-rw-r--r--lib/fsk4hf/genwsprdpsk.f9063
-rw-r--r--lib/fsk4hf/genwsprlf.f90137
-rw-r--r--lib/fsk4hf/getfc1.f9058
-rw-r--r--lib/fsk4hf/getfc1w.f9047
-rw-r--r--lib/fsk4hf/getfc2.f9074
-rw-r--r--lib/fsk4hf/getfc2w.f9082
-rw-r--r--lib/fsk4hf/gran.c28
-rw-r--r--lib/fsk4hf/ldpc_204_68_params.f90154
-rw-r--r--lib/fsk4hf/ldpc_300_60_params.f90262
-rw-r--r--lib/fsk4hf/ldpcsim120.f90238
-rw-r--r--lib/fsk4hf/ldpcsim168.f90233
-rw-r--r--lib/fsk4hf/ldpcsim204.f90249
-rw-r--r--lib/fsk4hf/ldpcsim300.f90254
-rw-r--r--lib/fsk4hf/mskhfsim.f90194
-rw-r--r--lib/fsk4hf/msksoftsym.f9081
-rw-r--r--lib/fsk4hf/msksoftsymw.f9078
-rw-r--r--lib/fsk4hf/osd204.f90365
-rw-r--r--lib/fsk4hf/osd300.f90365
-rw-r--r--lib/fsk4hf/polyfit4.f90109
-rw-r--r--lib/fsk4hf/spb.m89
-rw-r--r--lib/fsk4hf/spec4.f9035
-rw-r--r--lib/fsk4hf/spec8.f9031
-rw-r--r--lib/fsk4hf/tweak1.f9023
-rw-r--r--lib/fsk4hf/wavhdr.f90110
-rw-r--r--lib/fsk4hf/wspr5_downsample.f9029
-rw-r--r--lib/fsk4hf/wspr5_wav.f9048
-rw-r--r--lib/fsk4hf/wspr5d.f90220
-rw-r--r--lib/fsk4hf/wspr5d_exp.f90544
-rw-r--r--lib/fsk4hf/wspr5sim.f90111
-rw-r--r--lib/fsk4hf/wspr_fsk8_downsample.f9027
-rw-r--r--lib/fsk4hf/wspr_fsk8_params.f9014
-rw-r--r--lib/fsk4hf/wspr_fsk8_sim.f90107
-rw-r--r--lib/fsk4hf/wspr_fsk8_wav.f9044
-rw-r--r--lib/fsk4hf/wspr_fsk8d.f90197
-rw-r--r--lib/fsk4hf/wspr_params.f9023
-rw-r--r--lib/fsk4hf/wspr_wav.f9049
-rw-r--r--lib/fsk4hf/wsprcpm_params.f9014
-rw-r--r--lib/fsk4hf/wsprcpm_wav.f9044
-rw-r--r--lib/fsk4hf/wsprcpmd.f90550
-rw-r--r--lib/fsk4hf/wsprcpmsim.f90109
-rw-r--r--lib/fsk4hf/wsprdpskd.f90439
-rw-r--r--lib/fsk4hf/wsprdpsksim.f90175
-rw-r--r--lib/fsk4hf/wsprlf.f90110
-rw-r--r--lib/fsk4hf/wsprlf_params.f9014
-rw-r--r--lib/fsk4hf/wsprlfsim.f90286
-rw-r--r--lib/fsk4hf/wsprsimf.f90113
74 files changed, 0 insertions, 10786 deletions
diff --git a/lib/fsk4hf/Makefile b/lib/fsk4hf/Makefile
deleted file mode 100644
index 9372821b..00000000
--- a/lib/fsk4hf/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-# Compilers
-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: wsprlf
-
-OBJS0 = testpsk.o four2a.o bpfilter.o nonlinear.o tweak1.o spectrum.o smo.o
-testpsk: $(OBJS0)
- $(FC) -o testpsk $(OBJS0) -lfftw3f
-
-OBJS1 = gmsk8.o four2a.o gaussfilt.o
-gmsk8: $(OBJS1)
- $(FC) -o gmsk8 $(OBJS1) -lfftw3f
-
-OBJS2 = testfsk.o four2a.o smo.o
-testfsk: $(OBJS2)
- $(FC) -o testfsk $(OBJS2) -lfftw3f
-
-OBJS3 = fsk2sim.o four2a.o smo.o wavhdr.o gran.o
-fsk2sim: $(OBJS3)
- $(FC) -o fsk2sim $(OBJS3) -lfftw3f
-
-OBJS4 = fsk4sim.o four2a.o wavhdr.o gran.o tweak1.o
-fsk4sim: $(OBJS4)
- $(FC) -o fsk4sim $(OBJS4) -lfftw3f
-
-OBJS5 = wsprlf.o four2a.o
-wsprlf: $(OBJS5)
- $(FC) -o wsprlf $(OBJS5) -lfftw3f
-
-.PHONY : clean
-
-clean:
- $(RM) *.o testpsk testfsk fsk2sim fsk4sim wsprlf
diff --git a/lib/fsk4hf/Makefile.win b/lib/fsk4hf/Makefile.win
deleted file mode 100644
index ab383557..00000000
--- a/lib/fsk4hf/Makefile.win
+++ /dev/null
@@ -1,84 +0,0 @@
-# Compilers
-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: dbpsksim.exe
-
-OBJS0 = testpsk.o four2a.o bpfilter.o nonlinear.o tweak1.o spectrum.o smo.o
-testpsk: $(OBJS0)
- $(FC) -o testpsk $(OBJS0) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS1 = gmsk8.o four2a.o gaussfilt.o
-gmsk8: $(OBJS1)
- $(FC) -o gmsk8 $(OBJS1) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS2 = testfsk.o four2a.o smo.o
-testfsk: $(OBJS2)
- $(FC) -o testfsk $(OBJS2) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS3 = fsk2sim.o four2a.o smo.o wavhdr.o gran.o
-fsk2sim: $(OBJS3)
- $(FC) -o fsk2sim $(OBJS3) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS4 = fsk4sim.o four2a.o gran.o genfsk4.o smo.o getsnr.o spec4.o \
- watterson.o db.o snr2_wsprlf.o pctile.o shell.o snr_wsprlf.o
-fsk4sim.exe: $(OBJS4)
- $(FC) -o fsk4sim.exe $(OBJS4) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS5 = wsprlf.o four2a.o downsample.o
-wsprlf.exe: $(OBJS5)
- $(FC) -o wsprlf.exe $(OBJS5) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS6 = wspr_gmsk.o four2a.o gaussfilt.o
-wspr_gmsk.exe: $(OBJS6)
- $(FC) -o wspr_gmsk.exe $(OBJS6) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS7 = wspr_msk.o four2a.o bpfilter.o
-wspr_msk.exe: $(OBJS7)
- $(FC) -o wspr_msk.exe $(OBJS7) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS8 = dbpsksim.o four2a.o gran.o genbpsk.o watterson.o db.o \
- encode120.o bpdecode120.o platanh.o
-dbpsksim.exe: $(OBJS8)
- $(FC) -o dbpsksim.exe $(OBJS8) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS9 = fsk4a.o four2a.o gran.o genfsk4a.o spec4.o \
- watterson.o db.o
-fsk4a.exe: $(OBJS9)
- $(FC) -o fsk4a.exe $(OBJS9) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS10 = gmsk8.o gaussfilt.o four2a.o
-gmsk8.exe: $(OBJS10)
- $(FC) -o gmsk8.exe $(OBJS10) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS11 = gmsksim.o four2a.o gran.o gengmsk.o genbpsk.o watterson.o db.o \
- encode168.o bpdecode168.o platanh.o gaussfilt.o tweak1.o smo121.o
-gmsksim.exe: $(OBJS11)
- $(FC) -o gmsksim.exe $(OBJS11) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-OBJS12 = mskhfsim.o four2a.o gran.o genmskhf.o watterson.o db.o \
- encode168.o bpdecode168.o platanh.o twkfreq1.o smo121.o \
- polyfit4.o
-mskhfsim.exe: $(OBJS12)
- $(FC) -o mskhfsim.exe $(OBJS12) C:\JTSDK\fftw3f\libfftw3f-3.dll
-
-.PHONY : clean
-
-clean:
- $(RM) *.o testpsk.exe testfsk.exe fsk2sim.exe fsk4sim.exe wsprlf.exe
diff --git a/lib/fsk4hf/bpdecode120.f90 b/lib/fsk4hf/bpdecode120.f90
deleted file mode 100644
index c9b11ac3..00000000
--- a/lib/fsk4hf/bpdecode120.f90
+++ /dev/null
@@ -1,306 +0,0 @@
-subroutine bpdecode120(llr,apmask,maxiterations,decoded,niterations,cw)
-
-! A log-domain belief propagation decoder for the (120,60) code.
-
-integer, parameter:: N=120, K=60, M=N-K
-integer*1 codeword(N),cw(N),apmask(N)
-integer colorder(N)
-integer*1 decoded(K)
-integer Nm(7,M) ! 5, 6, or 7 bits per check
-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)
-real llr(N)
-real Tmn
-integer nrw(M)
-
-data colorder/ &
- 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, &
- 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, &
- 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, &
- 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, &
- 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, &
- 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/
-
-data Mn/ &
- 1, 18, 48, &
- 2, 4, 51, &
- 3, 23, 47, &
- 5, 36, 42, &
- 6, 43, 49, &
- 7, 24, 55, &
- 8, 35, 60, &
- 9, 26, 30, &
- 10, 29, 45, &
- 11, 13, 46, &
- 12, 53, 54, &
- 14, 20, 57, &
- 15, 16, 58, &
- 17, 39, 44, &
- 19, 37, 41, &
- 21, 28, 34, &
- 22, 50, 59, &
- 25, 31, 52, &
- 27, 32, 38, &
- 33, 40, 56, &
- 1, 11, 47, &
- 2, 10, 16, &
- 3, 12, 27, &
- 4, 24, 28, &
- 5, 23, 60, &
- 6, 29, 39, &
- 7, 31, 54, &
- 8, 50, 56, &
- 9, 13, 14, &
- 15, 22, 41, &
- 17, 26, 40, &
- 18, 25, 45, &
- 19, 20, 55, &
- 21, 30, 36, &
- 32, 49, 59, &
- 33, 53, 58, &
- 34, 38, 46, &
- 29, 35, 57, &
- 37, 43, 48, &
- 42, 51, 52, &
- 7, 11, 44, &
- 1, 42, 58, &
- 2, 13, 49, &
- 3, 20, 40, &
- 4, 18, 56, &
- 5, 45, 55, &
- 6, 21, 31, &
- 8, 46, 52, &
- 9, 12, 48, &
- 10, 37, 38, &
- 14, 15, 25, &
- 16, 17, 60, &
- 19, 39, 53, &
- 22, 44, 51, &
- 23, 28, 41, &
- 24, 32, 35, &
- 26, 45, 59, &
- 27, 33, 36, &
- 30, 47, 54, &
- 34, 50, 57, &
- 33, 43, 55, &
- 1, 41, 57, &
- 2, 40, 54, &
- 3, 6, 24, &
- 4, 11, 59, &
- 5, 13, 56, &
- 7, 16, 34, &
- 8, 19, 26, &
- 9, 31, 58, &
- 10, 21, 53, &
- 12, 22, 60, &
- 14, 38, 51, &
- 15, 43, 46, &
- 17, 48, 50, &
- 18, 27, 39, &
- 20, 28, 44, &
- 23, 25, 49, &
- 4, 29, 36, &
- 30, 32, 52, &
- 35, 37, 47, &
- 39, 42, 59, &
- 1, 21, 40, &
- 2, 50, 55, &
- 3, 8, 10, &
- 5, 31, 37, &
- 6, 14, 60, &
- 7, 36, 49, &
- 9, 34, 39, &
- 11, 19, 25, &
- 12, 52, 57, &
- 13, 22, 29, &
- 15, 30, 56, &
- 16, 18, 20, &
- 17, 24, 46, &
- 23, 38, 58, &
- 26, 28, 43, &
- 2, 27, 41, &
- 5, 32, 44, &
- 33, 47, 51, &
- 35, 48, 53, &
- 42, 43, 54, &
- 34, 45, 47, &
- 1, 8, 49, &
- 3, 14, 59, &
- 4, 31, 46, &
- 6, 20, 50, &
- 7, 26, 53, &
- 9, 10, 36, &
- 11, 58, 60, &
- 12, 21, 45, &
- 13, 28, 33, &
- 15, 17, 35, &
- 16, 38, 52, &
- 18, 41, 54, &
- 19, 23, 32, &
- 22, 40, 55, &
- 24, 25, 42, &
- 26, 27, 56, &
- 29, 44, 54, &
- 30, 37, 55/
-
-data Nm/ &
- 1, 21, 42, 62, 82, 103, 0, &
- 2, 22, 43, 63, 83, 97, 0, &
- 3, 23, 44, 64, 84, 104, 0, &
- 2, 24, 45, 65, 78, 105, 0, &
- 4, 25, 46, 66, 85, 98, 0, &
- 5, 26, 47, 64, 86, 106, 0, &
- 6, 27, 41, 67, 87, 107, 0, &
- 7, 28, 48, 68, 84, 103, 0, &
- 8, 29, 49, 69, 88, 108, 0, &
- 9, 22, 50, 70, 84, 108, 0, &
- 10, 21, 41, 65, 89, 109, 0, &
- 11, 23, 49, 71, 90, 110, 0, &
- 10, 29, 43, 66, 91, 111, 0, &
- 12, 29, 51, 72, 86, 104, 0, &
- 13, 30, 51, 73, 92, 112, 0, &
- 13, 22, 52, 67, 93, 113, 0, &
- 14, 31, 52, 74, 94, 112, 0, &
- 1, 32, 45, 75, 93, 114, 0, &
- 15, 33, 53, 68, 89, 115, 0, &
- 12, 33, 44, 76, 93, 106, 0, &
- 16, 34, 47, 70, 82, 110, 0, &
- 17, 30, 54, 71, 91, 116, 0, &
- 3, 25, 55, 77, 95, 115, 0, &
- 6, 24, 56, 64, 94, 117, 0, &
- 18, 32, 51, 77, 89, 117, 0, &
- 8, 31, 57, 68, 96, 107, 118, &
- 19, 23, 58, 75, 97, 118, 0, &
- 16, 24, 55, 76, 96, 111, 0, &
- 9, 26, 38, 78, 91, 119, 0, &
- 8, 34, 59, 79, 92, 120, 0, &
- 18, 27, 47, 69, 85, 105, 0, &
- 19, 35, 56, 79, 98, 115, 0, &
- 20, 36, 58, 61, 99, 111, 0, &
- 16, 37, 60, 67, 88, 102, 0, &
- 7, 38, 56, 80, 100, 112, 0, &
- 4, 34, 58, 78, 87, 108, 0, &
- 15, 39, 50, 80, 85, 120, 0, &
- 19, 37, 50, 72, 95, 113, 0, &
- 14, 26, 53, 75, 81, 88, 0, &
- 20, 31, 44, 63, 82, 116, 0, &
- 15, 30, 55, 62, 97, 114, 0, &
- 4, 40, 42, 81, 101, 117, 0, &
- 5, 39, 61, 73, 96, 101, 0, &
- 14, 41, 54, 76, 98, 119, 0, &
- 9, 32, 46, 57, 102, 110, 0, &
- 10, 37, 48, 73, 94, 105, 0, &
- 3, 21, 59, 80, 99, 102, 0, &
- 1, 39, 49, 74, 100, 0, 0, &
- 5, 35, 43, 77, 87, 103, 0, &
- 17, 28, 60, 74, 83, 106, 0, &
- 2, 40, 54, 72, 99, 0, 0, &
- 18, 40, 48, 79, 90, 113, 0, &
- 11, 36, 53, 70, 100, 107, 0, &
- 11, 27, 59, 63, 101, 114, 119, &
- 6, 33, 46, 61, 83, 116, 120, &
- 20, 28, 45, 66, 92, 118, 0, &
- 12, 38, 60, 62, 90, 0, 0, &
- 13, 36, 42, 69, 95, 109, 0, &
- 17, 35, 57, 65, 81, 104, 0, &
- 7, 25, 52, 71, 86, 109, 0/
-
-data nrw/ &
-6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, &
-6,6,6,6,6,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6, &
-6,6,6,6,6,6,6,5,6,6,5,6,6,7,7,6,5,6,6,6/
-
-ncw=3
-
-toc=0
-tov=0
-tanhtoc=0
-!write(*,*) llr
-! initialize messages to checks
-do j=1,M
- do i=1,nrw(j)
- toc(i,j)=llr((Nm(i,j)))
- enddo
-enddo
-
-ncnt=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
-
-! 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
-! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
- enddo
-!write(*,*) 'number of unsatisfied parity checks ',ncheck
- if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it
- niterations=iter
- codeword=cw(colorder+1)
- decoded=codeword(M+1:N)
- return
- endif
-
- if( iter.gt.0 ) 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. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then
- niterations=-1
- return
- 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
-niterations=-1
-return
-end subroutine bpdecode120
diff --git a/lib/fsk4hf/bpdecode168.f90 b/lib/fsk4hf/bpdecode168.f90
deleted file mode 100644
index d527f71d..00000000
--- a/lib/fsk4hf/bpdecode168.f90
+++ /dev/null
@@ -1,380 +0,0 @@
-subroutine bpdecode168(llr,apmask,maxiterations,decoded,niterations)
-!
-! A log-domain belief propagation decoder for the (168,84) code.
-!
-integer, parameter:: N=168, K=84, M=N-K
-integer*1 codeword(N),cw(N),apmask(N)
-integer colorder(N)
-integer*1 decoded(K)
-integer Nm(7,M) ! 5, 6, or 7 bits per check
-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)
-real llr(N)
-real Tmn
-integer nrw(M)
-
-data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, &
- 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, &
- 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, &
- 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, &
- 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, &
- 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, &
- 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, &
- 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/
-
-data Mn/ &
- 1,24,67, &
- 2,5,71, &
- 3,31,66, &
- 4,50,58, &
- 6,60,65, &
- 7,32,76, &
- 8,49,83, &
- 9,36,41, &
- 10,40,63, &
- 11,14,62, &
- 12,72,75, &
- 13,23,78, &
- 15,16,80, &
- 17,54,64, &
- 18,51,59, &
- 19,30,48, &
- 20,68,81, &
- 21,29,70, &
- 22,25,43, &
- 26,34,73, &
- 27,35,37, &
- 28,39,44, &
- 33,53,55, &
- 38,52,84, &
- 42,56,57, &
- 45,74,82, &
- 46,69,79, &
- 47,61,77, &
- 1,4,5, &
- 2,48,52, &
- 3,47,82, &
- 6,26,76, &
- 7,9,16, &
- 8,10,78, &
- 11,36,56, &
- 12,38,65, &
- 13,43,81, &
- 14,33,68, &
- 15,18,44, &
- 17,59,77, &
- 19,27,69, &
- 20,21,58, &
- 22,45,79, &
- 23,34,54, &
- 24,28,40, &
- 25,80,84, &
- 29,37,51, &
- 30,42,83, &
- 31,63,72, &
- 32,50,66, &
- 35,67,73, &
- 39,55,74, &
- 41,61,71, &
- 46,60,62, &
- 49,70,74, &
- 53,64,75, &
- 25,57,67, &
- 1,46,64, &
- 2,51,63, &
- 3,14,80, &
- 4,15,78, &
- 5,27,74, &
- 6,13,70, &
- 7,19,20, &
- 8,38,77, &
- 9,75,83, &
- 10,36,69, &
- 11,22,29, &
- 12,58,82, &
- 16,35,60, &
- 17,32,43, &
- 18,42,45, &
- 21,53,84, &
- 23,39,48, &
- 24,52,68, &
- 26,33,61, &
- 28,56,76, &
- 30,65,66, &
- 31,34,49, &
- 37,47,81, &
- 16,40,54, &
- 41,44,65, &
- 50,73,79, &
- 55,59,60, &
- 54,57,71, &
- 23,62,72, &
- 1,36,47, &
- 2,32,70, &
- 3,28,69, &
- 4,7,33, &
- 5,20,26, &
- 6,14,63, &
- 8,22,68, &
- 9,13,67, &
- 10,55,71, &
- 11,15,19, &
- 12,51,56, &
- 17,27,52, &
- 18,34,46, &
- 21,41,42, &
- 24,50,80, &
- 25,39,75, &
- 29,54,76, &
- 30,40,84, &
- 31,35,58, &
- 37,79,83, &
- 38,43,73, &
- 44,72,81, &
- 7,45,62, &
- 47,48,49, &
- 53,57,78, &
- 20,59,66, &
- 28,61,64, &
- 11,75,77, &
- 33,54,82, &
- 1,14,44, &
- 2,62,73, &
- 3,9,26, &
- 4,37,84, &
- 5,56,80, &
- 6,45,71, &
- 8,67,72, &
- 10,76,81, &
- 12,32,78, &
- 13,59,82, &
- 15,17,79, &
- 16,42,69, &
- 18,61,70, &
- 19,31,64, &
- 21,39,63, &
- 22,30,58, &
- 23,27,66, &
- 24,41,49, &
- 25,36,60, &
- 29,65,67, &
- 34,36,53, &
- 35,48,76, &
- 15,38,55, &
- 40,43,74, &
- 46,52,57, &
- 50,63,77, &
- 51,68,69, &
- 2,44,83, &
- 1,30,55, &
- 3,29,78, &
- 4,34,65, &
- 5,31,38, &
- 6,52,58, &
- 7,25,51, &
- 8,16,66, &
- 9,46,74, &
- 10,70,75, &
- 11,32,84, &
- 12,48,79, &
- 13,50,64, &
- 14,37,57, &
- 17,42,72, &
- 18,43,48, &
- 19,24,60, &
- 20,54,83, &
- 21,47,62, &
- 22,28,59, &
- 23,61,80, &
- 8,26,39, &
- 27,44,53, &
- 33,49,56, &
- 35,68,71, &
- 12,26,40/
-
-data Nm/ &
- 1,29,58,87,116,144,0,&
- 2,30,59,88,117,143,0,&
- 3,31,60,89,118,145,0,&
- 4,29,61,90,119,146,0,&
- 2,29,62,91,120,147,0,&
- 5,32,63,92,121,148,0,&
- 6,33,64,90,109,149,0,&
- 7,34,65,93,122,150,164,&
- 8,33,66,94,118,151,0,&
- 9,34,67,95,123,152,0,&
- 10,35,68,96,114,153,0,&
- 11,36,69,97,124,154,168,&
- 12,37,63,94,125,155,0,&
- 10,38,60,92,116,156,0,&
- 13,39,61,96,126,138,0,&
- 13,33,70,81,127,150,0,&
- 14,40,71,98,126,157,0,&
- 15,39,72,99,128,158,0,&
- 16,41,64,96,129,159,0,&
- 17,42,64,91,112,160,0,&
- 18,42,73,100,130,161,0,&
- 19,43,68,93,131,162,0,&
- 12,44,74,86,132,163,0,&
- 1,45,75,101,133,159,0,&
- 19,46,57,102,134,149,0,&
- 20,32,76,91,118,164,168,&
- 21,41,62,98,132,165,0,&
- 22,45,77,89,113,162,0,&
- 18,47,68,103,135,145,0,&
- 16,48,78,104,131,144,0,&
- 3,49,79,105,129,147,0,&
- 6,50,71,88,124,153,0,&
- 23,38,76,90,115,166,0,&
- 20,44,79,99,136,146,0,&
- 21,51,70,105,137,167,0,&
- 8,35,67,87,134,136,0,&
- 21,47,80,106,119,156,0,&
- 24,36,65,107,138,147,0,&
- 22,52,74,102,130,164,0,&
- 9,45,81,104,139,168,0,&
- 8,53,82,100,133,0,0,&
- 25,48,72,100,127,157,0,&
- 19,37,71,107,139,158,0,&
- 22,39,82,108,116,143,165,&
- 26,43,72,109,121,0,0,&
- 27,54,58,99,140,151,0,&
- 28,31,80,87,110,161,0,&
- 16,30,74,110,137,154,158,&
- 7,55,79,110,133,166,0,&
- 4,50,83,101,141,155,0,&
- 15,47,59,97,142,149,0,&
- 24,30,75,98,140,148,0,&
- 23,56,73,111,136,165,0,&
- 14,44,81,85,103,115,160,&
- 23,52,84,95,138,144,0,&
- 25,35,77,97,120,166,0,&
- 25,57,85,111,140,156,0,&
- 4,42,69,105,131,148,0,&
- 15,40,84,112,125,162,0,&
- 5,54,70,84,134,159,0,&
- 28,53,76,113,128,163,0,&
- 10,54,86,109,117,161,0,&
- 9,49,59,92,130,141,0,&
- 14,56,58,113,129,155,0,&
- 5,36,78,82,135,146,0,&
- 3,50,78,112,132,150,0,&
- 1,51,57,94,122,135,0,&
- 17,38,75,93,142,167,0,&
- 27,41,67,89,127,142,0,&
- 18,55,63,88,128,152,0,&
- 2,53,85,95,121,167,0,&
- 11,49,86,108,122,157,0,&
- 20,51,83,107,117,0,0,&
- 26,52,55,62,139,151,0,&
- 11,56,66,102,114,152,0,&
- 6,32,77,103,123,137,0,&
- 28,40,65,114,141,0,0,&
- 12,34,61,111,124,145,0,&
- 27,43,83,106,126,154,0,&
- 13,46,60,101,120,163,0,&
- 17,37,80,108,123,0,0,&
- 26,31,69,115,125,0,0,&
- 7,48,66,106,143,160,0,&
- 24,46,73,104,119,153,0/
-
-data nrw/ &
-6,6,6,6,6,6,6,7,6,6,6,7,6,6,6,6,6,6,6,6,6, &
-6,6,6,6,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,6, &
-6,7,5,6,6,7,6,6,6,6,6,7,6,6,6,6,6,6,6,6,6, &
-6,6,6,6,6,6,6,6,6,5,6,6,6,5,6,6,6,5,5,6,6/
-
-ncw=3
-
-toc=0
-tov=0
-tanhtoc=0
-!write(*,*) llr
-! initialize messages to checks
-do j=1,M
- do i=1,nrw(j)
- toc(i,j)=llr((Nm(i,j)))
- enddo
-enddo
-
-ncnt=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
-
-! 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
-! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
- enddo
-!write(*,*) 'number of unsatisfied parity checks ',ncheck
- if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it
- niterations=iter
- codeword=cw(colorder+1)
- decoded=codeword(M+1:N)
- return
- endif
-
- if( iter.gt.0 ) 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. 3 .and. iter .ge. 5 .and. ncheck .gt. 10) then
- niterations=-1
- return
- 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
-niterations=-1
-return
-end subroutine bpdecode168
diff --git a/lib/fsk4hf/bpdecode204.f90 b/lib/fsk4hf/bpdecode204.f90
deleted file mode 100644
index 160b51a9..00000000
--- a/lib/fsk4hf/bpdecode204.f90
+++ /dev/null
@@ -1,482 +0,0 @@
-subroutine bpdecode204(llr,apmask,maxiterations,decoded,cw,nharderror,iter)
-!
-! A log-domain belief propagation decoder for the (204,68) code.
-!
-integer, parameter:: N=204, K=68, M=N-K
-integer*1 codeword(N),cw(N),apmask(N)
-integer colorder(N)
-integer*1 decoded(K)
-integer Nm(6,M) ! 4, 5, or 6 bits per check
-integer Mn(3,N) ! 3 checks per bit
-integer synd(M)
-real tov(3,N)
-real toc(6,M)
-real tanhtoc(6,M)
-real zn(N)
-real llr(N)
-real Tmn
-integer nrw(M)
-
-data colorder/ &
- 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, &
- 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, &
- 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, &
- 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, &
- 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, &
- 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, &
- 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, &
- 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, &
- 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, &
- 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, &
- 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, &
- 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/
-
-data Mn/ &
- 1, 38, 107, &
- 2, 7, 114, &
- 3, 48, 106, &
- 4, 79, 94, &
- 5, 97, 108, &
- 6, 50, 122, &
- 8, 78, 134, &
- 9, 55, 65, &
- 10, 62, 100, &
- 11, 16, 99, &
- 12, 113, 119, &
- 13, 31, 125, &
- 14, 15, 127, &
- 17, 87, 103, &
- 18, 81, 98, &
- 19, 43, 77, &
- 20, 102, 130, &
- 21, 36, 111, &
- 22, 23, 60, &
- 24, 39, 112, &
- 25, 37, 42, &
- 26, 41, 51, &
- 27, 67, 70, &
- 28, 64, 136, &
- 29, 61, 68, &
- 30, 91, 124, &
- 32, 80, 121, &
- 33, 40, 117, &
- 34, 35, 90, &
- 44, 88, 93, &
- 45, 128, 133, &
- 46, 56, 69, &
- 47, 49, 52, &
- 53, 76, 131, &
- 54, 104, 116, &
- 57, 84, 86, &
- 58, 120, 135, &
- 59, 75, 92, &
- 63, 71, 109, &
- 66, 74, 126, &
- 72, 85, 105, &
- 73, 82, 95, &
- 83, 89, 123, &
- 96, 115, 118, &
- 101, 110, 129, &
- 52, 99, 132, &
- 1, 3, 20, &
- 2, 77, 89, &
- 4, 72, 75, &
- 5, 34, 79, &
- 6, 24, 130, &
- 7, 48, 88, &
- 8, 36, 116, &
- 9, 71, 114, &
- 10, 87, 101, &
- 11, 22, 121, &
- 12, 50, 64, &
- 13, 39, 53, &
- 14, 41, 78, &
- 15, 68, 96, &
- 16, 83, 90, &
- 17, 23, 45, &
- 18, 47, 126, &
- 19, 70, 91, &
- 21, 57, 76, &
- 25, 110, 117, &
- 26, 82, 135, &
- 27, 46, 58, &
- 28, 37, 56, &
- 29, 66, 102, &
- 30, 62, 125, &
- 31, 85, 93, &
- 32, 104, 113, &
- 33, 81, 92, &
- 35, 100, 118, &
- 38, 95, 133, &
- 40, 86, 109, &
- 42, 61, 124, &
- 43, 59, 119, &
- 44, 49, 134, &
- 51, 97, 122, &
- 54, 105, 107, &
- 55, 128, 136, &
- 60, 67, 84, &
- 63, 112, 115, &
- 65, 74, 131, &
- 69, 80, 94, &
- 73, 98, 123, &
- 103, 130, 134, &
- 46, 106, 111, &
- 1, 84, 108, &
- 120, 129, 132, &
- 65, 75, 127, &
- 2, 80, 101, &
- 3, 118, 119, &
- 4, 52, 124, &
- 5, 13, 68, &
- 6, 27, 81, &
- 7, 51, 76, &
- 8, 77, 108, &
- 9, 31, 58, &
- 10, 18, 57, &
- 11, 63, 105, &
- 12, 14, 132, &
- 15, 56, 123, &
- 16, 21, 128, &
- 17, 37, 59, &
- 19, 85, 126, &
- 20, 71, 91, &
- 22, 26, 117, &
- 23, 79, 98, &
- 24, 32, 95, &
- 25, 90, 93, &
- 28, 49, 109, &
- 29, 116, 120, &
- 30, 54, 136, &
- 33, 53, 107, &
- 34, 64, 103, &
- 35, 39, 67, &
- 36, 71, 73, &
- 38, 47, 125, &
- 40, 66, 94, &
- 41, 70, 104, &
- 42, 55, 112, &
- 43, 44, 82, &
- 29, 45, 88, &
- 48, 86, 127, &
- 50, 72, 135, &
- 60, 74, 96, &
- 61, 121, 131, &
- 62, 78, 92, &
- 69, 100, 133, &
- 83, 122, 129, &
- 87, 97, 106, &
- 89, 102, 113, &
- 24, 99, 108, &
- 20, 72, 110, &
- 111, 115, 117, &
- 35, 52, 114, &
- 1, 44, 94, &
- 2, 23, 107, &
- 3, 81, 136, &
- 4, 8, 96, &
- 5, 37, 70, &
- 6, 43, 131, &
- 7, 103, 115, &
- 9, 94, 122, &
- 10, 68, 82, &
- 11, 56, 88, &
- 12, 46, 126, &
- 13, 16, 75, &
- 14, 79, 112, &
- 15, 47, 110, &
- 17, 36, 39, &
- 18, 63, 120, &
- 19, 22, 55, &
- 21, 49, 113, &
- 25, 54, 57, &
- 26, 89, 125, &
- 27, 101, 109, &
- 28, 31, 60, &
- 30, 74, 97, &
- 32, 92, 93, &
- 33, 83, 91, &
- 34, 58, 121, &
- 38, 65, 111, &
- 40, 99, 118, &
- 3, 41, 61, &
- 42, 50, 100, &
- 45, 78, 106, &
- 48, 95, 129, &
- 51, 85, 133, &
- 53, 59, 69, &
- 11, 62, 66, &
- 64, 73, 124, &
- 67, 123, 134, &
- 76, 104, 132, &
- 77, 100, 127, &
- 36, 80, 119, &
- 84, 102, 135, &
- 86, 105, 124, &
- 4, 87, 128, &
- 90, 106, 116, &
- 65, 98, 130, &
- 92, 108, 114, &
- 1, 52, 121, &
- 2, 84, 117, &
- 5, 83, 105, &
- 6, 15, 63, &
- 7, 28, 82, &
- 8, 32, 135, &
- 9, 104, 134, &
- 9, 10, 89, &
- 12, 62, 107, &
- 13, 40, 103, &
- 14, 31, 95, &
- 16, 27, 74, &
- 17, 90, 132, &
- 18, 34, 69, &
- 19, 103, 129, &
- 20, 76, 87, &
- 21, 22, 130, &
- 23, 25, 99, &
- 24, 101, 126/
-
-data Nm/ &
- 1, 47, 91, 140, 186, 0, &
- 2, 48, 94, 141, 187, 0, &
- 3, 47, 95, 142, 168, 0, &
- 4, 49, 96, 143, 182, 0, &
- 5, 50, 97, 144, 188, 0, &
- 6, 51, 98, 145, 189, 0, &
- 2, 52, 99, 146, 190, 0, &
- 7, 53, 100, 143, 191, 0, &
- 8, 54, 101, 147, 192, 193, &
- 9, 55, 102, 148, 193, 0, &
- 10, 56, 103, 149, 174, 0, &
- 11, 57, 104, 150, 194, 0, &
- 12, 58, 97, 151, 195, 0, &
- 13, 59, 104, 152, 196, 0, &
- 13, 60, 105, 153, 189, 0, &
- 10, 61, 106, 151, 197, 0, &
- 14, 62, 107, 154, 198, 0, &
- 15, 63, 102, 155, 199, 0, &
- 16, 64, 108, 156, 200, 0, &
- 17, 47, 109, 137, 201, 0, &
- 18, 65, 106, 157, 202, 0, &
- 19, 56, 110, 156, 202, 0, &
- 19, 62, 111, 141, 203, 0, &
- 20, 51, 112, 136, 204, 0, &
- 21, 66, 113, 158, 203, 0, &
- 22, 67, 110, 159, 0, 0, &
- 23, 68, 98, 160, 197, 0, &
- 24, 69, 114, 161, 190, 0, &
- 25, 70, 115, 126, 0, 0, &
- 26, 71, 116, 162, 0, 0, &
- 12, 72, 101, 161, 196, 0, &
- 27, 73, 112, 163, 191, 0, &
- 28, 74, 117, 164, 0, 0, &
- 29, 50, 118, 165, 199, 0, &
- 29, 75, 119, 139, 0, 0, &
- 18, 53, 120, 154, 179, 0, &
- 21, 69, 107, 144, 0, 0, &
- 1, 76, 121, 166, 0, 0, &
- 20, 58, 119, 154, 0, 0, &
- 28, 77, 122, 167, 195, 0, &
- 22, 59, 123, 168, 0, 0, &
- 21, 78, 124, 169, 0, 0, &
- 16, 79, 125, 145, 0, 0, &
- 30, 80, 125, 140, 0, 0, &
- 31, 62, 126, 170, 0, 0, &
- 32, 68, 90, 150, 0, 0, &
- 33, 63, 121, 153, 0, 0, &
- 3, 52, 127, 171, 0, 0, &
- 33, 80, 114, 157, 0, 0, &
- 6, 57, 128, 169, 0, 0, &
- 22, 81, 99, 172, 0, 0, &
- 33, 46, 96, 139, 186, 0, &
- 34, 58, 117, 173, 0, 0, &
- 35, 82, 116, 158, 0, 0, &
- 8, 83, 124, 156, 0, 0, &
- 32, 69, 105, 149, 0, 0, &
- 36, 65, 102, 158, 0, 0, &
- 37, 68, 101, 165, 0, 0, &
- 38, 79, 107, 173, 0, 0, &
- 19, 84, 129, 161, 0, 0, &
- 25, 78, 130, 168, 0, 0, &
- 9, 71, 131, 174, 194, 0, &
- 39, 85, 103, 155, 189, 0, &
- 24, 57, 118, 175, 0, 0, &
- 8, 86, 93, 166, 184, 0, &
- 40, 70, 122, 174, 0, 0, &
- 23, 84, 119, 176, 0, 0, &
- 25, 60, 97, 148, 0, 0, &
- 32, 87, 132, 173, 199, 0, &
- 23, 64, 123, 144, 0, 0, &
- 39, 54, 109, 120, 0, 0, &
- 41, 49, 128, 137, 0, 0, &
- 42, 88, 120, 175, 0, 0, &
- 40, 86, 129, 162, 197, 0, &
- 38, 49, 93, 151, 0, 0, &
- 34, 65, 99, 177, 201, 0, &
- 16, 48, 100, 178, 0, 0, &
- 7, 59, 131, 170, 0, 0, &
- 4, 50, 111, 152, 0, 0, &
- 27, 87, 94, 179, 0, 0, &
- 15, 74, 98, 142, 0, 0, &
- 42, 67, 125, 148, 190, 0, &
- 43, 61, 133, 164, 188, 0, &
- 36, 84, 91, 180, 187, 0, &
- 41, 72, 108, 172, 0, 0, &
- 36, 77, 127, 181, 0, 0, &
- 14, 55, 134, 182, 201, 0, &
- 30, 52, 126, 149, 0, 0, &
- 43, 48, 135, 159, 193, 0, &
- 29, 61, 113, 183, 198, 0, &
- 26, 64, 109, 164, 0, 0, &
- 38, 74, 131, 163, 185, 0, &
- 30, 72, 113, 163, 0, 0, &
- 4, 87, 122, 140, 147, 0, &
- 42, 76, 112, 171, 196, 0, &
- 44, 60, 129, 143, 0, 0, &
- 5, 81, 134, 162, 0, 0, &
- 15, 88, 111, 184, 0, 0, &
- 10, 46, 136, 167, 203, 0, &
- 9, 75, 132, 169, 178, 0, &
- 45, 55, 94, 160, 204, 0, &
- 17, 70, 135, 180, 0, 0, &
- 14, 89, 118, 146, 195, 200, &
- 35, 73, 123, 177, 192, 0, &
- 41, 82, 103, 181, 188, 0, &
- 3, 90, 134, 170, 183, 0, &
- 1, 82, 117, 141, 194, 0, &
- 5, 91, 100, 136, 185, 0, &
- 39, 77, 114, 160, 0, 0, &
- 45, 66, 137, 153, 0, 0, &
- 18, 90, 138, 166, 0, 0, &
- 20, 85, 124, 152, 0, 0, &
- 11, 73, 135, 157, 0, 0, &
- 2, 54, 139, 185, 0, 0, &
- 44, 85, 138, 146, 0, 0, &
- 35, 53, 115, 183, 0, 0, &
- 28, 66, 110, 138, 187, 0, &
- 44, 75, 95, 167, 0, 0, &
- 11, 79, 95, 179, 0, 0, &
- 37, 92, 115, 155, 0, 0, &
- 27, 56, 130, 165, 186, 0, &
- 6, 81, 133, 147, 0, 0, &
- 43, 88, 105, 176, 0, 0, &
- 26, 78, 96, 175, 181, 0, &
- 12, 71, 121, 159, 0, 0, &
- 40, 63, 108, 150, 204, 0, &
- 13, 93, 127, 178, 0, 0, &
- 31, 83, 106, 182, 0, 0, &
- 45, 92, 133, 171, 200, 0, &
- 17, 51, 89, 184, 202, 0, &
- 34, 86, 130, 145, 0, 0, &
- 46, 92, 104, 177, 198, 0, &
- 31, 76, 132, 172, 0, 0, &
- 7, 80, 89, 176, 192, 0, &
- 37, 67, 128, 180, 191, 0, &
- 24, 83, 116, 142, 0, 0/
-
-data nrw/ &
- 5,5,5,5,5,5,5,5,6,5,5,5,5,5,5,5,5, &
- 5,5,5,5,5,5,5,5,4,5,5,4,4,5,5,4,5, &
- 4,5,4,4,4,5,4,4,4,4,4,4,4,4,4,4,4, &
- 5,4,4,4,4,4,4,4,4,4,5,5,4,5,4,4,4, &
- 5,4,4,4,4,5,4,5,4,4,4,4,4,5,5,5,4, &
- 4,5,4,5,5,4,5,4,5,5,4,4,4,5,5,5,4, &
- 6,5,5,5,5,5,4,4,4,4,4,4,4,4,5,4,4, &
- 4,5,4,4,5,4,5,4,4,5,5,4,5,4,5,5,4/
-
-ncw=3
-
-decoded=0
-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
-
-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
-
-! 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
-! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
- enddo
-! write(*,*) 'number of unsatisfied parity checks ',ncheck
- if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it
- codeword=cw(colorder+1)
- decoded=codeword(M+1:N)
- nerr=0
- do i=1,N
- if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1
- enddo
- nharderror=nerr
- return
- 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
- return
- 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:6,i)=tanh(-toc(1:6,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
-nharderror=-1
-return
-end subroutine bpdecode204
diff --git a/lib/fsk4hf/bpdecode300.f90 b/lib/fsk4hf/bpdecode300.f90
deleted file mode 100644
index 22f7f885..00000000
--- a/lib/fsk4hf/bpdecode300.f90
+++ /dev/null
@@ -1,708 +0,0 @@
-subroutine bpdecode300(llr,apmask,maxiterations,decoded,niterations,cw)
-
-! A log-domain belief propagation decoder for the (300,60) code.
-
-integer, parameter:: N=300, K=60, M=N-K
-integer*1 codeword(N),cw(N),apmask(N)
-integer colorder(N)
-integer*1 decoded(K)
-integer Nm(5,M) ! 4, or 5 bits per check
-integer Mn(7,N) ! 2, 3, or 7 checks per bit
-integer synd(M)
-real tov(7,N)
-real toc(5,M)
-real tanhtoc(5,M)
-real zn(N)
-real llr(N)
-real Tmn
-integer nrw(M)
-integer ncw(N)
-
-data colorder/ &
-0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, &
-19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, &
-37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, &
-125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, &
-181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, &
-79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, &
-88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, &
-132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, &
-205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, &
-206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, &
-200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, &
-118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, &
-240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, &
-260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, &
-280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/
-
-data Mn/ &
- 1, 67, 0, 0, 0, 0, 0, &
- 2, 189, 0, 0, 0, 0, 0, &
- 3, 201, 0, 0, 0, 0, 0, &
- 4, 13, 0, 0, 0, 0, 0, &
- 5, 84, 0, 0, 0, 0, 0, &
- 6, 188, 0, 0, 0, 0, 0, &
- 7, 140, 0, 0, 0, 0, 0, &
- 8, 167, 0, 0, 0, 0, 0, &
- 9, 187, 0, 0, 0, 0, 0, &
- 10, 173, 0, 0, 0, 0, 0, &
- 11, 88, 0, 0, 0, 0, 0, &
- 12, 213, 0, 0, 0, 0, 0, &
- 14, 141, 0, 0, 0, 0, 0, &
- 15, 236, 0, 0, 0, 0, 0, &
- 16, 117, 0, 0, 0, 0, 0, &
- 17, 99, 0, 0, 0, 0, 0, &
- 18, 111, 0, 0, 0, 0, 0, &
- 19, 178, 0, 0, 0, 0, 0, &
- 20, 28, 0, 0, 0, 0, 0, &
- 21, 177, 0, 0, 0, 0, 0, &
- 22, 199, 0, 0, 0, 0, 0, &
- 23, 209, 0, 0, 0, 0, 0, &
- 24, 220, 0, 0, 0, 0, 0, &
- 25, 59, 0, 0, 0, 0, 0, &
- 26, 224, 0, 0, 0, 0, 0, &
- 27, 30, 0, 0, 0, 0, 0, &
- 29, 157, 0, 0, 0, 0, 0, &
- 31, 184, 0, 0, 0, 0, 0, &
- 32, 179, 0, 0, 0, 0, 0, &
- 33, 149, 0, 0, 0, 0, 0, &
- 34, 144, 0, 0, 0, 0, 0, &
- 35, 80, 0, 0, 0, 0, 0, &
- 36, 228, 0, 0, 0, 0, 0, &
- 37, 185, 0, 0, 0, 0, 0, &
- 38, 197, 0, 0, 0, 0, 0, &
- 39, 69, 0, 0, 0, 0, 0, &
- 40, 42, 0, 0, 0, 0, 0, &
- 41, 112, 0, 0, 0, 0, 0, &
- 43, 70, 0, 0, 0, 0, 0, &
- 44, 198, 0, 0, 0, 0, 0, &
- 45, 76, 0, 0, 0, 0, 0, &
- 46, 68, 0, 0, 0, 0, 0, &
- 47, 90, 0, 0, 0, 0, 0, &
- 48, 75, 0, 0, 0, 0, 0, &
- 49, 118, 0, 0, 0, 0, 0, &
- 50, 125, 0, 0, 0, 0, 0, &
- 51, 114, 0, 0, 0, 0, 0, &
- 52, 239, 0, 0, 0, 0, 0, &
- 53, 108, 0, 0, 0, 0, 0, &
- 54, 120, 0, 0, 0, 0, 0, &
- 55, 162, 0, 0, 0, 0, 0, &
- 56, 218, 0, 0, 0, 0, 0, &
- 57, 138, 0, 0, 0, 0, 0, &
- 58, 212, 0, 0, 0, 0, 0, &
- 60, 207, 0, 0, 0, 0, 0, &
- 61, 71, 0, 0, 0, 0, 0, &
- 62, 65, 0, 0, 0, 0, 0, &
- 63, 161, 0, 0, 0, 0, 0, &
- 64, 166, 0, 0, 0, 0, 0, &
- 66, 158, 0, 0, 0, 0, 0, &
- 72, 235, 0, 0, 0, 0, 0, &
- 73, 225, 0, 0, 0, 0, 0, &
- 74, 116, 0, 0, 0, 0, 0, &
- 77, 96, 0, 0, 0, 0, 0, &
- 78, 81, 0, 0, 0, 0, 0, &
- 79, 82, 0, 0, 0, 0, 0, &
- 83, 229, 0, 0, 0, 0, 0, &
- 85, 134, 0, 0, 0, 0, 0, &
- 86, 176, 0, 0, 0, 0, 0, &
- 87, 203, 0, 0, 0, 0, 0, &
- 89, 145, 0, 0, 0, 0, 0, &
- 91, 152, 0, 0, 0, 0, 0, &
- 92, 237, 0, 0, 0, 0, 0, &
- 93, 215, 0, 0, 0, 0, 0, &
- 94, 130, 0, 0, 0, 0, 0, &
- 95, 156, 0, 0, 0, 0, 0, &
- 97, 104, 0, 0, 0, 0, 0, &
- 98, 182, 0, 0, 0, 0, 0, &
- 100, 222, 0, 0, 0, 0, 0, &
- 101, 123, 0, 0, 0, 0, 0, &
- 102, 181, 0, 0, 0, 0, 0, &
- 103, 135, 0, 0, 0, 0, 0, &
- 105, 146, 0, 0, 0, 0, 0, &
- 106, 115, 0, 0, 0, 0, 0, &
- 107, 109, 0, 0, 0, 0, 0, &
- 110, 194, 0, 0, 0, 0, 0, &
- 113, 164, 0, 0, 0, 0, 0, &
- 119, 172, 0, 0, 0, 0, 0, &
- 121, 190, 0, 0, 0, 0, 0, &
- 122, 169, 0, 0, 0, 0, 0, &
- 124, 211, 0, 0, 0, 0, 0, &
- 126, 165, 0, 0, 0, 0, 0, &
- 127, 139, 0, 0, 0, 0, 0, &
- 128, 129, 0, 0, 0, 0, 0, &
- 131, 205, 0, 0, 0, 0, 0, &
- 132, 196, 0, 0, 0, 0, 0, &
- 133, 193, 0, 0, 0, 0, 0, &
- 136, 200, 0, 0, 0, 0, 0, &
- 137, 159, 0, 0, 0, 0, 0, &
- 142, 204, 0, 0, 0, 0, 0, &
- 143, 154, 0, 0, 0, 0, 0, &
- 147, 238, 0, 0, 0, 0, 0, &
- 148, 175, 0, 0, 0, 0, 0, &
- 150, 216, 0, 0, 0, 0, 0, &
- 151, 171, 0, 0, 0, 0, 0, &
- 153, 231, 0, 0, 0, 0, 0, &
- 155, 208, 0, 0, 0, 0, 0, &
- 160, 230, 0, 0, 0, 0, 0, &
- 163, 223, 0, 0, 0, 0, 0, &
- 168, 217, 0, 0, 0, 0, 0, &
- 170, 180, 0, 0, 0, 0, 0, &
- 174, 233, 0, 0, 0, 0, 0, &
- 183, 202, 0, 0, 0, 0, 0, &
- 186, 214, 0, 0, 0, 0, 0, &
- 191, 206, 0, 0, 0, 0, 0, &
- 192, 219, 0, 0, 0, 0, 0, &
- 195, 227, 0, 0, 0, 0, 0, &
- 210, 226, 0, 0, 0, 0, 0, &
- 221, 234, 0, 0, 0, 0, 0, &
- 232, 240, 0, 0, 0, 0, 0, &
- 1, 106, 0, 0, 0, 0, 0, &
- 2, 119, 0, 0, 0, 0, 0, &
- 3, 139, 0, 0, 0, 0, 0, &
- 4, 14, 0, 0, 0, 0, 0, &
- 5, 65, 0, 0, 0, 0, 0, &
- 6, 61, 0, 0, 0, 0, 0, &
- 7, 223, 0, 0, 0, 0, 0, &
- 8, 171, 0, 0, 0, 0, 0, &
- 9, 136, 0, 0, 0, 0, 0, &
- 10, 113, 0, 0, 0, 0, 0, &
- 11, 104, 0, 0, 0, 0, 0, &
- 12, 175, 0, 0, 0, 0, 0, &
- 13, 203, 0, 0, 0, 0, 0, &
- 15, 149, 0, 0, 0, 0, 0, &
- 16, 226, 0, 0, 0, 0, 0, &
- 17, 219, 0, 0, 0, 0, 0, &
- 18, 98, 0, 0, 0, 0, 0, &
- 19, 211, 0, 0, 0, 0, 0, &
- 20, 49, 0, 0, 0, 0, 0, &
- 21, 214, 0, 0, 0, 0, 0, &
- 22, 68, 0, 0, 0, 0, 0, &
- 23, 77, 0, 0, 0, 0, 0, &
- 24, 116, 0, 0, 0, 0, 0, &
- 25, 235, 0, 0, 0, 0, 0, &
- 26, 50, 0, 0, 0, 0, 0, &
- 27, 124, 0, 0, 0, 0, 0, &
- 28, 229, 0, 0, 0, 0, 0, &
- 29, 83, 0, 0, 0, 0, 0, &
- 30, 158, 0, 0, 0, 0, 0, &
- 31, 220, 0, 0, 0, 0, 0, &
- 32, 155, 0, 0, 0, 0, 0, &
- 33, 152, 0, 0, 0, 0, 0, &
- 34, 231, 0, 0, 0, 0, 0, &
- 35, 207, 0, 0, 0, 0, 0, &
- 36, 40, 0, 0, 0, 0, 0, &
- 37, 142, 0, 0, 0, 0, 0, &
- 38, 75, 0, 0, 0, 0, 0, &
- 39, 90, 167, 0, 0, 0, 0, &
- 41, 55, 125, 0, 0, 0, 0, &
- 42, 153, 196, 0, 0, 0, 0, &
- 43, 72, 112, 0, 0, 0, 0, &
- 44, 183, 233, 0, 0, 0, 0, &
- 45, 81, 178, 0, 0, 0, 0, &
- 46, 187, 230, 0, 0, 0, 0, &
- 47, 133, 176, 0, 0, 0, 0, &
- 48, 54, 186, 0, 0, 0, 0, &
- 51, 150, 224, 0, 0, 0, 0, &
- 52, 53, 190, 0, 0, 0, 0, &
- 56, 143, 228, 0, 0, 0, 0, &
- 57, 97, 197, 0, 0, 0, 0, &
- 58, 62, 89, 0, 0, 0, 0, &
- 59, 174, 194, 0, 0, 0, 0, &
- 60, 91, 93, 0, 0, 0, 0, &
- 63, 85, 96, 0, 0, 0, 0, &
- 64, 92, 205, 0, 0, 0, 0, &
- 66, 67, 164, 0, 0, 0, 0, &
- 69, 103, 159, 0, 0, 0, 0, &
- 70, 117, 122, 0, 0, 0, 0, &
- 71, 88, 160, 0, 0, 0, 0, &
- 73, 148, 180, 0, 0, 0, 0, &
- 74, 108, 109, 0, 0, 0, 0, &
- 76, 102, 151, 0, 0, 0, 0, &
- 78, 128, 206, 0, 0, 0, 0, &
- 79, 215, 239, 0, 0, 0, 0, &
- 80, 138, 221, 0, 0, 0, 0, &
- 82, 162, 195, 0, 0, 0, 0, &
- 84, 161, 184, 0, 0, 0, 0, &
- 86, 213, 218, 0, 0, 0, 0, &
- 87, 120, 240, 0, 0, 0, 0, &
- 94, 100, 157, 0, 0, 0, 0, &
- 95, 202, 217, 0, 0, 0, 0, &
- 99, 199, 201, 0, 0, 0, 0, &
- 101, 127, 225, 0, 0, 0, 0, &
- 105, 168, 185, 0, 0, 0, 0, &
- 107, 182, 237, 0, 0, 0, 0, &
- 110, 147, 208, 0, 0, 0, 0, &
- 111, 118, 172, 0, 0, 0, 0, &
- 114, 140, 165, 0, 0, 0, 0, &
- 115, 130, 141, 0, 0, 0, 0, &
- 121, 144, 173, 0, 0, 0, 0, &
- 123, 204, 209, 0, 0, 0, 0, &
- 126, 137, 188, 0, 0, 0, 0, &
- 129, 179, 189, 0, 0, 0, 0, &
- 131, 192, 210, 0, 0, 0, 0, &
- 132, 200, 238, 0, 0, 0, 0, &
- 134, 177, 191, 0, 0, 0, 0, &
- 135, 145, 222, 0, 0, 0, 0, &
- 146, 229, 236, 0, 0, 0, 0, &
- 154, 169, 232, 0, 0, 0, 0, &
- 124, 156, 163, 0, 0, 0, 0, &
- 166, 223, 234, 0, 0, 0, 0, &
- 1, 11, 170, 0, 0, 0, 0, &
- 3, 181, 227, 0, 0, 0, 0, &
- 193, 198, 220, 0, 0, 0, 0, &
- 10, 16, 212, 0, 0, 0, 0, &
- 42, 96, 216, 0, 0, 0, 0, &
- 2, 6, 215, 0, 0, 0, 0, &
- 4, 208, 219, 0, 0, 0, 0, &
- 5, 22, 35, 0, 0, 0, 0, &
- 7, 12, 20, 0, 0, 0, 0, &
- 8, 15, 75, 0, 0, 0, 0, &
- 9, 74, 83, 0, 0, 0, 0, &
- 13, 37, 50, 0, 0, 0, 0, &
- 14, 52, 86, 0, 0, 0, 0, &
- 17, 30, 177, 0, 0, 0, 0, &
- 18, 25, 97, 0, 0, 0, 0, &
- 19, 72, 157, 0, 0, 0, 0, &
- 21, 58, 116, 0, 0, 0, 0, &
- 23, 111, 226, 0, 0, 0, 0, &
- 24, 26, 180, 0, 0, 0, 0, &
- 27, 34, 39, 0, 0, 0, 0, &
- 28, 32, 161, 0, 0, 0, 0, &
- 29, 36, 60, 0, 0, 0, 0, &
- 31, 76, 154, 0, 0, 0, 0, &
- 33, 101, 238, 0, 0, 0, 0, &
- 38, 95, 162, 0, 0, 0, 0, &
- 40, 164, 183, 0, 0, 0, 0, &
- 41, 92, 196, 0, 0, 0, 0, &
- 43, 48, 99, 165, 190, 198, 204, &
- 44, 129, 138, 145, 160, 203, 237, &
- 45, 65, 66, 98, 127, 137, 146, &
- 46, 131, 149, 181, 211, 218, 224, &
- 47, 49, 55, 191, 194, 207, 232, &
- 51, 69, 106, 109, 119, 184, 217, &
- 53, 62, 104, 155, 166, 206, 231, &
- 54, 61, 63, 73, 118, 151, 163, &
- 56, 94, 110, 117, 185, 189, 214, &
- 57, 81, 91, 115, 173, 175, 227, &
- 59, 79, 103, 136, 171, 201, 212, &
- 24, 64, 77, 93, 202, 235, 236, &
- 67, 132, 142, 150, 156, 176, 222, &
- 68, 153, 159, 169, 170, 186, 221, &
- 70, 84, 89, 113, 174, 197, 205, &
- 71, 125, 130, 140, 158, 200, 210, &
- 8, 78, 143, 182, 192, 193, 216, &
- 23, 80, 82, 90, 108, 139, 228, &
- 85, 122, 123, 128, 141, 187, 188, &
- 25, 87, 100, 152, 209, 213, 234, &
- 88, 134, 147, 167, 172, 178, 239, &
- 18, 40, 102, 114, 133, 144, 179, &
- 4, 105, 108, 112, 148, 230, 240, &
- 29, 33, 50, 62, 107, 195, 199, &
- 3, 83, 113, 120, 126, 177, 216, &
- 11, 55, 116, 121, 135, 168, 225, &
- 1, 27, 28, 76, 187, 226, 233, &
- 2, 4, 7, 10, 22, 75, 222, &
- 5, 30, 131, 152, 156, 168, 215, &
- 6, 13, 19, 58, 196, 228, 229, &
- 9, 26, 144, 147, 158, 223, 240, &
- 12, 31, 66, 79, 92, 96, 155, &
- 14, 54, 103, 173, 202, 232, 238, &
- 15, 17, 37, 69, 129, 164, 209, &
- 16, 72, 91, 114, 163, 169, 237, &
- 20, 45, 89, 99, 143, 180, 208, &
- 21, 39, 60, 141, 171, 198, 234, &
- 21, 32, 52, 78, 95, 148, 199, &
- 34, 73, 84, 157, 200, 221, 236, &
- 35, 36, 63, 97, 105, 119, 220, &
- 38, 46, 93, 111, 136, 191, 203, &
- 41, 51, 151, 160, 213, 214, 231, &
- 42, 57, 65, 161, 167, 194, 204, &
- 43, 109, 162, 175, 189, 210, 212, &
- 44, 74, 100, 149, 170, 188, 197, &
- 47, 64, 88, 107, 122, 165, 211, &
- 48, 139, 179, 184, 218, 233, 239, &
- 49, 94, 106, 112, 138, 142, 205, &
- 53, 59, 102, 115, 134, 182, 225, &
- 56, 68, 101, 150, 166, 178, 207, &
- 61, 117, 126, 154, 195, 219, 224, &
- 67, 80, 118, 174, 185, 190, 235, &
- 70, 77, 86, 125, 153, 172, 193, &
- 32, 71, 87, 90, 98, 110, 135, &
- 41, 75, 81, 85, 124, 133, 201, &
- 82, 120, 128, 140, 159, 176, 183, &
- 22, 72, 104, 130, 146, 181, 217, &
- 25, 89, 96, 121, 132, 186, 230, &
- 118, 123, 145, 192, 196, 227, 240, &
- 1, 14, 35, 38, 114, 127, 192, &
- 7, 23, 43, 63, 116, 137, 206, &
- 2, 37, 52, 57, 64, 76, 120/
-
-data Nm/ &
- 1, 121, 212, 265, 298, &
- 2, 122, 217, 266, 300, &
- 3, 123, 213, 263, 0, &
- 4, 124, 218, 261, 266, &
- 5, 125, 219, 267, 0, &
- 6, 126, 217, 268, 0, &
- 7, 127, 220, 266, 299, &
- 8, 128, 221, 255, 0, &
- 9, 129, 222, 269, 0, &
- 10, 130, 215, 266, 0, &
- 11, 131, 212, 264, 0, &
- 12, 132, 220, 270, 0, &
- 4, 133, 223, 268, 0, &
- 13, 124, 224, 271, 298, &
- 14, 134, 221, 272, 0, &
- 15, 135, 215, 273, 0, &
- 16, 136, 225, 272, 0, &
- 17, 137, 226, 260, 0, &
- 18, 138, 227, 268, 0, &
- 19, 139, 220, 274, 0, &
- 20, 140, 228, 275, 276, &
- 21, 141, 219, 266, 295, &
- 22, 142, 229, 256, 299, &
- 23, 143, 230, 250, 0, &
- 24, 144, 226, 258, 296, &
- 25, 145, 230, 269, 0, &
- 26, 146, 231, 265, 0, &
- 19, 147, 232, 265, 0, &
- 27, 148, 233, 262, 0, &
- 26, 149, 225, 267, 0, &
- 28, 150, 234, 270, 0, &
- 29, 151, 232, 276, 292, &
- 30, 152, 235, 262, 0, &
- 31, 153, 231, 277, 0, &
- 32, 154, 219, 278, 298, &
- 33, 155, 233, 278, 0, &
- 34, 156, 223, 272, 300, &
- 35, 157, 236, 279, 298, &
- 36, 158, 231, 275, 0, &
- 37, 155, 237, 260, 0, &
- 38, 159, 238, 280, 293, &
- 37, 160, 216, 281, 0, &
- 39, 161, 239, 282, 299, &
- 40, 162, 240, 283, 0, &
- 41, 163, 241, 274, 0, &
- 42, 164, 242, 279, 0, &
- 43, 165, 243, 284, 0, &
- 44, 166, 239, 285, 0, &
- 45, 139, 243, 286, 0, &
- 46, 145, 223, 262, 0, &
- 47, 167, 244, 280, 0, &
- 48, 168, 224, 276, 300, &
- 49, 168, 245, 287, 0, &
- 50, 166, 246, 271, 0, &
- 51, 159, 243, 264, 0, &
- 52, 169, 247, 288, 0, &
- 53, 170, 248, 281, 300, &
- 54, 171, 228, 268, 0, &
- 24, 172, 249, 287, 0, &
- 55, 173, 233, 275, 0, &
- 56, 126, 246, 289, 0, &
- 57, 171, 245, 262, 0, &
- 58, 174, 246, 278, 299, &
- 59, 175, 250, 284, 300, &
- 57, 125, 241, 281, 0, &
- 60, 176, 241, 270, 0, &
- 1, 176, 251, 290, 0, &
- 42, 141, 252, 288, 0, &
- 36, 177, 244, 272, 0, &
- 39, 178, 253, 291, 0, &
- 56, 179, 254, 292, 0, &
- 61, 161, 227, 273, 295, &
- 62, 180, 246, 277, 0, &
- 63, 181, 222, 283, 0, &
- 44, 157, 221, 266, 293, &
- 41, 182, 234, 265, 300, &
- 64, 142, 250, 291, 0, &
- 65, 183, 255, 276, 0, &
- 66, 184, 249, 270, 0, &
- 32, 185, 256, 290, 0, &
- 65, 163, 248, 293, 0, &
- 66, 186, 256, 294, 0, &
- 67, 148, 222, 263, 0, &
- 5, 187, 253, 277, 0, &
- 68, 174, 257, 293, 0, &
- 69, 188, 224, 291, 0, &
- 70, 189, 258, 292, 0, &
- 11, 179, 259, 284, 0, &
- 71, 171, 253, 274, 296, &
- 43, 158, 256, 292, 0, &
- 72, 173, 248, 273, 0, &
- 73, 175, 238, 270, 0, &
- 74, 173, 250, 279, 0, &
- 75, 190, 247, 286, 0, &
- 76, 191, 236, 276, 0, &
- 64, 174, 216, 270, 296, &
- 77, 170, 226, 278, 0, &
- 78, 137, 241, 292, 0, &
- 16, 192, 239, 274, 0, &
- 79, 190, 258, 283, 0, &
- 80, 193, 235, 288, 0, &
- 81, 182, 260, 287, 0, &
- 82, 177, 249, 271, 0, &
- 77, 131, 245, 295, 0, &
- 83, 194, 261, 278, 0, &
- 84, 121, 244, 286, 0, &
- 85, 195, 262, 284, 0, &
- 49, 181, 256, 261, 0, &
- 85, 181, 244, 282, 0, &
- 86, 196, 247, 292, 0, &
- 17, 197, 229, 279, 0, &
- 38, 161, 261, 286, 0, &
- 87, 130, 253, 263, 0, &
- 47, 198, 260, 273, 298, &
- 84, 199, 248, 287, 0, &
- 63, 143, 228, 264, 299, &
- 15, 178, 247, 289, 0, &
- 45, 197, 246, 290, 297, &
- 88, 122, 244, 278, 0, &
- 50, 189, 263, 294, 300, &
- 89, 200, 264, 296, 0, &
- 90, 178, 257, 284, 0, &
- 80, 201, 257, 297, 0, &
- 91, 146, 210, 293, 0, &
- 46, 159, 254, 291, 0, &
- 92, 202, 263, 289, 0, &
- 93, 193, 241, 298, 0, &
- 94, 183, 257, 294, 0, &
- 94, 203, 240, 272, 0, &
- 75, 199, 254, 295, 0, &
- 95, 204, 242, 267, 0, &
- 96, 205, 251, 296, 0, &
- 97, 165, 260, 293, 0, &
- 68, 206, 259, 287, 0, &
- 82, 207, 264, 292, 0, &
- 98, 129, 249, 279, 0, &
- 99, 202, 241, 299, 0, &
- 53, 185, 240, 286, 0, &
- 93, 123, 256, 285, 0, &
- 7, 198, 254, 294, 0, &
- 13, 199, 257, 275, 0, &
- 100, 156, 251, 286, 0, &
- 101, 169, 255, 274, 0, &
- 31, 200, 260, 269, 0, &
- 71, 207, 240, 297, 0, &
- 83, 208, 241, 295, 0, &
- 102, 196, 259, 269, 0, &
- 103, 180, 261, 276, 0, &
- 30, 134, 242, 283, 0, &
- 104, 167, 251, 288, 0, &
- 105, 182, 246, 280, 0, &
- 72, 152, 258, 267, 0, &
- 106, 160, 252, 291, 0, &
- 101, 209, 234, 289, 0, &
- 107, 151, 245, 270, 0, &
- 76, 210, 251, 267, 0, &
- 27, 190, 227, 277, 0, &
- 60, 149, 254, 269, 0, &
- 99, 177, 252, 294, 0, &
- 108, 179, 240, 280, 0, &
- 58, 187, 232, 281, 0, &
- 51, 186, 236, 282, 0, &
- 109, 210, 246, 273, 0, &
- 87, 176, 237, 272, 0, &
- 92, 198, 239, 284, 0, &
- 59, 211, 245, 288, 0, &
- 8, 158, 259, 281, 0, &
- 110, 194, 264, 267, 0, &
- 90, 209, 252, 273, 0, &
- 111, 212, 252, 283, 0, &
- 105, 128, 249, 275, 0, &
- 88, 197, 259, 291, 0, &
- 10, 200, 248, 271, 0, &
- 112, 172, 253, 290, 0, &
- 103, 132, 248, 282, 0, &
- 69, 165, 251, 294, 0, &
- 20, 206, 225, 263, 0, &
- 18, 163, 259, 288, 0, &
- 29, 203, 260, 285, 0, &
- 111, 180, 230, 274, 0, &
- 81, 213, 242, 295, 0, &
- 78, 195, 255, 287, 0, &
- 113, 162, 237, 294, 0, &
- 28, 187, 244, 285, 0, &
- 34, 194, 247, 290, 0, &
- 114, 166, 252, 296, 0, &
- 9, 164, 257, 265, 0, &
- 6, 202, 257, 283, 0, &
- 2, 203, 247, 282, 0, &
- 89, 168, 239, 290, 0, &
- 115, 206, 243, 279, 0, &
- 116, 204, 255, 297, 298, &
- 97, 214, 255, 291, 0, &
- 86, 172, 243, 281, 0, &
- 117, 186, 262, 289, 0, &
- 96, 160, 238, 268, 297, &
- 35, 170, 253, 283, 0, &
- 40, 214, 239, 275, 0, &
- 21, 192, 262, 276, 0, &
- 98, 205, 254, 277, 0, &
- 3, 192, 249, 293, 0, &
- 113, 191, 250, 271, 0, &
- 70, 133, 240, 279, 0, &
- 100, 201, 239, 281, 0, &
- 95, 175, 253, 286, 0, &
- 115, 183, 245, 299, 0, &
- 55, 154, 243, 288, 0, &
- 107, 196, 218, 274, 0, &
- 22, 201, 258, 272, 0, &
- 118, 204, 254, 282, 0, &
- 91, 138, 242, 284, 0, &
- 54, 215, 249, 282, 0, &
- 12, 188, 258, 280, 0, &
- 114, 140, 247, 280, 0, &
- 74, 184, 217, 267, 0, &
- 104, 216, 255, 263, 0, &
- 110, 191, 244, 295, 0, &
- 52, 188, 242, 285, 0, &
- 116, 136, 218, 289, 0, &
- 23, 150, 214, 278, 0, &
- 119, 185, 252, 277, 0, &
- 79, 207, 251, 266, 0, &
- 109, 127, 211, 269, 0, &
- 25, 167, 242, 289, 0, &
- 62, 193, 264, 287, 0, &
- 118, 135, 229, 265, 0, &
- 117, 213, 248, 297, 0, &
- 33, 169, 256, 268, 0, &
- 67, 147, 208, 268, 0, &
- 108, 164, 261, 296, 0, &
- 106, 153, 245, 280, 0, &
- 120, 209, 243, 271, 0, &
- 112, 162, 265, 285, 0, &
- 119, 211, 258, 275, 0, &
- 61, 144, 250, 290, 0, &
- 14, 208, 250, 277, 0, &
- 73, 195, 240, 273, 0, &
- 102, 205, 235, 271, 0, &
- 48, 184, 259, 285, 0, &
- 120, 189, 261, 269, 297/
-
-data nrw/ &
-5,5,4,5,4,4,5,4,4,4,4,4,4,5,4,4,4,4,4,4, &
-5,5,5,4,5,4,4,4,4,4,4,5,4,4,5,4,5,5,4,4, &
-5,4,5,4,4,4,4,4,4,4,4,5,4,4,4,4,5,4,4,4, &
-4,4,5,5,4,4,4,4,4,4,4,5,4,4,5,5,4,4,4,4, &
-4,4,4,4,4,4,4,4,5,4,4,4,4,4,4,5,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,5,4,5,4,5,4,5, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,5,4,4,4,5,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, &
-4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5/
-
-data ncw/ &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, &
-2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, &
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, &
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, &
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, &
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,7, &
-7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, &
-7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, &
-7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7/
-
-!ncw=3
-
-toc=0
-tov=0
-tanhtoc=0
-!write(*,*) llr
-! initialize messages to checks
-do j=1,M
- do i=1,nrw(j)
- toc(i,j)=llr((Nm(i,j)))
- enddo
-enddo
-
-ncnt=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),i))
- else
- zn(i)=llr(i)
- endif
- enddo
-
-! 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
-! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
- enddo
-!write(*,*) 'number of unsatisfied parity checks ',ncheck
- if( ncheck .eq. 0 ) then ! we have a codeword - reorder the columns and return it
-! niterations=iter
- codeword=cw(colorder+1)
- decoded=codeword(M+1:N)
- nerr=0
- do i=1,N
- if( (2*cw(i)-1)*llr(i) .lt. 0.0 ) nerr=nerr+1
- enddo
- niterations=nerr
- return
- endif
-
- if( iter.gt.0 ) 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. 15 .and. ncheck .gt. 50) then
- niterations=-1
- return
- 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(ibj) ! subtract off what the bit had received from the check
- do kk=1,7 ! 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:5,i)=tanh(-toc(1:5,i)/2)
- enddo
-
- do j=1,N
- do i=1,ncw(j)
- 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
-niterations=-1
-return
-end subroutine bpdecode300
diff --git a/lib/fsk4hf/chkcrc10.f90 b/lib/fsk4hf/chkcrc10.f90
deleted file mode 100644
index abe7bd79..00000000
--- a/lib/fsk4hf/chkcrc10.f90
+++ /dev/null
@@ -1,27 +0,0 @@
-subroutine chkcrc10(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(60)
- integer*1, target:: i1Dec8BitBytes(9)
-
-! Check the CRC
- do ibyte=1,6
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
- i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64
-
-! Pack received CRC into bytes 8 and 9 for crc10_check
- i1Dec8BitBytes(8)=decoded(51)*2+decoded(52)
- i1Dec8BitBytes(9)=decoded(53)*128 + decoded(54)*64+decoded(55)*32 + &
- decoded(56)*16
- i1Dec8BitBytes(9)=i1Dec8BitBytes(9) + decoded(57)*8+decoded(58)*4 + &
- decoded(59)*2+decoded(60)*1
- nbadcrc=1
- if(crc10_check(c_loc(i1Dec8BitBytes),9)) nbadcrc=0
-
- return
-end subroutine chkcrc10
diff --git a/lib/fsk4hf/chkcrc12.f90 b/lib/fsk4hf/chkcrc12.f90
deleted file mode 100644
index a177fa11..00000000
--- a/lib/fsk4hf/chkcrc12.f90
+++ /dev/null
@@ -1,27 +0,0 @@
-subroutine chkcrc12(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(84)
- integer*1, target:: i1Dec8BitBytes(11)
-
-! Check the CRC
-! Collapse 84 decoded bits to 11 bytes. Bytes 1-9 are the message,
-! byte 10 and first half of byte 11 is the crc
- do ibyte=1,9
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
-
-! Pack the crc into bytes 10 and 11 for crc12_check
- i1Dec8BitBytes(10)=decoded(73)*8 + decoded(74)*4 + decoded(75)*2 + decoded(76)
- i1Dec8BitBytes(11)=decoded(77)*128 + decoded(78)*64 + &
- decoded(79)*32 + decoded(80)*16 + decoded(81)*8 + decoded(82)*4 + &
- decoded(83)*2 + decoded(84)
- nbadcrc=1
- if( crc12_check(c_loc (i1Dec8BitBytes), 11) ) nbadcrc=0
-
- return
-end subroutine chkcrc12
diff --git a/lib/fsk4hf/cpolyfit.f90 b/lib/fsk4hf/cpolyfit.f90
deleted file mode 100644
index fd0d5987..00000000
--- a/lib/fsk4hf/cpolyfit.f90
+++ /dev/null
@@ -1,76 +0,0 @@
-subroutine cpolyfit(c,pp,id,maxn,aa,bb,zz,nhardsync)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real x(NS),yi(NS),yq(NS) !For complex polyfit
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
-
- ib=NSPS-1
- ib2=N2-1
- n=0
- do j=1,117 !First-pass demodulation
- ia=ib+1
- ib=ia+N2-1
- zz(j)=sum(pp*c(ia:ib))/NSPS
- if(abs(id(j)).eq.2) then !Save all sync symbols
- n=n+1
- x(n)=float(ia+ib)/NZ - 1.0
- yi(n)=real(zz(j))*0.5*id(j)
- yq(n)=aimag(zz(j))*0.5*id(j)
-! write(54,1225) n,x(n),yi(n),yq(n)
-!1225 format(i5,3f12.4)
- endif
- if(j.le.116) then
- zz(j+117)=sum(pp*c(ia+NSPS:ib+NSPS))/NSPS
- endif
- enddo
-
- aa=0.
- bb=0.
- nterms=0
- chisqa=0.
- chisqb=0.
- if(maxn.gt.0) then
- npts=n
- mode=0
- nterms=maxn
- call polyfit4(x,yi,yi,npts,nterms,mode,aa,chisqa)
- call polyfit4(x,yq,yq,npts,nterms,mode,bb,chisqb)
- endif
-
- nhardsync=0
- do j=1,117
- if(abs(id(j)).ne.2) cycle
- xx=j*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(p*id(j).lt.0) nhardsync=nhardsync+1
- enddo
-
- return
-end subroutine cpolyfit
diff --git a/lib/fsk4hf/cpolyfitw.f90 b/lib/fsk4hf/cpolyfitw.f90
deleted file mode 100644
index 561052f8..00000000
--- a/lib/fsk4hf/cpolyfitw.f90
+++ /dev/null
@@ -1,68 +0,0 @@
-subroutine cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhardsync)
-
- include 'wsprlf_params.f90'
-
- complex c(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real x(NS),yi(NS),yq(NS) !For complex polyfit
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
-
- ib=NSPS-1
- ib2=N2-1
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz !First-pass demodulation
- ia=ib+1
- ib=ia+N2-1
- zz(j)=sum(pp*c(ia:ib))/NSPS
- if(abs(id(j)).eq.2) then !Save all sync symbols
- n=n+1
- x(n)=float(ia+ib)/NZ - 1.0
- yi(n)=real(zz(j))*0.5*id(j)
- yq(n)=aimag(zz(j))*0.5*id(j)
-! write(54,1225) n,x(n),yi(n),yq(n)
-!1225 format(i5,3f12.4)
- endif
- if(j.lt.jz) then
- zz(j+jz)=sum(pp*c(ia+NSPS:ib+NSPS))/NSPS
- endif
- enddo
-
- aa=0.
- bb=0.
- nterms=0
- chisqa=0.
- chisqb=0.
- if(maxn.gt.0) then
- npts=n
- mode=0
- nterms=maxn
- call polyfit4(x,yi,yi,npts,nterms,mode,aa,chisqa)
- call polyfit4(x,yq,yq,npts,nterms,mode,bb,chisqb)
- endif
-
- nhardsync=0
- do j=1,205
- if(abs(id(j)).ne.2) cycle
- xx=j*2.0/205.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(p*id(j).lt.0) nhardsync=nhardsync+1
- enddo
-
- return
-end subroutine cpolyfitw
diff --git a/lib/fsk4hf/dbpsksim.f90 b/lib/fsk4hf/dbpsksim.f90
deleted file mode 100644
index 8b9ea12c..00000000
--- a/lib/fsk4hf/dbpsksim.f90
+++ /dev/null
@@ -1,241 +0,0 @@
-program dbpsksim
-
- parameter (ND=121) !Data symbols: LDPC (120,60), r=1/2
- parameter (NN=ND) !Total symbols (121)
- parameter (NSPS=28800) !Samples per symbol at 12000 sps
- parameter (NZ=NSPS*NN) !Samples in waveform (3484800)
- parameter (NFFT1=65536,NH1=NFFT1/2)
- parameter (NFFT2=128,NH2=NFFT2/2)
-
- character*8 arg
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- complex cr(0:NZ-1)
- complex ct(0:NZ-1)
- complex cz(0:NFFT2-1)
- complex z0,z,zp
- real s(-NH1+1:NH1)
- real s2(-NH2+1:NH2)
- real xnoise(0:NZ-1) !Generated random noise
- real ynoise(0:NZ-1) !Generated random noise
- real rxdata(120),llr(120)
- integer id(NN) !Encoded NRZ data (values +/-1)
- integer id1(NN) !Recovered data (1st pass)
- integer id2(NN) !Recovered data (2nd pass)
-! integer icw(NN)
- integer*1 msgbits(60),decoded(60),codeword(120),apmask(120),cw(120)
- data msgbits/0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,&
- 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,0,1,0/
-
- nnn=0
- nargs=iargc()
- if(nargs.ne.6) then
- print*,'Usage: dbpsksim f0(Hz) delay(ms) fspread(Hz) ndiff iters snr(dB)'
- print*,'Example: dbpsksim 1500 0 0 10 -35'
- print*,'Set snr=0 to cycle through a range'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) f0 !Low tone frequency
- call getarg(2,arg)
- read(arg,*) delay
- call getarg(3,arg)
- read(arg,*) fspread
- call getarg(4,arg)
- read(arg,*) ndiff
- call getarg(5,arg)
- read(arg,*) iters
- call getarg(6,arg)
- read(arg,*) snrdb
-
- twopi=8.d0*atan(1.d0)
- fs=12000.d0
- dt=1.0/fs
- ts=NSPS*dt
- baud=1.d0/ts
- txt=NZ*dt
- bandwidth_ratio=2500.0/6000.0
- write(*,1000) baud,5*baud,txt,delay,fspread,ndiff
-1000 format('Baud:',f6.3,' BW:',f4.1,' TxT:',f6.1,' Delay:',f5.2, &
- ' fSpread:',f5.2,' ndiff:',i2/)
-
- write(*,1004)
-1004 format(' SNR err ber fer fsigma'/35('-'))
-
- call encode120(msgbits,codeword) !Encode the test message
- isna=-28
- isnb=-40
- if(snrdb.ne.0.0) then
- isna=nint(snrdb)
- isnb=isna
- endif
- do isnr=isna,isnb,-1
- snrdb=isnr
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- nhard=0
- nhardc=0
- nfe1=0
- nfe2=0
- sqf=0.
- do iter=1,iters
- nnn=nnn+1
- id(1)=1 !First bit is always 1
- id(2:NN)=2*codeword-1
- call genbpsk(id,f0,ndiff,0,c) !Generate the 4-FSK waveform
- if(delay.ne.0.0 .or. fspread.ne.0.0) call watterson(c,delay,fspread)
- c=sig*c !Scale to requested SNR
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Generate gaussian noise
- xnoise(i)=gran()
- ynoise(i)=gran()
- enddo
- c=c + cmplx(xnoise,ynoise) !Add noise to signal
- endif
-
-! First attempt at finding carrier frequency fc: 64k FFTs ==> avg power spectra
- nspec=NZ/NFFT1
- df1=12000.0/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*NSPS
- ib=ia+NSPS-1
- c2(0:NSPS-1)=c(ia:ib)
- c2(NSPS:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
- s=1.e-6*s
- smax=0.
- ipk=0
- ia=(1400.0)/df1
- ib=(1600.0)/df1
- do i=ia,ib
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc=f
- endif
- enddo
- a=(s(ipk+1)-s(ipk-1))/2.0
- b=(s(ipk+1)+s(ipk-1)-2.0*s(ipk))/2.0
- dx=-a/(2.0*b)
- fc=fc + df1*dx !Estimated carrier frequency
- sqf=sqf + (fc-f0)**2
-
-! The following is for testing SNR calibration:
-! sp5n=(s(ipk-2)+s(ipk-1)+s(ipk)+s(ipk+1)+s(ipk+2)) !Sig + 5*noise
-! base=(sum(s)-sp5n)/(NFFT1-5.0) !Noise per bin
-! psig=sp5n-5*base !Sig only
-! pnoise=(2500.0/df1)*base !Noise in 2500 Hz
-! xsnrdb=db(psig/pnoise)
-
- call genbpsk(id,fc,ndiff,1,cr) !Generate reference carrier
- c=c*conjg(cr) !Mix signal to baseband
-
- z0=1.0
- do j=1,NN !Demodulate
- ia=(j-1)*NSPS
- ib=ia+NSPS-1
- z=sum(c(ia:ib))
- cz(j-1)=z
- zp=z*conjg(z0)
- p=1.e-4*real(zp)
- id1(j)=-1
- if(p.ge.0.0) id1(j)=1
- if(j.ge.2) rxdata(j-1)=p
- z0=z
- enddo
-
- rxav=sum(rxdata)/120
- rx2av=sum(rxdata*rxdata)/120
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss)
- apmask=0
- max_iterations=10
- call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw)
-
-! Count frame errors
- if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0) nfe1=nfe1+1
-
-! Find carrier frequency from squared cz array.
- cz(121:)=0.
- cz=cz*cz
- call four2a(cz,NFFT2,1,-1,1)
- s2max=0.
- do i=0,NFFT2-1
- j=i
- if(i.gt.NH2) j=j-NFFT2
- s2(j)=real(cz(i))**2 + aimag(cz(i))**2
- if(s2(j).gt.s2max) then
- s2max=s2(j)
- jpk=j
- endif
-! write(16,1200) j*baud/NFFT2,1.e-12*s2(j)
-!1200 format(2f12.3)
- enddo
- a=(s2(jpk+1)-s2(jpk-1))/2.0
- b=(s2(jpk+1)+s2(jpk-1)-2.0*s2(jpk))/2.0
- dx=-a/(2.0*b)
- fc2=0.5*(jpk+dx)*baud/NFFT2
-
- call genbpsk(id,fc2,ndiff,1,cr) !Generate new ref carrier at fc2
- c=c*conjg(cr)
- z0=1.0
- do j=1,NN !Demodulate
- ia=(j-1)*NSPS
- ib=ia+NSPS-1
- z=sum(c(ia:ib))
- if(j.eq.1) z0=z
- zp=z*conjg(z0)
- p=1.e-4*real(zp)
- id2(j)=-1
- if(p.ge.0.0) id2(j)=1
- if(j.ge.2) rxdata(j-1)=p
- ierr=0
- if(id2(j).ne.id(j)) ierr=1
- id3=-1
- if(real(z).ge.0.0) id3=1
- if(j.ge.2 .and. id3.ne.id(j)) nhardc=nhardc+1
- if(j.ge.2 .and. ndiff.eq.0) rxdata(j-1)=real(z)
- z0=z
- enddo
- nhard=nhard + count(id2.ne.id) !Count hard errors
-
- rxav=sum(rxdata)/120
- rx2av=sum(rxdata*rxdata)/120
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss) !Soft symbols
- apmask=0
- max_iterations=10
- decoded=0
- call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw)
-! if(niterations.lt.0) then
-! llr=-llr
-! call bpdecode120(llr,apmask,max_iterations,decoded,niterations,cw)
-! if(niterations.ge.0) nhard=NN*iters-nhard
-! endif
- if(niterations.ge.0) call chkcrc10(decoded,nbadcrc)
- if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. &
- nbadcrc.ne.0) nfe2=nfe2+1
- enddo
-
- if(ndiff.eq.0) nhard=nhardc
- fsigma=sqrt(sqf/iters)
- ber=float(nhard)/(NN*iters)
- fer=float(nfe2)/iters
- write(*,1050) snrdb,nhard,ber,fer,fsigma
- write(14,1050) snrdb,nhard,ber,fer,fsigma
-1050 format(f6.1,i5,f8.4,f7.3,f8.2)
- enddo
-
-999 end program dbpsksim
diff --git a/lib/fsk4hf/dopspread.f90 b/lib/fsk4hf/dopspread.f90
deleted file mode 100644
index cadfbecc..00000000
--- a/lib/fsk4hf/dopspread.f90
+++ /dev/null
@@ -1,62 +0,0 @@
-subroutine dopspread(c,fspread)
-
- parameter (NFFT=268800,NH=NFFT/2)
- complex c(0:NFFT-1)
- complex cspread(0:NFFT-1)
-
- 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
-
- izh=fspread/df
- do i=-izh,izh
- f=i*df
- j=i
- if(j.lt.0) j=j+nfft
- s=real(cspread(j))**2 + aimag(cspread(j))**2
-! write(23,3000) f,s,cspread(j)
-!3000 format(f10.3,3f12.6)
- enddo
-
- 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
- c=cspread*c !Apply Rayleigh fading to c()
-
- do i=0,NFFT-1
- p=real(cspread(i))**2 + aimag(cspread(i))**2
-! write(24,3010) i,p,cspread(i)
-!3010 format(i8,3f12.6)
- enddo
-
- return
-end subroutine dopspread
diff --git a/lib/fsk4hf/encode120.f90 b/lib/fsk4hf/encode120.f90
deleted file mode 100644
index 577bbe86..00000000
--- a/lib/fsk4hf/encode120.f90
+++ /dev/null
@@ -1,116 +0,0 @@
-subroutine encode120(message,codeword)
-! Encode an 60-bit message and return a 120-bit codeword.
-! The generator matrix has dimensions (60,60).
-! The code is a (120,60) regular ldpc code with column weight 3.
-! The code was generated using the PEG algorithm.
-! After creating the codeword, the columns are re-ordered according to
-! "colorder" to make the codeword compatible with the parity-check matrix
-!
-character*15 g(60)
-integer*1 codeword(120)
-integer colorder(120)
-integer*1 gen(60,60)
-integer*1 itmp(120)
-integer*1 message(60)
-integer*1 pchecks(60)
-logical first
-data first/.true./
-data g/ &
- "65541ad98feab6e",&
- "27249940a5895a3",&
- "c80eac7506bf794",&
- "aa50393e3e18d3f",&
- "28527e87d47dced",&
- "5da0dcaf8db048c",&
- "d6509a43ca9b01a",&
- "9a7dadd9c94f1d4",&
- "bb673d3ba07cf29",&
- "65e190f2fbed447",&
- "bc2062a4e520969",&
- "9e357f3feed059b",&
- "aa6b59212036a57",&
- "f78a326722d6565",&
- "416754bc34c6405",&
- "f77000b3f04ff67",&
- "d48fbd7d48c5ab9",&
- "031ffb5db3a70cb",&
- "125964e358c4df5",&
- "bd02c32a5a241ea",&
- "4c15ecdd8561abd",&
- "7f0f1b352c7413e",&
- "26edb94dfd0ae79",&
- "ca1ba1ee0f8fb24",&
- "49878a58cb4544c",&
- "3dbcd0ff821b203",&
- "c1f4440160d5345",&
- "b5ea9dc7a5a70ab",&
- "cebcf7d94976be4",&
- "0968265f5977c88",&
- "c5a36937faa78c3",&
- "f0d4fef11e01c10",&
- "e35fc0c779bebfe",&
- "cf49c3eb41a31d5",&
- "3f0b19352c7013e",&
- "0e15eccd8521abd",&
- "dda8dcaf9d3048c",&
- "fee31438fba59ed",&
- "ad74a27e939189c",&
- "736ac01b439106e",&
- "ab5d2729b29bfa1",&
- "edf11fb02e5a426",&
- "5f38be1c93ecc83",&
- "1e4b3b8dc516b3e",&
- "84443d8bee614c6",&
- "d854d9f355ceac4",&
- "a476b5ece51f0ea",&
- "831c2b36c4c2f68",&
- "f485c97a91615ae",&
- "e9376d828ade9ba",&
- "cac586f089d3185",&
- "b8f8c67613dafe2",&
- "1a3142b401b315d",&
- "87dbedc43265d2e",&
- "bb64ec6e652e7da",&
- "e71bfd4c95dfd38",&
- "31209af07ad4f75",&
- "cff1a8ccc5f4978",&
- "742eded1e1dfefd",&
- "1cd7154a904dac4"/
-
-data colorder/ &
- 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, &
- 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, &
- 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, &
- 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, &
- 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, &
- 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/
-
-save first,gen
-
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,60
- do j=1,15
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- icol=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(i,icol)=1
- enddo
- enddo
- enddo
-first=.false.
-endif
-
-do i=1, 60
- nsum=0
- do j=1, 60
- nsum=nsum+message(j)*gen(i,j)
- enddo
- pchecks(i)=mod(nsum,2)
-enddo
-itmp(1:60)=pchecks
-itmp(61:120)=message(1:60)
-codeword(colorder+1)=itmp(1:120)
-
-return
-end subroutine encode120
diff --git a/lib/fsk4hf/encode168.f90 b/lib/fsk4hf/encode168.f90
deleted file mode 100644
index bf121215..00000000
--- a/lib/fsk4hf/encode168.f90
+++ /dev/null
@@ -1,141 +0,0 @@
-subroutine encode168(message,codeword)
-! Encode an 84-bit message and return a 168-bit codeword.
-! The generator matrix has dimensions (84,84).
-! The code is a (168,84) regular ldpc code with column weight 3.
-! The code was generated using the PEG algorithm.
-! After creating the codeword, the columns are re-ordered according to
-! "colorder" to make the codeword compatible with the parity-check matrix
-!
-character*21 g(84)
-integer*1 codeword(168)
-integer colorder(168)
-integer*1 gen(84,168)
-integer*1 itmp(168)
-integer*1 message(84)
-integer*1 pchecks(84)
-logical first
-data first/.true./
-data g/ & !parity generator matrix for (168,84) code
- "25c5bf31ef6710fde9a5a", &
- "18038ef7899cd97a77d96", &
- "270dde504dad076c02b1f", &
- "ed37fe12616565bd7d500", &
- "12b99aa49b5367aff3838", &
- "41cc27f2fac8b228aac21", &
- "2265b233a3cff0b9cee24", &
- "292760cd4f7f4a526a2f1", &
- "2b3db4c8bd831911680cc", &
- "cef2b24ce203bdc60b266", &
- "5045a24f9340915d807ab", &
- "3592b7fc60ba85139502e", &
- "9318023145637bd798f0e", &
- "ad796023c3d58d1e6509c", &
- "3da5eab57f040e75d7413", &
- "27466d1d2734d0ff64830", &
- "2ed50bb1ce313bbfb1ab0", &
- "9a616bda01b25b7e6eeaf", &
- "a84c8c1e9df103169d10d", &
- "a40da29b4aca9234a8942", &
- "dd258d02d79a5f209d3d0", &
- "bdfdc06713511997b5621", &
- "25c58f12f4096cd8ead1a", &
- "b2638a478f21e10fe97de", &
- "4051020f43c605d458156", &
- "f651aad14322a526dae35", &
- "a1c147e31bcc9d87330bf", &
- "7524b53d996d48284647b", &
- "a72e7d25ce31b27282e56", &
- "a97f53b019022350b7519", &
- "56106c6340c0810790984", &
- "c63b8e03a57208635992b", &
- "43a3de2aa3a2b1afb65dc", &
- "9baa64847ead03b77fecc", &
- "251cbd1895c8839c46b0d", &
- "2858107dde2d173e13530", &
- "20096f6a870f636b704e7", &
- "7f833ccbceec52dd6eb79", &
- "a9108dd77b8015b75242a", &
- "689666a79e5579c916236", &
- "aa5dff46459787f69911f", &
- "794558c13138d08171089", &
- "c937042857b291cee8dfd", &
- "6f0bf3248bb9a231366b8", &
- "1c09e756ef1656c96f2d2", &
- "073b875b6774e71fba549", &
- "f7d840aafc037febd2d5c", &
- "dcc0e7d0da5fe17c99ad3", &
- "98238ef7819cd97a77d94", &
- "177c2594743477421a262", &
- "7d01a833c19374fbaaa6e", &
- "7bb800216660482ffd1c4", &
- "39a92e2dba0d4cfda98d2", &
- "44b8d88622698816456a8", &
- "791db2334d6d86639229b", &
- "ba6004b086bd38559ea48", &
- "f94558e13138d18170089", &
- "08ba145302cfbed7845ae", &
- "fb8e64b6da3602168ed38", &
- "1045a2cf1340915d8072b", &
- "7592b6fc64ba85139582e", &
- "3eb238a11bc6654452bae", &
- "b69d8d23b1ea170f70214", &
- "0123dfae84fb20462a614", &
- "4131066ad52a339b3c0d7", &
- "fd2cc26850951c43ed737", &
- "a644d4eb7e56c40f0d050", &
- "0c3bd9d5dab7c9ee2c8fc", &
- "4a198b37af56d7ceffb56", &
- "b6e946c429294cf0eed8b", &
- "98384d75e758774f5ff3b", &
- "5c58e5d9a4d0531d37384", &
- "7a0af02719afed521fd06", &
- "8cd5b2e694e7854abbc70", &
- "1a2f061912d0ea19702d3", &
- "6ffbce557d8fa691a50e8", &
- "d43438e2e2ed5d9f14011", &
- "8d502106083b809adba00", &
- "67e22f9b9983aa715964d", &
- "b31f3a3f3c1f406b1fd58", &
- "529f60ac291f827d97331", &
- "476a815424f2e2cbe641f", &
- "81c82c89bcc3feec42458", &
- "2c882d0e281b178e80364"/
-
-data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, &
- 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, &
- 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, &
- 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, &
- 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, &
- 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, &
- 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, &
- 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/
-
-save first,gen
-
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,84
- do j=1,21
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- icol=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(i,icol)=1
- enddo
- enddo
- enddo
-first=.false.
-endif
-
-do i=1, 84
- nsum=0
- do j=1, 84
- nsum=nsum+message(j)*gen(i,j)
- enddo
- pchecks(i)=mod(nsum,2)
-enddo
-itmp(1:84)=pchecks
-itmp(85:168)=message(1:84)
-codeword(colorder+1)=itmp(1:168)
-
-return
-end subroutine encode168
diff --git a/lib/fsk4hf/encode204.f90 b/lib/fsk4hf/encode204.f90
deleted file mode 100644
index b824196a..00000000
--- a/lib/fsk4hf/encode204.f90
+++ /dev/null
@@ -1,48 +0,0 @@
-subroutine encode204(message,codeword)
-! Encode an 68-bit message and return a 204-bit codeword.
-! The generator matrix has dimensions (136,68).
-! The code is a (204,68) regular ldpc code with column weight 3.
-! The code was generated using the PEG algorithm.
-! After creating the codeword, the columns are re-ordered according to
-! "colorder" to make the codeword compatible with the parity-check matrix
-!
-
-include "ldpc_204_68_params.f90"
-
-integer*1 codeword(N)
-integer*1 gen(M,K)
-integer*1 itmp(N)
-integer*1 message(K)
-integer*1 pchecks(M)
-logical first
-data first/.true./
-
-save first,gen
-
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,M
- do j=1,17
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- 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
-itmp(1:M)=pchecks
-itmp(M+1:N)=message(1:K)
-codeword(colorder+1)=itmp(1:N)
-
-return
-end subroutine encode204
diff --git a/lib/fsk4hf/encode300.f90 b/lib/fsk4hf/encode300.f90
deleted file mode 100644
index f1d3bbae..00000000
--- a/lib/fsk4hf/encode300.f90
+++ /dev/null
@@ -1,308 +0,0 @@
-subroutine encode300(message,codeword)
-! Encode an 60-bit message and return a 300-bit codeword.
-! The generator matrix has dimensions (240,60).
-! The code is a (300,60) irregular ldpc code with column weights:
-! 52% column weight 2
-! 27% column weight 3
-! 21% column weight 7
-! The code was generated using the PEG algorithm.
-! After creating the codeword, the columns are re-ordered according to
-! "colorder" to make the codeword compatible with the parity-check matrix
-!
-character*15 g(240)
-integer*1 codeword(300)
-integer colorder(300)
-integer*1 gen(240,60)
-integer*1 itmp(300)
-integer*1 message(60)
-integer*1 pchecks(240)
-logical first
-data first/.true./
-data g/ &
- "316fd3bb18bcefd", &
- "a9c1c984f91244e", &
- "9e04bd3d5d78d89", &
- "f81617089621bd4", &
- "12997ce2f44dbf4", &
- "3ebddaf9b0fa1fc", &
- "d0c114b0b0ef162", &
- "f8c4f115f98bd92", &
- "d0a79c0c5b8ca19", &
- "477f6712f357b3b", &
- "fa28b2444a7e66b", &
- "bedcd4df8d95c64", &
- "da30de73e57022c", &
- "bc099bbb90fe09e", &
- "cffc1e47e5708e8", &
- "713d808563ca9a3", &
- "70fcf1741d5d5d7", &
- "32e80bc15112008", &
- "804cef4df9b18ec", &
- "3736881819d1033", &
- "f4e37db7f9c5efe", &
- "9e84b93d4d78d09", &
- "2250c3518ec830a", &
- "55a529a92e18021", &
- "1cb80b14c9f6eae", &
- "80c504b031ef926", &
- "ece6636d0ac9c6d", &
- "5d50a1690782cd0", &
- "3d54a1fb30937a2", &
- "ba8fe8006318041", &
- "02917ce2fc45bf4", &
- "abc1d984f95a44e", &
- "fc05b4c4ab2d850", &
- "467f7718f357b3b", &
- "472cc094546c6b2", &
- "fcdd94cf8c9cc64", &
- "4dbc1647e970cc8", &
- "6caa465c442aed1", &
- "aead5af8b0da1be", &
- "d8e1fa45a2e8431", &
- "9d4dc4cc63abb7f", &
- "9b2df6b48264637", &
- "7335808563ca3a3", &
- "36bf8d5cd93e6cc", &
- "004ccf4db9b08ec", &
- "90a71c8c598ca19", &
- "f8c5d115f90bc92", &
- "b95546c4e3f7934", &
- "7d50a1690786cd0", &
- "c90939921a0d7c6", &
- "d0c504b030ef126", &
- "ce3e6f9396fc542", &
- "a0072a59f3707f5", &
- "532d0a8fe3da1ea", &
- "68b9e5cd7d142db", &
- "fedc94df8c9dc64", &
- "6da2465c448aed0", &
- "3574aa19cb273c0", &
- "1e54768c6bc6843", &
- "691f65654498186", &
- "fe2c92444a6ef6b", &
- "9caad933e038cc4", &
- "ad4e6f4defb28ec", &
- "4f3d80947c6d2b2", &
- "1caad933e0b8cc4", &
- "b14fd3bf18bcafd", &
- "ad091bbbb0f809e", &
- "90b71c8c598da19", &
- "f8c4d115f90bd92", &
- "9d4dcccc63afb7f", &
- "fa2c92444a6e76b", &
- "1e14768c6bc6c43", &
- "d1baf5aacb86087", &
- "bdf762b92ee51c7", &
- "caacec06ad8a90c", &
- "804ccf4df9b08ec", &
- "69e969f9da5cbd8", &
- "814ccf4df9b086c", &
- "cebe4f9796f4542", &
- "491f65654499186", &
- "8fbf5b9796f6d2a", &
- "ce3e4f9396f4542", &
- "47558560e7debc3", &
- "94aadd33e038cc4", &
- "a94eef4debb286e", &
- "d8e5d115f91bcd2", &
- "532d488fe3da0ab", &
- "664e7bc4e23a80c", &
- "94a2dd33a038cd4", &
- "d8c5d115f91bc92", &
- "0fef071eee60bd5", &
- "9a89a09163c2b97", &
- "0eaf071e6c60bd5", &
- "bc0d1bbbb0fe0be", &
- "f9babd3d12d0f31", &
- "69a969f9da5c9d8", &
- "6e4e7bc4e23a82c", &
- "b0042659f3227f5", &
- "2d51418f0f28347", &
- "be0d5bbbb0da0be", &
- "225003508ec8302", &
- "8fbf4b9796f4d2a", &
- "bead5af9b0da1be", &
- "6ca2465c440aed1", &
- "4fbc1e47ed708c8", &
- "bd091bbbb0fc09e", &
- "b0062259f3307f5", &
- "a8072a59f3727f5", &
- "a0062259f3707f5", &
- "3c380b14c974eae", &
- "30042659f3226f5", &
- "48b9e4cd7d142db", &
- "728bcd4b38308fb", &
- "c0c504b031ef126", &
- "314fd3bb18bcafd", &
- "1c29148305faec1", &
- "44c92a9c28ada63", &
- "88e99b370aae32b", &
- "695081690386ad8", &
- "572d0a8de3da1ea", &
- "467f6610f357b2b", &
- "733d008563da1a3", &
- "d1baf4aacb84087", &
- "4315551d71c8ff0", &
- "48bde4cd7d140db", &
- "3ebd58f9b0da9fc", &
- "51baf4aacb84083", &
- "814e4f4de9b082c", &
- "814ecf4de9b086c", &
- "be0d1bbbb0fa0be", &
- "4f7580947c792b3", &
- "cdf2dce48c39c3b", &
- "d8c5c115f91bc12", &
- "a94e6f4debb28ee", &
- "be2d5afbb0da1be", &
- "cdd6dce48439c2b", &
- "bebd5af9b0da1fe", &
- "fa2892444a6e66b", &
- "51bbf4aacb8c083", &
- "baa73d81eebcd83", &
- "79a2ce47f138cc9", &
- "cc28cf198e6dbd4", &
- "fcde94dfcc9cc64", &
- "1016fcf59286717", &
- "12917ce2fc4dbf4", &
- "4fbc1647e9708c8", &
- "3e382b1cc974fae", &
- "d5bafdaad386087", &
- "0fef473eee60bd5", &
- "c0e504b031ee126", &
- "8bbf5b9797f6d2a", &
- "0eef071e6e60bd5", &
- "1806fcf59386517", &
- "fcdc94df8c9cc64", &
- "141eca2bfa25656", &
- "5fbc1767e9708e8", &
- "5aa4c7803a6bdf1", &
- "b14bd3b718bcafd", &
- "3ebd5af9b0da1fc", &
- "d0a7148c5b8ca09", &
- "a94ecf4debb086e", &
- "733d808563ca1a3", &
- "fd9abd1d92d0f31", &
- "bc091bbbb0fe09e", &
- "d0c514b0b0ef122", &
- "4f7d80947c7d2b3", &
- "8b3f5b97b7f6d2a", &
- "4fbc1767e9708c8", &
- "cebf4f9796f4502", &
- "9c76c880a864e67", &
- "abc1c984f95244e", &
- "795081690786ad8", &
- "467f6710f357b3b", &
- "1c380b14c9f4eae", &
- "d5baf5aac386087", &
- "bedc94df8c95c64", &
- "553d0a8de2da1fa", &
- "0315551d71d8ff0", &
- "1c1eca2ffa25656", &
- "d4bafdaad3c6087", &
- "be2d5bfbb0da0be", &
- "b0062659f3207f5", &
- "5ffc1765e9708e8", &
- "8d62e8bcd303e33", &
- "cc08cf198e69bd4", &
- "573d0a8de3da1fa", &
- "cd56dce48639c2b", &
- "472dc094546c2b2", &
- "7950a16907868d8", &
- "7283cf4b38308fb", &
- "894ecf4de9b086e", &
- "0f7580b47c792b3", &
- "cfbf4b9796f4d0a", &
- "3e380b14c974fae", &
- "732d0085e3da1a3", &
- "1816fcf59386717", &
- "532d088fe3da1ab", &
- "1c300b94c9fcaae", &
- "d0a71c8c5b8ca19", &
- "9e84bd3d5d78d09", &
- "225083508ec830a", &
- "f99abd1d12d0f31", &
- "35f4aa19cb673c0", &
- "cdd2dce48c39c2b", &
- "0f7780b47c792bf", &
- "0e33a5f114f5730", &
- "bc05b4c4ab0d850", &
- "1c300b14c9f4aae", &
- "cfbc1e47ed708e8", &
- "0f7180b47c392b3", &
- "d8c7c115f91be12", &
- "c09148adfa94e97", &
- "9c66c880a844e67", &
- "2226c13b73519f8", &
- "cebf4b9796f4d02", &
- "c0e706b031ee126", &
- "6a6629715e53ce3", &
- "73f9aa824e7d0b8", &
- "473d80947c6c2b2", &
- "1df140e0ddb5632", &
- "473dc0945c6c2b2", &
- "81b4d95f671971d", &
- "663945ca758e2b6", &
- "02ec3d98a2306fd", &
- "5dadb0fa1275690", &
- "4bb8aaa854948d0", &
- "8359ba40886971c", &
- "49cc3d2a2be2ee0", &
- "bfdf13af137f318", &
- "a1de773a2b1ff04", &
- "8ff3945a2f465c7", &
- "532d0087e3da1a3", &
- "f3eaf7fa454d385", &
- "a606aa5aeba07d9", &
- "67f0627b0af8a53", &
- "56698bed69d1c2c", &
- "d5f420011fbf924", &
- "2a8f86c810e2c62", &
- "43cc1cf1208c206", &
- "ee784c4900258de"/
-
-data colorder/ &
-0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, &
-19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, &
-37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, &
-125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, &
-181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, &
-79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, &
-88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, &
-132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, &
-205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, &
-206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, &
-200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, &
-118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, &
-240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, &
-260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, &
-280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/
-
-save first,gen
-
-if( first ) then ! fill the generator matrix
- gen=0
- do i=1,240
- do j=1,15
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- icol=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(i,icol)=1
- enddo
- enddo
- enddo
-first=.false.
-endif
-
-do i=1, 240
- nsum=0
- do j=1, 60
- nsum=nsum+message(j)*gen(i,j)
- enddo
- pchecks(i)=mod(nsum,2)
-enddo
-itmp(1:240)=pchecks
-itmp(241:300)=message(1:60)
-codeword(colorder+1)=itmp(1:300)
-
-return
-end subroutine encode300
diff --git a/lib/fsk4hf/extractmessage168.f90 b/lib/fsk4hf/extractmessage168.f90
deleted file mode 100644
index 466d2a63..00000000
--- a/lib/fsk4hf/extractmessage168.f90
+++ /dev/null
@@ -1,48 +0,0 @@
-subroutine extractmessage168(decoded,msgreceived,ncrcflag,recent_calls,nrecent)
- use iso_c_binding, only: c_loc,c_size_t
- use crc
- use packjt
-
- character*22 msgreceived
- character*12 call1,call2
- character*12 recent_calls(nrecent)
- integer*1 decoded(84)
- integer*1, target:: i1Dec8BitBytes(11)
- integer*4 i4Dec6BitWords(12)
-
-! Collapse 84 decoded bits to 11 bytes. Bytes 1-9 are the message, byte 10 and first half of byte 11 is the crc
- do ibyte=1,9
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
-! Need to pack the crc into bytes 10 and 11 for crc12_check
- i1Dec8BitBytes(10)=decoded(73)*8+decoded(74)*4+decoded(75)*2+decoded(76)
- i1Dec8BitBytes(11)=decoded(77)*128+decoded(78)*64+decoded(79)*2*32+decoded(80)*16
- i1Dec8BitBytes(11)=i1Dec8BitBytes(11)+decoded(81)*8+decoded(82)*4+decoded(83)*2+decoded(84)
-
- if( crc12_check(c_loc (i1Dec8BitBytes), 11) ) then
-! CRC12 checks out --- unpack 72-bit message
- do ibyte=1,12
- itmp=0
- do ibit=1,6
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*6+ibit))
- enddo
- i4Dec6BitWords(ibyte)=itmp
- enddo
- call unpackmsg144(i4Dec6BitWords,msgreceived,call1,call2)
- ncrcflag=1
- if( call1(1:2) .ne. 'CQ' .and. call1(1:2) .ne. ' ' ) then
- call update_recent_calls(call1,recent_calls,nrecent)
- endif
- if( call2(1:2) .ne. ' ' ) then
- call update_recent_calls(call2,recent_calls,nrecent)
- endif
- else
- msgreceived=' '
- ncrcflag=-1
- endif
- return
- end subroutine extractmessage168
diff --git a/lib/fsk4hf/fftw3.f90 b/lib/fsk4hf/fftw3.f90
deleted file mode 100644
index 440ccc28..00000000
--- a/lib/fsk4hf/fftw3.f90
+++ /dev/null
@@ -1,64 +0,0 @@
- INTEGER FFTW_R2HC
- PARAMETER (FFTW_R2HC=0)
- INTEGER FFTW_HC2R
- PARAMETER (FFTW_HC2R=1)
- INTEGER FFTW_DHT
- PARAMETER (FFTW_DHT=2)
- INTEGER FFTW_REDFT00
- PARAMETER (FFTW_REDFT00=3)
- INTEGER FFTW_REDFT01
- PARAMETER (FFTW_REDFT01=4)
- INTEGER FFTW_REDFT10
- PARAMETER (FFTW_REDFT10=5)
- INTEGER FFTW_REDFT11
- PARAMETER (FFTW_REDFT11=6)
- INTEGER FFTW_RODFT00
- PARAMETER (FFTW_RODFT00=7)
- INTEGER FFTW_RODFT01
- PARAMETER (FFTW_RODFT01=8)
- INTEGER FFTW_RODFT10
- PARAMETER (FFTW_RODFT10=9)
- INTEGER FFTW_RODFT11
- PARAMETER (FFTW_RODFT11=10)
- INTEGER FFTW_FORWARD
- PARAMETER (FFTW_FORWARD=-1)
- INTEGER FFTW_BACKWARD
- PARAMETER (FFTW_BACKWARD=+1)
- INTEGER FFTW_MEASURE
- PARAMETER (FFTW_MEASURE=0)
- INTEGER FFTW_DESTROY_INPUT
- PARAMETER (FFTW_DESTROY_INPUT=1)
- INTEGER FFTW_UNALIGNED
- PARAMETER (FFTW_UNALIGNED=2)
- INTEGER FFTW_CONSERVE_MEMORY
- PARAMETER (FFTW_CONSERVE_MEMORY=4)
- INTEGER FFTW_EXHAUSTIVE
- PARAMETER (FFTW_EXHAUSTIVE=8)
- INTEGER FFTW_PRESERVE_INPUT
- PARAMETER (FFTW_PRESERVE_INPUT=16)
- INTEGER FFTW_PATIENT
- PARAMETER (FFTW_PATIENT=32)
- INTEGER FFTW_ESTIMATE
- PARAMETER (FFTW_ESTIMATE=64)
- INTEGER FFTW_ESTIMATE_PATIENT
- PARAMETER (FFTW_ESTIMATE_PATIENT=128)
- INTEGER FFTW_BELIEVE_PCOST
- PARAMETER (FFTW_BELIEVE_PCOST=256)
- INTEGER FFTW_DFT_R2HC_ICKY
- PARAMETER (FFTW_DFT_R2HC_ICKY=512)
- INTEGER FFTW_NONTHREADED_ICKY
- PARAMETER (FFTW_NONTHREADED_ICKY=1024)
- INTEGER FFTW_NO_BUFFERING
- PARAMETER (FFTW_NO_BUFFERING=2048)
- INTEGER FFTW_NO_INDIRECT_OP
- PARAMETER (FFTW_NO_INDIRECT_OP=4096)
- INTEGER FFTW_ALLOW_LARGE_GENERIC
- PARAMETER (FFTW_ALLOW_LARGE_GENERIC=8192)
- INTEGER FFTW_NO_RANK_SPLITS
- PARAMETER (FFTW_NO_RANK_SPLITS=16384)
- INTEGER FFTW_NO_VRANK_SPLITS
- PARAMETER (FFTW_NO_VRANK_SPLITS=32768)
- INTEGER FFTW_NO_VRECURSE
- PARAMETER (FFTW_NO_VRECURSE=65536)
- INTEGER FFTW_NO_SIMD
- PARAMETER (FFTW_NO_SIMD=131072)
diff --git a/lib/fsk4hf/four2a.f90 b/lib/fsk4hf/four2a.f90
deleted file mode 100644
index 57c7239e..00000000
--- a/lib/fsk4hf/four2a.f90
+++ /dev/null
@@ -1,115 +0,0 @@
-subroutine four2a(a,nfft,ndim,isign,iform)
-
-! IFORM = 1, 0 or -1, as data is
-! complex, real, or the first half of a complex array. Transform
-! values are returned in array DATA. They are complex, real, or
-! the first half of a complex array, as IFORM = 1, -1 or 0.
-
-! The transform of a real array (IFORM = 0) dimensioned N(1) by N(2)
-! by ... will be returned in the same array, now considered to
-! be complex of dimensions N(1)/2+1 by N(2) by .... Note that if
-! IFORM = 0 or -1, N(1) must be even, and enough room must be
-! reserved. The missing values may be obtained by complex conjugation.
-
-! The reverse transformation of a half complex array dimensioned
-! N(1)/2+1 by N(2) by ..., is accomplished by setting IFORM
-! to -1. In the N array, N(1) must be the true N(1), not N(1)/2+1.
-! The transform will be real and returned to the input array.
-
-! This version of four2a makes calls to the FFTW library to do the
-! actual computations.
-
- parameter (NPMAX=2100) !Max numberf of stored plans
- parameter (NSMALL=16384) !Max size of "small" FFTs
- complex a(nfft) !Array to be transformed
- complex aa(NSMALL) !Local copy of "small" a()
- integer nn(NPMAX),ns(NPMAX),nf(NPMAX) !Params of stored plans
- integer*8 nl(NPMAX),nloc !More params of plans
- integer*8 plan(NPMAX) !Pointers to stored plans
- logical found_plan
- data nplan/0/ !Number of stored plans
- common/patience/npatience,nthreads !Patience and threads for FFTW plans
- include 'fftw3.f90' !FFTW definitions
- save plan,nplan,nn,ns,nf,nl
-
- if(nfft.lt.0) go to 999
-
- nloc=loc(a)
-
- found_plan = .false.
- !$omp critical(four2a_setup)
- do i=1,nplan
- if(nfft.eq.nn(i) .and. isign.eq.ns(i) .and. &
- iform.eq.nf(i) .and. nloc.eq.nl(i)) then
- found_plan = .true.
- exit
- end if
- enddo
-
- if(i.ge.NPMAX) stop 'Too many FFTW plans requested.'
-
- if (.not. found_plan) then
- nplan=nplan+1
- i=nplan
-
- nn(i)=nfft
- ns(i)=isign
- nf(i)=iform
- nl(i)=nloc
-
-! Planning: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, FFTW_MEASURE,
-! FFTW_PATIENT, FFTW_EXHAUSTIVE
- nflags=FFTW_ESTIMATE
- if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT
- if(npatience.eq.2) nflags=FFTW_MEASURE
- if(npatience.eq.3) nflags=FFTW_PATIENT
- if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE
-
- if(nfft.le.NSMALL) then
- jz=nfft
- if(iform.eq.0) jz=nfft/2
- aa(1:jz)=a(1:jz)
- endif
-
- !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls
- if(isign.eq.-1 .and. iform.eq.1) then
- call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_FORWARD,nflags)
- else if(isign.eq.1 .and. iform.eq.1) then
- call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_BACKWARD,nflags)
- else if(isign.eq.-1 .and. iform.eq.0) then
- call sfftw_plan_dft_r2c_1d(plan(i),nfft,a,a,nflags)
- else if(isign.eq.1 .and. iform.eq.-1) then
- call sfftw_plan_dft_c2r_1d(plan(i),nfft,a,a,nflags)
- else
- stop 'Unsupported request in four2a'
- endif
- !$omp end critical(fftw)
-
- if(nfft.le.NSMALL) then
- jz=nfft
- if(iform.eq.0) jz=nfft/2
- a(1:jz)=aa(1:jz)
- endif
- end if
- !$omp end critical(four2a_setup)
-
- call sfftw_execute(plan(i))
- return
-
-999 continue
-
- !$omp critical(four2a)
- do i=1,nplan
-! The test is only to silence a compiler warning:
- if(ndim.ne.-999) then
- !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls
- call sfftw_destroy_plan(plan(i))
- !$omp end critical(fftw)
- end if
- enddo
-
- nplan=0
- !$omp end critical(four2a)
-
- return
-end subroutine four2a
diff --git a/lib/fsk4hf/fsk4hf.f90 b/lib/fsk4hf/fsk4hf.f90
deleted file mode 100644
index 191e05c3..00000000
--- a/lib/fsk4hf/fsk4hf.f90
+++ /dev/null
@@ -1,145 +0,0 @@
-program fsk4hf
-
-! Simulate characteristics of a potential mode using LDPC (168,84) code,
-! 4-FSK modulation, and 30 s T/R sequences.
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays)
- parameter (NR=2) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (98)
- parameter (NSPS=2688/84) !Samples per symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
-
- character*8 arg
- complex c0(0:NZ-1) !Complex waveform
- complex c(0:NZ-1) !Complex waveform
- real xnoise(0:NZ-1) !Generated random noise
- real ynoise(0:NZ-1) !Generated random noise
- real rxdata(2*ND),llr(2*ND) !Soft symbols
- real s(0:NSPS,NN)
- real savg(0:NSPS)
- real ps(0:3)
- integer id(ND) !Symbol values (0-3), data only
- integer id1(ND) !Recovered data values
- integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND)
- data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, &
- 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,1,1,0,1,1, &
- 1,1,0,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0/
-
- nargs=iargc()
- if(nargs.ne.5) then
- print*,'Usage: fsk4hf f0(Hz) delay(ms) fspread(Hz) iters snr(dB)'
- print*,'Example: fsk4hf 20 0 0 10 -20'
- print*,'Set snr=0 to cycle through a range'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) f0 !Generated carrier frequency
- call getarg(2,arg)
- read(arg,*) delay !Delta_t (ms) for Watterson model
- call getarg(3,arg)
- read(arg,*) fspread !Fspread (Hz) for Watterson model
- call getarg(4,arg)
- read(arg,*) iters !Iterations at each SNR
- call getarg(5,arg)
- read(arg,*) snrdb !Specified SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/84.0 !Sample rate = 142.857... Hz
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- write(*,1000) f0,delay,fspread,iters,baud,4*baud,txt
-1000 format('f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2, &
- ' Iters:',i6/'Baud:',f7.3,' BW:',f5.1,' TxT:',f5.1,f5.2/)
- write(*,1004)
-1004 format(/' SNR sym bit ser ber fer fsigma'/50('-'))
-
- call genfsk4hf(msgbits,f0,id,c0) !Generate baseband waveform
- isna=-10
- isnb=-30
- if(snrdb.ne.0.0) then
- isna=nint(snrdb)
- isnb=isna
- endif
- do isnr=isna,isnb,-1 !Loop over SNR range
- snrdb=isnr
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- nhard=0
- nbit=0
- nfe=0
- sqf=0.
- do iter=1,iters !Loop over requested iterations
- c=c0
- if(delay.ne.0.0 .or. fspread.ne.0.0) then
- call watterson(c,NZ,fs,delay,fspread)
- endif
- c=sig*c !Scale to requested SNR
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Generate gaussian noise
- xnoise(i)=gran()
- ynoise(i)=gran()
- enddo
- c=c + cmplx(xnoise,ynoise) !Add AWGN noise
- endif
- df=fs/(2*NSPS)
- i0=nint(f0/df)
- call spec4(c,s,savg)
- do i=0,NSPS
- write(12,3001) i*df,savg(i),db(savg(i))
-3001 format(3f15.3)
- enddo
-
- do j=1,ND
- nlo=0
- nhi=0
- k=j+5
- if(j.ge.43) k=j+9
- ps=s(i0:i0+6:2,k)
- ps=sqrt(ps) !###
- rlo=max(ps(1),ps(3))-max(ps(0),ps(2))
- rhi=max(ps(2),ps(3))-max(ps(0),ps(1))
- if(rlo.ge.0.0) nlo=1
- if(rhi.ge.0.0) nhi=1
- rxdata(2*j-1)=rhi
- rxdata(2*j)=rlo
- id1(j)=2*nhi+nlo
- enddo
-! write(*,1001) id(1:70)
-! write(*,1001) id1(1:70)
-!1001 format(70i1)
- nhard=nhard+count(id.ne.id1)
- nbit=nbit + count(iand(id,1).ne.iand(id1,1)) + &
- count(iand(id,2).ne.iand(id1,2))
-
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss)
- apmask=0
- max_iterations=40
- ifer=0
- call bpdecode168(llr,apmask,max_iterations,decoded,niterations,cw)
- nbadcrc=0
- if(niterations.ge.0) call chkcrc12(decoded,nbadcrc)
- if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. &
- nbadcrc.ne.0) ifer=1
- nfe=nfe+ifer
- enddo
-
- fsigma=sqrt(sqf/iters)
- ser=float(nhard)/(ND*iters)
- ber=float(nbit)/(2*ND*iters)
- fer=float(nfe)/iters
- write(*,1050) snrdb,nhard,nbit,ser,ber,fer,fsigma
-! write(60,1050) snrdb,nhard,ber,fer,fsigma
-1050 format(f6.1,2i6,2f8.4,f7.3,f8.2)
- enddo
-
-999 end program fsk4hf
diff --git a/lib/fsk4hf/fsk4sim.f90 b/lib/fsk4hf/fsk4sim.f90
deleted file mode 100644
index 9800616e..00000000
--- a/lib/fsk4hf/fsk4sim.f90
+++ /dev/null
@@ -1,185 +0,0 @@
-program fsk4sim
-
- parameter (ND=60) !Data symbols: LDPC (120,60), r=1/2
- parameter (NN=ND) !Total symbols (60)
- parameter (NSPS=57600) !Samples per symbol at 12000 sps
- parameter (NZ=NSPS*NN) !Samples in waveform (3456000)
-
- character*8 arg
- complex c(0:NZ-1) !Complex waveform
- complex cr(0:NZ-1)
- complex cs(NSPS,NN)
- complex cps(0:3)
- complex ct(0:2*NN-1)
- complex z,w,zsum
- real r(0:NZ-1)
- real s(NSPS,NN)
- real savg(NSPS)
- real tmp(NN) !For generating random data
- real xnoise(0:NZ-1) !Generated random noise
- real ps(0:3)
- integer id(NN) !Encoded 2-bit data (values 0-3)
- integer id2(NN) !Recovered data
- equivalence (r,cr)
-
- nnn=0
- nargs=iargc()
- if(nargs.ne.6) then
- print*,'Usage: fsk8sim f0 delay(ms) fspread(Hz) nts iters snr(dB)'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) f0 !Low tone frequency
- call getarg(2,arg)
- read(arg,*) delay
- call getarg(3,arg)
- read(arg,*) fspread
- call getarg(4,arg)
- read(arg,*) nts
- call getarg(5,arg)
- read(arg,*) iters
- call getarg(6,arg)
- read(arg,*) snrdb
-
- twopi=8.d0*atan(1.d0)
- fs=12000.d0
- dt=1.0/fs
- ts=NSPS*dt
- baud=1.d0/ts
- txt=NZ*dt
- bandwidth_ratio=2500.0/6000.0
- write(*,1000) baud,5*baud,txt,delay,fspread,nts
-1000 format('Baud:',f6.3,' BW:',f5.1,' TxT:',f5.1,' Delay:',f5.2, &
- ' fSpread:',f5.2,' nts:',i3/)
-
- write(*,1004)
-1004 format(' SNR Sym Bit SER BER Sym Bit SER BER'/59('-'))
-
- isna=-25
- isnb=-40
- if(snrdb.ne.0.0) then
- isna=nint(snrdb)
- isnb=isna
- endif
- do isnr=isna,isnb,-1
- snrdb=isnr
- sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- nhard1=0
- nhard2=0
- nbit1=0
- nbit2=0
- nh2=0
- nb2=0
- do iter=1,iters
- nnn=nnn+1
- id=0
- call random_number(tmp)
- where(tmp.ge.0.25 .and. tmp.lt.0.50) id=1
- where(tmp.ge.0.50 .and. tmp.lt.0.75) id=2
- where(tmp.ge.0.75) id=3
-
- call genfsk4(id,f0,nts,c) !Generate the 4-FSK waveform
- call watterson(c,delay,fspread)
- if(sig.ne.1.0) c=sig*c !Scale to requested SNR
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Generate gaussian noise
- xnoise(i)=gran()
- enddo
- endif
- r(0:NZ-1)=real(c(0:NZ-1)) + xnoise !Add noise to signal
-
- call snr2_wsprlf(r,freq,snr2500,width,1)
- write(*,3001) freq,snr2500,width
-3001 format(40x,3f10.3)
-
- df=12000.0/(2*NSPS)
-! i0=nint(f0/df)
-! i0=nint((1500.0+freq)/df)
- i0=nint((f0+freq)/df)
- call spec4(r,cs,s,savg)
-
- do j=1,NN
- nlo=0
- nhi=0
- ps=s(i0:i0+6*nts:2*nts,j)
- cps=cs(i0:i0+6*nts:2*nts,j)
- if(max(ps(1),ps(3)).ge.max(ps(0),ps(2))) nlo=1
- if(max(ps(2),ps(3)).ge.max(ps(0),ps(1))) nhi=1
- id2(j)=2*nhi+nlo
- z=cps(id2(j))
- ct(j-1)=z
- enddo
- nh1=count(id.ne.id2)
- nb1=count(iand(id,1).ne.iand(id2,1)) + count(iand(id,2).ne.iand(id2,2))
-
- ct(NN:)=0.
- call four2a(ct,2*NN,1,-1,1)
- df2=baud/(2*NN)
- ct=cshift(ct,NN)
- ppmax=0.
- dfpk=0.
- do i=0,2*NN-1
- f=(i-NN)*df2
- pp=real(ct(i))**2 + aimag(ct(i))**2
- if(pp.gt.ppmax) then
- ppmax=pp
- dfpk=f
- endif
- enddo
-
- zsum=0.
- do j=1,NN
- phi=(j-1)*twopi*dfpk*ts
- w=cmplx(cos(phi),sin(phi))
- cps=cs(i0:i0+6*nts:2*nts,j)*conjg(w)
- z=cps(id2(j))
- ct(j)=z
- zsum=zsum+z
- write(12,1042) j,id(j),id2(j),20*ps,atan2(aimag(z),real(z)), &
- atan2(aimag(zsum),real(zsum)),zsum
-1042 format(3i2,6f8.3,2f8.1)
- enddo
-
- phi0=atan2(aimag(zsum),real(zsum))
- zsum=0.
- do j=1,NN
- phi=(j-1)*twopi*dfpk*ts + phi0
- w=cmplx(cos(phi),sin(phi))
- nlo=0
- nhi=0
- cps=cs(i0:i0+6*nts:2*nts,j)*conjg(w)
- ps=real(cps)
- if(max(ps(1),ps(3)).ge.max(ps(0),ps(2))) nlo=1
- if(max(ps(2),ps(3)).ge.max(ps(0),ps(1))) nhi=1
- id2(j)=2*nhi+nlo
- z=cps(id2(j))
- ct(j)=z
- zsum=zsum+z
- enddo
-
- nh2=count(id.ne.id2)
- nb2=count(iand(id,1).ne.iand(id2,1)) + count(iand(id,2).ne.iand(id2,2))
- nhard1=nhard1+nh1
- nhard2=nhard2+nh2
- nbit1=nbit1+nb1
- nbit2=nbit2+nb2
-
- fdiff=1500.0+freq - f0
- write(13,1040) snrdb,snr2500,f0,fdiff,width,nh1,nb1,nh2,nb2
-1040 format(2f7.1,f9.2,f7.2,f6.1,2(i8,i6))
-40 continue
- enddo
-
- ser1=float(nhard1)/(NN*iters)
- ser2=float(nhard2)/(NN*iters)
- ber1=float(nbit1)/(2*NN*iters)
- ber2=float(nbit2)/(2*NN*iters)
- write(*,1050) snrdb,nhard1,nbit1,ser1,ber1,nhard2,nbit2,ser2,ber2
- write(14,1050) snrdb,nhard1,nbit1,ser1,ber1,nhard2,nbit2,ser2,ber2
-1050 format(f6.1,2(2i5,2f8.4))
- enddo
- write(*,1060) NN*iters,2*NN*iters
-1060 format(59('-')/'Max: ',2i5)
-
-999 end program fsk4sim
diff --git a/lib/fsk4hf/genbpsk.f90 b/lib/fsk4hf/genbpsk.f90
deleted file mode 100644
index 6c283e72..00000000
--- a/lib/fsk4hf/genbpsk.f90
+++ /dev/null
@@ -1,44 +0,0 @@
-subroutine genbpsk(id,f00,ndiff,nref,c)
-
- parameter (ND=121) !Data symbols: LDPC (120,60), r=1/2
- parameter (NN=ND) !Total symbols (121)
- parameter (NSPS=28800) !Samples per symbol at 12000 sps
- parameter (NZ=NSPS*NN) !Samples in waveform (3456000)
-
- complex c(0:NZ-1) !Complex waveform
- real*8 twopi,dt,fs,baud,f0,dphi,phi
- integer id(NN) !Encoded NRZ data (values +/-1)
- integer ie(NN) !Differentially encoded data
-
- f0=f00
- twopi=8.d0*atan(1.d0)
- fs=12000.d0
- dt=1.0/fs
- baud=1.d0/(NSPS*dt)
-
- if(ndiff.ne.0) then
- ie(1)=1 !First bit is always 1
- do i=2,NN !Differentially encode
- ie(i)=id(i)*ie(i-1)
- enddo
- endif
-
-! Generate the BPSK waveform
- phi=0.d0
- k=-1
- do j=1,NN
- dphi=twopi*f0*dt
- x=id(j)
- if(ndiff.ne.0) x=ie(j) !Differential
- if(nref.ne.0) x=1.0 !Generate reference carrier
- do i=1,NSPS
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- c(k)=x*cmplx(cos(xphi),sin(xphi))
- enddo
- enddo
-
- return
-end subroutine genbpsk
diff --git a/lib/fsk4hf/genfsk4.f90 b/lib/fsk4hf/genfsk4.f90
deleted file mode 100644
index d8b0394b..00000000
--- a/lib/fsk4hf/genfsk4.f90
+++ /dev/null
@@ -1,36 +0,0 @@
-subroutine genfsk4(id,f00,nts,c)
-
- parameter (ND=60) !Data symbols: LDPC (120,60), r=1/2
- parameter (NN=ND) !Total symbols (60)
- parameter (NSPS=57600) !Samples per symbol at 12000 sps
- parameter (NZ=NSPS*NN) !Samples in waveform (3456000)
- parameter (NFFT=NZ) !Full length FFT
-
- complex c(0:NFFT-1) !Complex waveform
- real*8 twopi,dt,fs,baud,f0,dphi,phi
- integer id(NN) !Encoded 2-bit data (values 0-3)
-
- f0=f00
- twopi=8.d0*atan(1.d0)
- fs=12000.d0
- dt=1.0/fs
- baud=1.d0/(NSPS*dt)
-
-! Generate the 4-FSK waveform
- x=0.
- c=0.
- phi=0.d0
- k=-1
- do j=1,NN
- dphi=twopi*(f0 + nts*id(j)*baud)*dt
- do i=1,NSPS
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- c(k)=cmplx(cos(xphi),sin(xphi))
- enddo
- enddo
-
- return
-end subroutine genfsk4
diff --git a/lib/fsk4hf/genfsk4hf.f90 b/lib/fsk4hf/genfsk4hf.f90
deleted file mode 100644
index 924e9793..00000000
--- a/lib/fsk4hf/genfsk4hf.f90
+++ /dev/null
@@ -1,51 +0,0 @@
-subroutine genfsk4hf(msgbits,f0,id,c)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays)
- parameter (NR=2) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (98)
- parameter (NSPS=2688/84) !Samples per symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3136)
-
- complex c(0:NZ-1) !Complex waveform
- integer id0(NN) !2-bit data (values 0-3), all symbols
- integer id(ND) !2-bit data (values 0-3), data only
- integer*1 msgbits(KK),codeword(2*ND)
- integer icos4(4) !4x4 Costas array
- data icos4/0,1,3,2/
-
- twopi=8.0*atan(1.0)
- fs=12000.0/84.0
- dt=1.0/fs
- baud=1.0/(NSPS*dt)
- call encode168(msgbits,codeword) !Encode the test message
- id0(1)=0 !Ramp-up
- id0(2:5)=icos4 !First Costas array
- id0(48:51)=icos4 !Second
- id0(94:97)=icos4 !Third
- id0(98)=0 !Ramp down
- j=5
- do i=1,84 !Data symbols
- id(i)=2*codeword(2*i-1) + codeword(2*i)
- j=j+1
- if(i.eq.43) j=j+4
- id0(j)=id(i)
- enddo
-
-! Generate the 4-FSK waveform, low tone at f=0
- c=0.
- phi=0.d0
- k=-1
- do j=1,NN
- dphi=twopi*(f0+id0(j)*baud)*dt
- do i=1,NSPS
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- c(k)=cmplx(cos(phi),sin(phi))
- enddo
- enddo
-
- return
-end subroutine genfsk4hf
diff --git a/lib/fsk4hf/genmskhf.f90 b/lib/fsk4hf/genmskhf.f90
deleted file mode 100644
index 7d4b0838..00000000
--- a/lib/fsk4hf/genmskhf.f90
+++ /dev/null
@@ -1,126 +0,0 @@
-subroutine genmskhf(msgbits,id,icw,cbb,csync)
-
-!Encode an MSK-HF message, produce baseband waveform and sync vector.
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
-
- complex cbb(0:NZ-1)
- complex csync(0:NZ-1)
- real x(0:NZ-1)
- real y(0:NZ-1)
- real pp(N2)
- logical first
- integer*1 msgbits(KK),codeword(ND)
- integer icw(ND)
- integer id(NS+ND)
- integer isync(26) !Long sync vector
- integer ib13(13) !Barker 13 code
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync,twopi,pp
-
- if(first) then
- n=z'2c1aeb1'
- do i=1,26
- isync(i)=-1
- if(iand(n,1).eq.1) isync(i)=1
- n=n/2
- enddo
-
- twopi=8.0*atan(1.0)
- do i=1,N2 !Half-sine shaped pulse
- pp(i)=sin(0.5*(i-1)*twopi/N2)
- enddo
- first=.false.
- endif
-
- call encode168(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1
-
-! Message structure: R1 26*(S1+D1) S13 26*(D1+S1) R1
-! Generate QPSK without any offset; then shift the y array to get OQPSK.
-
-! Do the I channel first: results in array x
- n=0
- k=0
- ia=0
- ib=NSPS-1
- x(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,26 !Insert group of 26*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- enddo
-
- do j=1,13 !Insert Barker 13 code
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*ib13(j)
- x(ia:ib)=ib13(j)*pp
- enddo
-
- do j=1,26 !Insert group of 26*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- x(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
-
-! Now do the Q channel: results in array y
- ia=0
- ib=NSPS-1
- y(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,116
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- y(ia:ib)=id(n)*pp
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- y(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
- y=cshift(y,-NSPS) !Shift Q array to get OQPSK
- cbb=cmplx(x,y) !Complex baseband waveform
-
- ib=NSPS-1
- ib2=NSPS-1+64*N2
- do j=1,26 !Zero all data symbols in x
- ia=ib+1+N2
- ib=ia+N2-1
- x(ia:ib)=0.
- ia2=ib2+1+N2
- ib2=ia2+N2-1
- x(ia2:ib2)=0.
- enddo
- csync=x
-
- return
-end subroutine genmskhf
diff --git a/lib/fsk4hf/genwspr5.f90 b/lib/fsk4hf/genwspr5.f90
deleted file mode 100644
index e09bcd6f..00000000
--- a/lib/fsk4hf/genwspr5.f90
+++ /dev/null
@@ -1,107 +0,0 @@
-subroutine genwspr5(msg,msgsent,itone)
-
-! Encode a WSPR-LF message, producing array itone().
-
- use crc
- include 'wsprlf_params.f90'
-
- character*22 msg,msgsent
- character*60 cbits
- integer*1,target :: idat(9)
- integer*1 msgbits(KK),codeword(ND)
- logical first
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer itone(NN)
- integer*8 n8
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync
-
- if(first) then
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
- icrc=crc10(c_loc(idat),9) !Compute the 10-bit CRC
- idat(8)=icrc/256 !Insert CRC into idat(8:9)
- idat(9)=iand(icrc,255)
- call wqdecode(idat,msgsent,itype)
-
- write(cbits,1004) idat(1:6),id7,icrc
-1004 format(6b8.8,b2.2,b10.10)
- read(cbits,1006) msgbits
-1006 format(60i1)
-
-! call chkcrc10(msgbits,nbadcrc)
-! print*,msgsent,itype,crc10_check(c_loc(idat),9),nbadcrc
-
- call encode300(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1 !NRZ codeword
-
-! Message structure:
-! I channel: R1 48*(S1+D1) S13 48*(D1+S1) R1
-! Q channel: R1 D204 R1
-! Generate QPSK with no offset, then shift the y array to get OQPSK.
-
-! I channel:
- n=0
- k=0
- do j=1,48 !Insert group of 48*(S1+D1)
- n=n+1
- id(n)=2*isync(j)
- k=k+1
- n=n+1
- id(n)=icw(k)
- enddo
-
- do j=1,13 !Insert Barker 13 code
- n=n+1
- id(n)=2*ib13(j)
- enddo
-
- do j=1,48 !Insert group of 48*(S1+D1)
- k=k+1
- n=n+1
- id(n)=icw(k)
- n=n+1
- id(n)=2*isync(j)
- enddo
-
-! Q channel
- do j=1,204
- k=k+1
- n=n+1
- id(n)=icw(k)
- enddo
-
-! Map I and Q to tones.
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz-1
- jd(2*j-1)=id(j)/abs(id(j))
- jd(2*j)=id(j+jz)/abs(id(j+jz))
- enddo
- jd(NS+ND)=id(jz)/abs(id(jz))
- itone=0
- do j=1,jz-1
- itone(2*j+1)=(jd(2*j)*jd(2*j-1)+1)/2;
- itone(2*j+2)=-(jd(2*j)*jd(2*j+1)-1)/2;
- enddo
- itone(NS+ND+2)=jd(NS+ND) !### Is this correct ??? ###
-
- return
-end subroutine genwspr5
diff --git a/lib/fsk4hf/genwspr_fsk8.f90 b/lib/fsk4hf/genwspr_fsk8.f90
deleted file mode 100644
index 2ef6ace3..00000000
--- a/lib/fsk4hf/genwspr_fsk8.f90
+++ /dev/null
@@ -1,45 +0,0 @@
-subroutine genwspr_fsk8(msg,msgsent,itone)
-
-! Encode a WSPR-LF 8-FSK message, producing array itone().
-
- use crc
- include 'wspr_fsk8_params.f90'
-
- character*22 msg,msgsent
- character*60 cbits
- integer*1,target :: idat(9)
- integer*1 msgbits(KK),codeword(3*ND)
- integer itone(NN)
- integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
- icrc=crc10(c_loc(idat),9) !Compute the 10-bit CRC
- idat(8)=icrc/256 !Insert CRC into idat(8:9)
- idat(9)=iand(icrc,255)
- call wqdecode(idat,msgsent,itype)
-
- write(cbits,1004) idat(1:6),id7,icrc
-1004 format(6b8.8,b2.2,b10.10)
- read(cbits,1006) msgbits
-1006 format(60i1)
-
-! call chkcrc10(msgbits,nbadcrc)
-! print*,msgsent,itype,crc10_check(c_loc(idat),9),nbadcrc
-
- call encode300(msgbits,codeword) !Encode the test message
-
-! Message structure: S7 D100 S7
- itone(1:7)=icos7
- itone(NN-6:NN)=icos7
- do j=1,ND
- i=3*j -2
- itone(j+7)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
- enddo
-
- return
-end subroutine genwspr_fsk8
diff --git a/lib/fsk4hf/genwsprcpm.f90 b/lib/fsk4hf/genwsprcpm.f90
deleted file mode 100644
index 49d30a25..00000000
--- a/lib/fsk4hf/genwsprcpm.f90
+++ /dev/null
@@ -1,70 +0,0 @@
-subroutine genwsprcpm(msg,msgsent,itone)
-
-! Encode a WSPRCPM message, producing array itone().
-!
- use crc
- include 'wsprcpm_params.f90'
-
- character*22 msg,msgsent
- character*64 cbits
- character*32 sbits
- integer iuniqueword0
- integer*1,target :: idat(9)
- integer*1 msgbits(68),codeword(ND)
- logical first
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer ipreamble(16) !Freq estimation preamble
- integer isync(200) !Long sync vector
- integer itone(NN)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data first/.true./
- data iuniqueword0/z'30C9E8AD'/
- save first,isync,ipreamble
-
- if(first) then
- write(sbits,'(b32.32)') iuniqueword0
- read(sbits,'(32i1)') isync(1:32)
- read(sbits,'(32i1)') isync(33:64)
- read(sbits,'(32i1)') isync(65:96)
- read(sbits,'(32i1)') isync(97:128)
- read(sbits,'(32i1)') isync(129:160)
- read(sbits,'(32i1)') isync(161:192)
- read(sbits,'(8i1)') isync(193:200)
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
-write(*,*) 'idat ',idat
- icrc=crc14(c_loc(idat),9)
-write(*,*) 'icrc: ',icrc
-write(*,'(a6,b16.16)') 'icrc: ',icrc
- call wqdecode(idat,msgsent,itype)
- print*,msgsent,itype
- write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
-1004 format(6b8.8,b2.2,b14.14)
- msgbits=0
- read(cbits,1006) msgbits(1:64)
-1006 format(64i1)
-
-write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
-
- call encode204(msgbits,codeword) !Encode the test message
-
-! Message structure:
-! d100 p16 d100
- itone(1:100)=isync(1:100)+2*codeword(1:100)
- itone(101:116)=ipreamble+1
- itone(117:216)=isync(101:200)+2*codeword(101:200)
- itone=2*itone-3
- do i=1,216
- write(*,*) i,itone(i)
- enddo
-
- return
-end subroutine genwsprcpm
diff --git a/lib/fsk4hf/genwsprdpsk.f90 b/lib/fsk4hf/genwsprdpsk.f90
deleted file mode 100644
index 1b6c58b1..00000000
--- a/lib/fsk4hf/genwsprdpsk.f90
+++ /dev/null
@@ -1,63 +0,0 @@
-subroutine genwsprdpsk(msg,msgsent,imsgde)
-
-! Encode a WSPRDPSK message, producing array txwave().
-!
- use crc
- include 'wsprdpsk_params.f90'
-
- character*22 msg,msgsent
- character*64 cbits
- character*32 sbits
- integer iuniqueword0
- integer*1,target :: idat(9)
- integer*1 msgbits(68),codeword(ND)
- logical first
- integer ipreamble(16) !Freq estimation preamble
- integer isync(32) !Long sync vector
- integer imsg(NN),imsgde(NN)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data first/.true./
- data iuniqueword0/z'30C9E8AD'/
- save first,isync,ipreamble
-
- if(first) then
- write(sbits,'(b32.32)') iuniqueword0
- read(sbits,'(32i1)') isync(1:32)
- first=.false.
- endif
-
- idat=0
- call wqencode(msg,ntype0,idat) !Source encoding
- id7=idat(7)
- if(id7.lt.0) id7=id7+256
- id7=id7/64
-write(*,*) 'idat ',idat
- icrc=crc14(c_loc(idat),9)
-write(*,*) 'icrc: ',icrc
-write(*,'(a6,b16.16)') 'icrc: ',icrc
- call wqdecode(idat,msgsent,itype)
- print*,msgsent,itype
- write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
-1004 format(6b8.8,b2.2,b14.14)
- msgbits=0
- read(cbits,1006) msgbits(1:64)
-1006 format(64i1)
-
-write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
-
- call encode204(msgbits,codeword) !Encode the test message
-
- imsg(1)=1 !reference bit
- imsg(2:101)=codeword(1:100)
- imsg(102:132)=isync(1:31) !only use 31 of the sync bits
- imsg(133:232)=codeword(101:200)
-write(*,'(232i1)') imsg(1:232)
- imsgde(1)=1
- do i=2,232
- imsgde(i)=mod(imsgde(i-1)+imsg(i),2)
- enddo
-
-write(*,*) '-------------'
-write(*,'(232i1)') imsgde(1:232)
- return
-end subroutine genwsprdpsk
diff --git a/lib/fsk4hf/genwsprlf.f90 b/lib/fsk4hf/genwsprlf.f90
deleted file mode 100644
index 4c5b31cf..00000000
--- a/lib/fsk4hf/genwsprlf.f90
+++ /dev/null
@@ -1,137 +0,0 @@
-subroutine genwsprlf(msgbits,id,icw,cbb,csync,itone)
-
-!Encode a WSPR-LF message, produce baseband waveform and sync vector.
-
- include 'wsprlf_params.f90'
-
- complex cbb(0:NZ-1)
- complex csync(0:NZ-1)
- real x(0:NZ-1)
- real y(0:NZ-1)
- real pp(N2)
- logical first
- integer*1 msgbits(KK),codeword(ND)
- integer icw(ND)
- integer id(NS+ND)
- integer jd(NS+ND)
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer itone(NN)
- integer*8 n8
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
- data first/.true./
- save first,isync,twopi,pp
-
- if(first) then
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
-
- twopi=8.0*atan(1.0)
- do i=1,N2 !Half-sine shaped pulse
- pp(i)=sin(0.5*(i-1)*twopi/N2)
- enddo
- first=.false.
- endif
-
- call encode300(msgbits,codeword) !Encode the test message
- icw=2*codeword - 1
-
-! Message structure: R1 48*(S1+D1) S13 48*(D1+S1) R1
-! Generate QPSK without any offset; then shift the y array to get OQPSK.
-
-! Do the I channel first: results in array x
- n=0
- k=0
- ia=0
- ib=NSPS-1
- x(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,48 !Insert group of 48*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- enddo
-
- do j=1,13 !Insert Barker 13 code
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*ib13(j)
- x(ia:ib)=ib13(j)*pp
- enddo
-
- do j=1,48 !Insert group of 48*(S1+D1)
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- x(ia:ib)=id(n)*pp !Insert data bit
- ia=ib+1
- ib=ia+N2-1
- n=n+1
- id(n)=2*isync(j)
- x(ia:ib)=isync(j)*pp !Insert Sync bit
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- x(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
-
-! Now do the Q channel: results in array y
- ia=0
- ib=NSPS-1
- y(ia:ib)=0. !Ramp up (half-symbol; shape TBD)
- do j=1,204
- ia=ib+1
- ib=ia+N2-1
- k=k+1
- n=n+1
- id(n)=icw(k)
- y(ia:ib)=id(n)*pp
- enddo
- ia=ib+1
- ib=ia+NSPS-1
- y(ia:ib)=0. !Ramp down (half-symbol; shape TBD)
- y=cshift(y,-NSPS) !Shift Q array to get OQPSK
- cbb=cmplx(x,y) !Complex baseband waveform
-
- ib=NSPS-1
- ib2=NSPS-1+64*N2
- do j=1,48 !Zero all data symbols in x
- ia=ib+1+N2
- ib=ia+N2-1
- x(ia:ib)=0.
- ia2=ib2+1+N2
- ib2=ia2+N2-1
- x(ia2:ib2)=0.
- enddo
- csync=x
-
-! Map I and Q to tones.
- n=0
- jz=(NS+ND+1)/2
- do j=1,jz-1
- jd(2*j-1)=id(j)/abs(id(j))
- jd(2*j)=id(j+jz)/abs(id(j+jz))
- enddo
- jd(NS+ND)=id(jz)/abs(id(jz))
- itone=0
- do j=1,jz-1
- itone(2*j-1)=(jd(2*j)*jd(2*j-1)+1)/2;
- itone(2*j)=-(jd(2*j)*jd(2*j+1)-1)/2;
- enddo
- itone(NS+ND)=jd(NS+ND) !### Is this correct ??? ###
-
- return
-end subroutine genwsprlf
diff --git a/lib/fsk4hf/getfc1.f90 b/lib/fsk4hf/getfc1.f90
deleted file mode 100644
index b82b0303..00000000
--- a/lib/fsk4hf/getfc1.f90
+++ /dev/null
@@ -1,58 +0,0 @@
-subroutine getfc1(c,fc1)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
-
- nspec=NZ/NFFT1
- fs=12000.0/72.0
- df1=fs/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*N2
- ib=ia+N2-1
- c2(0:N2-1)=c(ia:ib)
- c2(N2:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
-! call smo121(s,NFFT1)
- smax=0.
- ipk=0
- fc1=0.
- ia=nint(40.0/df1)
- do i=-ia,ia
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc1=f
- endif
-! write(51,3001) f,s(i),db(s(i))
-! 3001 format(f10.3,e12.3,f10.3)
- enddo
-
-! The following is for testing SNR calibration:
-! sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise
-! base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin
-! psig=sp3n-3*base !Sig only
-! pnoise=(2500.0/df1)*base !Noise in 2500 Hz
-! xsnrdb=db(psig/pnoise)
-
- return
-end subroutine getfc1
diff --git a/lib/fsk4hf/getfc1w.f90 b/lib/fsk4hf/getfc1w.f90
deleted file mode 100644
index 532b9837..00000000
--- a/lib/fsk4hf/getfc1w.f90
+++ /dev/null
@@ -1,47 +0,0 @@
-subroutine getfc1w(c,fs,fa,fb,fc1,xsnr)
-
- include 'wsprlf_params.f90'
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
- nspec=NZ/NFFT1
- df1=fs/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*N2
- ib=ia+N2-1
- c2(0:N2-1)=c(ia:ib)
- c2(N2:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
-! call smo121(s,NFFT1)
- smax=0.
- ipk=0
- fc1=0.
- ia=nint(fa/df1)
- ib=nint(fb/df1)
- do i=ia,ib
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc1=f
- endif
-! write(51,3001) f,s(i),db(s(i))
-! 3001 format(f10.3,e12.3,f10.3)
- enddo
-
-! The following is for testing SNR calibration:
- sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise
- base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin
- psig=sp3n-3*base !Sig only
- pnoise=(2500.0/df1)*base !Noise in 2500 Hz
- xsnr=db(psig/pnoise)
-
- return
-end subroutine getfc1w
diff --git a/lib/fsk4hf/getfc2.f90 b/lib/fsk4hf/getfc2.f90
deleted file mode 100644
index 9506168d..00000000
--- a/lib/fsk4hf/getfc2.f90
+++ /dev/null
@@ -1,74 +0,0 @@
-subroutine getfc2(c,csync,fc1,fc2,fc3)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex cs(0:NZ-1) !For computing spectrum
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- real a(5)
-
- fs=12000.0/72.0
- df=fs/NZ
- baud=fs/NSPS
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
-
-! Filter, square, then FFT to get refined carrier frequency fc2.
- call four2a(cs,NZ,1,-1,1) !To freq domain
- ia=nint(0.75*baud/df)
- cs(ia:NZ-1-ia)=0. !Save only freqs around fc1
- call four2a(cs,NZ,1,1,1) !Back to time domain
- cs=cs/NZ
- cs=cs*cs !Square the data
- call four2a(cs,NZ,1,-1,1) !Compute squared spectrum
-
-! Find two peaks separated by baud
- pmax=0.
- fc2=0.
- ic=nint(baud/df)
- ja=nint(0.5*baud/df)
- do j=-ja,ja
- f2=j*df
- ia=nint((f2-0.5*baud)/df)
- if(ia.lt.0) ia=ia+NZ
- ib=nint((f2+0.5*baud)/df)
- p=real(cs(ia))**2 + aimag(cs(ia))**2 + &
- real(cs(ib))**2 + aimag(cs(ib))**2
- if(p.gt.pmax) then
- pmax=p
- fc2=0.5*f2
- endif
-! write(52,1200) f2,p,db(p)
-!1200 format(f10.3,2f15.3)
- enddo
-
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
- cs=cs*conjg(csync)
- call four2a(cs,NZ,1,-1,1) !To freq domain
- pmax=0.
- do i=0,NZ-1
- f=i*df
- if(i.gt.NZ/2) f=(i-NZ)*df
- p=real(cs(i))**2 + aimag(cs(i))**2
-! write(51,3001) f,p,db(p)
-!3001 format(f10.3,e12.3,f10.3)
- if(p.gt.pmax) then
- pmax=p
- fc3=f
- endif
- enddo
-
- return
-end subroutine getfc2
diff --git a/lib/fsk4hf/getfc2w.f90 b/lib/fsk4hf/getfc2w.f90
deleted file mode 100644
index 0d100ee5..00000000
--- a/lib/fsk4hf/getfc2w.f90
+++ /dev/null
@@ -1,82 +0,0 @@
-subroutine getfc2w(c,csync,npeaks,fs,fc1,fpks)
-
- include 'wsprlf_params.f90'
-
- complex c(0:NZ-1) !Complex waveform
- complex cs(0:NZ-1) !For computing spectrum
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- real a(5)
- real freqs(413),sp2(413),fpks(npeaks)
- integer pkloc(1)
-
- df=fs/NZ
- baud=fs/NSPS
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
-
-! Filter, square, then FFT to get refined carrier frequency fc2.
- call four2a(cs,NZ,1,-1,1) !To freq domain
-
- ia=nint(0.75*baud/df)
- cs(ia:NZ-1-ia)=0. !Save only freqs around fc1
- call four2a(cs,NZ,1,1,1) !Back to time domain
- cs=cs/NZ
- cs=cs*cs !Square the data
- call four2a(cs,NZ,1,-1,1) !Compute squared spectrum
-
-! Find two peaks separated by baud
- pmax=0.
- fc2=0.
- ja=nint(0.3*baud/df)
- k=1
- do j=-ja,ja
- f2=j*df
- ia=nint((f2-0.5*baud)/df)
- if(ia.lt.0) ia=ia+NZ
- ib=nint((f2+0.5*baud)/df)
- p=real(cs(ia))**2 + aimag(cs(ia))**2 + &
- real(cs(ib))**2 + aimag(cs(ib))**2
- if(p.gt.pmax) then
- pmax=p
- fc2=0.5*f2
- endif
- freqs(k)=0.5*f2
- sp2(k)=p
- k=k+1
-! write(52,1200) f2,p,db(p)
-!1200 format(f10.3,2f15.3)
- enddo
-
- do i=1,npeaks
- pkloc=maxloc(sp2)
- ipk=pkloc(1)
- fpks(i)=freqs(ipk)
- ipk0=max(1,ipk-1)
- ipk1=min(413,ipk+1)
-! ipk0=ipk
-! ipk1=ipk
- sp2(ipk0:ipk1)=0.0
-!write(*,*) i,fpks(i),fc2
- enddo
-
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
- cs=cs*conjg(csync)
- call four2a(cs,NZ,1,-1,1) !To freq domain
- pmax=0.
- do i=0,NZ-1
- f=i*df
- if(i.gt.NZ/2) f=(i-NZ)*df
- p=real(cs(i))**2 + aimag(cs(i))**2
-! write(51,3001) f,p,db(p)
-!3001 format(f10.3,e12.3,f10.3)
- if(p.gt.pmax) then
- pmax=p
- fc3=f
- endif
- enddo
-
- return
-end subroutine getfc2w
diff --git a/lib/fsk4hf/gran.c b/lib/fsk4hf/gran.c
deleted file mode 100644
index 24b98650..00000000
--- a/lib/fsk4hf/gran.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-
-/* Generate gaussian random float with mean=0 and std_dev=1 */
-float gran_()
-{
- float fac,rsq,v1,v2;
- static float gset;
- static int iset;
-
- if(iset){
- /* Already got one */
- iset = 0;
- return gset;
- }
- /* Generate two evenly distributed numbers between -1 and +1
- * that are inside the unit circle
- */
- do {
- v1 = 2.0 * (float)rand() / RAND_MAX - 1;
- v2 = 2.0 * (float)rand() / RAND_MAX - 1;
- rsq = v1*v1 + v2*v2;
- } while(rsq >= 1.0 || rsq == 0.0);
- fac = sqrt(-2.0*log(rsq)/rsq);
- gset = v1*fac;
- iset++;
- return v2*fac;
-}
diff --git a/lib/fsk4hf/ldpc_204_68_params.f90 b/lib/fsk4hf/ldpc_204_68_params.f90
deleted file mode 100644
index 6e75ef11..00000000
--- a/lib/fsk4hf/ldpc_204_68_params.f90
+++ /dev/null
@@ -1,154 +0,0 @@
-integer, parameter:: N=204, K=68, M=N-K
-character*17 g(136)
-integer colorder(N)
-data g/ & !parity generator matrix for (204,68) code
- "2de7435fd27c0031d", &
- "f331b40671e20ea80", &
- "48bd3f8cb9a24392f", &
- "d4ed71c935162aa2a", &
- "c437a3284ec58bce7", &
- "35a806dd5be35627c", &
- "396e797c33a4739a6", &
- "768f331a59c15487b", &
- "c214eac24ae5e1732", &
- "0b5c53ff3a6da1192", &
- "99624981d2703fb97", &
- "e9f5447ef7f1ff6af", &
- "bd8c730f0cfdf0727", &
- "26f61e63e1e098f7f", &
- "ef826566137b6526f", &
- "af0e4fa251e9b4926", &
- "75974a8b2a24292c5", &
- "71caf0f2cd10f6d4f", &
- "b1103f1f26e6898b7", &
- "67ceb7d6f490da64f", &
- "ee0e8fbefec23008a", &
- "11cc2227e8bd676ca", &
- "6e71626ba1e278046", &
- "005d28da267e50e13", &
- "a9ae4a130aaba8219", &
- "d8ab72e0158d0da70", &
- "56009d42b37bd66ff", &
- "c39a75eca99b0e996", &
- "6886de0bf7c0bf4bb", &
- "1046cd8f64162f7b5", &
- "da0f15843ac21e3a5", &
- "e9bf9cd19f3db3913", &
- "2fb9cb42d650f47a7", &
- "a2b6c5a378fa75a65", &
- "41a88f3cd60b79d6c", &
- "fcf175794cc3ac96a", &
- "8677a3447d40a9f71", &
- "97a1f08c250b4bf12", &
- "0168f090a1df6e8ea", &
- "418a06bf372cc67d9", &
- "0f17b880c1ff51239", &
- "b2afd6d585deb961b", &
- "60298ac5b58dbeee0", &
- "8350c03c40119feff", &
- "b29c964a8accf6af4", &
- "9b46f036a5c178b5d", &
- "917398bff051c300a", &
- "5e52c03b2f8c5128c", &
- "beae6c33c87ba38ab", &
- "20843f7b056a02ebf", &
- "66690d65acd9de598", &
- "8f025841af5b54331", &
- "b43cd869d3be2c3db", &
- "c9c342fe63c18df50", &
- "d331b40671e28ea80", &
- "62406a0f4947e6ce9", &
- "d67b1495883b22e1b", &
- "734534c372408895b", &
- "d88750e33d9677dcd", &
- "6f96964da55138687", &
- "80bee98bb75d50ef2", &
- "c428ef3e3f06f4c56", &
- "b1a1499b125883a35", &
- "ac892d4b37fa9e395", &
- "458dbda0f95ab11a5", &
- "6f93c9e95b1094eed", &
- "2e370d713914f848e", &
- "758806dd5be35627c", &
- "8c52e01caec798b49", &
- "c286cc25bae3669cf", &
- "87c56fb895c100884", &
- "e89cb1376a18fd911", &
- "156ffe5f30dc354e0", &
- "f20d0b121d6a6b3ee", &
- "7db08891b491a95d2", &
- "191fac548d5077bdf", &
- "023a37d7ea5660bbc", &
- "6781668b363fee682", &
- "bbfaf262cab7370da", &
- "feea557965b7e474f", &
- "c094eb223e1d305b8", &
- "2be051abdd5beea35", &
- "0790449880fda9d00", &
- "f9029a39ec869e7b4", &
- "5a29f48926ec9a552", &
- "e0463306dc1470f87", &
- "9251058334d790f86", &
- "3019e1d4578e8a4dc", &
- "887e46631502fa111", &
- "c25fcd7a42465d326", &
- "cf64bcc1056b555c4", &
- "3e71c0fe5f0ad733b", &
- "11055ec43b076e5b2", &
- "3440f64dfa3c30a96", &
- "2b73885b4d3299f60", &
- "2e71627ba1e268046", &
- "ad23743d5e6e5b80c", &
- "c9757b05f29bfdc10", &
- "f7112bea739247b51", &
- "3664062387998b2b1", &
- "90897a3b8785aefba", &
- "29e126e3201fc1d46", &
- "96c9001c84d5257fc", &
- "067723447d40a9f71", &
- "1a019cc68f7511402", &
- "4bd48eb2330032763", &
- "d139a5da936b37647", &
- "765ab46a4dec5f04f", &
- "706f475ad19b91955", &
- "1755c988fa8a55e5c", &
- "2fd9ed5777eb01d6a", &
- "bec27d85b954d3fe8", &
- "7135a3b92c45b3f8d", &
- "353237872f002163a", &
- "e31e4a97aef10c729", &
- "da527d5e1cbc4edb6", &
- "6e33cdede17c3207e", &
- "ef2d2062e84dc401f", &
- "8217c84c50c1bf833", &
- "12ffbac7b2219c9e0", &
- "3729178706f66881f", &
- "2fdd748c382a608a1", &
- "dd0a00076f9dcec73", &
- "46b1d37bced447035", &
- "7316f33a9c05ef178", &
- "152c39a6de8954cc3", &
- "16efffb7b62e12ba3", &
- "9d9ec2bb467affd83", &
- "467723445d40a9f61", &
- "87994762b3bf50697", &
- "b1bfa5b51526dde9b", &
- "b0a6a19d709a96148", &
- "990d567c0aba31a14", &
- "171f190792461b1e0", &
- "166011c27d2b6b8a4", &
- "170c15831244ae73e"/
-
-data colorder/ &
- 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, &
- 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, &
- 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, &
- 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, &
- 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, &
- 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, &
- 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, &
- 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, &
- 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, &
- 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, &
- 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, &
- 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/
diff --git a/lib/fsk4hf/ldpc_300_60_params.f90 b/lib/fsk4hf/ldpc_300_60_params.f90
deleted file mode 100644
index 53ee994e..00000000
--- a/lib/fsk4hf/ldpc_300_60_params.f90
+++ /dev/null
@@ -1,262 +0,0 @@
-integer, parameter:: N=300, K=60, M=N-K
-character*15 g(M)
-integer colorder(N)
-data g/ &
- "316fd3bb18bcefd", &
- "a9c1c984f91244e", &
- "9e04bd3d5d78d89", &
- "f81617089621bd4", &
- "12997ce2f44dbf4", &
- "3ebddaf9b0fa1fc", &
- "d0c114b0b0ef162", &
- "f8c4f115f98bd92", &
- "d0a79c0c5b8ca19", &
- "477f6712f357b3b", &
- "fa28b2444a7e66b", &
- "bedcd4df8d95c64", &
- "da30de73e57022c", &
- "bc099bbb90fe09e", &
- "cffc1e47e5708e8", &
- "713d808563ca9a3", &
- "70fcf1741d5d5d7", &
- "32e80bc15112008", &
- "804cef4df9b18ec", &
- "3736881819d1033", &
- "f4e37db7f9c5efe", &
- "9e84b93d4d78d09", &
- "2250c3518ec830a", &
- "55a529a92e18021", &
- "1cb80b14c9f6eae", &
- "80c504b031ef926", &
- "ece6636d0ac9c6d", &
- "5d50a1690782cd0", &
- "3d54a1fb30937a2", &
- "ba8fe8006318041", &
- "02917ce2fc45bf4", &
- "abc1d984f95a44e", &
- "fc05b4c4ab2d850", &
- "467f7718f357b3b", &
- "472cc094546c6b2", &
- "fcdd94cf8c9cc64", &
- "4dbc1647e970cc8", &
- "6caa465c442aed1", &
- "aead5af8b0da1be", &
- "d8e1fa45a2e8431", &
- "9d4dc4cc63abb7f", &
- "9b2df6b48264637", &
- "7335808563ca3a3", &
- "36bf8d5cd93e6cc", &
- "004ccf4db9b08ec", &
- "90a71c8c598ca19", &
- "f8c5d115f90bc92", &
- "b95546c4e3f7934", &
- "7d50a1690786cd0", &
- "c90939921a0d7c6", &
- "d0c504b030ef126", &
- "ce3e6f9396fc542", &
- "a0072a59f3707f5", &
- "532d0a8fe3da1ea", &
- "68b9e5cd7d142db", &
- "fedc94df8c9dc64", &
- "6da2465c448aed0", &
- "3574aa19cb273c0", &
- "1e54768c6bc6843", &
- "691f65654498186", &
- "fe2c92444a6ef6b", &
- "9caad933e038cc4", &
- "ad4e6f4defb28ec", &
- "4f3d80947c6d2b2", &
- "1caad933e0b8cc4", &
- "b14fd3bf18bcafd", &
- "ad091bbbb0f809e", &
- "90b71c8c598da19", &
- "f8c4d115f90bd92", &
- "9d4dcccc63afb7f", &
- "fa2c92444a6e76b", &
- "1e14768c6bc6c43", &
- "d1baf5aacb86087", &
- "bdf762b92ee51c7", &
- "caacec06ad8a90c", &
- "804ccf4df9b08ec", &
- "69e969f9da5cbd8", &
- "814ccf4df9b086c", &
- "cebe4f9796f4542", &
- "491f65654499186", &
- "8fbf5b9796f6d2a", &
- "ce3e4f9396f4542", &
- "47558560e7debc3", &
- "94aadd33e038cc4", &
- "a94eef4debb286e", &
- "d8e5d115f91bcd2", &
- "532d488fe3da0ab", &
- "664e7bc4e23a80c", &
- "94a2dd33a038cd4", &
- "d8c5d115f91bc92", &
- "0fef071eee60bd5", &
- "9a89a09163c2b97", &
- "0eaf071e6c60bd5", &
- "bc0d1bbbb0fe0be", &
- "f9babd3d12d0f31", &
- "69a969f9da5c9d8", &
- "6e4e7bc4e23a82c", &
- "b0042659f3227f5", &
- "2d51418f0f28347", &
- "be0d5bbbb0da0be", &
- "225003508ec8302", &
- "8fbf4b9796f4d2a", &
- "bead5af9b0da1be", &
- "6ca2465c440aed1", &
- "4fbc1e47ed708c8", &
- "bd091bbbb0fc09e", &
- "b0062259f3307f5", &
- "a8072a59f3727f5", &
- "a0062259f3707f5", &
- "3c380b14c974eae", &
- "30042659f3226f5", &
- "48b9e4cd7d142db", &
- "728bcd4b38308fb", &
- "c0c504b031ef126", &
- "314fd3bb18bcafd", &
- "1c29148305faec1", &
- "44c92a9c28ada63", &
- "88e99b370aae32b", &
- "695081690386ad8", &
- "572d0a8de3da1ea", &
- "467f6610f357b2b", &
- "733d008563da1a3", &
- "d1baf4aacb84087", &
- "4315551d71c8ff0", &
- "48bde4cd7d140db", &
- "3ebd58f9b0da9fc", &
- "51baf4aacb84083", &
- "814e4f4de9b082c", &
- "814ecf4de9b086c", &
- "be0d1bbbb0fa0be", &
- "4f7580947c792b3", &
- "cdf2dce48c39c3b", &
- "d8c5c115f91bc12", &
- "a94e6f4debb28ee", &
- "be2d5afbb0da1be", &
- "cdd6dce48439c2b", &
- "bebd5af9b0da1fe", &
- "fa2892444a6e66b", &
- "51bbf4aacb8c083", &
- "baa73d81eebcd83", &
- "79a2ce47f138cc9", &
- "cc28cf198e6dbd4", &
- "fcde94dfcc9cc64", &
- "1016fcf59286717", &
- "12917ce2fc4dbf4", &
- "4fbc1647e9708c8", &
- "3e382b1cc974fae", &
- "d5bafdaad386087", &
- "0fef473eee60bd5", &
- "c0e504b031ee126", &
- "8bbf5b9797f6d2a", &
- "0eef071e6e60bd5", &
- "1806fcf59386517", &
- "fcdc94df8c9cc64", &
- "141eca2bfa25656", &
- "5fbc1767e9708e8", &
- "5aa4c7803a6bdf1", &
- "b14bd3b718bcafd", &
- "3ebd5af9b0da1fc", &
- "d0a7148c5b8ca09", &
- "a94ecf4debb086e", &
- "733d808563ca1a3", &
- "fd9abd1d92d0f31", &
- "bc091bbbb0fe09e", &
- "d0c514b0b0ef122", &
- "4f7d80947c7d2b3", &
- "8b3f5b97b7f6d2a", &
- "4fbc1767e9708c8", &
- "cebf4f9796f4502", &
- "9c76c880a864e67", &
- "abc1c984f95244e", &
- "795081690786ad8", &
- "467f6710f357b3b", &
- "1c380b14c9f4eae", &
- "d5baf5aac386087", &
- "bedc94df8c95c64", &
- "553d0a8de2da1fa", &
- "0315551d71d8ff0", &
- "1c1eca2ffa25656", &
- "d4bafdaad3c6087", &
- "be2d5bfbb0da0be", &
- "b0062659f3207f5", &
- "5ffc1765e9708e8", &
- "8d62e8bcd303e33", &
- "cc08cf198e69bd4", &
- "573d0a8de3da1fa", &
- "cd56dce48639c2b", &
- "472dc094546c2b2", &
- "7950a16907868d8", &
- "7283cf4b38308fb", &
- "894ecf4de9b086e", &
- "0f7580b47c792b3", &
- "cfbf4b9796f4d0a", &
- "3e380b14c974fae", &
- "732d0085e3da1a3", &
- "1816fcf59386717", &
- "532d088fe3da1ab", &
- "1c300b94c9fcaae", &
- "d0a71c8c5b8ca19", &
- "9e84bd3d5d78d09", &
- "225083508ec830a", &
- "f99abd1d12d0f31", &
- "35f4aa19cb673c0", &
- "cdd2dce48c39c2b", &
- "0f7780b47c792bf", &
- "0e33a5f114f5730", &
- "bc05b4c4ab0d850", &
- "1c300b14c9f4aae", &
- "cfbc1e47ed708e8", &
- "0f7180b47c392b3", &
- "d8c7c115f91be12", &
- "c09148adfa94e97", &
- "9c66c880a844e67", &
- "2226c13b73519f8", &
- "cebf4b9796f4d02", &
- "c0e706b031ee126", &
- "6a6629715e53ce3", &
- "73f9aa824e7d0b8", &
- "473d80947c6c2b2", &
- "1df140e0ddb5632", &
- "473dc0945c6c2b2", &
- "81b4d95f671971d", &
- "663945ca758e2b6", &
- "02ec3d98a2306fd", &
- "5dadb0fa1275690", &
- "4bb8aaa854948d0", &
- "8359ba40886971c", &
- "49cc3d2a2be2ee0", &
- "bfdf13af137f318", &
- "a1de773a2b1ff04", &
- "8ff3945a2f465c7", &
- "532d0087e3da1a3", &
- "f3eaf7fa454d385", &
- "a606aa5aeba07d9", &
- "67f0627b0af8a53", &
- "56698bed69d1c2c", &
- "d5f420011fbf924", &
- "2a8f86c810e2c62", &
- "43cc1cf1208c206", &
- "ee784c4900258de"/
-
-data colorder/ &
-0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, &
-19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, &
-37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, &
-125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, &
-181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, &
-79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, &
-88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, &
-132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, &
-205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, &
-206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, &
-200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, &
-118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, &
-240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, &
-260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, &
-280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/
-
diff --git a/lib/fsk4hf/ldpcsim120.f90 b/lib/fsk4hf/ldpcsim120.f90
deleted file mode 100644
index 0b7d9286..00000000
--- a/lib/fsk4hf/ldpcsim120.f90
+++ /dev/null
@@ -1,238 +0,0 @@
-program ldpcsim120
-! End to end test of the (120,60)/crc10 encoder and decoder.
-use crc
-use packjt
-
-parameter(NRECENT=10)
-character*12 recent_calls(NRECENT)
-character*22 msg,msgsent,msgreceived
-character*8 arg
-integer*1, allocatable :: codeword(:), decoded(:), message(:)
-integer*1, target:: i1Msg8BitBytes(9)
-integer*1, target:: i1Dec8BitBytes(9)
-integer*1 msgbits(60)
-integer*1 apmask(120)
-integer*1 cw(120)
-integer*2 checksum
-integer colorder(120)
-integer nerrtot(120),nerrdec(120),nmpcbad(60)
-logical checksumok,fsk,bpsk
-real*8, allocatable :: rxdata(:)
-real, allocatable :: llr(:)
-real dllr(120),llrd(120)
-
-data colorder/ &
- 0,1,2,21,3,4,5,6,7,8,20,10,9,11,12,23,13,28,14,31, &
- 15,16,22,26,17,30,18,29,25,32,41,34,19,33,27,36,38,43,42,24, &
- 37,39,45,40,35,44,47,46,50,51,53,48,52,56,54,57,55,49,58,61, &
- 60,59,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79, &
- 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99, &
- 100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119/
-
-do i=1,NRECENT
- recent_calls(i)=' '
-enddo
-nerrtot=0
-nerrdec=0
-nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword
-
-nargs=iargc()
-if(nargs.ne.3) then
- print*,'Usage: ldpcsim niter #trials s '
- print*,'eg: ldpcsim 10 1000 0.84'
- print*,'If s is negative, then value is ignored and sigma is calculated from SNR.'
- return
-endif
-call getarg(1,arg)
-read(arg,*) max_iterations
-call getarg(2,arg)
-read(arg,*) ntrials
-call getarg(3,arg)
-read(arg,*) s
-
-fsk=.false.
-bpsk=.true.
-
-! don't count crc bits as data bits
-N=120
-K=60
-! scale Eb/No for a (120,50) code
-rate=real(50)/real(N)
-
-write(*,*) "rate: ",rate
-write(*,*) "niter= ",max_iterations," s= ",s
-
-allocate ( codeword(N), decoded(K), message(K) )
-allocate ( rxdata(N), llr(N) )
-
-! The message should be packed into the first 7 bytes
- i1Msg8BitBytes(1:6)=85
- i1Msg8BitBytes(7)=64
-! The CRC will be put into the last 2 bytes
- i1Msg8BitBytes(8:9)=0
- checksum = crc10 (c_loc (i1Msg8BitBytes), 9)
-! For reference, the next 3 lines show how to check the CRC
- i1Msg8BitBytes(8)=checksum/256
- i1Msg8BitBytes(9)=iand (checksum,255)
- checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9)
- if( checksumok ) write(*,*) 'Good checksum'
-write(*,*) i1Msg8BitBytes(1:9)
-
- mbit=0
- do i=1, 7
- i1=i1Msg8BitBytes(i)
- do ibit=1,8
- mbit=mbit+1
- msgbits(mbit)=iand(1,ishft(i1,ibit-8))
- enddo
- enddo
- i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte
- do ibit=1,2
- msgbits(50+ibit)=iand(1,ishft(i1,ibit-2))
- enddo
- i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC
- do ibit=1,8
- msgbits(52+ibit)=iand(1,ishft(i1,ibit-8))
- enddo
-
- write(*,*) 'message'
- write(*,'(9(8i1,1x))') msgbits
-
- call encode120(msgbits,codeword)
- call init_random_seed()
- call sgran()
-
- write(*,*) 'codeword'
- write(*,'(15(8i1,1x))') codeword
-
-write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma"
-do idb = -10, 24
- db=idb/2.0-1.0
-! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No
- sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No
- ngood=0
- nue=0
- nbadcrc=0
- nberr=0
- do itrial=1, ntrials
-! Create a realization of a noisy received word
- do i=1,N
- if( bpsk ) then
- rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
- elseif( fsk ) then
- if( codeword(i) .eq. 1 ) then
- r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r2=(sigma*gran())**2 + (sigma*gran())**2
- elseif( codeword(i) .eq. 0 ) then
- r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r1=(sigma*gran())**2 + (sigma*gran())**2
- endif
- rxdata(i)=0.35*(sqrt(r1)-sqrt(r2))
-! rxdata(i)=0.35*(exp(r1)-exp(r2))
-! rxdata(i)=0.12*(log(r1)-log(r2))
- endif
- enddo
- nerr=0
- do i=1,N
- if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
- enddo
- nerrtot(nerr)=nerrtot(nerr)+1
- nberr=nberr+nerr
-
-! Correct signal normalization is important for this decoder.
-! rxav=sum(rxdata)/N
-! rx2av=sum(rxdata*rxdata)/N
-! rxsig=sqrt(rx2av-rxav*rxav)
-! rxdata=rxdata/rxsig
-! To match the metric to the channel, s should be set to the noise standard deviation.
-! For now, set s to the value that optimizes decode probability near threshold.
-! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
-! magnitude in UER
- if( s .lt. 0 ) then
- ss=sigma
- else
- ss=s
- endif
-
- llr=2.0*rxdata/(ss*ss)
- apmask=0
-
-! max_iterations is max number of belief propagation iterations
- call bpdecode120(llr, apmask, max_iterations, decoded, niterations, cw)
- n2err=0
- do i=1,N
- if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1
- enddo
-!write(*,*) nerr,niterations,n2err
- damp=0.75
- ndither=0
- if( niterations .lt. 0 ) then
- do i=1, ndither
- do in=1,N
- dllr(in)=damp*gran()
- enddo
- llrd=llr+dllr
- call bpdecode120(llrd, apmask, max_iterations, decoded, niterations, cw)
- if( niterations .ge. 0 ) exit
- enddo
- endif
-
-! If the decoder finds a valid codeword, niterations will be .ge. 0.
- if( niterations .ge. 0 ) then
-! Check the CRC
- do ibyte=1,6
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
- i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64
-! Need to pack the received crc into bytes 8 and 9 for crc10_check
- i1Dec8BitBytes(8)=decoded(51)*2+decoded(52)
- i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16
- i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1
- ncrcflag=0
- if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1
-
- if( ncrcflag .ne. 1 ) then
- nbadcrc=nbadcrc+1
- endif
- nueflag=0
-
- nerrmpc=0
- do i=1,K ! find number of errors in message+crc part of codeword
- if( msgbits(i) .ne. decoded(i) ) then
- nueflag=1
- nerrmpc=nerrmpc+1
- endif
- enddo
- nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly
- if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then
- ngood=ngood+1
- nerrdec(nerr)=nerrdec(nerr)+1
- else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then
- nue=nue+1;
- endif
- endif
- enddo
- snr2500=db+10*log10(0.4166/2500.0)
- pberr=real(nberr)/(real(ntrials*N))
- write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
-
-enddo
-
-open(unit=23,file='nerrhisto.dat',status='unknown')
-do i=1,120
- write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
-enddo
-close(23)
-open(unit=25,file='nmpcbad.dat',status='unknown')
-do i=1,60
- write(25,'(i4,2x,i10)') i,nmpcbad(i)
-enddo
-close(25)
-
-
-
-end program ldpcsim120
diff --git a/lib/fsk4hf/ldpcsim168.f90 b/lib/fsk4hf/ldpcsim168.f90
deleted file mode 100644
index a1aee3eb..00000000
--- a/lib/fsk4hf/ldpcsim168.f90
+++ /dev/null
@@ -1,233 +0,0 @@
-program ldpcsim168
-! End to end test of the (168,84)/crc12 encoder and decoder.
-use crc
-use packjt
-
-parameter(NRECENT=10)
-character*12 recent_calls(NRECENT)
-character*22 msg,msgsent,msgreceived
-character*8 arg
-integer*1, allocatable :: codeword(:), decoded(:), message(:)
-integer*1, target:: i1Msg8BitBytes(11)
-integer*1 msgbits(84)
-integer*1 apmask(168), cw(168)
-integer*2 checksum
-integer*4 i4Msg6BitWords(13)
-integer colorder(168)
-integer nerrtot(168),nerrdec(168),nmpcbad(84)
-logical checksumok,fsk,bpsk
-real*8, allocatable :: rxdata(:)
-real, allocatable :: llr(:)
-
-data colorder/0,1,2,3,28,4,5,6,7,8,9,10,11,34,12,32,13,14,15,16,17, &
- 18,36,29,42,31,20,21,41,40,30,38,22,19,47,37,46,35,44,33,49,24, &
- 43,51,25,26,27,50,52,57,69,54,55,45,59,58,56,61,60,53,48,23,62, &
- 63,64,67,66,65,68,39,70,71,72,74,73,75,76,77,80,81,78,82,79,83, &
- 84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104, &
- 105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, &
- 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146, &
- 147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167/
-
-do i=1,NRECENT
- recent_calls(i)=' '
-enddo
-nerrtot=0
-nerrdec=0
-nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword
-
-nargs=iargc()
-if(nargs.ne.3) then
- print*,'Usage: ldpcsim niter #trials s '
- print*,'eg: ldpcsim 10 1000 0.84'
- print*,'If s is negative, then value is ignored and sigma is calculated from SNR.'
- return
-endif
-call getarg(1,arg)
-read(arg,*) max_iterations
-call getarg(2,arg)
-read(arg,*) ntrials
-call getarg(3,arg)
-read(arg,*) s
-
-fsk=.false.
-bpsk=.true.
-
-! don't count crc bits as data bits
-N=168
-K=84
-! scale Eb/No for a (168,72) code
-rate=real(72)/real(N)
-
-write(*,*) "rate: ",rate
-write(*,*) "niter= ",max_iterations," s= ",s
-
-allocate ( codeword(N), decoded(K), message(K) )
-allocate ( rxdata(N), llr(N) )
-
-! msg="K1JT K9AN EN50"
- msg="G4WJS K9AN EN50"
- call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes
- call unpackmsg(i4Msg6BitWords,msgsent,.false.,'') !Unpack to get msgsent
- write(*,*) "message sent ",msgsent
-
- i4=0
- ik=0
- im=0
- do i=1,12
- nn=i4Msg6BitWords(i)
- do j=1, 6
- ik=ik+1
- i4=i4+i4+iand(1,ishft(nn,j-6))
- i4=iand(i4,255)
- if(ik.eq.8) then
- im=im+1
-! if(i4.gt.127) i4=i4-256
- i1Msg8BitBytes(im)=i4
- ik=0
- endif
- enddo
- enddo
-
- i1Msg8BitBytes(10:11)=0
- checksum = crc12 (c_loc (i1Msg8BitBytes), 11)
-! For reference, the next 3 lines show how to check the CRC
- i1Msg8BitBytes(10)=checksum/256
- i1Msg8BitBytes(11)=iand (checksum,255)
- checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11)
- if( checksumok ) write(*,*) 'Good checksum'
-
- mbit=0
- do i=1, 9
- i1=i1Msg8BitBytes(i)
- do ibit=1,8
- mbit=mbit+1
- msgbits(mbit)=iand(1,ishft(i1,ibit-8))
- enddo
- enddo
- i1=i1Msg8BitBytes(10) ! First 4 bits of crc12 are LSB of this byte
- do ibit=1,4
- msgbits(72+ibit)=iand(1,ishft(i1,ibit-4))
- enddo
- i1=i1Msg8BitBytes(11) ! Now shift in last 8 bits of the CRC
- do ibit=1,8
- msgbits(76+ibit)=iand(1,ishft(i1,ibit-8))
- enddo
-
- write(*,*) 'message'
- write(*,'(11(8i1,1x))') msgbits
-
- call encode168(msgbits,codeword)
- call init_random_seed()
- call sgran()
-
- write(*,*) 'codeword'
- write(*,'(21(8i1,1x))') codeword
-
-write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma"
-do idb = 6,-6,-1
- db=idb/2.0-1.0
- sigma=1/sqrt( 2*(10**(db/10.0)) )
- ngood=0
- nue=0
- nbadcrc=0
- nberr=0
- do itrial=1, ntrials
-! Create a realization of a noisy received word
- do i=1,N
- if( bpsk ) then
- rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
- elseif( fsk ) then
- if( codeword(i) .eq. 1 ) then
- r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r2=(sigma*gran())**2 + (sigma*gran())**2
- elseif( codeword(i) .eq. 0 ) then
- r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r1=(sigma*gran())**2 + (sigma*gran())**2
- endif
- rxdata(i)=0.35*(sqrt(r1)-sqrt(r2))
-! rxdata(i)=0.35*(exp(r1)-exp(r2))
-! rxdata(i)=0.12*(log(r1)-log(r2))
- endif
- enddo
- nerr=0
- do i=1,N
- if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1
- enddo
- nerrtot(nerr)=nerrtot(nerr)+1
- nberr=nberr+nerr
-
-! Correct signal normalization is important for this decoder.
-! rxav=sum(rxdata)/N
-! rx2av=sum(rxdata*rxdata)/N
-! rxsig=sqrt(rx2av-rxav*rxav)
-! rxdata=rxdata/rxsig
-! To match the metric to the channel, s should be set to the noise standard deviation.
-! For now, set s to the value that optimizes decode probability near threshold.
-! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
-! magnitude in UER
- if( s .lt. 0 ) then
- ss=sigma
- else
- ss=s
- endif
-
- llr=2.0*rxdata/(ss*ss)
- nap=0 ! number of AP bits
- llr(colorder(168-84+1:168-84+nap)+1)=5*(2.0*msgbits(1:nap)-1.0)
- apmask=0
- apmask(colorder(168-84+1:168-84+nap)+1)=1
-
-! max_iterations is max number of belief propagation iterations
- call bpdecode168(llr, apmask, max_iterations, decoded, niterations)
-! if( niterations .eq. -1 ) then
-! norder=3
-! call osd168(llr, norder, decoded, niterations, cw)
-! endif
-! If the decoder finds a valid codeword, niterations will be .ge. 0.
- if( niterations .ge. 0 ) then
- call extractmessage168(decoded,msgreceived,ncrcflag,recent_calls,nrecent)
- if( ncrcflag .ne. 1 ) then
- nbadcrc=nbadcrc+1
- endif
-
- nueflag=0
- nerrmpc=0
- do i=1,K ! find number of errors in message+crc part of codeword
- if( msgbits(i) .ne. decoded(i) ) then
- nueflag=1
- nerrmpc=nerrmpc+1
- endif
- enddo
-
-write(37,*) niterations, ncrcflag, nueflag
- nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1
- if( ncrcflag .eq. 1 ) then
- if( nueflag .eq. 0 ) then
- ngood=ngood+1
- nerrdec(nerr)=nerrdec(nerr)+1
- else if( nueflag .eq. 1 ) then
- nue=nue+1;
- endif
- endif
- endif
- enddo
- snr2500=db+10*log10(10.417/2500.0)
- pberr=real(nberr)/(real(ntrials*N))
- write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
-
-enddo
-
-open(unit=23,file='nerrhisto.dat',status='unknown')
-do i=1,168
- write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
-enddo
-close(23)
-open(unit=25,file='nmpcbad.dat',status='unknown')
-do i=1,84
- write(25,'(i4,2x,i10)') i,nmpcbad(i)
-enddo
-close(25)
-
-
-
-end program ldpcsim168
diff --git a/lib/fsk4hf/ldpcsim204.f90 b/lib/fsk4hf/ldpcsim204.f90
deleted file mode 100644
index 794b1476..00000000
--- a/lib/fsk4hf/ldpcsim204.f90
+++ /dev/null
@@ -1,249 +0,0 @@
-program ldpcsim204
-
-! End-to-end test of the (300,60)/crc10 encoder and decoders.
-
-use crc
-use packjt
-
-parameter(NRECENT=10)
-character*12 recent_calls(NRECENT)
-character*8 arg
-integer*1, allocatable :: codeword(:), decoded(:), message(:)
-integer*1, target:: i1Msg8BitBytes(9)
-integer*1, target:: i1Dec8BitBytes(9)
-integer*1 msgbits(68)
-integer*1 apmask(204)
-integer*1 cw(204)
-integer*2 checksum
-integer colorder(204)
-integer nerrtot(204),nerrdec(204),nmpcbad(68)
-logical checksumok,fsk,bpsk
-real*8, allocatable :: rxdata(:)
-real, allocatable :: llr(:)
-real dllr(204),llrd(204)
-
-data colorder/ &
- 0, 1, 2, 3, 4, 5, 47, 6, 7, 8, 9, 10, 11, 12, 58, 55, 13, &
- 14, 15, 46, 17, 18, 60, 19, 20, 21, 22, 23, 24, 25, 57, 26, 27, 49, &
- 28, 52, 65, 16, 50, 73, 59, 68, 63, 29, 30, 31, 32, 51, 62, 56, 66, &
- 45, 33, 34, 53, 67, 35, 36, 37, 61, 69, 54, 38, 71, 82, 39, 77, 80, &
- 83, 78, 84, 48, 41, 85, 40, 64, 75, 96, 74, 72, 76, 86, 87, 89, 90, &
- 79, 70, 92, 99, 93,101, 95,100, 97, 94, 42, 98,103,105,102, 43,104, &
- 88, 44,106, 81,107,110,108,111,112,109,113,114,117,118,116,121,115, &
- 119,122,120,125,129,124,127,126,128, 91,123,133,131,130,134,135,137, &
- 136,132,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152, &
- 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169, &
- 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186, &
- 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203/
-
-do i=1,NRECENT
- recent_calls(i)=' '
-enddo
-nerrtot=0
-nerrdec=0
-nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword
-
-nargs=iargc()
-if(nargs.ne.4) then
- print*,'Usage: ldpcsim niter ndeep #trials s '
- print*,'eg: ldpcsim 100 4 1000 0.84'
- print*,'If s is negative, then value is ignored and sigma is calculated from SNR.'
- return
-endif
-call getarg(1,arg)
-read(arg,*) max_iterations
-call getarg(2,arg)
-read(arg,*) ndeep
-call getarg(3,arg)
-read(arg,*) ntrials
-call getarg(4,arg)
-read(arg,*) s
-
-fsk=.false.
-bpsk=.true.
-
-N=204
-K=68
-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) )
-
-! The message should be packed into the first 7 bytes
- i1Msg8BitBytes(1:6)=85
- i1Msg8BitBytes(7)=64
-! The CRC will be put into the last 2 bytes
- i1Msg8BitBytes(8:9)=0
- checksum = crc10 (c_loc (i1Msg8BitBytes), 9)
-! For reference, the next 3 lines show how to check the CRC
- i1Msg8BitBytes(8)=checksum/256
- i1Msg8BitBytes(9)=iand (checksum,255)
- checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9)
- if( checksumok ) write(*,*) 'Good checksum'
-write(*,*) i1Msg8BitBytes(1:9)
-
- mbit=0
- do i=1, 7
- i1=i1Msg8BitBytes(i)
- do ibit=1,8
- mbit=mbit+1
- msgbits(mbit)=iand(1,ishft(i1,ibit-8))
- enddo
- enddo
- i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte
- do ibit=1,2
- msgbits(50+ibit)=iand(1,ishft(i1,ibit-2))
- enddo
- i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC
- do ibit=1,8
- msgbits(52+ibit)=iand(1,ishft(i1,ibit-8))
- enddo
-
- write(*,*) 'message'
- write(*,'(9(8i1,1x))') msgbits
-
- call encode204(msgbits,codeword)
- call init_random_seed()
- call sgran()
-
- write(*,*) 'codeword'
- write(*,'(204i1)') codeword
-
-write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma"
-do idb = 20,-18,-1
-!do idb = -16, -16, -1
- db=idb/2.0-1.0
-! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No
- sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No
- ngood=0
- nue=0
- nbadcrc=0
- nberr=0
- do itrial=1, ntrials
-! Create a realization of a noisy received word
- do i=1,N
- if( bpsk ) then
- rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
- elseif( fsk ) then
- if( codeword(i) .eq. 1 ) then
- r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r2=(sigma*gran())**2 + (sigma*gran())**2
- elseif( codeword(i) .eq. 0 ) then
- r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r1=(sigma*gran())**2 + (sigma*gran())**2
- endif
- rxdata(i)=0.35*(sqrt(r1)-sqrt(r2))
-! rxdata(i)=0.35*(exp(r1)-exp(r2))
-! rxdata(i)=0.12*(log(r1)-log(r2))
- endif
- 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
- nberr=nberr+nerr
-
-! Correct signal normalization is important for this decoder.
- rxav=sum(rxdata)/N
- rx2av=sum(rxdata*rxdata)/N
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
-! To match the metric to the channel, s should be set to the noise standard deviation.
-! For now, set s to the value that optimizes decode probability near threshold.
-! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
-! magnitude in UER
- if( s .lt. 0 ) then
- ss=sigma
- else
- ss=s
- endif
-
- llr=2.0*rxdata/(ss*ss)
- apmask=0
-! max_iterations is max number of belief propagation iterations
- call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations)
- if( (nharderror .lt. 0) .and. (ndeep .ge. 0) ) then
- call osd204(llr, apmask, ndeep, decoded, cw, nhardmin, dmin)
- niterations=nhardmin
- endif
- n2err=0
- do i=1,N
- if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1
- enddo
-!write(*,*) nerr,niterations,n2err
- damp=0.75
- ndither=0
- if( niterations .lt. 0 ) then
- do i=1, ndither
- do in=1,N
- dllr(in)=damp*gran()
- enddo
- llrd=llr+dllr
- call bpdecode300(llrd, apmask, max_iterations, decoded, cw, nharderror, niterations)
- if( niterations .ge. 0 ) exit
- enddo
- endif
-
-! If the decoder finds a valid codeword, niterations will be .ge. 0.
- if( niterations .ge. 0 ) then
-! Check the CRC
- do ibyte=1,6
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
- i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64
-! Need to pack the received crc into bytes 8 and 9 for crc10_check
- i1Dec8BitBytes(8)=decoded(51)*2+decoded(52)
- i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16
- i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1
- ncrcflag=0
- if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1
-
- if( ncrcflag .ne. 1 ) then
- nbadcrc=nbadcrc+1
- endif
- nueflag=0
-
- nerrmpc=0
- do i=1,K ! find number of errors in message+crc part of codeword
- if( msgbits(i) .ne. decoded(i) ) then
- nueflag=1
- nerrmpc=nerrmpc+1
- endif
- enddo
- if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly
- if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then
- ngood=ngood+1
- if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1
- else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then
- nue=nue+1;
- endif
- endif
- enddo
- snr2500=db+10*log10(200.0/116.0/2500.0)
- pberr=real(nberr)/(real(ntrials*N))
- write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
-
-enddo
-
-open(unit=23,file='nerrhisto.dat',status='unknown')
-do i=1,120
- write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
-enddo
-close(23)
-open(unit=25,file='nmpcbad.dat',status='unknown')
-do i=1,68
- write(25,'(i4,2x,i10)') i,nmpcbad(i)
-enddo
-close(25)
-
-
-
-end program ldpcsim204
diff --git a/lib/fsk4hf/ldpcsim300.f90 b/lib/fsk4hf/ldpcsim300.f90
deleted file mode 100644
index cfd28a78..00000000
--- a/lib/fsk4hf/ldpcsim300.f90
+++ /dev/null
@@ -1,254 +0,0 @@
-program ldpcsim300
-
-! End-to-end test of the (300,60)/crc10 encoder and decoders.
-
-use crc
-use packjt
-
-parameter(NRECENT=10)
-character*12 recent_calls(NRECENT)
-character*8 arg
-integer*1, allocatable :: codeword(:), decoded(:), message(:)
-integer*1, target:: i1Msg8BitBytes(9)
-integer*1, target:: i1Dec8BitBytes(9)
-integer*1 msgbits(60)
-integer*1 apmask(300)
-integer*1 cw(300)
-integer*2 checksum
-integer colorder(300)
-integer nerrtot(300),nerrdec(300),nmpcbad(60)
-logical checksumok,fsk,bpsk
-real*8, allocatable :: rxdata(:)
-real, allocatable :: llr(:)
-real dllr(300),llrd(300)
-
-data colorder/ &
-0,1,2,3,4,5,6,7,8,9,10,11,123,12,13,14,15,16,17,18, &
-19,20,21,22,23,24,25,138,26,145,27,28,29,30,31,32,33,34,35,36, &
-37,154,38,39,40,41,42,43,44,144,46,47,48,49,50,51,52,53,143,54, &
-125,56,57,58,124,59,120,140,157,160,55,60,61,62,156,162,141,64,65,153, &
-181,183,66,170,67,68,69,130,70,164,71,72,73,74,75,63,76,77,135,78, &
-79,80,176,169,82,83,84,167,180,85,136,158,129,166,175,142,134,146,121,165, &
-88,89,192,90,45,91,92,93,182,189,94,95,96,173,81,97,98,178,122,126, &
-132,99,100,152,186,193,101,102,151,103,104,172,159,168,150,190,147,148,201,107, &
-205,177,108,198,197,174,127,109,185,110,202,87,199,171,179,187,139,137,106,131, &
-206,194,112,149,155,113,128,184,196,86,114,203,212,195,208,105,188,161,163,191, &
-200,209,214,204,115,218,133,111,207,117,213,216,211,217,116,215,219,220,210,221, &
-118,222,223,225,224,228,226,229,231,227,233,119,234,235,232,230,237,239,236,238, &
-240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259, &
-260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279, &
-280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299/
-
-do i=1,NRECENT
- recent_calls(i)=' '
-enddo
-nerrtot=0
-nerrdec=0
-nmpcbad=0 ! Used to collect the number of errors in the message+crc part of the codeword
-
-nargs=iargc()
-if(nargs.ne.4) then
- print*,'Usage: ldpcsim niter ndeep #trials s '
- print*,'eg: ldpcsim 100 4 1000 0.84'
- print*,'If s is negative, then value is ignored and sigma is calculated from SNR.'
- return
-endif
-call getarg(1,arg)
-read(arg,*) max_iterations
-call getarg(2,arg)
-read(arg,*) ndeep
-call getarg(3,arg)
-read(arg,*) ntrials
-call getarg(4,arg)
-read(arg,*) s
-
-fsk=.false.
-bpsk=.true.
-
-! don't count crc bits as data bits
-N=300
-K=60
-! scale Eb/No for a (300,50) code
-rate=real(50)/real(N)
-
-write(*,*) "rate: ",rate
-write(*,*) "niter= ",max_iterations," s= ",s
-
-allocate ( codeword(N), decoded(K), message(K) )
-allocate ( rxdata(N), llr(N) )
-
-! The message should be packed into the first 7 bytes
- i1Msg8BitBytes(1:6)=85
- i1Msg8BitBytes(7)=64
-! The CRC will be put into the last 2 bytes
- i1Msg8BitBytes(8:9)=0
- checksum = crc10 (c_loc (i1Msg8BitBytes), 9)
-! For reference, the next 3 lines show how to check the CRC
- i1Msg8BitBytes(8)=checksum/256
- i1Msg8BitBytes(9)=iand (checksum,255)
- checksumok = crc10_check(c_loc (i1Msg8BitBytes), 9)
- if( checksumok ) write(*,*) 'Good checksum'
-write(*,*) i1Msg8BitBytes(1:9)
-
- mbit=0
- do i=1, 7
- i1=i1Msg8BitBytes(i)
- do ibit=1,8
- mbit=mbit+1
- msgbits(mbit)=iand(1,ishft(i1,ibit-8))
- enddo
- enddo
- i1=i1Msg8BitBytes(8) ! First 2 bits of crc10 are LSB of this byte
- do ibit=1,2
- msgbits(50+ibit)=iand(1,ishft(i1,ibit-2))
- enddo
- i1=i1Msg8BitBytes(9) ! Now shift in last 8 bits of the CRC
- do ibit=1,8
- msgbits(52+ibit)=iand(1,ishft(i1,ibit-8))
- enddo
-
- write(*,*) 'message'
- write(*,'(9(8i1,1x))') msgbits
-
- call encode300(msgbits,codeword)
- call init_random_seed()
- call sgran()
-
- write(*,*) 'codeword'
- write(*,'(38(8i1,1x))') codeword
-
-write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma"
-do idb = 20,-16,-1
-!do idb = -16, -16, -1
- db=idb/2.0-1.0
-! sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No
- sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No
- ngood=0
- nue=0
- nbadcrc=0
- nberr=0
- do itrial=1, ntrials
-! Create a realization of a noisy received word
- do i=1,N
- if( bpsk ) then
- rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran()
- elseif( fsk ) then
- if( codeword(i) .eq. 1 ) then
- r1=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r2=(sigma*gran())**2 + (sigma*gran())**2
- elseif( codeword(i) .eq. 0 ) then
- r2=(1.0 + sigma*gran())**2 + (sigma*gran())**2
- r1=(sigma*gran())**2 + (sigma*gran())**2
- endif
- rxdata(i)=0.35*(sqrt(r1)-sqrt(r2))
-! rxdata(i)=0.35*(exp(r1)-exp(r2))
-! rxdata(i)=0.12*(log(r1)-log(r2))
- endif
- 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
- nberr=nberr+nerr
-
-! Correct signal normalization is important for this decoder.
- rxav=sum(rxdata)/N
- rx2av=sum(rxdata*rxdata)/N
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
-! To match the metric to the channel, s should be set to the noise standard deviation.
-! For now, set s to the value that optimizes decode probability near threshold.
-! The s parameter can be tuned to trade a few tenth's dB of threshold for an order of
-! magnitude in UER
- if( s .lt. 0 ) then
- ss=sigma
- else
- ss=s
- endif
-
- llr=2.0*rxdata/(ss*ss)
- apmask=0
-! max_iterations is max number of belief propagation iterations
- call bpdecode300(llr, apmask, max_iterations, decoded, niterations, cw)
- if( (niterations .lt. 0) .and. (ndeep .ge. 0) ) then
- call osd300(llr, apmask, ndeep, decoded, cw, nhardmin, dmin)
- niterations=nhardmin
- endif
- n2err=0
- do i=1,N
- if( cw(i)*(2*codeword(i)-1.0) .lt. 0 ) n2err=n2err+1
- enddo
-!write(*,*) nerr,niterations,n2err
- damp=0.75
- ndither=0
- if( niterations .lt. 0 ) then
- do i=1, ndither
- do in=1,N
- dllr(in)=damp*gran()
- enddo
- llrd=llr+dllr
- call bpdecode300(llrd, apmask, max_iterations, decoded, niterations, cw)
- if( niterations .ge. 0 ) exit
- enddo
- endif
-
-! If the decoder finds a valid codeword, niterations will be .ge. 0.
- if( niterations .ge. 0 ) then
-! Check the CRC
- do ibyte=1,6
- itmp=0
- do ibit=1,8
- itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*8+ibit))
- enddo
- i1Dec8BitBytes(ibyte)=itmp
- enddo
- i1Dec8BitBytes(7)=decoded(49)*128+decoded(50)*64
-! Need to pack the received crc into bytes 8 and 9 for crc10_check
- i1Dec8BitBytes(8)=decoded(51)*2+decoded(52)
- i1Dec8BitBytes(9)=decoded(53)*128+decoded(54)*64+decoded(55)*32+decoded(56)*16
- i1Dec8BitBytes(9)=i1Dec8BitBytes(9)+decoded(57)*8+decoded(58)*4+decoded(59)*2+decoded(60)*1
- ncrcflag=0
- if( crc10_check( c_loc( i1Dec8BitBytes ), 9 ) ) ncrcflag=1
-
- if( ncrcflag .ne. 1 ) then
- nbadcrc=nbadcrc+1
- endif
- nueflag=0
-
- nerrmpc=0
- do i=1,K ! find number of errors in message+crc part of codeword
- if( msgbits(i) .ne. decoded(i) ) then
- nueflag=1
- nerrmpc=nerrmpc+1
- endif
- enddo
- if(nerrmpc.ge.1) nmpcbad(nerrmpc)=nmpcbad(nerrmpc)+1 ! This histogram should inform our selection of CRC poly
- if( ncrcflag .eq. 1 .and. nueflag .eq. 0 ) then
- ngood=ngood+1
- if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1
- else if( ncrcflag .eq. 1 .and. nueflag .eq. 1 ) then
- nue=nue+1;
- endif
- endif
- enddo
- snr2500=db+10*log10(1.389/2500.0)
- pberr=real(nberr)/(real(ntrials*N))
- write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,snr2500,ngood,nue,nbadcrc,ss,pberr
-
-enddo
-
-open(unit=23,file='nerrhisto.dat',status='unknown')
-do i=1,120
- write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10)
-enddo
-close(23)
-open(unit=25,file='nmpcbad.dat',status='unknown')
-do i=1,60
- write(25,'(i4,2x,i10)') i,nmpcbad(i)
-enddo
-close(25)
-
-
-
-end program ldpcsim300
diff --git a/lib/fsk4hf/mskhfsim.f90 b/lib/fsk4hf/mskhfsim.f90
deleted file mode 100644
index 86140e1c..00000000
--- a/lib/fsk4hf/mskhfsim.f90
+++ /dev/null
@@ -1,194 +0,0 @@
-program msksim
-
-! Simulate characteristics of a potential "MSK10" mode using LDPC (168,84)
-! code, OQPDK modulation, and 30 s T/R sequences.
-
-! Reception and Demodulation algorithm:
-! 1. Compute coarse spectrum; find fc1 = approx carrier freq
-! 2. Mix from fc1 to 0; LPF at +/- 0.75*R
-! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2
-! 4. Mix from fc2 to 0
-! 5. Fit cb13 (central part of csync) to c -> lag, phase
-! 6. Fit complex ploynomial for channel equalization
-! 7. Get soft bits from equalized data
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=1152/72) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3776)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- character*8 arg
- complex cbb(0:NZ-1) !Complex baseband waveform
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- complex cb13(0:N13-1) !Barker 13 waveform
- complex c(0:NZ-1) !Complex waveform
- complex c0(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z
- real xnoise(0:NZ-1) !Generated random noise
- real ynoise(0:NZ-1) !Generated random noise
- real rxdata(ND),llr(ND) !Soft symbols
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real a(5) !For twkfreq1
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
- integer icw(NN)
- integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND)
-! integer*1 codeword(ND)
- data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, &
- 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,1,1,0,1,1, &
- 1,1,0,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,0/
-
- nargs=iargc()
- if(nargs.ne.6) then
- print*,'Usage: mskhfsim f0(Hz) delay(ms) fspread(Hz) maxn iters snr(dB)'
- print*,'Example: mskhfsim 0 0 0 5 10 -20'
- print*,'Set snr=0 to cycle through a range'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) f0 !Generated carrier frequency
- call getarg(2,arg)
- read(arg,*) delay !Delta_t (ms) for Watterson model
- call getarg(3,arg)
- read(arg,*) fspread !Fspread (Hz) for Watterson model
- call getarg(4,arg)
- read(arg,*) maxn !Max nterms for polyfit
- call getarg(5,arg)
- read(arg,*) iters !Iterations at each SNR
- call getarg(6,arg)
- read(arg,*) snrdb !Specified SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/72.0 !Sample rate = 166.6666667 Hz
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- ts=2*NSPS*dt !Duration of OQPSK symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- write(*,1000) f0,delay,fspread,maxn,iters,baud,3*baud,txt
-1000 format('f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2,' maxn:',i3, &
- ' Iters:',i6/'Baud:',f7.3,' BW:',f5.1,' TxT:',f5.1,f5.2/)
- write(*,1004)
-1004 format(/' SNR err ber fer fsigma'/37('-'))
-
- do i=1,N2 !Half-sine pulse shape
- pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS))
- enddo
-
- call genmskhf(msgbits,id,icw,cbb,csync)!Generate baseband waveform and csync
- cb13=csync(1680:2095) !Copy the Barker 13 waveform
- a=0.
- a(1)=f0
- call twkfreq1(cbb,NZ,fs,a,cbb) !Mix to specified frequency
-
- isna=-10
- isnb=-30
- if(snrdb.ne.0.0) then
- isna=nint(snrdb)
- isnb=isna
- endif
- do isnr=isna,isnb,-1 !Loop over SNR range
- snrdb=isnr
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- nhard=0
- nhardsync=0
- nfe=0
- sqf=0.
- do iter=1,iters !Loop over requested iterations
- c=cbb
- if(delay.ne.0.0 .or. fspread.ne.0.0) then
- call watterson(c,NZ,fs,delay,fspread)
- endif
- c=sig*c !Scale to requested SNR
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Generate gaussian noise
- xnoise(i)=gran()
- ynoise(i)=gran()
- enddo
- c=c + cmplx(xnoise,ynoise) !Add AWGN noise
- endif
-
- call getfc1(c,fc1) !First approx for freq
- call getfc2(c,csync,fc1,fc2,fc3) !Refined freq
- sqf=sqf + (fc1+fc2-f0)**2
-
-!NB: Measured performance is about equally good using fc2 or fc3 here:
- a(1)=-(fc1+fc2)
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2
-
-! The following may not be necessary?
-! z=sum(c(1680:2095)*cb13)/208.0 !Get phase from Barker 13 vector
-! z0=z/abs(z)
-! c=c*conjg(z0)
-
-!---------------------------------------------------------------- DT
-! Not presently used:
- amax=0.
- jpk=0
- do j=-20*NSPS,20*NSPS !Get jpk
- z=sum(c(1680+j:2095+j)*cb13)/208.0
- if(abs(z).gt.amax) then
- amax=abs(z)
- jpk=j
- endif
- enddo
- xdt=jpk/fs
-
- nterms=maxn
- c0=c
- do itry=1,10
- idf=itry/2
- if(mod(itry,2).eq.0) idf=-idf
- nhard0=0
- nhardsync0=0
- ifer=1
- a(1)=idf*0.01
- a(2:5)=0.
- call twkfreq1(c0,NZ,fs,a,c) !Mix c0 into c
- call cpolyfit(c,pp,id,maxn,aa,bb,zz,nhs)
- call msksoftsym(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
- if(nhardsync0.gt.12) cycle
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss)
- apmask=0
- max_iterations=40
- ifer=0
- call bpdecode168(llr,apmask,max_iterations,decoded,niterations,cw)
- nbadcrc=0
- if(niterations.ge.0) call chkcrc12(decoded,nbadcrc)
- if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. &
- nbadcrc.ne.0) ifer=1
-! if(ifer.eq.0) write(67,1301) snrdb,itry,idf,niterations, &
-! nhardsync0,nhard0
-!1301 format(f6.1,5i6)
- if(ifer.eq.0) exit
- enddo !Freq dither loop
- nhard=nhard+nhard0
- nhardsync=nharsdync+nhardsync0
- nfe=nfe+ifer
- enddo
-
- fsigma=sqrt(sqf/iters)
- ber=float(nhard)/((NS+ND)*iters)
- fer=float(nfe)/iters
- write(*,1050) snrdb,nhard,ber,fer,fsigma
-! write(60,1050) snrdb,nhard,ber,fer,fsigma
-1050 format(f6.1,i7,f8.4,f7.3,f8.2)
- enddo
-
-999 end program msksim
diff --git a/lib/fsk4hf/msksoftsym.f90 b/lib/fsk4hf/msksoftsym.f90
deleted file mode 100644
index 016b23e1..00000000
--- a/lib/fsk4hf/msksoftsym.f90
+++ /dev/null
@@ -1,81 +0,0 @@
-subroutine msksoftsym(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=168) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=65) !Sync symbols (2 x 26 + Barker 13)
- parameter (NR=3) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (236)
- parameter (NSPS=16) !Samples per MSK symbol (16)
- parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
- parameter (N13=13*N2) !Samples in central sync vector (416)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real rxdata(ND) !Soft symbols
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
-
- n=0
- ierror=0
- do j=1,117
- xx=j*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(abs(id(j)).eq.2) then
- if(real(z)*id(j).lt.0) then !Sync bit
- nhardsync0=nhardsync0+1
- ierror(j)=2
- endif
- else
- n=n+1 !Data bit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- endif
- enddo
-
- do j=118,233
- xx=(j-116.5)*2.0/117.0 - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=aimag(z)
- n=n+1
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- enddo
-
- return
-end subroutine msksoftsym
diff --git a/lib/fsk4hf/msksoftsymw.f90 b/lib/fsk4hf/msksoftsymw.f90
deleted file mode 100644
index c7402ec4..00000000
--- a/lib/fsk4hf/msksoftsymw.f90
+++ /dev/null
@@ -1,78 +0,0 @@
-subroutine msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
-
- include 'wsprlf_params.f90'
-
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z,z0
- real rxdata(ND) !Soft symbols
- real aa(20),bb(20) !Fitted polyco's
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
-
- n=0
- ierror=0
- ierr=0
- jz=(NS+ND+1)/2
- do j=1,jz
- xx=j*2.0/jz - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=real(z)
- if(abs(id(j)).eq.2) then
- if(real(z)*id(j).lt.0) then !Sync bit
- nhardsync0=nhardsync0+1
- ierror(j)=2
- endif
- else
- n=n+1 !Data bit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
- endif
-! write(41,3301) j,id(j),ierror(j),ierr,n,p,p*id(j)
-!3301 format(5i6,2f10.3)
- enddo
-
- do j=jz+1,NS+ND
- xx=(j-jz+0.5)*2.0/jz - 1.0
- yii=1.
- yqq=0.
- if(nterms.gt.0) then
- yii=aa(1)
- yqq=bb(1)
- do i=2,nterms
- yii=yii + aa(i)*xx**(i-1)
- yqq=yqq + bb(i)*xx**(i-1)
- enddo
- endif
- z0=cmplx(yii,yqq)
- z=zz(j)*conjg(z0)
- p=aimag(z)
- n=n+1
- if(n.gt.ND) exit
- rxdata(n)=p
- ierr=0
- if(id(j)*p.lt.0) then
- ierr=1
- ierror(j)=1
- endif
- nhard0=nhard0+ierr
-! write(41,3301) j,id(j),ierror(j),ierr,n,p,p*id(j)
- enddo
-
- return
-end subroutine msksoftsymw
diff --git a/lib/fsk4hf/osd204.f90 b/lib/fsk4hf/osd204.f90
deleted file mode 100644
index acebbf64..00000000
--- a/lib/fsk4hf/osd204.f90
+++ /dev/null
@@ -1,365 +0,0 @@
-subroutine osd204(llr,apmask,ndeep,decoded,cw,nhardmin,dmin)
-!
-! An ordered-statistics decoder for the (204,68) code.
-!
-include "ldpc_204_68_params.f90"
-
-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 indx(N)
-real llr(N),rx(N),absrx(N)
-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,17
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- irow=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(irow,i)=1
- enddo
- enddo
- enddo
- do irow=1,K
- gen(irow,M+irow)=1
- enddo
-first=.false.
-endif
-
-! Re-order received vector to place systematic msg bits at the end.
-rx=llr(colorder+1)
-apmaskr=apmask(colorder+1)
-
-! 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 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 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 mrbencode(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=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 mrbencode(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 mrbencode(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 nextpat(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 boxit(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 mrbencode(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 fetchit(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 mrbencode(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 nextpat(misub,K,nord,iflag)
- enddo
-endif
-
-998 continue
-! Re-order the codeword to place message bits at the end.
-cw(indices)=cw
-hdec(indices)=hdec
-decoded=cw(M+1:N)
-cw(colorder+1)=cw ! put the codeword back into received-word order
-return
-end subroutine osd204
-
-subroutine mrbencode(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 mrbencode
-
-subroutine nextpat(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 nextpat
-
-subroutine boxit(reset,e2,ntau,npindex,i1,i2)
- integer*1 e2(1:ntau)
- integer indexes(4000,2),fp(0:525000),np(4000)
- 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 boxit
-
-subroutine fetchit(reset,e2,ntau,i1,i2)
- integer indexes(4000,2),fp(0:525000),np(4000)
- 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 fetchit
-
diff --git a/lib/fsk4hf/osd300.f90 b/lib/fsk4hf/osd300.f90
deleted file mode 100644
index 565f4ce5..00000000
--- a/lib/fsk4hf/osd300.f90
+++ /dev/null
@@ -1,365 +0,0 @@
-subroutine osd300(llr,apmask,ndeep,decoded,cw,nhardmin,dmin)
-!
-! An ordered-statistics decoder for the (300,60) code.
-!
-include "ldpc_300_60_params.f90"
-
-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 indx(N)
-real llr(N),rx(N),absrx(N)
-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, 15
- read(g(i)(j:j),"(Z1)") istr
- do jj=1, 4
- irow=(j-1)*4+jj
- if( btest(istr,4-jj) ) gen(irow,i)=1
- enddo
- enddo
- enddo
- do irow=1,K
- gen(irow,M+irow)=1
- enddo
-first=.false.
-endif
-
-! Re-order received vector to place systematic msg bits at the end.
-rx=llr(colorder+1)
-apmaskr=apmask(colorder+1)
-
-! 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 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 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 mrbencode(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=120
- ntheta=12
-elseif(ndeep.eq.2) then
- nord=1
- npre1=1
- npre2=0
- nt=120
- ntheta=12
-elseif(ndeep.eq.3) then
- nord=1
- npre1=1
- npre2=1
- nt=120
- ntheta=12
- ntau=15
-elseif(ndeep.eq.4) then
- nord=2
- npre1=1
- npre2=0
- nt=120
- ntheta=12
- ntau=15
-elseif(ndeep.eq.5) then
- nord=3
- npre1=1
- npre2=1
- nt=80
- ntheta=40
- ntau=16
-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 mrbencode(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 mrbencode(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 nextpat(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 boxit(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 mrbencode(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 fetchit(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 mrbencode(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 nextpat(misub,K,nord,iflag)
- enddo
-endif
-
-998 continue
-! Re-order the codeword to place message bits at the end.
-cw(indices)=cw
-hdec(indices)=hdec
-decoded=cw(M+1:N)
-cw(colorder+1)=cw ! put the codeword back into received-word order
-return
-end subroutine osd300
-
-subroutine mrbencode(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 mrbencode
-
-subroutine nextpat(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 nextpat
-
-subroutine boxit(reset,e2,ntau,npindex,i1,i2)
- integer*1 e2(1:ntau)
- integer indexes(4000,2),fp(0:525000),np(4000)
- 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 boxit
-
-subroutine fetchit(reset,e2,ntau,i1,i2)
- integer indexes(4000,2),fp(0:525000),np(4000)
- 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 fetchit
-
diff --git a/lib/fsk4hf/polyfit4.f90 b/lib/fsk4hf/polyfit4.f90
deleted file mode 100644
index 892cd2cd..00000000
--- a/lib/fsk4hf/polyfit4.f90
+++ /dev/null
@@ -1,109 +0,0 @@
-subroutine polyfit4(x,y,sigmay,npts,nterms,mode,a,chisqr)
-
- parameter (MAXN=20)
- implicit real*8 (a-h,o-z)
- real x(npts), y(npts), sigmay(npts), a(nterms),chisqr
- real*8 sumx(2*MAXN-1), sumy(MAXN), array(MAXN,MAXN)
-
-! Accumulate weighted sums
- nmax = 2*nterms-1
- sumx=0.
- sumy=0.
- chisq=0.
- do i=1,npts
- xi=x(i)
- yi=y(i)
- if(mode.lt.0) then
- weight=1./abs(yi)
- else if(mode.eq.0) then
- weight=1
- else
- weight=1./sigmay(i)**2
- end if
- xterm=weight
- do n=1,nmax
- sumx(n)=sumx(n)+xterm
- xterm=xterm*xi
- enddo
- yterm=weight*yi
- do n=1,nterms
- sumy(n)=sumy(n)+yterm
- yterm=yterm*xi
- enddo
- chisq=chisq+weight*yi**2
- enddo
-
-! Construct matrices and calculate coefficients
- do j=1,nterms
- do k=1,nterms
- n=j+k-1
- array(j,k)=sumx(n)
- enddo
- enddo
-
- delta=determ4(array,nterms)
- if(delta.eq.0) then
- chisqr=0.
- a=0.
- else
- do l=1,nterms
- do j=1,nterms
- do k=1,nterms
- n=j+k-1
- array(j,k)=sumx(n)
- enddo
- array(j,l)=sumy(j)
- enddo
- a(l)=determ4(array,nterms)/delta
- enddo
-
-! Calculate chi square
-
- do j=1,nterms
- chisq=chisq-2*a(j)*sumy(j)
- do k=1,nterms
- n=j+k-1
- chisq=chisq+a(j)*a(k)*sumx(n)
- enddo
- enddo
- free=npts-nterms
- chisqr=chisq/free
- end if
-
- return
-end subroutine polyfit4
-
-real*8 function determ4(array,norder)
-
- parameter (MAXN=20)
- implicit real*8 (a-h,o-z)
- real*8 array(MAXN,MAXN)
-
- determ4=1.
- do k=1,norder
- if (array(k,k).ne.0) go to 41
- do j=k,norder
- if(array(k,j).ne.0) go to 31
- enddo
- determ4=0.
- go to 60
-
-31 do i=k,norder
- s8=array(i,j)
- array(i,j)=array(i,k)
- array(i,k)=s8
- enddo
- determ4=-1.*determ4
-41 determ4=determ4*array(k,k)
- if(k.lt.norder) then
- k1=k+1
- do i=k1,norder
- do j=k1,norder
- array(i,j)=array(i,j)-array(i,k)*array(k,j)/array(k,k)
- enddo
- enddo
- end if
- enddo
-
-60 return
-end function determ4
diff --git a/lib/fsk4hf/spb.m b/lib/fsk4hf/spb.m
deleted file mode 100644
index ed176192..00000000
--- a/lib/fsk4hf/spb.m
+++ /dev/null
@@ -1,89 +0,0 @@
-clear all;
-global N
-global R
-global A
-
-#-------------------------------------------------------------------------------
-function retval = f1(theta)
- global N;
- global R;
- retval=0.0;
- gterm = gammaln(N/2) - gammaln((N+1)/2) - log(2*sqrt(pi));
- rhs = -N*R*log(2);
- lhs=gterm + (N-1)*log(sin(theta)) + log(1-(tan(theta).^2)/N) - log(cos(theta));
- retval = rhs-real(lhs);
-endfunction
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-function retval = d(N,i,x)
- t1=(x.^2)/2;
- t2=gammaln(N/2);
- t3=-gammaln(i/2+1);
- t4=-gammaln(N-i);
- t5=(N-1-i)*log(sqrt(2)*x);
- t6=-log(2)/2;
- t7arg=1+(-1)^i * gammainc((x.^2)/2.0,(i+1)/2);
- t7=log(t7arg);
- retval=t1+t2+t3+t4+t5+t6+t7;
-endfunction
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-function retval = maxstar(x1,x2)
- retval = max(x1,x2)+log(1+exp(-abs(x1-x2)));
-endfunction
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-function retval = spb_integrand(x)
- global N;
- global A;
-
- t1=log(N-1);
- t2=-N*(A^2)/2;
- t3=-0.5*log(2*pi);
- t4=(N-2)*log(sin(x));
-
- arg=sqrt(N)*A*cos(x);
- t5=maxstar(d(N,0,arg),d(N,1,arg));
- for i=2:N-1
- t5=maxstar(t5,d(N,i,arg));
- endfor
-
- retval=exp(t1+t2+t3+t4+t5);
-endfunction
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-function retval = qfunc(x)
- retval = 0.5 * erfc(x/sqrt(2));
-endfunction
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-# Calculate sphere packing lower bound on the probability of word error
-# given block length (N), code rate (R), and Eb/No.
-#
-# Ref:
-# "Log-Domain Calculation of the 1959 Sphere-Packing Bound with Application to
-# M-ary PSK Block Coded Modulation," Igal Sason and Gil Weichman,
-# doi: 10.1109/EEEI.2006.321097
-#-------------------------------------------------------------------------------
-N=174
-K=75
-R=K/N
-
-delta=0.01;
-[ths,fval,info,output]=fzero(@f1,[delta,pi/2-delta], optimset ("jacobian", "off"));
-
-for ebnodb=-6:0.5:4
- ebno=10^(ebnodb/10.0);
- esno=ebno*R;
- A=sqrt(2*esno);
- term1=quadcc(@spb_integrand,ths,pi/2);
- term2=qfunc(sqrt(N)*A);
- pe=term1+term2;
- ps=1-pe;
- printf("%f %f\n",ebnodb,ps);
-endfor
diff --git a/lib/fsk4hf/spec4.f90 b/lib/fsk4hf/spec4.f90
deleted file mode 100644
index e0588950..00000000
--- a/lib/fsk4hf/spec4.f90
+++ /dev/null
@@ -1,35 +0,0 @@
-subroutine spec4(c,s,savg)
-
- parameter (KK=84) !Information bits (72 + CRC12)
- parameter (ND=84) !Data symbols: LDPC (168,84), r=1/2
- parameter (NS=12) !Sync symbols (3 @ 4x4 Costas arrays)
- parameter (NR=2) !Ramp up/down
- parameter (NN=NR+NS+ND) !Total symbols (98)
- parameter (NSPS=2688/84) !Samples per symbol (32)
- parameter (NZ=NSPS*NN) !Samples in baseband waveform (3760)
- parameter (NFFT=2*NSPS,NH=NSPS)
-
- complex c(0:NZ-1)
- complex c1(0:NFFT-1)
- real s(0:NH,NN)
- real savg(0:NH)
-
- fs=12000.0/84.0
- df=fs/NFFT
- savg=0.
- do j=1,NN
- ia=(j-1)*NSPS
- ib=ia + NSPS-1
- c1(0:NSPS-1)=c(ia:ib)
- c1(NSPS:)=0.
- call four2a(c1,NFFT,1,-1,1)
- do k=1,NSPS
- s(k,j)=real(c1(k))**2 + aimag(c1(k))**2
- enddo
- savg=savg+s(0:NH,j)
- enddo
- s=s/NZ
- savg=savg/(NN*NZ)
-
- return
-end subroutine spec4
diff --git a/lib/fsk4hf/spec8.f90 b/lib/fsk4hf/spec8.f90
deleted file mode 100644
index 43fbc7ee..00000000
--- a/lib/fsk4hf/spec8.f90
+++ /dev/null
@@ -1,31 +0,0 @@
-subroutine spec8(c,s,savg)
-
- include 'wspr_fsk8_params.f90'
- complex c(0:NMAXD-1)
- complex c1(0:NSPS-1)
- real s(0:NH2,NN)
- real savg(0:NH2)
-
- fs=12000.0/NDOWN
- df=fs/NSPS
- savg=0.
- do j=1,NN
- ia=(j-1)*NSPS
- ib=ia + NSPS-1
- c1(0:NSPS-1)=c(ia:ib)
- c1(NSPS:)=0.
- call four2a(c1,NSPS,1,-1,1)
- do i=0,NH2
- s(i,j)=real(c1(i))**2 + aimag(c1(i))**2
- enddo
- savg=savg+s(0:NH2,j)
- enddo
- s=s/NZ
- savg=savg/(NN*NZ)
-! do i=0,NH2
-! write(31,3101) i*df,savg(i)
-!3101 format(f10.3,f12.3)
-! enddo
-
- return
-end subroutine spec8
diff --git a/lib/fsk4hf/tweak1.f90 b/lib/fsk4hf/tweak1.f90
deleted file mode 100644
index c62c4087..00000000
--- a/lib/fsk4hf/tweak1.f90
+++ /dev/null
@@ -1,23 +0,0 @@
-subroutine tweak1(ca,jz,f0,cb)
-
-! Shift frequency of analytic signal ca, with output to cb
-
- complex ca(jz),cb(jz)
- real*8 twopi
- complex*16 w,wstep
- complex w4
- data twopi/0.d0/
- save twopi
-
- if(twopi.eq.0.d0) twopi=8.d0*atan(1.d0)
- w=1.d0
- dphi=twopi*f0/12000.d0
- wstep=cmplx(cos(dphi),sin(dphi))
- do i=1,jz
- w=w*wstep
- w4=w
- cb(i)=w4*ca(i)
- enddo
-
- return
-end subroutine tweak1
diff --git a/lib/fsk4hf/wavhdr.f90 b/lib/fsk4hf/wavhdr.f90
deleted file mode 100644
index b54fba78..00000000
--- a/lib/fsk4hf/wavhdr.f90
+++ /dev/null
@@ -1,110 +0,0 @@
-module wavhdr
- type hdr
- character*4 ariff
- integer*4 lenfile
- character*4 awave
- character*4 afmt
- integer*4 lenfmt
- integer*2 nfmt2
- integer*2 nchan2
- integer*4 nsamrate
- integer*4 nbytesec
- integer*2 nbytesam2
- integer*2 nbitsam2
- character*4 adata
- integer*4 ndata
- end type hdr
-
- contains
-
- function default_header(nsamrate,npts)
- type(hdr) default_header,h
- h%ariff='RIFF'
- h%awave='WAVE'
- h%afmt='fmt '
- h%lenfmt=16
- h%nfmt2=1
- h%nchan2=1
- h%nsamrate=nsamrate
- h%nbitsam2=16
- h%nbytesam2=h%nbitsam2 * h%nchan2 / 8
- h%adata='data'
- h%nbytesec=h%nsamrate * h%nbitsam2 * h%nchan2 / 8
- h%ndata=2*npts
- h%lenfile=h%ndata + 44 - 8
- default_header=h
- end function default_header
-
- subroutine set_wsjtx_wav_params(fMHz,mode,nsubmode,ntrperiod,id2)
-
- parameter (NBANDS=23,NMODES=11)
- character*8 mode,modes(NMODES)
- integer*2 id2(4)
- integer iperiod(7)
- real fband(NBANDS)
- data fband/0.137,0.474,1.8,3.5,5.1,7.0,10.14,14.0,18.1,21.0,24.9, &
- 28.0,50.0,144.0,222.0,432.0,902.0,1296.0,2304.0,3400.0, &
- 5760.0,10368.0,24048.0/
- data modes/'Echo','FSK441','ISCAT','JT4','JT65','JT6M','JT9', &
- 'JT9+JT65','JTMS','JTMSK','WSPR'/
- data iperiod/5,10,15,30,60,120,900/
-
- dmin=1.e30
- iband=0
- do i=1,NBANDS
- if(abs(fMHz-fband(i)).lt.dmin) then
- dmin=abs(fMHz-fband(i))
- iband=i
- endif
- enddo
-
- imode=0
- do i=1,NMODES
- if(mode.eq.modes(i)) imode=i
- enddo
-
- ip=0
- do i=1,7
- if(ntrperiod.eq.iperiod(i)) ip=i
- enddo
-
- id2(1)=iband
- id2(2)=imode
- id2(3)=nsubmode
- id2(4)=ip
-
- return
- end subroutine set_wsjtx_wav_params
-
- subroutine get_wsjtx_wav_params(id2,band,mode,nsubmode,ntrperiod,ok)
-
- parameter (NBANDS=23,NMODES=11)
- character*8 mode,modes(NMODES)
- character*6 band,bands(NBANDS)
- integer*2 id2(4)
- integer iperiod(7)
- logical ok
- data modes/'Echo','FSK441','ISCAT','JT4','JT65','JT6M','JT9', &
- 'JT9+JT65','JTMS','JTMSK','WSPR'/
- data iperiod/5,10,15,30,60,120,900/
- data bands/'2190m','630m','160m','80m','60m','40m','30m','20m', &
- '17m','15m','12m','10m','6m','2m','1.25m','70cm','33cm', &
- '23cm','13cm','9cm','6cm','3cm','1.25cm'/
-
- ok=.true.
- if(id2(1).lt.1 .or. id2(1).gt.NBANDS) ok=.false.
- if(id2(2).lt.1 .or. id2(2).gt.NMODES) ok=.false.
- if(id2(3).lt.1 .or. id2(3).gt.8) ok=.false.
- if(id2(4).lt.1 .or. id2(4).gt.7) ok=.false.
-
- if(ok) then
- band=bands(id2(1))
- mode=modes(id2(2))
- nsubmode=id2(3)
- ntrperiod=iperiod(id2(4))
- endif
-
- return
- end subroutine get_wsjtx_wav_params
-
-end module wavhdr
diff --git a/lib/fsk4hf/wspr5_downsample.f90 b/lib/fsk4hf/wspr5_downsample.f90
deleted file mode 100644
index 6fdb9021..00000000
--- a/lib/fsk4hf/wspr5_downsample.f90
+++ /dev/null
@@ -1,29 +0,0 @@
-subroutine wspr5_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 400 Hz
-
- include 'wsprlf_params.f90'
- parameter (NMAX=300*12000,NFFT2=NMAX/30)
- integer*2 iwave(NMAX)
- complex c(0:NZ-1)
- complex c1(0:NFFT2-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NFFT2/2
- c1(i)=cx(i0+i)
- c1(NFFT2-i)=cx(i0-i)
- enddo
- c1=c1/NFFT2
- call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
- c=c1(0:NZ-1)
-
- return
-end subroutine wspr5_downsample
diff --git a/lib/fsk4hf/wspr5_wav.f90 b/lib/fsk4hf/wspr5_wav.f90
deleted file mode 100644
index 0b09ccde..00000000
--- a/lib/fsk4hf/wspr5_wav.f90
+++ /dev/null
@@ -1,48 +0,0 @@
-subroutine wspr5_wav(baud,xdt,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wsprlf_params.f90'
- parameter (NMAX=300*12000)
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- dphi0=twopi*(f0-0.25d0*baud)*dt
- dphi1=twopi*(f0+0.25d0*baud)*dt
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=dphi0
- if(itone(j).eq.1) dphi=dphi1
- if(k.eq.0) phi=-dphi
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wspr5_wav
diff --git a/lib/fsk4hf/wspr5d.f90 b/lib/fsk4hf/wspr5d.f90
deleted file mode 100644
index 8a3c800b..00000000
--- a/lib/fsk4hf/wspr5d.f90
+++ /dev/null
@@ -1,220 +0,0 @@
-program wspr5d
-
-! Decode WSPR-LF data read from *.c5 or *.wav files.
-
-! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF.
-! It uses an LDPC (300,60) code, OQPSK modulation, and 5 minute T/R sequences.
-
-! Reception and Demodulation algorithm:
-! 1. Compute coarse spectrum; find fc1 = approx carrier freq
-! 2. Mix from fc1 to 0; LPF at +/- 0.75*R
-! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2
-! 4. Mix from fc2 to 0
-! 5. Fit cb13 (central part of csync) to c -> lag, phase
-! 6. Fit complex ploynomial for channel equalization
-! 7. Get soft bits from equalized data
-
-! Still to do: find and decode more than one signal in the specified passband.
-
- include 'wsprlf_params.f90'
- parameter (NMAX=300*12000)
- character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
- character*120 data_dir
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- complex c(0:NZ-1) !Complex waveform
- complex c1(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z
- real*8 fMHz
- real rxdata(ND),llr(ND) !Soft symbols
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real a(5) !For twkfreq1
- real aa(20),bb(20) !Fitted polyco's
- real fpks(20)
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer ihdr(11)
- integer*8 n8
- integer*2 iwave(NMAX) !Generated full-length waveform
- integer*1 idat(7)
- integer*1 decoded(KK),apmask(ND),cw(ND)
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
-
- nargs=iargc()
- if(nargs.lt.2) then
- print*,'Usage: wspr5d [-a <data_dir>] [-f fMHz] file1 [file2 ...]'
- go to 999
- endif
- iarg=1
- data_dir="."
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-a') then
- call getarg(iarg+1,data_dir)
- iarg=iarg+2
- endif
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-f') then
- call getarg(iarg+1,arg)
- read(arg,*) fMHz
- iarg=iarg+2
- endif
-
- open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
- position='append')
-! maxn=4 !Default value
- maxn=2
- twopi=8.0*atan(1.0)
- fs=NSPS*12000.0/NSPS0 !Sample rate
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- ts=2*NSPS*dt !Duration of OQPSK symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
-
- do i=1,N2 !Half-sine pulse shape
- pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS))
- enddo
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
-
-! Define array id() for sync symbols
- id=0
- do j=1,48 !First group of 48
- id(2*j-1)=2*isync(j)
- enddo
- do j=1,13 !Barker 13 code
- id(j+96)=2*ib13(j)
- enddo
- do j=1,48 !Second group of 48
- id(2*j+109)=2*isync(j)
- enddo
-
- csync=0.
- do j=1,205
- if(abs(id(j)).eq.2) then
- ia=nint((j-0.5)*N2)
- ib=ia+N2-1
- csync(ia:ib)=pp*id(j)/abs(id(j))
- endif
- enddo
-
-write(*,*) 'iarg, nargs ',iarg,nargs
- do ifile=iarg,nargs
- call getarg(ifile,infile)
- open(10,file=infile,status='old',access='stream')
- j1=index(infile,'.c5')
- j2=index(infile,'.wav')
- if(j1.gt.0) then
- read(10,end=999) fname,ntrmin,fMHz,c
- read(fname(8:11),*) nutc
- write(datetime,'(i11)') nutc
- else if(j2.gt.0) then
- read(10,end=999) ihdr,iwave
- read(infile(j2-4:j2-1),*) nutc
- datetime=infile(j2-11:j2-1)
- call wspr5_downsample(iwave,c)
- else
- print*,'Wrong file format?'
- go to 999
- endif
- close(10)
- fa=100.0
- fb=150.0
- call getfc1w(c,fs,fa,fb,fc1,xsnr) !First approx for freq
- npeaks=20
- call getfc2w(c,csync,npeaks,fs,fc1,fpks) !Refined freq
-
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2
-! Find time offset xdt
- amax=0.
- jpk=0
- iaa=0
- ibb=NZ-1
- jmax=1260
- do j=-jmax,jmax,NSPS/8
- ia=j
- ib=NZ-1+j
- if(ia.lt.0) then
- ia=0
- iaa=-j
- else
- iaa=0
- endif
- if(ib.gt.NZ-1) then
- ib=NZ-1
- ibb=NZ-1-j
- endif
- z=sum(c(ia:ib)*conjg(csync(iaa:ibb)))
- if(abs(z).gt.amax) then
- amax=abs(z)
- jpk=j
- endif
- enddo
- xdt=jpk/fs
-xdt=1.0
-jpk=fs*xdt
- do i=0,NZ-1
- j=i+jpk
- if(j.ge.0 .and. j.lt.NZ) c1(i)=c(j)
- enddo
-
- nterms=maxn
- do itry=1,npeaks
- nhard0=0
- nhardsync0=0
- ifer=1
- a(1)=-fpks(itry)
- a(2:5)=0.
- call twkfreq1(c1,NZ,fs,a,c) !Mix c1 into c
- call cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhs)
- call msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
- if(nhardsync0.gt.35) cycle
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss)
- apmask=0
- max_iterations=40
- ifer=0
- call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw)
- nhardmin=0
- if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin)
- nbadcrc=0
- call chkcrc10(decoded,nbadcrc)
- if(nbadcrc.ne.0) ifer=1
- if(ifer.eq.0) exit
- enddo !Freq dither loop
- message=' '
- if(ifer.eq.0) then
- write(cbits,1100) decoded(1:50)
-1100 format(50i1)
- read(cbits,1102) idat
-1102 format(6b8,b2)
- idat(7)=ishft(idat(7),6)
- call wqdecode(idat,message,itype)
- nsnr=nint(xsnr)
-! freq=fMHz + 1.d-6*(fc1+fc2)
-! freq=fMHz + 1.d-6*(fc1+fpks(itry))
- freq=fc1+fpks(itry)
- nfdot=0
- write(13,1110) datetime,0,nsnr,xdt,freq,message,nfdot
-1110 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
- write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message,itry,nhardmin
-!1112 format(a4,i4,f5.1,f11.6,i3,2x,a22,i4)
-1112 format(a4,i4,f8.3,f8.3,i3,2x,a22,i4,i4)
- endif
- enddo ! ifile loop
- write(*,1120)
-1120 format("<DecodeFinished>")
-
-999 end program wspr5d
diff --git a/lib/fsk4hf/wspr5d_exp.f90 b/lib/fsk4hf/wspr5d_exp.f90
deleted file mode 100644
index 6e6667b6..00000000
--- a/lib/fsk4hf/wspr5d_exp.f90
+++ /dev/null
@@ -1,544 +0,0 @@
-program wspr5d
-
-! Decode WSPR-LF data read from *.c5 or *.wav files.
-
-! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF.
-! It uses an LDPC (300,60) code, OQPSK modulation, and 5 minute T/R sequences.
-!
-! Still to do: find and decode more than one signal in the specified passband.
-
-! include 'wsprlf_params.f90'
-
- parameter (NDOWN=30)
- parameter (KK=60)
- parameter (ND=300)
- parameter (NS=109)
- parameter (NR=3)
- parameter (NN=NR+NS+ND)
- parameter (NSPS0=8640)
- parameter (NSPS=16)
- parameter (N2=2*NSPS)
- parameter (NZ=NSPS*NN)
- parameter (NZ400=288*NN)
- parameter (NMAX=300*12000)
-
- character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
- character*120 data_dir
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- complex c400(0:NZ400-1) !Complex waveform
- complex c(0:NZ-1) !Complex waveform
- complex cd(0:NZ-1) !Complex waveform
- complex ca(0:NZ-1) !Complex waveform
- complex zz,zzsum
- real*8 fMHz
- real rxdata(ND),llr(ND) !Soft symbols
- real pp(32) !Shaped pulse for OQPSK
- real sbits(412),softbits(9)
- real fpks(20)
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer isync(48) !Long sync vector
- integer ib13(13) !Barker 13 code
- integer ihdr(11)
- integer*8 n8
- integer*2 iwave(NMAX) !Generated full-length waveform
- integer*1 idat(7)
- integer*1 decoded(KK),apmask(ND),cw(ND)
- integer*1 hbits(412),bits(13)
- logical reset
- data ib13/1,1,1,1,1,-1,-1,1,1,-1,1,-1,1/
-
- nargs=iargc()
- if(nargs.lt.2) then
- print*,'Usage: wspr5d [-a <data_dir>] [-f fMHz] file1 [file2 ...]'
- go to 999
- endif
- iarg=1
- data_dir="."
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-a') then
- call getarg(iarg+1,data_dir)
- iarg=iarg+2
- endif
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-f') then
- call getarg(iarg+1,arg)
- read(arg,*) fMHz
- iarg=iarg+2
- endif
-
- open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
- position='append')
- maxn=8 !Default value
- twopi=8.0*atan(1.0)
- fs=NSPS*12000.0/NSPS0 !Sample rate
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- ts=2*NSPS*dt !Duration of OQPSK symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
-
- do i=1,32 !Half-sine pulse shape
- pp(i)=sin(0.5*(i-1)*twopi/(32))
- enddo
- n8=z'cbf089223a51'
- do i=1,48
- isync(i)=-1
- if(iand(n8,1).eq.1) isync(i)=1
- n8=n8/2
- enddo
-
-! Define array id() for sync symbols
- id=0
- do j=1,48 !First group of 48
- id(2*j-1)=2*isync(j)
- enddo
- do j=1,13 !Barker 13 code
- id(j+96)=2*ib13(j)
- enddo
- do j=1,48 !Second group of 48
- id(2*j+109)=2*isync(j)
- enddo
-
- csync=0.
- do j=1,205
- if(abs(id(j)).eq.2) then
- ia=nint((j-0.5)*N2)
- ib=ia+N2-1
- csync(ia:ib)=pp*id(j)/abs(id(j))
- endif
- enddo
-
- do ifile=iarg,nargs
- call getarg(ifile,infile)
- open(10,file=infile,status='old',access='stream')
- j1=index(infile,'.c5')
- j2=index(infile,'.wav')
- if(j1.gt.0) then
- read(10,end=999) fname,ntrmin,fMHz,c400
- read(fname(8:11),*) nutc
- write(datetime,'(i11)') nutc
- else if(j2.gt.0) then
- read(10,end=999) ihdr,iwave
- read(infile(j2-4:j2-1),*) nutc
- datetime=infile(j2-11:j2-1)
- call wspr5_downsample(iwave,c400)
- else
- print*,'Wrong file format?'
- go to 999
- endif
- close(10)
-
- fa=100.0
- fb=150.0
- fs400=400.0
- call getfc1(c400,fs400,fa,fb,fc1,xsnr) !First approx for freq
- npeaks=5
- call getfc2(c400,npeaks,fs400,fc1,fpks) !Refined freq
-
-! do idf=1,npeaks ! consider the top npeak peaks
- do idf=1,1 ! for genie-aided sync
- fc1=125.0 ! genie provided
- fc2=0.0 ! from the genie
-! fc2=fpks(idf)
- call downsample(c400,fc1+fc2,cd)
- s2=sum(cd*conjg(cd))/(16*412)
- cd=cd/sqrt(s2)
- do is=0,0 ! dt search range is zeroed for genie-aided sync
- idt=is/2
- if( mod(is,2).eq. 1 ) idt=-(is+1)/2
- xdt=real(22+idt)/22.222 - 1.0
- ca=cshift(cd,22+idt)
- zzsum=0.0
- do iseq=3,4
- if(iseq.eq.4) then
- k=1-2*3
- nseq=9
- istep=3*4
- else
- k=1-2*iseq
- nseq=iseq*3
- istep=iseq*4
- endif
- do i=1,408,istep
- j=(i+1)*16
- if(iseq.eq.4) then
-! phase=-1.18596900
-! For now, average complex corr. coeffs over the entire frame to
-! estimate phase
- phase=atan2(imag(zzsum),real(zzsum))
- k=k+3*2
- call mskcohdet(nseq,ca(j),pp,id(k),softbits,phase)
- else
- k=k+iseq*2
- call mskseqdet(nseq,ca(j),pp,id(k),softbits,1,zz)
- zzsum=zzsum+zz
- endif
- sbits(i+1)=softbits(1)
- sbits(i+2)=softbits(2)
- if( id(k+1) .ne. 0 ) sbits(i+2)=id(k+1)*25
- sbits(i+3)=softbits(3)
- if( iseq .ge. 2 ) then
- sbits(i+5)=softbits(4)
- sbits(i+6)=softbits(5)
- if( id(k+3) .ne. 0 ) sbits(i+6)=id(k+3)*25
- sbits(i+7)=softbits(6)
- if( iseq .ge. 3 ) then
- sbits(i+9)=softbits(7)
- sbits(i+10)=softbits(8)
- if( id(k+5) .ne. 0 ) sbits(i+10)=id(k+5)*25
- sbits(i+11)=softbits(9)
- endif
- endif
- enddo
- j=1
- do i=1,205
- if( abs(id(i)) .ne. 2 ) then
- rxdata(j)=sbits(2*i-1)
- j=j+1
- endif
- enddo
- do i=1,204
- rxdata(j)=sbits(2*i)
- j=j+1
- enddo
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- sigma=1.20
- llr=2*rxdata/(sigma*sigma)
- apmask=0
- max_iterations=40
-
- ifer=0
- call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw)
-! niterations will be equal to the Hamming distance between hard received word and the codeword
- nhardmin=0
- if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin)
- if(nhardmin.gt.0) niterations=nhardmin
- nbadcrc=0
- call chkcrc10(decoded,nbadcrc)
- if(nbadcrc.ne.0) ifer=1
-
- if( ifer.eq.0 ) then
- write(cbits,1200) decoded(1:50)
-1200 format(50i1)
- read(cbits,1202) idat
-1202 format(6b8,b2)
- idat(7)=ishft(idat(7),6)
- call wqdecode(idat,message,itype)
- nsnr=nint(xsnr)
-! freq=fMHz + 1.d-6*(fc1+fc2)
- freq=fc1+fc2
- nfdot=0
- write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot
-1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
- write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,is,iseq,niterations
-!1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i3,i3,i3,i4)
-1212 format(a4,i4,f8.3,f8.3,i3,2x,a22,a1,i3,i3,i3,i3,i4)
- goto 888
- endif
- enddo !iseq
- enddo
- enddo
-888 continue
- enddo
-
- write(*,1120)
-1120 format("<DecodeFinished>")
-
-999 end program wspr5d
-
-subroutine getmetric(ib,ps,xmet)
- real ps(0:511)
- xm1=0
- xm0=0
- do i=0,511
- if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) xm1=ps(i)
- if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) xm0=ps(i)
- enddo
- xmet=xm1-xm0
- return
-end subroutine getmetric
-
-subroutine mskseqdet(ns,cdat,pp,bsync,softbits,ncoh,zz)
-!
-! Detect sequences of 3, 6, or 9 bits (ns).
-! Sync bits are assumed to be known.
-!
-complex cdat(16*12),cbest(16*12),cideal(16*12)
-complex cdf(16*12),cfac,zz
-real cm(0:511),cmbest(0:511)
-real pp(32),softbits(9)
-integer bit(13),bestbits(13),sgn(13)
-integer bsync(7)
-
-twopi=8.0*atan(1.0)
-dt=30.0*18.0/12000.0
-cmax=0;
-fbest=0.0;
-np=2**ns-1
-idfmax=40
-if( ncoh .eq. 1 ) idfmax=0
-do idf=0,idfmax
- if( mod(idf,2).eq.0 ) deltaf=idf/2*0.02
- if( mod(idf,2).eq.1 ) deltaf=-(idf+1)/2*0.02
- dphi=twopi*deltaf*dt
- cfac=cmplx(cos(dphi),sin(dphi))
- cdf=1.0
- do i=2,16*(ns-1)
- cdf(i)=cdf(i-1)*cfac
- enddo
-
- cm=0
- ibflag=0
- do i=0,np
- bit(1)=(bsync(1)+2)/4
- bit(2)=iand(i/(2**(ns-1)),1)
- bit(3)=iand(i/(2**(ns-2)),1)
- if( bsync(2).ne.0 ) then ! force the barker bits
- bit(3)=(bsync(2)+2)/4
- endif
- bit(4)=iand(i/(2**(ns-3)),1)
- bit(5)=(bsync(3)+2)/4
-
- if( ns .ge. 6 ) then
- bit(6)=iand(i/(2**(ns-4)),1)
- bit(7)=iand(i/(2**(ns-5)),1)
- if( bsync(4).ne.0 ) then ! force the barker bits
- bit(7)=(bsync(4)+2)/4
- endif
- bit(8)=iand(i/(2**(ns-6)),1)
- bit(9)=(bsync(5)+2)/4
- if( ns .eq. 9 ) then
- bit(10)=iand(i/4,1)
- bit(11)=iand(i/2,1)
- if( bsync(6).ne.0 ) then ! force the barker bits
- bit(11)=(bsync(6)+2)/4
- endif
- bit(12)=iand(i/1,1)
- bit(13)=(bsync(7)+2)/4
- endif
- endif
-
- sgn=2*bit-1
- cideal(1:16) =cmplx(sgn(1)*pp(17:32),sgn(2)*pp(1:16))
- cideal(17:32) =cmplx(sgn(3)*pp(1:16),sgn(2)*pp(17:32))
- cideal(33:48) =cmplx(sgn(3)*pp(17:32),sgn(4)*pp(1:16))
- cideal(49:64) =cmplx(sgn(5)*pp(1:16),sgn(4)*pp(17:32))
- if( ns .ge. 6 ) then
- cideal(65:80) =cmplx(sgn(5)*pp(17:32),sgn(6)*pp(1:16))
- cideal(81:96) =cmplx(sgn(7)*pp(1:16),sgn(6)*pp(17:32))
- cideal(97:112) =cmplx(sgn(7)*pp(17:32),sgn(8)*pp(1:16))
- cideal(113:128)=cmplx(sgn(9)*pp(1:16),sgn(8)*pp(17:32))
- if( ns .eq. 9 ) then
- cideal(129:144) =cmplx(sgn(9)*pp(17:32),sgn(10)*pp(1:16))
- cideal(145:160) =cmplx(sgn(11)*pp(1:16),sgn(10)*pp(17:32))
- cideal(161:176) =cmplx(sgn(11)*pp(17:32),sgn(12)*pp(1:16))
- cideal(177:192)=cmplx(sgn(13)*pp(1:16),sgn(12)*pp(17:32))
- endif
- endif
- cideal=cideal*cdf
- cm(i)=abs(sum(cdat(1:64*ns/3)*conjg(cideal(1:64*ns/3))))/1.e3
- if( cm(i) .gt. cmax ) then
- ibflag=1
- cmax=cm(i)
- bestbits=bit
- cbest=cideal
- fbest=deltaf
- zz=sum(cdat*conjg(cbest))/1.e3
- endif
- enddo
- if( ibflag .eq. 1 ) then ! new best found
- cmbest=cm
- endif
-enddo
-softbits=0.0
-call getmetric(1,cmbest,softbits(ns))
-call getmetric(2,cmbest,softbits(ns-1))
-call getmetric(4,cmbest,softbits(ns-2))
-if( ns .ge. 6 ) then
- call getmetric(8,cmbest,softbits(ns-3))
- call getmetric(16,cmbest,softbits(ns-4))
- call getmetric(32,cmbest,softbits(ns-5))
- if( ns .eq. 9 ) then
- call getmetric(64,cmbest,softbits(3))
- call getmetric(128,cmbest,softbits(2))
- call getmetric(256,cmbest,softbits(1))
- endif
-endif
-end subroutine mskseqdet
-
-subroutine mskcohdet(ns,cdat,pp,bsync,softbits,phase)
-!
-! Coherent demodulate blocks of 9 bits (ns).
-!
- complex cdat(16*12),crot(16*12)
- real pp(32),softbits(9)
-
- np=2**ns-1
-
- softbits=0.0
- crot=cdat*cmplx(cos(phase),-sin(phase))
- softbits(1)=sum(imag(crot(1:32)*pp))
- softbits(2)=sum(real(crot(17:48)*pp))
- softbits(3)=sum(imag(crot(33:64)*pp))
- softbits(4)=sum(imag(crot(65:96)*pp))
- softbits(5)=sum(real(crot(81:112)*pp))
- softbits(6)=sum(imag(crot(97:128)*pp))
- softbits(7)=sum(imag(crot(129:160)*pp))
- softbits(8)=sum(real(crot(145:176)*pp))
- softbits(9)=sum(imag(crot(161:192)*pp))
- softbits=softbits/64.
-end subroutine mskcohdet
-
-subroutine downsample(ci,f0,co)
- parameter(NI=412*288,NO=NI/18)
- complex ci(0:NI-1),ct(0:NI-1)
- complex co(0:NO-1)
-
- df=400.0/NI
- ct=ci
- call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain
- i0=nint(f0/df)
- co=0.0
- co(0)=ct(i0)
-! b=3.0 !optimized for sequence detection
- b=6.0
- do i=1,NO/2
- arg=(i*df/b)**2
- filt=exp(-arg)
- co(i)=ct(i0+i)*filt
- co(NO-i)=ct(i0-i)*filt
- enddo
- co=co/NO
- call four2a(co,NO,1,1,1) !c2c FFT back to time domain
- return
-end subroutine downsample
-
-subroutine getfc1(c,fs,fa,fb,fc1,xsnr)
-
-! include 'wsprlf_params.f90'
- parameter (NZ=288*412)
- parameter (NSPS=288)
- parameter (N2=2*NSPS)
- parameter (NFFT1=16*NSPS)
- parameter (NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
- nspec=NZ/N2
- df1=fs/NFFT1
- s=0.
- do k=1,nspec
- ia=(k-1)*N2
- ib=ia+N2-1
- c2(0:N2-1)=c(ia:ib)
- c2(N2:)=0.
- call four2a(c2,NFFT1,1,-1,1)
- do i=0,NFFT1-1
- j=i
- if(j.gt.NH1) j=j-NFFT1
- s(j)=s(j) + real(c2(i))**2 + aimag(c2(i))**2
- enddo
- enddo
-! call smo121(s,NFFT1)
- smax=0.
- ipk=0
- fc1=0.
- ia=nint(fa/df1)
- ib=nint(fb/df1)
- do i=ia,ib
- f=i*df1
- if(s(i).gt.smax) then
- smax=s(i)
- ipk=i
- fc1=f
- endif
-! write(51,3001) f,s(i),db(s(i))
-! 3001 format(f10.3,e12.3,f10.3)
- enddo
-
-! The following is for testing SNR calibration:
- sp3n=(s(ipk-1)+s(ipk)+s(ipk+1)) !Sig + 3*noise
- base=(sum(s)-sp3n)/(NFFT1-3.0) !Noise per bin
- psig=sp3n-3*base !Sig only
- pnoise=(2500.0/df1)*base !Noise in 2500 Hz
- xsnr=db(psig/pnoise)
- xsnr=xsnr+5.0
- return
-end subroutine getfc1
-
-subroutine getfc2(c,npeaks,fs,fc1,fpks)
-
-! include 'wsprlf_params.f90'
- parameter (NZ=288*412)
- parameter (NSPS=288)
- parameter (N2=2*NSPS)
- parameter (NFFT1=16*NSPS)
- parameter (NH1=NFFT1/2)
-
- complex c(0:NZ-1) !Complex waveform
- complex cs(0:NZ-1) !For computing spectrum
- real a(5)
- real freqs(413),sp2(413),fpks(npeaks)
- integer pkloc(1)
-
- df=fs/NZ
- baud=fs/NSPS
- a(1)=-fc1
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1
-
-! Filter, square, then FFT to get refined carrier frequency fc2.
- call four2a(cs,NZ,1,-1,1) !To freq domain
-
- ia=nint(0.75*baud/df)
- cs(ia:NZ-1-ia)=0. !Save only freqs around fc1
-! do i=1,NZ/2
-! filt=1/(1+((i*df)**2/(0.50*baud)**2)**8)
-! cs(i)=cs(i)*filt
-! cs(NZ+1-i)=cs(NZ+1-i)*filt
-! enddo
- call four2a(cs,NZ,1,1,1) !Back to time domain
- cs=cs/NZ
- cs=cs*cs !Square the data
- call four2a(cs,NZ,1,-1,1) !Compute squared spectrum
-! Find two peaks separated by baud
- pmax=0.
- fc2=0.
-! ja=nint(0.3*baud/df)
- ja=nint(0.5*baud/df)
- k=1
- sp2=0.0
- do j=-ja,ja
- f2=j*df
- ia=nint((f2-0.5*baud)/df)
- if(ia.lt.0) ia=ia+NZ
- ib=nint((f2+0.5*baud)/df)
- p=real(cs(ia))**2 + aimag(cs(ia))**2 + &
- real(cs(ib))**2 + aimag(cs(ib))**2
- if(p.gt.pmax) then
- pmax=p
- fc2=0.5*f2
- endif
- freqs(k)=0.5*f2
- sp2(k)=p
- k=k+1
-! write(52,1200) f2,p,db(p)
-!1200 format(f10.3,2f15.3)
- enddo
-
- do i=1,npeaks
- pkloc=maxloc(sp2)
- ipk=pkloc(1)
- fpks(i)=freqs(ipk)
- ipk0=max(1,ipk-2)
- ipk1=min(413,ipk+2)
-! ipk0=ipk
-! ipk1=ipk
- sp2(ipk0:ipk1)=0.0
- enddo
- return
-end subroutine getfc2
diff --git a/lib/fsk4hf/wspr5sim.f90 b/lib/fsk4hf/wspr5sim.f90
deleted file mode 100644
index 5c2147b9..00000000
--- a/lib/fsk4hf/wspr5sim.f90
+++ /dev/null
@@ -1,111 +0,0 @@
-program wspr5sim
-
-! Generate simulated data for a 5-minute "WSPR-LF" mode. Output is saved
-! to a *.c5 or *.wav file.
-
- use wavhdr
- include 'wsprlf_params.f90' !Set various constants
- parameter (NMAX=300*12000)
- type(hdr) h !Header for .wav file
- character arg*12,fname*16
- character msg*22,msgsent*22
- complex c0(0:NZ-1)
- complex c(0:NZ-1)
- real*8 fMHz
- integer itone(NN)
- integer*2 iwave(NMAX) !Generated full-length waveform
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: wspr5sim "message" f0 DT fsp del nwav nfiles snr'
- print*,'Example: wspr5sim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
- go to 999
- endif
- call getarg(1,msg) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
- 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,*) nwav !1 for *.wav file, 0 for *.c5 file
- call getarg(7,arg)
- read(arg,*) nfiles !Number of files
- call getarg(8,arg)
- read(arg,*) snrdb !SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/NDOWN !Sample rate
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- ts=2*NSPS*dt !Duration of OQPSK symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS0/12000.0
-
- call genwspr5(msg,msgsent,itone) !Encode the message, get itone
- write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
-1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
- ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
-
- dphi0=twopi*(f0-0.25*baud)*dt
- dphi1=twopi*(f0+0.25*baud)*dt
- phi=0.0
- c0=0.
- k=-1 + nint(xdt/dt)
- do j=1,NN !Generate OQPSK waveform from itone
- dphi=dphi0
- if(itone(j).eq.1) dphi=dphi1
- if(k.eq.0) phi=-dphi
- do i=1,NSPS
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi))
- enddo
- enddo
-
- call sgran()
- do ifile=1,nfiles
- c=c0
- if(nwav.eq.0) then
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(c,NZ,fs,delay,fspread)
- endif
- c=c*sig
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Add gaussian noise at specified SNR
- xnoise=gran()
- ynoise=gran()
- c(i)=c(i) + cmplx(xnoise,ynoise)
- enddo
- endif
- write(fname,1100) ifile
-1100 format('000000_',i4.4,'.c5')
- open(10,file=fname,status='unknown',access='stream')
- fMHz=10.1387d0
- nmin=5
- write(10) fname,nmin,fMHz,c !Save to *.c5 file
- close(10)
- else
- call wspr5_wav(baud,xdt,f0,itone,snrdb,iwave)
- h=default_header(12000,NMAX)
- write(fname,1102) ifile
-1102 format('000000_',i4.4,'.wav')
- open(10,file=fname,status='unknown',access='stream')
- write(10) h,iwave !Save to *.wav file
- close(10)
- endif
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
- enddo
-
-999 end program wspr5sim
diff --git a/lib/fsk4hf/wspr_fsk8_downsample.f90 b/lib/fsk4hf/wspr_fsk8_downsample.f90
deleted file mode 100644
index 9750e0cb..00000000
--- a/lib/fsk4hf/wspr_fsk8_downsample.f90
+++ /dev/null
@@ -1,27 +0,0 @@
-subroutine wspr_fsk8_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 12000/24=500 Hz
-
- include 'wspr_fsk8_params.f90'
- integer*2 iwave(NMAX)
- complex c(0:NMAXD-1)
- complex c1(0:NMAXD-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NMAXD/2
- c1(i)=cx(i0+i)
- c1(NMAXD-i)=cx(i0-i)
- enddo
- c=c1/NMAXD
- call four2a(c,NMAXD,1,1,1) !c2c FFT back to time domain
-
- return
-end subroutine wspr_fsk8_downsample
diff --git a/lib/fsk4hf/wspr_fsk8_params.f90 b/lib/fsk4hf/wspr_fsk8_params.f90
deleted file mode 100644
index c080f029..00000000
--- a/lib/fsk4hf/wspr_fsk8_params.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-! LDPC (300,60) code
-parameter (NDOWN=24) !Downsample factor
-parameter (KK=60) !Information bits (50 + CRC10)
-parameter (ND=100) !Data symbols
-parameter (NS=14) !Sync symbols (2 @ Costas 7x7)
-parameter (NN=NS+ND) !Total symbols (114)
-parameter (NSPS0=24576) !Samples per symbol at 12000 S/s
-parameter (NSPS=NSPS0/NDOWN) !Sam/sym, downsampled (1024)
-parameter (N7=7*NSPS) !Samples in Costas 7x7 array (7168)
-parameter (NZ=NSPS*NN) !Samples in downsampled waveform (116,736)
-parameter (NMAX=240*12000) !Samples in iwave()
-parameter (NMAXD=NMAX/24) !Samples in c(), after downsampling
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-parameter (NH2=NSPS/2)
diff --git a/lib/fsk4hf/wspr_fsk8_sim.f90 b/lib/fsk4hf/wspr_fsk8_sim.f90
deleted file mode 100644
index 40d808a0..00000000
--- a/lib/fsk4hf/wspr_fsk8_sim.f90
+++ /dev/null
@@ -1,107 +0,0 @@
-program wspr_fsk8_sim
-
-! Generate simulated data for a 4-minute "WSPR-LF" mode using 8-FSK.
-! Output is saved to a *.wav file.
-
- use wavhdr
- include 'wspr_fsk8_params.f90' !Set various constants
- type(hdr) h !Header for .wav file
- character arg*12,fname*16
- character msg*22,msgsent*22
- complex c0(0:NZ-1)
- complex c(0:NZ-1)
- real*8 fMHz
- integer itone(NN)
- integer*2 iwave(NMAX) !Generated full-length waveform
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: wspr5sim "message" f0 DT fsp del nwav nfiles snr'
- print*,'Example: wspr5sim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
- go to 999
- endif
- call getarg(1,msg) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
- 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,*) nwav !1 for *.wav file, 0 for *.c4 file
- call getarg(7,arg)
- read(arg,*) nfiles !Number of files
- call getarg(8,arg)
- read(arg,*) snrdb !SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/NDOWN !Sample rate after downsampling
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of symbols (s)
- baud=1.0/tt !Keying rate
- bw=8*baud
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS0/12000.0
-
- call genwspr_fsk8(msg,msgsent,itone) !Encode the message, get itone
- write(*,1000) f0,xdt,txt,snrdb,bw,msgsent
-1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, &
- ' BW:',f4.1,2x,a22)
-
-
- phi=0.0
- c0=0.
- k=-1 + nint(xdt/dt)
- do j=1,NN !Generate OQPSK waveform from itone
- dphi=twopi*(f0+itone(j)*baud)*dt
- if(k.eq.0) phi=-dphi
- do i=1,NSPS
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi))
- enddo
- enddo
-
- call sgran()
- do ifile=1,nfiles
- if(nwav.eq.0) then
- c=c0
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(c,NZ,fs,delay,fspread)
- endif
- c=c*sig
- if( snrdb.lt.90) then
- do i=0,NZ-1
- xnoise=gran()
- ynoise=gran()
- c(i)=c(i)+cmplx(xnoise,ynoise)
- enddo
- endif
- write(fname,1100) ifile
-1100 format('000000_',i4.4,'.c4')
- open(10,file=fname,status='unknown',access='stream')
- fMHz=1.866d0
- nmin=4
- write(10) fname,nmin,fMHz,c
- else
- call wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave)
- h=default_header(12000,NMAX)
- write(fname,1102) ifile
-1102 format('000000_',i4.4,'.wav')
- open(10,file=fname,status='unknown',access='stream')
- write(10) h,iwave !Save to *.wav file
- close(10)
- endif
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
- enddo
-
-999 end program wspr_fsk8_sim
diff --git a/lib/fsk4hf/wspr_fsk8_wav.f90 b/lib/fsk4hf/wspr_fsk8_wav.f90
deleted file mode 100644
index 3b0a0ff3..00000000
--- a/lib/fsk4hf/wspr_fsk8_wav.f90
+++ /dev/null
@@ -1,44 +0,0 @@
-subroutine wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wspr_fsk8_params.f90'
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise, rms = 1.0
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint((xdt+1.0)/dt)
- do j=1,NN
- dphi=twopi*(f0+ itone(j)*baud)*dt
- if(k.eq.0) phi=-dphi
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wspr_fsk8_wav
diff --git a/lib/fsk4hf/wspr_fsk8d.f90 b/lib/fsk4hf/wspr_fsk8d.f90
deleted file mode 100644
index 1f69c440..00000000
--- a/lib/fsk4hf/wspr_fsk8d.f90
+++ /dev/null
@@ -1,197 +0,0 @@
-program wspr_fsk8d
-
-! WSPR-LF is a potential WSPR-like mode intended for use at LF and MF.
-! This version uses 4-minute T/R sequences, an LDPC (300,60) code,
-! 8-FSK modulation, and noncoherent demodulation. This decoder reads
-! data from *.wav files.
-
-! Reception and Demodulation algorithm:
-! 1. Compute coarse spectrum; find fc1 = approx carrier freq
-! 2. Mix from fc1 to 0; LPF at +/- 0.75*R
-! 3. Find two 7x7 Costas arrays to get xdt and fc2
-! 4. Mix from fc2 to 0, compute aligned symbol spectra
-! 5. Get soft bits from symbol spectra
-
-! Still to do: find and decode more than one signal in the specified passband.
-
- include 'wspr_fsk8_params.f90'
- character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
- character*120 data_dir
- complex csync(0:N7-1) !Sync symbols for Costas 7x7 array
- complex c1(0:2*N7-1)
- complex c2(0:2*N7-1)
- complex c(0:NMAXD-1) !Complex waveform
- real*8 fMHz
- real rxdata(3*ND),llr(3*ND) !Soft symbols
- real a(5) !For twkfreq1
- real s(0:NH2,NN)
- real savg(0:NH2)
- real ss(0:N7)
- real ss0(0:N7)
- real ps(0:7)
- integer ihdr(11)
- integer*2 iwave(NMAX) !Generated full-length waveform
- integer*1 idat(7)
- integer*1 decoded(KK),apmask(3*ND),cw(3*ND)
- integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
-
- nargs=iargc()
- if(nargs.lt.7) then
- print*,'Usage: wspr_fsk8d -d db -f fMHz -a data_dir file1 [file2 ...]'
- go to 999
- endif
- call getarg(1,arg)
- if(arg(1:3).ne.'-d ') go to 999
- call getarg(2,arg)
- read(arg,*) degrade
- rxbw=3000.
-
- call getarg(3,arg)
- if(arg(1:3).ne.'-f ') go to 999
- call getarg(4,arg)
- read(arg,*) fMHz
-
- call getarg(5,arg)
- if(arg(1:3).ne.'-a ') go to 999
- call getarg(6,data_dir)
-
- open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
- position='append')
-
- twopi=8.0*atan(1.0)
- fs=NSPS*12000.0/NSPS0 !Sample rate after downsampling (Hz)
- dt=1.0/fs !Sample interval (s)
- ts=NSPS*dt !Symbol duration (s)
- baud=1.0/ts !Keying rate (Hz)
- txt=NZ*dt !Transmission length (s)
-
- phi=0.
- k=-1
- do j=0,6
- dphi=twopi*baud*icos7(j)*dt
- do i=1,NSPS
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- k=k+1
- csync(k)=cmplx(cos(phi),sin(phi))
- enddo
- enddo
-
- do ifile=7,nargs
- call getarg(ifile,infile)
- open(10,file=infile,status='old',access='stream')
- j1=index(infile,'.c4')
- j2=index(infile,'.wav')
- if(j1.gt.0) then
- read(10,end=999) fname,ntrmin,fMHz,c(0:NZ-1)
- read(fname(8:11),*) nutc
- write(datetime,'(i11)') nutc
- else if(j2.gt.0) then
- read(10,end=999) ihdr,iwave
- read(infile(j2-4:j2-1),*) nutc
- datetime=infile(j2-11:j2-1)
- if(degrade.gt.0.0) call degrade_snr(iwave,NMAX,degrade,rxbw)
- call wspr_fsk8_downsample(iwave,c)
- else
- print*,'Wrong file format?'
- go to 999
- endif
- close(10)
- pmax=0.
- df1=fs/(2*N7)
- ia=nint(100.0/df1)
- ib=nint(150.0/df1)
- ipk=0
- jpk=0
-! Get xdt and f0 from the sync arrays
- do j0=0,1000,50
- j0b=j0+107*NSPS
- c1(0:N7-1)=c(j0:j0+N7-1)*conjg(csync)
- c1(N7:)=0.
- c2(0:N7-1)=c(j0b:j0b+N7-1)*conjg(csync)
- c2(N7:)=0.
- call four2a(c1,2*N7,1,-1,1)
- call four2a(c2,2*N7,1,-1,1)
- do i=0,N7
- p=1.e-9*(real(c1(i))**2 + aimag(c1(i))**2 + &
- real(c2(i))**2 + aimag(c2(i))**2)
- ss(i)=p
- enddo
- do i=ia,ib
- p=ss(i)
- if(p.gt.pmax) then
- pmax=p
- ipk=i
- jpk=j0
- endif
- enddo
- if(jpk.eq.j0) ss0=ss
- enddo
- f0=ipk*df1
- xdt=jpk*dt - 1.0
-
- sp3n=(ss0(ipk-1)+ss0(ipk)+ss0(ipk+1)) !Sig + 3*noise
- call pctile(ss0,N7,45,base)
- psig=sp3n-3*base !Sig only
- pnoise=(2500.0/df1)*base !Noise in 2500 Hz
- xsnr=db(psig/pnoise) !SNR from sync tones
-
- if(jpk.ge.0) c(0:NMAXD-1-jpk)=c(jpk:NMAXD-1)
-
- a(1)=-f0
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,c) !Mix from f0 down to 0
- call spec8(c,s,savg) !Get symbol spectra
-
- do j=1,ND
- k=j+7
- ps=s(0:7,k)
- ps=sqrt(ps) !### ??? ###
-! ps=log(ps)
- r1=max(ps(1),ps(3),ps(5),ps(7))-max(ps(0),ps(2),ps(4),ps(6))
- r2=max(ps(2),ps(3),ps(6),ps(7))-max(ps(0),ps(1),ps(4),ps(5))
- r4=max(ps(4),ps(5),ps(6),ps(7))-max(ps(0),ps(1),ps(2),ps(3))
- rxdata(3*j-2)=r4
- rxdata(3*j-1)=r2
- rxdata(3*j)=r1
- enddo
-
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- s0=1.1
- llr=2.0*rxdata/(s0*s0)
- apmask=0
- max_iterations=40
- ifer=0
- call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw)
- if(niterations.lt.0) call osd300(llr,apmask,5,decoded,cw,nhardmin,dmin)
- if(nhardmin.ge.0) niterations=nhardmin
- nbadcrc=0
- if(niterations.ge.0) call chkcrc10(decoded,nbadcrc)
- if(niterations.lt.0 .or. nbadcrc.ne.0) ifer=1
- nsnr=nint(xsnr)
-! freq=fMHz + 1.d-6*f0
- freq=1.d-6*(f0+1500)
- nfdot=0
- message=' '
- if(ifer.eq.0) then
- write(cbits,1100) decoded(1:50)
-1100 format(50i1)
- read(cbits,1102) idat
-1102 format(6b8,b2)
- idat(7)=ishft(idat(7),6)
- call wqdecode(idat,message,itype)
- write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message
-1112 format(a4,i4,f5.1,f11.6,i3,2x,a22)
- endif
- write(13,1110) datetime,0,nsnr,xdt,freq,message,nfdot
-1110 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
- enddo ! ifile loop
- write(*,1120)
-1120 format("<DecodeFinished>")
-
-999 end program wspr_fsk8d
-
diff --git a/lib/fsk4hf/wspr_params.f90 b/lib/fsk4hf/wspr_params.f90
deleted file mode 100644
index 18feaea2..00000000
--- a/lib/fsk4hf/wspr_params.f90
+++ /dev/null
@@ -1,23 +0,0 @@
- parameter (NN=162)
- parameter (NSPS0=8192) !Samples per symbol at 12000 S/s
- parameter (NDOWN=32)
- parameter (NSPS=NSPS0/NDOWN)
- parameter (NZ=NSPS*NN) !Samples in waveform at 12000 S/s
- parameter (NZ0=NSPS0*NN) !Samples in waveform at 375 S/s
- parameter (NMAX=120*12000) !Samples in waveform at 375 S/s
-
-! Define the sync vector:
- integer*1 sync(162)
- data sync/ &
- 1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0, &
- 0,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1, &
- 0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1, &
- 1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1, &
- 0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,0,0,0,1,0, &
- 0,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,1,1, &
- 0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,1,1, &
- 0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0, &
- 0,0/
-
-
-
diff --git a/lib/fsk4hf/wspr_wav.f90 b/lib/fsk4hf/wspr_wav.f90
deleted file mode 100644
index 188242bb..00000000
--- a/lib/fsk4hf/wspr_wav.f90
+++ /dev/null
@@ -1,49 +0,0 @@
-subroutine wspr_wav(baud,xdt,h,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wspr_params.f90'
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
- baud=375.0/256.0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=twopi*(f0+h*(itone(j)-1.5)*baud)*dt
- do i=1,NSPS0
- k=k+1
- phi=mod(phi+dphi,twopi)
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(phi)
- enddo
- enddo
-
- rms=100.0
- if(snrdb.lt.90.0) then
- dat=rms*dat;
- if(maxval(abs(dat)).gt.32767.0) print*,"Warning - data will be clipped."
- else
- datpk=maxval(abs(dat))
- fac=32767.9/datpk
- dat=fac*dat
- endif
- iwave=nint(dat)
-
- return
-end subroutine wspr_wav
diff --git a/lib/fsk4hf/wsprcpm_params.f90 b/lib/fsk4hf/wsprcpm_params.f90
deleted file mode 100644
index b09ed86e..00000000
--- a/lib/fsk4hf/wsprcpm_params.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-parameter (KK=64) !Information bits (50 + CRC14) ?
-parameter (ND=200) !Data symbols: LDPC (204,68), r=1/3, don't send last 4 bits
-parameter (NS=16) !Sync symbols (16)
-parameter (NN=NS+ND) !Total symbols (216)
-
-parameter (NSPS0=6400) !Samples per symbol at 12000 S/s
-
-parameter (NDOWN=32) !Downsample to 200 sa/symbol (375 Hz) for candidate selection
-parameter (NSPS=NSPS0/NDOWN) !Samples per symbol
-parameter (NZ=NSPS*NN) !Samples in baseband waveform
-
-parameter (NZ0=NSPS0*NN) !Samples in waveform at 12000 S/s
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
-
diff --git a/lib/fsk4hf/wsprcpm_wav.f90 b/lib/fsk4hf/wsprcpm_wav.f90
deleted file mode 100644
index baf49a94..00000000
--- a/lib/fsk4hf/wsprcpm_wav.f90
+++ /dev/null
@@ -1,44 +0,0 @@
-subroutine wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
-
-! Generate iwave() from itone().
-
- include 'wsprcpm_params.f90'
- parameter (NMAX=120*12000)
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 twopi,dt,dphi0,dphi1,dphi,phi
- real dat(NMAX)
-
- twopi=8.d0*atan(1.d0)
- dt=1.d0/12000.d0
-
- dat=0.
- if(snrdb.lt.90) then
- do i=1,NMAX
- dat(i)=gran() !Generate gaussian noise
- enddo
- bandwidth_ratio=2500.0/6000.0
- sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
- else
- sig=1.0
- endif
-
- phi=0.d0
- k=nint(xdt/dt)
- do j=1,NN
- dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt
- do i=1,NSPS0
- k=k+1
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
- enddo
- enddo
- fac=32767.0
- rms=100.0
- if(snrdb.ge.90.0) iwave=nint(fac*dat)
- if(snrdb.lt.90.0) iwave=nint(rms*dat)
-
- return
-end subroutine wsprcpm_wav
diff --git a/lib/fsk4hf/wsprcpmd.f90 b/lib/fsk4hf/wsprcpmd.f90
deleted file mode 100644
index 281a2415..00000000
--- a/lib/fsk4hf/wsprcpmd.f90
+++ /dev/null
@@ -1,550 +0,0 @@
-program wsprcpmd
-
-! Decode WSPRCPM data read from *.c2 or *.wav files.
-
-! WSPRCPM is a WSPR-like mode based on full-response CPM.
-!
-! Currently configured to use (204,68) r=1/3 LDPC code, regular column weight 3.
-! 50 data bits + 14 bit CRC + 4 "0" bits. The 4 "0" bits are unused bits that
-! are not transmitted. At the decoder, these bits are treated as "AP" bits.
-! This shortens the code to (200,64) r=0.32, slightly decreasing the code rate.
-!
-! Frame format is:
-! d100 p32 d100 (232) channel symbols
-!
- use crc
- include 'wsprcpm_params.f90'
- parameter(NMAX=120*12000)
- character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
- character*22 decodes(100)
- character*120 data_dir
- character*32 uwbits
- character*68 dmsg
- complex c2(0:120*12000/32-1) !Complex waveform
- complex cframe(0:216*200-1) !Complex waveform
- complex cd(0:216*10-1) !Complex waveform
- complex c1(0:9,0:1),c0(0:9,0:1)
- complex ccor(0:1,216)
- complex csum,cterm
- real*8 fMHz
- real rxdata(ND),llr(204) !Soft symbols
- real sbits(216),sbits1(216),sbits3(216)
- real ps(0:8191),psbest(0:8191)
- real candidates(100,2)
- integer iuniqueword0
- integer isync(200) !Unique word
- integer isync2(216)
- integer ipreamble(16) !Preamble vector
- integer ihdr(11)
- integer*2 iwave(NMAX) !Generated full-length waveform
- integer*1,target :: idat(9)
- integer*1 decoded(68),apmask(204),cw(204)
- integer*1 hbits(216),hbits1(216),hbits3(216)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data iuniqueword0/z'30C9E8AD'/
-
- write(uwbits,'(b32.32)') iuniqueword0
- read(uwbits,'(32i1)') isync(1:32)
- read(uwbits,'(32i1)') isync(33:64)
- read(uwbits,'(32i1)') isync(65:96)
- read(uwbits,'(32i1)') isync(97:128)
- read(uwbits,'(32i1)') isync(129:160)
- read(uwbits,'(32i1)') isync(161:192)
- read(uwbits,'(8i1)') isync(193:200)
-
- fs=12000.0/NDOWN !Sample rate
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- h=1.00 !h=0.8 seems to be optimum for AWGN sensitivity (not for fading)
- twopi=8.0*atan(1.0)
-
- isync2(1:100)=isync(1:100)
- isync2(101:104)=0 ! This is *not* backwards.
- isync2(105:112)=1
- isync2(113:116)=0
- isync2(117:216)=isync(101:200)
-
-! data sync tone
-! 0 0 0
-! 0 1 1
-! 1 0 2
-! 1 1 3
- dphi=twopi*baud*(h/2.0)*dt*20 ! dt*10 is samp interval after downsample
- do j=0,1
- if(j.eq.0) then
- dphi0=-3*dphi
- dphi1=+1*dphi
- else
- dphi0=-1*dphi
- dphi1=+3*dphi
- endif
- phi0=0.0
- phi1=0.0
- do i=0,9
- c1(i,j)=cmplx(cos(phi1),sin(phi1))
- c0(i,j)=cmplx(cos(phi0),sin(phi0))
- phi1=mod(phi1+dphi1,twopi)
- phi0=mod(phi0+dphi0,twopi)
- enddo
- enddo
-
- nargs=iargc()
- if(nargs.lt.1) then
- print*,'Usage: wsprcpmd [-a <data_dir>] [-f fMHz] [-c ncoh] file1 [file2 ...]'
- go to 999
- endif
- iarg=1
- data_dir="."
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-a') then
- call getarg(iarg+1,data_dir)
- iarg=iarg+2
- endif
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-f') then
- call getarg(iarg+1,arg)
- read(arg,*) fMHz
- iarg=iarg+2
- endif
- ncoh=1
- npdi=16
- if(arg(1:2).eq.'-c') then
- call getarg(iarg+1,arg)
- read(arg,*) ncoh
- iarg=iarg+2
- npdi=16/ncoh
- endif
-! write(*,*) 'ncoh: ',ncoh,' npdi: ',npdi
-
- open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
- position='append')
-
- xs1=0.0
- xs2=0.0
- fr1=0.0
- fr2=0.0
- nav=0
- ngood=0
-
- do ifile=iarg,nargs
- call getarg(ifile,infile)
- open(10,file=infile,status='old',access='stream')
- j1=index(infile,'.c2')
- j2=index(infile,'.wav')
- if(j1.gt.0) then
- read(10,end=999) fname,ntrmin,fMHz,c2
- read(fname(8:11),*) nutc
- write(datetime,'(i11)') nutc
- else if(j2.gt.0) then
- read(10,end=999) ihdr,iwave
- read(infile(j2-4:j2-1),*) nutc
- datetime=infile(j2-11:j2-1)
- call wsprcpm_downsample(iwave,c2)
- else
- print*,'Wrong file format?'
- go to 999
- endif
- close(10)
-
- fa=-100.0
- fb=100.0
- fs=12000.0/32.0
- npts=120*12000.0/32.0
- nsync=16
- call getcandidate2(c2,npts,fs,fa,fb,ncand,candidates) !First approx for freq
-ndecodes=0
-do icand=1,ncand
- fc0=candidates(icand,1)
- xsnr=candidates(icand,2)
- xmax=-1e32
- do i=-5,5
- ft=fc0+i*0.2
- call noncoherent_frame_sync(c2,ft,isync2,is,xf1)
- if(xf1.gt.xmax) then
- xmax=xf1
- fc1=ft
- is0=is
- endif
- enddo
- call coherent_preamble_fsync(c2,ipreamble,nsync,NSPS,is0,fc1,fcest,xp1)
- call noncoherent_frame_sync(c2,fcest,isync2,istart,xf2)
- write(*,'(i5,i5,i5,4(f11.5,2x))') ifile,iii,istart,fc0,fc1,fcest
-
-do ijitter=0,4
- io=-10*(ijitter/2+1)
- if(mod(ijitter,2).eq.0) io=10*(ijitter/2)
- ib=max(0,istart+io)
- cframe=c2(ib:ib+216*200-1)
- call downsample2(cframe,fcest,cd)
-
- s2=sum(cd*conjg(cd))/(10*216)
- cd=cd/sqrt(s2)
-
- do nseq=1,7
- if( nseq.eq.1 ) then ! noncoherent single-symbol detection
- sbits1=0.0
- do ibit=1,216
- j=isync2(ibit)
- ib=(ibit-1)*10
- ccor(1,ibit)=sum(cd(ib:ib+9)*conjg(c1(0:9,j)))
- ccor(0,ibit)=sum(cd(ib:ib+9)*conjg(c0(0:9,j)))
- sbits1(ibit)=abs(ccor(1,ibit))-abs(ccor(0,ibit))
- hbits1(ibit)=0
- if(sbits1(ibit).gt.0) hbits1(ibit)=1
- enddo
- sbits=sbits1
- hbits=hbits1
- sbits3=sbits1
- hbits3=hbits1
- elseif( nseq.ge.2 ) then
- ps=0
- if( nseq.eq. 2 ) nbit=3
- if( nseq.eq. 3 ) nbit=5
- if( nseq.eq. 4 ) nbit=7
- if( nseq.eq. 5 ) nbit=9
- if( nseq.eq. 6 ) nbit=11
- if( nseq.eq. 7 ) nbit=13
- numseq=2**(nbit)
- do ibit=nbit/2+1,216-nbit/2
- ps=0.0
- pmax=0.0
- do iseq=0,numseq-1
- csum=0.0
- cterm=1.0
- k=1
- do i=nbit-1,0,-1
- ibb=iand(iseq/(2**i),1)
- csum=csum+ccor(ibb,ibit-(nbit/2+1)+k)*cterm
- cterm=-cterm
- k=k+1
- enddo
- ps(iseq)=abs(csum)
- if( ps(iseq) .gt. pmax ) then
- pmax=ps(iseq)
- ibflag=1
- endif
- enddo
- if( ibflag .eq. 1 ) then
- psbest=ps
- ibflag=0
- endif
- call getmetric2(2**(nbit/2),psbest,numseq,sbits3(ibit))
- hbits3(ibit)=0
- if(sbits3(ibit).gt.0) hbits3(ibit)=1
- enddo
- sbits=sbits3
- hbits=hbits3
- endif
- rxdata(1:100)=sbits(1:100)
- rxdata(101:200)=sbits(117:216);
- rxav=sum(rxdata(1:200))/200.0
- rx2av=sum(rxdata(1:200)*rxdata(1:200))/200.0
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- sigma=0.90
- llr(201:204)=-5.0
- llr(1:200)=2*rxdata/(sigma*sigma)
- apmask=0
- apmask(201:204)=1
- max_iterations=40
- ifer=0
- call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations)
- nhardmin=-1
- if(nharderror.lt.0) call osd204(llr,apmask,5,decoded,cw,nhardmin,dmin)
- if(sum(decoded).eq.0) cycle
- if(nhardmin.ge.0 .or. nharderror.ge.0) then
- idat=0
- write(dmsg,'(68i1)') decoded
- read(dmsg(1:50),'(6b8.8,b2.2)') idat(1:7)
- idat(7)=idat(7)*64
- read(dmsg(51:64),'(b14.14)') ndec_crc
- ncalc_crc=iand(crc14(c_loc(idat),9),z'FFFF')
- nbadcrc=1
- if(ncalc_crc .eq. ndec_crc) nbadcrc=0
- else
- cycle
- endif
- if( nbadcrc.eq.0 ) then
- write(cbits,1200) decoded(1:50)
-1200 format(50i1)
- read(cbits,1202) idat
-1202 format(8b8,b4)
- idat(7)=ishft(idat(7),6)
- call wqdecode(idat,message,itype)
- idupe=0
- do i=1,ndecodes
- if(decodes(i).eq.message) idupe=1
- enddo
- if(idupe.eq.1) goto 888
- ndecodes=ndecodes+1
- decodes(ndecodes)=message
- nsnr=nint(xsnr)
- freq=fMHz + 1.d-6*(fc1+fbest)
- nfdot=0
- write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot
-1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
- write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,ijitter,nharderror,nhardmin
-1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i5,i5,i5,i5,i5)
- goto 888
- endif
- enddo ! nseq
-enddo !jitter
-888 continue
-enddo !candidate list
- enddo !files
-
- write(*,1120)
-1120 format("<DecodeFinished>")
-
-999 end program wsprcpmd
-
-
-subroutine coherent_preamble_fsync(c2,ipreamble,nsync,nsps,istart,fc0,fc1,xmax)
- complex c2(0:120*12000/32-1)
- complex cpreamble(0:16*200-1)
- complex ctmp1(0:4*16*200-1)
- complex ctwkp(0:16*200-1)
- complex ccohp(0:15)
- integer ipreamble(nsync)
- logical first/.true./
- save dt,first,h,twopi,cpreamble
-
- if(first) then
- baud=12000.0/6400.0
- dt=32.0/12000.0
- h=1.00
- twopi=8.0*atan(1.0)
- k=0
- phi=0.0
- dphi=twopi*baud*0.5*h*dt
- do i=1,16
- dp=dphi
- if(ipreamble(i).eq.0) dp=-dphi
- do j=1,200
- cpreamble(k)=cmplx(cos(phi),sin(phi))
- phi=mod(phi+dp,twopi)
- k=k+1
- enddo
- enddo
- first=.false.
- endif
-
- dphi=twopi*fc0*dt
- ctwkp=cmplx(0.0,0.0)
- phi=0
- do i=0,nsync*nsps-1
- ctwkp(i)=cpreamble(i)*cmplx(cos(phi),sin(phi))
- phi=mod(phi+dphi,twopi)
- enddo
- ipstart=istart+100*200
- ctmp1=0.0
- ctmp1(0:16*200-1)=c2(ipstart:ipstart+16*200-1)*conjg(ctwkp)
- call four2a(ctmp1,4*16*200,1,-1,1) !c2c FFT to freq domain
- xmax=0.0
- ctmp1=cshift(ctmp1,-200)
- dfp=1/(4*6400.0/12000.0*16)
- do i=150,250
- xa=abs(ctmp1(i))
- if(xa.gt.xmax) then
- ishift=i
- xmax=xa
- endif
- enddo
- delta=(ishift-200)*dfp
- xm1=abs(ctmp1(ishift-1))
- x0=abs(ctmp1(ishift))
- xp1=abs(ctmp1(ishift+1))
- xint=(log(xm1)-log(xp1))/(log(xm1)+log(xp1)-2*log(x0))
- delta2=delta+xint*dfp/2.0
- fc1=fc0+delta2
- return
-end subroutine coherent_preamble_fsync
-
-
-subroutine noncoherent_frame_sync(c2,fc,isync2,istart,ssmax)
- complex c2(0:120*12000/32-1)
- complex ct0(0:199),ct1(0:199),ct2(0:199),ct3(0:199)
- integer isync2(216)
-
- twopi=8.0*atan(1.0)
- h=1.0
- dt=32.0/12000.0
- baud=12000.0/6400.0
- imax=370 ! defines dt search range (375 samples/s)
- ssmax=-1e32
- izero=375
- do it = -imax,imax,10
-! noncoherent wspr-type dt estimation
- dp0=twopi*(fc-1.5*h*baud)*dt
- dp1=twopi*(fc-0.5*h*baud)*dt
- dp2=twopi*(fc+0.5*h*baud)*dt
- dp3=twopi*(fc+1.5*h*baud)*dt
- th0=0.0
- th1=0.0
- th2=0.0
- th3=0.0
- do i=0,199
- ct0(i)=cmplx(cos(th0),sin(th0))
- ct1(i)=cmplx(cos(th1),sin(th1))
- ct2(i)=cmplx(cos(th2),sin(th2))
- ct3(i)=cmplx(cos(th3),sin(th3))
- th0=mod(th0+dp0,twopi)
- th1=mod(th1+dp1,twopi)
- th2=mod(th2+dp2,twopi)
- th3=mod(th3+dp3,twopi)
- enddo
- ss=0.0
- totp=0.0
- do is=1,216
- i0=izero+it+(is-1)*200
- p0=abs(sum(c2(i0:i0+199)*conjg(ct0)))
- p1=abs(sum(c2(i0:i0+199)*conjg(ct1)))
- p2=abs(sum(c2(i0:i0+199)*conjg(ct2)))
- p3=abs(sum(c2(i0:i0+199)*conjg(ct3)))
- p0=sqrt(p0)
- p1=sqrt(p1)
- p2=sqrt(p2)
- p3=sqrt(p3)
-
- totp=totp+p0+p1+p2+p3
-! cmet=(p1+p3)-(p0+p2)
- cmet=max(p1,p3)-max(p0,p2) ! This works better near threshold SNR
- if(isync2(is).eq.0) ss=ss-cmet
- if(isync2(is).eq.1) ss=ss+cmet
- enddo
- ss=ss/totp
- if(ss.gt.ssmax) then
- ioffset=it
- ssmax=ss
- endif
- enddo
- istart=izero+ioffset
- return
-end subroutine noncoherent_frame_sync
-
-subroutine getmetric2(ib,ps,ns,xmet)
- real ps(0:ns-1)
- xm1=0
- xm0=0
- do i=0,ns-1
- if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) xm1=ps(i)
- if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) xm0=ps(i)
- enddo
- xmet=xm1-xm0
- return
-end subroutine getmetric2
-
-subroutine downsample2(ci,f0,co)
- parameter(NI=216*200,NH=NI/2,NO=NI/20) ! downsample from 200 samples per symbol to 10
- complex ci(0:NI-1),ct(0:NI-1)
- complex co(0:NO-1)
- fs=12000.0/32.0
- df=fs/NI
- ct=ci
- call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain
- i0=nint(f0/df)
- ct=cshift(ct,i0)
- co=0.0
- co(0)=ct(0)
- b=8.0
- do i=1,NO/2
- arg=(i*df/b)**2
- filt=exp(-arg)
- co(i)=ct(i)*filt
- co(NO-i)=ct(NI-i)*filt
- enddo
- co=co/NO
- call four2a(co,NO,1,1,1) !c2c FFT back to time domain
- return
-end subroutine downsample2
-
-subroutine getcandidate2(c,npts,fs,fa,fb,ncand,candidates)
- parameter(NDAT=200,NFFT1=120*12000/32,NH1=NFFT1/2,NFFT2=120*12000/320,NH2=NFFT2/2)
- complex c(0:npts-1) !Complex waveform
- complex cc(0:NFFT1-1)
- complex csfil(0:NFFT2-1)
- complex cwork(0:NFFT2-1)
- real bigspec(0:NFFT2-1)
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
- real ss(-NH1+1:NH1) !Smoothed coarse spectrum
- real candidates(100,2)
- integer indx(NFFT2-1)
- logical first
- data first/.true./
- save first,w,df,csfil
-
- if(first) then
- df=10*fs/NFFT1
- csfil=cmplx(0.0,0.0)
- do i=0,NFFT2-1
- csfil(i)=exp(-((i-NH2)/20.0)**2)
- enddo
- csfil=cshift(csfil,NH2)
- call four2a(csfil,NFFT2,1,-1,1)
- first=.false.
- endif
-
- cc=cmplx(0.0,0.0)
- cc(0:npts-1)=c;
- call four2a(cc,NFFT1,1,-1,1)
- cc=abs(cc)**2
- call four2a(cc,NFFT1,1,-1,1)
- cwork(0:NH2)=cc(0:NH2)*conjg(csfil(0:NH2))
- cwork(NH2+1:NFFT2-1)=cc(NFFT1-NH2+1:NFFT1-1)*conjg(csfil(NH2+1:NFFT2-1))
-
- call four2a(cwork,NFFT2,1,+1,1)
- bigspec=cshift(real(cwork),-NH2)
- il=NH2+fa/df
- ih=NH2+fb/df
- nnl=ih-il+1
- call indexx(bigspec(il:il+nnl-1),nnl,indx)
- xn=bigspec(il-1+indx(nint(0.3*nnl)))
- bigspec=bigspec/xn
- ncand=0
- do i=il,ih
- if((bigspec(i).gt.bigspec(i-1)).and. &
- (bigspec(i).gt.bigspec(i+1)).and. &
- (bigspec(i).gt.1.15).and.ncand.lt.100) then
- ncand=ncand+1
- candidates(ncand,1)=df*(i-NH2)
- candidates(ncand,2)=10*log10(bigspec(i))-30.0
- endif
- enddo
-! do i=1,ncand
-! write(*,*) i,candidates(i,1),candidates(i,2)
-! enddo
- return
-end subroutine getcandidate2
-
-subroutine wsprcpm_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 400 Hz
-
- include 'wsprcpm_params.f90'
- parameter (NMAX=120*12000,NFFT2=NMAX/32)
- integer*2 iwave(NMAX)
- complex c(0:NMAX/32-1)
- complex c1(0:NFFT2-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NFFT2/2
- c1(i)=cx(i0+i)
- c1(NFFT2-i)=cx(i0-i)
- enddo
- c1=c1/NFFT2
- call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
- c=c1(0:NMAX/32-1)
- return
-end subroutine wsprcpm_downsample
-
diff --git a/lib/fsk4hf/wsprcpmsim.f90 b/lib/fsk4hf/wsprcpmsim.f90
deleted file mode 100644
index 6a1f87f3..00000000
--- a/lib/fsk4hf/wsprcpmsim.f90
+++ /dev/null
@@ -1,109 +0,0 @@
-program wsprcpmsim
-
-! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved
-! to a *.c2 or *.wav file.
-
- use wavhdr
- include 'wsprcpm_params.f90' !Set various constants
- parameter (NMAX=120*12000)
- type(hdr) hwav !Header for .wav file
- character arg*12,fname*16
- character msg*22,msgsent*22
- complex c0(0:NMAX/NDOWN-1)
- complex c(0:NMAX/NDOWN-1)
- real*8 fMHz
- integer itone(NN)
- integer*2 iwave(NMAX) !Generated full-length waveform
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: wsprmsksim "message" f0 DT fsp del nwav nfiles snr'
- print*,'Example: wsprmsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
- go to 999
- endif
- call getarg(1,msg) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
- 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,*) nwav !1 for *.wav file, 0 for *.c2 file
- call getarg(7,arg)
- read(arg,*) nfiles !Number of files
- call getarg(8,arg)
- read(arg,*) snrdb !SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/NDOWN !
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS0/12000.0
-
- call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone
- write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
-1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
- ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
-
- h=1.00
- c0=0.
- k=-1 + nint(xdt/dt)
- do j=1,NN
- dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt
- do i=1,NSPS
- k=k+1
- phi=mod(phi+dp,twopi)
- if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi))
- enddo
- enddo
- call sgran()
- do ifile=1,nfiles
- c=c0
- if(nwav.eq.0) then
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(c,NMAX/NDOWN,fs,delay,fspread)
- endif
-!do i=0,NMAX/NDOWN-1
-!write(23,*) i,real(c(i)),imag(c(i))
-!enddo
- c=c*sig
- if(snrdb.lt.90) then
- do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
- xnoise=gran()
- ynoise=gran()
- c(i)=c(i) + cmplx(xnoise,ynoise)
- enddo
- endif
- write(fname,1100) ifile
-1100 format('000000_',i4.4,'.c2')
- open(10,file=fname,status='unknown',access='stream')
- fMHz=10.1387d0
- nmin=2
- write(10) fname,nmin,fMHz,c !Save to *.c2 file
- close(10)
-!do i=0,NMAX/NDOWN-1
-!write(57,*) i,real(c(i)),imag(c(i))
-!enddo
- else
- call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
- hwav=default_header(12000,NMAX)
- write(fname,1102) ifile
-1102 format('000000_',i4.4,'.wav')
- open(10,file=fname,status='unknown',access='stream')
- write(10) hwav,iwave !Save to *.wav file
- close(10)
- endif
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
- enddo
-
-999 end program wsprcpmsim
diff --git a/lib/fsk4hf/wsprdpskd.f90 b/lib/fsk4hf/wsprdpskd.f90
deleted file mode 100644
index 223e2e4f..00000000
--- a/lib/fsk4hf/wsprdpskd.f90
+++ /dev/null
@@ -1,439 +0,0 @@
-program wsprdpskd
-
-! Decode WSPRDPSK data read from *.c2 or *.wav files.
-
-! Currently configured to use (204,68) r=1/3 LDPC code, regular column weight 3.
-! 50 data bits + 14 bit CRC + 4 "0" bits. The 4 "0" bits are unused bits that
-! are not transmitted. At the decoder, these bits are treated as "AP" bits.
-! This shortens the code to (200,64) r=0.32, slightly decreasing the code rate.
-! Frame format is:
-! d100 p32 d100 (232) channel symbols
-!
- use crc
- include 'wsprdpsk_params.f90'
- parameter(NMAX=120*12000)
- character arg*8,message*22,cbits*50,infile*80,fname*16,datetime*11
- character*22 decodes(100)
- character*120 data_dir
- character*32 uwbits
- character*68 dmsg
- complex c2(0:120*12000/30-1) !Complex waveform
- complex cframe(0:232*200-1) !Complex waveform
- complex cd(0:240*10-1) !Complex waveform
- complex cs(0:240)
- complex c1(0:9,0:1),c0(0:9,0:1)
- complex ccor(0:1,232)
- complex csum,cterm
- real*8 fMHz
- real rxdata(ND),llr(204) !Soft symbols
- real sbits(232),sbits1(232),sbits3(232)
- real ps(0:8191),psbest(0:8191)
- real candidates(100,2)
- integer iuniqueword0
- integer isync(200) !Unique word
- integer isync2(232)
- integer ipreamble(16) !Preamble vector
- integer ihdr(11)
- integer*2 iwave(NMAX) !Generated full-length waveform
- integer*1,target :: idat(9)
- integer*1 decoded(68),apmask(204),cw(204)
- integer*1 hbits(232),hbits1(232),hbits3(232)
- integer*1 b(14),bbest(14)
- data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
- data iuniqueword0/z'30C9E8AD'/
-
- write(uwbits,'(b32.32)') iuniqueword0
- read(uwbits,'(32i1)') isync(1:32)
- read(uwbits,'(32i1)') isync(33:64)
- read(uwbits,'(32i1)') isync(65:96)
- read(uwbits,'(32i1)') isync(97:128)
- read(uwbits,'(32i1)') isync(129:160)
- read(uwbits,'(32i1)') isync(161:192)
- read(uwbits,'(8i1)') isync(193:200)
-
- fs=12000.0/NDOWN !Sample rate
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- h=1.00 !h=0.8 seems to be optimum for AWGN sensitivity (not for fading)
- twopi=8.0*atan(1.0)
-
- isync2(1:100)=isync(1:100)
- isync2(101:104)=0 ! This is *not* backwards.
- isync2(105:112)=1
- isync2(113:116)=0
- isync2(117:216)=isync(101:200)
-
- dphi=twopi*baud*(h/2.0)*dt*20 ! dt*20 is samp interval after downsample
- do j=0,1
- if(j.eq.0) then
- dphi0=-3*dphi
- dphi1=+1*dphi
- else
- dphi0=-1*dphi
- dphi1=+3*dphi
- endif
- phi0=0.0
- phi1=0.0
- do i=0,9
- c1(i,j)=cmplx(cos(phi1),sin(phi1))
- c0(i,j)=cmplx(cos(phi0),sin(phi0))
- phi1=mod(phi1+dphi1,twopi)
- phi0=mod(phi0+dphi0,twopi)
- enddo
- enddo
-
- nargs=iargc()
- if(nargs.lt.1) then
- print*,'Usage: wsprdpskd [-a <data_dir>] [-f fMHz] [-c ncoh] file1 [file2 ...]'
- go to 999
- endif
- iarg=1
- data_dir="."
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-a') then
- call getarg(iarg+1,data_dir)
- iarg=iarg+2
- endif
- call getarg(iarg,arg)
- if(arg(1:2).eq.'-f') then
- call getarg(iarg+1,arg)
- read(arg,*) fMHz
- iarg=iarg+2
- endif
- ncoh=1
- npdi=16
- if(arg(1:2).eq.'-c') then
- call getarg(iarg+1,arg)
- read(arg,*) ncoh
- iarg=iarg+2
- npdi=16/ncoh
- endif
-! write(*,*) 'ncoh: ',ncoh,' npdi: ',npdi
-
- open(13,file=trim(data_dir)//'/ALL_WSPR.TXT',status='unknown', &
- position='append')
-
- xs1=0.0
- xs2=0.0
- fr1=0.0
- fr2=0.0
- nav=0
- ngood=0
-
- do ifile=iarg,nargs
- call getarg(ifile,infile)
- open(10,file=infile,status='old',access='stream')
- j1=index(infile,'.c2')
- j2=index(infile,'.wav')
- if(j1.gt.0) then
- read(10,end=999) fname,ntrmin,fMHz,c2
- read(fname(8:11),*) nutc
- write(datetime,'(i11)') nutc
- else if(j2.gt.0) then
- read(10,end=999) ihdr,iwave
- read(infile(j2-4:j2-1),*) nutc
- datetime=infile(j2-11:j2-1)
- call wsprdpsk_downsample(iwave,c2)
- else
- print*,'Wrong file format?'
- go to 999
- endif
- close(10)
-
- fa=-10.0
- fb=10.0
- fs=12000.0/30.0
- npts=120*12000.0/30.0
-! call getcandidate2(c2,npts,fs,fa,fb,ncand,candidates) !First approx for freq
- ncand=1
- candidates(1,1)=0.0
- candidates(1,2)=-28
- ndecodes=0
- do icand=1,ncand
- fc0=candidates(icand,1)
- xsnr=candidates(icand,2)
- call dsdpsk(c2,fc0,cd)
- i0=40
- do i=0,231
- cs(i)=cd(i0+10*i)/5e4
- enddo
-! 2-bit differential detection
- do i=1,231
-! do i=1,232
- sbits(i)=-real(cs(i)*conjg(cs(i-1))) !2 symbol dpsk
-! sbits(i)=real(cs(i-1)) !for coherent dpsk
-! sbits(i)=real(cs(i)) !for coherent bpsk
- enddo
-! do i=1,231
-! sbits3(i)=-sbits(i+1)*sbits(i) ! for coherent dpsk
-! enddo
-
-! detect a differentially encoded block of symbols using the
-! Divsalar and Simon approach, except that we estimate only
-! the central symbol of the block and then step the block forward
-! by one symbol.
-!
- sbits3=sbits
-!goto 100
- nbit=13 ! number of decoded bits to be derived from nbit+1 symbols
- numseq=2**nbit
- il=(nbit+1)/2
- ih=231-nbit/2
- do isym=il,ih
- rmax=-1e32
- b=0
- do iseq=0,numseq-1
- do i=1,nbit
- b(i)=merge(1,0,iand(iseq,2**(nbit-i))>0)
- enddo
- b(1:nbit)=2*b(1:nbit)-1
- i1=isym-(nbit+1)/2
- csum=cs(i1)
- do i=1,nbit
- bb=1
- do m=1,i
- bb=bb*b(m)
- enddo
- csum=csum+bb*cs(i1+i)
- enddo
-! ps(iseq)=abs(csum)**2
- ps(iseq)=abs(csum)
- if(ps(iseq).gt.rmax) then
- bbest=b
- rmax=ps(iseq)
- endif
- enddo
- if(isym.eq.il) then
- do i=1,isym-1
- call getmetric(2**(nbit-i),ps,numseq,xmet)
- sbits3(i)=-xmet
- enddo
- endif
- call getmetric(2**((nbit-1)/2),ps,numseq,xmet)
- sbits3(isym)=-xmet
- if(isym.eq.ih) then
- do i=ih+1,231
- call getmetric(2**(231-i),ps,numseq,xmet)
- sbits3(i)=-xmet
- enddo
- endif
- enddo
-100 continue
- rxdata(1:100)=sbits3(1:100)
- rxdata(101:200)=sbits3(132:231);
- rxav=sum(rxdata(1:200))/200.0
- rx2av=sum(rxdata(1:200)*rxdata(1:200))/200.0
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- sigma=0.90
- llr(201:204)=-5.0
- llr(1:200)=2*rxdata/(sigma*sigma)
- apmask=0
- apmask(201:204)=1
- max_iterations=40
- ifer=0
- call bpdecode204(llr,apmask,max_iterations,decoded,cw,nharderror,niterations)
- nhardmin=-1
- if(nharderror.lt.0) call osd204(llr,apmask,5,decoded,cw,nhardmin,dmin)
- if(sum(decoded).eq.0) cycle
- if(nhardmin.ge.0 .or. nharderror.ge.0) then
- idat=0
- write(dmsg,'(68i1)') decoded
- read(dmsg(1:50),'(6b8.8,b2.2)') idat(1:7)
- idat(7)=idat(7)*64
- read(dmsg(51:64),'(b14.14)') ndec_crc
- ncalc_crc=iand(crc14(c_loc(idat),9),z'FFFF')
- nbadcrc=1
- if(ncalc_crc .eq. ndec_crc) nbadcrc=0
- else
- cycle
- endif
- if( nbadcrc.eq.0 ) then
- write(cbits,1200) decoded(1:50)
-1200 format(50i1)
- read(cbits,1202) idat
-1202 format(8b8,b4)
- idat(7)=ishft(idat(7),6)
- call wqdecode(idat,message,itype)
- idupe=0
- do i=1,ndecodes
- if(decodes(i).eq.message) idupe=1
- enddo
- if(idupe.eq.1) goto 888
- ndecodes=ndecodes+1
- decodes(ndecodes)=message
- nsnr=nint(xsnr)
- freq=fMHz + 1.d-6*(fc1+fbest)
- nfdot=0
- write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot
-1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
- write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',idf,nseq,ijitter,nharderror,nhardmin
-1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i5,i5,i5,i5,i5)
- goto 888
- endif
-888 continue
- enddo !candidate list
- enddo !files
-
- write(*,1120)
-1120 format("<DecodeFinished>")
-
-999 end program wsprdpskd
-
-subroutine getmetric(ib,ps,ns,xmet)
- real ps(0:ns-1)
- xm1=-1e32
- xm0=-1e32
- do i=0,ns-1
- if( iand(i/ib,1) .eq. 1 .and. ps(i) .gt. xm1 ) then
- xm1=ps(i)
- endif
- if( iand(i/ib,1) .eq. 0 .and. ps(i) .gt. xm0 ) then
- xm0=ps(i)
- endif
- enddo
- xmet=xm1-xm0
- return
-end subroutine getmetric
-
-subroutine getmetric3(ib,ps,ns,xmet)
- real ps(0:ns-1)
- xm1=0
- xm0=0
- do i=0,ns-1
- if( iand(i/ib,1) .eq. 1 ) then
- xm1=xm1+ps(i)
- endif
- if( iand(i/ib,1) .eq. 0 ) then
- xm0=xm0+ps(i)
- endif
- enddo
- xmet=xm1-xm0
- return
-end subroutine getmetric3
-
-subroutine dsdpsk(ci,f0,co)
- parameter(NI=240*200,NH=NI/2,NO=NI/20) ! downsample from 200 samples per symbol to 10
- complex ci(0:NI-1),ct(0:NI-1)
- complex co(0:NO-1)
-
- pi=4.0*atan(1.0)
- fs=12000.0/30.0
- df=fs/NI
- ct=ci
- call four2a(ct,NI,1,-1,1) !c2c FFT to freq domain
- i0=nint(f0/df)
- ct=cshift(ct,i0)
- co=0.0
- co(0)=ct(0)
-
- dt=20/fs
- beta=1.0
- tt=10*dt
- baud=1/tt
- bw=(1+beta)*baud/2.0
- bf=(1-beta)*baud/2.0
- iw=bw/df
- if=bf/df
- co=0.0
- co(0)=ct(0)
- do i=1,iw
- filt=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5
- co(i)=ct(i)*filt
- co(NO-i)=ct(NI-i)*filt
- enddo
- co=co/NO
- call four2a(co,NO,1,1,1) !c2c FFT back to time domain
- return
-end subroutine dsdpsk
-
-subroutine getcandidate2(c,npts,fs,fa,fb,ncand,candidates)
- parameter(NDAT=200,NFFT1=120*12000/30,NH1=NFFT1/2,NFFT2=120*12000/300,NH2=NFFT2/2)
- complex c(0:npts-1) !Complex waveform
- complex cc(0:NFFT1-1)
- complex csfil(0:NFFT2-1)
- complex cwork(0:NFFT2-1)
- real bigspec(0:NFFT2-1)
- complex c2(0:NFFT1-1) !Short spectra
- real s(-NH1+1:NH1) !Coarse spectrum
- real ss(-NH1+1:NH1) !Smoothed coarse spectrum
- real candidates(100,2)
- integer indx(NFFT2-1)
- logical first
- data first/.true./
- save first,w,df,csfil
-
- if(first) then
- df=10*fs/NFFT1
- csfil=cmplx(0.0,0.0)
- do i=0,NFFT2-1
- csfil(i)=exp(-((i-NH2)/20.0)**2)
- enddo
- csfil=cshift(csfil,NH2)
- call four2a(csfil,NFFT2,1,-1,1)
- first=.false.
- endif
-
- cc=cmplx(0.0,0.0)
- cc(0:npts-1)=c;
- call four2a(cc,NFFT1,1,-1,1)
- cc=abs(cc)**2
- call four2a(cc,NFFT1,1,-1,1)
- cwork(0:NH2)=cc(0:NH2)*conjg(csfil(0:NH2))
- cwork(NH2+1:NFFT2-1)=cc(NFFT1-NH2+1:NFFT1-1)*conjg(csfil(NH2+1:NFFT2-1))
-
- call four2a(cwork,NFFT2,1,+1,1)
- bigspec=cshift(real(cwork),-NH2)
- il=NH2+fa/df
- ih=NH2+fb/df
- nnl=ih-il+1
- call indexx(bigspec(il:il+nnl-1),nnl,indx)
- xn=bigspec(il-1+indx(nint(0.3*nnl)))
- bigspec=bigspec/xn
- ncand=0
- do i=il,ih
- if((bigspec(i).gt.bigspec(i-1)).and. &
- (bigspec(i).gt.bigspec(i+1)).and. &
- (bigspec(i).gt.1.15).and.ncand.lt.100) then
- ncand=ncand+1
- candidates(ncand,1)=df*(i-NH2)
- candidates(ncand,2)=10*log10(bigspec(i))-30.0
- endif
- enddo
-! do i=1,ncand
-! write(*,*) i,candidates(i,1),candidates(i,2)
-! enddo
- return
-end subroutine getcandidate2
-
-subroutine wsprdpsk_downsample(iwave,c)
-
-! Input: i*2 data in iwave() at sample rate 12000 Hz
-! Output: Complex data in c(), sampled at 400 Hz
-
- include 'wsprdpsk_params.f90'
- parameter (NMAX=120*12000,NFFT2=NMAX/30)
- integer*2 iwave(NMAX)
- complex c(0:NMAX/30-1)
- complex c1(0:NFFT2-1)
- complex cx(0:NMAX/2)
- real x(NMAX)
- equivalence (x,cx)
-
- df=12000.0/NMAX
- x=iwave
- call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
- i0=nint(1500.0/df)
- c1(0)=cx(i0)
- do i=1,NFFT2/2
- c1(i)=cx(i0+i)
- c1(NFFT2-i)=cx(i0-i)
- enddo
- c1=c1/NFFT2
- call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
- c=c1(0:NMAX/30-1)
- return
-end subroutine wsprdpsk_downsample
-
diff --git a/lib/fsk4hf/wsprdpsksim.f90 b/lib/fsk4hf/wsprdpsksim.f90
deleted file mode 100644
index fa5e34e4..00000000
--- a/lib/fsk4hf/wsprdpsksim.f90
+++ /dev/null
@@ -1,175 +0,0 @@
-program wsprdpsksim
-
-! Generate simulated data for a 2-minute "WSPR-DPSK" mode. Output is saved
-! to a *.c2 or *.wav file.
-
- use wavhdr
- include 'wsprdpsk_params.f90' !Set various constants
- parameter (NMAX=120*12000)
- type(hdr) hwav !Header for .wav file
- character arg*12,fname*16
- character msg*22,msgsent*22
- complex c0(0:NMAX/NDOWN-1)
- complex c(0:NMAX/NDOWN-1)
- complex c0wav(0:NMAX-1)
- complex cwav(0:NMAX-1)
- real*8 fMHz
- integer imessage(NN)
- integer*2 iwave(NMAX) !Generated full-length waveform
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: wsprdpsksim "message" f0 DT fsp del nwav nfiles snr'
- print*,'Example: wsprdpsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
- go to 999
- endif
- call getarg(1,msg) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
- 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,*) nwav !1 for *.wav file, 0 for *.c2 file
- call getarg(7,arg)
- read(arg,*) nfiles !Number of files
- call getarg(8,arg)
- read(arg,*) snrdb !SNR_2500
-
- twopi=8.0*atan(1.0)
- pi=twopi/2.0
- fs=12000.0/NDOWN
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS0/12000.0
-
- call genwsprdpsk(msg,msgsent,imessage) !Encode the message, get itone
- imessage=2*imessage-1
- write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
-1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
- ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
-
-
- beta=1.0 ! excess bandwidth
- if(nwav.eq.0) then
- df=fs/(NMAX/NDOWN) !
- c=0
- bw=(1+beta)*baud/2.0
- bf=(1-beta)*baud/2.0
- iw=bw/df
- if=bf/df
- c(0:if-1)=1.0
- if(iw.gt.if) then
- do i=if,iw
- c(i)=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5
- enddo
- endif
- c(NMAX/NDOWN-1:NMAX/NDOWN-iw:-1)=c(1:iw)
-
- istart=xdt/dt
- c0=0.0
- do i=1,NN
- c0(istart+(i-1)*200)=imessage(i)
- enddo
- call four2a(c0,NMAX/NDOWN,1,1,1)
- c0=c0*conjg(c)
- ic=f0/df
- c0=cshift(c0,ic)
- call four2a(c0,NMAX/NDOWN,1,-1,1)
- xx=sum(abs(c0(istart:istart+NN*200-1)**2))/(NN*200)
- c0=c0/sqrt(xx)
-
- call sgran()
- do ifile=1,nfiles
- c=c0
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(c,NMAX/NDOWN,fs,delay,fspread)
- endif
- c=c*sig
- if(snrdb.lt.90) then
- do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
- xnoise=gran()
- ynoise=gran()
- c(i)=c(i) + cmplx(xnoise,ynoise)
- enddo
- endif
-snrtest=sum(abs(c(istart:istart+NN*200-1)**2))/(NN*200)/2.0-1.0
-write(*,*) 'sample SNR: ',10*log10(snrtest)+10*log10(0.4/2.5)
- write(fname,1100) ifile
-1100 format('000000_',i4.4,'.c2')
- open(10,file=fname,status='unknown',access='stream')
- fMHz=10.1387d0
- nmin=2
- write(10) fname,nmin,fMHz,c !Save to *.c2 file
- close(10)
- enddo
- else
- fs=12000.0
- df=fs/NMAX
- dt=1/fs
- 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
- cwav=0
- bw=(1+beta)*baud/2.0
- bf=(1-beta)*baud/2.0
- iw=bw/df
- if=bf/df
- cwav(0:if-1)=1.0
- if(iw.gt.if) then
- do i=if,iw
- cwav(i)=((1.0+cos(pi*(i-if)/(iw-if)))/2.0)**0.5
- enddo
- endif
- cwav(NMAX-1:NMAX-iw:-1)=cwav(1:iw)
-
- istart=xdt/dt
- c0wav=0.0
- do i=1,NN
- c0wav(istart+(i-1)*200*NDOWN)=imessage(i)
- enddo
- call four2a(c0wav,NMAX,1,1,1)
- c0wav=c0wav*conjg(cwav)
- ic=f0/df
- c0wav=cshift(c0wav,-ic)
- call four2a(c0wav,NMAX,1,-1,1)
- xx=sum(abs(c0wav(istart:istart+NN*200*NDOWN-1))**2)/(NN*200*NDOWN)
- c0wav=c0wav/sqrt(xx)
-write(*,*) 'Peak power: ',maxval(abs(c0wav)**2)
-write(*,*) 'Average power: ',sum(abs(c0wav(istart:istart+NN*200*NDOWN-1))**2)/(NN*200*NDOWN)
- call sgran()
- do ifile=1,nfiles
- cwav=c0wav
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(cwav,NMAX,fs,delay,fspread)
- endif
- cwav=cwav*sig
- if(snrdb.lt.90) then
- do i=1,NMAX !Add gaussian noise at specified SNR
- xnoise=gran()
- iwave(i)=100*(real(cwav(i-1)) + xnoise)
- enddo
- endif
-snrtest=sum(real(iwave(istart:istart+NN*200*NDOWN-1)**2)/(NN*200*NDOWN))/100.0**2-1
-write(*,*) 'sample SNR: ',10*log10(snrtest)+10*log10(6.0/2.5)
- hwav=default_header(12000,NMAX)
- write(fname,1102) ifile
-1102 format('000000_',i4.4,'.wav')
- open(10,file=fname,status='unknown',access='stream')
- write(10) hwav,iwave !Save to *.wav file
- close(10)
- enddo
- endif
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
-
-999 end program wsprdpsksim
diff --git a/lib/fsk4hf/wsprlf.f90 b/lib/fsk4hf/wsprlf.f90
deleted file mode 100644
index efc3e846..00000000
--- a/lib/fsk4hf/wsprlf.f90
+++ /dev/null
@@ -1,110 +0,0 @@
-program wsprlf
-
- parameter (NN=121) !Total symbols
- parameter (NSPS=28800) !Samples per symbol @ fs=12000 Hz
- parameter (NZ=NSPS*NN) !Samples in waveform
-
- character*8 arg
- complex c(0:NZ-1)
- real*8 twopi,fs,f0,dt,phi,dphi
- real x(0:NZ-1)
- real p(0:NZ/2)
- real h0(0:NSPS/2) !Pulse shape, rising edge
- real h1(0:NSPS/2) !Pulse shape, trailing edge
- real tmp(NN)
- integer id(NN) !Generated data
- integer ie(NN) !Differentially encoded data
- data fs/12000.d0/
-
- nargs=iargc()
- if(nargs.ne.3) then
- print*,'Usage: wsprlf f0 t1 snr'
- goto 999
- endif
- call getarg(1,arg)
- read(arg,*) f0
- call getarg(2,arg)
- read(arg,*) t1
- call getarg(3,arg)
- read(arg,*) snrdb
-
- call random_number(tmp) !Generate random bipolar data
- id=1
- where(tmp.lt.0.5) id=-1
- ie(1)=1
- do i=2,NN !Differentially encode
- ie(i)=id(i)*ie(i-1)
- enddo
-
- n1=nint(t1*NSPS)
- twopi=8.d0*atan(1.d0)
-
- do i=0,2*n1-1 !Define the shape functions
- if(i.le.n1-1) then
- h0(i)=0.5*(1.0-cos(0.5*i*twopi/n1))
- else
- h1(i-n1)=0.5*(1.0-cos(0.5*i*twopi/n1))
- endif
- enddo
- if(t1.eq.0.0) h0=1
- if(t1.eq.0.0) h1=1
-
-! Shape the channel pulses
- x=1.
- x(0:n1-1)=h0(0:n1-1) !Leading edge of 1st pulse
- do j=2,NN !Leading edges
- if(ie(j).ne.ie(j-1)) then
- ia=(j-1)*NSPS + 1
- ib=ia+n1-1
- x(ia:ib)=h0(0:n1-1)
- endif
- enddo
- do j=1,NN-1 !Trailing edges
- if(ie(j+1).ne.ie(j)) then
- ib=j*NSPS
- ia=ib-n1+1
- x(ia:ib)=h1(0:n1-1)
- endif
- enddo
- ib=NN*NSPS-1
- ia=ib-n1+1
- x(ia:ib)=h1(0:n1-1) !Trailing edge of last pulse
-
- dt=1.d0/fs
- ts=dt*NSPS
- baud=fs/NSPS
- write(*,1000) baud,ts
-1000 format('Baud:',f6.3,' Tsym:',f6.3)
-
- dphi=twopi*f0*dt
- phi=0.d0
- i=-1
- do j=1,NN !Generate the baseband waveform
- a=ie(j)
- do k=1,NSPS
- i=i+1
- x(i)=a*x(i)
- phi=phi+dphi
- if(phi.gt.twopi) phi=phi-twopi
- xphi=phi
- c(i)=x(i)*cmplx(cos(xphi),sin(xphi))
- sym=i*dt/ts
- if(j.le.20) write(13,1010) sym,x(i),c(i)
-1010 format(4f12.6)
- enddo
- enddo
-
- call four2a(c,NZ,1,-1,1) !To freq domain
- df=fs/NZ
- nh=NZ/2
- do i=0,nh
- f=i*df
- p(i)=real(c(i))**2 + aimag(c(i))**2
- enddo
- p=p/maxval(p)
- do i=0,nh !Save spectrum for plotting
- write(14,1020) i*df,p(i),10.0*log10(p(i)+1.e-8)
-1020 format(f10.3,2e12.3)
- enddo
-
-999 end program wsprlf
diff --git a/lib/fsk4hf/wsprlf_params.f90 b/lib/fsk4hf/wsprlf_params.f90
deleted file mode 100644
index d0c3f5c7..00000000
--- a/lib/fsk4hf/wsprlf_params.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-!parameter (NDOWN=540) !Downsample factor (default 540)
-parameter (NDOWN=30) !Downsample factor (default 540)
-parameter (KK=60) !Information bits (50 + CRC10)
-parameter (ND=300) !Data symbols: LDPC (300,60), r=1/5
-parameter (NS=109) !Sync symbols (2 x 48 + Barker 13)
-parameter (NR=3) !Ramp up/down
-parameter (NN=NR+NS+ND) !Total symbols (412)
-parameter (NSPS0=8640) !Samples per symbol at 12000 S/s
-parameter (NSPS=NSPS0/NDOWN) !Samples per MSK symbol (16)
-parameter (N2=2*NSPS) !Samples per OQPSK symbol (32)
-parameter (N13=13*N2) !Samples in central sync vector (416)
-parameter (NZ=NSPS*NN) !Samples in baseband waveform (6592)
-parameter (NZMAX=NSPS0*NN)
-parameter (NFFT1=4*NSPS,NH1=NFFT1/2)
diff --git a/lib/fsk4hf/wsprlfsim.f90 b/lib/fsk4hf/wsprlfsim.f90
deleted file mode 100644
index 6ee0710b..00000000
--- a/lib/fsk4hf/wsprlfsim.f90
+++ /dev/null
@@ -1,286 +0,0 @@
-program wsprlfsim
-
-! Simulate characteristics of a potential "WSPR-LF" mode using LDPC (300,60)
-! code, OQPSK modulation, and 5 minute T/R sequences.
-
-! Reception and Demodulation algorithm:
-! 1. Compute coarse spectrum; find fc1 = approx carrier freq
-! 2. Mix from fc1 to 0; LPF at +/- 0.75*R
-! 3. Square, FFT; find peaks near -R/2 and +R/2 to get fc2
-! 4. Mix from fc2 to 0
-! 5. Fit cb13 (central part of csync) to c -> lag, phase
-! 6. Fit complex ploynomial for channel equalization
-! 7. Get soft bits from equalized data
-
- include 'wsprlf_params.f90'
-
-! Q: Would it be better for central Sync array to use both I and Q channels?
-
- character*8 arg
- complex cbb(0:NZ-1) !Complex baseband waveform
- complex csync(0:NZ-1) !Sync symbols only, from cbb
- complex c(0:NZ-1) !Complex waveform
- complex c0(0:NZ-1) !Complex waveform
- complex c1(0:NZ-1) !Complex waveform
- complex zz(NS+ND) !Complex symbol values (intermediate)
- complex z
- real xnoise(0:NZ-1) !Generated random noise
- real ynoise(0:NZ-1) !Generated random noise
- real rxdata(ND),llr(ND) !Soft symbols
- real pp(2*NSPS) !Shaped pulse for OQPSK
- real a(5) !For twkfreq1
- real aa(20),bb(20) !Fitted polyco's
- real t(11)
- character*12 label(11)
- integer*8 count0,count1,count2,count3,clkfreq
- integer nc(11)
- integer id(NS+ND) !NRZ values (+/-1) for Sync and Data
- integer ierror(NS+ND)
- integer icw(NN)
- integer itone(NN)
- integer*1 msgbits(KK),decoded(KK),apmask(ND),cw(ND)
-! integer*1 codeword(ND)
- data msgbits/0,0,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1, &
- 1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,1,0,1,0,1,1,0,0,1,1/
- data label/'genwsprlf','twkfreq1 a','watterson','noise gen','getfc1w', &
- 'getfc2w','twkfreq1 b','xdt loop','cpolyfitw','msksoftsym', &
- 'bpdecode300'/
-
- nargs=iargc()
- if(nargs.ne.6) then
- print*,'Usage: wsprlfsim f0(Hz) delay(ms) fspread(Hz) maxn iters snr(dB)'
- print*,'Example: wsprlfsim 0 0 0 5 10 -20'
- print*,'Set snr=0 to cycle through a range'
- go to 999
- endif
- call getarg(1,arg)
- read(arg,*) f0 !Generated carrier frequency
- call getarg(2,arg)
- read(arg,*) delay !Delta_t (ms) for Watterson model
- call getarg(3,arg)
- read(arg,*) fspread !Fspread (Hz) for Watterson model
- call getarg(4,arg)
- read(arg,*) maxn !Max nterms for polyfit
- call getarg(5,arg)
- read(arg,*) iters !Iterations at each SNR
- call getarg(6,arg)
- read(arg,*) snrdb !Specified SNR_2500
-
- nc=0
- twopi=8.0*atan(1.0)
- fs=NSPS*12000.0/NSPS0 !Sample rate = 22.2222... Hz
- dt=1.0/fs !Sample interval (s)
- tt=NSPS*dt !Duration of "itone" symbols (s)
- ts=2*NSPS*dt !Duration of OQPSK symbols (s)
- baud=1.0/tt !Keying rate for "itone" symbols (baud)
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- write(*,1000) fs,f0,delay,fspread,maxn,baud,3*baud,txt,iters
-1000 format('fs:',f10.3,' f0:',f5.1,' Delay:',f4.1,' fSpread:',f5.2, &
- ' maxn:',i3,/'Baud:',f8.3,' BW:',f5.1,' TxT:',f6.1,' iters:',i4/)
- write(*,1004)
-1004 format(/' SNR sync data ser ber fer fsigma tsigma', &
- ' tsec'/68('-'))
-
- do i=1,N2 !Half-sine pulse shape
- pp(i)=sin(0.5*(i-1)*twopi/(2*NSPS))
- enddo
-
- t=0.
- call system_clock(count0,clkfreq)
- call genwsprlf(msgbits,id,icw,cbb,csync,itone)!Generate baseband waveform
- call system_clock(count1,clkfreq)
- t(1)=float(count1-count0)/float(clkfreq)
- nc(1)=nc(1)+1
- do i=0,NZ-1
- write(40,4001) i,cbb(i),csync(i)
-4001 format(i8,4f12.6)
- enddo
-
- call system_clock(count0,clkfreq)
- a=0.
- a(1)=f0
- call twkfreq1(cbb,NZ,fs,a,c0) !Mix baseband to specified frequency
- call system_clock(count1,clkfreq)
- t(2)=float(count1-count0)/float(clkfreq)
- nc(2)=nc(2)+1
-
- isna=-20
- isnb=-40
- if(snrdb.ne.0.0) then
- isna=nint(snrdb)
- isnb=isna
- endif
- do isnr=isna,isnb,-1 !Loop over SNR range
- if(isna.ne.isnb) snrdb=isnr
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- nhard=0
- nhardsync=0
- nfe=0
- sqf=0.
- sqt=0.
-
- call system_clock(count2,clkfreq)
- do iter=1,iters !Loop over requested iterations
- c=c0
-write(*,*) 'iter ',iter
- call system_clock(count0,clkfreq)
- if(delay.ne.0.0 .or. fspread.ne.0.0) then
- call watterson(c,NZ,fs,delay,fspread)
- endif
- call system_clock(count1,clkfreq)
- t(3)=t(3)+float(count1-count0)/float(clkfreq)
- nc(3)=nc(3)+1
-
- call system_clock(count0,clkfreq)
- c=sig*c !Scale to requested SNR
- if(snrdb.lt.90) then
- do i=0,NZ-1 !Generate gaussian noise
- xnoise(i)=gran()
- ynoise(i)=gran()
- enddo
- c=c + cmplx(xnoise,ynoise) !Add AWGN noise
- endif
- call system_clock(count1,clkfreq)
- t(4)=t(4)+float(count1-count0)/float(clkfreq)
- nc(4)=nc(4)+1
-
- call system_clock(count0,clkfreq)
- call getfc1w(c,fs,fc1) !First approx for freq
- call system_clock(count1,clkfreq)
- t(5)=t(5)+float(count1-count0)/float(clkfreq)
- nc(5)=nc(5)+1
-write(*,*) 'fc1 ',fc1
- call system_clock(count0,clkfreq)
- call getfc2w(c,csync,fs,fc1,fc2,fc3) !Refined freq
-write(*,*) 'fc1,fc2,fc3 ',fc1,fc2,fc3
- call system_clock(count1,clkfreq)
- t(6)=t(6)+float(count1-count0)/float(clkfreq)
- nc(6)=nc(6)+1
- sqf=sqf + (fc1+fc2-f0)**2
-
- call system_clock(count0,clkfreq)
-!NB: Measured performance is about equally good using fc2 or fc3 here:
- a(1)=-(fc1+fc2)
- a(2:5)=0.
- call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2
- call system_clock(count1,clkfreq)
- t(7)=t(7)+float(count1-count0)/float(clkfreq)
- nc(7)=nc(7)+1
-
-! The following may not be necessary?
-! z=sum(c(3088:3503)*cb13)/208.0 !Get phase from Barker 13 vector
-! z0=z/abs(z)
-! c=c*conjg(z0)
-
- call system_clock(count0,clkfreq)
-!---------------------------------------------------------------- DT
-! Not presently used:
- amax=0.
- jpk=0
- iaa=0
- ibb=NZ-1
- do j=-20*NSPS,20*NSPS,NSPS/8
- ia=j
- ib=NZ-1+j
- if(ia.lt.0) then
- ia=0
- iaa=-j
- else
- iaa=0
- endif
- if(ib.gt.NZ-1) then
- ib=NZ-1
- ibb=NZ-1-j
- endif
- z=sum(c(ia:ib)*conjg(csync(iaa:ibb)))
- if(abs(z).gt.amax) then
- amax=abs(z)
- jpk=j
- endif
- enddo
- xdt=jpk/fs
- sqt=sqt + xdt**2
- call system_clock(count1,clkfreq)
- t(8)=t(8)+float(count1-count0)/float(clkfreq)
- nc(8)=nc(8)+1
-
-!-----------------------------------------------------------------
-
- nterms=maxn
- c1=c
- do itry=1,20
- idf=itry/2
- if(mod(itry,2).eq.0) idf=-idf
- nhard0=0
- nhardsync0=0
- ifer=1
- a(1)=idf*0.00085
- a(2:5)=0.
- call system_clock(count0,clkfreq)
- call twkfreq1(c1,NZ,fs,a,c) !Mix c1 into c
- call cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhs)
- call system_clock(count1,clkfreq)
- t(9)=t(9)+float(count1-count0)/float(clkfreq)
- nc(9)=nc(9)+1
-
- call system_clock(count0,clkfreq)
- call msksoftsymw(zz,aa,bb,id,nterms,ierror,rxdata,nhard0,nhardsync0)
- call system_clock(count1,clkfreq)
- t(10)=t(10)+float(count1-count0)/float(clkfreq)
- nc(10)=nc(10)+1
-
- if(nhardsync0.gt.35) cycle
- rxav=sum(rxdata)/ND
- rx2av=sum(rxdata*rxdata)/ND
- rxsig=sqrt(rx2av-rxav*rxav)
- rxdata=rxdata/rxsig
- ss=0.84
- llr=2.0*rxdata/(ss*ss)
- apmask=0
- max_iterations=40
- ifer=0
- call system_clock(count0,clkfreq)
- call bpdecode300(llr,apmask,max_iterations,decoded,niterations,cw)
- call system_clock(count1,clkfreq)
- t(11)=t(11)+float(count1-count0)/float(clkfreq)
- nc(11)=nc(11)+1
- nbadcrc=0
- if(niterations.ge.0) call chkcrc10(decoded,nbadcrc)
- if(niterations.lt.0 .or. count(msgbits.ne.decoded).gt.0 .or. &
- nbadcrc.ne.0) ifer=1
- if(ifer.eq.0) exit
- enddo !Freq dither loop
- nhard=nhard+nhard0
- nhardsync=nhardsync+nhardsync0
- nfe=nfe+ifer
- if(nhardsync0+nhard0+niterations+ifer.gt.0) write(42,1045) snrdb, &
- nhardsync0,nhard0,niterations,ifer,xdt
-1045 format(f6.1,4i6,f8.2)
- enddo
- call system_clock(count3,clkfreq)
- tsec=float(count3-count2)/float(clkfreq)
-
- fsigma=sqrt(sqf/iters)
- tsigma=sqrt(sqt/iters)
- ser=float(nhardsync)/(NS*iters)
- ber=float(nhard)/(ND*iters)
- fer=float(nfe)/iters
- write(*,1050) snrdb,nhardsync,nhard,ser,ber,fer,fsigma,tsigma,tsec
-1050 format(f6.1,2i7,2f8.4,f7.3,2f8.2f8.3)
- enddo
-
- write(*,1060) NS*iters,ND*iters
-1060 format(68('-')/6x,2i7)
-
- write(*,1065)
-1065 format(/'Timing sec frac calls'/39('-'))
- do i=1,11
- write(*,1070) label(i),t(i),t(i)/sum(t),nc(i)
-1070 format(a12,2f9.3,i8)
- enddo
- write(*,1072) sum(t),1.0
-1072 format(39('-')/12x,2f10.3)
-
-999 end program wsprlfsim
diff --git a/lib/fsk4hf/wsprsimf.f90 b/lib/fsk4hf/wsprsimf.f90
deleted file mode 100644
index c6c71fe6..00000000
--- a/lib/fsk4hf/wsprsimf.f90
+++ /dev/null
@@ -1,113 +0,0 @@
-!-------------------------------------------------------------------------------
-!
-! This file is part of the WSPR application, Weak Signal Propagation Reporter
-!
-!-------------------------------------------------------------------------------
-
-program wsprsim
-
- use wavhdr
- include 'wspr_params.f90'
- type(hdr) hwav
- character arg*12,fname14*14,fname15*15
- character*22 msg,msgsent
- complex c0(0:NMAX/NDOWN-1)
- complex c(0:NMAX/NDOWN-1)
- integer itone(NN)
- integer*2 iwave(NMAX)
- real*8 fMHz
-
-! Get command-line argument(s)
- nargs=iargc()
- if(nargs.ne.8) then
- print*,'Usage: wsprsim "message" f0 DT fsp del nwav nfiles snr'
- print*,'Example: wsprsim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
- go to 999
- endif
- call getarg(1,msg) !Message to be transmitted
- call getarg(2,arg)
- read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
- 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,*) nwav !1 for *.wav file, 0 for *.c2 file
- call getarg(7,arg)
- read(arg,*) nfiles !Number of files
- call getarg(8,arg)
- read(arg,*) snrdb !SNR_2500
-
- twopi=8.0*atan(1.0)
- fs=12000.0/NDOWN
- dt=1.0/fs
- tt=NSPS*dt
- baud=12000.0/8192.0
-
- txt=NZ*dt !Transmission length (s)
- bandwidth_ratio=2500.0/(fs/2.0)
- sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
- if(snrdb.gt.90.0) sig=1.0
- txt=NN*NSPS0/12000.0
-
- call genwspr(msg,msgsent,itone) !Encode the message, get itone
-
- write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
-1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
- ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
-! write(*,*) "Channel symbols: "
-! write(*,'(162i2)') itone
-
- h=1.0
- phi=0.0
- c0=0.
- k=-1 + nint(xdt/dt)
- do j=1,NN
- dphi=-twopi*(f0+h*(itone(j)-1.5)*baud)*dt
- do i=1,NSPS
- k=k+1
- phi=mod(phi+dphi,twopi)
- if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi))
- enddo
- enddo
- call sgran()
- do ifile=1,nfiles
- c=c0
- if(nwav.eq.0) then
- if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
- call watterson(c,NMAX/NDOWN,fs,delay,fspread)
- endif
- c=c*sig
- if(snrdb.lt.90) then
- do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
- xnoise=gran()
- ynoise=gran()
- c(i)=c(i) + cmplx(xnoise,ynoise)
- enddo
- endif
- write(fname14,1100) ifile
-1100 format('000000_',i4.4,'.c2')
- open(10,file=fname14,status='unknown',access='stream')
- fMHz=10.1387d0
- nmin=2
- write(10) fname14,nmin,fMHz,c !Save to *.c2 file
- close(10)
- write(*,1108) ifile,xdt,f0,snrdb,fname14
-1108 format(i4,f7.2,f8.2,f7.1,2x,a14)
- else
- freq=1500.0+f0
- call wspr_wav(baud,xdt,h,freq,itone,snrdb,iwave)
- hwav=default_header(12000,NMAX)
- write(fname15,1102) ifile
-1102 format('000000_',i4.4,'.wav')
- open(10,file=fname15,status='unknown',access='stream')
- write(10) hwav,iwave !Save to *.wav file
- close(10)
- write(*,1110) ifile,xdt,f0,snrdb,fname15
-1110 format(i4,f7.2,f8.2,f7.1,2x,a15)
- endif
- enddo
-
-999 end program wsprsim