From e8bb7e74bc9c2fb4a84c62345ea9e44a7ea6b49c Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Tue, 30 Jun 2020 13:29:32 -0500 Subject: [PATCH] Add routines for a (240,74) code. Hardwire decoder for wspr messages, for the time being. --- CMakeLists.txt | 5 +- lib/.fst240_decode.f90.swp | Bin 0 -> 45056 bytes lib/fst240/decode240_74.f90 | 154 ++++++++++ lib/fst240/encode240_74.f90 | 46 +++ lib/fst240/genfst240.f90 | 6 +- lib/fst240/ldpc_240_74_generator.f90 | 170 +++++++++++ lib/fst240/ldpc_240_74_parity.f90 | 423 +++++++++++++++++++++++++++ lib/fst240/ldpcsim240_74.f90 | 125 ++++++++ lib/fst240/osd240_74.f90 | 403 +++++++++++++++++++++++++ lib/fst240_decode.f90 | 16 +- 10 files changed, 1342 insertions(+), 6 deletions(-) create mode 100644 lib/.fst240_decode.f90.swp create mode 100644 lib/fst240/decode240_74.f90 create mode 100644 lib/fst240/encode240_74.f90 create mode 100644 lib/fst240/ldpc_240_74_generator.f90 create mode 100644 lib/fst240/ldpc_240_74_parity.f90 create mode 100644 lib/fst240/ldpcsim240_74.f90 create mode 100644 lib/fst240/osd240_74.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 20eb32034..87b8509ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -596,15 +596,18 @@ set (wsjt_FSRCS lib/wqencode.f90 lib/wspr_downsample.f90 lib/zplot9.f90 - lib/fst240/bpdecode240_101.f90 lib/fst240/decode240_101.f90 + lib/fst240/decode240_74.f90 lib/fst240/encode240_101.f90 + lib/fst240/encode240_74.f90 lib/fst240/fst240sim.f90 lib/fst240/gen_fst240wave.f90 lib/fst240/genfst240.f90 lib/fst240/get_fst240_bitmetrics.f90 lib/fst240/ldpcsim240_101.f90 + lib/fst240/ldpcsim240_74.f90 lib/fst240/osd240_101.f90 + lib/fst240/osd240_74.f90 lib/fst240/get_crc24.f90 ) diff --git a/lib/.fst240_decode.f90.swp b/lib/.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#ebWPX_~6n~%1dHpf2Vz6$19x7kbSbnVW#`DWhOWmQ|7!8i+ z*59g{l3h}Be#lzMR@GV^X;5LLqTJdabTX%yxOYT8nMshzT(hX*PFgZnNx5!Y9t!bn zPs*0U8!Snd+QiWz?yj~)T7TEuVh#Oa&PINQk>4LIc!jJ7%*Fn7=cmO+$AO?x8c@o{ zL2}&nx?5>LuI}=qiCS^3?r6z(wD$5dY5G%vqXhonRXy7b(eH<@94#j|-B1bC-O+)W zMW-+}P|!onAaIypM`CZsZ|cB5BrQ(<;@CI+*~0w^*MKrQWYiW2yIT(|GFr+BA~7G1R6; zf%=&bJ>S^BO?d&7Nxfg2#!~Owrt#GKwJD$4JxXD%yap5Fnj;(4!2y>lQe9%dXx@QY zqU>Vs{PWNEu9Y7fU_;<>Gaxjef?_pTNU*#}u*^uX+(?YMhoQnv*yOzbe$oCwXq9J{ zXH6EOqW$$(u`H6Gh&BJ^_h8l5NbI+B?*>Q@QL5E=o~gZ|WOHa?(<(C;^e-hWui@}&H`7SC&6W;ipTOwdqgo=EigopJx{g zv5-@{5m;hbgDFMkZaSz96(vf=Vq-NO2s#(63U)Z(K#|M#*C}c7S`q#KKfwoo0X|vy ze_m1g`6|5rUxAl`r-AdpKf~vL1^f*V-v4)i`1y;T|5t(h7J%68zYRPcoCW?Ce*Ycd zwO|{FU;mZh;oxWR{9gn&gB!tXz%#)ia31(Ry#E)$7r-mP9+2|@4*-z~ya^lw*MLKy z3PdJQ0NNhgmf6>=2WCAm>w#Gh%z9wf13yPSU^e9D|4fFS?+vbHH#v~t&t&L#K_4)a zp(E|R;?yBI3t%QgpUKdjtbHa!FXR_nS!qRYK(|bnp^L1: do bp and then call osd maxosd times with saved bp outputs +! norder : osd decoding depth +! + integer, parameter:: N=240, K=74, M=N-K + integer*1 cw(N),apmask(N) + integer*1 nxor(N),hdec(N) + integer*1 message74(74),m74(74) + integer nrw(M),ncw + integer Nm(5,M) + integer Mn(3,N) ! 3 checks per bit + integer synd(M) + real tov(3,N) + real toc(5,M) + real tanhtoc(5,M) + real zn(N),zsum(N),zsave(N,3) + real llr(N) + real Tmn + + include "ldpc_240_74_parity.f90" + + maxiterations=30 + nosd=0 + if(maxosd.gt.3) maxosd=3 + if(maxosd.eq.0) then ! osd with channel llrs + nosd=1 + zsave(:,1)=llr + elseif(maxosd.gt.0) then ! + nosd=maxosd + elseif(maxosd.lt.0) then ! just bp + nosd=0 + endif + + toc=0 + tov=0 + tanhtoc=0 +! initialize messages to checks + do j=1,M + do i=1,nrw(j) + toc(i,j)=llr((Nm(i,j))) + enddo + enddo + + ncnt=0 + nclast=0 + zsum=0.0 + do iter=0,maxiterations +! Update bit log likelihood ratios (tov=0 in iteration 0). + do i=1,N + if( apmask(i) .ne. 1 ) then + zn(i)=llr(i)+sum(tov(1:ncw,i)) + else + zn(i)=llr(i) + endif + enddo + zsum=zsum+zn + if(iter.gt.0 .and. iter.le.maxosd) then + zsave(:,iter)=zsum + endif + +! Check to see if we have a codeword (check before we do any iteration). + cw=0 + where( zn .gt. 0. ) cw=1 + ncheck=0 + do i=1,M + synd(i)=sum(cw(Nm(1:nrw(i),i))) + if( mod(synd(i),2) .ne. 0 ) ncheck=ncheck+1 + enddo + if( ncheck .eq. 0 ) then ! we have a codeword - if crc is good, return it + m74=0 + m74(1:74)=cw(1:74) + call get_crc24(m74,74,nbadcrc) + if(nbadcrc.eq.0) then + message74=cw(1:74) + hdec=0 + where(llr .ge. 0) hdec=1 + nxor=ieor(hdec,cw) + nharderror=sum(nxor) + dmin=sum(nxor*abs(llr)) + ntype=1 + return + endif + endif + + if( iter.gt.0 ) then ! this code block implements an early stopping criterion +! if( iter.gt.10000 ) then ! this code block implements an early stopping criterion + nd=ncheck-nclast + if( nd .lt. 0 ) then ! # of unsatisfied parity checks decreased + ncnt=0 ! reset counter + else + ncnt=ncnt+1 + endif +! write(*,*) iter,ncheck,nd,ncnt + if( ncnt .ge. 5 .and. iter .ge. 10 .and. ncheck .gt. 15) then + nharderror=-1 + exit + endif + endif + nclast=ncheck + +! Send messages from bits to check nodes + do j=1,M + do i=1,nrw(j) + ibj=Nm(i,j) + toc(i,j)=zn(ibj) + do kk=1,ncw ! subtract off what the bit had received from the check + if( Mn(kk,ibj) .eq. j ) then + toc(i,j)=toc(i,j)-tov(kk,ibj) + endif + enddo + enddo + enddo + +! send messages from check nodes to variable nodes + do i=1,M + tanhtoc(1:5,i)=tanh(-toc(1:5,i)/2) + enddo + + do j=1,N + do i=1,ncw + ichk=Mn(i,j) ! Mn(:,j) are the checks that include bit j + Tmn=product(tanhtoc(1:nrw(ichk),ichk),mask=Nm(1:nrw(ichk),ichk).ne.j) + call platanh(-Tmn,y) +! y=atanh(-Tmn) + tov(i,j)=2*y + enddo + enddo + + enddo ! bp iterations + + do i=1,nosd + zn=zsave(:,i) + call osd240_74(zn,Keff,apmask,norder,message74,cw,nharderror,dminosd) + if(nharderror.gt.0) then + hdec=0 + where(llr .ge. 0) hdec=1 + nxor=ieor(hdec,cw) + dmin=sum(nxor*abs(llr)) + ntype=2 + return + endif + enddo + + ntype=0 + nharderror=-1 + dminosd=0.0 + + return +end subroutine decode240_74 diff --git a/lib/fst240/encode240_74.f90 b/lib/fst240/encode240_74.f90 new file mode 100644 index 000000000..1d555d17f --- /dev/null +++ b/lib/fst240/encode240_74.f90 @@ -0,0 +1,46 @@ +subroutine encode240_74(message,codeword) + use, intrinsic :: iso_c_binding + use iso_c_binding, only: c_loc,c_size_t + use crc + + integer, parameter:: N=240, K=74, M=N-K + character*24 c24 + integer*1 codeword(N) + integer*1 gen(M,K) + integer*1 message(K) + integer*1 pchecks(M) + integer*4 ncrc24 + include "ldpc_240_74_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,19 + read(g(i)(j:j),"(Z1)") istr + ibmax=4 + if(j.eq.19) ibmax=2 + do jj=1, ibmax + icol=(j-1)*4+jj + if( btest(istr,4-jj) ) gen(i,icol)=1 + enddo + enddo + enddo + first=.false. + endif + + do i=1,M + nsum=0 + do j=1,K + nsum=nsum+message(j)*gen(i,j) + enddo + pchecks(i)=mod(nsum,2) + enddo + + codeword(1:K)=message + codeword(K+1:N)=pchecks + + return +end subroutine encode240_74 diff --git a/lib/fst240/genfst240.f90 b/lib/fst240/genfst240.f90 index f60dc8446..adb8d20ec 100644 --- a/lib/fst240/genfst240.f90 +++ b/lib/fst240/genfst240.f90 @@ -71,7 +71,11 @@ subroutine genfst240(msg0,ichk,msgsent,msgbits,i4tone,iwspr) entry get_fst240_tones_from_bits(msgbits,i4tone,iwspr) 2 continue - call encode240_101(msgbits,codeword) + if(iwspr.eq.0) then + call encode240_101(msgbits,codeword) + else + call encode240_74(msgbits(1:74),codeword) + endif ! Grayscale mapping: ! bits tone diff --git a/lib/fst240/ldpc_240_74_generator.f90 b/lib/fst240/ldpc_240_74_generator.f90 new file mode 100644 index 000000000..0cd5db01e --- /dev/null +++ b/lib/fst240/ldpc_240_74_generator.f90 @@ -0,0 +1,170 @@ +character*19 g(166) + +data g/ & + "de8b3201e3c59f55a14", & + "2e06d352ebc5b74c4fc", & + "2e16d6cf5a725c3244c", & + "84f5587edca6d777de4", & + "e152b1e2b5965093ecc", & + "244b4828a2ccf2b5f58", & + "5fbbaade810e123c730", & + "6b7e92a99a918df3d44", & + "bbcec6a63ab757a7278", & + "f5f3f0b89a21ceccdb0", & + "a248c5f1ec2bc816290", & + "c84bbad839a5fe76d0c", & + "ad724129bbf4c7f4570", & + "91adb56e7623a2575cc", & + "cbe995bdf156df2c9e4", & + "92ff6ea492c08c150e0", & + "c4ddbe5a02f6a933384", & + "d2e9befc131dc483858", & + "68567543d1eebcb080c", & + "21fa61d559f9baf6abc", & + "911c4fbbafc72e3db28", & + "7c0b534af4b7d583d50", & + "12ce371b90ee9dfe72c", & + "15a604148872e251ec4", & + "3a3c9f3eb0e0f96edc0", & + "705919ffb636f96b390", & + "43daaaa8163d6bc2bd4", & + "96e11ea798b74b10e98", & + "811150609c9dee8230c", & + "be713f85ab34380f4b0", & + "5a02c4abaaccb8f24c4", & + "67bdebb8863d04768cc", & + "5a449cd90c3dbdfe844", & + "9c7a54d1c4ef7418b84", & + "cd82fefaaf9cd28cd8c", & + "ca47e847fabb0054a38", & + "f0b30cef6aab9e37f98", & + "d948d912fbcc1708710", & + "cce1a7b355053d98270", & + "4cf227c225a9063dd48", & + "2db92612e9ba1418e24", & + "3d215c04c762c3d6a28", & + "77de65500b5624ceb0c", & + "fd1a1df99ded2fb9d88", & + "2a19392c71438410fb8", & + "a9b486a9d26ed579754", & + "b698d244ac78d97a498", & + "3d7975b74d727a5e704", & + "38094225a2bce0e1940", & + "3d3e58fae40fac342b0", & + "7732e839a066e337714", & + "69356c082b7753a47b0", & + "3e868a55dc403a802ac", & + "a0157a14a6bf7fdbbcc", & + "1ab628e11a7ab4a7c44", & + "9da3a2247d7449052f4", & + "199a8a7b114816b97f4", & + "b1c5cde2542061704cc", & + "432fa8d3a153eafbdc8", & + "c4ece7e400d8a89c448", & + "316ecf74e4b983f007c", & + "6a14fa8e713bb5e8adc", & + "da4b957ded8374e3640", & + "0a804dba7c7e4533300", & + "52c342ed033f86580e0", & + "1667da8d6fcf4272470", & + "da2f7038d550fa88d8c", & + "685bcbab1d9dd2c2a44", & + "4c93008b3156b3636bc", & + "726998d6327ac797c3c", & + "44ece7e400d8a8dc448", & + "01f9add00dfe823a948", & + "dbb95f5ce9e371ad720", & + "fc746ee5c76827a8728", & + "b25408029506467f4b4", & + "9b5c9219e21126b7cf8", & + "39ae9f48ba9d1a24f04", & + "7de2699623eb507f938", & + "b9c6e903ee91dd32934", & + "397510d2c6cb5e81de8", & + "20157a14aebf7fdbbec", & + "067f76ea5817a465980", & + "9248f3cea0869feb994", & + "23cde2678004ebe5f80", & + "5b81fe6848f58e3cfa8", & + "a9099ace96bff092904", & + "4afa4b0802b33215438", & + "f4f740396b030360858", & + "fc613f77a35ee1163b8", & + "1a4dc27d7e8cc835ff4", & + "e9b056f153b39def7ec", & + "b62eb777a2f953c7efc", & + "388ae4de514b62d238c", & + "891529af40e85317160", & + "474f1afeb724dbd2ba8", & + "11d70880fd88fdd307c", & + "29f26a3acb76e6a517c", & + "df3e902ff9cadcf776c", & + "e3c42da8445965c09f0", & + "ce277a6aeccc316dc58", & + "4d7841fb71543abd9b8", & + "e63230d2d465fb44750", & + "b6e11fa798b74b14e98", & + "05f189d37c5616547b4", & + "ebdb51a81d1e883baa8", & + "bf5bc736663bcd53ae0", & + "2f8d1cc0936142c08fc", & + "436b22fc36d917b6928", & + "044b482822ccf2b5f58", & + "37b2e839a066e3b7714", & + "2a9b4b765c581f0c51c", & + "10a7d44cecf8e6628dc", & + "ad95f02df6d5502dd4c", & + "bbd34f8afd63deaf564", & + "cabddfeb01fce632788", & + "66b57babeedd6124114", & + "7813e0454fbd462be8c", & + "b6105ed6f01ea621d04", & + "9f68bbcec679d1c088c", & + "673da96e414fc7a0f40", & + "5568adb935e11084abc", & + "f6dd308de5e5c4f6fb0", & + "3b49e80d40ae596c7b4", & + "a3cde2478004ebe5f80", & + "dd8e4f309e919d5ed94", & + "5a4020d387757d7bc28", & + "64f9e02ae32362a255c", & + "630d5942d392334b0dc", & + "0bd7e9f4229b2dee210", & + "bca549a9467d3a2550c", & + "2fef7b1f578c5e28d04", & + "f35e0fdda1be4b3b35c", & + "69ed575e7cc537d2394", & + "7dfdcfbfd5ef3093680", & + "b3b2921af97f251d328", & + "5622d0fe90363522364", & + "fcd4fc7fa04a69d2ac4", & + "1119ea451502ed9ab34", & + "970ee777ec969a41754", & + "688d14f8afec76783dc", & + "4d0b8a1028578407420", & + "d3d2138d9fa268da3e8", & + "df1bdbff898e006394c", & + "8ac478a916bb0b77684", & + "93881997428e2c17a94", & + "4aa510e746245e90c08", & + "e00cb8543f85a5d58b8", & + "9100d8eb74031073044", & + "38710e4235bd1e4003c", & + "6aef311cac4c4dccfd4", & + "58430f577f51c36b3e0", & + "12082fa5d4268a95b4c", & + "7a7435a0aca071e64d0", & + "cd8250ebadc95de15b0", & + "debad40c852e99d64dc", & + "4e6caa5e7c86efef748", & + "a5d4cbb97e726e3c580", & + "7e3a0a2c73ef8553640", & + "b60bfc2fd2bd8f530dc", & + "32dbef097a5f84b0318", & + "4cc7c1cf434300be380", & + "896840945be8eabf7f0", & + "36c9b10ec694819a0a0", & + "349f46a799ef95a47c8", & + "9bdcd4ce2563e560b74", & + "b19fcd7111a335c52ec"/ + diff --git a/lib/fst240/ldpc_240_74_parity.f90 b/lib/fst240/ldpc_240_74_parity.f90 new file mode 100644 index 000000000..6d41fde54 --- /dev/null +++ b/lib/fst240/ldpc_240_74_parity.f90 @@ -0,0 +1,423 @@ +data Mn/ & + 84, 101, 144, & + 10, 14, 138, & + 87, 148, 166, & + 1, 50, 67, & + 2, 53, 74, & + 3, 83, 113, & + 4, 90, 121, & + 5, 63, 128, & + 6, 124, 138, & + 8, 22, 108, & + 11, 28, 159, & + 12, 18, 142, & + 13, 24, 145, & + 15, 131, 149, & + 16, 44, 93, & + 17, 41, 47, & + 19, 37, 129, & + 20, 33, 94, & + 21, 100, 154, & + 23, 71, 141, & + 25, 89, 95, & + 26, 105, 153, & + 27, 36, 58, & + 29, 59, 166, & + 30, 52, 126, & + 31, 61, 77, & + 32, 84, 111, & + 34, 97, 155, & + 38, 98, 127, & + 39, 76, 143, & + 40, 55, 92, & + 42, 147, 158, & + 43, 82, 148, & + 45, 49, 109, & + 46, 70, 86, & + 48, 78, 139, & + 51, 101, 104, & + 54, 63, 96, & + 56, 81, 125, & + 57, 117, 164, & + 60, 75, 107, & + 39, 62, 132, & + 64, 110, 118, & + 24, 65, 146, & + 66, 80, 134, & + 68, 91, 114, & + 69, 123, 162, & + 72, 88, 152, & + 79, 99, 130, & + 85, 112, 124, & + 99, 103, 157, & + 106, 115, 133, & + 116, 120, 140, & + 119, 161, 165, & + 64, 122, 137, & + 34, 89, 135, & + 136, 138, 163, & + 93, 144, 159, & + 35, 130, 150, & + 62, 151, 164, & + 104, 153, 160, & + 1, 106, 166, & + 2, 132, 152, & + 3, 11, 105, & + 4, 18, 160, & + 5, 53, 91, & + 6, 109, 141, & + 7, 111, 113, & + 8, 54, 136, & + 9, 61, 92, & + 10, 40, 101, & + 12, 30, 146, & + 13, 37, 82, & + 14, 29, 95, & + 1, 47, 131, & + 2, 8, 139, & + 3, 58, 130, & + 4, 96, 115, & + 5, 119, 129, & + 6, 60, 148, & + 7, 95, 163, & + 2, 35, 56, & + 9, 67, 79, & + 10, 75, 122, & + 11, 17, 121, & + 12, 137, 145, & + 13, 36, 152, & + 14, 15, 155, & + 15, 134, 143, & + 16, 106, 125, & + 11, 106, 157, & + 18, 99, 118, & + 19, 50, 94, & + 20, 126, 158, & + 21, 41, 135, & + 22, 24, 71, & + 23, 42, 136, & + 22, 109, 161, & + 25, 39, 46, & + 26, 45, 55, & + 27, 77, 82, & + 28, 73, 166, & + 29, 69, 76, & + 30, 108, 150, & + 31, 91, 146, & + 14, 32, 147, & + 33, 35, 107, & + 34, 103, 111, & + 8, 94, 122, & + 13, 70, 151, & + 32, 37, 142, & + 3, 38, 87, & + 25, 51, 92, & + 40, 57, 72, & + 21, 108, 153, & + 23, 26, 142, & + 43, 44, 48, & + 30, 43, 62, & + 7, 45, 154, & + 16, 46, 149, & + 1, 53, 75, & + 33, 44, 160, & + 49, 86, 157, & + 19, 80, 159, & + 51, 116, 138, & + 52, 92, 98, & + 6, 12, 47, & + 54, 83, 101, & + 24, 55, 102, & + 56, 63, 120, & + 17, 57, 82, & + 38, 154, 162, & + 59, 74, 151, & + 53, 144, 164, & + 61, 85, 117, & + 62, 66, 90, & + 48, 113, 145, & + 64, 65, 128, & + 27, 29, 65, & + 58, 63, 134, & + 9, 74, 83, & + 68, 109, 113, & + 41, 61, 69, & + 36, 60, 155, & + 42, 64, 144, & + 40, 90, 130, & + 28, 110, 135, & + 20, 59, 112, & + 70, 110, 124, & + 54, 76, 105, & + 4, 77, 111, & + 78, 104, 143, & + 66, 67, 91, & + 80, 81, 88, & + 50, 101, 132, & + 71, 97, 120, & + 72, 131, 158, & + 84, 133, 141, & + 5, 85, 99, & + 49, 89, 133, & + 87, 132, 140, & + 34, 88, 104, & + 89, 105, 147, & + 6, 76, 102, & + 18, 31, 163, & + 52, 96, 140, & + 93, 102, 165, & + 79, 104, 165, & + 81, 100, 126, & + 95, 121, 152, & + 97, 123, 153, & + 37, 98, 114, & + 8, 91, 155, & + 100, 114, 160, & + 2, 26, 28, & + 93, 116, 150, & + 68, 103, 166, & + 78, 117, 125, & + 86, 107, 127, & + 4, 59, 136, & + 9, 37, 97, & + 7, 30, 75, & + 80, 148, 153, & + 73, 138, 164, & + 10, 39, 103, & + 39, 146, 156, & + 48, 129, 136, & + 5, 17, 51, & + 112, 149, 161, & + 11, 24, 126, & + 1, 70, 78, & + 14, 113, 118, & + 10, 119, 141, & + 13, 33, 105, & + 19, 57, 89, & + 12, 25, 56, & + 16, 18, 54, & + 84, 124, 162, & + 20, 41, 134, & + 15, 45, 82, & + 115, 118, 123, & + 128, 139, 149, & + 127, 156, 159, & + 21, 141, 152, & + 23, 130, 156, & + 3, 160, 164, & + 22, 90, 110, & + 35, 61, 109, & + 31, 87, 158, & + 42, 60, 106, & + 137, 140, 157, & + 27, 114, 124, & + 32, 62, 125, & + 34, 38, 128, & + 40, 123, 139, & + 29, 66, 86, & + 36, 52, 161, & + 43, 63, 133, & + 46, 73, 108, & + 44, 135, 146, & + 47, 115, 127, & + 49, 74, 116, & + 58, 102, 122, & + 55, 85, 132, & + 50, 65, 150, & + 67, 145, 162, & + 53, 71, 77, & + 69, 88, 142, & + 68, 72, 93, & + 9, 64, 95, & + 92, 94, 111, & + 81, 83, 119, & + 98, 143, 163, & + 73, 79, 96, & + 35, 129, 131, & + 99, 100, 151, & + 7, 112, 159, & + 117, 137, 156, & + 120, 147, 154, & + 107, 121, 165/ + +data Nm/ & + 4, 62, 75, 121, 191, & + 5, 63, 76, 82, 175, & + 6, 64, 77, 112, 206, & + 7, 65, 78, 151, 180, & + 8, 66, 79, 159, 188, & + 9, 67, 80, 127, 164, & + 68, 81, 119, 182, 237, & + 10, 69, 76, 109, 173, & + 70, 83, 141, 181, 230, & + 2, 71, 84, 185, 193, & + 11, 64, 85, 91, 190, & + 12, 72, 86, 127, 196, & + 13, 73, 87, 110, 194, & + 2, 74, 88, 106, 192, & + 14, 88, 89, 200, 0, & + 15, 90, 120, 197, 0, & + 16, 85, 131, 188, 0, & + 12, 65, 92, 165, 197, & + 17, 93, 124, 195, 0, & + 18, 94, 148, 199, 0, & + 19, 95, 115, 204, 0, & + 10, 96, 98, 207, 0, & + 20, 97, 116, 205, 0, & + 13, 44, 96, 129, 190, & + 21, 99, 113, 196, 0, & + 22, 100, 116, 175, 0, & + 23, 101, 139, 212, 0, & + 11, 102, 147, 175, 0, & + 24, 74, 103, 139, 216, & + 25, 72, 104, 118, 182, & + 26, 105, 165, 209, 0, & + 27, 106, 111, 213, 0, & + 18, 107, 122, 194, 0, & + 28, 56, 108, 162, 214, & + 59, 82, 107, 208, 235, & + 23, 87, 144, 217, 0, & + 17, 73, 111, 172, 181, & + 29, 112, 132, 214, 0, & + 30, 42, 99, 185, 186, & + 31, 71, 114, 146, 215, & + 16, 95, 143, 199, 0, & + 32, 97, 145, 210, 0, & + 33, 117, 118, 218, 0, & + 15, 117, 122, 220, 0, & + 34, 100, 119, 200, 0, & + 35, 99, 120, 219, 0, & + 16, 75, 127, 221, 0, & + 36, 117, 137, 187, 0, & + 34, 123, 160, 222, 0, & + 4, 93, 155, 225, 0, & + 37, 113, 125, 188, 0, & + 25, 126, 166, 217, 0, & + 5, 66, 121, 134, 227, & + 38, 69, 128, 150, 197, & + 31, 100, 129, 224, 0, & + 39, 82, 130, 196, 0, & + 40, 114, 131, 195, 0, & + 23, 77, 140, 223, 0, & + 24, 133, 148, 180, 0, & + 41, 80, 144, 210, 0, & + 26, 70, 135, 143, 208, & + 42, 60, 118, 136, 213, & + 8, 38, 130, 140, 218, & + 43, 55, 138, 145, 230, & + 44, 138, 139, 225, 0, & + 45, 136, 153, 216, 0, & + 4, 83, 153, 226, 0, & + 46, 142, 177, 229, 0, & + 47, 103, 143, 228, 0, & + 35, 110, 149, 191, 0, & + 20, 96, 156, 227, 0, & + 48, 114, 157, 229, 0, & + 102, 184, 219, 234, 0, & + 5, 133, 141, 222, 0, & + 41, 84, 121, 182, 0, & + 30, 103, 150, 164, 0, & + 26, 101, 151, 227, 0, & + 36, 152, 178, 191, 0, & + 49, 83, 168, 234, 0, & + 45, 124, 154, 183, 0, & + 39, 154, 169, 232, 0, & + 33, 73, 101, 131, 200, & + 6, 128, 141, 232, 0, & + 1, 27, 158, 198, 0, & + 50, 135, 159, 224, 0, & + 35, 123, 179, 216, 0, & + 3, 112, 161, 209, 0, & + 48, 154, 162, 228, 0, & + 21, 56, 160, 163, 195, & + 7, 136, 146, 207, 0, & + 46, 66, 105, 153, 173, & + 31, 70, 113, 126, 231, & + 15, 58, 167, 176, 229, & + 18, 93, 109, 231, 0, & + 21, 74, 81, 170, 230, & + 38, 78, 166, 234, 0, & + 28, 156, 171, 181, 0, & + 29, 126, 172, 233, 0, & + 49, 51, 92, 159, 236, & + 19, 169, 174, 236, 0, & + 1, 37, 71, 128, 155, & + 129, 164, 167, 223, 0, & + 51, 108, 177, 185, 0, & + 37, 61, 152, 162, 168, & + 22, 64, 150, 163, 194, & + 52, 62, 90, 91, 210, & + 41, 107, 179, 240, 0, & + 10, 104, 115, 219, 0, & + 34, 67, 98, 142, 208, & + 43, 147, 149, 207, 0, & + 27, 68, 108, 151, 231, & + 50, 148, 189, 237, 0, & + 6, 68, 137, 142, 192, & + 46, 172, 174, 212, 0, & + 52, 78, 201, 221, 0, & + 53, 125, 176, 222, 0, & + 40, 135, 178, 238, 0, & + 43, 92, 192, 201, 0, & + 54, 79, 193, 232, 0, & + 53, 130, 156, 239, 0, & + 7, 85, 170, 240, 0, & + 55, 84, 109, 223, 0, & + 47, 171, 201, 215, 0, & + 9, 50, 149, 198, 212, & + 39, 90, 178, 213, 0, & + 25, 94, 169, 190, 0, & + 29, 179, 203, 221, 0, & + 8, 138, 202, 214, 0, & + 17, 79, 187, 235, 0, & + 49, 59, 77, 146, 205, & + 14, 75, 157, 235, 0, & + 42, 63, 155, 161, 224, & + 52, 158, 160, 218, 0, & + 45, 89, 140, 199, 0, & + 56, 95, 147, 220, 0, & + 57, 69, 97, 180, 187, & + 55, 86, 211, 238, 0, & + 2, 9, 57, 125, 184, & + 36, 76, 202, 215, 0, & + 53, 161, 166, 211, 0, & + 20, 67, 158, 193, 204, & + 12, 111, 116, 228, 0, & + 30, 89, 152, 233, 0, & + 1, 58, 134, 145, 0, & + 13, 86, 137, 226, 0, & + 44, 72, 105, 186, 220, & + 32, 106, 163, 239, 0, & + 3, 33, 80, 183, 0, & + 14, 120, 189, 202, 0, & + 59, 104, 176, 225, 0, & + 60, 110, 133, 236, 0, & + 48, 63, 87, 170, 204, & + 22, 61, 115, 171, 183, & + 19, 119, 132, 239, 0, & + 28, 88, 144, 173, 0, & + 186, 203, 205, 238, 0, & + 51, 91, 123, 211, 0, & + 32, 94, 157, 209, 0, & + 11, 58, 124, 203, 237, & + 61, 65, 122, 174, 206, & + 54, 98, 189, 217, 0, & + 47, 132, 198, 226, 0, & + 57, 81, 165, 233, 0, & + 40, 60, 134, 184, 206, & + 54, 167, 168, 240, 0, & + 3, 24, 62, 102, 177/ + +data nrw/ & +5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,5,4,4, & +4,4,4,5,4,4,4,4,5,5,4,4,4,5,5,4,5,4,5,5, & +4,4,4,4,4,4,4,4,4,4,4,4,5,5,4,4,4,4,4,4, & +5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, & +4,5,4,4,4,4,4,4,5,4,5,5,5,4,5,4,4,4,5,4, & +5,4,4,5,5,5,4,4,5,4,5,4,5,4,4,4,4,4,4,4, & +4,4,4,5,4,4,4,4,4,5,4,5,4,4,4,5,4,5,4,4, & +5,4,4,4,4,5,4,4,4,4,4,5,5,4,4,4,4,4,5,5, & +4,4,4,5,4,5/ + +ncw=3 + diff --git a/lib/fst240/ldpcsim240_74.f90 b/lib/fst240/ldpcsim240_74.f90 new file mode 100644 index 000000000..743dff34b --- /dev/null +++ b/lib/fst240/ldpcsim240_74.f90 @@ -0,0 +1,125 @@ +program ldpcsim240_74 + +! End-to-end test of the (240,74)/crc24 encoder and decoders. + + use packjt77 + + parameter(N=240, K=74, M=N-K) + character*8 arg + character*37 msg0,msg + character*77 c77 + character*24 c24 + integer*1 msgbits(74) + integer*1 apmask(240) + integer*1 cw(240) + integer*1 codeword(N),message74(74) + integer ncrc24 + real rxdata(N),llr(N) + logical first,unpk77_success + data first/.true./ + + nargs=iargc() + if(nargs.ne.5 .and. nargs.ne.6) then + print*,'Usage: ldpcsim niter ndeep #trials s K [msg]' + print*,'e.g. ldpcsim240_74 20 5 1000 0.85 64 "K9AN K1JT FN20"' + print*,'s : if negative, then value is ignored and sigma is calculated from SNR.' + print*,'niter: is the number of BP iterations.' + print*,'ndeep: -1 is BP only, ndeep>=0 is OSD order' + print*,'K :is the number of message+CRC bits and must be in the range [50,74]' + print*,'WSPR-format message is optional' + return + endif + call getarg(1,arg) + read(arg,*) max_iterations + call getarg(2,arg) + read(arg,*) norder + call getarg(3,arg) + read(arg,*) ntrials + call getarg(4,arg) + read(arg,*) s + call getarg(5,arg) + read(arg,*) Keff + msg0='K9AN K1JT FN20 ' + if(nargs.eq.6) call getarg(6,msg0) + call pack77(msg0,i3,n3,c77) + + rate=real(Keff)/real(N) + + write(*,*) "code rate: ",rate + write(*,*) "niter : ",max_iterations + write(*,*) "norder : ",norder + write(*,*) "s : ",s + write(*,*) "K : ",Keff + + msgbits=0 + read(c77,'(77i1)') msgbits(1:77) + write(*,*) 'message' + write(*,'(77i1)') msgbits(1:77) + + call get_crc24(msgbits,74,ncrc24) + write(c24,'(b24.24)') ncrc24 + read(c24,'(24i1)') msgbits(51:74) +write(*,'(24i1)') msgbits(51:74) + write(*,*) 'message with crc24' + write(*,'(74i1)') msgbits(1:74) + call encode240_74(msgbits,codeword) + call init_random_seed() + call sgran() + + write(*,*) 'codeword' + write(*,'(77i1,1x,24i1,1x,73i1)') codeword + + write(*,*) "Eb/N0 Es/N0 ngood nundetected sigma symbol error rate" + do idb = 8,-3,-1 + db=idb/2.0-1.0 + sigma=1/sqrt( 2*rate*(10**(db/10.0)) ) ! to make db represent Eb/No +! sigma=1/sqrt( 2*(10**(db/10.0)) ) ! db represents Es/No + ngood=0 + nue=0 + nberr=0 + do itrial=1, ntrials +! Create a realization of a noisy received word + do i=1,N + rxdata(i) = 2.0*codeword(i)-1.0 + sigma*gran() + enddo + nerr=0 + do i=1,N + if( rxdata(i)*(2*codeword(i)-1.0) .lt. 0 ) nerr=nerr+1 + enddo + nberr=nberr+nerr + + rxav=sum(rxdata)/N + rx2av=sum(rxdata*rxdata)/N + rxsig=sqrt(rx2av-rxav*rxav) + rxdata=rxdata/rxsig + if( s .lt. 0 ) then + ss=sigma + else + ss=s + endif + + llr=2.0*rxdata/(ss*ss) + apmask=0 + dmin=0.0 + maxosd=2 + call decode240_74(llr, Keff, maxosd, norder, apmask, message74, cw, ntype, nharderror, dmin) + if(nharderror.ge.0) then + n2err=0 + do i=1,N + if( cw(i).ne.codeword(i) ) n2err=n2err+1 + enddo + if(n2err.eq.0) then + ngood=ngood+1 + else + nue=nue+1 + endif + endif + enddo +! snr2500=db+10*log10(200.0/116.0/2500.0) + esn0=db+10*log10(rate) + pberr=real(nberr)/(real(ntrials*N)) + write(*,"(f4.1,4x,f5.1,1x,i8,1x,i8,8x,f5.2,8x,e10.3)") db,esn0,ngood,nue,ss,pberr + + enddo + +end program ldpcsim240_74 diff --git a/lib/fst240/osd240_74.f90 b/lib/fst240/osd240_74.f90 new file mode 100644 index 000000000..a44b69867 --- /dev/null +++ b/lib/fst240/osd240_74.f90 @@ -0,0 +1,403 @@ +subroutine osd240_74(llr,k,apmask,ndeep,message74,cw,nhardmin,dmin) +! +! An ordered-statistics decoder for the (240,74) code. +! Message payload is 50 bits. Any or all of a 24-bit CRC can be +! used for detecting incorrect codewords. The remaining CRC bits are +! cascaded with the LDPC code for the purpose of improving the +! distance spectrum of the code. +! +! If p1 (0.le.p1.le.24) is the number of CRC24 bits that are +! to be used for bad codeword detection, then the argument k should +! be set to 77+p1. +! +! Valid values for k are in the range [50,74]. +! + character*24 c24 + integer, parameter:: N=240 + integer*1 apmask(N),apmaskr(N) + integer*1, allocatable, save :: gen(:,:) + integer*1, allocatable :: genmrb(:,:),g2(:,:) + integer*1, allocatable :: temp(:),m0(:),me(:),mi(:),misub(:),e2sub(:),e2(:),ui(:) + integer*1, allocatable :: r2pat(:) + integer indices(N),nxor(N) + integer*1 cw(N),ce(N),c0(N),hdec(N) + integer*1, allocatable :: decoded(:) + integer*1 message74(74) + integer indx(N) + real llr(N),rx(N),absrx(N) + + logical first,reset + data first/.true./ + save first + + allocate( genmrb(k,N), g2(N,k) ) + allocate( temp(k), m0(k), me(k), mi(k), misub(k), e2sub(N-k), e2(N-k), ui(N-k) ) + allocate( r2pat(N-k), decoded(k) ) + + if( first ) then ! fill the generator matrix +! +! Create generator matrix for partial CRC cascaded with LDPC code. +! +! Let p2=74-k and p1+p2=24. +! +! The last p2 bits of the CRC24 are cascaded with the LDPC code. +! +! The first p1=k-50 CRC24 bits will be used for error detection. +! + allocate( gen(k,N) ) + gen=0 + do i=1,k + message74=0 + message74(i)=1 + if(i.le.50) then + call get_crc24(message74,74,ncrc24) + write(c24,'(b24.24)') ncrc24 + read(c24,'(24i1)') message74(51:74) + message74(51:k)=0 + endif + call encode240_74(message74,cw) + gen(i,:)=cw + enddo + + first=.false. + endif + + rx=llr + apmaskr=apmask + +! Hard decisions on the received word. + hdec=0 + where(rx .ge. 0) hdec=1 + +! Use magnitude of received symbols as a measure of reliability. + absrx=abs(rx) + call indexx(absrx,N,indx) + +! Re-order the columns of the generator matrix in order of decreasing reliability. + do i=1,N + genmrb(1:k,i)=gen(1:k,indx(N+1-i)) + indices(i)=indx(N+1-i) + enddo + +! Do gaussian elimination to create a generator matrix with the most reliable +! received bits in positions 1:k in order of decreasing reliability (more or less). + do id=1,k ! diagonal element indices + do icol=id,k+20 ! The 20 is ad hoc - beware + iflag=0 + if( genmrb(id,icol) .eq. 1 ) then + iflag=1 + if( icol .ne. id ) then ! reorder column + temp(1:k)=genmrb(1:k,id) + genmrb(1:k,id)=genmrb(1:k,icol) + genmrb(1:k,icol)=temp(1:k) + itmp=indices(id) + indices(id)=indices(icol) + indices(icol)=itmp + endif + do ii=1,k + if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then + genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N)) + endif + enddo + exit + endif + enddo + enddo + + g2=transpose(genmrb) + +! The hard decisions for the k MRB bits define the order 0 message, m0. +! Encode m0 using the modified generator matrix to find the "order 0" codeword. +! Flip various combinations of bits in m0 and re-encode to generate a list of +! codewords. Return the member of the list that has the smallest Euclidean +! distance to the received word. + + hdec=hdec(indices) ! hard decisions from received symbols + m0=hdec(1:k) ! zero'th order message + absrx=absrx(indices) + rx=rx(indices) + apmaskr=apmaskr(indices) + + call mrbencode74(m0,c0,g2,N,k) + nxor=ieor(c0,hdec) + nhardmin=sum(nxor) + dmin=sum(nxor*absrx) + + cw=c0 + ntotal=0 + nrejected=0 + npre1=0 + npre2=0 + + if(ndeep.eq.0) goto 998 ! norder=0 + if(ndeep.gt.6) ndeep=6 + if( ndeep.eq. 1) then + nord=1 + npre1=0 + npre2=0 + nt=40 + ntheta=12 + elseif(ndeep.eq.2) then + nord=1 + npre1=1 + npre2=0 + nt=40 + ntheta=12 + elseif(ndeep.eq.3) then + nord=1 + npre1=1 + npre2=1 + nt=40 + ntheta=12 + ntau=14 + elseif(ndeep.eq.4) then + nord=2 + npre1=1 + npre2=1 + nt=40 + ntheta=12 + ntau=17 + elseif(ndeep.eq.5) then + nord=3 + npre1=1 + npre2=1 + nt=40 + ntheta=12 + ntau=15 + elseif(ndeep.eq.6) then + nord=4 + npre1=1 + npre2=1 + nt=95 + ntheta=12 + ntau=15 + endif + + do iorder=1,nord + misub(1:k-iorder)=0 + misub(k-iorder+1:k)=1 + iflag=k-iorder+1 + do while(iflag .ge.0) + if(iorder.eq.nord .and. npre1.eq.0) then + iend=iflag + else + iend=1 + endif + d1=0. + do n1=iflag,iend,-1 + mi=misub + mi(n1)=1 + if(any(iand(apmaskr(1:k),mi).eq.1)) cycle + ntotal=ntotal+1 + me=ieor(m0,mi) + if(n1.eq.iflag) then + call mrbencode74(me,ce,g2,N,k) + e2sub=ieor(ce(k+1:N),hdec(k+1:N)) + e2=e2sub + nd1kpt=sum(e2sub(1:nt))+1 + d1=sum(ieor(me(1:k),hdec(1:k))*absrx(1:k)) + else + e2=ieor(e2sub,g2(k+1:N,n1)) + nd1kpt=sum(e2(1:nt))+2 + endif + if(nd1kpt .le. ntheta) then + call mrbencode74(me,ce,g2,N,k) + nxor=ieor(ce,hdec) + if(n1.eq.iflag) then + dd=d1+sum(e2sub*absrx(k+1:N)) + else + dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(k+1:N)) + endif + if( dd .lt. dmin ) then + dmin=dd + cw=ce + nhardmin=sum(nxor) + nd1kptbest=nd1kpt + endif + else + nrejected=nrejected+1 + endif + enddo +! Get the next test error pattern, iflag will go negative +! when the last pattern with weight iorder has been generated. + call nextpat74(misub,k,iorder,iflag) + enddo + enddo + + if(npre2.eq.1) then + reset=.true. + ntotal=0 + do i1=k,1,-1 + do i2=i1-1,1,-1 + ntotal=ntotal+1 + mi(1:ntau)=ieor(g2(k+1:k+ntau,i1),g2(k+1:k+ntau,i2)) + call boxit74(reset,mi(1:ntau),ntau,ntotal,i1,i2) + enddo + enddo + + ncount2=0 + ntotal2=0 + reset=.true. +! Now run through again and do the second pre-processing rule + misub(1:k-nord)=0 + misub(k-nord+1:k)=1 + iflag=k-nord+1 + do while(iflag .ge.0) + me=ieor(m0,misub) + call mrbencode74(me,ce,g2,N,k) + e2sub=ieor(ce(k+1:N),hdec(k+1:N)) + do i2=0,ntau + ntotal2=ntotal2+1 + ui=0 + if(i2.gt.0) ui(i2)=1 + r2pat=ieor(e2sub,ui) +778 continue + call fetchit74(reset,r2pat(1:ntau),ntau,in1,in2) + if(in1.gt.0.and.in2.gt.0) then + ncount2=ncount2+1 + mi=misub + mi(in1)=1 + mi(in2)=1 + if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:k),mi).eq.1)) cycle + me=ieor(m0,mi) + call mrbencode74(me,ce,g2,N,k) + nxor=ieor(ce,hdec) + dd=sum(nxor*absrx) + if( dd .lt. dmin ) then + dmin=dd + cw=ce + nhardmin=sum(nxor) + endif + goto 778 + endif + enddo + call nextpat74(misub,k,nord,iflag) + enddo + endif + +998 continue +! Re-order the codeword to [message bits][parity bits] format. + cw(indices)=cw + hdec(indices)=hdec + message74=cw(1:74) + call get_crc24(message74,74,nbadcrc) + if(nbadcrc.ne.0) nhardmin=-nhardmin + + return +end subroutine osd240_74 + +subroutine mrbencode74(me,codeword,g2,N,K) + integer*1 me(K),codeword(N),g2(N,K) +! fast encoding for low-weight test patterns + codeword=0 + do i=1,K + if( me(i) .eq. 1 ) then + codeword=ieor(codeword,g2(1:N,i)) + endif + enddo + return +end subroutine mrbencode74 + +subroutine nextpat74(mi,k,iorder,iflag) + integer*1 mi(k),ms(k) +! generate the next test error pattern + ind=-1 + do i=1,k-1 + if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i + enddo + if( ind .lt. 0 ) then ! no more patterns of this order + iflag=ind + return + endif + ms=0 + ms(1:ind-1)=mi(1:ind-1) + ms(ind)=1 + ms(ind+1)=0 + if( ind+1 .lt. k ) then + nz=iorder-sum(ms) + ms(k-nz+1:k)=1 + endif + mi=ms + do i=1,k ! iflag will point to the lowest-index 1 in mi + if(mi(i).eq.1) then + iflag=i + exit + endif + enddo + return +end subroutine nextpat74 + +subroutine boxit74(reset,e2,ntau,npindex,i1,i2) + integer*1 e2(1:ntau) + integer indexes(5000,2),fp(0:525000),np(5000) + logical reset + common/boxes/indexes,fp,np + + if(reset) then + patterns=-1 + fp=-1 + np=-1 + sc=-1 + indexes=-1 + reset=.false. + endif + + indexes(npindex,1)=i1 + indexes(npindex,2)=i2 + ipat=0 + do i=1,ntau + if(e2(i).eq.1) then + ipat=ipat+ishft(1,ntau-i) + endif + enddo + + ip=fp(ipat) ! see what's currently stored in fp(ipat) + if(ip.eq.-1) then + fp(ipat)=npindex + else + do while (np(ip).ne.-1) + ip=np(ip) + enddo + np(ip)=npindex + endif + return +end subroutine boxit74 + +subroutine fetchit74(reset,e2,ntau,i1,i2) + integer indexes(5000,2),fp(0:525000),np(5000) + integer lastpat + integer*1 e2(ntau) + logical reset + common/boxes/indexes,fp,np + save lastpat,inext + + if(reset) then + lastpat=-1 + reset=.false. + endif + + ipat=0 + do i=1,ntau + if(e2(i).eq.1) then + ipat=ipat+ishft(1,ntau-i) + endif + enddo + index=fp(ipat) + + if(lastpat.ne.ipat .and. index.gt.0) then ! return first set of indices + i1=indexes(index,1) + i2=indexes(index,2) + inext=np(index) + elseif(lastpat.eq.ipat .and. inext.gt.0) then + i1=indexes(inext,1) + i2=indexes(inext,2) + inext=np(inext) + else + i1=-1 + i2=-1 + inext=-1 + endif + lastpat=ipat + return +end subroutine fetchit74 + diff --git a/lib/fst240_decode.f90 b/lib/fst240_decode.f90 index 85038769f..745f2c68e 100644 --- a/lib/fst240_decode.f90 +++ b/lib/fst240_decode.f90 @@ -154,7 +154,7 @@ contains hmod=2**nsubmode if(nfqso+nqsoprogress.eq.-999) return Keff=91 - iwspr=0 + iwspr=1 nmax=15*12000 single_decode=iand(nexp_decode,32).eq.32 if(ntrperiod.eq.15) then @@ -413,6 +413,11 @@ contains if(ndepth.eq.1) ntmax=nblock apmask=0 + if(iwspr.eq.1) then + nblock=4 + ntmax=nblock + endif + do itry=1,ntmax if(itry.eq.1) llr=llra if(itry.eq.2.and.itry.le.nblock) llr=llrb @@ -471,8 +476,10 @@ contains else maxosd=2 call timer('d240_74 ',0) -! call decode240_74(llr,Keff,maxosd,norder,apmask,message74,cw, & -! ntype,nharderrors,dmin) + Keff=64 + norder=4 + call decode240_74(llr,Keff,maxosd,norder,apmask,message74,cw, & + ntype,nharderrors,dmin) call timer('d240_74 ',1) endif if(nharderrors .ge.0) then @@ -694,7 +701,8 @@ write(21,'(i6,7i6,f7.1,f9.2,3f7.1,1x,a37)') & enddo call pctile(s2(ina+hmod*3:inb-hmod*3),inb-ina+1-hmod*6,30,base) s2=s2/base !Normalize wrt noise level - thresh=1.25 !First candidate threshold +! thresh=1.25 + thresh=1.15 !First candidate threshold ncand=0 candidates=0