Silence compiler warnings; reformmat some source code.

This commit is contained in:
Joe Taylor 2020-03-19 13:13:33 -04:00
parent d4d37c49ab
commit d5e92202d0
5 changed files with 256 additions and 254 deletions

View File

@ -33,6 +33,7 @@ do j=1,M
enddo enddo
ncnt=0 ncnt=0
nclast=0
do iter=0,maxiterations do iter=0,maxiterations

View File

@ -102,7 +102,7 @@ contains
if(nsubmode.ge.100) then if(nsubmode.ge.100) then
! This is QRA64 mode ! This is QRA64 mode
mode64=2**(nsubmode-100) mode64=2**(nsubmode-100)
call qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & call qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
emedelay,mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft) emedelay,mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft)
if (associated(this%callback)) then if (associated(this%callback)) then
ndrift=0 ndrift=0

View File

@ -1,88 +1,93 @@
subroutine osd128_90(llr,apmask,ndeep,message77,cw,nhardmin,dmin) subroutine osd128_90(llr,apmask,ndeep,message77,cw,nhardmin,dmin)
!
! An ordered-statistics decoder for the (128,90) code.
!
integer, parameter:: N=128, K=90, M=N-K
integer*1 apmask(N),apmaskr(N)
integer*1 gen(K,N)
integer*1 genmrb(K,N),g2(N,K)
integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K)
integer*1 r2pat(N-K)
integer indices(N),nxor(N)
integer*1 cw(N),ce(N),c0(N),hdec(N)
integer*1 decoded(K)
integer*1 message77(77)
integer indx(N)
real llr(N),rx(N),absrx(N)
include "ldpc_128_90_generator.f90" ! Ordered-statistics decoder for the (128,90) code.
logical first,reset integer, parameter:: N=128, K=90, M=N-K
data first/.true./ integer*1 apmask(N),apmaskr(N)
save first,gen integer*1 gen(K,N)
integer*1 genmrb(K,N),g2(N,K)
integer*1 temp(K),m0(K),me(K),mi(K),misub(K),e2sub(N-K),e2(N-K),ui(N-K)
integer*1 r2pat(N-K)
integer indices(N),nxor(N)
integer*1 cw(N),ce(N),c0(N),hdec(N)
integer*1 decoded(K)
integer*1 message77(77)
integer indx(N)
real llr(N),rx(N),absrx(N)
if( first ) then ! fill the generator matrix include "ldpc_128_90_generator.f90"
gen=0
do i=1,M
do j=1,23
read(g(i)(j:j),"(Z1)") istr
ibmax=4
if(j.eq.23) ibmax=2
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,irow)=1
enddo
first=.false.
endif
rx=llr logical first,reset
apmaskr=apmask 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=2
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,irow)=1
enddo
first=.false.
endif
rx=llr
apmaskr=apmask
d1=0.
ntheta=0
npre1=0
npre2=0
nt=0
! Hard decisions on the received word. ! Hard decisions on the received word.
hdec=0 hdec=0
where(rx .ge. 0) hdec=1 where(rx .ge. 0) hdec=1
! Use magnitude of received symbols as a measure of reliability. ! Use magnitude of received symbols as a measure of reliability.
absrx=abs(rx) absrx=abs(rx)
call indexx(absrx,N,indx) call indexx(absrx,N,indx)
! Re-order the columns of the generator matrix in order of decreasing reliability. ! Re-order columns of generator matrix in order of decreasing reliability.
do i=1,N do i=1,N
genmrb(1:K,i)=gen(1:K,indx(N+1-i)) genmrb(1:K,i)=gen(1:K,indx(N+1-i))
indices(i)=indx(N+1-i) indices(i)=indx(N+1-i)
enddo enddo
! Do gaussian elimination to create a generator matrix with the most reliable ! 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). ! received bits in positions 1:K in order of decreasing reliability (more or less).
do id=1,K ! diagonal element indices do id=1,K ! diagonal element indices
do icol=id,K+20 ! The 20 is ad hoc - beware do icol=id,K+20 ! The 20 is ad hoc - beware
iflag=0 iflag=0
if( genmrb(id,icol) .eq. 1 ) then if( genmrb(id,icol) .eq. 1 ) then
iflag=1 iflag=1
if( icol .ne. id ) then ! reorder column if( icol .ne. id ) then ! reorder column
temp(1:K)=genmrb(1:K,id) temp(1:K)=genmrb(1:K,id)
genmrb(1:K,id)=genmrb(1:K,icol) genmrb(1:K,id)=genmrb(1:K,icol)
genmrb(1:K,icol)=temp(1:K) genmrb(1:K,icol)=temp(1:K)
itmp=indices(id) itmp=indices(id)
indices(id)=indices(icol) indices(id)=indices(icol)
indices(icol)=itmp indices(icol)=itmp
endif endif
do ii=1,K do ii=1,K
if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then if( ii .ne. id .and. genmrb(ii,id) .eq. 1 ) then
genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N)) genmrb(ii,1:N)=ieor(genmrb(ii,1:N),genmrb(id,1:N))
endif
enddo
exit
endif endif
enddo enddo
exit
endif
enddo enddo
enddo
g2=transpose(genmrb) g2=transpose(genmrb)
! The hard decisions for the K MRB bits define the order 0 message, m0. ! 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. ! Encode m0 using the modified generator matrix to find the "order 0" codeword.
@ -90,180 +95,180 @@ g2=transpose(genmrb)
! codewords. Return the member of the list that has the smallest Euclidean ! codewords. Return the member of the list that has the smallest Euclidean
! distance to the received word. ! distance to the received word.
hdec=hdec(indices) ! hard decisions from received symbols hdec=hdec(indices) ! hard decisions from received symbols
m0=hdec(1:K) ! zero'th order message m0=hdec(1:K) ! zero'th order message
absrx=absrx(indices) absrx=absrx(indices)
rx=rx(indices) rx=rx(indices)
apmaskr=apmaskr(indices) apmaskr=apmaskr(indices)
call mrbencode90(m0,c0,g2,N,K) call mrbencode90(m0,c0,g2,N,K)
nxor=ieor(c0,hdec) nxor=ieor(c0,hdec)
nhardmin=sum(nxor) nhardmin=sum(nxor)
dmin=sum(nxor*absrx) dmin=sum(nxor*absrx)
cw=c0 cw=c0
ntotal=0 ntotal=0
nrejected=0 nrejected=0
if(ndeep.eq.0) goto 998 ! norder=0 if(ndeep.eq.0) goto 998 ! norder=0
if(ndeep.gt.5) ndeep=5 if(ndeep.gt.5) ndeep=5
if( ndeep.eq. 1) then if( ndeep.eq. 1) then
nord=1 nord=1
npre1=0 npre1=0
npre2=0 npre2=0
nt=12 nt=12
ntheta=3 ntheta=3
elseif(ndeep.eq.2) then elseif(ndeep.eq.2) then
nord=1 nord=1
npre1=1 npre1=1
npre2=0 npre2=0
nt=18 nt=18
ntheta=4 ntheta=4
elseif(ndeep.eq.3) then elseif(ndeep.eq.3) then
nord=1 nord=1
npre1=1 npre1=1
npre2=0 npre2=0
nt=12 nt=12
ntheta=4 ntheta=4
elseif(ndeep.eq.4) then elseif(ndeep.eq.4) then
nord=1 nord=1
npre1=1 npre1=1
npre2=1 npre2=1
nt=12 nt=12
ntheta=4 ntheta=4
ntau=15 ntau=15
elseif(ndeep.eq.5) then elseif(ndeep.eq.5) then
nord=1 nord=1
npre1=1 npre1=1
npre2=1 npre2=1
nt=12 nt=12
ntheta=4 ntheta=4
ntau=5 ntau=5
endif endif
do iorder=1,nord do iorder=1,nord
misub(1:K-iorder)=0 misub(1:K-iorder)=0
misub(K-iorder+1:K)=1 misub(K-iorder+1:K)=1
iflag=K-iorder+1 iflag=K-iorder+1
do while(iflag .ge.0) do while(iflag .ge.0)
if(iorder.eq.nord .and. npre1.eq.0) then if(iorder.eq.nord .and. npre1.eq.0) then
iend=iflag iend=iflag
else else
iend=1 iend=1
endif endif
do n1=iflag,iend,-1 do n1=iflag,iend,-1
mi=misub mi=misub
mi(n1)=1 mi(n1)=1
if(any(iand(apmaskr(1:K),mi).eq.1)) cycle if(any(iand(apmaskr(1:K),mi).eq.1)) cycle
ntotal=ntotal+1 ntotal=ntotal+1
me=ieor(m0,mi) me=ieor(m0,mi)
if(n1.eq.iflag) then if(n1.eq.iflag) then
call mrbencode90(me,ce,g2,N,K) call mrbencode90(me,ce,g2,N,K)
e2sub=ieor(ce(K+1:N),hdec(K+1:N)) e2sub=ieor(ce(K+1:N),hdec(K+1:N))
e2=e2sub e2=e2sub
nd1Kpt=sum(e2sub(1:nt))+1 nd1Kpt=sum(e2sub(1:nt))+1
d1=sum(ieor(me(1:K),hdec(1:K))*absrx(1:K)) d1=sum(ieor(me(1:K),hdec(1:K))*absrx(1:K))
else else
e2=ieor(e2sub,g2(K+1:N,n1)) e2=ieor(e2sub,g2(K+1:N,n1))
nd1Kpt=sum(e2(1:nt))+2 nd1Kpt=sum(e2(1:nt))+2
endif endif
if(nd1Kpt .le. ntheta) then if(nd1Kpt .le. ntheta) then
call mrbencode90(me,ce,g2,N,K) call mrbencode90(me,ce,g2,N,K)
nxor=ieor(ce,hdec) nxor=ieor(ce,hdec)
if(n1.eq.iflag) then if(n1.eq.iflag) then
dd=d1+sum(e2sub*absrx(K+1:N)) dd=d1+sum(e2sub*absrx(K+1:N))
else else
dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(K+1:N)) dd=d1+ieor(ce(n1),hdec(n1))*absrx(n1)+sum(e2*absrx(K+1:N))
endif endif
if( dd .lt. dmin ) then if( dd .lt. dmin ) then
dmin=dd dmin=dd
cw=ce cw=ce
nhardmin=sum(nxor) nhardmin=sum(nxor)
nd1Kptbest=nd1Kpt nd1Kptbest=nd1Kpt
endif endif
else else
nrejected=nrejected+1 nrejected=nrejected+1
endif endif
enddo enddo
! Get the next test error pattern, iflag will go negative ! Get the next test error pattern, iflag will go negative
! when the last pattern with weight iorder has been generated. ! when the last pattern with weight iorder has been generated.
call nextpat90(misub,k,iorder,iflag) call nextpat90(misub,k,iorder,iflag)
enddo enddo
enddo enddo
if(npre2.eq.1) then if(npre2.eq.1) then
reset=.true. reset=.true.
ntotal=0 ntotal=0
do i1=K,1,-1 do i1=K,1,-1
do i2=i1-1,1,-1 do i2=i1-1,1,-1
ntotal=ntotal+1 ntotal=ntotal+1
mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2)) mi(1:ntau)=ieor(g2(K+1:K+ntau,i1),g2(K+1:K+ntau,i2))
call boxit90(reset,mi(1:ntau),ntau,ntotal,i1,i2) call boxit90(reset,mi(1:ntau),ntau,ntotal,i1,i2)
enddo enddo
enddo enddo
ncount2=0 ncount2=0
ntotal2=0 ntotal2=0
reset=.true. reset=.true.
! Now run through again and do the second pre-processing rule ! Now run through again and do the second pre-processing rule
misub(1:K-nord)=0 misub(1:K-nord)=0
misub(K-nord+1:K)=1 misub(K-nord+1:K)=1
iflag=K-nord+1 iflag=K-nord+1
do while(iflag .ge.0) do while(iflag .ge.0)
me=ieor(m0,misub) me=ieor(m0,misub)
call mrbencode90(me,ce,g2,N,K) call mrbencode90(me,ce,g2,N,K)
e2sub=ieor(ce(K+1:N),hdec(K+1:N)) e2sub=ieor(ce(K+1:N),hdec(K+1:N))
do i2=0,ntau do i2=0,ntau
ntotal2=ntotal2+1 ntotal2=ntotal2+1
ui=0 ui=0
if(i2.gt.0) ui(i2)=1 if(i2.gt.0) ui(i2)=1
r2pat=ieor(e2sub,ui) r2pat=ieor(e2sub,ui)
778 continue 778 continue
call fetchit90(reset,r2pat(1:ntau),ntau,in1,in2) call fetchit90(reset,r2pat(1:ntau),ntau,in1,in2)
if(in1.gt.0.and.in2.gt.0) then if(in1.gt.0.and.in2.gt.0) then
ncount2=ncount2+1 ncount2=ncount2+1
mi=misub mi=misub
mi(in1)=1 mi(in1)=1
mi(in2)=1 mi(in2)=1
if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle if(sum(mi).lt.nord+npre1+npre2.or.any(iand(apmaskr(1:K),mi).eq.1)) cycle
me=ieor(m0,mi) me=ieor(m0,mi)
call mrbencode90(me,ce,g2,N,K) call mrbencode90(me,ce,g2,N,K)
nxor=ieor(ce,hdec) nxor=ieor(ce,hdec)
dd=sum(nxor*absrx) dd=sum(nxor*absrx)
if( dd .lt. dmin ) then if( dd .lt. dmin ) then
dmin=dd dmin=dd
cw=ce cw=ce
nhardmin=sum(nxor) nhardmin=sum(nxor)
endif endif
goto 778 goto 778
endif endif
enddo enddo
call nextpat90(misub,K,nord,iflag) call nextpat90(misub,K,nord,iflag)
enddo enddo
endif endif
998 continue 998 continue
! Re-order the codeword to [message bits][parity bits] format. ! Re-order the codeword to [message bits][parity bits] format.
cw(indices)=cw cw(indices)=cw
hdec(indices)=hdec hdec(indices)=hdec
decoded=cw(1:K) decoded=cw(1:K)
call chkcrc13a(decoded,nbadcrc) call chkcrc13a(decoded,nbadcrc)
message77=decoded(1:77) message77=decoded(1:77)
if(nbadcrc.eq.1) nhardmin=-nhardmin if(nbadcrc.eq.1) nhardmin=-nhardmin
return return
end subroutine osd128_90 end subroutine osd128_90
subroutine mrbencode90(me,codeword,g2,N,K) subroutine mrbencode90(me,codeword,g2,N,K)
integer*1 me(K),codeword(N),g2(N,K) integer*1 me(K),codeword(N),g2(N,K)
! fast encoding for low-weight test patterns ! fast encoding for low-weight test patterns
codeword=0 codeword=0
do i=1,K do i=1,K
if( me(i) .eq. 1 ) then if( me(i) .eq. 1 ) then
codeword=ieor(codeword,g2(1:N,i)) codeword=ieor(codeword,g2(1:N,i))
endif endif
enddo enddo
return return
end subroutine mrbencode90 end subroutine mrbencode90
subroutine nextpat90(mi,k,iorder,iflag) subroutine nextpat90(mi,k,iorder,iflag)
@ -274,8 +279,8 @@ subroutine nextpat90(mi,k,iorder,iflag)
if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i if( mi(i).eq.0 .and. mi(i+1).eq.1) ind=i
enddo enddo
if( ind .lt. 0 ) then ! no more patterns of this order if( ind .lt. 0 ) then ! no more patterns of this order
iflag=ind iflag=ind
return return
endif endif
ms=0 ms=0
ms(1:ind-1)=mi(1:ind-1) ms(1:ind-1)=mi(1:ind-1)
@ -287,45 +292,45 @@ subroutine nextpat90(mi,k,iorder,iflag)
endif endif
mi=ms mi=ms
do i=1,k ! iflag will point to the lowest-index 1 in mi do i=1,k ! iflag will point to the lowest-index 1 in mi
if(mi(i).eq.1) then if(mi(i).eq.1) then
iflag=i iflag=i
exit exit
endif endif
enddo enddo
return return
end subroutine nextpat90 end subroutine nextpat90
subroutine boxit90(reset,e2,ntau,npindex,i1,i2) subroutine boxit90(reset,e2,ntau,npindex,i1,i2)
integer*1 e2(1:ntau) integer*1 e2(1:ntau)
integer indexes(5000,2),fp(0:525000),np(5000) integer indexes(5000,2),fp(0:525000),np(5000)
logical reset logical reset
common/boxes/indexes,fp,np common/boxes/indexes,fp,np
if(reset) then if(reset) then
patterns=-1 patterns=-1
fp=-1 fp=-1
np=-1 np=-1
sc=-1 sc=-1
indexes=-1 indexes=-1
reset=.false. reset=.false.
endif endif
indexes(npindex,1)=i1 indexes(npindex,1)=i1
indexes(npindex,2)=i2 indexes(npindex,2)=i2
ipat=0 ipat=0
do i=1,ntau do i=1,ntau
if(e2(i).eq.1) then if(e2(i).eq.1) then
ipat=ipat+ishft(1,ntau-i) ipat=ipat+ishft(1,ntau-i)
endif endif
enddo enddo
ip=fp(ipat) ! see what's currently stored in fp(ipat) ip=fp(ipat) ! see what's currently stored in fp(ipat)
if(ip.eq.-1) then if(ip.eq.-1) then
fp(ipat)=npindex fp(ipat)=npindex
else else
do while (np(ip).ne.-1) do while (np(ip).ne.-1)
ip=np(ip) ip=np(ip)
enddo enddo
np(ip)=npindex np(ip)=npindex
endif endif
return return
@ -340,15 +345,15 @@ subroutine fetchit90(reset,e2,ntau,i1,i2)
save lastpat,inext save lastpat,inext
if(reset) then if(reset) then
lastpat=-1 lastpat=-1
reset=.false. reset=.false.
endif endif
ipat=0 ipat=0
do i=1,ntau do i=1,ntau
if(e2(i).eq.1) then if(e2(i).eq.1) then
ipat=ipat+ishft(1,ntau-i) ipat=ipat+ishft(1,ntau-i)
endif endif
enddo enddo
index=fp(ipat) index=fp(ipat)
@ -368,4 +373,3 @@ subroutine fetchit90(reset,e2,ntau,i1,i2)
lastpat=ipat lastpat=ipat
return return
end subroutine fetchit90 end subroutine fetchit90

View File

@ -1,4 +1,4 @@
subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & subroutine qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
emedelay,mycall_12,hiscall_12,hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft) emedelay,mycall_12,hiscall_12,hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft)
use packjt use packjt
@ -151,8 +151,5 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
endif endif
call timer('qra64a ',1) call timer('qra64a ',1)
! write(71,3001) nutc,dtx,f0,sync,sync2,width,minsync,decoded
!3001 format(i4.4,f7.2,4f8.1,i3,2x,a22)
return return
end subroutine qra64a end subroutine qra64a

View File

@ -39,7 +39,7 @@ program qratest
if(nfqso0.ne.-1) nfqso=nfqso0 if(nfqso0.ne.-1) nfqso=nfqso0
if(ntol0.ne.-1) ntol=ntol0 if(ntol0.ne.-1) ntol=ntol0
call qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & call qra64a(dd,npts,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, &
mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft) mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft)
c='a' c='a'
if(mode64.eq.2) c='b' if(mode64.eq.2) c='b'