Work on (174,101) encoding and decoding for ft4slow.

This commit is contained in:
Steven Franke 2020-04-22 10:36:48 -05:00
parent 3085047a96
commit edeb756257
8 changed files with 293 additions and 159 deletions

View File

@ -1,12 +1,11 @@
subroutine bpdecode174_101(llr,apmask,maxiterations,message50,cw,nharderror,iter)
subroutine bpdecode174_101(llr,apmask,maxiterations,message101,cw,nharderror,iter,ncheck)
!
! A log-domain belief propagation decoder for the (174,101) code.
!
integer, parameter:: N=174, K=101, M=N-K
integer*1 cw(N),apmask(N)
integer*1 decoded(K)
integer*1 message77(77)
integer*1 message101(101)
integer nrw(M),ncw
integer Nm(8,M)
integer Mn(3,N) ! 3 checks per bit
@ -46,19 +45,18 @@ subroutine bpdecode174_101(llr,apmask,maxiterations,message50,cw,nharderror,iter
! 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'
! if( mod(synd(i),2) .ne. 0 ) write(*,*) 'check ',i,' unsatisfied'
enddo
if( ncheck .eq. 0 ) then ! we have a codeword - if crc is good, return it
decoded=cw(1:101)
call get_crc24(decoded,101,nbadcrc)
nharderror=count( (2*cw-1)*llr .lt. 0.0 )
if(nbadcrc.eq.0) then
message77=decoded(1:77)
message101=decoded(1:101)
return
endif
endif

View File

@ -1,4 +1,4 @@
subroutine bpdecode174_74(llr,apmask,maxiterations,message50,cw,nharderror,iter)
subroutine bpdecode174_74(llr,apmask,maxiterations,message50,cw,nharderror,iter,ncheck)
!
! A log-domain belief propagation decoder for the (174,74) code.
!

View File

@ -0,0 +1,128 @@
subroutine decode174_101(llr,Keff,ndeep,apmask,maxsuper,message101,cw,nharderror,iter,ncheck,dmin,isuper)
!
! A hybrid bp/osd decoder for the (174,101) code.
!
integer, parameter:: N=174, K=101, M=N-K
integer*1 cw(N),apmask(N)
integer*1 decoded(K)
integer*1 message101(101)
integer nrw(M),ncw
integer Nm(8,M)
integer Mn(3,N) ! 3 checks per bit
integer synd(M)
real tov(3,N)
real toc(8,M)
real tanhtoc(8,M)
real zn(N),zsum(N)
real llr(N)
real Tmn
include "ldpc_174_101_parity.f90"
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
nclast=0
maxiterations=1
zsum=0.0
do isuper=1,maxsuper
do iter=0,maxiterations
! Update bit log likelihood ratios (tov=0 in iteration 0).
do i=1,N
if( apmask(i) .ne. 1 ) then
zn(i)=llr(i)+sum(tov(1:ncw,i))
else
zn(i)=llr(i)
endif
enddo
zsum=zsum+zn
! 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 - if crc is good, return it
decoded=cw(1:K)
call get_crc24(decoded,74,nbadcrc)
nharderror=count( (2*cw-1)*llr .lt. 0.0 )
if(nbadcrc.eq.0) then
message101=decoded(1:101)
dmin=0.0
return
endif
endif
! if( iter.gt.0 ) then ! this code block implements an early stopping criterion
if( iter.gt.10000 ) then ! this code block implements an early stopping criterion
nd=ncheck-nclast
if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased
ncnt=0 ! reset counter
else
ncnt=ncnt+1
endif
! write(*,*) iter,ncheck,nd,ncnt
if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then
nharderror=-1
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:8,i)=tanh(-toc(1:8,i)/2)
enddo
do j=1,N
do i=1,ncw
ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j
Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j)
call platanh(-Tmn,y)
! y=atanh(-Tmn)
tov(i,j)=2*y
enddo
enddo
enddo ! bp iterations
llr=zsum
call osd174_101(llr,Keff,apmask,ndeep,message101,cw,nharderror,dmin)
if(nharderror.gt.0) then
return
endif
enddo ! super iterations
nharderror=-1
return
end subroutine decode174_101

View File

@ -1,34 +1,34 @@
data Mn/ &
2, 54, 72, &
18, 60, 62, &
13, 24, 47, &
37, 50, 70, &
3, 30, 66, &
4, 9, 14, &
5, 19, 23, &
6, 21, 47, &
10, 33, 73, &
7, 31, 50, &
3, 30, 66, &
8, 39, 70, &
36, 46, 63, &
16, 53, 55, &
10, 33, 73, &
11, 22, 49, &
12, 60, 61, &
16, 53, 55, &
17, 63, 67, &
24, 59, 64, &
25, 27, 68, &
14, 35, 44, &
28, 57, 72, &
32, 48, 51, &
26, 38, 46, &
11, 22, 49, &
28, 57, 72, &
29, 36, 43, &
32, 48, 51, &
34, 52, 69, &
45, 56, 65, &
14, 35, 44, &
40, 41, 42, &
45, 56, 65, &
31, 51, 54, &
42, 58, 69, &
29, 36, 43, &
4, 10, 12, &
1, 37, 72, &
2, 27, 64, &
3, 41, 70, &
1, 37, 72, &
4, 10, 12, &
5, 40, 59, &
6, 19, 39, &
7, 53, 68, &
@ -104,150 +104,150 @@ data Mn/ &
2, 5, 62, &
3, 27, 57, &
4, 43, 51, &
2, 35, 63, &
6, 53, 59, &
14, 28, 40, &
7, 29, 66, &
8, 42, 72, &
9, 31, 36, &
10, 35, 55, &
11, 13, 54, &
12, 63, 65, &
10, 11, 15, &
14, 22, 69, &
20, 41, 48, &
15, 16, 70, &
27, 38, 56, &
9, 16, 24, &
17, 47, 56, &
18, 45, 50, &
19, 30, 44, &
20, 60, 71, &
1, 44, 65, &
22, 26, 68, &
23, 28, 61, &
24, 25, 39, &
51, 69, 70, &
26, 34, 67, &
33, 39, 66, &
32, 37, 38, &
19, 36, 57, &
40, 49, 52, &
13, 46, 50, &
48, 64, 73, &
15, 17, 59, &
22, 26, 68, &
12, 37, 64, &
52, 55, 71, &
49, 53, 62, &
17, 18, 23, &
1, 44, 65, &
25, 32, 34, &
1, 41, 43, &
33, 41, 46, &
2, 35, 63, &
30, 45, 72, &
31, 61, 73, &
21, 29, 52, &
26, 34, 67, &
3, 6, 60, &
2, 61, 66, &
14, 28, 40, &
4, 7, 42, &
4, 6, 34, &
3, 13, 14, &
9, 38, 58, &
19, 36, 57, &
25, 32, 34, &
32, 37, 38, &
33, 41, 46, &
17, 18, 23, &
5, 43, 47, &
30, 45, 72, &
12, 37, 64, &
27, 38, 56, &
31, 61, 73, &
40, 49, 52, &
20, 41, 48, &
21, 29, 52, &
8, 68, 71, &
15, 17, 59, &
3, 13, 14, &
2, 61, 66, &
9, 38, 58, &
48, 64, 73, &
49, 53, 62, &
10, 19, 26, &
5, 37, 68, &
1, 41, 43, &
52, 55, 71, &
16, 20, 30, &
12, 39, 40, &
4, 6, 34, &
51, 69, 70, &
7, 11, 64, &
18, 25, 35, &
48, 57, 62, &
21, 45, 73, &
54, 58, 67, &
9, 16, 24, &
27, 51, 55, &
33, 53, 69, &
20, 28, 67, &
12, 39, 40, &
33, 39, 66, &
5, 37, 68, &
8, 31, 59, &
22, 29, 56, &
37, 50, 70, &
32, 44, 49, &
10, 11, 15, &
4, 9, 14, &
21, 45, 73, &
27, 51, 55, &
23, 42, 65, &
1, 15, 71/
22, 29, 56, &
20, 28, 67, &
32, 44, 49, &
33, 53, 69, &
13, 24, 47, &
36, 46, 63, &
1, 15, 71, &
48, 57, 62/
data Nm/ &
30, 52, 63, 101, 102, 138, 140, 174, &
1, 28, 53, 76, 103, 142, 147, 0, &
8, 29, 50, 77, 104, 146, 150, 0, &
27, 54, 76, 100, 105, 148, 149, 172, &
4, 31, 55, 78, 93, 103, 152, 155, &
5, 32, 56, 79, 106, 146, 149, 0, &
7, 33, 57, 80, 108, 148, 158, 0, &
9, 34, 58, 81, 109, 153, 167, 0, &
35, 55, 74, 110, 151, 163, 172, 0, &
6, 27, 59, 82, 111, 154, 171, 0, &
20, 36, 56, 58, 112, 158, 171, 0, &
12, 27, 60, 83, 113, 134, 157, 0, &
3, 37, 52, 84, 112, 130, 150, 0, &
16, 61, 85, 107, 114, 150, 172, 0, &
38, 47, 86, 116, 132, 171, 174, 0, &
11, 39, 60, 76, 116, 156, 163, 0, &
13, 40, 62, 87, 118, 132, 137, 0, &
2, 36, 63, 88, 119, 137, 159, 0, &
4, 32, 64, 85, 120, 128, 154, 0, &
37, 53, 77, 115, 121, 156, 166, 0, &
5, 41, 60, 85, 102, 145, 161, 0, &
20, 42, 51, 89, 114, 133, 168, 0, &
4, 39, 65, 89, 122, 137, 173, 0, &
3, 14, 43, 65, 82, 123, 163, 0, &
15, 44, 66, 90, 123, 139, 159, 0, &
19, 41, 67, 91, 125, 133, 154, 0, &
15, 28, 68, 86, 104, 117, 164, 0, &
17, 38, 69, 80, 107, 122, 166, 0, &
26, 37, 59, 81, 108, 145, 168, 0, &
8, 44, 70, 81, 97, 120, 143, 156, &
7, 24, 66, 77, 101, 110, 144, 167, &
18, 45, 59, 92, 127, 139, 170, 0, &
6, 46, 71, 93, 126, 141, 165, 0, &
21, 47, 72, 94, 125, 139, 149, 0, &
16, 34, 57, 95, 111, 142, 159, 0, &
10, 26, 36, 72, 86, 110, 128, 0, &
30, 70, 95, 100, 127, 134, 155, 169, &
19, 48, 58, 96, 117, 127, 151, 0, &
9, 32, 73, 87, 98, 123, 126, 157, &
23, 31, 68, 97, 107, 129, 157, 0, &
23, 29, 62, 94, 95, 115, 140, 141, &
23, 25, 67, 84, 109, 148, 173, 0, &
26, 44, 48, 87, 105, 140, 152, 0, &
16, 49, 67, 79, 120, 138, 170, 0, &
22, 47, 55, 98, 119, 143, 161, 0, &
10, 19, 38, 54, 90, 130, 141, 0, &
3, 5, 34, 45, 99, 118, 152, 0, &
18, 35, 65, 79, 101, 115, 131, 160, &
20, 50, 54, 82, 129, 136, 170, 0, &
7, 49, 68, 75, 119, 130, 169, 0, &
18, 24, 43, 88, 105, 124, 164, 0, &
21, 40, 74, 80, 129, 135, 145, 0, &
11, 33, 52, 94, 106, 136, 165, 0, &
1, 24, 39, 71, 75, 112, 162, 0, &
11, 51, 73, 78, 111, 135, 164, 0, &
22, 46, 69, 100, 117, 118, 168, 0, &
17, 40, 57, 83, 104, 128, 160, 0, &
25, 50, 64, 91, 102, 151, 162, 0, &
14, 31, 74, 91, 106, 132, 167, 0, &
2, 12, 48, 75, 89, 121, 146, 0, &
12, 45, 73, 88, 122, 144, 147, 0, &
2, 41, 69, 98, 103, 136, 160, 0, &
10, 13, 42, 70, 92, 113, 142, 0, &
14, 28, 61, 64, 131, 134, 158, 0, &
22, 43, 56, 93, 113, 138, 173, 0, &
8, 35, 63, 83, 108, 126, 147, 0, &
13, 49, 66, 78, 125, 162, 166, 0, &
15, 33, 62, 96, 133, 153, 155, 0, &
21, 25, 53, 97, 99, 114, 124, 165, &
9, 29, 71, 90, 116, 124, 169, 0, &
46, 61, 92, 121, 135, 153, 174, 0, &
1, 17, 30, 51, 99, 109, 143, 0, &
6, 42, 72, 84, 96, 131, 144, 161/
27, 52, 63, 101, 102, 122, 152, 173, &
1, 28, 53, 76, 103, 106, 147, 0, &
4, 29, 50, 77, 104, 128, 146, 0, &
5, 30, 54, 76, 100, 105, 130, 155, &
6, 31, 55, 78, 93, 103, 136, 162, &
7, 32, 56, 79, 107, 128, 155, 0, &
8, 33, 57, 80, 108, 130, 157, 0, &
9, 34, 58, 81, 109, 144, 163, 0, &
5, 35, 55, 74, 110, 117, 148, 0, &
10, 30, 59, 82, 111, 114, 151, 0, &
11, 36, 56, 58, 112, 114, 157, 0, &
12, 30, 60, 83, 113, 138, 160, 0, &
37, 52, 84, 112, 126, 146, 171, 0, &
5, 22, 61, 85, 115, 129, 146, 0, &
38, 47, 86, 114, 116, 145, 173, 0, &
13, 39, 60, 76, 116, 117, 154, 0, &
14, 40, 62, 87, 118, 135, 145, 0, &
2, 36, 63, 88, 119, 135, 158, 0, &
6, 32, 64, 85, 120, 131, 151, 0, &
37, 53, 77, 121, 142, 154, 168, 0, &
7, 41, 60, 85, 102, 143, 164, 0, &
11, 42, 51, 89, 115, 123, 167, 0, &
6, 39, 65, 89, 124, 135, 166, 0, &
15, 43, 65, 82, 117, 125, 171, 0, &
16, 44, 66, 90, 125, 132, 158, 0, &
17, 41, 67, 91, 123, 127, 151, 0, &
16, 28, 68, 86, 104, 139, 165, 0, &
18, 38, 69, 80, 124, 129, 168, 0, &
19, 37, 59, 81, 108, 143, 167, 0, &
4, 44, 70, 81, 97, 120, 137, 154, &
8, 25, 66, 77, 101, 110, 140, 163, &
20, 45, 59, 92, 132, 133, 169, 0, &
10, 46, 71, 93, 134, 161, 170, 0, &
21, 47, 72, 94, 127, 132, 155, 0, &
22, 34, 57, 95, 106, 111, 158, 0, &
19, 36, 72, 86, 110, 131, 172, 0, &
3, 27, 70, 95, 100, 133, 138, 162, &
17, 48, 58, 96, 133, 139, 148, 0, &
9, 32, 73, 87, 98, 125, 160, 161, &
23, 31, 68, 97, 129, 141, 160, 0, &
23, 29, 62, 94, 95, 134, 142, 152, &
23, 26, 67, 84, 109, 130, 166, 0, &
19, 44, 48, 87, 105, 136, 152, 0, &
22, 49, 67, 79, 120, 122, 169, 0, &
24, 47, 55, 98, 119, 137, 164, 0, &
17, 38, 54, 90, 126, 134, 172, 0, &
7, 34, 45, 99, 118, 136, 171, 0, &
20, 35, 65, 79, 101, 142, 149, 174, &
11, 50, 54, 82, 141, 150, 169, 0, &
3, 8, 49, 68, 75, 119, 126, 0, &
20, 25, 43, 88, 105, 156, 165, 0, &
21, 40, 74, 80, 141, 143, 153, 0, &
13, 33, 52, 94, 107, 150, 170, 0, &
1, 25, 39, 71, 75, 112, 159, 0, &
13, 51, 73, 78, 111, 153, 165, 0, &
24, 46, 69, 100, 118, 139, 167, 0, &
18, 40, 57, 83, 104, 131, 174, 0, &
26, 50, 64, 91, 102, 148, 159, 0, &
15, 31, 74, 91, 107, 145, 163, 0, &
2, 12, 48, 75, 89, 121, 128, 0, &
12, 45, 73, 88, 124, 140, 147, 0, &
2, 41, 69, 98, 103, 150, 174, 0, &
14, 42, 70, 92, 106, 113, 172, 0, &
15, 28, 61, 64, 138, 149, 157, 0, &
24, 43, 56, 93, 113, 122, 166, 0, &
4, 35, 63, 83, 108, 147, 161, 0, &
14, 49, 66, 78, 127, 159, 168, 0, &
16, 33, 62, 96, 123, 144, 162, 0, &
21, 26, 53, 97, 99, 115, 156, 170, &
3, 9, 29, 71, 90, 116, 156, 0, &
46, 61, 92, 121, 144, 153, 173, 0, &
1, 18, 27, 51, 99, 109, 137, 0, &
10, 42, 72, 84, 96, 140, 149, 164/
data nrw/ &
8,7,7,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, &

View File

@ -12,7 +12,7 @@ program ldpcsim174_101
integer*1 msgbits(101)
integer*1 apmask(174)
integer*1 cw(174)
integer*1 codeword(N),message(77)
integer*1 codeword(N),message(77),message101(101)
integer ncrc24
real rxdata(N),llr(N)
real dllr(174),llrd(174)
@ -59,7 +59,6 @@ program ldpcsim174_101
call get_crc24(msgbits,101,ncrc24)
write(c24,'(b24.24)') ncrc24
write(*,*) 'c24 ',c24
read(c24,'(24i1)') msgbits(78:101)
write(*,'(24i1)') msgbits(78:101)
write(*,*) 'message with crc24'
@ -103,10 +102,12 @@ write(*,'(24i1)') msgbits(78:101)
llr=2.0*rxdata/(ss*ss)
apmask=0
! max_iterations is max number of belief propagation iterations
call bpdecode174_101(llr,apmask,max_iterations,message,cw,nharderror,niterations)
call bpdecode174_101(llr,apmask,max_iterations,message101,cw,nharderror,niterations,nchecks)
dmin=0.0
if( (nharderror .lt. 0) .and. (ndeep .ge. 0) ) then
call osd174_101(llr, Keff, apmask, ndeep, message, cw, nharderror, dmin)
! call osd174_101(llr, Keff, apmask, ndeep, message101, cw, nharderror, dmin)
maxsuper=2
call decode174_101(llr, Keff, ndeep, apmask, maxsuper, message101, cw, nharderror, iterations, ncheck, dmin, isuper)
endif
if(nharderror.ge.0) then
@ -127,7 +128,8 @@ write(*,'(24i1)') msgbits(78:101)
write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,esn0,ngood,nue,ss,pberr
if(first) then
write(c77,'(77i1)') message
write(c77,'(77i1)') message101(1:77)
write(*,'(101i1)') message101
call unpack77(c77,0,msg,unpk77_success)
if(unpk77_success) then
write(*,1100) msg(1:37)

View File

@ -13,7 +13,7 @@ program ldpcsim174_74
integer*1 msgbits(74)
integer*1 apmask(174)
integer*1 cw(174)
integer*1 codeword(N),message(50)
integer*1 codeword(N),message74(74)
integer ncrc24
integer nerrtot(174),nerrdec(174),nmpcbad(74)
real rxdata(N),llr(N)
@ -107,11 +107,11 @@ program ldpcsim174_74
llr=2.0*rxdata/(ss*ss)
apmask=0
! max_iterations is max number of belief propagation iterations
call bpdecode174_74(llr,apmask,max_iterations,message,cw,nharderror,niterations)
call bpdecode174_74(llr,apmask,max_iterations,message74,cw,nharderror,niterations,nchecks)
dmin=0.0
if( (nharderror .lt. 0) .and. (ndeep .ge. 0) ) then
! call osd174_74(llr, Keff, apmask, ndeep, message, cw, nharderror, dmin)
call decode174_74(llr,Keff,ndeep,apmask,max_iterations,message,cw,nharderror,niterations,ncheck,dmin,isuper)
! call osd174_74(llr, Keff, apmask, ndeep, message74, cw, nharderror, dmin)
call decode174_74(llr,Keff,ndeep,apmask,max_iterations,message74,cw,nharderror,niterations,ncheck,dmin,isuper)
endif
if(nharderror.ge.0) then
@ -132,7 +132,7 @@ call decode174_74(llr,Keff,ndeep,apmask,max_iterations,message,cw,nharderror,nit
write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,esn0,ngood,nue,ss,pberr
if(first) then
write(c77,'(50i1)') message
write(c77,'(74i1)') message74
c77(51:77)='000000000000000000000110000'
call unpack77(c77,0,msg,unpk77_success)
if(unpk77_success) then

View File

@ -22,7 +22,7 @@ subroutine osd174_101(llr,k,apmask,ndeep,message101,cw,nhardmin,dmin)
integer indices(N),nxor(N)
integer*1 cw(N),ce(N),c0(N),hdec(N)
integer*1, allocatable :: decoded(:)
integer*1 message77(77),message101(101)
integer*1 message101(101)
integer indx(N)
real llr(N),rx(N),absrx(N)

View File

@ -22,7 +22,8 @@ program wspr4d
integer*2 iwave(NMAX) !Generated full-length waveform
integer*1 apmask(174),cw(174)
integer*1 hbits(206)
integer*1 message(50)
integer*1 message74(74)
integer*1 message101(101)
logical badsync,unpk77_success
fs=12000.0/NDOWN !Sample rate
@ -107,7 +108,7 @@ program wspr4d
do if=-ifhw,ifhw
fc=fc1+df*if
do istart=max(1,is0-ishw),is0+ishw,dis
call coherent_sync(c2,istart,fc,1,sync,data_aided,kstart,tones)
call coherent_sync(c2,istart,fc,1,sync)
if(sync.gt.smax) then
fc2=fc
isbest=istart
@ -115,11 +116,12 @@ program wspr4d
endif
enddo
enddo
write(*,*) ifile,icand,isync,fc1+del,fc2+del,isbest,smax
! write(*,*) ifile,icand,isync,fc1+del,fc2+del,isbest,smax
enddo
if(smax .lt. 100.0 ) cycle
! if(smax .lt. 100.0 ) cycle
!isbest=375
!fc2=-del
idecoded=0
do ijitter=0,2
if(idecoded.eq.1) exit
@ -166,18 +168,22 @@ program wspr4d
nhardbp=0
nhardosd=0
dmin=0.0
call bpdecode174_74(llr,apmask,max_iterations,message,cw,nhardbp,niterations)
Keff=64
! if(nhardbp.lt.0) call osd174_74(llr,Keff,apmask,5,message,cw,nhardosd,dmin)
! call bpdecode174_74(llr,apmask,max_iterations,message74,cw,nhardbp,niterations,nchecks)
call bpdecode174_101(llr,apmask,max_iterations,message101,cw,nhardbp,niterations,ncheck101)
Keff=91
! if(nhardbp.lt.0) call osd174_74(llr,Keff,apmask,5,message74,cw,nhardosd,dmin)
! if(nhardbp.lt.0) call osd174_101(llr,Keff,apmask,5,message74,cw,nhardosd,dmin)
maxsuperits=2
ndeep=4
! ndeep=4
ndeep=3
if(nhardbp.lt.0) then
call decode174_74(llr,Keff,ndeep,apmask,maxsuperits,message,cw,nhardosd,iter,ncheck,dmin,isuper)
! call decode174_74(llr,Keff,ndeep,apmask,maxsuperits,message74,cw,nhardosd,iter,ncheck,dmin,isuper)
call decode174_101(llr,Keff,ndeep,apmask,maxsuperits,message101,cw,nhardosd,iter,ncheck,dmin,isuper)
endif
if(nhardbp.ge.0 .or. nhardosd.ge.0) then
write(c77,'(50i1)') message
c77(51:77)='000000000000000000000110000'
! write(c77,'(50i1)') message74(1:50)
! c77(51:77)='000000000000000000000110000'
write(c77,'(77i1)') message101(1:77)
call unpack77(c77,0,msg,unpk77_success)
if(unpk77_success .and. index(msg,'K9AN').gt.0) then
idecoded=1