diff options
| author | Christoph Berg <myon@debian.org> | 2021-09-09 22:49:00 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2021-09-09 22:49:00 +0200 |
| commit | 85895feeaf88bcde26bbfc71e8f6b2047c0f5f41 (patch) | |
| tree | 79807e00771e4af4ce279e368262f2222806102f /lib | |
| parent | 2f095a04ed69d9aa14b47dc4acde6b3225b2d65e (diff) | |
New upstream version 2.5.0~rc6+repackupstream/2.5.0_rc6+repack
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/77bit/messages.txt | 4 | ||||
| -rw-r--r-- | lib/77bit/packjt77.f90 | 3 | ||||
| -rw-r--r-- | lib/calibrate.f90 | 4 | ||||
| -rw-r--r-- | lib/decode65a.f90 | 8 | ||||
| -rw-r--r-- | lib/decoder.f90 | 5 | ||||
| -rw-r--r-- | lib/encode_rs.c | 17 | ||||
| -rw-r--r-- | lib/fast_decode.f90 | 1 | ||||
| -rw-r--r-- | lib/fst4_decode.f90 | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/ft2/portaudio.h | 0 | ||||
| -rw-r--r-- | lib/ftrsd/ftrsd2.c | 4 | ||||
| -rw-r--r-- | lib/hspec.f90 | 2 | ||||
| -rw-r--r-- | lib/init_rs.c | 14 | ||||
| -rw-r--r-- | lib/jt9.f90 | 9 | ||||
| -rw-r--r-- | lib/jt9a.f90 | 3 | ||||
| -rw-r--r-- | lib/jt9com.f90 | 1 | ||||
| -rw-r--r-- | lib/map65_mmdec.f90 | 95 | ||||
| -rw-r--r-- | lib/msk144signalquality.f90 | 6 | ||||
| -rw-r--r-- | lib/mskrtd.f90 | 2 | ||||
| -rw-r--r-- | lib/q65_decode.f90 | 47 | ||||
| -rw-r--r-- | lib/qra/q65/q65.c | 21 | ||||
| -rw-r--r-- | lib/qra/q65/q65.f90 | 140 | ||||
| -rw-r--r-- | lib/qra/q65/q65_encoding_modules.f90 | 223 | ||||
| -rw-r--r-- | lib/qra/q65/q65_loops.f90 | 32 | ||||
| -rw-r--r-- | lib/qra/q65/q65code.f90 | 29 | ||||
| -rw-r--r-- | lib/qra/q65/qra15_65_64_irr_e23.c | 3 | ||||
| -rw-r--r-- | lib/spec64.f90 | 11 | ||||
| -rw-r--r-- | lib/symspec.f90 | 32 | ||||
| -rw-r--r-- | lib/test_q65.f90 | 20 | ||||
| -rw-r--r-- | lib/twkfreq.f90 | 4 | ||||
| -rw-r--r-- | lib/wsprd/wsprd.c | 1 |
30 files changed, 565 insertions, 178 deletions
diff --git a/lib/77bit/messages.txt b/lib/77bit/messages.txt index 2100ae39..d84bba2c 100644 --- a/lib/77bit/messages.txt +++ b/lib/77bit/messages.txt @@ -94,3 +94,7 @@ KA1ABC/VEX 37 <W3CCX/P> <K1JT> 590001 FN20QI <W3CCX/P> <K1JT/P> 590001 FN20QI <W3CCX/QRP> <K1JT/QRO> 590001 FN20QI +CQ OE21FTDMC +K9AN K1JT R- +K9AN K1JT R+ +K1AN K1JT WXY diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90 index aec73c68..b8a4ac42 100644 --- a/lib/77bit/packjt77.f90 +++ b/lib/77bit/packjt77.f90 @@ -1118,7 +1118,7 @@ subroutine pack77_1(nwords,w,i3,n3,c77) irpt=irpt+35 else if(c2.eq.'R+' .or. c2.eq.'R-') then ir=1 - read(w(nwords)(2:),*) irpt + read(w(nwords)(2:),*,err=900) irpt if(irpt.ge.-50 .and. irpt.le.-31) irpt=irpt+101 irpt=irpt+35 else if(trim(w(nwords)).eq.'RRR') then @@ -1276,6 +1276,7 @@ subroutine pack77_4(nwords,w,i3,n3,c77) if(call_2(1:1).eq.'<') call_2=w(2)(2:len(trim(w(2)))-1) call chkcall(call_1,bcall_1,ok1) call chkcall(call_2,bcall_2,ok2) + if(call_1.eq.bcall_1 .and. call_2.eq.bcall_2 .and. ok1 .and. ok2) go to 900 icq=0 if(trim(w(1)).eq.'CQ' .or. (ok1.and.ok2)) then if(trim(w(1)).eq.'CQ' .and. len(trim(w(2))).le.4) go to 900 diff --git a/lib/calibrate.f90 b/lib/calibrate.f90 index a27c400a..76e70f2b 100644 --- a/lib/calibrate.f90 +++ b/lib/calibrate.f90 @@ -12,8 +12,8 @@ subroutine calibrate(data_dir,iz,a,b,rms,sigmaa,sigmab,irc) real*8 fd(NZ),deltaf(NZ),r(NZ),rmsd(NZ) integer nn(NZ) - infile=trim(data_dir)//'fmt.all' - outfile=trim(data_dir)//'fcal2.out' + infile=trim(data_dir)//'/'//'fmt.all' + outfile=trim(data_dir)//'/'//'fcal2.out' open(10,file=trim(infile),status='old',err=996) open(12,file=trim(outfile),status='unknown',err=997) diff --git a/lib/decode65a.f90 b/lib/decode65a.f90 index ec9fbd31..3b82178b 100644 --- a/lib/decode65a.f90 +++ b/lib/decode65a.f90 @@ -41,9 +41,7 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, & if(nflip.eq.0) go to 900
! Find best DF, drift, curvature, and DT. Start by downsampling to 344.53125 Hz
- call timer('fil6521 ',0)
call fil6521(cx,n5,c5x,n6)
- call timer('fil6521 ',1)
fsample=1378.125/4.
@@ -60,10 +58,8 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, & ! Apply AFC corrections to the time-domain signal
! Now we are back to using the 1378.125 Hz sample rate, enough to
! accommodate the full JT65C bandwidth.
- a(3)=0
- call timer('twkfreq ',0)
+ a(3)=0
call twkfreq65(cx,n5,a)
- call timer('twkfreq ',1)
! Compute spectrum for each symbol.
nsym=126
@@ -71,7 +67,6 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, & df=1378.125/nfft
j=int(dtbest*1378.125)
- call timer('sh_ffts ',0)
c5a=cmplx(0.0,0.0)
do k=1,nsym
do i=1,nfft
@@ -89,7 +84,6 @@ subroutine decode65a(dd,npts,newdat,nqd,f0,nflip,mode65,ntrials, & s1(jj,k)=real(c5a(i))**2 + aimag(c5a(i))**2
enddo
enddo
- call timer('sh_ffts ',1)
call timer('dec65b ',0)
qualbest=0.
diff --git a/lib/decoder.f90 b/lib/decoder.f90 index d1a53009..1e2eba9c 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -205,10 +205,11 @@ subroutine multimode_decoder(ss,id2,params,nfsample) open(17,file=trim(temp_dir)//'/red.dat',status='unknown') open(14,file=trim(temp_dir)//'/avemsg.txt',status='unknown') call timer('dec_q65 ',0) - call my_q65%decode(q65_decoded,id2,params%nutc,params%ntr, & + nqd=1 + call my_q65%decode(q65_decoded,id2,nqd,params%nutc,params%ntr, & params%nsubmode,params%nfqso,params%ntol,params%ndepth, & params%nfa,params%nfb,logical(params%nclearave), & - single_decode,logical(params%nagain), & + single_decode,logical(params%nagain),params%max_drift, & logical(params%newdat),params%emedelay,mycall,hiscall,hisgrid, & params%nQSOProgress,ncontest,logical(params%lapcqonly),navg0) call timer('dec_q65 ',1) diff --git a/lib/encode_rs.c b/lib/encode_rs.c index 911bc36d..9d56d0bf 100644 --- a/lib/encode_rs.c +++ b/lib/encode_rs.c @@ -13,24 +13,19 @@ #endif void ENCODE_RS( -#ifdef FIXED -DTYPE *data, DTYPE *bb,int pad){ -#else -void *p,DTYPE *data, DTYPE *bb){ +#ifndef FIXED +void *p, +#endif +DTYPE *data, DTYPE *bb){ +#ifndef FIXED struct rs *rs = (struct rs *)p; #endif int i, j; DTYPE feedback; -#ifdef FIXED - /* Check pad parameter for validity */ - if(pad < 0 || pad >= NN) - return; -#endif - memset(bb,0,NROOTS*sizeof(DTYPE)); - for(i=0;i<NN-NROOTS-PAD;i++){ + for(i=0;i<NN-NROOTS;i++){ feedback = INDEX_OF[data[i] ^ bb[0]]; if(feedback != A0){ /* feedback term is non-zero */ #ifdef UNNORMALIZED diff --git a/lib/fast_decode.f90 b/lib/fast_decode.f90 index 30384b0a..c4326cba 100644 --- a/lib/fast_decode.f90 +++ b/lib/fast_decode.f90 @@ -9,7 +9,6 @@ subroutine fast_decode(id2,narg,trperiod,line,mycall_12, & double precision trperiod real dat(30*12000) complex cdat(262145),cdat2(262145) - real psavg(450) logical pick,first character*6 cfile6 character*80 line(100) diff --git a/lib/fst4_decode.f90 b/lib/fst4_decode.f90 index 64fc207d..38e8a15b 100644 --- a/lib/fst4_decode.f90 +++ b/lib/fst4_decode.f90 @@ -630,7 +630,7 @@ contains close(42) endif -900 return + return end subroutine decode subroutine sync_fst4(cd0,i0,f0,hmod,ncoh,np,nss,ntr,fs,sync) diff --git a/lib/ft2/portaudio.h b/lib/ft2/portaudio.h index 250fba02..250fba02 100644..100755 --- a/lib/ft2/portaudio.h +++ b/lib/ft2/portaudio.h diff --git a/lib/ftrsd/ftrsd2.c b/lib/ftrsd/ftrsd2.c index 6da9b417..7d8dd366 100644 --- a/lib/ftrsd/ftrsd2.c +++ b/lib/ftrsd/ftrsd2.c @@ -38,7 +38,7 @@ void ftrsd2_(int mrsym[], int mrprob[], int mr2sym[], int mr2prob[], int nera_best=0; float pp,pp1,pp2; static unsigned int nseed; - + // Power-percentage symbol metrics - composite gnnf/hf int perr[8][8] = { { 4, 9, 11, 13, 14, 14, 15, 15}, @@ -203,7 +203,7 @@ NB: j is the symbol-vector index of the symbol with rank i. param[1]=nhard_min; param[2]=nsoft_min; param[3]=nera_best; - param[4]=1000.0*pp2/pp1; + param[4]= pp1 > 0 ? 1000.0*pp2/pp1 : 1000.0; param[5]=ntotal_min; param[6]=ntry[0]; param[7]=1000.0*pp2; diff --git a/lib/hspec.f90 b/lib/hspec.f90 index 144ddf19..b30f4a09 100644 --- a/lib/hspec.f90 +++ b/lib/hspec.f90 @@ -20,7 +20,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144, & parameter (JZ=703) character*80 line1 - character*512 datadir + character*(*) datadir character*12 mycall,hiscall integer*2 id2(0:120*12000-1) logical*1 bmsk144,bshmsg,btrain,bswl diff --git a/lib/init_rs.c b/lib/init_rs.c index a8052365..876819f8 100644 --- a/lib/init_rs.c +++ b/lib/init_rs.c @@ -28,10 +28,9 @@ void FREE_RS(void *p){ * fcr = first root of RS code generator polynomial, index form * prim = primitive element to generate polynomial roots * nroots = RS code generator polynomial degree (number of roots) - * pad = padding bytes at front of shortened block */ -void *INIT_RS(int symsize,int gfpoly,int fcr,int prim, - int nroots,int pad){ +void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned fcr,unsigned prim, + unsigned int nroots){ struct rs *rs; int i, j, sr,root,iprim; @@ -39,19 +38,16 @@ void *INIT_RS(int symsize,int gfpoly,int fcr,int prim, if(symsize < 0 || symsize > (int)(8*sizeof(DTYPE))) return NULL; /* Need version with ints rather than chars */ - if(fcr < 0 || fcr >= (1<<symsize)) + if(fcr >= (1<<symsize)) return NULL; - if(prim <= 0 || prim >= (1<<symsize)) + if(prim == 0 || prim >= (1<<symsize)) return NULL; - if(nroots < 0 || nroots >= (1<<symsize)) + if(nroots >= (1<<symsize)) return NULL; /* Can't have more roots than symbol values! */ - if(pad < 0 || pad >= ((1<<symsize) -1 - nroots)) - return NULL; /* Too much padding */ rs = (struct rs *)calloc(1,sizeof(struct rs)); rs->mm = symsize; rs->nn = (1<<symsize)-1; - rs->pad = pad; rs->alpha_to = (DTYPE *)malloc(sizeof(DTYPE)*(rs->nn+1)); if(rs->alpha_to == NULL){ diff --git a/lib/jt9.f90 b/lib/jt9.f90 index e07fd742..3bfac672 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -20,7 +20,7 @@ program jt9 real*8 TRperiod character c character(len=500) optarg, infile - character wisfile*80 + character wisfile*256 !### ndepth was defined as 60001. Why??? integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & fhigh=4000,nrxfreq=1500,ndepth=1,nexp_decode=0,nQSOProg=0 @@ -301,6 +301,9 @@ program jt9 shared_data%params%napwid=75 shared_data%params%dttol=3. if(mode.eq.164 .and. nsubmode.lt.100) nsubmode=nsubmode+100 + shared_data%params%nagain=.false. + shared_data%params%nclearave=.false. + shared_data%params%lapcqonly=.false. shared_data%params%naggressive=0 shared_data%params%n2pass=2 shared_data%params%nQSOprogress=nQSOProg @@ -322,6 +325,10 @@ program jt9 shared_data%params%nmode=mode end if shared_data%params%nsubmode=nsubmode + +!### temporary, for MAP65: + if(mode.eq.66 .and. TRperiod.eq.60) shared_data%params%emedelay=2.5 + datetime="2013-Apr-16 15:13" !### Temp shared_data%params%datetime=transfer(datetime,shared_data%params%datetime) if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit diff --git a/lib/jt9a.f90 b/lib/jt9a.f90 index b0df912c..f9399f4a 100644 --- a/lib/jt9a.f90 +++ b/lib/jt9a.f90 @@ -55,7 +55,8 @@ subroutine jt9a() if(.not.ok) call abort call flush(6) call timer('decoder ',0) - if(local_params%nmode.eq.8 .and. local_params%ndiskdat) then + if(local_params%nmode.eq.8 .and. local_params%ndiskdat .and. & + .not. local_params%nagain) then ! Early decoding pass, FT8 only, when wsjtx reads from disk nearly=41 local_params%nzhsym=nearly diff --git a/lib/jt9com.f90 b/lib/jt9com.f90 index 3a6b8759..5b2970c0 100644 --- a/lib/jt9com.f90 +++ b/lib/jt9com.f90 @@ -41,6 +41,7 @@ integer(c_int) :: naggressive logical(c_bool) :: nrobust integer(c_int) :: nexp_decode + integer(c_int) :: max_drift character(kind=c_char) :: datetime(20) character(kind=c_char) :: mycall(12) character(kind=c_char) :: mygrid(6) diff --git a/lib/map65_mmdec.f90 b/lib/map65_mmdec.f90 new file mode 100644 index 00000000..ca9f959e --- /dev/null +++ b/lib/map65_mmdec.f90 @@ -0,0 +1,95 @@ +subroutine map65_mmdec(nutc,id2,nqd,nsubmode,nfa,nfb,nfqso,ntol,newdat, & + nagain,max_drift,mycall,hiscall,hisgrid) + + use prog_args + use timer_module, only: timer + use q65_decode + + include 'jt9com.f90' + include 'timer_common.inc' + + type, extends(q65_decoder) :: counting_q65_decoder + integer :: decoded + end type counting_q65_decoder + + logical single_decode,bVHF,lnewdat,lagain,lclearave,lapcqonly + integer*2 id2(300*12000) +! type(params_block) :: params + character(len=20) :: datetime + character(len=12) :: mycall, hiscall + character(len=6) :: hisgrid + data ntr0/-1/ + save + type(counting_q65_decoder) :: my_q65 + +! Cast C character arrays to Fortran character strings +! datetime=transfer(params%datetime, datetime) +! mycall=transfer(params%mycall,mycall) +! hiscall=transfer(params%hiscall,hiscall) +! mygrid=transfer(params%mygrid,mygrid) +! hisgrid=transfer(params%hisgrid,hisgrid) + datetime=' ' + + my_q65%decoded = 0 + ncontest=0 + nQSOprogress=0 + lclearave=.false. + single_decode=.false. + lapcqonly=.false. + lnewdat=(newdat.ne.0) + lagain=(nagain.ne.0) + bVHF=.true. + emedelay=2.5 + ndepth=1 + ntrperiod=60 + + open(17,file=trim(temp_dir)//'/red.dat',status='unknown') + open(14,file=trim(temp_dir)//'/avemsg.txt',status='unknown') + + call timer('dec_q65 ',0) + call my_q65%decode(q65_decoded,id2,nqd,nutc,ntrperiod,nsubmode,nfqso, & + ntol,ndepth,nfa,nfb,lclearave,single_decode,lagain,max_drift,lnewdat, & + emedelay,mycall,hiscall,hisgrid,nQSOProgress,ncontest,lapcqonly,navg0) + call timer('dec_q65 ',1) + + return + +contains + + subroutine q65_decoded (this,nutc,snr1,nsnr,dt,freq,decoded,idec, & + nused,ntrperiod) + + use q65_decode + implicit none + + class(q65_decoder), intent(inout) :: this + integer, intent(in) :: nutc + real, intent(in) :: snr1 + integer, intent(in) :: nsnr + real, intent(in) :: dt + real, intent(in) :: freq + character(len=37), intent(in) :: decoded + integer, intent(in) :: idec + integer, intent(in) :: nused + integer, intent(in) :: ntrperiod + + if(nutc+snr1+nsnr+dt+freq+idec+nused+ntrperiod.eq.-999) stop + if(decoded.eq.'-999') stop + + cq0='q ' + write(cq0(2:2),'(i1)') idec + if(nused.ge.2) write(cq0(3:3),'(i1)') nused + nsnr0=nsnr + xdt0=dt + nfreq0=nint(freq) + msg0=decoded + + select type(this) + type is (counting_q65_decoder) + if(idec.ge.0) this%decoded = this%decoded + 1 + end select + + return + end subroutine q65_decoded + +end subroutine map65_mmdec diff --git a/lib/msk144signalquality.f90 b/lib/msk144signalquality.f90 index 3caaa349..c2ba5f6c 100644 --- a/lib/msk144signalquality.f90 +++ b/lib/msk144signalquality.f90 @@ -9,7 +9,7 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & character*8 date character*10 time character*5 zone - character*512 datadir + character*(*) datadir complex cframe(864) complex cross(864) @@ -191,9 +191,7 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & write(pcoeff_filename,'(i2.2,i2.2,i2.2,"_",i2.2,i2.2,i2.2)') & values(1)-2000,values(2),values(3),values(5),values(6),values(7) pcoeff_filename=trim(trained_dxcall)//"_"//trim(pcoeff_filename)//".pcoeff" - l1=index(datadir,char(0))-1 - datadir(l1+1:l1+1)="/" - pcoeff_filename=datadir(1:l1+1)//trim(pcoeff_filename) + pcoeff_filename=datadir//'/'//trim(pcoeff_filename) !write(*,*) 'trained - writing coefficients to: ',pcoeff_filename open(17,file=pcoeff_filename,status='new') write(17,'(i4,2f10.2,3i5,5e25.16)') navg,sqrt(chisqr),rmsdiff,NFREQLOW,NFREQHIGH,nterms,a diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index 3bf62180..b2a5cbb8 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -19,7 +19,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,hiscall, & character*80 line !Formatted line with UTC dB T Freq Msg character*12 mycall,hiscall character*37 recent_shmsgs(NSHMEM) - character*512 datadir + character*(*) datadir complex cdat(NFFT1) !Analytic signal complex c(NSPM) !Coherently averaged complex data diff --git a/lib/q65_decode.f90 b/lib/q65_decode.f90 index 5acc15f5..cbe295ad 100644 --- a/lib/q65_decode.f90 +++ b/lib/q65_decode.f90 @@ -1,5 +1,9 @@ module q65_decode + integer nsnr0,nfreq0 + real xdt0 + character msg0*37,cq0*3 + type :: q65_decoder procedure(q65_decode_callback), pointer :: callback contains @@ -26,9 +30,10 @@ module q65_decode contains - subroutine decode(this,callback,iwave,nutc,ntrperiod,nsubmode,nfqso, & - ntol,ndepth,nfa0,nfb0,lclearave,single_decode,lagain,lnewdat0, & - emedelay,mycall,hiscall,hisgrid,nQSOprogress,ncontest,lapcqonly,navg0) + subroutine decode(this,callback,iwave,nqd0,nutc,ntrperiod,nsubmode,nfqso, & + ntol,ndepth,nfa0,nfb0,lclearave,single_decode,lagain,max_drift0, & + lnewdat0,emedelay,mycall,hiscall,hisgrid,nQSOprogress,ncontest, & + lapcqonly,navg0) ! Top-level routine that organizes the decoding of Q65 signals ! Input: iwave Raw data, i*2 @@ -67,15 +72,17 @@ contains integer dat4(13) !Decoded message as 12 6-bit integers integer dgen(13) logical lclearave,lnewdat0,lapcqonly,unpk77_success - logical single_decode,lagain,ex + logical single_decode,lagain complex, allocatable :: c00(:) !Analytic signal, 6000 Sa/s complex, allocatable :: c0(:) !Analytic signal, 6000 Sa/s - + ! Start by setting some parameters and allocating storage for large arrays call sec0(0,tdecode) nfa=nfa0 nfb=nfb0 + nqd=nqd0 lnewdat=lnewdat0 + max_drift=max_drift0 idec=-1 idf=0 idt=0 @@ -84,6 +91,7 @@ contains npts=ntrperiod*12000 nfft1=ntrperiod*12000 nfft2=ntrperiod*6000 + npasses=1 ! Determine the T/R sequence: iseq=0 (even), or iseq=1 (odd) n=nutc @@ -116,37 +124,40 @@ contains baud=12000.0/nsps this%callback => callback nFadingModel=1 - - inquire(file='ndepth.dat',exist=ex) - if(.not.ex) ndepth=iand(ndepth,not(3)) + 1 !Treat any ndepth as "Fast" - maxiters=67 + maxiters=33 ibwa=max(1,int(1.8*log(baud*mode_q65)) + 1) - ibwb=min(10,ibwa+4) + ibwb=min(10,ibwa+2) if(iand(ndepth,3).ge.2) then ibwa=max(1,int(1.8*log(baud*mode_q65)) + 1) ibwb=min(10,ibwa+5) + maxiters=67 else if(iand(ndepth,3).eq.3) then ibwa=max(1,ibwa-1) ibwb=min(10,ibwb+1) maxiters=100 endif - -! Generate codewords for full-AP list decoding - call q65_set_list(mycall,hiscall,hisgrid,codewords,ncw) +! Generate codewords for full-AP list decoding + if(ichar(hiscall(1:1)).eq.0) hiscall=' ' + if(ichar(hisgrid(1:1)).eq.0) hisgrid=' ' + ncw=0 + if(nqd.eq.1 .or. lagain) then + call q65_set_list(mycall,hiscall,hisgrid,codewords,ncw) + endif dgen=0 call q65_enc(dgen,codewords) !Initialize the Q65 codec - nused=1 iavg=0 call timer('q65_dec0',0) -! Call top-level routine in q65 module: establish sync and try for a q3 decode. +! Call top-level routine in q65 module: establish sync and try for a +! q3 or q0 decode. call q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & emedelay,xdt,f0,snr1,width,dat4,snr2,idec) -! idec=-1 !### TEMPORARY ### call timer('q65_dec0',1) +! write(*,3001) '=a',sum(abs(float(iwave))),nfqso,ntol,ndepth,xdt,f0,idec +!3001 format(a2,f15.0,3i5,f7.2,f7.1,i5) if(idec.ge.0) then - dtdec=xdt !We have a list-decode result at nfqso + dtdec=xdt !We have a q3 or q0 decode at nfqso f0dec=f0 go to 100 endif @@ -199,6 +210,7 @@ contains call q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & emedelay,xdt,f0,snr1,width,dat4,snr2,idec) call timer('list_avg',1) + if(idec.ge.0) then dtdec=xdt !We have a list-decode result from averaged data f0dec=f0 @@ -298,7 +310,6 @@ contains call timer('q65loops',0) call q65_loops(c00,npts/2,nsps/2,nsubmode,ndepth,jpk0, & xdt,f0,iaptype,xdt1,f1,snr2,dat4,idec) -! idec=-1 !### TEMPORARY ### call timer('q65loops',1) if(idec.ge.0) then dtdec=xdt1 diff --git a/lib/qra/q65/q65.c b/lib/qra/q65/q65.c index f7701792..10d756d8 100644 --- a/lib/qra/q65/q65.c +++ b/lib/qra/q65/q65.c @@ -434,11 +434,14 @@ int q65_intrinsics_fastfading(q65_codec_ds *pCodec, // exponentiate and accumulate the normalization constant sumix = 0.0f; - for (k=0;k<nM;k++) { - fTemp = expf(pCurIx[k]-maxlogp); - pCurIx[k]=fTemp; - sumix +=fTemp; - } + for (k=0;k<nM;k++) { + float x=pCurIx[k]-maxlogp; + if(x < -85.0) x=-85.0; + if(x > 85.0) x= 85.0; + fTemp = expf(x); + pCurIx[k]=fTemp; + sumix +=fTemp; + } // scale to a probability distribution sumix = 1.0f/sumix; @@ -663,9 +666,11 @@ int q65_check_llh(float *llh, const int* ydec, const int nN, const int nM, const float t = 0; for (k=0;k<nN;k++) { - t+=logf(pIntrin[ydec[k]]); - pIntrin+=nM; - } + float x=pIntrin[ydec[k]]; + if(x < 1.0e-36) x = 1.0e-36; + t+=logf(x); + pIntrin+=nM; + } if (llh!=NULL) *llh = t; diff --git a/lib/qra/q65/q65.f90 b/lib/qra/q65/q65.f90 index a85c3271..86cd15d5 100644 --- a/lib/qra/q65/q65.f90 +++ b/lib/qra/q65/q65.f90 @@ -10,8 +10,8 @@ module q65 integer,dimension(22) :: isync = (/1,9,12,13,15,22,23,26,27,33,35, & 38,46,50,55,60,62,66,69,74,76,85/) integer codewords(63,206) - integer ibwa,ibwb,ncw,nsps,mode_q65,nfa,nfb - integer idfbest,idtbest,ibw,ndistbest,maxiters + integer ibwa,ibwb,ncw,nsps,mode_q65,nfa,nfb,nqd + integer idfbest,idtbest,ibw,ndistbest,maxiters,max_drift integer istep,nsmo,lag1,lag2,npasses,nused,iseq,ncand,nrc integer i0,j0 integer navg(0:1) @@ -23,7 +23,7 @@ module q65 real, allocatable,save :: ccf2(:) !Max CCF(freq) at any lag, single seq real, allocatable,save :: ccf2_avg(:) !Like ccf2, but for accumulated average real sync(85) !sync vector - real df,dtstep,dtdec,f0dec,ftol,plog + real df,dtstep,dtdec,f0dec,ftol,plog,drift contains @@ -69,6 +69,7 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & data first/.true./ save first + NN=63 if(nutc+ndepth.eq.-999) stop !Silence compiler warnings ! Set some parameters and allocate storage for large arrays @@ -123,7 +124,7 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & dtstep=nsps/(NSTEP*12000.0) !Step size in seconds lag1=-1.0/dtstep lag2=1.0/dtstep + 0.9999 - if(nsps.ge.3600 .and. emedelay.gt.0) lag2=4.0/dtstep + 0.9999 !Include EME + if(nsps.ge.3600 .and. emedelay.gt.0) lag2=5.5/dtstep + 0.9999 !Include EME j0=0.5/dtstep if(nsps.ge.7200) j0=1.0/dtstep !Nominal start-signal index @@ -138,16 +139,17 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & endif i0=nint(nfqso/df) !Target QSO frequency - if(i0-64.lt.1 .or. i0-65+LL.gt.iz) go to 900 !Frequency out of range - call pctile(s1(i0-64:i0-65+LL,1:jz),LL*jz,45,base) + ii1=max(1,i0-64) + ii2=i0-65+LL + call pctile(s1(ii1:ii2,1:jz),ii2-ii1+1*jz,45,base) s1=s1/base s1raw=s1 ! Apply fast AGC to the symbol spectra s1max=20.0 !Empirical choice do j=1,jz !### Maybe wrong way? ### - smax=maxval(s1(i0-64:i0-65+LL,j)) - if(smax.gt.s1max) s1(i0-64:i0-65+LL,j)=s1(i0-64:i0-65+LL,j)*s1max/smax + smax=maxval(s1(ii1:ii2,j)) + if(smax.gt.s1max) s1(ii1:ii2,j)=s1(ii1:ii2,j)*s1max/smax enddo dat4=0 @@ -155,21 +157,34 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & ! Try list decoding via "Deep Likelihood". call timer('ccf_85 ',0) ! Try to synchronize using all 85 symbols - call q65_ccf_85(s1,iz,jz,nfqso,ia,ia2,ipk,jpk,f0,xdt,imsg_best,ccf1) + call q65_ccf_85(s1,iz,jz,nfqso,ia,ia2,ipk,jpk,f0,xdt,imsg_best, & + better,ccf1) call timer('ccf_85 ',1) - call timer('list_dec',0) - call q65_dec_q3(s1,iz,jz,s3,LL,ipk,jpk,snr2,dat4,idec,decoded) - call timer('list_dec',1) + if(better.ge.1.10 .or. mode_q65.ge.8) then + call timer('list_dec',0) + call q65_dec_q3(s1,iz,jz,s3,LL,ipk,jpk,snr2,dat4,idec,decoded) + call timer('list_dec',1) +! if(idec.ge.0) write(70,3070) idec,mode_q65,better,trim(decoded) +!3070 format(i3,i5,f8.2,2x,a) + endif +! If idec=3 we have a q3 decode. Continue to compute sync curve for plotting. endif +! Get 2d CCF and ccf2 using sync symbols only if(iavg.eq.0) then - call q65_ccf_22(s1,iz,jz,nfqso,ipk,jpk,f0a,xdta,ccf2) + call timer('ccf_22a ',0) + call q65_ccf_22(s1,iz,jz,nfqso,ntol,ndepth,ntrperiod,iavg,ipk,jpk, & + f0a,xdta,ccf2) + call timer('ccf_22a ',1) endif -! Get 2d CCF and ccf2 using sync symbols only +! Get 2d CCF and ccf2_avg using sync symbols only if(iavg.ge.1) then - call q65_ccf_22(s1,iz,jz,nfqso,ipk,jpk,f0a,xdta,ccf2_avg) + call timer('ccf_22b ',0) + call q65_ccf_22(s1,iz,jz,nfqso,ntol,ndepth,ntrperiod,iavg,ipk,jpk, & + f0a,xdta,ccf2_avg) + call timer('ccf_22b ',1) endif if(idec.lt.0) then f0=f0a @@ -190,7 +205,7 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & smax=maxval(ccf1) -! Estimate frequenct spread +! Estimate frequency spread i1=-9999 i2=-9999 do i=-ia,ia @@ -200,11 +215,10 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, & width=df*(i2-i1) if(ncw.eq.0) ccf1=0. -! write(*,3001) nutc,iavg,navg(0),sum(ccf2_avg),sum(ccf2) -!3001 format(i4.4,2i4,2f8.2) + call q65_write_red(iz,xdt,ccf2_avg,ccf2) - if(iavg.eq.2) then + if(idec.lt.0 .and. (iavg.eq.0 .or. iavg.eq.2)) then call q65_dec_q012(s3,LL,snr2,dat4,idec,decoded) endif @@ -350,18 +364,21 @@ subroutine q65_dec_q012(s3,LL,snr2,dat4,idec,decoded) 100 return end subroutine q65_dec_q012 -subroutine q65_ccf_85(s1,iz,jz,nfqso,ia,ia2,ipk,jpk,f0,xdt,imsg_best,ccf1) +subroutine q65_ccf_85(s1,iz,jz,nfqso,ia,ia2,ipk,jpk,f0,xdt,imsg_best, & + better,ccf1) ! Attempt synchronization using all 85 symbols, in advance of an ! attempt at q3 decoding. Return ccf1 for the "red sync curve". real s1(iz,jz) real, allocatable :: ccf(:,:) !CCF(freq,lag) + real, allocatable :: best(:) !best(imsg) -- for checking 2nd best real ccf1(-ia2:ia2) integer ijpk(2) integer itone(85) allocate(ccf(-ia2:ia2,-53:214)) + allocate(best(ncw)) ipk=0 jpk=0 ccf_best=0. @@ -406,13 +423,21 @@ subroutine q65_ccf_85(s1,iz,jz,nfqso,ia,ia2,ipk,jpk,f0,xdt,imsg_best,ccf1) imsg_best=imsg ccf1=ccf(:,jpk) endif + best(imsg)=ccfmax enddo ! imsg + deallocate(ccf) + better=0. + if(imsg_best.gt.0) then + best(imsg_best)=0. + better=ccf_best/maxval(best) + endif return end subroutine q65_ccf_85 -subroutine q65_ccf_22(s1,iz,jz,nfqso,ipk,jpk,f0,xdt,ccf2) +subroutine q65_ccf_22(s1,iz,jz,nfqso,ntol,ndepth,ntrperiod,iavg,ipk,jpk, & + f0,xdt,ccf2) ! Attempt synchronization using only the 22 sync symbols. Return ccf2 ! for the "orange sync curve". @@ -420,57 +445,81 @@ subroutine q65_ccf_22(s1,iz,jz,nfqso,ipk,jpk,f0,xdt,ccf2) real s1(iz,jz) real ccf2(iz) !Orange sync curve real, allocatable :: xdt2(:) + real, allocatable :: s1avg(:) integer, allocatable :: indx(:) allocate(xdt2(iz)) + allocate(s1avg(iz)) allocate(indx(iz)) + ia=max(nfa,100)/df + ib=min(nfb,4900)/df + if(nqd.ne.1 .or. iavg.ne.0) max_drift=0 + if(max_drift.ne.0) then + ia=max(nint(100/df),nint((nfqso-ntol)/df)) + ib=min(nint(4900/df),nint((nfqso+ntol)/df)) + endif + + do i=ia,ib + s1avg(i)=sum(s1(i,1:jz)) + enddo + ccfbest=0. ibest=0 lagpk=0 lagbest=0 - do i=1,iz + idrift_best=0 + do i=ia,ib ccfmax=0. do lag=lag1,lag2 - ccft=0. - do k=1,85 - n=NSTEP*(k-1) + 1 - j=n+lag+j0 - if(j.ge.1 .and. j.le.jz) then - ccft=ccft + sync(k)*s1(i,j) + do idrift=-max_drift,max_drift + ccft=0. + do kk=1,22 + k=isync(kk) + ii=i + nint(idrift*(k-43)/85.0) + if(ii.lt.1 .or. ii.gt.iz) cycle + n=NSTEP*(k-1) + 1 + j=n+lag+j0 + if(j.ge.1 .and. j.le.jz) ccft=ccft + s1(ii,j) + enddo ! kk + ccft=ccft - (22.0/jz)*s1avg(i) + if(ccft.gt.ccfmax) then + ccfmax=ccft + lagpk=lag + idrift_max=idrift endif - enddo - if(ccft.gt.ccfmax) then - ccfmax=ccft - lagpk=lag - endif - enddo + enddo ! idrift + enddo ! lag ccf2(i)=ccfmax xdt2(i)=lagpk*dtstep if(ccfmax.gt.ccfbest .and. abs(i*df-nfqso).le.ftol) then ccfbest=ccfmax ibest=i lagbest=lagpk + idrift_best=idrift_max endif - enddo + enddo ! i ! Parameters for the top candidate: ipk=ibest - i0 jpk=lagbest f0=nfqso + ipk*df xdt=jpk*dtstep + drift=df*idrift_best + ccf2(:ia)=0. + ccf2(ib:)=0. ! Save parameters for best candidates - i1=max(nfa,100)/df - i2=min(nfb,4900)/df - jzz=i2-i1+1 - call pctile(ccf2(i1:i2),jzz,40,base) + jzz=ib-ia+1 + call pctile(ccf2(ia:ib),jzz,40,base) ccf2=ccf2/base - call indexx(ccf2(i1:i2),jzz,indx) + call indexx(ccf2(ia:ib),jzz,indx) ncand=0 maxcand=20 do j=1,20 - i=indx(jzz-j+1)+i1-1 + k=jzz-j+1 + if(k.lt.1 .or. k.gt.iz) cycle + i=indx(k)+ia-1 if(ccf2(i).lt.3.3) exit !Candidate limit f=i*df if(f.ge.(nfqso-ftol) .and. f.le.(nfqso+ftol)) cycle !Looked here already @@ -692,12 +741,6 @@ subroutine q65_snr(dat4,dtdec,f0dec,mode_q65,nused,snr2) if(nused.eq.3) snr2=snr2 - 2.9 if(nused.ge.4) snr2=snr2 - 3.5 -! do i=ia,ib -! write(71,3071) i*df,spec(i),db(spec(i)) -!3071 format(3f10.3) -! enddo -! flush(71) - return end subroutine q65_snr @@ -736,7 +779,8 @@ subroutine q65_hist(if0,msg0,dxcall,dxgrid) msg(nhist)=msg0 go to 900 -100 dxcall=' ' !This is a lookup request +100 if(dxcall(1:3).ne.' ') go to 900 + dxcall=' ' !This is a lookup request dxgrid=' ' ! Look for a decode close to if0, starting with most recent ones do i=nhist,1,-1 diff --git a/lib/qra/q65/q65_encoding_modules.f90 b/lib/qra/q65/q65_encoding_modules.f90 new file mode 100644 index 00000000..b55c7f27 --- /dev/null +++ b/lib/qra/q65/q65_encoding_modules.f90 @@ -0,0 +1,223 @@ +module gf64math +! add and subtract in GF(2^6) based on primitive polynomial x^6+x+1 + + implicit none + integer, private :: gf64log(0:63) + integer, private :: gf64antilog(0:62) + +! table of the logarithms of the elements of GF(M) (log(0) never used) + data gf64log/ & + -1, 0, 1, 6, 2, 12, 7, 26, 3, 32, & + 13, 35, 8, 48, 27, 18, 4, 24, 33, 16, & + 14, 52, 36, 54, 9, 45, 49, 38, 28, 41, & + 19, 56, 5, 62, 25, 11, 34, 31, 17, 47, & + 15, 23, 53, 51, 37, 44, 55, 40, 10, 61, & + 46, 30, 50, 22, 39, 43, 29, 60, 42, 21, & + 20, 59, 57, 58/ + +! table of GF(M) elements given their logarithm + data gf64antilog/ & + 1, 2, 4, 8, 16, 32, 3, 6, 12, 24, & + 48, 35, 5, 10, 20, 40, 19, 38, 15, 30, & + 60, 59, 53, 41, 17, 34, 7, 14, 28, 56, & + 51, 37, 9, 18, 36, 11, 22, 44, 27, 54, & + 47, 29, 58, 55, 45, 25, 50, 39, 13, 26, & + 52, 43, 21, 42, 23, 46, 31, 62, 63, 61, & + 57, 49, 33/ + +contains + + integer function gf64_add(i1,i2) + implicit none + integer::i1 + integer::i2 + gf64_add=iand(ieor(i1,i2),63) + end function gf64_add + + integer function gf64_mult(i1,i2) + implicit none + integer::i1 + integer::i2 + integer::j + + if(i1.eq.0 .or. i2.eq.0) then + gf64_mult=0 + elseif(i1.eq.1) then + gf64_mult=i2 + elseif(i2.eq.1) then + gf64_mult=i1 + else + j=mod(gf64log(i1)+gf64log(i2),63) + gf64_mult=gf64antilog(j) + endif + end function gf64_mult + +end module gf64math + +module q65_generator + + integer generator(15,50) + data generator/ & + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, & + 0,20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, & + 0,20, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, & + 0,20, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, & + 0,20, 0, 1, 1, 0, 0, 0,10, 0, 0, 0, 0, 1, 0, & + 0,20, 0, 1, 1, 0, 0, 0,10, 0, 0, 0,44, 1, 0, & + 0,20, 0, 1, 1, 0, 0, 0,10, 1, 0, 0,44, 1, 0, & + 0,20, 0, 1, 1, 0, 0, 0,10, 1, 0, 0,44, 1,14, & + 0,20, 0, 1, 1, 0, 0, 0,10, 1,31, 0,44, 1,14, & + 0,20, 0, 1, 1,33, 0, 0,10, 1,31, 0,44, 1,14, & + 56,20, 0, 1, 1,33, 0, 0,10, 1,31, 0,44, 1,14, & + 56,20, 0, 1, 1,33, 0, 1,10, 1,31, 0,44, 1,14, & + 56, 1, 0, 1, 1,33, 0, 1,10, 1,31, 0,44, 1,14, & + 56, 1, 0, 1, 1,33, 0, 1,10, 1,31,36,44, 1,14, & + 56, 1, 0, 1, 1,33, 0, 1,43, 1,31,36,44, 1,14, & + 56, 1, 0, 1, 1,33, 0, 1,43,17,31,36,44, 1,14, & + 56, 1, 0, 1, 1,33, 0, 1,43,17,31,36,36, 1,14, & + 56, 1, 0, 1, 1,33,53, 1,43,17,31,36,36, 1,14, & + 56, 1, 0,35, 1,33,53, 1,43,17,31,36,36, 1,14, & + 56, 1, 0,35, 1,33,53, 1,43,17,30,36,36, 1,14, & + 56, 1, 0,35, 1,33,53,52,43,17,30,36,36, 1,14, & + 56, 1, 0,35, 1,32,53,52,43,17,30,36,36, 1,14, & + 56, 1,60,35, 1,32,53,52,43,17,30,36,36, 1,14, & + 56, 1,60,35, 1,32,53,52,43,17,30,36,36,49,14, & + 56, 1,60,35, 1,32,53,52,43,17,30,36,37,49,14, & + 56, 1,60,35,54,32,53,52,43,17,30,36,37,49,14, & + 56, 1,60,35,54,32,53,52, 1,17,30,36,37,49,14, & + 1, 1,60,35,54,32,53,52, 1,17,30,36,37,49,14, & + 1, 0,60,35,54,32,53,52, 1,17,30,36,37,49,14, & + 1, 0,60,35,54,32,53,52, 1,17,30,37,37,49,14, & + 1, 0,61,35,54,32,53,52, 1,17,30,37,37,49,14, & + 1, 0,61,35,54,32,53,52, 1,48,30,37,37,49,14, & + 1, 0,61,35,54,32,53,52, 1,48,30,37,37,49,15, & + 1, 0,61,35,54, 0,53,52, 1,48,30,37,37,49,15, & + 1, 0,61,35,54, 0,52,52, 1,48,30,37,37,49,15, & + 1, 0,61,35,54, 0,52,52, 1,48,30,37,37, 0,15, & + 1, 0,61,35,54, 0,52,34, 1,48,30,37,37, 0,15, & + 1, 0,61,35,54, 0,52,34, 1,48,30,37, 0, 0,15, & + 1, 0,61,35,54, 0,52,34, 1,48,30,20, 0, 0,15, & + 1, 0, 0,35,54, 0,52,34, 1,48,30,20, 0, 0,15, & + 1, 0, 0,35,54, 0,52,34, 1, 0,30,20, 0, 0,15, & + 0, 0, 0,35,54, 0,52,34, 1, 0,30,20, 0, 0,15, & + 0, 0, 0,35,54, 0,52,34, 1, 0,38,20, 0, 0,15, & + 0, 0, 0,35, 0, 0,52,34, 1, 0,38,20, 0, 0,15, & + 0, 0, 0,35, 0, 0,52, 0, 1, 0,38,20, 0, 0,15, & + 0, 0, 0,35, 0, 0,52, 0, 1, 0,38,20, 0, 0, 0, & + 0, 0, 0,35, 0, 0,52, 0, 0, 0,38,20, 0, 0, 0, & + 0, 0, 0,35, 0, 0,52, 0, 0, 0,38, 0, 0, 0, 0, & + 0, 0, 0, 0, 0, 0,52, 0, 0, 0,38, 0, 0, 0, 0, & + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,38, 0, 0, 0, 0/ + +end module q65_generator + +module q65_encoding + +contains + +subroutine q65_encode(message,codeword) + use gf64math + use q65_generator + integer message(15) + integer codeword(65) + integer i,j + + codeword=0 + codeword(1:15)=message + do i=1,15 + do j=16,65 + codeword(j)=gf64_add(codeword(j),gf64_mult(message(i),generator(i,j-15))) + enddo + enddo + + return +end + +subroutine get_q65crc12(mc2,ncrc1,ncrc2) +! + character c12*12,c6*6 + integer*1 mc(90),mc2(90),tmp(6) + integer*1 r(13),p(13) + integer ncrc +! polynomial for 12-bit CRC 0xF01 + data p/1,1,0,0,0,0,0,0,0,1,1,1,1/ + +! flip bit order of each 6-bit symbol for consistency with Nico's calculation + do i=0,14 + tmp=mc2(i*6+1:i*6+6) + mc(i*6+1:i*6+6)=tmp(6:1:-1) + enddo + +! divide by polynomial + r=mc(1:13) + do i=0,77 + r(13)=mc(i+13) + r=mod(r+r(1)*p,2) + r=cshift(r,1) + enddo + + write(c6,'(6b1)') r(6:1:-1) + read(c6,'(b6.6)') ncrc1 + read(c6,'(6b1)') mc2(79:84) + write(c6,'(6b1)') r(12:7:-1) + read(c6,'(b6.6)') ncrc2 + read(c6,'(6b1)') mc2(85:90) + +end subroutine get_q65crc12 + +subroutine get_q65_tones(msg37,codeword,itone) + use packjt77 + implicit none + character*37 msg37 + character*77 c77 + character*12 c12 + character*6 c6 + integer codeword(65) + integer sync(22) + integer message(15) + integer shortcodeword(63) + integer itone(85) + integer i,j,k + integer*1 mbits(90) + integer i3,n3,ncrc1,ncrc2 + data sync/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/ + + i3=-1 + n3=-1 + call pack77(msg37,i3,n3,c77) + mbits=0 + read(c77,'(77i1)') mbits(1:77) + +! Message is 77 bits long. Add a 0 bit to create a 78-bit message and pad with +! 12 zeros to create 90-bit mbit array for CRC calculation. + call get_q65crc12(mbits,ncrc1,ncrc2) + +! Now have message in bits 1:78 and CRC in bits 79:90. +! Group message bits into 15 6-bit symbols: + do i=0,14 + write(c6,'(6i1)') mbits( (i*6+1):(i*6+6) ) + read(c6,'(b6.6)') message(i+1) + enddo + +! Encode to create a 65-symbol codeword + call q65_encode(message,codeword) + +!Shorten the codeword by omitting the CRC symbols (symbols 14 and 15) + shortcodeword(1:13)=codeword(1:13) + shortcodeword(14:63)=codeword(16:65) + +!Insert sync symbols to create array of channel symbols + j=1 + k=0 + do i=1,85 + if(i.eq.sync(j)) then + j=j+1 + itone(i)=0 + else + k=k+1 + itone(i)=shortcodeword(k)+1 + endif + enddo +end subroutine get_q65_tones + +end module q65_encoding diff --git a/lib/qra/q65/q65_loops.f90 b/lib/qra/q65/q65_loops.f90 index 827e7f4c..ec93adb0 100644 --- a/lib/qra/q65/q65_loops.f90 +++ b/lib/qra/q65/q65_loops.f90 @@ -11,30 +11,35 @@ subroutine q65_loops(c00,npts2,nsps2,nsubmode,ndepth,jpk0, & complex ,allocatable :: c0(:) !Ditto, with freq shift character decoded*37 real a(3) !twkfreq params f,f1,f2 - real s3(LN) !Symbol spectra + real,allocatable :: s3(:) !Symbol spectra integer dat4(13) !Decoded message (as 13 six-bit integers) integer nap(0:11) !AP return codes data nap/0,2,3,2,3,4,2,3,6,4,6,6/ + LL=64*(mode_q65+2) + allocate(s3(LL*NN)) + allocate(c0(0:npts2-1)) idec=-1 ircbest=9999 - allocate(c0(0:npts2-1)) irc=-99 s3lim=20. baud=6000.0/nsps2 - idfmax=3 - idtmax=3 + idfmax=1 + idtmax=1 + maxdist=4 ibw0=(ibwa+ibwb)/2 - maxdist=5 - if(iand(ndepth,3).ge.2) then + if(iand(ndepth,3).eq.2) then + idfmax=3 + idtmax=3 + maxdist=5 + endif + if(iand(ndepth,3).eq.3) then idfmax=5 idtmax=5 - maxdist=10 + maxdist=15 endif - if(iand(ndepth,3).eq.3) maxdist=15 - LL=64*(mode_q65+2) napmin=99 xdt1=xdt0 f1=f0 @@ -47,15 +52,16 @@ subroutine q65_loops(c00,npts2,nsps2,nsubmode,ndepth,jpk0, & if(mod(idf,2).eq.0) ndf=-ndf a=0. a(1)=-(f0+0.5*baud*ndf) +! Variable 'drift' is frequency increase over full TxT. Therefore we want: + a(2)=-0.5*drift call twkfreq(c00,c0,npts2,6000.0,a) do idt=1,idtmax ndt=idt/2 if(mod(idt,2).eq.0) ndt=-ndt jpk=jpk0 + nsps2*ndt/16 !tsym/16 - if(jpk.lt.0) jpk=0 - call timer('spec64 ',0) - call spec64(c0,nsps2,mode_q65,jpk,s3,LL,NN) - call timer('spec64 ',1) + jpk=max(0,jpk) + jpk=min(29000,jpk) + call spec64(c0,npts2,nsps2,mode_q65,jpk,s3,LL,NN) call pctile(s3,LL*NN,40,base) s3=s3/base where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim diff --git a/lib/qra/q65/q65code.f90 b/lib/qra/q65/q65code.f90 new file mode 100644 index 00000000..d61cba91 --- /dev/null +++ b/lib/qra/q65/q65code.f90 @@ -0,0 +1,29 @@ +program q65code + use q65_encoding + + implicit none + character*37 msg37 + integer nargs + integer codeword(65),tones(85) + + nargs=iargc() + if(nargs .ne. 1) then + print*,'Usage: q65code "msg"' + goto 999 + endif + call getarg(1,msg37) + + call get_q65_tones(msg37,codeword,tones) + + write(*,*) 'Generated message plus CRC (90 bits)' + write(*,'(a8,15i4)') '6 bit : ',codeword(1:15) + write(*,'(a8,15b6.6)') 'binary: ',codeword(1:15) + write(*,*) ' ' + write(*,*) 'Codeword with CRC symbols (65 symbols)' + write(*,'(20i3)') codeword + + write(*,*) ' ' + write(*,*) 'Channel symbols (85 total)' + write(*,'(20i3)') tones + +999 end program q65code diff --git a/lib/qra/q65/qra15_65_64_irr_e23.c b/lib/qra/q65/qra15_65_64_irr_e23.c index d56e057f..88667169 100644 --- a/lib/qra/q65/qra15_65_64_irr_e23.c +++ b/lib/qra/q65/qra15_65_64_irr_e23.c @@ -494,7 +494,7 @@ static const int qra_pmat[qra_M*qra_M] = { 3, 1, 7, 5, 11, 9, 15, 13, 19, 17, 23, 21, 27, 25, 31, 29, 35, 33, 39, 37, 43, 41, 47, 45, 51, 49, 55, 53, 59, 57, 63, 61 }; - +/* // SO array static const int SO[qra_N-qra_K+1] = { 14, 2, 4, 5, 9, 13, 10, 15, 11, 6, 1, 8, 2, 12, 9, 10, @@ -515,6 +515,7 @@ static const int LOGWO[qra_N-qra_K+1] = { static const int repfact[qra_K] = { 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 3, 3 }; +*/ const qracode qra15_65_64_irr_e23 = { qra_K, diff --git a/lib/spec64.f90 b/lib/spec64.f90 index b3b7d54d..79322050 100644 --- a/lib/spec64.f90 +++ b/lib/spec64.f90 @@ -1,8 +1,7 @@ -subroutine spec64(c0,nsps,mode_q65,jpk,s3,LL,NN) +subroutine spec64(c0,npts,nsps,mode_q65,jpk,s3,LL,NN) parameter (MAXFFT=20736) -!### Fix this: - complex c0(0:1800000-1) !Complex spectrum of dd() + complex c0(0:npts-1) !Complex spectrum of dd() complex cs(0:MAXFFT-1) !Complex symbol spectrum real s3(LL,NN) !Synchronized symbol spectra real xbase0(LL),xbase(LL) @@ -21,7 +20,11 @@ subroutine spec64(c0,nsps,mode_q65,jpk,s3,LL,NN) j=j+1 ja=(k-1)*nsps + jpk jb=ja+nsps-1 - cs(0:nfft-1)=c0(ja:jb) + if(ja.lt.0) ja=0 + if(jb.gt.npts-1) jb=npts-1 + nz=jb-ja + cs(0:nz)=c0(ja:jb) + if(nz.lt.nfft-1) cs(nz+1:)=0. call four2a(cs,nsps,1,-1,1) !c2c FFT to frequency do ii=1,LL i=ii-65+mode_q65 !mode_q65 = 1 2 4 8 16 for Q65 A B C D E diff --git a/lib/symspec.f90 b/lib/symspec.f90 index 8f5ddd09..38189a3c 100644 --- a/lib/symspec.f90 +++ b/lib/symspec.f90 @@ -126,35 +126,3 @@ subroutine symspec(shared_data,k,TRperiod,nsps,ingain,bLowSidelobes, & return end subroutine symspec - -subroutine chk_samples(ihsym,k,nstop) - - integer*8 count0,count1,clkfreq - integer itime(8) - real*8 dtime,fsample - character*12 ctime - data count0/-1/,k0/99999999/,maxhsym/0/ - save count0,k0,maxhsym - - if(k.lt.k0 .or. count0.eq.-1) then - call system_clock(count0,clkfreq) - maxhsym=0 - endif -! if((mod(ihsym,100).eq.0 .or. ihsym.ge.nstop-100) .and. & -! k0.ne.99999999) then -! call system_clock(count1,clkfreq) -! dtime=dfloat(count1-count0)/dfloat(clkfreq) -! if(dtime.lt.28.0) return -! if(dtime.gt.1.d-6) fsample=(k-3456)/dtime -! call date_and_time(values=itime) -! sec=itime(7)+0.001*itime(8) -! write(ctime,3000) itime(5)-itime(4)/60,itime(6),sec -!3000 format(i2.2,':',i2.2,':',f6.3) -! write(33,3033) ctime,dtime,ihsym,nstop,k,fsample -!3033 format(a12,f12.6,2i7,i10,f15.3) -! flush(33) -! endif - k0=k - - return -end subroutine chk_samples diff --git a/lib/test_q65.f90 b/lib/test_q65.f90 index 4135a290..598de976 100644 --- a/lib/test_q65.f90 +++ b/lib/test_q65.f90 @@ -1,6 +1,6 @@ program test_q65 - character*82 cmd1,cmd2,line + character*84 cmd1,cmd2,line character*22 msg character*8 arg character*1 csubmode @@ -71,19 +71,19 @@ program test_q65 tsym=1.0/baud ! 1 2 3 4 5 6 7 -! 123456789012345678901234567890123456789012345678901234567890123456789012345' - cmd1='q65sim "K1ABC W9XYZ EN37 " A 1500 5.0 0.0 0.0 1 60 100 -10.0 > junk0' - cmd2='jt9 -3 -p 15 -L 300 -H 3000 -d 3 -b A -Q 3 -f 1500 *.wav > junk' +! 1234567890123456789012345678901234567890123456789012345678901234567890123456' + cmd1='q65sim "K1ABC W9XYZ EN37 " A 1500 5.0 0.0 0.0 1 60 100 -10.0 > junk0' + cmd2='jt9 -3 -p 15 -L 300 -H 3000 -d 3 -b A -Q 3 -f 1500 -X 32 *.wav > junk' write(cmd1(10:33),'(a)') '"'//msg//'"' cmd1(35:35)=csubmode write(cmd1(37:40),'(i4)') nf0 write(cmd1(41:45),'(f5.0)') fDop write(cmd1(46:50),'(f5.2)') dt - write(cmd1(51:54),'(f4.0)') f1 - write(cmd1(55:57),'(i3)') nstp - write(cmd1(58:61),'(i4)') ntrperiod - write(cmd1(62:66),'(i5)') nfiles + write(cmd1(51:56),'(i6)') nint(f1) + write(cmd1(57:59),'(i3)') nstp + write(cmd1(60:63),'(i4)') ntrperiod + write(cmd1(64:68),'(i5)') nfiles write(cmd2(11:13),'(i3)') ntrperiod write(cmd2(33:35),'(i3)') ndepth @@ -94,7 +94,7 @@ program test_q65 call system('rm -f *.wav') write(*,1008) ntrperiod,csubmode,ndepth,fDop,f1,nstp -1008 format('Mode:',i4,a1,' Depth:',i3,' fDop:',f6.1,' Drift:',f6.1, & +1008 format('Mode:',i4,a1,' Depth:',i3,' fDop:',f6.1,' Drift:',f8.1, & ' Steps:',i3) write(*,1010) (j,j=0,5) write(12,1010) (j,j=0,5) @@ -112,7 +112,7 @@ program test_q65 nfalse=0 naptype=0 ndecn=0 - write(cmd1(70:74),'(f5.1)') snr1 + write(cmd1(72:76),'(f5.1)') snr1 call system(cmd1) call sec0(0,tdec) call system(cmd2) diff --git a/lib/twkfreq.f90 b/lib/twkfreq.f90 index 7c240d52..5188d500 100644 --- a/lib/twkfreq.f90 +++ b/lib/twkfreq.f90 @@ -1,5 +1,9 @@ subroutine twkfreq(c3,c4,npts,fsample,a)
+ ! Adjust frequency of complex data
+ ! a(1) Hz
+ ! a(2) Hz/(0.5*TxT), where TxT = npts/fsample = file duration
+
complex c3(npts)
complex c4(npts)
complex w,wstep
diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c index eea667eb..8d862276 100644 --- a/lib/wsprd/wsprd.c +++ b/lib/wsprd/wsprd.c @@ -677,6 +677,7 @@ unsigned long writec2file(char *c2filename, int trmin, double freq } nwrite = fwrite(buffer, sizeof(float), 2*45000, fp); free(buffer); + fclose(fp); if( nwrite == 2*45000 ) { return nwrite; } else { |
