Merged master 8748

This commit is contained in:
Jordan Sherer
2018-08-05 11:33:30 -04:00
parent 8f8772f1bd
commit 62899069bf
1222 changed files with 70382 additions and 406763 deletions
@@ -0,0 +1,96 @@
subroutine sync65(nfa,nfb,naggressive,ntol,nqsym,ca,ncand,nrobust, &
bVHF)
parameter (NSZ=3413,NFFT=8192,MAXCAND=300)
real ss(552,NSZ)
real ccfblue(-32:82) !CCF with pseudorandom sequence
real ccfred(NSZ) !Peak of ccfblue, as function of freq
logical bVHF
type candidate
real freq
real dt
real sync
real flip
end type candidate
type(candidate) ca(MAXCAND)
common/steve/thresh0
common/sync/ss
if(ntol.eq.-99) stop !Silence compiler warning
call setup65
df=12000.0/NFFT !df = 12000.0/8192 = 1.465 Hz
ia=max(2,nint(nfa/df))
ib=min(NSZ-1,nint(nfb/df))
! lag1=-11
! lag2=59
! lag1=-22
! lag2=118
lag1=-32
lag2=82 !may need to be extended for EME
nsym=126
ncand=0
fdot=0.
ccfred=0.
ccfblue=0.
ccfmax=0.
ipk=0
do i=ia,ib
call xcor(i,nqsym,nsym,lag1,lag2,ccfblue,ccf0,lagpk0,flip,fdot,nrobust)
! Remove best-fit slope from ccfblue and normalize so baseline rms=1.0
if(.not.bVHF) call slope(ccfblue(lag1),lag2-lag1+1, &
lagpk0-lag1+1.0)
ccfred(i)=ccfblue(lagpk0)
if(ccfred(i).gt.ccfmax) then
ccfmax=ccfred(i)
ipk=i
endif
enddo
call pctile(ccfred(ia:ib),ib-ia+1,35,xmed)
ccfred(ia:ib)=ccfred(ia:ib)-xmed
ccfred(ia-1)=ccfred(ia)
ccfred(ib+1)=ccfred(ib)
do i=ia,ib
freq=i*df
itry=0
! if(naggressive.gt.0 .and. ntol.lt.1000 .and. ccfmax.ge.thresh0) then
if(naggressive.gt.0 .and. ccfmax.ge.thresh0) then
if(i.ne.ipk) cycle
itry=1
ncand=ncand+1
else
if(ccfred(i).ge.thresh0 .and. ccfred(i).gt.ccfred(i-1) .and. &
ccfred(i).gt.ccfred(i+1)) then
itry=1
ncand=ncand+1
endif
endif
if(itry.ne.0) then
call xcor(i,nqsym,nsym,lag1,lag2,ccfblue,ccf0,lagpk,flip,fdot,nrobust)
if(.not.bVHF) call slope(ccfblue(lag1),lag2-lag1+1, &
lagpk-lag1+1.0)
xlag=lagpk
if(lagpk.gt.lag1 .and. lagpk.lt.lag2) then
call peakup(ccfblue(lagpk-1),ccfmax,ccfblue(lagpk+1),dx2)
xlag=lagpk+dx2
endif
dtx=xlag*1024.0/11025.0
ccfblue(lag1)=0.
ccfblue(lag2)=0.
ca(ncand)%freq=freq
ca(ncand)%dt=dtx
ca(ncand)%flip=flip
if(bVHF) then
ca(ncand)%sync=db(ccfred(i)) - 16.0
else
ca(ncand)%sync=ccfred(i)
endif
endif
if(ncand.eq.MAXCAND) exit
enddo
return
end subroutine sync65
@@ -1,81 +0,0 @@
module jt65_test
! Test the JT65 decoder for WSJT-X
implicit none
public :: test
integer, parameter, public :: NZMAX=60*12000
integer, public :: nft
contains
subroutine test (dd,nutc,nflow,nfhigh,nfqso,ntol,nsubmode,n2pass,nrobust &
,ntrials,naggressive,ndepth,mycall,hiscall,hisgrid,nexp_decode)
use timer_module, only: timer
use jt65_decode
implicit none
include 'constants.f90'
real, intent(in) :: dd(NZMAX)
integer, intent(in) :: nutc, nflow, nfhigh, nfqso, ntol, nsubmode, n2pass &
, ntrials, naggressive, ndepth, nexp_decode
logical, intent(in) :: nrobust
character(len=12), intent(in) :: mycall, hiscall
character(len=6), intent(in) :: hisgrid
type(jt65_decoder) :: my_decoder
logical nclearave !### Should be a dummy arg?
nclearave=.false.
call timer('jt65a ',0)
call my_decoder%decode(my_callback,dd,npts=52*12000,newdat=.true., &
nutc=nutc,nf1=nflow,nf2=nfhigh,nfqso=nfqso,ntol=ntol, &
nsubmode=nsubmode, minsync=-1,nagain=.false.,n2pass=n2pass, &
nrobust=nrobust,ntrials=ntrials,naggressive=naggressive, &
ndepth=ndepth,emedelay=0.0,clearave=nclearave,mycall=mycall, &
hiscall=hiscall,hisgrid=hisgrid,nexp_decode=nexp_decode)
call timer('jt65a ',1)
end subroutine test
subroutine my_callback (this,sync,snr,dt,freq,drift,nflip,width, &
decoded,ft,qual,smo,sum,minsync)
use jt65_decode
implicit none
class(jt65_decoder), intent(inout) :: this
real, intent(in) :: sync
integer, intent(in) :: snr
real, intent(in) :: dt
integer, intent(in) :: freq
integer, intent(in) :: drift
integer, intent(in) :: nflip
real, intent(in) :: width
character(len=22), intent(in) :: decoded
integer, intent(in) :: ft
integer, intent(in) :: qual
integer, intent(in) :: smo
integer, intent(in) :: sum
integer, intent(in) :: minsync
integer nwidth
real t
if(minsync+nflip+qual.eq.-9999) stop !Silence compiler warning
t=max(0.0,width*width-7.2)
nwidth=max(nint(sqrt(t)),2)
!### deal with nflip here! ###
!### also single_decode, csync, etc... ###
write(*,1010) snr,dt,freq,decoded
1010 format(i4,f5.1,i5,1x,'#',1x,a22)
write(13,1012) nint(sync),snr,dt,freq,drift,nwidth, &
decoded,ft,sum,smo
1012 format(i4,i5,f6.2,i5,i4,i3,1x,a22,' JT65',3i3)
nft=ft
call flush(6)
! write(79,3001) sync,snr,dt,freq,candidates, &
! hard_min,total_min,rtt,tries,ft,qual,decoded
!3001 format(f5.1,i4,f5.1,i5,i6,i3,i4,f6.3,i8,i2,i3,1x,a22)
end subroutine my_callback
end module jt65_test
@@ -0,0 +1,216 @@
// Status=review
=== Standard Exchange
By longstanding tradition, a minimally valid QSO requires the exchange
of callsigns, a signal report or some other information, and
acknowledgments. _WSJT-X_ is designed to facilitate making such
minimal QSOs using short, structured messages. The process works best
if you use these formats and follow standard operating practices. The
recommended basic QSO goes something like this:
CQ K1ABC FN42 #K1ABC calls CQ
K1ABC G0XYZ IO91 #G0XYZ answers
G0XYZ K1ABC 19 #K1ABC sends report
K1ABC G0XYZ R-22 #G0XYZ sends R+report
G0XYZ K1ABC RRR #K1ABC sends RRR
K1ABC G0XYZ 73 #G0XYZ sends 73
*Standard messages* consist of two callsigns (or CQ, QRZ, or DE and
one callsign) followed by the transmitting stations grid locator, a
signal report, R plus a signal report, or the final acknowledgements
RRR or 73. These messages are compressed and encoded in a highly
efficient and reliable way. In uncompressed form (as displayed
on-screen) they may contain as many as 22 characters.
*Signal reports* are specified as signal-to-noise ratio (S/N) in dB,
using a standard reference noise bandwidth of 2500 Hz. Thus, in the
example message above, K1ABC is telling G0XYZ that his
signal is 19 dB below the noise power in bandwidth 2500 Hz. In the
message at 0004, G0XYZ acknowledges receipt of that report and
responds with a 22 dB signal report. JT65 reports are constrained to
lie in the range 30 to 1 dB, and values are significantly compressed
above about -10 dB. JT9 supports the extended range 50 to +49 dB and
assigns more reliable numbers to relatively strong signals.
NOTE: Signals become visible on the waterfall around S/N = 26 dB and
audible (to someone with very good hearing) around 15 dB. Thresholds
for decodability are around -20 dB for FT8, -23 dB for JT4, 25 dB for
JT65, 27 dB for JT9.
NOTE: Several options are available for circumstances where fast QSOs
are desirable. Double-click the *Tx1* control under _Now_ or _Next_
to toggle use of the Tx2 message rather than Tx1 to start a QSO.
Similarly, double-click the *Tx4* control to toggle between sending
`RRR` and `RR73` in that message. The `RR73` message should be used
only if you are reasonably confident that no repetitions will be
required.
=== Free-Text Messages
Users often add some friendly chit-chat at the end of a QSO.
Free-format messages such as "`TNX ROBERT 73`" or "`5W VERT 73 GL`"
are supported, up to a maximum of 13 characters, including spaces. In
general you should avoid the character / in free-text messages, as the
program may then try to interpret your construction as part of a
compound callsign. It should be obvious that the JT4, JT9, and JT65
protocols are not designed or well suited for extensive conversations
or rag-chewing.
=== Auto-Sequencing
The 15-second T/R cycles of FT8 allow only about two seconds to inspect
decoded messages and decide how to reply, which is often not enough.
The slow modes JT4, JT9, JT65, and QRA64 allow nearly 10 seconds
for this task, but operators may find that this is still insufficient
when workload is high, especially on EME. For these reasons a basic
auto-sequencing feature is offered.
Check *Auto Seq* on the main window to enable this feature:
image::auto-seq.png[align="center",alt="AutoSeq"]
When calling CQ you may also choose to check the box *Call 1st*.
_WSJT-X_ will then respond automatically to the first decoded
responder to your CQ.
NOTE: When *Auto-Seq* is enabled the program de-activates *Enable Tx*
at the end of each QSO. It is not intended that _WSJT-X_ should make
fully automated QSOs.
=== VHF Contest Mode
A special *NA VHF Contest* mode can be activated for FT8 and MSK144
modes by checking a box on the main window. This mode is configured
especially for contests in which four-character grid locators are the
required exchange. When *NA VHF Contest* mode is active, the standard
QSO sequence looks like this:
CQ K1ABC FN42
K1ABC W9XYZ EN37
W9XYZ K1ABC R FN42
K1ABC W9XYZ RRR
W9XYZ K1ABC 73
In contest circumstances K1ABC might choose to call CQ again rather
than sending 73 for his third transmission.
IMPORTANT: Do not use VHF Contest Mode on an HF band or in conditions
where worldwide propagation is available. See
<<PROTOCOL_OVERVIEW,Protocol Specifications>> for further details.
[[COMP-CALL]]
=== Compound Callsigns
Compound callsigns such as xx/K1ABC or K1ABC/x are handled in
one of two possible ways:
.Messages containing Type 1 compound callsigns
A list of about 350 of the most common prefixes and suffixes can be
displayed from the *Help* menu. A single compound callsign involving
one item from this list can be used in place of the standard third
word of a message (normally a locator, signal report, RRR, or 73).
The following examples are all acceptable messages containing *Type 1*
compound callsigns:
CQ ZA/K1ABC
CQ K1ABC/4
ZA/K1ABC G0XYZ
G0XYZ K1ABC/4
The following messages are _not_ valid, because a third word is not
permitted in any message containing a *Type 1* compound callsign:
ZA/K1ABC G0XYZ -22 #These messages are invalid; each would
G0XYZ K1ABC/4 73 # be sent without its third "word"
A QSO between two stations using *Type 1* compound-callsign messages
might look like this:
CQ ZA/K1ABC
ZA/K1ABC G0XYZ
G0XYZ K1ABC 19
K1ABC G0XYZ R22
G0XYZ K1ABC RRR
K1ABC G0XYZ 73
Notice that the full compound callsign is sent and received in the
first two transmissions. After that, the operators omit the add-on
prefix or suffix and use the standard structured messages.
.Type 2 Compound-Callsign Messages
Prefixes and suffixes _not_ found in the displayable short list are
handled by using *Type 2* compound callsigns. In this case the
compound callsign must be the second word in a two- or three-word
message, and the first word must be CQ, DE, or QRZ. Prefixes can be 1
to 4 characters, suffixes 1 to 3 characters. A third word conveying a
locator, report, RRR, or 73 is permitted. The following are valid
messages containing *Type 2* compound callsigns:
CQ W4/G0XYZ FM07
QRZ K1ABC/VE6 DO33
DE W4/G0XYZ FM18
DE W4/G0XYZ -22
DE W4/G0XYZ R-22
DE W4/G0XYZ RRR
DE W4/G0XYZ 73
In each case, the compound callsign is treated as *Type 2* because the
add-on prefix or suffix is _not_ one of those in the fixed list. Note
that a second callsign is never permissible in these messages.
NOTE: During a transmission your outgoing message is displayed in the
first label on the *Status Bar* and shown exactly as another station
will receive it. You can check to see that you are actually
transmitting the message you wish to send.
QSOs involving *Type 2* compound callsigns might look like either
of the following sequences:
CQ K1ABC/VE1 FN75
K1ABC G0XYZ IO91
G0XYZ K1ABC 19
K1ABC G0XYZ R22
G0XYZ K1ABC RRR
K1ABC/VE1 73
CQ K1ABC FN42
DE G0XYZ/W4 FM18
G0XYZ K1ABC 19
K1ABC G0XYZ R22
G0XYZ K1ABC RRR
DE G0XYZ/W4 73
Operators with a compound callsign use its full form when calling CQ
and possibly also in a 73 transmission, as may be required by
licensing authorities. Other transmissions during a QSO may use the
standard structured messages without callsign prefix or suffix.
TIP: If you are using a compound callsign, you may want to
experiment with the option *Message generation for type 2 compound
callsign holders* on the *Settings | General* tab, so that messages
will be generated that best suit your needs.
=== Pre-QSO Checklist
Before attempting your first QSO with one of the WSJT modes, be sure
to go through the <<TUTORIAL,Basic Operating Tutorial>> above as well
as the following checklist:
- Your callsign and grid locator set to correct values
- PTT and CAT control (if used) properly configured and tested
- Computer clock properly synchronized to UTC within ±1 s
- Audio input and output devices configured for sample rate 48000 Hz,
16 bits
- Radio set to *USB* (upper sideband) mode
- Radio filters centered and set to widest available passband (up to 5 kHz).
TIP: Remember that in many circumstances FT8, JT4, JT9, JT65, and WSPR
do not require high power. Under most HF propagation conditions, QRP
is the norm.
@@ -1,50 +0,0 @@
/*
* Reads an ADIF log file into memory
* Searches log for call, band and mode
* VK3ACF July 2013
*/
#ifndef __ADIF_H
#define __ADIF_H
#if defined (QT5)
#include <QList>
#include <QString>
#include <QMultiHash>
#else
#include <QtGui>
#endif
class ADIF
{
public:
void init(QString filename);
void load();
void add(const QString call, const QString band, const QString mode, const QString date);
bool match(const QString call, const QString band, const QString mode);
QList<QString> getCallList();
int getCount();
// open ADIF file and append the QSO details. Return true on success
bool addQSOToFile(const QString hisCall, const QString hisGrid, const QString mode, const QString rptSent, const QString rptRcvd, const QString dateOn, const QString timeOn, const QString dateOff, const QString timeOff, const QString band,
const QString comments, const QString name, const QString strDialFreq, const QString m_myCall, const QString m_myGrid, const QString m_txPower);
static QString bandFromFrequency(double dialFreq);
private:
struct QSO
{
QString call,band,mode,date;
};
QMultiHash<QString, QSO> _data;
QString _filename;
QString _extractField(const QString line, const QString fieldName);
};
#endif
@@ -1,401 +0,0 @@
subroutine bpdecode174(llr,apmask,maxiterations,decoded,niterations)
!
! A log-domain belief propagation decoder for the (174,87) code.
!
integer, parameter:: N=174, K=87, 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, 30, 4, 5, 6, 7, 8, 9, 10, 11, 32, 12, 40, 13, 14, 15, 16,&
17, 18, 37, 45, 29, 19, 20, 21, 41, 22, 42, 31, 33, 34, 44, 35, 47, 51, 50, 43,&
36, 52, 63, 46, 25, 55, 27, 24, 23, 53, 39, 49, 59, 38, 48, 61, 60, 57, 28, 62,&
56, 58, 65, 66, 26, 70, 64, 69, 68, 67, 74, 71, 54, 76, 72, 75, 78, 77, 80, 79,&
73, 83, 84, 81, 82, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,&
100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,&
120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,&
140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,&
160,161,162,163,164,165,166,167,168,169,170,171,172,173/
data Mn/ &
1, 25, 69, &
2, 5, 73, &
3, 32, 68, &
4, 51, 61, &
6, 63, 70, &
7, 33, 79, &
8, 50, 86, &
9, 37, 43, &
10, 41, 65, &
11, 14, 64, &
12, 75, 77, &
13, 23, 81, &
15, 16, 82, &
17, 56, 66, &
18, 53, 60, &
19, 31, 52, &
20, 67, 84, &
21, 29, 72, &
22, 24, 44, &
26, 35, 76, &
27, 36, 38, &
28, 40, 42, &
30, 54, 55, &
34, 49, 87, &
39, 57, 58, &
45, 74, 83, &
46, 62, 80, &
47, 48, 85, &
59, 71, 78, &
1, 50, 53, &
2, 47, 84, &
3, 25, 79, &
4, 6, 14, &
5, 7, 80, &
8, 34, 55, &
9, 36, 69, &
10, 43, 83, &
11, 23, 74, &
12, 17, 44, &
13, 57, 76, &
15, 27, 56, &
16, 28, 29, &
18, 19, 59, &
20, 40, 63, &
21, 35, 52, &
22, 54, 64, &
24, 62, 78, &
26, 32, 77, &
30, 72, 85, &
31, 65, 87, &
33, 39, 51, &
37, 48, 75, &
38, 70, 71, &
41, 42, 68, &
45, 67, 86, &
46, 81, 82, &
49, 66, 73, &
58, 60, 66, &
61, 65, 85, &
1, 14, 21, &
2, 13, 59, &
3, 67, 82, &
4, 32, 73, &
5, 36, 54, &
6, 43, 46, &
7, 28, 75, &
8, 33, 71, &
9, 49, 76, &
10, 58, 64, &
11, 48, 68, &
12, 19, 45, &
15, 50, 61, &
16, 22, 26, &
17, 72, 80, &
18, 40, 55, &
20, 35, 51, &
23, 25, 34, &
24, 63, 87, &
27, 39, 74, &
29, 78, 83, &
30, 70, 77, &
31, 69, 84, &
22, 37, 86, &
38, 41, 81, &
42, 44, 57, &
47, 53, 62, &
52, 56, 79, &
60, 75, 81, &
1, 39, 77, &
2, 16, 41, &
3, 31, 54, &
4, 36, 78, &
5, 45, 65, &
6, 57, 85, &
7, 14, 49, &
8, 21, 46, &
9, 15, 72, &
10, 20, 62, &
11, 17, 71, &
12, 34, 47, &
13, 68, 86, &
18, 23, 43, &
19, 64, 73, &
24, 48, 79, &
25, 70, 83, &
26, 80, 87, &
27, 32, 40, &
28, 56, 69, &
29, 63, 66, &
30, 42, 50, &
33, 37, 82, &
35, 60, 74, &
38, 55, 84, &
44, 52, 61, &
51, 53, 72, &
58, 59, 67, &
47, 56, 76, &
1, 19, 37, &
2, 61, 75, &
3, 8, 66, &
4, 60, 84, &
5, 34, 39, &
6, 26, 53, &
7, 32, 57, &
9, 52, 67, &
10, 12, 15, &
11, 51, 69, &
13, 14, 65, &
16, 31, 43, &
17, 20, 36, &
18, 80, 86, &
21, 48, 59, &
22, 40, 46, &
23, 33, 62, &
24, 30, 74, &
25, 42, 64, &
27, 49, 85, &
28, 38, 73, &
29, 44, 81, &
35, 68, 70, &
41, 63, 76, &
45, 49, 71, &
50, 58, 87, &
48, 54, 83, &
13, 55, 79, &
77, 78, 82, &
1, 2, 24, &
3, 6, 75, &
4, 56, 87, &
5, 44, 53, &
7, 50, 83, &
8, 10, 28, &
9, 55, 62, &
11, 29, 67, &
12, 33, 40, &
14, 16, 20, &
15, 35, 73, &
17, 31, 39, &
18, 36, 57, &
19, 46, 76, &
21, 42, 84, &
22, 34, 59, &
23, 26, 61, &
25, 60, 65, &
27, 64, 80, &
30, 37, 66, &
32, 45, 72, &
38, 51, 86, &
41, 77, 79, &
43, 56, 68, &
47, 74, 82, &
40, 52, 78, &
54, 61, 71, &
46, 58, 69/
data Nm/ &
1, 30, 60, 89, 118, 147, 0, &
2, 31, 61, 90, 119, 147, 0, &
3, 32, 62, 91, 120, 148, 0, &
4, 33, 63, 92, 121, 149, 0, &
2, 34, 64, 93, 122, 150, 0, &
5, 33, 65, 94, 123, 148, 0, &
6, 34, 66, 95, 124, 151, 0, &
7, 35, 67, 96, 120, 152, 0, &
8, 36, 68, 97, 125, 153, 0, &
9, 37, 69, 98, 126, 152, 0, &
10, 38, 70, 99, 127, 154, 0, &
11, 39, 71, 100, 126, 155, 0, &
12, 40, 61, 101, 128, 145, 0, &
10, 33, 60, 95, 128, 156, 0, &
13, 41, 72, 97, 126, 157, 0, &
13, 42, 73, 90, 129, 156, 0, &
14, 39, 74, 99, 130, 158, 0, &
15, 43, 75, 102, 131, 159, 0, &
16, 43, 71, 103, 118, 160, 0, &
17, 44, 76, 98, 130, 156, 0, &
18, 45, 60, 96, 132, 161, 0, &
19, 46, 73, 83, 133, 162, 0, &
12, 38, 77, 102, 134, 163, 0, &
19, 47, 78, 104, 135, 147, 0, &
1, 32, 77, 105, 136, 164, 0, &
20, 48, 73, 106, 123, 163, 0, &
21, 41, 79, 107, 137, 165, 0, &
22, 42, 66, 108, 138, 152, 0, &
18, 42, 80, 109, 139, 154, 0, &
23, 49, 81, 110, 135, 166, 0, &
16, 50, 82, 91, 129, 158, 0, &
3, 48, 63, 107, 124, 167, 0, &
6, 51, 67, 111, 134, 155, 0, &
24, 35, 77, 100, 122, 162, 0, &
20, 45, 76, 112, 140, 157, 0, &
21, 36, 64, 92, 130, 159, 0, &
8, 52, 83, 111, 118, 166, 0, &
21, 53, 84, 113, 138, 168, 0, &
25, 51, 79, 89, 122, 158, 0, &
22, 44, 75, 107, 133, 155, 172, &
9, 54, 84, 90, 141, 169, 0, &
22, 54, 85, 110, 136, 161, 0, &
8, 37, 65, 102, 129, 170, 0, &
19, 39, 85, 114, 139, 150, 0, &
26, 55, 71, 93, 142, 167, 0, &
27, 56, 65, 96, 133, 160, 174, &
28, 31, 86, 100, 117, 171, 0, &
28, 52, 70, 104, 132, 144, 0, &
24, 57, 68, 95, 137, 142, 0, &
7, 30, 72, 110, 143, 151, 0, &
4, 51, 76, 115, 127, 168, 0, &
16, 45, 87, 114, 125, 172, 0, &
15, 30, 86, 115, 123, 150, 0, &
23, 46, 64, 91, 144, 173, 0, &
23, 35, 75, 113, 145, 153, 0, &
14, 41, 87, 108, 117, 149, 170, &
25, 40, 85, 94, 124, 159, 0, &
25, 58, 69, 116, 143, 174, 0, &
29, 43, 61, 116, 132, 162, 0, &
15, 58, 88, 112, 121, 164, 0, &
4, 59, 72, 114, 119, 163, 173, &
27, 47, 86, 98, 134, 153, 0, &
5, 44, 78, 109, 141, 0, 0, &
10, 46, 69, 103, 136, 165, 0, &
9, 50, 59, 93, 128, 164, 0, &
14, 57, 58, 109, 120, 166, 0, &
17, 55, 62, 116, 125, 154, 0, &
3, 54, 70, 101, 140, 170, 0, &
1, 36, 82, 108, 127, 174, 0, &
5, 53, 81, 105, 140, 0, 0, &
29, 53, 67, 99, 142, 173, 0, &
18, 49, 74, 97, 115, 167, 0, &
2, 57, 63, 103, 138, 157, 0, &
26, 38, 79, 112, 135, 171, 0, &
11, 52, 66, 88, 119, 148, 0, &
20, 40, 68, 117, 141, 160, 0, &
11, 48, 81, 89, 146, 169, 0, &
29, 47, 80, 92, 146, 172, 0, &
6, 32, 87, 104, 145, 169, 0, &
27, 34, 74, 106, 131, 165, 0, &
12, 56, 84, 88, 139, 0, 0, &
13, 56, 62, 111, 146, 171, 0, &
26, 37, 80, 105, 144, 151, 0, &
17, 31, 82, 113, 121, 161, 0, &
28, 49, 59, 94, 137, 0, 0, &
7, 55, 83, 101, 131, 168, 0, &
24, 50, 78, 106, 143, 149, 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,6,6,6,6,6, &
6,6,6,6,6,6,6,6,6,7, &
6,6,6,6,6,7,6,6,6,6, &
6,6,6,6,6,7,6,6,6,6, &
7,6,5,6,6,6,6,6,6,5, &
6,6,6,6,6,6,6,6,6,6, &
5,6,6,6,5,6,6/
ncw=3
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
! 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
! 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
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 bpdecode174