diff options
Diffstat (limited to 'lib/ft8')
28 files changed, 1498 insertions, 1487 deletions
diff --git a/lib/ft8/bpdecode174.f90 b/lib/ft8/bpdecode174.f90 deleted file mode 100644 index 9442cc4a..00000000 --- a/lib/ft8/bpdecode174.f90 +++ /dev/null @@ -1,401 +0,0 @@ -subroutine bpdecode174(llr,apmask,maxiterations,decoded,cw,nharderror,iter) -! -! 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 - -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: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 -nharderror=-1 -return -end subroutine bpdecode174 diff --git a/lib/ft8/bpdecode174_91.f90 b/lib/ft8/bpdecode174_91.f90 new file mode 100644 index 00000000..78809f19 --- /dev/null +++ b/lib/ft8/bpdecode174_91.f90 @@ -0,0 +1,115 @@ +subroutine bpdecode174_91(llr,apmask,maxiterations,message77,cw,nharderror,iter) +! +! A log-domain belief propagation decoder for the (174,91) code. +! +use iso_c_binding, only: c_loc,c_size_t +use crc +integer, parameter:: N=174, K=91, M=N-K +integer*1 cw(N),apmask(N) +integer*1 decoded(K) +integer*1 message77(77) +integer nrw(M),ncw +integer Nm(7,M) +integer Mn(3,N) ! 3 checks per bit +integer synd(M) +real tov(3,N) +real toc(7,M) +real tanhtoc(7,M) +real zn(N) +real llr(N) +real Tmn + +include "ldpc_174_91_c_reordered_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 + +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 - if crc is good, return it + decoded=cw(1:K) + call chkcrc14a(decoded,nbadcrc) + nharderror=count( (2*cw-1)*llr .lt. 0.0 ) + if(nbadcrc.eq.0) then + message77=decoded(1:77) + 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: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 +nharderror=-1 +return +end subroutine bpdecode174_91 diff --git a/lib/ft8/chkcrc12a.f90 b/lib/ft8/chkcrc12a.f90 deleted file mode 100644 index fc429190..00000000 --- a/lib/ft8/chkcrc12a.f90 +++ /dev/null @@ -1,24 +0,0 @@ -subroutine chkcrc12a(decoded,nbadcrc)
-
- use crc
- integer*1 decoded(87)
- integer*1, target:: i1Dec8BitBytes(11)
- character*87 cbits
-
-! Write decoded bits into cbits: 75-bit message plus 12-bit CRC
- write(cbits,1000) decoded
-1000 format(87i1)
- read(cbits,1001) i1Dec8BitBytes
-1001 format(11b8)
- read(cbits,1002) ncrc12 !Received CRC12
-1002 format(75x,b12)
-
- i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32)
- i1Dec8BitBytes(11)=0
- icrc12=crc12(c_loc(i1Dec8BitBytes),11) !CRC12 computed from 75 msg bits
-
- nbadcrc=1
- if(ncrc12.eq.icrc12) nbadcrc=0
-
- return
-end subroutine chkcrc12a
diff --git a/lib/ft8/chkcrc13a.f90 b/lib/ft8/chkcrc13a.f90 new file mode 100644 index 00000000..74259cfc --- /dev/null +++ b/lib/ft8/chkcrc13a.f90 @@ -0,0 +1,24 @@ +subroutine chkcrc13a(decoded,nbadcrc)
+
+ use crc
+ integer*1 decoded(90)
+ integer*1, target:: i1Dec8BitBytes(12)
+ character*90 cbits
+
+! Write decoded bits into cbits: 77-bit message plus 13-bit CRC
+ write(cbits,1000) decoded
+1000 format(90i1)
+ read(cbits,1001) i1Dec8BitBytes
+1001 format(12b8)
+ read(cbits,1002) ncrc13 !Received CRC13
+1002 format(77x,b13)
+
+ i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
+ i1Dec8BitBytes(11:12)=0
+ icrc13=crc13(c_loc(i1Dec8BitBytes),12) !CRC13 computed from 77 msg bits
+
+ nbadcrc=1
+ if(ncrc13.eq.icrc13) nbadcrc=0
+
+ return
+end subroutine chkcrc13a
diff --git a/lib/ft8/chkcrc14a.f90 b/lib/ft8/chkcrc14a.f90 new file mode 100644 index 00000000..d9d3d7a4 --- /dev/null +++ b/lib/ft8/chkcrc14a.f90 @@ -0,0 +1,24 @@ +subroutine chkcrc14a(decoded,nbadcrc)
+
+ use crc
+ integer*1 decoded(91)
+ integer*1, target:: i1Dec8BitBytes(12)
+ character*91 cbits
+
+! Write decoded bits into cbits: 77-bit message plus 14-bit CRC
+ write(cbits,1000) decoded
+1000 format(91i1)
+ read(cbits,1001) i1Dec8BitBytes
+1001 format(12b8)
+ read(cbits,1002) ncrc14 !Received CRC14
+1002 format(77x,b14)
+
+ i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8)
+ i1Dec8BitBytes(11:12)=0
+ icrc14=crc14(c_loc(i1Dec8BitBytes),12) !CRC14 computed from 77 msg bits
+
+ nbadcrc=1
+ if(ncrc14.eq.icrc14) nbadcrc=0
+
+ return
+end subroutine chkcrc14a
diff --git a/lib/ft8/encode174_91.f90 b/lib/ft8/encode174_91.f90 new file mode 100644 index 00000000..0ffa4841 --- /dev/null +++ b/lib/ft8/encode174_91.f90 @@ -0,0 +1,58 @@ +subroutine encode174_91(message77,codeword) +! +! Add a 14-bit CRC to a 77-bit message and return a 174-bit codeword +! +use, intrinsic :: iso_c_binding +use iso_c_binding, only: c_loc,c_size_t +use crc + +integer, parameter:: N=174, K=91, M=N-K +character*91 tmpchar +integer*1 codeword(N) +integer*1 gen(M,K) +integer*1 message77(77),message(K) +integer*1 pchecks(M) +integer*1, target :: i1MsgBytes(12) +include "ldpc_174_91_c_generator.f90" +logical first +data first/.true./ +save first,gen + +if( first ) then ! fill the generator matrix + gen=0 + do i=1,M + do j=1,23 + read(g(i)(j:j),"(Z1)") istr + ibmax=4 + if(j.eq.23) ibmax=3 + do jj=1, ibmax + icol=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(i,icol)=1 + enddo + enddo + enddo +first=.false. +endif + +! Add 14-bit CRC to form 91-bit message+CRC14 +write(tmpchar,'(77i1)') message77 +tmpchar(78:80)='000' +i1MsgBytes=0 +read(tmpchar,'(10b8)') i1MsgBytes(1:10) +ncrc14 = crc14 (c_loc (i1MsgBytes), 12) +write(tmpchar(78:91),'(b14)') ncrc14 +read(tmpchar,'(91i1)') message + +do i=1,M + nsum=0 + do j=1,K + nsum=nsum+message(j)*gen(i,j) + enddo + pchecks(i)=mod(nsum,2) +enddo + +codeword(1:K)=message +codeword(K+1:N)=pchecks + +return +end subroutine encode174_91 diff --git a/lib/ft8/extractmessage174.f90 b/lib/ft8/extractmessage174.f90 index e7c7c3a1..4bac6694 100644 --- a/lib/ft8/extractmessage174.f90 +++ b/lib/ft8/extractmessage174.f90 @@ -30,7 +30,7 @@ subroutine extractmessage174(decoded,msgreceived,ncrcflag) enddo i4Dec6BitWords(ibyte)=itmp enddo - call unpackmsg(i4Dec6BitWords,msgreceived,.false.,' ') + call unpackmsg(i4Dec6BitWords,msgreceived) ncrcflag=1 else msgreceived=' ' diff --git a/lib/ft8/extractmessage174_91.f90 b/lib/ft8/extractmessage174_91.f90 new file mode 100644 index 00000000..d2d3019e --- /dev/null +++ b/lib/ft8/extractmessage174_91.f90 @@ -0,0 +1,40 @@ +subroutine extractmessage174_91(decoded,msgreceived,ncrcflag) + use iso_c_binding, only: c_loc,c_size_t + use crc + use packjt + + character*22 msgreceived + character*91 cbits + integer*1 decoded(91) + integer*1, target:: i1Dec8BitBytes(12) + integer*4 i4Dec6BitWords(12) + +! Write decoded bits into cbits: 77-bit message plus 14-bit CRC + write(cbits,1000) decoded +1000 format(91i1) + read(cbits,1001) i1Dec8BitBytes +1001 format(12b8) + read(cbits,1002) ncrc14 !Received CRC12 +1002 format(77x,b14) + + i1Dec8BitBytes(10)=iand(i1Dec8BitBytes(10),128+64+32+16+8) + i1Dec8BitBytes(11:12)=0 + icrc14=crc14(c_loc(i1Dec8BitBytes),12) !CRC12 computed from 75 msg bits + + if(ncrc14.eq.icrc14 .or. sum(decoded(57:87)).eq.0) then !### Kludge ### +! CRC14 checks out --- unpack 72-bit message + do ibyte=1,12 + itmp=0 + do ibit=1,6 + itmp=ishft(itmp,1)+iand(1,decoded((ibyte-1)*6+ibit)) + enddo + i4Dec6BitWords(ibyte)=itmp + enddo + call unpackmsg(i4Dec6BitWords,msgreceived) + ncrcflag=1 + else + msgreceived=' ' + ncrcflag=-1 + endif + return + end subroutine extractmessage174_91 diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90 index b1220966..7492a6f7 100644 --- a/lib/ft8/foxgen.f90 +++ b/lib/ft8/foxgen.f90 @@ -14,84 +14,31 @@ subroutine foxgen() ! common/foxcom/. The generated wave(NWAVE) is passed back in the same
! common block.
- use crc
- parameter (NN=79,ND=58,KK=87,NSPS=4*1920)
+ parameter (NN=79,ND=58,NSPS=4*1920)
parameter (NWAVE=NN*NSPS,NFFT=614400,NH=NFFT/2)
character*40 cmsg
- character*22 msg,msgsent
- character*6 mygrid
- character*87 cbits
- character*88 cb88
- logical bcontest
- integer itone(NN)
- integer icos7(0:6)
- integer*1 msgbits(KK),codeword(3*ND),msgbits2
- integer*1, target:: i1Msg8BitBytes(11)
+ character*37 msg,msgsent
+ integer itone(79)
+ integer*1 msgbits(77),msgbits2
integer*1, target:: mycall
real x(NFFT)
real*8 dt,twopi,f0,fstep,dfreq,phi,dphi
complex cx(0:NH)
common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall(12)
- common/foxcom2/itone2(NN),msgbits2(KK)
+ common/foxcom2/itone2(NN),msgbits2(77)
equivalence (x,cx),(y,cy)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
- bcontest=.false.
fstep=60.d0
dfreq=6.25d0
dt=1.d0/48000.d0
twopi=8.d0*atan(1.d0)
- mygrid=' '
irpt=0
nplot=0
wave=0.
do n=1,nslots
- i3b=i3bit(n)
- if(i3b.eq.0) then
- msg=cmsg(n)(1:22) !Standard FT8 message
- else
- i1=index(cmsg(n),' ') !Special Fox message
- i2=index(cmsg(n),';')
- i3=index(cmsg(n),'<')
- i4=index(cmsg(n),'>')
- msg=cmsg(n)(1:i1)//cmsg(n)(i2+1:i3-2)//' '
- read(cmsg(n)(i4+2:i4+4),*) irpt
- endif
- call genft8(msg,mygrid,bcontest,0,msgsent,msgbits,itone)
-! print*,'Foxgen:',n,cmsg(n),msgsent
-
- if(i3b.eq.1) then
- icrc10=crc10(c_loc(mycall),12)
- nrpt=irpt+30
- write(cbits,1001) msgbits(1:56),icrc10,nrpt,i3b,0
-1001 format(56b1.1,b10.10,b6.6,b3.3,b12.12)
- read(cbits,1002) msgbits
-1002 format(87i1)
-
- cb88=cbits//'0'
- read(cb88,1003) i1Msg8BitBytes(1:11)
-1003 format(11b8)
- icrc12=crc12(c_loc(i1Msg8BitBytes),11)
-
- write(cbits,1001) msgbits(1:56),icrc10,nrpt,i3b,icrc12
- read(cbits,1002) msgbits
-
- call encode174(msgbits,codeword) !Encode the test message
-
-! Message structure: S7 D29 S7 D29 S7
- itone(1:7)=icos7
- itone(36+1:36+7)=icos7
- itone(NN-6:NN)=icos7
- k=7
- do j=1,ND
- i=3*j -2
- k=k+1
- if(j.eq.30) k=k+7
- itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
- enddo
- endif
-
+ msg=cmsg(n)(1:37)
+ call genft8(msg,i3,n3,msgsent,msgbits,itone)
! Make copies of itone() and msgbits() for ft8sim
itone2=itone
msgbits2=msgbits
diff --git a/lib/ft8/foxgen_wrap.f90 b/lib/ft8/foxgen_wrap.f90 index dbcb2582..bc8c430f 100644 --- a/lib/ft8/foxgen_wrap.f90 +++ b/lib/ft8/foxgen_wrap.f90 @@ -1,6 +1,6 @@ subroutine foxgen_wrap(msg40,msgbits,itone)
- parameter (NN=79,ND=58,KK=87,NSPS=4*1920)
+ parameter (NN=79,ND=58,KK=77,NSPS=4*1920)
parameter (NWAVE=NN*NSPS)
character*40 msg40,cmsg
diff --git a/lib/ft8/ft8_downsample.f90 b/lib/ft8/ft8_downsample.f90 index 79191416..f3552258 100644 --- a/lib/ft8/ft8_downsample.f90 +++ b/lib/ft8/ft8_downsample.f90 @@ -5,15 +5,23 @@ subroutine ft8_downsample(dd,newdat,f0,c1) parameter (NMAX=15*12000,NSPS=1920)
parameter (NFFT1=192000,NFFT2=3200) !192000/60 = 3200
- logical newdat
+ logical newdat,first
complex c1(0:NFFT2-1)
complex cx(0:NFFT1/2)
- real dd(NMAX),x(NFFT1)
+ real dd(NMAX),x(NFFT1),taper(0:100)
equivalence (x,cx)
- save cx
+ data first/.true./
+ save cx,first,taper
+ if(first) then
+ pi=4.0*atan(1.0)
+ do i=0,100
+ taper(i)=0.5*(1.0+cos(i*pi/100))
+ enddo
+ first=.false.
+ endif
if(newdat) then
-! Data in dd have changed, recompute the long FFT
+! Data in dd have changed, recompute the long FFT
x(1:NMAX)=dd
x(NMAX+1:NFFT1)=0. !Zero-pad the x array
call four2a(cx,NFFT1,1,-1,0) !r2c FFT to freq domain
@@ -23,9 +31,9 @@ subroutine ft8_downsample(dd,newdat,f0,c1) df=12000.0/NFFT1
baud=12000.0/NSPS
i0=nint(f0/df)
- ft=f0+8.0*baud
+ ft=f0+8.5*baud
it=min(nint(ft/df),NFFT1/2)
- fb=f0-1.0*baud
+ fb=f0-1.5*baud
ib=max(1,nint(fb/df))
k=0
c1=0.
@@ -33,6 +41,8 @@ subroutine ft8_downsample(dd,newdat,f0,c1) c1(k)=cx(i)
k=k+1
enddo
+ c1(0:100)=c1(0:100)*taper(100:0:-1)
+ c1(k-1-100:k-1)=c1(k-1-100:k-1)*taper
c1=cshift(c1,i0-ib)
call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain
fac=1.0/sqrt(float(NFFT1)*NFFT2)
diff --git a/lib/ft8/ft8_params.f90 b/lib/ft8/ft8_params.f90 index 858e61e9..bd228bde 100644 --- a/lib/ft8/ft8_params.f90 +++ b/lib/ft8/ft8_params.f90 @@ -1,5 +1,5 @@ -! LDPC (174,87) code
-parameter (KK=87) !Information bits (75 + CRC12)
+! LDPC (174,91) code
+parameter (KK=91) !Information bits (77 + CRC14)
parameter (ND=58) !Data symbols
parameter (NS=21) !Sync symbols (3 @ Costas 7x7)
parameter (NN=NS+ND) !Total channel symbols (79)
diff --git a/lib/ft8/ft8_testmsg.f90 b/lib/ft8/ft8_testmsg.f90 index aac3ad93..2a1bf8f9 100644 --- a/lib/ft8/ft8_testmsg.f90 +++ b/lib/ft8/ft8_testmsg.f90 @@ -1,145 +1,51 @@ - parameter (MAXTEST=75,NTEST=68) - character*40 testmsg(MAXTEST) - character*40 testmsgchk(MAXTEST) - ! Test msgs should include the extremes for the different types - ! See pfx.f90 - ! Type 1 P & A - ! Type 1 1A & E5 - data testmsg(1:NTEST)/ & - "CQ WB9XYZ EN34", & - "CQ DX WB9XYZ EN34", & - "QRZ WB9XYZ EN34", & - "KA1ABC WB9XYZ EN34", & - "KA1ABC WB9XYZ RO", & - "KA1ABC WB9XYZ -21", & - "KA1ABC WB9XYZ R-19", & - "KA1ABC WB9XYZ RRR", & - "KA1ABC WB9XYZ 73", & - "KA1ABC WB9XYZ", & - "CQ 000 WB9XYZ EN34", & - "CQ 999 WB9XYZ EN34", & - "CQ EU WB9XYZ EN34", & - "CQ WY WB9XYZ EN34", & - "1A/KA1ABC WB9XYZ", & - "E5/KA1ABC WB9XYZ", & - "KA1ABC 1A/WB9XYZ", & - "KA1ABC E5/WB9XYZ", & - "KA1ABC/P WB9XYZ", & - "KA1ABC/A WB9XYZ", & - "KA1ABC WB9XYZ/P", & - "KA1ABC WB9XYZ/A", & - "CQ KA1ABC/P", & - "CQ WB9XYZ/A", & - "QRZ KA1ABC/P", & - "QRZ WB9XYZ/A", & - "DE KA1ABC/P", & - "DE WB9XYZ/A", & - "CQ 1A/KA1ABC", & - "CQ E5/KA1ABC", & - "DE 1A/KA1ABC", & - "DE E5/KA1ABC", & - "QRZ 1A/KA1ABC", & - "QRZ E5/KA1ABC", & - "CQ WB9XYZ/1A", & - "CQ WB9XYZ/E5", & - "QRZ WB9XYZ/1A", & - "QRZ WB9XYZ/E5", & - "DE WB9XYZ/1A", & - "DE WB9XYZ/E5", & - "CQ A000/KA1ABC FM07", & - "CQ ZZZZ/KA1ABC FM07", & - "QRZ W4/KA1ABC FM07", & - "DE W4/KA1ABC FM07", & - "CQ W4/KA1ABC -22", & - "DE W4/KA1ABC -22", & - "QRZ W4/KA1ABC -22", & - "CQ W4/KA1ABC R-22", & - "DE W4/KA1ABC R-22", & - "QRZ W4/KA1ABC R-22", & - "DE W4/KA1ABC 73", & - "CQ KA1ABC FM07", & - "QRZ KA1ABC FM07", & - "DE KA1ABC/VE6 FM07", & - "CQ KA1ABC/VE6 -22", & - "DE KA1ABC/VE6 -22", & - "QRZ KA1ABC/VE6 -22", & - "CQ KA1ABC/VE6 R-22", & - "DE KA1ABC/VE6 R-22", & - "QRZ KA1ABC/VE6 R-22", & - "DE KA1ABC 73", & - "HELLO WORLD", & - "ZL4/KA1ABC 73", & - "KA1ABC XL/WB9XYZ", & - "KA1ABC WB9XYZ/W4", & - "DE KA1ABC/QRP 2W", & - "KA1ABC/1 WB9XYZ/1", & - "123456789ABCDEFGH"/ - data testmsgchk(1:NTEST)/ & - "CQ WB9XYZ EN34", & - "CQ DX WB9XYZ EN34", & - "QRZ WB9XYZ EN34", & - "KA1ABC WB9XYZ EN34", & - "KA1ABC WB9XYZ RO", & - "KA1ABC WB9XYZ -21", & - "KA1ABC WB9XYZ R-19", & - "KA1ABC WB9XYZ RRR", & - "KA1ABC WB9XYZ 73", & - "KA1ABC WB9XYZ", & - "CQ 000 WB9XYZ EN34", & - "CQ 999 WB9XYZ EN34", & - "CQ EU WB9XYZ EN34", & - "CQ WY WB9XYZ EN34", & - "1A/KA1ABC WB9XYZ", & - "E5/KA1ABC WB9XYZ", & - "KA1ABC 1A/WB9XYZ", & - "KA1ABC E5/WB9XYZ", & - "KA1ABC/P WB9XYZ", & - "KA1ABC/A WB9XYZ", & - "KA1ABC WB9XYZ/P", & - "KA1ABC WB9XYZ/A", & - "CQ KA1ABC/P", & - "CQ WB9XYZ/A", & - "QRZ KA1ABC/P", & - "QRZ WB9XYZ/A", & - "DE KA1ABC/P", & - "DE WB9XYZ/A", & - "CQ 1A/KA1ABC", & - "CQ E5/KA1ABC", & - "DE 1A/KA1ABC", & - "DE E5/KA1ABC", & - "QRZ 1A/KA1ABC", & - "QRZ E5/KA1ABC", & - "CQ WB9XYZ/1A", & - "CQ WB9XYZ/E5", & - "QRZ WB9XYZ/1A", & - "QRZ WB9XYZ/E5", & - "DE WB9XYZ/1A", & - "DE WB9XYZ/E5", & - "CQ A000/KA1ABC FM07", & - "CQ ZZZZ/KA1ABC FM07", & - "QRZ W4/KA1ABC FM07", & - "DE W4/KA1ABC FM07", & - "CQ W4/KA1ABC -22", & - "DE W4/KA1ABC -22", & - "QRZ W4/KA1ABC -22", & - "CQ W4/KA1ABC R-22", & - "DE W4/KA1ABC R-22", & - "QRZ W4/KA1ABC R-22", & - "DE W4/KA1ABC 73", & - "CQ KA1ABC FM07", & - "QRZ KA1ABC FM07", & - "DE KA1ABC/VE6 FM07", & - "CQ KA1ABC/VE6 -22", & - "DE KA1ABC/VE6 -22", & - "QRZ KA1ABC/VE6 -22", & - "CQ KA1ABC/VE6 R-22", & - "DE KA1ABC/VE6 R-22", & - "QRZ KA1ABC/VE6 R-22", & - "DE KA1ABC 73", & - "HELLO WORLD", & - "ZL4/KA1ABC 73", & - "KA1ABC XL/WB9", & - "KA1ABC WB9XYZ", & - "DE KA1ABC/QRP", & - "KA1ABC/1 WB9X", & - "123456789ABCD"/ + parameter (MAXTEST=75,NTEST=48) + character*37 testmsg(MAXTEST) + data testmsg(1:NTEST)/ & + "CQ K1ABC FN42", & + "K1ABC W9XYZ EN37", & + "W9XYZ K1ABC -11", & + "K1ABC W9XYZ R-09", & + "W9XYZ K1ABC RRR", & + "K1ABC W9XYZ 73", & + "K1ABC W9XYZ RR73", & + "CQ KH1/KH7Z", & + "K1ABC RR73; W9XYZ <KH1/KH7Z> -08", & + "CQ FD K1ABC FN42", & + "K1ABC W9XYZ 6A WI", & + "W9XYZ K1ABC R 2B EMA", & + "CQ TEST K1ABC/R FN42", & + "K1ABC/R W9XYZ EN37", & + "W9XYZ K1ABC/R R FN42", & + "K1ABC/R W9XYZ RR73", & + "CQ TEST K1ABC FN42", & + "K1ABC W9XYZ 579 WI", & + "W9XYZ K1ABC R 589 MA", & + "K1ABC KA0DEF 559 MO", & + "TU; KA0DEF K1ABC R 569 MA", & + "KA1ABC G3AAA 529 0013", & + "TU; G3AAA K1ABC R 559 MA", & + "CQ G4ABC/P IO91", & + "G4ABC/P PA9XYZ JO22", & + "PA9XYZ 590003 IO91NP", & + "G4ABC/P R 570007 JO22DB", & + "PA9XYZ G4ABC/P RR73", & + "CQ PJ4/K1ABC", & + "PJ4/K1ABC <W9XYZ>", & + "W9XYZ <PJ4/K1ABC> -11", & + "<PJ4/K1ABC> W9XYZ R-09", & + "<W9XYZ> PJ4/K1ABC RRR", & + "PJ4/K1ABC <W9XYZ> 73", & + "CQ W9XYZ EN37", & + "<W9XYZ> YW18FIFA", & + "<YW18FIFA> W9XYZ -11", & + "W9XYZ <YW18FIFA> R-09", & + "YW18FIFA <W9XYZ> RRR", & + "<W9XYZ> YW18FIFA 73", & + "TNX BOB 73 GL", & + "CQ YW18FIFA", & + "<YW18FIFA> KA1ABC", & + "KA1ABC <YW18FIFA> -11", & + "<YW18FIFA> KA1ABC R-17", & + "<KA1ABC> YW18FIFA RR73", & + "<YW18FIFA> KA1ABC 73", & + "123456789ABCDEF012"/ diff --git a/lib/ft8/ft8apset.f90 b/lib/ft8/ft8apset.f90 index ca5e5a6d..15eddd05 100644 --- a/lib/ft8/ft8apset.f90 +++ b/lib/ft8/ft8apset.f90 @@ -1,31 +1,43 @@ -subroutine ft8apset(mycall12,mygrid6,hiscall12,hisgrid6,bcontest,apsym,iaptype) - parameter(NAPM=4,KK=87) - character*12 mycall12,hiscall12 - character*22 msg,msgsent - character*6 mycall,hiscall - character*6 mygrid6,hisgrid6 - character*4 hisgrid - logical bcontest - integer apsym(KK) - integer*1 msgbits(KK) - integer itone(KK) - - mycall=mycall12(1:6) - hiscall=hiscall12(1:6) - hisgrid=hisgrid6(1:4) - if(len_trim(hiscall).eq.0) then - iaptype=1 - hiscall="K9AN" - else - iaptype=2 +subroutine ft8apset(mycall12,hiscall12,apsym) + use packjt77 + character*77 c77 + character*37 msg + character*12 mycall12,hiscall12,hiscall + integer apsym(58) + logical nohiscall + + if(len(trim(mycall12)).eq.0) then + apsym=0 + apsym(1)=99 + apsym(30)=99 + return endif - hisgrid=hisgrid6(1:4) -! if(len_trim(hisgrid).eq.0) hisgrid="EN50" - if(index(hisgrid," ").eq.0) hisgrid="EN50" - msg=mycall//' '//hiscall//' '//hisgrid - i3bit=0 ! ### TEMPORARY ??? ### - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - apsym=2*msgbits-1 - + + nohiscall=.false. + hiscall=hiscall12 + if(len(trim(hiscall)).eq.0) then + hiscall="K9ABC" + nohiscall=.true. + endif + +! Encode a dummy standard message: i3=1, 28 1 28 1 1 15 +! + msg=trim(mycall12)//' '//trim(hiscall)//' RRR' + call pack77(msg,i3,n3,c77) + if(i3.ne.1) then + apsym=0 + apsym(1)=99 + apsym(30)=99 + return + endif + + read(c77,'(58i1)',err=1) apsym(1:58) + apsym=2*apsym-1 + if(nohiscall) apsym(30)=99 + return + +1 apsym=0 + apsym(1)=99 + apsym(30)=99 return end subroutine ft8apset diff --git a/lib/ft8/ft8b.f90 b/lib/ft8/ft8b.f90 index 7d345316..5db48341 100644 --- a/lib/ft8/ft8b.f90 +++ b/lib/ft8/ft8b.f90 @@ -1,50 +1,56 @@ -subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & - napwid,lsubtract,nagain,iaptype,mycall12,mygrid6,hiscall12,bcontest, & +subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & + napwid,lsubtract,nagain,ncontest,iaptype,mycall12,hiscall12, & sync0,f1,xdt,xbase,apsym,nharderrors,dmin,nbadcrc,ipass,iera,msg37,xsnr) use crc use timer_module, only: timer + use packjt77 include 'ft8_params.f90' parameter(NP2=2812) character*37 msg37 - character message*22,msgsent*22 - character*12 mycall12,hiscall12 - character*6 mycall6,mygrid6,hiscall6,c1,c2 - character*87 cbits - logical bcontest + character*12 mycall12,hiscall12,hiscall12_0 + character*77 c77 + character*13 c13 real a(5) - real s1(0:7,ND),s2(0:7,NN),s1sort(8*ND) - real ps(0:7),psl(0:7) - real bmeta(3*ND),bmetb(3*ND),bmetap(3*ND) - real llr(3*ND),llra(3*ND),llr0(3*ND),llr1(3*ND),llrap(3*ND) !Soft symbols + real s8(0:7,NN) + real s2(0:511),s2l(0:511) + real bmeta(174),bmetb(174),bmetc(174) + real llra(174),llrb(174),llrc(174),llrd(174) !Soft symbols real dd0(15*12000) - integer*1 decoded(KK),decoded0(KK),apmask(3*ND),cw(3*ND) - integer*1 msgbits(KK) - integer apsym(KK) - integer mcq(28),mde(28),mrrr(16),m73(16),mrr73(16) + integer*1 message77(77),apmask(174),cw(174) + integer apsym(58) + integer mcq(29),mcqru(29),mcqfd(29),mcqtest(29) + integer mrrr(19),m73(19),mrr73(19) integer itone(NN) - integer indxs1(8*ND) integer icos7(0:6),ip(1) integer nappasses(0:5) !Number of decoding passes to use for each QSO state integer naptypes(0:5,4) ! (nQSOProgress, decoding pass) maximum of 4 passes for now - integer*1, target:: i1hiscall(12) - complex cd0(3200) + integer ncontest,ncontest0 + logical one(0:511,0:8) + integer graymap(0:7) + complex cd0(0:3199) complex ctwk(32) complex csymb(32) - logical first,newdat,lsubtract,lapon,lapcqonly,nagain - equivalence (s1,s1sort) - data icos7/2,5,6,0,4,1,3/ - data mcq/1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,1,1,0,0,1/ - data mrrr/0,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1/ - data m73/0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0/ - data mde/1,1,1,1,1,1,1,1,0,1,1,0,0,1,0,0,0,0,0,1,1,1,0,1,0,0,0,1/ - data mrr73/0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1/ + complex cs(0:7,NN) + logical first,newdat,lsubtract,lapon,lapcqonly,nagain,unpk77_success + data icos7/3,1,4,0,6,5,2/ ! Flipped w.r.t. original FT8 sync array + data mcq/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0/ + data mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/ + data mcqfd/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0/ + data mcqtest/0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0/ + data mrrr/0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,1/ + data m73/0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,0,0,0,1/ + data mrr73/0,1,1,1,1,1,1,0,0,1,1,1,0,1,0,1,0,0,1/ data first/.true./ - save nappasses,naptypes + data graymap/0,1,3,2,5,6,4,7/ + save nappasses,naptypes,ncontest0,one,hiscall12_0 - if(first) then + + if(first.or.(ncontest.ne.ncontest0)) then mcq=2*mcq-1 - mde=2*mde-1 + mcqfd=2*mcqfd-1 + mcqru=2*mcqru-1 + mcqtest=2*mcqtest-1 mrrr=2*mrrr-1 m73=2*m73-1 mrr73=2*mrr73-1 @@ -57,25 +63,39 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & ! iaptype !------------------------ -! 1 CQ ??? ??? -! 2 MyCall ??? ??? -! 3 MyCall DxCall ??? -! 4 MyCall DxCall RRR -! 5 MyCall DxCall 73 -! 6 MyCall DxCall RR73 -! 7 ??? DxCall ??? - - naptypes(0,1:4)=(/1,2,0,0/) - naptypes(1,1:4)=(/2,3,0,0/) - naptypes(2,1:4)=(/2,3,0,0/) - naptypes(3,1:4)=(/3,4,5,6/) - naptypes(4,1:4)=(/3,4,5,6/) - naptypes(5,1:4)=(/3,1,2,0/) +! 1 CQ ??? ??? (29+3=32 ap bits) +! 2 MyCall ??? ??? (29+3=32 ap bits) +! 3 MyCall DxCall ??? (58+3=61 ap bits) +! 4 MyCall DxCall RRR (77 ap bits) +! 5 MyCall DxCall 73 (77 ap bits) +! 6 MyCall DxCall RR73 (77 ap bits) + + naptypes(0,1:4)=(/1,2,0,0/) ! Tx6 selected (CQ) + naptypes(1,1:4)=(/2,3,0,0/) ! Tx1 + naptypes(2,1:4)=(/2,3,0,0/) ! Tx2 + naptypes(3,1:4)=(/3,4,5,6/) ! Tx3 + naptypes(4,1:4)=(/3,4,5,6/) ! Tx4 + naptypes(5,1:4)=(/3,1,2,0/) ! Tx5 + + one=.false. + do i=0,511 + do j=0,8 + if(iand(i,2**j).ne.0) one(i,j)=.true. + enddo + enddo first=.false. + ncontest0=ncontest + endif + + if(hiscall12.ne.hiscall12_0) then + c13=hiscall12//' ' + call save_hash_call(c13,n10,n12,n22) + hiscall12_0=hiscall12 endif max_iterations=30 nharderrors=-1 + nbadcrc=1 ! this is used upstream to flag good decodes. fs2=12000.0/NDOWN dt2=1.0/fs2 twopi=8.0*atan(1.0) @@ -108,7 +128,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & ctwk(i)=cmplx(cos(phi),sin(phi)) phi=mod(phi+dphi,twopi) enddo - call sync8d(cd0,i0,ctwk,1,sync) + call sync8d(cd0,i0,ctwk,1,sync) if( sync .gt. smax ) then smax=sync delfbest=delf @@ -119,16 +139,15 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & call twkfreq1(cd0,NP2,fs2,a,cd0) xdt=xdt2 f1=f1+delfbest !Improved estimate of DF + call sync8d(cd0,i0,ctwk,0,sync) - call sync8d(cd0,i0,ctwk,2,sync) - - j=0 do k=1,NN i1=ibest+(k-1)*32 csymb=cmplx(0.0,0.0) - if( i1.ge.1 .and. i1+31 .le. NP2 ) csymb=cd0(i1:i1+31) + if( i1.ge.0 .and. i1+31 .le. NP2-1 ) csymb=cd0(i1:i1+31) call four2a(csymb,32,1,-1,1) - s2(0:7,k)=abs(csymb(1:8))/1e3 + cs(0:7,k)=csymb(1:8)/1e3 + s8(0:7,k)=abs(csymb(1:8)) enddo ! sync quality check @@ -136,11 +155,11 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & is2=0 is3=0 do k=1,7 - ip=maxloc(s2(:,k)) + ip=maxloc(s8(:,k)) if(icos7(k-1).eq.(ip(1)-1)) is1=is1+1 - ip=maxloc(s2(:,k+36)) + ip=maxloc(s8(:,k+36)) if(icos7(k-1).eq.(ip(1)-1)) is2=is2+1 - ip=maxloc(s2(:,k+72)) + ip=maxloc(s8(:,k+72)) if(icos7(k-1).eq.(ip(1)-1)) is3=is3+1 enddo ! hard sync sum - max is 21 @@ -150,292 +169,262 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, & return endif - j=0 - do k=1,NN - if(k.le.7) cycle - if(k.ge.37 .and. k.le.43) cycle - if(k.gt.72) cycle - j=j+1 - s1(0:7,j)=s2(0:7,k) - enddo - - call indexx(s1sort,8*ND,indxs1) - xmeds1=s1sort(indxs1(nint(0.5*8*ND))) - s1=s1/xmeds1 - - do j=1,ND - i4=3*j-2 - i2=3*j-1 - i1=3*j -! Max amplitude - ps=s1(0:7,j) - 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)) - bmeta(i4)=r4 - bmeta(i2)=r2 - bmeta(i1)=r1 - bmetap(i4)=r4 - bmetap(i2)=r2 - bmetap(i1)=r1 -! Max log metric - psl=log(ps) - r1=max(psl(1),psl(3),psl(5),psl(7))-max(psl(0),psl(2),psl(4),psl(6)) - r2=max(psl(2),psl(3),psl(6),psl(7))-max(psl(0),psl(1),psl(4),psl(5)) - r4=max(psl(4),psl(5),psl(6),psl(7))-max(psl(0),psl(1),psl(2),psl(3)) - bmetb(i4)=r4 - bmetb(i2)=r2 - bmetb(i1)=r1 - -! Metric for Cauchy noise -! r1=log(ps(1)**3+ps(3)**3+ps(5)**3+ps(7)**3)- & -! log(ps(0)**3+ps(2)**3+ps(4)**3+ps(6)**3) -! r2=log(ps(2)**3+ps(3)**3+ps(6)**3+ps(7)**3)- & -! log(ps(0)**3+ps(1)**3+ps(4)**3+ps(5)**3) -! r4=log(ps(4)**3+ps(5)**3+ps(6)**3+ps(7)**3)- & -! log(ps(0)**3+ps(1)**3+ps(2)**3+ps(3)**3) -! Metric for AWGN, no fading -! bscale=2.5 -! b0=bessi0(bscale*ps(0)) -! b1=bessi0(bscale*ps(1)) -! b2=bessi0(bscale*ps(2)) -! b3=bessi0(bscale*ps(3)) -! b4=bessi0(bscale*ps(4)) -! b5=bessi0(bscale*ps(5)) -! b6=bessi0(bscale*ps(6)) -! b7=bessi0(bscale*ps(7)) -! r1=log(b1+b3+b5+b7)-log(b0+b2+b4+b6) -! r2=log(b2+b3+b6+b7)-log(b0+b1+b4+b5) -! r4=log(b4+b5+b6+b7)-log(b0+b1+b2+b3) - - if(nQSOProgress .eq. 0 .or. nQSOProgress .eq. 5) then -! When bits 88:115 are set as ap bits, bit 115 lives in symbol 39 along -! with no-ap bits 116 and 117. Take care of metrics for bits 116 and 117. - if(j.eq.39) then ! take care of bits that live in symbol 39 - if(apsym(28).lt.0) then - bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1)) - bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2)) - else - bmetap(i2)=max(ps(6),ps(7))-max(ps(4),ps(5)) - bmetap(i1)=max(ps(5),ps(7))-max(ps(4),ps(6)) - endif - endif - endif - -! When bits 116:143 are set as ap bits, bit 115 lives in symbol 39 along -! with ap bits 116 and 117. Take care of metric for bit 115. -! if(j.eq.39) then ! take care of bit 115 -! iii=2*(apsym(29)+1)/2 + (apsym(30)+1)/2 ! known values of bits 116 & 117 -! if(iii.eq.0) bmetap(i4)=ps(4)-ps(0) -! if(iii.eq.1) bmetap(i4)=ps(5)-ps(1) -! if(iii.eq.2) bmetap(i4)=ps(6)-ps(2) -! if(iii.eq.3) bmetap(i4)=ps(7)-ps(3) -! endif - -! bit 144 lives in symbol 48 and will be 1 if it is set as an ap bit. -! take care of metrics for bits 142 and 143 - if(j.eq.48) then ! bit 144 is always 1 - bmetap(i4)=max(ps(5),ps(7))-max(ps(1),ps(3)) - bmetap(i2)=max(ps(3),ps(7))-max(ps(1),ps(5)) - endif - -! bit 154 lives in symbol 52 and will be 0 if it is set as an ap bit -! take care of metrics for bits 155 and 156 - if(j.eq.52) then ! bit 154 will be 0 if it is set as an ap bit. - bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1)) - bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2)) - endif - + do nsym=1,3 + nt=2**(3*nsym) + do ihalf=1,2 + do k=1,29,nsym + if(ihalf.eq.1) ks=k+7 + if(ihalf.eq.2) ks=k+43 + amax=-1.0 + do i=0,nt-1 + i1=i/64 + i2=iand(i,63)/8 + i3=iand(i,7) + if(nsym.eq.1) then + s2(i)=abs(cs(graymap(i3),ks)) + elseif(nsym.eq.2) then + s2(i)=abs(cs(graymap(i2),ks)+cs(graymap(i3),ks+1)) + elseif(nsym.eq.3) then + s2(i)=abs(cs(graymap(i1),ks)+cs(graymap(i2),ks+1)+cs(graymap(i3),ks+2)) + else + print*,"Error - nsym must be 1, 2, or 3." + endif + enddo + s2l(0:nt-1)=log(s2(0:nt-1)+1e-32) + i32=1+(k-1)*3+(ihalf-1)*87 + if(nsym.eq.1) ibmax=2 + if(nsym.eq.2) ibmax=5 + if(nsym.eq.3) ibmax=8 + do ib=0,ibmax + bm=maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)) - & + maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib)) + if(i32+ib .gt.174) cycle + if(nsym.eq.1) then + bmeta(i32+ib)=bm + elseif(nsym.eq.2) then + bmetb(i32+ib)=bm + elseif(nsym.eq.3) then + bmetc(i32+ib)=bm + endif + enddo + enddo + enddo enddo - - call normalizebmet(bmeta,3*ND) - call normalizebmet(bmetb,3*ND) - call normalizebmet(bmetap,3*ND) + call normalizebmet(bmeta,174) + call normalizebmet(bmetb,174) + call normalizebmet(bmetc,174) scalefac=2.83 - llr0=scalefac*bmeta - llr1=scalefac*bmetb - llra=scalefac*bmetap ! llr's for use with ap - apmag=scalefac*(maxval(abs(bmetap))*1.01) + llra=scalefac*bmeta + llrb=scalefac*bmetb + llrc=scalefac*bmetc + + apmag=maxval(abs(llra))*1.01 ! pass # !------------------------------ -! 1 regular decoding -! 2 erase 24 -! 3 erase 48 -! 4 ap pass 1 +! 1 regular decoding, nsym=1 +! 2 regular decoding, nsym=2 +! 3 regular decoding, nsym=3 +! 4 ap pass 1, nsym=1 (for now?) ! 5 ap pass 2 ! 6 ap pass 3 -! 7 ap pass 4, etc. +! 7 ap pass 4 - if(lapon) then + if(lapon.or.ncontest.eq.6) then !Hounds always use AP if(.not.lapcqonly) then - npasses=4+nappasses(nQSOProgress) + npasses=3+nappasses(nQSOProgress) else - npasses=5 + npasses=4 endif else - npasses=4 + npasses=3 endif do ipass=1,npasses - - llr=llr0 - if(ipass.eq.2) llr=llr1 - if(ipass.eq.3) llr(1:24)=0. - if(ipass.eq.4) llr(1:48)=0. - if(ipass.le.4) then + llrd=llra + if(ipass.eq.2) llrd=llrb + if(ipass.eq.3) llrd=llrc + if(ipass.le.3) then apmask=0 - llrap=llr iaptype=0 endif - - if(ipass .gt. 4) then + + if(ipass .gt. 3) then + llrd=llra if(.not.lapcqonly) then - iaptype=naptypes(nQSOProgress,ipass-4) + iaptype=naptypes(nQSOProgress,ipass-3) else iaptype=1 endif - if(iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle - if(iaptype.eq.1 .or. iaptype.eq.2 ) then ! AP,???,??? + +! ncontest=0 : NONE +! 1 : NA_VHF +! 2 : EU_VHF +! 3 : FIELD DAY +! 4 : RTTY +! 5 : FOX +! 6 : HOUND +! +! Conditions that cause us to bail out of AP decoding + if(ncontest.le.4 .and. iaptype.ge.3 .and. (abs(f1-nfqso).gt.napwid .and. abs(f1-nftx).gt.napwid) ) cycle + if(ncontest.eq.5) cycle ! No AP for Foxes + if(ncontest.eq.6.and.f1.gt.950.0) cycle ! Hounds use AP only for signals below 950 Hz + if(iaptype.ge.2 .and. apsym(1).gt.1) cycle ! No, or nonstandard, mycall + if(iaptype.ge.3 .and. apsym(30).gt.1) cycle ! No, or nonstandard, dxcall + + if(iaptype.eq.1) then ! CQ or CQ RU or CQ TEST or CQ FD apmask=0 - apmask(88:115)=1 ! first 28 bits are AP - apmask(144)=1 ! not free text - llrap=llr - if(iaptype.eq.1) llrap(88:115)=apmag*mcq - if(iaptype.eq.2) llrap(88:115)=apmag*apsym(1:28) - llrap(116:117)=llra(116:117) - llrap(142:143)=llra(142:143) - llrap(144)=-apmag + apmask(1:29)=1 + if(ncontest.eq.0) llrd(1:29)=apmag*mcq(1:29) + if(ncontest.eq.1) llrd(1:29)=apmag*mcqtest(1:29) + if(ncontest.eq.2) llrd(1:29)=apmag*mcqtest(1:29) + if(ncontest.eq.3) llrd(1:29)=apmag*mcqfd(1:29) + if(ncontest.eq.4) llrd(1:29)=apmag*mcqru(1:29) + if(ncontest.eq.6) llrd(1:29)=apmag*mcq(1:29) + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) endif - if(iaptype.eq.3) then ! mycall, dxcall, ??? + + if(iaptype.eq.2) then ! MyCall,???,??? apmask=0 - apmask(88:115)=1 ! mycall - apmask(116:143)=1 ! hiscall - apmask(144)=1 ! not free text - llrap=llr - llrap(88:143)=apmag*apsym(1:56) - llrap(144)=-apmag + if(ncontest.eq.0.or.ncontest.eq.1) then + apmask(1:29)=1 + llrd(1:29)=apmag*apsym(1:29) + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) + else if(ncontest.eq.2) then + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(72:74)=1 + llrd(72)=apmag*(-1) + llrd(73)=apmag*(+1) + llrd(74)=apmag*(-1) + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.3) then + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.4) then + apmask(2:29)=1 + llrd(2:29)=apmag*apsym(1:28) + apmask(75:77)=1 + llrd(75)=apmag*(-1) + llrd(76:77)=apmag*(+1) + else if(ncontest.eq.6) then ! ??? RR73; MyCall <???> ??? + apmask(29:56)=1 + llrd(29:56)=apmag*apsym(1:28) + apmask(72:77)=1 + llrd(72:73)=apmag*(-1) + llrd(74)=apmag*(+1) + llrd(75:77)=apmag*(-1) + endif endif - if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then + + if(iaptype.eq.3) then ! MyCall,DxCall,??? apmask=0 - apmask(88:115)=1 ! mycall - apmask(116:143)=1 ! hiscall - apmask(144:159)=1 ! RRR or 73 or RR73 - llrap=llr - llrap(88:143)=apmag*apsym(1:56) - if(iaptype.eq.4) llrap(144:159)=apmag*mrrr - if(iaptype.eq.5) llrap(144:159)=apmag*m73 - if(iaptype.eq.6) llrap(144:159)=apmag*mrr73 + if(ncontest.eq.0.or.ncontest.eq.1.or.ncontest.eq.2.or.ncontest.eq.6) then + apmask(1:58)=1 + llrd(1:58)=apmag*apsym + apmask(75:77)=1 + llrd(75:76)=apmag*(-1) + llrd(77)=apmag*(+1) + else if(ncontest.eq.3) then ! Field Day + apmask(1:56)=1 + llrd(1:28)=apmag*apsym(1:28) + llrd(29:56)=apmag*apsym(30:57) + apmask(72:74)=1 + apmask(75:77)=1 + llrd(75:77)=apmag*(-1) + else if(ncontest.eq.4) then ! RTTY RU + apmask(2:57)=1 + llrd(2:29)=apmag*apsym(1:28) + llrd(30:57)=apmag*apsym(30:57) + apmask(75:77)=1 + llrd(75)=apmag*(-1) + llrd(76:77)=apmag*(+1) + endif endif - if(iaptype.eq.7) then ! ???, dxcall, ??? + + if(iaptype.eq.5.and.ncontest.eq.6) cycle !Hound + if(iaptype.eq.4 .or. iaptype.eq.5 .or. iaptype.eq.6) then apmask=0 - apmask(116:143)=1 ! hiscall - apmask(144)=1 ! not free text - llrap=llr - llrap(115)=llra(115) - llrap(116:143)=apmag*apsym(29:56) - llrap(144)=-apmag + if(ncontest.le.4 .or. (ncontest.eq.6.and.iaptype.eq.6)) then + apmask(1:77)=1 ! mycall, hiscall, RRR|73|RR73 + llrd(1:58)=apmag*apsym + if(iaptype.eq.4) llrd(59:77)=apmag*mrrr + if(iaptype.eq.5) llrd(59:77)=apmag*m73 + if(iaptype.eq.6) llrd(59:77)=apmag*mrr73 + else if(ncontest.eq.6.and.iaptype.eq.4) then ! Hound listens for MyCall RR73;... + apmask(1:28)=1 + llrd(1:28)=apmag*apsym(1:28) + apmask(72:77)=1 + llrd(72:73)=apmag*(-1) + llrd(74)=apmag*(1) + llrd(75:77)=apmag*(-1) + endif endif endif cw=0 - call timer('bpd174 ',0) - call bpdecode174(llrap,apmask,max_iterations,decoded,cw,nharderrors, & + call timer('bpd174_91 ',0) + call bpdecode174_91(llrd,apmask,max_iterations,message77,cw,nharderrors, & niterations) - call timer('bpd174 ',1) + call timer('bpd174_91 ',1) dmin=0.0 if(ndepth.eq.3 .and. nharderrors.lt.0) then ndeep=3 if(abs(nfqso-f1).le.napwid .or. abs(nftx-f1).le.napwid) then - if((ipass.eq.3 .or. ipass.eq.4) .and. .not.nagain) then - ndeep=3 - else - ndeep=4 - endif + ndeep=4 endif if(nagain) ndeep=5 - call timer('osd174 ',0) - call osd174(llrap,apmask,ndeep,decoded,cw,nharderrors,dmin) - call timer('osd174 ',1) + call timer('osd174_91 ',0) + call osd174_91(llrd,apmask,ndeep,message77,cw,nharderrors,dmin) + call timer('osd174_91 ',1) endif - nbadcrc=1 - message=' ' - xsnr=-99.0 + + msg37=' ' + if(nharderrors.lt.0 .or. nharderrors.gt.36) cycle if(count(cw.eq.0).eq.174) cycle !Reject the all-zero codeword - if(nharderrors.ge.0 .and. nharderrors+dmin.lt.60.0 .and. & - .not.(sync.lt.2.0 .and. nharderrors.gt.35) .and. & - .not.(ipass.gt.2 .and. nharderrors.gt.39) .and. & - .not.(ipass.eq.4 .and. nharderrors.gt.30) & - ) then - call chkcrc12a(decoded,nbadcrc) - else - nharderrors=-1 - cycle + write(c77,'(77i1)') message77 + read(c77(72:74),'(b3)') n3 + read(c77(75:77),'(b3)') i3 + if(i3.gt.4 .or. (i3.eq.0.and.n3.gt.5)) then + cycle endif - i3bit=4*decoded(73) + 2*decoded(74) + decoded(75) - iFreeText=decoded(57) - if(nbadcrc.eq.0) then - decoded0=decoded - if(i3bit.eq.1) decoded(57:)=0 - call extractmessage174(decoded,message,ncrcflag) - decoded=decoded0 -! This needs fixing for messages with i3bit=1: - call genft8(message,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - if(lsubtract) call subtractft8(dd0,itone,f1,xdt2) - xsig=0.0 - xnoi=0.0 - do i=1,79 - xsig=xsig+s2(itone(i),i)**2 - ios=mod(itone(i)+4,7) - xnoi=xnoi+s2(ios,i)**2 - enddo - xsnr=0.001 - if(xnoi.gt.0 .and. xnoi.lt.xsig) xsnr=xsig/xnoi-1.0 - xsnr=10.0*log10(xsnr)-27.0 - xsnr2=db(xsig/xbase - 1.0) - 32.0 - if(.not.nagain) xsnr=xsnr2 - if(xsnr .lt. -24.0) xsnr=-24.0 - - if(i3bit.eq.1) then - do i=1,12 - i1hiscall(i)=ichar(hiscall12(i:i)) - enddo - icrc10=crc10(c_loc(i1hiscall),12) - write(cbits,1001) decoded -1001 format(87i1) - read(cbits,1002) ncrc10,nrpt -1002 format(56x,b10,b6) - irpt=nrpt-30 - i1=index(message,' ') - i2=index(message(i1+1:),' ') + i1 - c1=message(1:i1)//' ' - c2=message(i1+1:i2)//' ' - - if(ncrc10.eq.icrc10) msg37=c1//' RR73; '//c2//' <'// & - trim(hiscall12)//'> ' - if(ncrc10.ne.icrc10) msg37=c1//' RR73; '//c2//' <...> ' - -! msg37=c1//' RR73; '//c2//' <...> ' - write(msg37(35:37),1010) irpt -1010 format(i3.2) - if(msg37(35:35).ne.'-') msg37(35:35)='+' - - iz=len(trim(msg37)) - do iter=1,10 !Collapse multiple blanks - ib2=index(msg37(1:iz),' ') - if(ib2.lt.1) exit - msg37=msg37(1:ib2)//msg37(ib2+2:) - iz=iz-1 - enddo - else - msg37=message//' ' - endif - - return + call unpack77(c77,msg37,unpk77_success) + if(.not.unpk77_success) then + cycle + endif + nbadcrc=0 ! If we get this far: valid codeword, valid (i3,n3), nonquirky message. + call get_tones_from_77bits(message77,itone) + if(lsubtract) call subtractft8(dd0,itone,f1,xdt) + xsig=0.0 + xnoi=0.0 + do i=1,79 + xsig=xsig+s8(itone(i),i)**2 + ios=mod(itone(i)+4,7) + xnoi=xnoi+s8(ios,i)**2 + enddo + xsnr=0.001 + xsnr2=0.001 + arg=xsig/xnoi-1.0 + if(arg.gt.0.1) xsnr=arg + arg=xsig/xbase/2.6e6-1.0 + if(arg.gt.0.1) xsnr2=arg + xsnr=10.0*log10(xsnr)-27.0 + xsnr2=10.0*log10(xsnr2)-27.0 + if(.not.nagain) then + xsnr=xsnr2 endif + if(xsnr .lt. -24.0) xsnr=-24.0 + + return enddo - return end subroutine ft8b @@ -477,4 +466,3 @@ function bessi0(x) endif return end function bessi0 - diff --git a/lib/ft8/ft8code.f90 b/lib/ft8/ft8code.f90 index d273562e..cbafd34b 100644 --- a/lib/ft8/ft8code.f90 +++ b/lib/ft8/ft8code.f90 @@ -1,34 +1,25 @@ program ft8code -! Provides examples of message packing, LDPC(144,87) encoding, bit and +! Provides examples of message packing, LDPC(174,91) encoding, bit and ! symbol ordering, and other details of the FT8 protocol. - use packjt - use crc + use packjt77 include 'ft8_params.f90' !Set various constants include 'ft8_testmsg.f90' parameter (NWAVE=NN*NSPS) - - character*40 msg,msgchk - character*37 msg37 - character*6 c1,c2 + + character*37 msg,msgsent character*9 comment - character*22 msgsent,message - character*6 mygrid6 - character bad*1,msgtype*10 - character*87 cbits - logical bcontest + character bad*1,msgtype*18 integer itone(NN) - integer dgen(12) - integer*1 msgbits(KK),decoded(KK),decoded0(KK) - data mygrid6/'EM48 '/ + integer*1 msgbits(77) ! Get command-line argument(s) nargs=iargc() if(nargs.ne.1 .and. nargs.ne.3) then print* print*,'Program ft8code: Provides examples of message packing, ', & - 'LDPC(174,87) encoding,' + 'LDPC(174,91) encoding,' print*,'bit and symbol ordering, and other details of the FT8 protocol.' print* print*,'Usage: ft8code [-c grid] "message" # Results for specified message' @@ -36,99 +27,57 @@ program ft8code go to 999 endif - bcontest=.false. call getarg(1,msg) !Message to be transmitted if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-t') then - testmsg(NTEST+1)='KA1ABC RR73; WB9XYZ <KH1/KH7Z> -11' - nmsg=NTEST+1 - else if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-c') then - bcontest=.true. - call getarg(2,mygrid6) - call getarg(3,msg) - msgchk=msg - nmsg=1 + nmsg=NTEST else - msgchk=msg - call fmtmsg(msgchk,iz) !To upper case; collapse multiple blanks + call fmtmsg(msg,iz) !To upper case; collapse multiple blanks nmsg=1 endif write(*,1010) -1010 format(" Message Decoded Err? Type"/76("-")) +1010 format(4x,'Message',31x,'Decoded',29x,'Err i3.n3'/100('-')) do imsg=1,nmsg if(nmsg.gt.1) msg=testmsg(imsg) - call fmtmsg(msg,iz) !To upper case, collapse multiple blanks - msgchk=msg ! Generate msgsent, msgbits, and itone - if(index(msg,';').le.0) then - call packmsg(msg(1:22),dgen,itype,bcontest) - msgtype="" - if(itype.eq.1) msgtype="Std Msg" - if(itype.eq.2) msgtype="Type 1 pfx" - if(itype.eq.3) msgtype="Type 1 sfx" - if(itype.eq.4) msgtype="Type 2 pfx" - if(itype.eq.5) msgtype="Type 2 sfx" - if(itype.eq.6) msgtype="Free text" - i3bit=0 - call genft8(msg(1:22),mygrid6,bcontest,i3bit,msgsent,msgbits,itone) + i3=-1 + n3=-1 + call genft8(msg,i3,n3,msgsent,msgbits,itone) + msgtype="" + if(i3.eq.0) then + if(n3.eq.0) msgtype="Free text" + if(n3.eq.1) msgtype="DXpedition mode" + if(n3.eq.2) msgtype="EU VHF Contest" + if(n3.eq.3) msgtype="ARRL Field Day" + if(n3.eq.4) msgtype="ARRL Field Day" + if(n3.eq.5) msgtype="Telemetry" + if(n3.ge.6) msgtype="Undefined type" + endif + if(i3.eq.1) msgtype="Standard msg" + if(i3.eq.2) msgtype="EU VHF Contest" + if(i3.eq.3) msgtype="ARRL RTTY Roundup" + if(i3.eq.4) msgtype="Nonstandard calls" + if(i3.ge.5) msgtype="Undefined msg type" + if(i3.ge.1) n3=-1 + bad=" " + comment=' ' + if(msg.ne.msgsent) bad="*" + if(n3.ge.0) then + write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype,comment +1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9) else - call foxgen_wrap(msg,msgbits,itone) - i3bit=1 + write(*,1022) imsg,msg,msgsent,bad,i3,msgtype,comment +1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9) endif - decoded=msgbits - i3bit=4*decoded(73) + 2*decoded(74) + decoded(75) - iFreeText=decoded(57) - decoded0=decoded - if(i3bit.eq.1) decoded(57:)=0 - call extractmessage174(decoded,message,ncrcflag) - decoded=decoded0 - - if(i3bit.eq.0) then - if(bcontest) call fix_contest_msg(mygrid6,message) - bad=" " - comment=' ' - if(itype.ne.6 .and. message.ne.msgchk) bad="*" - if(itype.eq.6 .and. message(1:13).ne.msgchk(1:13)) bad="*" - if(itype.eq.6 .and. len(trim(msgchk)).gt.13) comment='truncated' - write(*,1020) imsg,msgchk,message,bad,i3bit,itype,msgtype,comment -1020 format(i2,'.',1x,a22,1x,a22,1x,a1,2i2,1x,a10,1x,a9) - else - write(cbits,1001) decoded -1001 format(87i1) - read(cbits,1002) nrpt -1002 format(66x,b6) - irpt=nrpt-30 - i1=index(message,' ') - i2=index(message(i1+1:),' ') + i1 - c1=message(1:i1)//' ' - c2=message(i1+1:i2)//' ' - msg37=c1//' RR73; '//c2//' <...> ' - write(msg37(35:37),1003) irpt -1003 format(i3.2) - if(msg37(35:35).ne.'-') msg37(35:35)='+' - iz=len(trim(msg37)) - do iter=1,10 !Collapse multiple blanks into one - ib2=index(msg37(1:iz),' ') - if(ib2.lt.1) exit - msg37=msg37(1:ib2)//msg37(ib2+2:) - iz=iz-1 - enddo - - write(*,1021) imsg,msgchk,msg37 -1021 format(i2,'.',1x,a40,1x,a37) - endif - enddo if(nmsg.eq.1) then - write(*,1030) msgbits(1:56) -1030 format(/'Call1: ',28i1,' Call2: ',28i1) - write(*,1032) msgbits(57:72),msgbits(73:75),msgbits(76:87) -1032 format('Grid: ',16i1,' 3Bit: ',3i1,' CRC12: ',12i1) + write(*,1030) msgbits +1030 format(/'Message bits: ',/77i1) write(*,1034) itone -1034 format(/'Channel symbols:'/79i1) +1034 format(/'Channel symbols (tones):'/79i1) endif 999 end program ft8code diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90 index a8bd4965..bbec600d 100644 --- a/lib/ft8/ft8sim.f90 +++ b/lib/ft8/ft8sim.f90 @@ -1,36 +1,33 @@ program ft8sim -! Generate simulated data for a 15-second HF/6m mode using 8-FSK. +! Generate simulated "type 2" ft8 files ! Output is saved to a *.wav file. use wavhdr + use packjt77 include 'ft8_params.f90' !Set various constants parameter (NWAVE=NN*NSPS) type(hdr) h !Header for .wav file character arg*12,fname*17 - character msg40*40,msg*22,msgsent*22,msg0*22 - character*6 mygrid6 - logical bcontest + character msg37*37,msgsent37*37 + character c77*77 complex c0(0:NMAX-1) complex c(0:NMAX-1) real wave(NMAX) integer itone(NN) - integer*1 msgbits(KK) + integer*1 msgbits(77) integer*2 iwave(NMAX) !Generated full-length waveform - data mygrid6/'EM48 '/ ! Get command-line argument(s) nargs=iargc() if(nargs.ne.8) then - print*,'Usage: ft8sim "message" nsig|f0 DT fdop del width nfiles snr' - print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' - print*,' ft8sim "K1ABC W9XYZ EN37" 10 0.0 0.1 1.0 25 10 -18' - print*,' ft8sim "K1ABC W9XYZ EN37" 25 0.0 0.1 1.0 25 10 -18' + print*,'Usage: ft8sim "message" f0 DT fdop del width nfiles snr' + print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' + print*,' ft8sim "WA9XYZ/R KA1ABC/R FN42" 1500.0 0.0 0.1 1.0 0 10 -18' print*,' ft8sim "K1ABC RR73; W9XYZ <KH1/KH7Z> -11" 300 0 0 0 25 1 -10' - print*,'Make nfiles negative to invoke 72-bit contest mode.' go to 999 endif - call getarg(1,msg40) !Message to be transmitted + call getarg(1,msg37) !Message to be transmitted call getarg(2,arg) read(arg,*) f0 !Frequency (only used for single-signal) call getarg(3,arg) @@ -45,13 +42,13 @@ program ft8sim read(arg,*) nfiles !Number of files call getarg(8,arg) read(arg,*) snrdb !SNR_2500 + nsig=1 if(f0.lt.100.0) then nsig=f0 f0=1500 endif - bcontest=nfiles.lt.0 nfiles=abs(nfiles) twopi=8.0*atan(1.0) fs=12000.0 !Sample rate (Hz) @@ -65,97 +62,72 @@ program ft8sim if(snrdb.gt.90.0) sig=1.0 txt=NN*NSPS/12000.0 -! Source-encode, then get itone() - if(index(msg40,';').le.0) then - i3bit=0 - msg=msg40(1:22) - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - write(*,1000) f0,xdt,txt,snrdb,bw,msgsent + ! Source-encode, then get itone() + i3=-1 + n3=-1 + call pack77(msg37,i3,n3,c77) + call genft8(msg37,i3,n3,msgsent37,msgbits,itone) + + write(*,*) + write(*,'(a23,a37,3x,a7,i1,a1,i1)') 'New Style FT8 Message: ',msgsent37,'i3.n3: ',i3,'.',n3 + write(*,1000) f0,xdt,txt,snrdb,bw 1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & - ' BW:',f4.1,2x,a22) + ' BW:',f4.1) + write(*,*) + if(i3.eq.1) then + write(*,*) ' mycall hiscall hisgrid' + write(*,'(28i1,1x,i1,1x,28i1,1x,i1,1x,i1,1x,15i1,1x,3i1)') msgbits(1:77) else - call foxgen_wrap(msg40,msgbits,itone) - write(*,1001) f0,xdt,txt,snrdb,bw,msg40 -1001 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & - ' BW:',f4.1,2x,a40) + write(*,'(a14)') 'Message bits: ' + write(*,'(77i1)') msgbits endif + write(*,*) + write(*,'(a17)') 'Channel symbols: ' + write(*,'(79i1)') itone + write(*,*) - write(*,1030) msgbits(1:56) -1030 format(/'Call1: ',28i1,' Call2: ',28i1) - write(*,1032) msgbits(57:72),msgbits(73:75),msgbits(76:87) -1032 format('Grid: ',16i1,' 3Bit: ',3i1,' CRC12: ',12i1) - write(*,1034) itone -1034 format(/'Channel symbols:'/79i1/) + call sgran() msg0=msg do ifile=1,nfiles - c=0. - do isig=1,nsig - c0=0. - if(nsig.eq.2) then - if(index(msg,'R-').gt.0) f0=500 - i1=index(msg,' ') - msg(i1+4:i1+4)=char(ichar('A')+isig-1) - if(isig.eq.2) then - f0=f0+100 - endif - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - endif - if(nsig.eq.25) then - f0=(isig+2)*100.0 - else if(nsig.eq.50) then - msg=msg0 - f0=1000.0 + (isig-1)*60.0 - i1=index(msg,' ') - i2=index(msg(i1+1:),' ') + i1 - msg(i1+2:i1+2)=char(ichar('0')+mod(isig-1,10)) - msg(i1+3:i1+3)=char(ichar('A')+mod(isig-1,26)) - msg(i1+4:i1+4)=char(ichar('A')+mod(isig-1,26)) - msg(i1+5:i1+5)=char(ichar('A')+mod(isig-1,26)) - write(msg(i2+3:i2+4),'(i2.2)') isig-1 - if(ifile.ge.2 .and. isig.eq.ifile-1) then - write(msg(i2+1:i2+4),1002) -isig -1002 format('R',i3.2) - f0=600.0 + mod(isig-1,5)*60.0 - endif - call genft8(msg,mygrid6,bcontest,i3bit,msgsent,msgbits,itone) - endif - k=-1 + nint((xdt+0.5+0.01*gran())/dt) -! k=-1 + nint((xdt+0.5)/dt) - ia=k+1 - phi=0.0 - do j=1,NN !Generate complex waveform - dphi=twopi*(f0+itone(j)*baud)*dt - do i=1,NSPS - k=k+1 - phi=mod(phi+dphi,twopi) - if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi)) - enddo + k=nint((xdt+0.5)/dt) + ia=k + phi=0.0 + c0=0.0 + do j=1,NN !Generate complex waveform + dphi=twopi*(f0*dt+itone(j)/real(NSPS)) + do i=1,NSPS + if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi)) + k=k+1 + phi=mod(phi+dphi,twopi) enddo - if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,fs,delay,fspread) - c=c+sig*c0 enddo + if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,NWAVE,fs,delay,fspread) + c=sig*c0 + ib=k wave=real(c) peak=maxval(abs(wave(ia:ib))) - rms=sqrt(dot_product(wave(ia:ib),wave(ia:ib))/NWAVE) nslots=1 if(width.gt.0.0) call filt8(f0,nslots,width,wave) - + if(snrdb.lt.90) then do i=1,NMAX !Add gaussian noise at specified SNR xnoise=gran() -! wave(i)=wave(i) + xnoise -! if(i.ge.ia .and. i.le.ib) write(30,3001) i,wave(i)/peak -!3001 format(i8,f12.6) wave(i)=wave(i) + xnoise enddo endif - fac=32767.0 - rms=100.0 - if(snrdb.ge.90.0) iwave(1:NMAX)=nint(fac*wave) - if(snrdb.lt.90.0) iwave(1:NMAX)=nint(rms*wave) + gain=100.0 + if(snrdb.lt.90.0) then + wave=gain*wave + else + datpk=maxval(abs(wave)) + fac=32766.9/datpk + wave=fac*wave + endif + if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped." + iwave=nint(wave) h=default_header(12000,NMAX) write(fname,1102) ifile @@ -165,8 +137,5 @@ program ft8sim close(10) write(*,1110) ifile,xdt,f0,snrdb,fname 1110 format(i4,f7.2,f8.2,f7.1,2x,a17) - enddo - + enddo 999 end program ft8sim - - diff --git a/lib/ft8/genft8.f90 b/lib/ft8/genft8.f90 index dcb249d3..bf3116b8 100644 --- a/lib/ft8/genft8.f90 +++ b/lib/ft8/genft8.f90 @@ -1,44 +1,33 @@ -subroutine genft8(msg,mygrid,bcontest,i3bit,msgsent,msgbits,itone) +subroutine genft8(msg,i3,n3,msgsent,msgbits,itone) ! Encode an FT8 message, producing array itone(). - use crc - use packjt + use packjt77 include 'ft8_params.f90' - character*22 msg,msgsent - character*6 mygrid - character*87 cbits - logical bcontest,checksumok - integer*4 i4Msg6BitWords(12) !72-bit message as 6-bit words - integer*1 msgbits(KK),codeword(3*ND) - integer*1, target:: i1Msg8BitBytes(11) - integer itone(NN) + character msg*37,msgsent*37 + character*77 c77 + integer*1 msgbits(77),codeword(174) + integer itone(79) integer icos7(0:6) - data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern - - call packmsg(msg,i4Msg6BitWords,itype,bcontest) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,bcontest,mygrid) !Unpack to get msgsent - - write(cbits,1000) i4Msg6BitWords,32*i3bit -1000 format(12b6.6,b8.8) - read(cbits,1001) i1Msg8BitBytes(1:10) -1001 format(10b8) - i1Msg8BitBytes(10)=iand(i1Msg8BitBytes(10),128+64+32) - i1Msg8BitBytes(11)=0 - icrc12=crc12(c_loc(i1Msg8BitBytes),11) - -! For reference, here's how to check the CRC -! i1Msg8BitBytes(10)=icrc12/256 -! i1Msg8BitBytes(11)=iand (icrc12,255) -! checksumok = crc12_check(c_loc (i1Msg8BitBytes), 11) -! if( checksumok ) write(*,*) 'Good checksum' - - write(cbits,1003) i4Msg6BitWords,i3bit,icrc12 -1003 format(12b6.6,b3.3,b12.12) - read(cbits,1004) msgbits -1004 format(87i1) - - call encode174(msgbits,codeword) !Encode the test message + integer graymap(0:7) + logical unpk77_success + data icos7/3,1,4,0,6,5,2/ !Costas 7x7 tone pattern + data graymap/0,1,3,2,5,6,4,7/ + + i3=-1 + n3=-1 + call pack77(msg,i3,n3,c77) + call unpack77(c77,msgsent,unpk77_success) + read(c77,'(77i1)',err=1) msgbits + if(unpk77_success) go to 2 +1 msgbits=0 + itone=0 + msgsent='*** bad message *** ' + go to 900 + +entry get_tones_from_77bits(msgbits,itone) + +2 call encode174_91(msgbits,codeword) !Encode the test message ! Message structure: S7 D29 S7 D29 S7 itone(1:7)=icos7 @@ -49,8 +38,9 @@ subroutine genft8(msg,mygrid,bcontest,i3bit,msgsent,msgbits,itone) i=3*j -2 k=k+1 if(j.eq.30) k=k+7 - itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2) + indx=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2) + itone(k)=graymap(indx) enddo - return +900 return end subroutine genft8 diff --git a/lib/ft8/genft8refsig.f90 b/lib/ft8/genft8refsig.f90 index 5bf4885c..cd1468c1 100644 --- a/lib/ft8/genft8refsig.f90 +++ b/lib/ft8/genft8refsig.f90 @@ -1,7 +1,8 @@ subroutine genft8refsig(itone,cref,f0) complex cref(79*1920) integer itone(79) - real*8 twopi,phi,dphi,dt,xnsps +! real*8 twopi,phi,dphi,dt,xnsps + real twopi,phi,dphi,dt,xnsps data twopi/0.d0/ save twopi if( twopi .lt. 0.1 ) twopi=8.d0*atan(1.d0) diff --git a/lib/ft8/ldpc_174_91_c_colorder.f90 b/lib/ft8/ldpc_174_91_c_colorder.f90 new file mode 100644 index 00000000..a83de09d --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_colorder.f90 @@ -0,0 +1,11 @@ +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, 43, 19, 20, 42, 21, 40, 30, 37, 22, 47, 61, 45, 44, 23, 41, 39, & + 49, 24, 46, 50, 48, 26, 31, 33, 51, 38, 52, 59, 55, 66, 57, 27, 60, 35, 54, 58, & + 25, 56, 62, 64, 67, 69, 63, 68, 70, 72, 65, 73, 75, 74, 71, 77, 78, 76, 79, 80, & + 53, 81, 83, 82, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, & +100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119, & +120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139, & +140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, & +160,161,162,163,164,165,166,167,168,169,170,171,172,173/ + diff --git a/lib/ft8/ldpc_174_91_c_generator.f90 b/lib/ft8/ldpc_174_91_c_generator.f90 new file mode 100644 index 00000000..675bae57 --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_generator.f90 @@ -0,0 +1,86 @@ +character*23 g(83) + +data g/ & + "8329ce11bf31eaf509f27fc", & + "761c264e25c259335493132", & + "dc265902fb277c6410a1bdc", & + "1b3f417858cd2dd33ec7f62", & + "09fda4fee04195fd034783a", & + "077cccc11b8873ed5c3d48a", & + "29b62afe3ca036f4fe1a9da", & + "6054faf5f35d96d3b0c8c3e", & + "e20798e4310eed27884ae90", & + "775c9c08e80e26ddae56318", & + "b0b811028c2bf997213487c", & + "18a0c9231fc60adf5c5ea32", & + "76471e8302a0721e01b12b8", & + "ffbccb80ca8341fafb47b2e", & + "66a72a158f9325a2bf67170", & + "c4243689fe85b1c51363a18", & + "0dff739414d1a1b34b1c270", & + "15b48830636c8b99894972e", & + "29a89c0d3de81d665489b0e", & + "4f126f37fa51cbe61bd6b94", & + "99c47239d0d97d3c84e0940", & + "1919b75119765621bb4f1e8", & + "09db12d731faee0b86df6b8", & + "488fc33df43fbdeea4eafb4", & + "827423ee40b675f756eb5fe", & + "abe197c484cb74757144a9a", & + "2b500e4bc0ec5a6d2bdbdd0", & + "c474aa53d70218761669360", & + "8eba1a13db3390bd6718cec", & + "753844673a27782cc42012e", & + "06ff83a145c37035a5c1268", & + "3b37417858cc2dd33ec3f62", & + "9a4a5a28ee17ca9c324842c", & + "bc29f465309c977e89610a4", & + "2663ae6ddf8b5ce2bb29488", & + "46f231efe457034c1814418", & + "3fb2ce85abe9b0c72e06fbe", & + "de87481f282c153971a0a2e", & + "fcd7ccf23c69fa99bba1412", & + "f0261447e9490ca8e474cec", & + "4410115818196f95cdd7012", & + "088fc31df4bfbde2a4eafb4", & + "b8fef1b6307729fb0a078c0", & + "5afea7acccb77bbc9d99a90", & + "49a7016ac653f65ecdc9076", & + "1944d085be4e7da8d6cc7d0", & + "251f62adc4032f0ee714002", & + "56471f8702a0721e00b12b8", & + "2b8e4923f2dd51e2d537fa0", & + "6b550a40a66f4755de95c26", & + "a18ad28d4e27fe92a4f6c84", & + "10c2e586388cb82a3d80758", & + "ef34a41817ee02133db2eb0", & + "7e9c0c54325a9c15836e000", & + "3693e572d1fde4cdf079e86", & + "bfb2cec5abe1b0c72e07fbe", & + "7ee18230c583cccc57d4b08", & + "a066cb2fedafc9f52664126", & + "bb23725abc47cc5f4cc4cd2", & + "ded9dba3bee40c59b5609b4", & + "d9a7016ac653e6decdc9036", & + "9ad46aed5f707f280ab5fc4", & + "e5921c77822587316d7d3c2", & + "4f14da8242a8b86dca73352", & + "8b8b507ad467d4441df770e", & + "22831c9cf1169467ad04b68", & + "213b838fe2ae54c38ee7180", & + "5d926b6dd71f085181a4e12", & + "66ab79d4b29ee6e69509e56", & + "958148682d748a38dd68baa", & + "b8ce020cf069c32a723ab14", & + "f4331d6d461607e95752746", & + "6da23ba424b9596133cf9c8", & + "a636bcbc7b30c5fbeae67fe", & + "5cb0d86a07df654a9089a20", & + "f11f106848780fc9ecdd80a", & + "1fbb5364fb8d2c9d730d5ba", & + "fcb86bc70a50c9d02a5d034", & + "a534433029eac15f322e34c", & + "c989d9c7c3d3b8c55d75130", & + "7bb38b2f0186d46643ae962", & + "2644ebadeb44b9467d1f42c", & + "608cc857594bfbb55d69600"/ diff --git a/lib/ft8/ldpc_174_91_c_parity.f90 b/lib/ft8/ldpc_174_91_c_parity.f90 new file mode 100644 index 00000000..6210ee26 --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_parity.f90 @@ -0,0 +1,269 @@ +data Mn/ & + 1, 24, 66, & + 2, 5, 70, & + 3, 31, 65, & + 4, 49, 58, & + 6, 60, 67, & + 7, 32, 75, & + 8, 48, 82, & + 9, 35, 41, & + 10, 39, 62, & + 11, 14, 61, & + 12, 71, 74, & + 13, 23, 78, & + 15, 16, 79, & + 17, 54, 63, & + 18, 50, 57, & + 19, 30, 47, & + 20, 64, 80, & + 21, 28, 69, & + 22, 25, 43, & + 26, 34, 72, & + 27, 36, 37, & + 29, 40, 44, & + 33, 52, 53, & + 38, 55, 83, & + 42, 51, 59, & + 45, 76, 81, & + 46, 68, 77, & + 56, 67, 73, & + 1, 4, 5, & + 2, 47, 51, & + 3, 46, 82, & + 6, 24, 76, & + 7, 9, 16, & + 8, 10, 78, & + 11, 35, 55, & + 12, 38, 64, & + 13, 22, 37, & + 14, 15, 58, & + 17, 50, 53, & + 18, 29, 56, & + 19, 26, 57, & + 20, 39, 77, & + 21, 36, 63, & + 23, 54, 74, & + 25, 69, 73, & + 27, 33, 65, & + 28, 44, 79, & + 30, 43, 52, & + 31, 45, 61, & + 32, 48, 71, & + 34, 60, 62, & + 40, 41, 70, & + 42, 66, 68, & + 49, 75, 83, & + 59, 72, 80, & + 36, 64, 81, & + 1, 65, 74, & + 2, 8, 81, & + 3, 26, 79, & + 4, 22, 72, & + 5, 38, 50, & + 6, 9, 52, & + 7, 18, 77, & + 10, 28, 55, & + 11, 56, 59, & + 12, 67, 68, & + 13, 29, 47, & + 14, 39, 54, & + 15, 60, 70, & + 16, 37, 66, & + 17, 25, 82, & + 19, 21, 71, & + 20, 30, 31, & + 23, 75, 80, & + 24, 69, 75, & + 27, 32, 62, & + 33, 59, 76, & + 34, 53, 61, & + 35, 46, 47, & + 40, 43, 83, & + 41, 42, 63, & + 20, 44, 48, & + 16, 45, 73, & + 42, 49, 57, & + 25, 51, 62, & + 33, 58, 78, & + 1, 44, 45, & + 2, 7, 61, & + 3, 6, 54, & + 4, 35, 48, & + 5, 13, 21, & + 8, 56, 79, & + 9, 64, 69, & + 10, 19, 66, & + 11, 36, 60, & + 12, 37, 58, & + 14, 32, 43, & + 15, 63, 80, & + 17, 28, 77, & + 18, 74, 83, & + 22, 53, 81, & + 23, 30, 34, & + 24, 31, 40, & + 26, 41, 76, & + 27, 57, 70, & + 29, 49, 65, & + 3, 38, 78, & + 5, 39, 82, & + 46, 50, 73, & + 51, 52, 74, & + 55, 71, 72, & + 44, 67, 72, & + 43, 68, 78, & + 1, 32, 59, & + 2, 6, 71, & + 4, 16, 54, & + 7, 65, 67, & + 8, 30, 42, & + 9, 22, 31, & + 10, 18, 76, & + 11, 23, 82, & + 12, 28, 61, & + 13, 52, 79, & + 14, 50, 51, & + 15, 81, 83, & + 17, 29, 60, & + 19, 33, 64, & + 20, 26, 73, & + 21, 34, 40, & + 24, 27, 77, & + 25, 55, 58, & + 35, 53, 66, & + 36, 48, 68, & + 37, 46, 75, & + 38, 45, 47, & + 39, 57, 69, & + 41, 56, 62, & + 20, 49, 53, & + 46, 52, 63, & + 45, 70, 75, & + 27, 35, 80, & + 1, 15, 30, & + 2, 68, 80, & + 3, 36, 51, & + 4, 28, 51, & + 5, 31, 56, & + 6, 20, 37, & + 7, 40, 82, & + 8, 60, 69, & + 9, 10, 49, & + 11, 44, 57, & + 12, 39, 59, & + 13, 24, 55, & + 14, 21, 65, & + 16, 71, 78, & + 17, 30, 76, & + 18, 25, 80, & + 19, 61, 83, & + 22, 38, 77, & + 23, 41, 50, & + 7, 26, 58, & + 29, 32, 81, & + 33, 40, 73, & + 18, 34, 48, & + 13, 42, 64, & + 5, 26, 43, & + 47, 69, 72, & + 54, 55, 70, & + 45, 62, 68, & + 10, 63, 67, & + 14, 66, 72, & + 22, 60, 74, & + 35, 39, 79, & + 1, 46, 64/ + +data Nm/ & + 1, 29, 57, 87, 114, 142, 174, & + 2, 30, 58, 88, 115, 143, 0, & + 3, 31, 59, 89, 107, 144, 0, & + 4, 29, 60, 90, 116, 145, 0, & + 2, 29, 61, 91, 108, 146, 166, & + 5, 32, 62, 89, 115, 147, 0, & + 6, 33, 63, 88, 117, 148, 161, & + 7, 34, 58, 92, 118, 149, 0, & + 8, 33, 62, 93, 119, 150, 0, & + 9, 34, 64, 94, 120, 150, 170, & + 10, 35, 65, 95, 121, 151, 0, & + 11, 36, 66, 96, 122, 152, 0, & + 12, 37, 67, 91, 123, 153, 165, & + 10, 38, 68, 97, 124, 154, 171, & + 13, 38, 69, 98, 125, 142, 0, & + 13, 33, 70, 83, 116, 155, 0, & + 14, 39, 71, 99, 126, 156, 0, & + 15, 40, 63, 100, 120, 157, 164, & + 16, 41, 72, 94, 127, 158, 0, & + 17, 42, 73, 82, 128, 138, 147, & + 18, 43, 72, 91, 129, 154, 0, & + 19, 37, 60, 101, 119, 159, 172, & + 12, 44, 74, 102, 121, 160, 0, & + 1, 32, 75, 103, 130, 153, 0, & + 19, 45, 71, 85, 131, 157, 0, & + 20, 41, 59, 104, 128, 161, 166, & + 21, 46, 76, 105, 130, 141, 0, & + 18, 47, 64, 99, 122, 145, 0, & + 22, 40, 67, 106, 126, 162, 0, & + 16, 48, 73, 102, 118, 142, 156, & + 3, 49, 73, 103, 119, 146, 0, & + 6, 50, 76, 97, 114, 162, 0, & + 23, 46, 77, 86, 127, 163, 0, & + 20, 51, 78, 102, 129, 164, 0, & + 8, 35, 79, 90, 132, 141, 173, & + 21, 43, 56, 95, 133, 144, 0, & + 21, 37, 70, 96, 134, 147, 0, & + 24, 36, 61, 107, 135, 159, 0, & + 9, 42, 68, 108, 136, 152, 173, & + 22, 52, 80, 103, 129, 148, 163, & + 8, 52, 81, 104, 137, 160, 0, & + 25, 53, 81, 84, 118, 165, 0, & + 19, 48, 80, 97, 113, 166, 0, & + 22, 47, 82, 87, 112, 151, 0, & + 26, 49, 83, 87, 135, 140, 169, & + 27, 31, 79, 109, 134, 139, 174, & + 16, 30, 67, 79, 135, 167, 0, & + 7, 50, 82, 90, 133, 164, 0, & + 4, 54, 84, 106, 138, 150, 0, & + 15, 39, 61, 109, 124, 160, 0, & + 25, 30, 85, 110, 124, 144, 145, & + 23, 48, 62, 110, 123, 139, 0, & + 23, 39, 78, 101, 132, 138, 0, & + 14, 44, 68, 89, 116, 168, 0, & + 24, 35, 64, 111, 131, 153, 168, & + 28, 40, 65, 92, 137, 146, 0, & + 15, 41, 84, 105, 136, 151, 0, & + 4, 38, 86, 96, 131, 161, 0, & + 25, 55, 65, 77, 114, 152, 0, & + 5, 51, 69, 95, 126, 149, 172, & + 10, 49, 78, 88, 122, 158, 0, & + 9, 51, 76, 85, 137, 169, 0, & + 14, 43, 81, 98, 139, 170, 0, & + 17, 36, 56, 93, 127, 165, 174, & + 3, 46, 57, 106, 117, 154, 0, & + 1, 53, 70, 94, 132, 171, 0, & + 5, 28, 66, 112, 117, 170, 0, & + 27, 53, 66, 113, 133, 143, 169, & + 18, 45, 75, 93, 136, 149, 167, & + 2, 52, 69, 105, 140, 168, 0, & + 11, 50, 72, 111, 115, 155, 0, & + 20, 55, 60, 111, 112, 167, 171, & + 28, 45, 83, 109, 128, 163, 0, & + 11, 44, 57, 100, 110, 172, 0, & + 6, 54, 74, 75, 134, 140, 0, & + 26, 32, 77, 104, 120, 156, 0, & + 27, 42, 63, 99, 130, 159, 0, & + 12, 34, 86, 107, 113, 155, 0, & + 13, 47, 59, 92, 123, 173, 0, & + 17, 55, 74, 98, 141, 143, 157, & + 26, 56, 58, 101, 125, 162, 0, & + 7, 31, 71, 108, 121, 148, 0, & + 24, 54, 80, 100, 125, 158, 0/ + +data nrw/ & +7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6,6, & +7,6,7,6,7,6,6,6,7,6,6,6,7,6,6,6,6, & +7,6,6,6,7,7,6,6,6,6,7,7,6,6,6,6,7, & +6,6,6,7,6,6,6,6,7,6,6,6,7,6,6,6,7, & +7,6,6,7,6,6,6,6,6,6,6,7,6,6,6/ + +ncw=3 diff --git a/lib/ft8/ldpc_174_91_c_reordered_parity.f90 b/lib/ft8/ldpc_174_91_c_reordered_parity.f90 new file mode 100644 index 00000000..2309ad8e --- /dev/null +++ b/lib/ft8/ldpc_174_91_c_reordered_parity.f90 @@ -0,0 +1,270 @@ +data Mn/ & + 16, 45, 73, & + 25, 51, 62, & + 33, 58, 78, & + 1, 44, 45, & + 2, 7, 61, & + 3, 6, 54, & + 4, 35, 48, & + 5, 13, 21, & + 8, 56, 79, & + 9, 64, 69, & + 10, 19, 66, & + 11, 36, 60, & + 12, 37, 58, & + 14, 32, 43, & + 15, 63, 80, & + 17, 28, 77, & + 18, 74, 83, & + 22, 53, 81, & + 23, 30, 34, & + 24, 31, 40, & + 26, 41, 76, & + 27, 57, 70, & + 29, 49, 65, & + 3, 38, 78, & + 5, 39, 82, & + 46, 50, 73, & + 51, 52, 74, & + 55, 71, 72, & + 44, 67, 72, & + 43, 68, 78, & + 1, 32, 59, & + 2, 6, 71, & + 4, 16, 54, & + 7, 65, 67, & + 8, 30, 42, & + 9, 22, 31, & + 10, 18, 76, & + 11, 23, 82, & + 12, 28, 61, & + 13, 52, 79, & + 14, 50, 51, & + 15, 81, 83, & + 17, 29, 60, & + 19, 33, 64, & + 20, 26, 73, & + 21, 34, 40, & + 24, 27, 77, & + 25, 55, 58, & + 35, 53, 66, & + 36, 48, 68, & + 37, 46, 75, & + 38, 45, 47, & + 39, 57, 69, & + 41, 56, 62, & + 20, 49, 53, & + 46, 52, 63, & + 45, 70, 75, & + 27, 35, 80, & + 1, 15, 30, & + 2, 68, 80, & + 3, 36, 51, & + 4, 28, 51, & + 5, 31, 56, & + 6, 20, 37, & + 7, 40, 82, & + 8, 60, 69, & + 9, 10, 49, & + 11, 44, 57, & + 12, 39, 59, & + 13, 24, 55, & + 14, 21, 65, & + 16, 71, 78, & + 17, 30, 76, & + 18, 25, 80, & + 19, 61, 83, & + 22, 38, 77, & + 23, 41, 50, & + 7, 26, 58, & + 29, 32, 81, & + 33, 40, 73, & + 18, 34, 48, & + 13, 42, 64, & + 5, 26, 43, & + 47, 69, 72, & + 54, 55, 70, & + 45, 62, 68, & + 10, 63, 67, & + 14, 66, 72, & + 22, 60, 74, & + 35, 39, 79, & + 1, 46, 64, & + 1, 24, 66, & + 2, 5, 70, & + 3, 31, 65, & + 4, 49, 58, & + 1, 4, 5, & + 6, 60, 67, & + 7, 32, 75, & + 8, 48, 82, & + 9, 35, 41, & + 10, 39, 62, & + 11, 14, 61, & + 12, 71, 74, & + 13, 23, 78, & + 11, 35, 55, & + 15, 16, 79, & + 7, 9, 16, & + 17, 54, 63, & + 18, 50, 57, & + 19, 30, 47, & + 20, 64, 80, & + 21, 28, 69, & + 22, 25, 43, & + 13, 22, 37, & + 2, 47, 51, & + 23, 54, 74, & + 26, 34, 72, & + 27, 36, 37, & + 21, 36, 63, & + 29, 40, 44, & + 19, 26, 57, & + 3, 46, 82, & + 14, 15, 58, & + 33, 52, 53, & + 30, 43, 52, & + 6, 9, 52, & + 27, 33, 65, & + 25, 69, 73, & + 38, 55, 83, & + 20, 39, 77, & + 18, 29, 56, & + 32, 48, 71, & + 42, 51, 59, & + 28, 44, 79, & + 34, 60, 62, & + 31, 45, 61, & + 46, 68, 77, & + 6, 24, 76, & + 8, 10, 78, & + 40, 41, 70, & + 17, 50, 53, & + 42, 66, 68, & + 4, 22, 72, & + 36, 64, 81, & + 13, 29, 47, & + 2, 8, 81, & + 56, 67, 73, & + 5, 38, 50, & + 12, 38, 64, & + 59, 72, 80, & + 3, 26, 79, & + 45, 76, 81, & + 1, 65, 74, & + 7, 18, 77, & + 11, 56, 59, & + 14, 39, 54, & + 16, 37, 66, & + 10, 28, 55, & + 15, 60, 70, & + 17, 25, 82, & + 20, 30, 31, & + 12, 67, 68, & + 23, 75, 80, & + 27, 32, 62, & + 24, 69, 75, & + 19, 21, 71, & + 34, 53, 61, & + 35, 46, 47, & + 33, 59, 76, & + 40, 43, 83, & + 41, 42, 63, & + 49, 75, 83, & + 20, 44, 48, & + 42, 49, 57/ + +data Nm/ & + 4, 31, 59, 91, 92, 96, 153, & + 5, 32, 60, 93, 115, 146, 0, & + 6, 24, 61, 94, 122, 151, 0, & + 7, 33, 62, 95, 96, 143, 0, & + 8, 25, 63, 83, 93, 96, 148, & + 6, 32, 64, 97, 126, 138, 0, & + 5, 34, 65, 78, 98, 107, 154, & + 9, 35, 66, 99, 139, 146, 0, & + 10, 36, 67, 100, 107, 126, 0, & + 11, 37, 67, 87, 101, 139, 158, & + 12, 38, 68, 102, 105, 155, 0, & + 13, 39, 69, 103, 149, 162, 0, & + 8, 40, 70, 82, 104, 114, 145, & + 14, 41, 71, 88, 102, 123, 156, & + 15, 42, 59, 106, 123, 159, 0, & + 1, 33, 72, 106, 107, 157, 0, & + 16, 43, 73, 108, 141, 160, 0, & + 17, 37, 74, 81, 109, 131, 154, & + 11, 44, 75, 110, 121, 166, 0, & + 45, 55, 64, 111, 130, 161, 173, & + 8, 46, 71, 112, 119, 166, 0, & + 18, 36, 76, 89, 113, 114, 143, & + 19, 38, 77, 104, 116, 163, 0, & + 20, 47, 70, 92, 138, 165, 0, & + 2, 48, 74, 113, 128, 160, 0, & + 21, 45, 78, 83, 117, 121, 151, & + 22, 47, 58, 118, 127, 164, 0, & + 16, 39, 62, 112, 134, 158, 0, & + 23, 43, 79, 120, 131, 145, 0, & + 19, 35, 59, 73, 110, 125, 161, & + 20, 36, 63, 94, 136, 161, 0, & + 14, 31, 79, 98, 132, 164, 0, & + 3, 44, 80, 124, 127, 169, 0, & + 19, 46, 81, 117, 135, 167, 0, & + 7, 49, 58, 90, 100, 105, 168, & + 12, 50, 61, 118, 119, 144, 0, & + 13, 51, 64, 114, 118, 157, 0, & + 24, 52, 76, 129, 148, 149, 0, & + 25, 53, 69, 90, 101, 130, 156, & + 20, 46, 65, 80, 120, 140, 170, & + 21, 54, 77, 100, 140, 171, 0, & + 35, 82, 133, 142, 171, 174, 0, & + 14, 30, 83, 113, 125, 170, 0, & + 4, 29, 68, 120, 134, 173, 0, & + 1, 4, 52, 57, 86, 136, 152, & + 26, 51, 56, 91, 122, 137, 168, & + 52, 84, 110, 115, 145, 168, 0, & + 7, 50, 81, 99, 132, 173, 0, & + 23, 55, 67, 95, 172, 174, 0, & + 26, 41, 77, 109, 141, 148, 0, & + 2, 27, 41, 61, 62, 115, 133, & + 27, 40, 56, 124, 125, 126, 0, & + 18, 49, 55, 124, 141, 167, 0, & + 6, 33, 85, 108, 116, 156, 0, & + 28, 48, 70, 85, 105, 129, 158, & + 9, 54, 63, 131, 147, 155, 0, & + 22, 53, 68, 109, 121, 174, 0, & + 3, 13, 48, 78, 95, 123, 0, & + 31, 69, 133, 150, 155, 169, 0, & + 12, 43, 66, 89, 97, 135, 159, & + 5, 39, 75, 102, 136, 167, 0, & + 2, 54, 86, 101, 135, 164, 0, & + 15, 56, 87, 108, 119, 171, 0, & + 10, 44, 82, 91, 111, 144, 149, & + 23, 34, 71, 94, 127, 153, 0, & + 11, 49, 88, 92, 142, 157, 0, & + 29, 34, 87, 97, 147, 162, 0, & + 30, 50, 60, 86, 137, 142, 162, & + 10, 53, 66, 84, 112, 128, 165, & + 22, 57, 85, 93, 140, 159, 0, & + 28, 32, 72, 103, 132, 166, 0, & + 28, 29, 84, 88, 117, 143, 150, & + 1, 26, 45, 80, 128, 147, 0, & + 17, 27, 89, 103, 116, 153, 0, & + 51, 57, 98, 163, 165, 172, 0, & + 21, 37, 73, 138, 152, 169, 0, & + 16, 47, 76, 130, 137, 154, 0, & + 3, 24, 30, 72, 104, 139, 0, & + 9, 40, 90, 106, 134, 151, 0, & + 15, 58, 60, 74, 111, 150, 163, & + 18, 42, 79, 144, 146, 152, 0, & + 25, 38, 65, 99, 122, 160, 0, & + 17, 42, 75, 129, 170, 172, 0/ + +data nrw/ & +7,6,6,6,7,6,7,6,6,7,6,6,7,7,6,6, & +6,7,6,7,6,7,6,6,6,7,6,6,6,7,6,6, & +6,6,7,6,6,6,7,7,6,6,6,6,7,7,6,6, & +6,6,7,6,6,6,7,6,6,6,6,7,6,6,6,7, & +6,6,6,7,7,6,6,7,6,6,6,6,6,6,6,7, & +6,6,6/ + +ncw=3 diff --git a/lib/ft8/ldpcsim174.f90 b/lib/ft8/ldpcsim174.f90 deleted file mode 100644 index 08b181eb..00000000 --- a/lib/ft8/ldpcsim174.f90 +++ /dev/null @@ -1,234 +0,0 @@ -program ldpcsim174 -! End to end test of the (174,75)/crc12 encoder and decoder. -use crc -use packjt - -character*22 msg,msgsent,msgreceived -character*8 arg -character*6 grid -integer*1, allocatable :: codeword(:), decoded(:), message(:) -integer*1, target:: i1Msg8BitBytes(11) -integer*1 msgbits(87) -integer*1 apmask(174), cw(174) -integer*2 checksum -integer*4 i4Msg6BitWords(13) -integer colorder(174) -integer nerrtot(174),nerrdec(174),nmpcbad(87) -logical checksumok,fsk,bpsk -real*8, allocatable :: rxdata(:) -real, allocatable :: llr(:) - -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/ - -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 ndepth #trials s ' - print*,'eg: ldpcsim 10 2 1000 0.84' - print*,'belief propagation iterations: niter, ordered-statistics depth: ndepth' - 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,*) ndepth -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=174 -K=87 -! scale Eb/No for a (174,87) code -rate=real(K)/real(N) - -write(*,*) "rate: ",rate -write(*,*) "niter= ",max_iterations," s= ",s - -allocate ( codeword(N), decoded(K), message(K) ) -allocate ( rxdata(N), llr(N) ) - - msg="K1JT K9AN EN50" -! msg="G4WJS K9AN EN50" - call packmsg(msg,i4Msg6BitWords,itype,.false.) !Pack into 12 6-bit bytes - call unpackmsg(i4Msg6BitWords,msgsent,.false.,grid) !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' - -! K=87, For now: -! msgbits(1:72) JT message bits -! msgbits(73:75) 3 free message bits (set to 0) -! msgbits(76:87) CRC12 - 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 - msgbits(73:75)=0 ! the three extra message bits go here - i1=i1Msg8BitBytes(10) ! First 4 bits of crc12 are LSB of this byte - do ibit=1,4 - msgbits(75+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(79+ibit)=iand(1,ishft(i1,ibit-8)) - enddo - - write(*,*) 'message' - write(*,'(11(8i1,1x))') msgbits - - call encode174(msgbits,codeword) - call init_random_seed() -! call sgran() - - write(*,*) 'codeword' - write(*,'(22(8i1,1x))') codeword - -write(*,*) "Es/N0 SNR2500 ngood nundetected nbadcrc sigma" -do idb = 20,-10,-1 -!do idb = -3,-3,-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 - 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) - nap=0 ! number of AP bits - llr(colorder(174-87+1:174-87+nap)+1)=5*(2.0*msgbits(1:nap)-1.0) - apmask=0 - apmask(colorder(174-87+1:174-87+nap)+1)=1 - -! max_iterations is max number of belief propagation iterations - call bpdecode174(llr, apmask, max_iterations, decoded, cw, nharderrors,niterations) - if( ndepth .ge. 0 .and. nharderrors .lt. 0 ) call osd174(llr, apmask, ndepth, decoded, cw, nharderrors, dmin) -! If the decoder finds a valid codeword, nharderrors will be .ge. 0. - if( nharderrors .ge. 0 ) then - call extractmessage174(decoded,msgreceived,ncrcflag) - 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 - if( ncrcflag .eq. 1 ) then - if( nueflag .eq. 0 ) then - ngood=ngood+1 - if(nerr.ge.1) nerrdec(nerr)=nerrdec(nerr)+1 - else if( nueflag .eq. 1 ) then - nue=nue+1; - endif - endif - endif - enddo - baud=12000/1920 - snr2500=db+10.0*log10((baud/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,174 - write(23,'(i4,2x,i10,i10,f10.2)') i,nerrdec(i),nerrtot(i),real(nerrdec(i))/real(nerrtot(i)+1e-10) -enddo -close(23) -open(unit=25,file='nmpcbad.dat',status='unknown') -do i=1,87 - write(25,'(i4,2x,i10)') i,nmpcbad(i) -enddo -close(25) - -end program ldpcsim174 diff --git a/lib/ft8/osd174.f90 b/lib/ft8/osd174_91.f90 index 45d7faa4..958b0c9f 100644 --- a/lib/ft8/osd174.f90 +++ b/lib/ft8/osd174_91.f90 @@ -1,9 +1,8 @@ -subroutine osd174(llr,apmask,ndeep,decoded,cw,nhardmin,dmin) +subroutine osd174_91(llr,apmask,ndeep,message77,cw,nhardmin,dmin) ! -! An ordered-statistics decoder for the (174,87) code. +! An ordered-statistics decoder for the (174,91) code. ! -include "ldpc_174_87_params.f90" - +integer, parameter:: N=174, K=91, M=N-K integer*1 apmask(N),apmaskr(N) integer*1 gen(K,N) integer*1 genmrb(K,N),g2(N,K) @@ -12,8 +11,12 @@ integer*1 r2pat(N-K) integer indices(N),nxor(N) integer*1 cw(N),ce(N),c0(N),hdec(N) integer*1 decoded(K) +integer*1 message77(77) integer indx(N) real llr(N),rx(N),absrx(N) + +include "ldpc_174_91_c_generator.f90" + logical first,reset data first/.true./ save first,gen @@ -21,23 +24,24 @@ save first,gen if( first ) then ! fill the generator matrix gen=0 do i=1,M - do j=1,22 + do j=1,23 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 + ibmax=4 + if(j.eq.23) ibmax=3 + do jj=1, ibmax + irow=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(irow,K+i)=1 + enddo enddo enddo do irow=1,K - gen(irow,M+irow)=1 + gen(irow,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) +rx=llr +apmaskr=apmask ! Hard decisions on the received word. hdec=0 @@ -92,7 +96,7 @@ absrx=absrx(indices) rx=rx(indices) apmaskr=apmaskr(indices) -call mrbencode(m0,c0,g2,N,K) +call mrbencode91(m0,c0,g2,N,K) nxor=ieor(c0,hdec) nhardmin=sum(nxor) dmin=sum(nxor*absrx) @@ -155,7 +159,7 @@ do iorder=1,nord ntotal=ntotal+1 me=ieor(m0,mi) if(n1.eq.iflag) then - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) e2sub=ieor(ce(K+1:N),hdec(K+1:N)) e2=e2sub nd1Kpt=sum(e2sub(1:nt))+1 @@ -165,7 +169,7 @@ do iorder=1,nord nd1Kpt=sum(e2(1:nt))+2 endif if(nd1Kpt .le. ntheta) then - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) nxor=ieor(ce,hdec) if(n1.eq.iflag) then dd=d1+sum(e2sub*absrx(K+1:N)) @@ -184,7 +188,7 @@ do iorder=1,nord 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) + call nextpat91(misub,k,iorder,iflag) enddo enddo @@ -195,7 +199,7 @@ if(npre2.eq.1) then 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) + call boxit91(reset,mi(1:ntau),ntau,ntotal,i1,i2) enddo enddo @@ -208,7 +212,7 @@ if(npre2.eq.1) then iflag=K-nord+1 do while(iflag .ge.0) me=ieor(m0,misub) - call mrbencode(me,ce,g2,N,K) + call mrbencode91(me,ce,g2,N,K) e2sub=ieor(ce(K+1:N),hdec(K+1:N)) do i2=0,ntau ntotal2=ntotal2+1 @@ -216,7 +220,7 @@ if(npre2.eq.1) then if(i2.gt.0) ui(i2)=1 r2pat=ieor(e2sub,ui) 778 continue - call fetchit(reset,r2pat(1:ntau),ntau,in1,in2) + call fetchit91(reset,r2pat(1:ntau),ntau,in1,in2) if(in1.gt.0.and.in2.gt.0) then ncount2=ncount2+1 mi=misub @@ -224,7 +228,7 @@ if(npre2.eq.1) then 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) + call mrbencode91(me,ce,g2,N,K) nxor=ieor(ce,hdec) dd=sum(nxor*absrx) if( dd .lt. dmin ) then @@ -235,20 +239,23 @@ if(npre2.eq.1) then goto 778 endif enddo - call nextpat(misub,K,nord,iflag) + call nextpat91(misub,K,nord,iflag) enddo endif 998 continue -! Re-order the codeword to place message bits at the end. +! Re-order the codeword to [message bits][parity bits] format. cw(indices)=cw hdec(indices)=hdec -decoded=cw(M+1:N) -cw(colorder+1)=cw ! put the codeword back into received-word order +decoded=cw(1:K) +call chkcrc14a(decoded,nbadcrc) +message77=decoded(1:77) +if(nbadcrc.eq.1) nhardmin=-nhardmin + return -end subroutine osd174 +end subroutine osd174_91 -subroutine mrbencode(me,codeword,g2,N,K) +subroutine mrbencode91(me,codeword,g2,N,K) integer*1 me(K),codeword(N),g2(N,K) ! fast encoding for low-weight test patterns codeword=0 @@ -258,9 +265,9 @@ integer*1 me(K),codeword(N),g2(N,K) endif enddo return -end subroutine mrbencode +end subroutine mrbencode91 -subroutine nextpat(mi,k,iorder,iflag) +subroutine nextpat91(mi,k,iorder,iflag) integer*1 mi(k),ms(k) ! generate the next test error pattern ind=-1 @@ -287,11 +294,11 @@ subroutine nextpat(mi,k,iorder,iflag) endif enddo return -end subroutine nextpat +end subroutine nextpat91 -subroutine boxit(reset,e2,ntau,npindex,i1,i2) +subroutine boxit91(reset,e2,ntau,npindex,i1,i2) integer*1 e2(1:ntau) - integer indexes(4000,2),fp(0:525000),np(4000) + integer indexes(5000,2),fp(0:525000),np(5000) logical reset common/boxes/indexes,fp,np @@ -323,10 +330,10 @@ subroutine boxit(reset,e2,ntau,npindex,i1,i2) np(ip)=npindex endif return -end subroutine boxit +end subroutine boxit91 -subroutine fetchit(reset,e2,ntau,i1,i2) - integer indexes(4000,2),fp(0:525000),np(4000) +subroutine fetchit91(reset,e2,ntau,i1,i2) + integer indexes(5000,2),fp(0:525000),np(5000) integer lastpat integer*1 e2(ntau) logical reset @@ -361,5 +368,5 @@ subroutine fetchit(reset,e2,ntau,i1,i2) endif lastpat=ipat return -end subroutine fetchit +end subroutine fetchit91 diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90 index 30f6de17..3924f1ba 100644 --- a/lib/ft8/sync8.f90 +++ b/lib/ft8/sync8.f90 @@ -1,4 +1,5 @@ -subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
+subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, &
+ ncand,sbase)
include 'ft8_params.f90'
! Search over +/- 2.5s relative to 0.5s TX start time.
@@ -10,14 +11,14 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) real x(NFFT1)
real sync2d(NH1,-JZ:JZ)
real red(NH1)
- real candidate0(3,200)
- real candidate(3,200)
+ real candidate0(3,maxcand)
+ real candidate(3,maxcand)
real dd(NMAX)
integer jpeak(NH1)
integer indx(NH1)
integer ii(1)
integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
+ data icos7/3,1,4,0,6,5,2/ !Costas 7x7 tone pattern
equivalence (x,cx)
! Compute symbol spectra, stepping by NSTEP steps.
@@ -37,17 +38,14 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) savg=savg + s(1:NH1,j) !Average spectrum
enddo
call baseline(savg,nfa,nfb,sbase)
-! savg=savg/NHSYM
-! do i=1,NH1
-! write(51,3051) i*df,savg(i),db(savg(i))
-!3051 format(f10.3,e12.3,f12.3)
-! enddo
ia=max(1,nint(nfa/df))
ib=nint(nfb/df)
nssy=NSPS/NSTEP ! # steps per symbol
nfos=NFFT1/NSPS ! # frequency bin oversampling factor
jstrt=0.5/tstep
+ candidate0=0.
+ k=0
do i=ia,ib
do j=-JZ,+JZ
@@ -58,23 +56,22 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) t0b=0.
t0c=0.
do n=0,6
- k=j+jstrt+nssy*n
- if(k.ge.1.and.k.le.NHSYM) then
- ta=ta + s(i+nfos*icos7(n),k)
- t0a=t0a + sum(s(i:i+nfos*6:nfos,k))
+ m=j+jstrt+nssy*n
+ if(m.ge.1.and.m.le.NHSYM) then
+ ta=ta + s(i+nfos*icos7(n),m)
+ t0a=t0a + sum(s(i:i+nfos*6:nfos,m))
endif
- tb=tb + s(i+nfos*icos7(n),k+nssy*36)
- t0b=t0b + sum(s(i:i+nfos*6:nfos,k+nssy*36))
- if(k+nssy*72.le.NHSYM) then
- tc=tc + s(i+nfos*icos7(n),k+nssy*72)
- t0c=t0c + sum(s(i:i+nfos*6:nfos,k+nssy*72))
+ tb=tb + s(i+nfos*icos7(n),m+nssy*36)
+ t0b=t0b + sum(s(i:i+nfos*6:nfos,m+nssy*36))
+ if(m+nssy*72.le.NHSYM) then
+ tc=tc + s(i+nfos*icos7(n),m+nssy*72)
+ t0c=t0c + sum(s(i:i+nfos*6:nfos,m+nssy*72))
endif
enddo
t=ta+tb+tc
t0=t0a+t0b+t0c
t0=(t0-t)/6.0
sync_abc=t/t0
-
t=tb+tc
t0=t0b+t0c
t0=(t0-t)/6.0
@@ -89,21 +86,19 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) j0=ii(1)
jpeak(i)=j0
red(i)=sync2d(i,j0)
-! write(52,3052) i*df,red(i),db(red(i))
-!3052 format(3f12.3)
enddo
iz=ib-ia+1
call indexx(red(ia:ib),iz,indx)
ibase=indx(nint(0.40*iz)) - 1 + ia
+ if(ibase.lt.1) ibase=1
+ if(ibase.gt.nh1) ibase=nh1
base=red(ibase)
red=red/base
- candidate0=0.
- k=0
- do i=1,200
+ do i=1,min(maxcand,iz)
n=ia + indx(iz+1-i) - 1
- if(red(n).lt.syncmin) exit
- if(k.lt.200) k=k+1
+ if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.maxcand) exit
+ k=k+1
candidate0(1,k)=n*df
candidate0(2,k)=(jpeak(n)-1)*tstep
candidate0(3,k)=red(n)
@@ -121,9 +116,6 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) if(candidate0(3,i).lt.candidate0(3,j)) candidate0(3,i)=0.
endif
enddo
-! write(*,3001) i,candidate0(1,i-1),candidate0(1,i),candidate0(3,i-1), &
-! candidate0(3,i)
-!3001 format(i2,4f8.1)
endif
enddo
@@ -140,9 +132,8 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase) j=indx(i)
! if( candidate0(3,j) .ge. syncmin .and. candidate0(2,j).ge.-1.5 ) then
if( candidate0(3,j) .ge. syncmin ) then
+ candidate(2:3,k)=candidate0(2:3,j)
candidate(1,k)=abs(candidate0(1,j))
- candidate(2,k)=candidate0(2,j)
- candidate(3,k)=candidate0(3,j)
k=k+1
endif
enddo
diff --git a/lib/ft8/sync8d.f90 b/lib/ft8/sync8d.f90 index d0d1c63b..798f2831 100644 --- a/lib/ft8/sync8d.f90 +++ b/lib/ft8/sync8d.f90 @@ -3,14 +3,14 @@ subroutine sync8d(cd0,i0,ctwk,itwk,sync) ! Compute sync power for a complex, downsampled FT8 signal.
parameter(NP2=2812,NDOWN=60)
- complex cd0(3125)
+ complex cd0(0:3199)
complex csync(0:6,32)
complex csync2(32)
complex ctwk(32)
complex z1,z2,z3
logical first
integer icos7(0:6)
- data icos7/2,5,6,0,4,1,3/
+ data icos7/3,1,4,0,6,5,2/
data first/.true./
save first,twopi,fs2,dt2,taus,baud,csync
@@ -44,9 +44,9 @@ subroutine sync8d(cd0,i0,ctwk,itwk,sync) z1=0.
z2=0.
z3=0.
- if(i1.ge.1 .and. i1+31.le.NP2) z1=sum(cd0(i1:i1+31)*conjg(csync2))
- if(i2.ge.1 .and. i2+31.le.NP2) z2=sum(cd0(i2:i2+31)*conjg(csync2))
- if(i3.ge.1 .and. i3+31.le.NP2) z3=sum(cd0(i3:i3+31)*conjg(csync2))
+ if(i1.ge.0 .and. i1+31.le.NP2-1) z1=sum(cd0(i1:i1+31)*conjg(csync2))
+ if(i2.ge.0 .and. i2+31.le.NP2-1) z2=sum(cd0(i2:i2+31)*conjg(csync2))
+ if(i3.ge.0 .and. i3+31.le.NP2-1) z3=sum(cd0(i3:i3+31)*conjg(csync2))
sync = sync + p(z1) + p(z2) + p(z3)
enddo
diff --git a/lib/ft8/watterson.f90 b/lib/ft8/watterson.f90 index d047a26e..a1131d7b 100644 --- a/lib/ft8/watterson.f90 +++ b/lib/ft8/watterson.f90 @@ -1,5 +1,8 @@ -subroutine watterson(c,npts,fs,delay,fspread)
-
+subroutine watterson(c,npts,nsig,fs,delay,fspread)
+!
+! npts is the total length of the simulated data vector
+! nsig is the number of points that are occupied by signal
+!
complex c(0:npts-1)
complex c2(0:npts-1)
complex cs1(0:npts-1)
@@ -55,7 +58,7 @@ subroutine watterson(c,npts,fs,delay,fspread) ! write(61,3001) i/12000.0,c(i)
!3001 format(3f12.6)
enddo
- rms=sqrt(sq/npts)
+ rms=sqrt(sq/nsig)
c=c/rms
return
|
