Finish writing a usable version of program qra64code.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7328 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-11-21 21:23:48 +00:00
parent 120b2ea151
commit 5e90bd6d42

View File

@ -2,126 +2,65 @@ program QRA64code
! Provides examples of message packing, bit and symbol ordering, ! Provides examples of message packing, bit and symbol ordering,
! QRA (63,12) encoding, and other necessary details of the QRA64 ! QRA (63,12) encoding, and other necessary details of the QRA64
! protocol. Also permits simple simulations to measure performance ! protocol.
! on an AWGN channel with secure time and frequency synchronization.
! Return codes from qra64_dec:
! irc=0 [? ? ?] AP0 (decoding with no a-priori information)
! irc=1 [CQ ? ?] AP27
! irc=2 [CQ ? ] AP42
! irc=3 [CALL ? ?] AP29
! irc=4 [CALL ? ] AP44
! irc=5 [CALL CALL ?] AP57
use packjt use packjt
character*22 msg,msg0,msg1,decoded,cok*3,msgtype*10,arg*12 character*22 msg,msg0,msg1,decoded,cok*3,msgtype*10,arg*12
character*6 mycall character*6 mycall
logical ltext logical ltext
integer dgen(12),sent(63),dec(12) integer dgen(12),sent(63),dec(12)
real s3(0:63,1:63) integer icos7(0:6)
data icos7/2,5,6,0,4,1,3/ !Defines a 7x7 Costas array
include 'testmsg.f90' include 'testmsg.f90'
nargs=iargc() nargs=iargc()
if(nargs.lt.1) then if(nargs.lt.1) then
print*,'Usage: qra64code "message" [snr2500] [Nrpt]' print*,'Usage: qra64code "message"'
print*,' qra64code -t [snr2500]' print*,' qra64code -t'
go to 999 go to 999
endif endif
call getarg(1,msg) !Get message from command line call getarg(1,msg) !Get message from command line
snr2500=10.0
if(nargs.ge.2) then
call getarg(2,arg)
read(arg,*) snr2500
endif
sig=sqrt(2.0)*10.0**(0.05*(snr2500+29.7))
nmsg=1 nmsg=1
nrpt=1 if(msg(1:2).eq."-t") nmsg=NTEST
if(msg(1:2).eq."-t") then
nmsg=NTEST
else
if(nargs.ge.3) then
call getarg(3,arg)
read(arg,*) nrpt
endif
endif
write(*,1010) write(*,1010)
1010 format(" Message Decoded Err? Type rc"/77("-")) 1010 format(" Message Decoded Err? Type"/74("-"))
ngood=0 do imsg=1,nmsg
nbad=0 if(nmsg.gt.1) msg=testmsg(imsg)
do nn=1,nrpt call fmtmsg(msg,iz) !To upper, collapse mult blanks
do imsg=1,nmsg msg0=msg !Input message
if(nmsg.gt.1) msg=testmsg(imsg) call chkmsg(msg,cok,nspecial,flip) !See if it includes "OOO" report
call fmtmsg(msg,iz) !To upper, collapse mult blanks msg1=msg !Message without "OOO"
msg0=msg !Input message call packmsg(msg1,dgen,itype) !Pack message into 12 six-bit bytes
call chkmsg(msg,cok,nspecial,flip) !See if it includes "OOO" report msgtype=""
msg1=msg !Message without "OOO" if(itype.eq.1) msgtype="Std Msg"
call packmsg(msg1,dgen,itype) !Pack message into 12 six-bit bytes if(itype.eq.2) msgtype="Type 1 pfx"
msgtype="" if(itype.eq.3) msgtype="Type 1 sfx"
if(itype.eq.1) msgtype="Std Msg" if(itype.eq.4) msgtype="Type 2 pfx"
if(itype.eq.2) msgtype="Type 1 pfx" if(itype.eq.5) msgtype="Type 2 sfx"
if(itype.eq.3) msgtype="Type 1 sfx" if(itype.eq.6) msgtype="Free text"
if(itype.eq.4) msgtype="Type 2 pfx"
if(itype.eq.5) msgtype="Type 2 sfx"
if(itype.eq.6) msgtype="Free text"
call qra64_enc(dgen,sent) !Encode using QRA64 call qra64_enc(dgen,sent) !Encode using QRA64
! Generate a simulated s3() array with moderately high S/N call unpackmsg(dgen,decoded) !Unpack the user message
do j=1,63 call fmtmsg(decoded,iz)
do i=0,63 ii=imsg
x=gran() write(*,1020) ii,msg0,decoded,itype,msgtype
y=gran() 1020 format(i4,1x,a22,2x,a22,4x,i3,": ",a13)
s3(i,j)=x*x + y*y
enddo
k=sent(j)
x=gran() + sig
y=gran()
s3(k,j)=x*x + y*y
enddo
i1=index(msg1,' ')
mycall=' '
if(i1.ge.4) mycall=msg(1:i1-1)
call packcall(mycall,nmycall,ltext)
call qra64_dec(s3,nmycall,dec,snr,irc) !Decode
decoded=" "
if(irc.ge.0) then
call unpackmsg(dec,decoded) !Unpack the user message
call fmtmsg(decoded,iz)
else
dec=0
endif
if(decoded.eq.msg0) then
ngood=ngood+1
else
if(irc.ge.0) nbad=nbad+1
endif
ii=imsg
if(nrpt.gt.1) ii=nn
write(*,1020) ii,msg0,decoded,itype,msgtype,irc
1020 format(i4,1x,a22,2x,a22,4x,i3,": ",a13,i3)
enddo
if(nmsg.eq.1 .and.nrpt.eq.1) then
write(*,1030) dgen
1030 format(/'Packed message, 6-bit symbols ',12i3) !Display packed symbols
write(*,1040) sent
1040 format(/'Information-carrying channel symbols'/(i5,20i3))
write(*,1050) dec
1050 format(/'Received message, 6-bit symbols ',12i3) !Display packed symbols
endif
enddo enddo
if(nrpt.gt.1) then if(nmsg.eq.1) then
write(*,1060) ngood,nrpt,nbad write(*,1030) dgen
1060 format('Decoded messages:',i5,'/',i4,' Undetected errors:',i5) 1030 format(/'Packed message, 6-bit symbols: ',12i3) !Display packed symbols
endif
write(*,1040) sent
1040 format(/'Information-carrying channel symbols:'/(i5,29i3))
write(*,1050) 10*icos7,sent(1:32),10*icos7,sent(33:63),10*icos7
1050 format(/'Channel symbols including sync:'/(i5,29i3))
endif
999 end program QRA64code 999 end program QRA64code