summaryrefslogtreecommitdiff
path: root/lib/ft8var
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ft8var')
-rw-r--r--lib/ft8var/agccft8.f902
-rw-r--r--lib/ft8var/cwfilter.f9011
-rw-r--r--lib/ft8var/fillhashvar.f9065
-rw-r--r--lib/ft8var/four2avar.f9013
-rw-r--r--lib/ft8var/ft4_mod1.f903
-rw-r--r--lib/ft8var/ft8_decode_ranges.f9038
-rw-r--r--lib/ft8var/ft8_decodevar.f90135
-rw-r--r--lib/ft8var/ft8_downsamplevar.f9026
-rw-r--r--lib/ft8var/ft8_mod1.f909
-rw-r--r--lib/ft8var/ft8_mtd_residual.f90459
-rw-r--r--lib/ft8var/ft8_tsan.c30
-rw-r--r--lib/ft8var/ft8apsetvar.f9077
-rw-r--r--lib/ft8var/ft8bvar.f9094
-rw-r--r--lib/ft8var/ft8mf1var.f903
-rw-r--r--lib/ft8var/ft8mfcqvar.f907
-rw-r--r--lib/ft8var/ft8sd1var.f907
-rw-r--r--lib/ft8var/ft8sdvar.f907
-rw-r--r--lib/ft8var/ft8svar.f9030
-rw-r--r--lib/ft8var/gen_ft8wavevar.f901
-rw-r--r--lib/ft8var/genft8sdvar.f9014
-rw-r--r--lib/ft8var/genft8var.f9012
-rw-r--r--lib/ft8var/jt65_mod9.f902
-rw-r--r--lib/ft8var/osd174_91var.f9020
-rw-r--r--lib/ft8var/packjt77sdvar.f90558
-rw-r--r--lib/ft8var/subtractft8var.f9027
-rw-r--r--lib/ft8var/sync8dvar.f9020
-rw-r--r--lib/ft8var/sync8var.f9058
-rw-r--r--lib/ft8var/tone8.f9064
-rw-r--r--lib/ft8var/tonesdvar.f9037
29 files changed, 945 insertions, 884 deletions
diff --git a/lib/ft8var/agccft8.f90 b/lib/ft8var/agccft8.f90
index 1b88ca84..be39347f 100644
--- a/lib/ft8var/agccft8.f90
+++ b/lib/ft8var/agccft8.f90
@@ -1,4 +1,4 @@
-subroutine agccft8(nfa,nfb,forcedt)
+subroutine agccft8(nfa,nfb)
use ft8_mod1, only : dd8,twopi,lagccbail
integer, parameter :: NFFT=1024,NSZ=426,NHSYM=178,NHSTEP=960 !3413 = NFFT*5000/12000
diff --git a/lib/ft8var/cwfilter.f90 b/lib/ft8var/cwfilter.f90
index d3ec35fb..e305047d 100644
--- a/lib/ft8var/cwfilter.f90
+++ b/lib/ft8var/cwfilter.f90
@@ -1,13 +1,14 @@
subroutine cwfilter(first)
use ft8_mod1, only : cw,windowc1,windowx,pivalue,facx,mcq,m73,mrr73,mrrr,one,twopi,facc1,dt,csync,idtone25,csynccq, &
+ idtone25_valid, &
NFILT1,NFILT2,endcorr,ctwkw,ctwkn,ctwk256
use jt65_mod9 ! callsign DB to memory
use prog_args ! path to files
parameter (NFFT=180000)
- complex csig0(151680)
- real*4 window1(-NFILT1/2:NFILT1/2),window2(-NFILT2/2:NFILT2/2)
+ complex, allocatable :: csig0(:)
+ real*4 window1(-NFILT1/2:NFILT1/2)
character*37 msgcq25(25),msgsent37
integer itone(79)
integer*1 msgbits(77)
@@ -17,6 +18,7 @@ subroutine cwfilter(first)
!note that with new, larger ALLCALL7.TXT files, dimensions of various ncall arrays may need to be increased in jt65_mod9.f90
!on 20250709 callj dim was increased from 9000 to 10000 when updated ALLCALL7.TXT file was added
if(first) then
+ allocate(csig0(151680))
! Open the shipped read-only ALLCALL7.TXT for reading only. status='old' with
! action='read' makes a missing/unreadable file degrade cleanly to an empty
! callsign DB (handled by the count check below) instead of status='unknown'
@@ -112,9 +114,12 @@ subroutine cwfilter(first)
msgcq25(23)='CQ SM2GSH KP05'
msgcq25(24)='CQ UA9OHX NO15'
msgcq25(25)='CQ JA W0YH EN12'
+ idtone25(2:25,1:58)=0
+ idtone25_valid(2:25)=.false.
do i=2,25
i3=-1; n3=-1
call genft8sdvar(msgcq25(i),i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) cycle
if(i.eq.2) then
call gen_ft8wave(itone,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
m=1
@@ -127,6 +132,7 @@ subroutine cwfilter(first)
endif
idtone25(i,1:29)=itone(8:36)
idtone25(i,30:58)=itone(44:72)
+ idtone25_valid(i)=.true.
enddo
dt2=0.005 ! fs2=200 Hz
k=1
@@ -182,4 +188,3 @@ subroutine cwfilter(first)
return
end subroutine cwfilter
- \ No newline at end of file
diff --git a/lib/ft8var/fillhashvar.f90 b/lib/ft8var/fillhashvar.f90
index edab5e30..851ddc13 100644
--- a/lib/ft8var/fillhashvar.f90
+++ b/lib/ft8var/fillhashvar.f90
@@ -1,67 +1,30 @@
subroutine fillhashvar(numthreads,lfill)
- use packjt77 ! also setting mycall13var,dxcall13var
+ use packjt77
use ft8_mod1, only : mycall,hiscall
integer, intent(in) :: numthreads
logical, intent(in) :: lfill
character*13 cw
if(lfill) then
+ ! End of a configured/var decode pass: merge per-thread successful decode
+ ! effects into the shared callsign hash and recent-call state.
do i=1,numthreads
- do m=1,nlast_callsvar(i)
- nposition=nthrindexvar(i)+m
- cw=last_callsvar(nposition)
+ do m=1,nqueued_calls_by_thread(i)
+ nposition=thread_call_index(i)+m
+ cw=queued_calls_by_thread(nposition)
!print *,i,m,cw
- n10=ihashcallvar(cw,10)
- if(n10.ge.0 .and. n10 .le. 1023 .and. cw.ne.mycall13var) calls10var(n10)=cw
-
- n12=ihashcallvar(cw,12)
- if(n12.ge.0 .and. n12 .le. 4095 .and. cw.ne.mycall13var) calls12var(n12)=cw
-
- n22=ihashcallvar(cw,22)
- if(any(ihash22var.eq.n22)) then ! If entry exists, make sure callsign is the most recently received one
- where(ihash22var.eq.n22) calls22var=cw
- go to 900
- endif
-
-! New entry: move table down, making room for new one at the top
- ihash22var(nzhashvar:2:-1)=ihash22var(nzhashvar-1:1:-1)
-
-! Add the new entry
- calls22var(nzhashvar:2:-1)=calls22var(nzhashvar-1:1:-1)
- ihash22var(1)=n22
- calls22var(1)=cw
- if(nzhashvar.lt.MAXHASHvar) nzhashvar=nzhashvar+1
-900 continue
+ call save_hash_call(cw,n10,n12,n22)
enddo
enddo
+ call fold_queued_recent_calls(numthreads)
else
- nlast_callsvar=0
- mycall13var=mycall//' '; dxcall13var=hiscall//' '
- if(mycall13var.ne.mycall13_0var) then
- if(len(trim(mycall13var)).gt.2) then
- mycall13_setvar=.true.
- mycall13_0var=mycall13var
- call save_hash_mycallvar(mycall13var,hashmy10var,hashmy12var,hashmy22var)
-!print *,mycall13var,hashmy10var,hashmy12var,hashmy22var
- else
- mycall13_setvar=.false.
- endif
- endif
-
- if(dxcall13var.ne.dxcall13_0var) then
- if(len(trim(dxcall13var)).gt.2) then
- dxcall13_setvar=.true.
- dxcall13_0var=dxcall13var
- hashdx10var=ihashcallvar(dxcall13var,10)
-! make sure new DX Call is stored in hash tables prior to decoding
-! it is needed if manually callsign set in DX Call window was not decoded before
- call save_hash_callvar(dxcall13var,1)
-!print *,dxcall13var,hashdx10var
- else
- dxcall13_setvar=.false.
- endif
- endif
+ ! Start of a configured/var decode pass: clear staged worker effects and
+ ! snapshot the operator-configured calls used by hash-only decode guards.
+ nqueued_calls_by_thread=0
+ nqueued_recent_calls_by_thread=0
+ mycall13=mycall//' '; dxcall13=hiscall//' '
+ call sync_configured_calls_for_decode_start()
endif
return
diff --git a/lib/ft8var/four2avar.f90 b/lib/ft8var/four2avar.f90
index 3ed44f22..1653955b 100644
--- a/lib/ft8var/four2avar.f90
+++ b/lib/ft8var/four2avar.f90
@@ -32,11 +32,20 @@ subroutine four2avar(a,nfft,ndim,isign,iform)
include '/lib/fftw3.f90' !FFTW definitions
save plan,nplan,nn,ns,nf,nl
+ interface
+ subroutine wsjt_tsan_acquire_four2avar_setup() bind(C)
+ end subroutine wsjt_tsan_acquire_four2avar_setup
+ subroutine wsjt_tsan_release_four2avar_setup() bind(C)
+ end subroutine wsjt_tsan_release_four2avar_setup
+ end interface
+
if(nfft.lt.0) go to 999
nloc=loc(a)
found_plan = .false.
+ !$omp critical(four2avar_setup)
+ call wsjt_tsan_acquire_four2avar_setup()
do i=1,nplan
if(nfft.eq.nn(i) .and. isign.eq.ns(i) .and. &
iform.eq.nf(i) .and. nloc.eq.nl(i)) then
@@ -48,7 +57,6 @@ subroutine four2avar(a,nfft,ndim,isign,iform)
if(i.ge.NPMAX) stop 'Too many FFTW plans requested.'
if (.not. found_plan) then
- !$omp critical(four2avar_setup)
nplan=nplan+1
i=nplan
@@ -90,8 +98,9 @@ subroutine four2avar(a,nfft,ndim,isign,iform)
if(iform.le.0) jz=nfft/2+1
a(1:jz)=aa(1:jz)
endif
- !$omp end critical(four2avar_setup)
end if
+ call wsjt_tsan_release_four2avar_setup()
+ !$omp end critical(four2avar_setup)
call sfftw_execute(plan(i))
return
diff --git a/lib/ft8var/ft4_mod1.f90 b/lib/ft8var/ft4_mod1.f90
index 9bdf2a94..e3cb7619 100644
--- a/lib/ft8var/ft4_mod1.f90
+++ b/lib/ft8var/ft4_mod1.f90
@@ -3,5 +3,6 @@ module ft4_mod1
real*4 dd4(73728)
logical(1) llagcc,lfilter,lhidetest,lhidetelemetry
integer nFT4decd,nfafilt,nfbfilt
+ save dd4
-end module ft4_mod1 \ No newline at end of file
+end module ft4_mod1
diff --git a/lib/ft8var/ft8_decode_ranges.f90 b/lib/ft8var/ft8_decode_ranges.f90
new file mode 100644
index 00000000..40c6b171
--- /dev/null
+++ b/lib/ft8var/ft8_decode_ranges.f90
@@ -0,0 +1,38 @@
+module ft8_decode_ranges
+ implicit none
+ private
+
+ integer, parameter, public :: max_ft8_decode_ranges = 12
+ public :: partition_ft8_decode_range
+
+contains
+
+ pure subroutine partition_ft8_decode_range(nfa,nfb,requested_ranges,range_low,range_high,nranges)
+ integer, intent(in) :: nfa,nfb,requested_ranges
+ integer, intent(out) :: range_low(max_ft8_decode_ranges)
+ integer, intent(out) :: range_high(max_ft8_decode_ranges)
+ integer, intent(out) :: nranges
+ integer :: base_width,extra,i,next_low,range_width,total_width
+
+ range_low=0
+ range_high=-1
+ nranges=0
+
+ if(nfa.gt.nfb) return
+
+ total_width=nfb-nfa+1
+ nranges=min(max(1,requested_ranges),max_ft8_decode_ranges,total_width)
+ base_width=total_width/nranges
+ extra=mod(total_width,nranges)
+ next_low=nfa
+
+ do i=1,nranges
+ range_width=base_width
+ if(i.le.extra) range_width=range_width+1
+ range_low(i)=next_low
+ range_high(i)=next_low+range_width-1
+ next_low=range_high(i)+1
+ enddo
+ end subroutine partition_ft8_decode_range
+
+end module ft8_decode_ranges
diff --git a/lib/ft8var/ft8_decodevar.f90 b/lib/ft8var/ft8_decodevar.f90
index 521ab6da..d7324216 100644
--- a/lib/ft8var/ft8_decodevar.f90
+++ b/lib/ft8var/ft8_decodevar.f90
@@ -21,42 +21,51 @@ module ft8_decodevar
contains
- subroutine decodevar(this,callback,nQSOProgress,nfqso,nft8rxfsens,nftx,nutc, &
+ subroutine decodevar(this,nQSOProgress,nfqso,nft8rxfsens,nftx, &
nfa,nfb,ncandthin,ndtcenter,nsec,napwid,lmycallstd,lhiscallstd, &
stophint,nthr,numthreads,nagainfil,lft8lowth,lft8subpass,lhideft8dupes, &
- lft8apon,ncontest)
+ progress_generation,residual,spectrum)
- use timer_module, only: timer
use omp_lib
- use ft8_a7
+ use ft8_mtd_residual, only : mtd_publish_worker,mtd_transform_phase
+ use decode_completion_module, only : write_decode_progress
use ft8_mod1, only : ndecodes,allmessages,allsnrs,allfreq,odd,even,nmsg, &
- lastrxmsg,lasthcall,calldteven,calldtodd,incall,oddcopy,evencopy, &
- avexdt,mycall,hiscall,dd8,nft8cycles,ncandallthr,nincallthr,evencq, &
+ lastrxmsg,calldteven,calldtodd,incall,oddcopy,evencopy, &
+ avexdt,mycall,hiscall,nft8cycles,ncandallthr,nincallthr,evencq, &
oddcq,numcqsig,numdeccq,evenmyc,oddmyc,nummycsig,numdecmyc,lapmyc, &
evenqso,oddqso,lqsomsgdcd,hisgrid4
+ interface
+ subroutine wsjt_tsan_acquire_ft8_find_dupes() bind(C)
+ end subroutine wsjt_tsan_acquire_ft8_find_dupes
+ subroutine wsjt_tsan_release_ft8_find_dupes() bind(C)
+ end subroutine wsjt_tsan_release_ft8_find_dupes
+ subroutine wsjt_tsan_acquire_ft8_update_structures() bind(C)
+ end subroutine wsjt_tsan_acquire_ft8_update_structures
+ subroutine wsjt_tsan_release_ft8_update_structures() bind(C)
+ end subroutine wsjt_tsan_release_ft8_update_structures
+ end interface
+
include 'ft8_params.f90'
class(ft8_decodervar), intent(inout) :: this
- procedure(ft8_decodevar_callback) :: callback
- real, DIMENSION(:), ALLOCATABLE :: dd8m
- real candidate(4,460),freqsub(200)
+ real, intent(inout) :: residual(180000)
+ complex, intent(inout) :: spectrum(0:96000)
+ real candidate(4,460)
real qual !ft8md
integer, intent(in) :: nQSOProgress,nfqso,nft8rxfsens,nftx,nfa,nfb, &
- ncandthin,ndtcenter,nsec,napwid,nthr,numthreads
+ ncandthin,ndtcenter,nsec,napwid,nthr,numthreads,progress_generation
logical, intent(in) :: nagainfil
logical(1), intent(in) :: stophint,lft8lowth,lft8subpass,lhideft8dupes, &
- lmycallstd,lhiscallstd,lft8apon
+ lmycallstd,lhiscallstd
logical newdat1,lsubtract,ldupe,lFreeText,lspecial
logical(1) lft8sdec,lft8s,lft8sd,lrepliedother,lhashmsg,lqsothread, &
- lhidemsg,lhighsens,lcqcand,lsubtracted,levenint,loddint,lnohiscall, &
+ lhidemsg,lhighsens,lcqcand,levenint,loddint,lnohiscall, &
lnomycall,lnohisgrid
character msg37*37,msg37_2*37,msg26*37,call2*12 !ft8md msg26 was *26
character*37 msgsrcvd(130)
- logical la8
integer nsnr
- character*6 dxgrid
type oddtmp_struct
real freq
@@ -85,7 +94,7 @@ contains
real xdt
complex cs(0:7,79)
end type tmpcqsig_struct
- type(tmpcqsig_struct) tmpcqsig(numcqsig) ! 20 sigs
+ type(tmpcqsig_struct), allocatable :: tmpcqsig(:) ! 20 sigs
type tmpmyc_struct
real freq
@@ -107,9 +116,7 @@ contains
end type tmpqsosig_struct
type(tmpqsosig_struct) tmpqsosig(1)
- this%callback => callback
- la8=.true.
-
+ allocate(tmpcqsig(numcqsig))
oddtmp%lstate=.false.
eventmp%lstate=.false.
nmsgloc=0
@@ -121,13 +128,6 @@ contains
tmpcqsig(:)%freq=6000.0
tmpmycsig(:)%freq=6000.0
tmpqsosig(1)%freq=6000.0
- if(hiscall.eq.'') then
- lastrxmsg(1)%lstate=.false.
- else if(lastrxmsg(1)%lstate .and. lasthcall.ne.hiscall .and. &
- index(lastrxmsg(1)%lastmsg,trim(hiscall)).le.0) then
- lastrxmsg(1)%lstate=.false.
- endif
-
levenint=.false.
loddint=.false.
if(nsec.eq.0 .or. nsec.eq.30) then
@@ -139,11 +139,9 @@ contains
lrepliedother=.false.
lft8sdec=.false.
lqsothread=.false.
- lsubtracted=.false.
ncount=0
mycalllen1=len_trim(mycall)+1
nincallthr(nthr)=0
- nallocthr=0
ncqsignal=0
nmycsignal=0
@@ -212,9 +210,15 @@ contains
syncmin=1.3
do ipass=1,npass
+ if(ipass.eq.4 .or. ipass.eq.7) then
+!$omp barrier
+!$omp single
+ call mtd_transform_phase(ipass)
+!$omp end single
+ endif
+ call mtd_publish_worker(nthr)
newdat1=.true.
lsubtract=.true.
- npos=0
if(ipass.eq.1 .or. ipass.eq.4 .or. ipass.eq.7) then
if(lft8lowth) syncmin=1.225
elseif(ipass.eq.2 .or. ipass.eq.5 .or. ipass.eq.8) then
@@ -224,36 +228,12 @@ contains
endif
if(ipass.gt.5 .or. (ipass.eq.3 .and. npass.eq.3)) lsubtract=.false.
- if(ipass.eq.4) then
-!$omp barrier
-!$omp single
- if(npass.eq.9) then ! 3 decoding cycles
- nallocthr=nthr
- allocate(dd8m(180000), STAT = nAllocateStatus1)
- if(nAllocateStatus1.ne.0) STOP "Not enough memory"
- dd8m=dd8
- endif
- do i=1,179999
- dd8(i)=(dd8(i)+dd8(i+1))/2
- enddo
-!$omp end single
-!$omp barrier
- else if(ipass.eq.7) then
-!$omp barrier
- if(nthr.eq.nallocthr) then
- dd8(1)=dd8m(1)
- do i=2,180000
- dd8(i)=(dd8m(i-1)+dd8m(i))/2
- enddo
- deallocate (dd8m, STAT = nDeAllocateStatus1)
- if (nDeAllocateStatus1.ne.0) print *, 'failed to release memory'
- endif
-!$omp barrier
- endif
-
- call sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass, &
- lqsothread,ncandthin,ndtcenter)
+ call write_decode_progress(progress_generation)
+ call sync8var(residual,nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt, &
+ ipass,lqsothread,ncandthin,ndtcenter,progress_generation)
+ call write_decode_progress(progress_generation)
do icand=1,ncand
+ if(mod(icand,8).eq.0) call write_decode_progress(progress_generation)
sync=candidate(3,icand)
f1=candidate(1,icand)
xdt=candidate(2,icand)
@@ -273,14 +253,16 @@ contains
i3=16
n3=16
- call ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos, &
- freqsub,tmpcqdec,tmpmyc,nagainfil,iaptype,f1,xdt,nbadcrc, &
+ call ft8bvar(residual,spectrum,newdat1,nQSOProgress,nfqso,nftx, &
+ napwid,lsubtract,tmpcqdec,tmpmyc,nagainfil,iaptype,f1,xdt, &
+ nbadcrc, &
lft8sdec,msg37,msg37_2,xsnr,stophint,nthr,lFreeText,ipass, &
lft8subpass,lspecial,lcqcand,ncqsignal,nmycsignal,npass,i3bit, &
lft8s,lmycallstd,lhiscallstd,levenint,loddint,lft8sd,i3,n3, &
nft8rxfsens,ncount,msgsrcvd,lrepliedother,lhashmsg,lqsothread, &
- lft8lowth,lhighsens,lsubtracted,tmpcqsig,tmpmycsig,tmpqsosig, &
- lnohiscall,lnomycall,lnohisgrid,qual,iaptype2)
+ lft8lowth,lhighsens,tmpcqsig,tmpmycsig,tmpqsosig, &
+ lnohiscall,lnomycall,lnohisgrid,qual,iaptype2, &
+ progress_generation)
nsnr=nint(xsnr)
xdt=xdt-0.5
if(nbadcrc.eq.0) then
@@ -292,6 +274,7 @@ contains
endif
!$omp critical(find_dupes)
+ call wsjt_tsan_acquire_ft8_find_dupes()
do k=1,nspecial
!ft8md if(k.eq.2) msg37=msg37_2 ! this splits DXpedition mode msg into 2 lines
ldupe=.false.
@@ -417,9 +400,11 @@ contains
endif
4 continue
enddo !do k
+ call wsjt_tsan_release_ft8_find_dupes()
!$omp end critical(find_dupes)
endif
enddo !icand
+ call write_decode_progress(progress_generation)
ncandthr=ncandthr+ncand
enddo !ipass
@@ -468,6 +453,7 @@ contains
if(nmsgloc.gt.0) then
!$omp critical(update_structures)
+ call wsjt_tsan_acquire_ft8_update_structures()
if(levenint) then
even(nmsg+1:nmsg+nmsgloc)%msg=eventmp(1:nmsgloc)%msg
even(nmsg+1:nmsg+nmsgloc)%freq=eventmp(1:nmsgloc)%freq
@@ -481,34 +467,11 @@ contains
odd(nmsg+1:nmsg+nmsgloc)%lstate=oddtmp(1:nmsgloc)%lstate
nmsg=nmsg+nmsgloc
endif
+ call wsjt_tsan_release_ft8_update_structures()
!$omp end critical(update_structures)
endif
-!$omp single
-! test code for a8 start
- if(lft8apon .and. ncontest.ne.6 .and. ncontest.ne.7 .and. la8 .and. &
- len(trim(hiscall)).ge.3 .and. &
- len(trim(hisgrid4)).ge.4 .and. ltry_a8) then
-! Try for an a8 decode at nfqso
- f1=nfqso
- dxgrid=hisgrid4
- call timer('ft8_a8d ',0)
- call ft8_a8d(dd8,mycall,hiscall,dxgrid,f1,xdt,fbest,xsnr,plog,msg37) !w3sz was dd
- call timer('ft8_a8d ',1)
- if(msg37(1:1).ne.' ') then
- if(associated(this%callback)) then
- sync=10.0 !### ??? !URUR was 10, tried 15
- nsnr=nint(xsnr)
- iaptype=8
- qual=1.0
- if(plog.lt.-147.0) qual=0.16
- call this%callback(nsnr,xdt,fbest,msg37,iaptype,qual)
- endif
- endif
- endif
-! test code for a8 stop
-!$omp end single nowait
-
return
+
end subroutine decodevar
end module ft8_decodevar
diff --git a/lib/ft8var/ft8_downsamplevar.f90 b/lib/ft8var/ft8_downsamplevar.f90
index 7253075e..6e7293f4 100644
--- a/lib/ft8var/ft8_downsamplevar.f90
+++ b/lib/ft8var/ft8_downsamplevar.f90
@@ -1,34 +1,26 @@
-subroutine ft8_downsamplevar(newdat1,f0,nqso,c0,c2,c3,lhighsens,lsubtracted,npos,freqsub)
+subroutine ft8_downsamplevar(residual,cxx,newdat1,f0,nqso,c0,c2,c3,lhighsens)
! Downconvert to complex data sampled at 200 Hz ==> 32 samples/symbol
- use ft8_mod1, only : dd8,windowc1,facc1
+ use ft8_mod1, only : windowc1,facc1
parameter (NFFT1=192000,NFFT2=3200) !192000/60 = 3200
logical newdat1
complex, intent(out) :: c0(-800:4000),c2(-800:4000),c3(-800:4000)
- complex cx(0:96000),cxx(0:96000),c1(0:3199) ! 0:NFFT1/2
+ real, intent(in) :: residual(180000)
+ complex, intent(inout) :: cxx(0:96000)
+ complex cx(0:96000),c1(0:3199) ! 0:NFFT1/2
real x(NFFT1)
real, intent(in) :: f0
integer, intent(in) :: nqso
- real freqsub(200)
logical(1), intent(in) :: lhighsens
- logical(1) lsubtracted,ldofft
equivalence (x,cx)
- save cxx
- ldofft=.false.
- if(lsubtracted) then
- do i=1,npos
- if(abs(f0-freqsub(i)).lt.50.) then; ldofft=.true.; lsubtracted=.false.; exit; endif
- enddo
- endif
-
- if(newdat1 .or. ldofft) then
-! Data in dd have changed, recompute the long FFT
- x(1:180000)=dd8
+ if(newdat1) then
+! Residual has changed, recompute the long FFT
+ x(1:180000)=residual
x(180001:NFFT1)=0. !Zero-pad the x array
call four2avar(cx,NFFT1,1,-1,0) !r2c FFT to freq domain
- newdat1=.false.; ldofft=.false.; npos=0
+ newdat1=.false.
cxx=cx
endif
diff --git a/lib/ft8var/ft8_mod1.f90 b/lib/ft8var/ft8_mod1.f90
index 8bfe3027..cd1f0d2c 100644
--- a/lib/ft8var/ft8_mod1.f90
+++ b/lib/ft8var/ft8_mod1.f90
@@ -1,5 +1,7 @@
module ft8_mod1
+ save
+
parameter (NPS=180000,NFR=151680,NFILT1=4000,NFILT2=3400,numcqsig=20, &
numdeccq=40,nummycsig=5,numdecmyc=25,nmaxthreads=24)
real*4 dd8(nps)
@@ -29,6 +31,8 @@ module ft8_mod1
logical one(0:511,0:8),lqsomsgdcd,first_osd
logical(1) lapmyc,lagcc,lagccbail,lhound,lenabledxcsearch, &
lwidedxcsearch,lmultinst,lskiptx1,ltxing
+ logical(1) idtone25_valid(25),idtone56_valid(56),idtone76_valid(76)
+ logical(1) csyncsd_valid,csyncsdcq_valid
data maskincallthr/0,30,45,55,65,75,85,90,95,100,105,110,115,120,125, &
130,135,140,145,150,155,160,165,170,175/
data mcq/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0/
@@ -99,6 +103,11 @@ module ft8_mod1
data nintcount/0/
data avexdt/0.0/
data first_osd/.true./
+ data idtone25_valid/25*.false./
+ data idtone56_valid/56*.false./
+ data idtone76_valid/76*.false./
+ data csyncsd_valid/.false./
+ data csyncsdcq_valid/.false./
type odd_struct
real freq
diff --git a/lib/ft8var/ft8_mtd_residual.f90 b/lib/ft8var/ft8_mtd_residual.f90
new file mode 100644
index 00000000..2d4dea8d
--- /dev/null
+++ b/lib/ft8var/ft8_mtd_residual.f90
@@ -0,0 +1,459 @@
+module ft8_mtd_residual
+
+ use iso_fortran_env, only : int64
+
+ implicit none
+
+ integer, parameter, public :: mtd_residual_samples=180000
+ integer, parameter, public :: mtd_spectrum_bins=96001
+ integer, parameter, public :: mtd_max_subtractions_per_worker=460
+ integer, parameter, public :: mtd_subtraction_passes=5
+ integer, parameter, public :: mtd_commit_current=1
+ integer, parameter, public :: mtd_commit_independent=2
+ integer, parameter, public :: mtd_commit_conflict=3
+ integer, parameter, public :: mtd_commit_duplicate=4
+ integer, parameter, public :: mtd_commit_fallback=5
+ integer, parameter :: mtd_frame_samples=151680
+ real, parameter :: mtd_interaction_bandwidth=50.0
+
+ type, public :: ft8_subtraction_descriptor
+ integer :: tones(79)=0
+ real :: frequency=0.0
+ real :: dt=0.0
+ integer :: frequency_bin=0
+ integer :: start_sample=0
+ integer :: clipped_start=0
+ integer :: clipped_end=-1
+ integer(int64) :: epoch=0_int64
+ integer :: pass=0
+ integer(int64) :: commit_generation=0_int64
+ end type ft8_subtraction_descriptor
+
+ real, allocatable, save, public :: mtd_worker_residual(:,:)
+ complex, allocatable, save, public :: mtd_worker_spectrum(:,:)
+
+ real, allocatable, save :: canonical_residual(:)
+ real, allocatable, save :: post_pass3_residual(:)
+ real, allocatable, save :: subtraction_delta(:,:)
+ type(ft8_subtraction_descriptor), allocatable, save :: history(:)
+ integer(int64), allocatable, save :: worker_generation(:)
+ integer(int64), allocatable, save :: worker_epoch(:)
+ integer(int64), allocatable, save :: worker_spectrum_generation(:)
+ integer(int64), allocatable, save :: worker_spectrum_epoch(:)
+ integer, save :: active_workers=0
+ integer(int64), save :: canonical_generation=0_int64
+ integer(int64), save :: current_epoch=0_int64
+ integer, save :: history_count=0
+
+ interface
+ subroutine subtractft8var(residual,itone,f0,dt,delta)
+ real, intent(inout) :: residual(180000)
+ integer, intent(in) :: itone(79)
+ real, intent(in) :: f0,dt
+ real, intent(out), optional :: delta(151680)
+ end subroutine subtractft8var
+ subroutine wsjt_tsan_acquire_ft8_mtd() bind(C)
+ end subroutine wsjt_tsan_acquire_ft8_mtd
+ subroutine wsjt_tsan_release_ft8_mtd() bind(C)
+ end subroutine wsjt_tsan_release_ft8_mtd
+ end interface
+
+contains
+
+ subroutine mtd_prepare(input_residual,nworkers)
+ real, intent(in) :: input_residual(:)
+ integer, intent(in) :: nworkers
+
+ if(size(input_residual).ne.mtd_residual_samples) error stop &
+ 'MTD residual has an unexpected sample count'
+ if(nworkers.lt.1) error stop 'MTD requires at least one worker'
+
+ call ensure_capacity(nworkers)
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ active_workers=nworkers
+ current_epoch=current_epoch+1_int64
+ canonical_generation=0_int64
+ history_count=0
+ canonical_residual=input_residual
+ post_pass3_residual=input_residual
+ worker_generation(1:active_workers)=-1_int64
+ worker_epoch(1:active_workers)=current_epoch
+ worker_spectrum_generation(1:active_workers)=-1_int64
+ worker_spectrum_epoch(1:active_workers)=current_epoch
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_prepare
+
+ subroutine ensure_capacity(nworkers)
+ integer, intent(in) :: nworkers
+ integer :: current_workers,history_capacity
+
+ current_workers=0
+ if(allocated(mtd_worker_residual)) current_workers=size(mtd_worker_residual,2)
+ if(current_workers.ge.nworkers) return
+
+ if(allocated(mtd_worker_residual)) deallocate(mtd_worker_residual)
+ if(allocated(mtd_worker_spectrum)) deallocate(mtd_worker_spectrum)
+ if(allocated(subtraction_delta)) deallocate(subtraction_delta)
+ if(allocated(history)) deallocate(history)
+ if(allocated(worker_generation)) deallocate(worker_generation)
+ if(allocated(worker_epoch)) deallocate(worker_epoch)
+ if(allocated(worker_spectrum_generation)) deallocate(worker_spectrum_generation)
+ if(allocated(worker_spectrum_epoch)) deallocate(worker_spectrum_epoch)
+ if(.not.allocated(canonical_residual)) allocate(canonical_residual(mtd_residual_samples))
+ if(.not.allocated(post_pass3_residual)) allocate(post_pass3_residual(mtd_residual_samples))
+
+ history_capacity=mtd_subtraction_passes*mtd_max_subtractions_per_worker*nworkers
+ allocate(mtd_worker_residual(mtd_residual_samples,nworkers))
+ allocate(mtd_worker_spectrum(0:mtd_spectrum_bins-1,nworkers))
+ allocate(subtraction_delta(mtd_frame_samples,nworkers))
+ allocate(history(history_capacity))
+ allocate(worker_generation(nworkers))
+ allocate(worker_epoch(nworkers))
+ allocate(worker_spectrum_generation(nworkers))
+ allocate(worker_spectrum_epoch(nworkers))
+ end subroutine ensure_capacity
+
+ subroutine mtd_publish_worker(worker)
+ integer, intent(in) :: worker
+
+ call assert_worker(worker)
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ mtd_worker_residual(:,worker)=canonical_residual
+ worker_generation(worker)=canonical_generation
+ worker_epoch(worker)=current_epoch
+ worker_spectrum_generation(worker)=-1_int64
+ worker_spectrum_epoch(worker)=current_epoch
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_publish_worker
+
+ subroutine mtd_refresh_candidate(worker,frequency,newdat1,rebuild_spectrum)
+ integer, intent(in) :: worker
+ real, intent(in) :: frequency
+ logical, intent(inout) :: newdat1
+ logical, intent(out) :: rebuild_spectrum
+ integer :: i
+ logical :: refresh_residual
+
+ call assert_worker(worker)
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ refresh_residual=worker_epoch(worker).ne.current_epoch
+ if(.not.refresh_residual) then
+ do i=1,history_count
+ if(history(i)%epoch.ne.current_epoch .or. &
+ history(i)%commit_generation.le.worker_generation(worker)) cycle
+ if(abs(history(i)%frequency-frequency).lt.mtd_interaction_bandwidth) then
+ refresh_residual=.true.
+ exit
+ endif
+ enddo
+ endif
+ if(refresh_residual) then
+ mtd_worker_residual(:,worker)=canonical_residual
+ worker_generation(worker)=canonical_generation
+ worker_epoch(worker)=current_epoch
+ newdat1=.true.
+ endif
+ if(worker_spectrum_epoch(worker).ne.worker_epoch(worker)) newdat1=.true.
+ if(.not.newdat1) then
+ do i=1,history_count
+ if(history(i)%epoch.ne.worker_epoch(worker) .or. &
+ history(i)%commit_generation.le.worker_spectrum_generation(worker) .or. &
+ history(i)%commit_generation.gt.worker_generation(worker)) cycle
+ if(abs(history(i)%frequency-frequency).lt.mtd_interaction_bandwidth) then
+ newdat1=.true.
+ exit
+ endif
+ enddo
+ endif
+ rebuild_spectrum=newdat1
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_refresh_candidate
+
+ subroutine mtd_mark_spectrum_current(worker)
+ integer, intent(in) :: worker
+
+ call assert_worker(worker)
+ worker_spectrum_generation(worker)=worker_generation(worker)
+ worker_spectrum_epoch(worker)=worker_epoch(worker)
+ end subroutine mtd_mark_spectrum_current
+
+ subroutine mtd_commit_subtraction(worker,ipass,itone,f0,dt,residual,final_outcome)
+ integer, intent(in) :: worker,ipass,itone(79)
+ real, intent(in) :: f0,dt
+ real, intent(inout) :: residual(mtd_residual_samples)
+ integer, intent(out), optional :: final_outcome
+ type(ft8_subtraction_descriptor) :: descriptor
+ integer(int64) :: base_generation,base_epoch
+ integer :: outcome
+
+ call assert_worker(worker)
+ call mtd_make_descriptor(descriptor,ipass,itone,f0,dt)
+ base_generation=worker_generation(worker)
+ base_epoch=worker_epoch(worker)
+ descriptor%epoch=base_epoch
+ call fit_subtraction(worker,residual,descriptor)
+ call mtd_try_commit_delta(worker,residual,descriptor,base_epoch, &
+ base_generation,subtraction_delta(:,worker),outcome)
+ if(outcome.ne.mtd_commit_conflict) then
+ if(present(final_outcome)) final_outcome=outcome
+ return
+ endif
+
+ base_generation=worker_generation(worker)
+ base_epoch=worker_epoch(worker)
+ descriptor%epoch=base_epoch
+ call fit_subtraction(worker,residual,descriptor)
+ call mtd_try_commit_delta(worker,residual,descriptor,base_epoch, &
+ base_generation,subtraction_delta(:,worker),outcome)
+ if(outcome.ne.mtd_commit_conflict) then
+ if(present(final_outcome)) final_outcome=outcome
+ return
+ endif
+
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ descriptor%epoch=current_epoch
+ if(history_contains_duplicate(descriptor)) then
+ outcome=mtd_commit_duplicate
+ else
+ ! No caller holds an FFT lock while entering this transaction region.
+ call subtractft8var(canonical_residual,descriptor%tones, &
+ descriptor%frequency,descriptor%dt)
+ call record_commit(descriptor)
+ outcome=mtd_commit_fallback
+ endif
+ residual=canonical_residual
+ worker_generation(worker)=canonical_generation
+ worker_epoch(worker)=current_epoch
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ if(present(final_outcome)) final_outcome=outcome
+ end subroutine mtd_commit_subtraction
+
+ subroutine mtd_capture_generation(worker,epoch,generation)
+ integer, intent(in) :: worker
+ integer(int64), intent(out) :: epoch,generation
+
+ call assert_worker(worker)
+ epoch=worker_epoch(worker)
+ generation=worker_generation(worker)
+ end subroutine mtd_capture_generation
+
+ subroutine mtd_try_commit_delta(worker,residual,descriptor,base_epoch, &
+ base_generation,delta,outcome)
+ integer, intent(in) :: worker
+ real, intent(inout) :: residual(mtd_residual_samples)
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+ integer(int64), intent(in) :: base_epoch,base_generation
+ real, intent(in) :: delta(mtd_frame_samples)
+ integer, intent(out) :: outcome
+ logical :: stale
+
+ call assert_worker(worker)
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ if(history_contains_duplicate(descriptor)) then
+ outcome=mtd_commit_duplicate
+ else if(history_has_conflict(base_epoch,base_generation,descriptor)) then
+ outcome=mtd_commit_conflict
+ else
+ stale=base_epoch.ne.current_epoch .or. base_generation.ne.canonical_generation
+ call apply_fitted_subtraction(delta,descriptor)
+ if(stale) then
+ outcome=mtd_commit_independent
+ else
+ outcome=mtd_commit_current
+ endif
+ endif
+ if(outcome.eq.mtd_commit_conflict .or. outcome.eq.mtd_commit_duplicate .or. &
+ outcome.eq.mtd_commit_independent) residual=canonical_residual
+ worker_generation(worker)=canonical_generation
+ worker_epoch(worker)=current_epoch
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_try_commit_delta
+
+ subroutine fit_subtraction(worker,residual,descriptor)
+ integer, intent(in) :: worker
+ real, intent(inout) :: residual(mtd_residual_samples)
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+
+ call subtractft8var(residual,descriptor%tones, &
+ descriptor%frequency,descriptor%dt,subtraction_delta(:,worker))
+ end subroutine fit_subtraction
+
+ subroutine apply_fitted_subtraction(delta,descriptor)
+ real, intent(in) :: delta(mtd_frame_samples)
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+
+ integer :: i,j
+
+ do i=1,mtd_frame_samples
+ j=descriptor%start_sample+i-1
+ if(j.ge.1 .and. j.le.mtd_residual_samples) &
+ canonical_residual(j)=canonical_residual(j)+delta(i)
+ enddo
+ call record_commit(descriptor)
+ end subroutine apply_fitted_subtraction
+
+ subroutine record_commit(descriptor)
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+
+ history_count=history_count+1
+ if(history_count.gt.size(history)) error stop 'MTD transaction history capacity exceeded'
+ canonical_generation=canonical_generation+1_int64
+ history(history_count)=descriptor
+ history(history_count)%commit_generation=canonical_generation
+ end subroutine record_commit
+
+ logical function history_contains_duplicate(descriptor)
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+ integer :: i
+
+ history_contains_duplicate=.false.
+ do i=1,history_count
+ if(history(i)%epoch.ne.descriptor%epoch .or. &
+ history(i)%pass.ne.descriptor%pass) cycle
+ if(mtd_same_signal(history(i),descriptor)) then
+ history_contains_duplicate=.true.
+ return
+ endif
+ enddo
+ end function history_contains_duplicate
+
+ logical function history_has_conflict(base_epoch,base_generation,descriptor)
+ integer(int64), intent(in) :: base_epoch,base_generation
+ type(ft8_subtraction_descriptor), intent(in) :: descriptor
+ integer :: i
+
+ history_has_conflict=base_epoch.ne.current_epoch .or. &
+ descriptor%epoch.ne.current_epoch
+ if(history_has_conflict) return
+ do i=1,history_count
+ if(history(i)%epoch.ne.descriptor%epoch .or. &
+ history(i)%commit_generation.le.base_generation) cycle
+ if(mtd_descriptors_conflict(history(i),descriptor)) then
+ history_has_conflict=.true.
+ return
+ endif
+ enddo
+ end function history_has_conflict
+
+ subroutine mtd_make_descriptor(descriptor,ipass,itone,f0,dt)
+ type(ft8_subtraction_descriptor), intent(out) :: descriptor
+ integer, intent(in) :: ipass,itone(79)
+ real, intent(in) :: f0,dt
+
+ descriptor%tones=itone
+ descriptor%frequency=f0
+ descriptor%dt=dt
+ descriptor%frequency_bin=nint(f0/0.0625)
+ descriptor%start_sample=mtd_start_sample(dt)
+ call mtd_clipped_interval(dt,descriptor%clipped_start,descriptor%clipped_end)
+ descriptor%epoch=current_epoch
+ descriptor%pass=ipass
+ descriptor%commit_generation=0_int64
+ end subroutine mtd_make_descriptor
+
+ integer function mtd_start_sample(dt)
+ real, intent(in) :: dt
+
+ mtd_start_sample=int(dt*12000.0+1.0)
+ end function mtd_start_sample
+
+ subroutine mtd_clipped_interval(dt,first_sample,last_sample)
+ real, intent(in) :: dt
+ integer, intent(out) :: first_sample,last_sample
+ integer :: start_sample
+
+ start_sample=mtd_start_sample(dt)
+ first_sample=max(1,start_sample)
+ last_sample=min(mtd_residual_samples,start_sample+mtd_frame_samples-1)
+ end subroutine mtd_clipped_interval
+
+ logical function mtd_same_signal(left,right)
+ type(ft8_subtraction_descriptor), intent(in) :: left,right
+
+ mtd_same_signal=left%frequency_bin.eq.right%frequency_bin .and. &
+ left%start_sample.eq.right%start_sample .and. all(left%tones.eq.right%tones)
+ end function mtd_same_signal
+
+ logical function mtd_descriptors_conflict(left,right)
+ type(ft8_subtraction_descriptor), intent(in) :: left,right
+ logical :: overlap
+
+ overlap=left%clipped_start.le.left%clipped_end .and. &
+ right%clipped_start.le.right%clipped_end .and. &
+ left%clipped_start.le.right%clipped_end .and. &
+ right%clipped_start.le.left%clipped_end
+ mtd_descriptors_conflict=overlap .and. &
+ abs(left%frequency-right%frequency).lt.mtd_interaction_bandwidth
+ end function mtd_descriptors_conflict
+
+ subroutine mtd_transform_phase(ipass)
+ integer, intent(in) :: ipass
+
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ if(ipass.eq.4) then
+ post_pass3_residual=canonical_residual
+ call mtd_forward_half_sample(canonical_residual)
+ else if(ipass.eq.7) then
+ canonical_residual=post_pass3_residual
+ call mtd_backward_half_sample(canonical_residual)
+ else
+ error stop 'Invalid MTD transform pass'
+ endif
+ current_epoch=current_epoch+1_int64
+ canonical_generation=canonical_generation+1_int64
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_transform_phase
+
+ subroutine mtd_finish(output_residual)
+ real, intent(out) :: output_residual(:)
+
+ if(size(output_residual).ne.mtd_residual_samples) error stop &
+ 'MTD output residual has an unexpected sample count'
+!$omp critical(ft8_mtd_canonical)
+ call wsjt_tsan_acquire_ft8_mtd()
+ output_residual=canonical_residual
+ call wsjt_tsan_release_ft8_mtd()
+!$omp end critical(ft8_mtd_canonical)
+ end subroutine mtd_finish
+
+ subroutine mtd_forward_half_sample(residual)
+ real, intent(inout) :: residual(:)
+ integer :: i
+
+ if(size(residual).ne.mtd_residual_samples) error stop &
+ 'MTD forward transform has an unexpected sample count'
+ do i=1,mtd_residual_samples-1
+ residual(i)=(residual(i)+residual(i+1))/2.0
+ enddo
+ end subroutine mtd_forward_half_sample
+
+ subroutine mtd_backward_half_sample(residual)
+ real, intent(inout) :: residual(:)
+ integer :: i
+
+ if(size(residual).ne.mtd_residual_samples) error stop &
+ 'MTD backward transform has an unexpected sample count'
+ do i=mtd_residual_samples,2,-1
+ residual(i)=(residual(i-1)+residual(i))/2.0
+ enddo
+ end subroutine mtd_backward_half_sample
+
+ subroutine assert_worker(worker)
+ integer, intent(in) :: worker
+
+ if(worker.lt.1 .or. worker.gt.active_workers) error stop 'Invalid MTD worker index'
+ end subroutine assert_worker
+
+end module ft8_mtd_residual
diff --git a/lib/ft8var/ft8_tsan.c b/lib/ft8var/ft8_tsan.c
new file mode 100644
index 00000000..1905ca07
--- /dev/null
+++ b/lib/ft8var/ft8_tsan.c
@@ -0,0 +1,30 @@
+#if defined(__SANITIZE_THREAD__)
+#include <sanitizer/tsan_interface.h>
+#endif
+
+// GCC TSan does not observe libgomp synchronization. Stable tokens mirror the
+// OpenMP edges without changing production synchronization.
+#if defined(__SANITIZE_THREAD__)
+#define WSJT_TSAN_SYNC(name) \
+ static unsigned char name##_token; \
+ void wsjt_tsan_acquire_##name(void) \
+ { \
+ __tsan_acquire(&name##_token); \
+ } \
+ void wsjt_tsan_release_##name(void) \
+ { \
+ __tsan_release(&name##_token); \
+ }
+#else
+#define WSJT_TSAN_SYNC(name) \
+ void wsjt_tsan_acquire_##name(void) {} \
+ void wsjt_tsan_release_##name(void) {}
+#endif
+
+WSJT_TSAN_SYNC(ft8_mtd)
+WSJT_TSAN_SYNC(four2avar_setup)
+WSJT_TSAN_SYNC(ft8_find_dupes)
+WSJT_TSAN_SYNC(ft8_update_structures)
+WSJT_TSAN_SYNC(decoder_section_primary)
+WSJT_TSAN_SYNC(decoder_section_secondary)
+WSJT_TSAN_SYNC(msk40_sync)
diff --git a/lib/ft8var/ft8apsetvar.f90 b/lib/ft8var/ft8apsetvar.f90
index 6a247a38..f23d604e 100644
--- a/lib/ft8var/ft8apsetvar.f90
+++ b/lib/ft8var/ft8apsetvar.f90
@@ -7,15 +7,28 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
character*77 c77
character*37 msg,msgchk
character*12 hiscallt,mycallprev,hiscallprev
+ integer :: i1,i3,n3,nlenmyc
logical lnohiscall,unpk77_successvar,first
logical(1) lhoundprev
logical(1), intent(in) :: lmycallstd,lhiscallstd
+ type(unpack77_options) :: no_record_options
+ type(pack77_options) :: no_tx_hash_options
data mycallprev/'QQ2QQ'/
data hiscallprev/'QQ1QQ'/
data lhoundprev/.false./
data first/.true./
save hiscallprev,mycallprev,lhoundprev,first
+ i1=0
+ i3=-1
+ n3=-1
+ nlenmyc=0
+! AP mask generation packs and unpacks synthetic messages only to derive symbol
+! masks; it must not teach those calls to the shared hash or recent-call state.
+ no_record_options=unpack77_options(record_hashes=.false., &
+ record_recent_calls=.false.)
+ no_tx_hash_options=pack77_options(record_tx_hashes=.false.)
+
if(hiscall.ne.hiscallprev .or. mycall.ne.mycallprev .or. (lhound.neqv.lhoundprev) .or. first) then ! first for lhound triggered
first=.false.; mycallprev=mycall; lhoundprev=lhound
@@ -38,8 +51,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
else; msg='CQ '//trim(hiscall)
endif
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(lhiscallstd .and. i3.ne.1 .or. .not.lhiscallstd .and. i3.ne.4 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 1
read(c77,'(77i1)',err=1) apcqsym(1:77)
@@ -49,8 +62,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
if(lhiscallstd .and. .not.lmycallstd) then
msg=trim(hiscall)//' '//trim(hiscall)//' RRR'
i3=0; n3=0
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 2
read(c77,'(58i1)',err=2) apsymdxstd(1:58)
@@ -60,16 +73,16 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
if(.not.lhound .and. .not.lhiscallstd .and. len_trim(hiscall).gt.2) then
! nonstandard DXCall searching
msg='<W9XYZ> '//trim(hiscall)//' RR73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.4 .or. .not.unpk77_successvar) go to 3
read(c77,'(77i1)',err=3) apsymdxnsrr73(1:77)
apsymdxnsrr73=2*apsymdxnsrr73-1
msg='<W9XYZ> '//trim(hiscall)//' 73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.4 .or. .not.unpk77_successvar) go to 4
read(c77,'(77i1)',err=4) apsymdxns73(1:77)
@@ -80,28 +93,28 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
if(.not.lhound .and. .not.lmycallstd .and. len_trim(mycall).gt.2) then
if(lhiscallstd) then
msg='<'//trim(mycall)//'> '//trim(hiscall)//' -15'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
if(i3.ne.1 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 5
read(c77,'(58i1)',err=5) apsymmyns2(1:58)
apsymmyns2=2*apsymmyns2-1
nlenmyc=len_trim(mycall)
msg=trim(mycall)//' <'//trim(hiscall)//'> RR73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 6
read(c77,'(77i1)',err=6) apsymmynsrr73(1:77)
apsymmynsrr73=2*apsymmynsrr73-1
msg=trim(mycall)//' <'//trim(hiscall)//'> 73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 7
read(c77,'(77i1)',err=7) apsymmyns73(1:77)
apsymmyns73=2*apsymmyns73-1
msg=trim(mycall)//' <'//trim(hiscall)//'> RRR'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 15
read(c77,'(77i1)',err=15) apsymmynsrrr(1:77)
apsymmynsrrr=2*apsymmynsrrr-1
@@ -109,8 +122,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
else if(lnohiscall) then
msg='<'//trim(mycall)//'> ZZ1ZZZ -15'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
if(i3.ne.1 .or. msgchk.ne.msg .or. .not.unpk77_successvar) go to 8
read(c77,'(29i1)',err=8) apsymmyns1(1:29)
apsymmyns1=2*apsymmyns1-1
@@ -122,8 +135,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
if(.not.lhound .and. lmycallstd .and. (lhiscallstd .or. lnohiscall)) then
msg=trim(mycall)//' '//trim(hiscallt)//' RRR'
i3=0; n3=0
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 9
read(c77,'(58i1)',err=9) apsym(1:58)
@@ -134,8 +147,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
! standard messages from Fox, always base callsigns
if(len_trim(hisbcall).gt.2 .and. len_trim(mybcall).gt.2) then
msg=trim(mybcall)//' '//trim(hisbcall)//' -15'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.1 .or. (msg.ne.msgchk) .or. .not.unpk77_successvar) go to 9
read(c77,'(58i1)',err=9) apsym(1:58)
@@ -147,8 +160,8 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
! special messages
msg=trim(mycall)//' RR73; '//trim(mycall)//' <'//trim(hiscallt)//'> -16'
i3=0; n3=1
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
i1=0; i1=index(msgchk,'<'); if(i1.lt.15) return
if(i3.ne.0 .or. msg(1:i1).ne.msgchk(1:i1) .or. .not.unpk77_successvar) go to 10
@@ -158,32 +171,32 @@ subroutine ft8apsetvar(lmycallstd,lhiscallstd,numthreads)
if(.not.lhound .and. lmycallstd .and. .not.lhiscallstd .and. len_trim(hiscall).gt.2) then
msg=trim(mycall)//' <'//trim(hiscall)//'> -16' ! report, rreport
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.1 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 11
read(c77,'(58i1)',err=11) apsymdxns1(1:58)
apsymdxns1=2*apsymdxns1-1
msg='<'//trim(mycall)//'> '//trim(hiscall)//' RRR'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 12
read(c77,'(77i1)',err=12) apsymdxnsrrr(1:77)
apsymdxnsrrr=2*apsymdxnsrrr-1
msg='<'//trim(mycall)//'> '//trim(hiscall)//' RR73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 13
read(c77,'(77i1)',err=13) apsymdxnsr73(1:77)
apsymdxnsr73=2*apsymdxnsr73-1
msg='<'//trim(mycall)//'> '//trim(hiscall)//' 73'
- call pack77var(msg,i3,n3,c77,0)
- call unpack77var(c77,1,msgchk,unpk77_successvar,25)
+ call pack77(msg,i3,n3,c77,no_tx_hash_options)
+ call unpack77_configured(c77,1,msgchk,unpk77_successvar,no_record_options)
!read(c77(75:77),'(b3)') k3; print *,'i3 =',k3; print *,msgchk
if(i3.ne.4 .or. msg.ne.msgchk .or. .not.unpk77_successvar) go to 14
read(c77,'(77i1)',err=14) apsymdxns732(1:77)
diff --git a/lib/ft8var/ft8bvar.f90 b/lib/ft8var/ft8bvar.f90
index 6a12b933..caf1d94c 100644
--- a/lib/ft8var/ft8bvar.f90
+++ b/lib/ft8var/ft8bvar.f90
@@ -1,47 +1,57 @@
-subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub, &
- tmpcqdec,tmpmyc,nagainfil,iaptype,f1,xdt,nbadcrc,lft8sdec,msg37,msg37_2, &
+subroutine ft8bvar(residual,spectrum,newdat1,nQSOProgress,nfqso,nftx,napwid, &
+ lsubtract,tmpcqdec,tmpmyc,nagainfil,iaptype,f1,xdt,nbadcrc,lft8sdec, &
+ msg37,msg37_2, &
xsnr,stophint,nthr,lFreeText,ipass,lft8subpass,lspecial,lcqcand,ncqsignal, &
nmycsignal,npass,i3bit,lft8s,lmycallstd,lhiscallstd,levenint,loddint,lft8sd, &
i3,n3,nft8rxfsens,ncount,msgsrcvd,lrepliedother,lhashmsg,lqsothread, &
- lft8lowth,lhighsens,lsubtracted,tmpcqsig,tmpmycsig,tmpqsosig,lnohiscall, &
- lnomycall,lnohisgrid,qual,iaptype2)
+ lft8lowth,lhighsens,tmpcqsig,tmpmycsig,tmpqsosig,lnohiscall, &
+ lnomycall,lnohisgrid,qual,iaptype2,progress_generation)
- use packjt77, only : unpack77var
+ use packjt77, only : unpack77, unpack77_configured, unpack77_options
+ use ft8_mtd_residual, only : mtd_commit_subtraction,mtd_mark_spectrum_current, &
+ mtd_refresh_candidate
+ use decode_completion_module, only : write_decode_progress
use ft8_mod1, only : allmessages,ndecodes,apsym,mcq,m73,mrr73,mrrr,icos7, &
naptypes,nhaptypes,one,graymap,oddcopy,evencopy,lastrxmsg,lasthcall, &
nlasttx,calldteven,calldtodd,lqsomsgdcd,mycalllen1,msgroot,msgrootlen, &
- allfreq,idtone25,lapmyc,idtonemyc,mycall,hiscall,lhound,apsymsp, &
+ allfreq,idtone25,idtone25_valid,lapmyc,idtonemyc,mycall,hiscall,lhound,apsymsp, &
ndxnsaptypes,apsymdxns1,apsymdxnsrrr,lenabledxcsearch,lwidedxcsearch, &
apcqsym,apsymdxnsrr73,apsymdxns73,mybcall,hisbcall,lskiptx1,nft8cycles, &
ctwkw,ctwkn,nincallthr,msgincall,xdtincall,maskincallthr,ctwk256,numcqsig, &
numdeccq,evencq,oddcq,nummycsig,numdecmyc,evenmyc,oddmyc,idtone56, &
+ idtone56_valid, &
idtonecqdxcns,evenqso,oddqso,nmycnsaptypes,apsymmyns1,apsymmyns2, &
apsymmynsrr73,apsymmyns73,apsymdxstd,apsymdxnsr73,apsymdxns732,ltxing, &
apsymmynsrrr,idtonedxcns73,idtonefox73,idtonespec !ft8md added
include 'ft8_params.f90'
+ real, intent(inout) :: residual(180000)
+ complex, intent(inout) :: spectrum(0:96000)
character c77*77,msg37*37,msg37_2*37,msgd*37,msgbase37*37,call_a*12,call_b*12
character callsign*12,grid*12
character*37 msgsrcvd(130)
complex cd0(-800:4000),cd1(-800:4000),cd2(-800:4000),cd3(-800:4000),ctwk(32), &
- csymb(32),cs(0:7,79),csymbr(32),csr(0:7,79),csig(32),csig0(151680),z1, &
+ csymb(32),cs(0:7,79),csymbr(32),csr(0:7,79),csig(32),z1, &
csymb256(256),cstmp2(0:7,79),csold(0:7,79),cscs(0:7,79)
+ complex, allocatable :: csig0(:)
real a(5),s8(0:7,79),s82(0:7,79),s2(0:511),sp(0:7),s81(0:7),snrsync(21), &
- syncw(7),sumkw(7),scoreratiow(7),freqsub(200),s256(0:8),s2563(0:26), &
+ syncw(7),sumkw(7),scoreratiow(7),s256(0:8),s2563(0:26), &
syncavpart(3)
real bmeta(174),bmetb(174),bmetc(174),bmetd(174)
real llra(174),llrb(174),llrc(174),llrd(174),llrz(174)
real qual !ft8md
integer*1 message77(77),apmask(174),cw(174),nsmax(8)
integer itone(79),ip(1),ka(1),nqsoend(3)
- integer, intent(in) :: nQSOProgress,nfqso,nftx,napwid,nthr,ipass,nft8rxfsens
+ integer, intent(in) :: nQSOProgress,nfqso,nftx,napwid,nthr,ipass,nft8rxfsens, &
+ progress_generation
logical newdat1,lsubtract,lFreeText,nagainfil,lspecial,unpk77_successvar
+ logical rebuild_spectrum
logical(1), intent(in) :: stophint,lft8subpass,lmycallstd,lhiscallstd, &
lqsothread,lft8lowth,lhighsens,lcqcand,levenint,loddint,lnohiscall, &
lnomycall,lnohisgrid
logical(1) falsedec,lastsync,ldupemsg,lft8s,lft8sdec,lft8sd,lsdone,ldupeft8sd, &
lrepliedother,lhashmsg,lvirtual2,lvirtual3,lsd,lcq,ldeepsync,lcallsstd, &
- lfound,lsubptxfreq,lreverse,lchkcall,lgvalid,lwrongcall,lsubtracted, &
+ lfound,lsubptxfreq,lreverse,lchkcall,lgvalid,lwrongcall, &
lcqsignal,loutapwid,lfoundcq,lmycsignal,lfoundmyc,lqsosig,ldxcsig, &
lcqdxcsig,lcqdxcnssig,lqsocandave,lcall1hash,lqsosigtype3,lqso73,lqsorr73, &
lqsorrr,lfoxspecrpt,lfoxstdr73,lapcqonly,lcall2hash,lskipnotap
@@ -185,8 +195,10 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
endif
endif
- call ft8_downsamplevar(newdat1,f1,nqso,cd0,cd2,cd3,lhighsens,lsubtracted,npos, &
- freqsub) !Mix f1 to baseband and downsample
+ call mtd_refresh_candidate(nthr,f1,newdat1,rebuild_spectrum)
+ call ft8_downsamplevar(residual,spectrum,newdat1,f1,nqso,cd0,cd2,cd3, &
+ lhighsens) !Mix f1 to baseband and downsample
+ if(rebuild_spectrum) call mtd_mark_spectrum_current(nthr)
lsd=.false.
isd=1
@@ -847,16 +859,18 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
if(.not.lqsomsgdcd .and. (dfqso.lt.napwid .or. abs(nftx-f1).lt.napwid) .and. &
lapmyc .and. len_trim(hiscall).gt.2) then
nqsot=0
- do i=1,19
- ip=maxloc(s8(:,i+7))
- if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
- enddo
- if(nqsot.gt.6) lqsosig=.true. ! decoding depth only
- do i=20,22
- ip=maxloc(s8(:,i+7))
- if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
- enddo
- if(nqsot.gt.3) lqsosigtype3=.true.
+ if(idtone56_valid(1)) then
+ do i=1,19
+ ip=maxloc(s8(:,i+7))
+ if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
+ enddo
+ if(nqsot.gt.6) lqsosig=.true. ! decoding depth only
+ do i=20,22
+ ip=maxloc(s8(:,i+7))
+ if(ip(1).eq.idtone56(1,i)+1) nqsot=nqsot+1
+ enddo
+ if(nqsot.gt.3) lqsosigtype3=.true.
+ endif
nqsoend=0 ! array 73,rr73,rrr
if(dfqso.lt.napwid .and. (nQSOProgress.eq.3 .or. nQSOProgress.eq.4)) then
! QSO RX freq only
@@ -866,9 +880,9 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
else
ip=maxloc(s8(:,i+14))
endif
- if(ip(1).eq.idtone56(56,i)+1) nqsoend(1)=nqsoend(1)+1
- if(ip(1).eq.idtone56(55,i)+1) nqsoend(2)=nqsoend(2)+1
- if(ip(1).eq.idtone56(54,i)+1) nqsoend(3)=nqsoend(3)+1
+ if(idtone56_valid(56) .and. ip(1).eq.idtone56(56,i)+1) nqsoend(1)=nqsoend(1)+1
+ if(idtone56_valid(55) .and. ip(1).eq.idtone56(55,i)+1) nqsoend(2)=nqsoend(2)+1
+ if(idtone56_valid(54) .and. ip(1).eq.idtone56(54,i)+1) nqsoend(3)=nqsoend(3)+1
enddo
ip=maxloc(nqsoend)
if(nqsoend(ip(1)).gt.6) then
@@ -900,10 +914,12 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
lcqdxcnssig=.false.
ndxt=0
if(lhiscallstd) then
- do k11=17,26
- ip=maxloc(s8(:,k11))
- if(ip(1).eq.idtone56(1,k11-7)+1) ndxt=ndxt+1
- enddo
+ if(idtone56_valid(1)) then
+ do k11=17,26
+ ip=maxloc(s8(:,k11))
+ if(ip(1).eq.idtone56(1,k11-7)+1) ndxt=ndxt+1
+ enddo
+ endif
if(ndxt.gt.3) ldxcsig=.true.
if(lcqsignal .and. ldxcsig) lcqdxcsig=.true.
endif
@@ -1056,6 +1072,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
endif
do isubp1=1,nsubpasses
+ call write_decode_progress(progress_generation)
if(nweak.eq.1 .and. isubp1.eq.2) cycle
! skip if it is lmycsignal, can be both lcq and lmy
@@ -1307,6 +1324,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
! print*,'hisgrid is ',hisgrid
do isubp2=1,31
+ call write_decode_progress(progress_generation)
if(isubp2.lt.5) then
if(lapcqonly .or. lskipnotap) cycle
if(ltxing) then
@@ -1381,6 +1399,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
if(iaptype.eq.1) then
if(isubp2.eq.20) then
+ if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
@@ -1553,6 +1572,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
if(iaptype.eq.1) then
if(isubp2.eq.20) then
+ if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
@@ -1703,6 +1723,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
if(iaptype.eq.1) then
if(isubp2.eq.20) then
+ if(.not.idtone25_valid(2)) cycle
scqlev=0.
do i4=1,9
scqlev=scqlev+s8(idtone25(2,i4),i4+7)
@@ -2091,7 +2112,8 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
if(nagainfil) ndeep=5
!print *,omp_get_nested(),OMP_get_num_threads()
- call osd174_91var(llrz,apmask,ndeep,message77,cw,nharderrors,dmin,nthr)
+ call osd174_91var(llrz,apmask,ndeep,message77,cw,nharderrors,dmin, &
+ nthr,progress_generation)
endif
nbadcrc=1
@@ -2253,7 +2275,8 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
! and n3.eq.5 for USA calls with EU VHF
! added .or. n3.eq.2 .or. n3.eq.8 .or. n3.eq.9 as test for EU VHF
!print*,'did not cycle at line 2248'
- call unpack77var(c77,1,msg37,unpk77_successvar,nthr)
+ call unpack77_configured(c77,1,msg37,unpk77_successvar, &
+ unpack77_options(thread_index=nthr))
if(.not.unpk77_successvar) then
if(lqsothread .and. (.not.lhound .and. iaptype.ge.3 .or. lhound .and. &
(iaptype.eq.21 .or. iaptype.eq.23)) .and. .not.lsdone) then
@@ -2901,6 +2924,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
syncp=0.
syncm=0.
k=1
+ allocate(csig0(151680))
call gen_ft8wavevar(itone,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
do i=0,78
do j=1,32
@@ -2920,6 +2944,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
z1=sum(cd0(i21:i21+31)*conjg(csig))
syncm = syncm + real(z1)**2 + aimag(z1)**2
enddo
+ deallocate(csig0)
call peakup(syncm,sync0,syncp,dx)
if(abs(dx).gt.1.0) then
scorr=0.
@@ -2927,12 +2952,7 @@ subroutine ft8bvar(newdat1,nQSOProgress,nfqso,nftx,napwid,lsubtract,npos,freqsub
scorr=real(noff)*(dx) ! was * dx ft8md
endif
xdt3=xdt+scorr*dt2
- call subtractft8var(itone,f1,xdt3)
- lsubtracted=.true. ! inside current thread
- if(npos.lt.200) then
- npos=npos+1
- freqsub(npos)=f1
- endif
+ call mtd_commit_subtraction(nthr,ipass,itone,f1,xdt3,residual)
endif
endif
diff --git a/lib/ft8var/ft8mf1var.f90 b/lib/ft8var/ft8mf1var.f90
index eff9f236..df4400bd 100644
--- a/lib/ft8var/ft8mf1var.f90
+++ b/lib/ft8var/ft8mf1var.f90
@@ -1,7 +1,7 @@
subroutine ft8mf1var(s8,itone,msgd,msg37,lft8sd)
- use ft8_mod1, only : itone76,idtone76,msgsd76
+ use ft8_mod1, only : itone76,idtone76,msgsd76,idtone76_valid
real, intent(in) :: s8(0:7,79)
real s8d(0:7,58)
character msgd*37,msg37*37,msggrid*37,c1*12,c2*12,grid*4
@@ -37,6 +37,7 @@ subroutine ft8mf1var(s8,itone,msgd,msg37,lft8sd)
ipk=0; u1=0.0; u2=0.0
do k=1,76
+ if(.not.idtone76_valid(k)) cycle
psum=0.; ref=ref0
do j=1,58; i3=idtone76(k,j); psum=psum + s8d(i3,j); if(i3.eq.mrs(j)) ref=ref - s8d(i3,j) + s8d(mrs2(j),j); enddo
p=psum/ref
diff --git a/lib/ft8var/ft8mfcqvar.f90 b/lib/ft8var/ft8mfcqvar.f90
index 092493da..bd58058e 100644
--- a/lib/ft8var/ft8mfcqvar.f90
+++ b/lib/ft8var/ft8mfcqvar.f90
@@ -1,7 +1,7 @@
subroutine ft8mfcqvar(s8,itone,msgd,msg37,lft8sd)
- use ft8_mod1, only : idtone25
+ use ft8_mod1, only : idtone25,idtone25_valid
real, intent(in) :: s8(0:7,79)
real s8d(0:7,58)
character*37 msgd,msg37,msgsent37
@@ -10,10 +10,14 @@ subroutine ft8mfcqvar(s8,itone,msgd,msg37,lft8sd)
logical(1) lft8sd
if(len_trim(msgd).lt.6) return
+ idtone25(1,1:58)=0
+ idtone25_valid(1)=.false.
i3=-1; n3=-1
call genft8sdvar(msgd,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) return
idtone25(1,1:29)=itone(8:36)
idtone25(1,30:58)=itone(44:72)
+ idtone25_valid(1)=.true.
thresh=0.0; i1=0; i2=0
do i=1,58; if(i.le.29) then; s8d(0:7,i)=s8(0:7,i+7); else; s8d(0:7,i)=s8(0:7,i+14); endif; enddo
@@ -28,6 +32,7 @@ subroutine ft8mfcqvar(s8,itone,msgd,msg37,lft8sd)
ipk=0; u1=0.0; u2=0.0
do k=1,25
+ if(.not.idtone25_valid(k)) cycle
psum=0.; ref=ref0
do j=1,58; i3=idtone25(k,j); psum=psum + s8d(i3,j); if(i3.eq.mrs(j)) ref=ref - s8d(i3,j) + s8d(mrs2(j),j); enddo
p=psum/ref
diff --git a/lib/ft8var/ft8sd1var.f90 b/lib/ft8var/ft8sd1var.f90
index 7436e586..3c6fd2c5 100644
--- a/lib/ft8var/ft8sd1var.f90
+++ b/lib/ft8var/ft8sd1var.f90
@@ -9,7 +9,7 @@ subroutine ft8sd1var(s8,itone,msgd,msg37,lft8sd,lcq)
integer itone(79),itonedem(58),idtone(58),ip1(1)
integer*1 msgbits(77)
logical(1), intent(in) :: lcq
- logical(1) lft8sd,lr73,lgrid,lmatched(58)
+ logical(1) lft8sd,lr73,lgrid,lmatched(58),valid4(4)
lmatched=.false.; lr73=.false.; lgrid=.false.
itonedem=11
@@ -41,13 +41,17 @@ subroutine ft8sd1var(s8,itone,msgd,msg37,lft8sd,lcq)
i3=-1; n3=-1
msg372=msgd
call genft8sdvar(msg372,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) return
idtone(1:29)=itone(8:36)
idtone(30:58)=itone(44:72)
else
+ valid4=.false.
do i=1,4
msg372=msg4(i)
i3=-1; n3=-1
call genft8sdvar(msg372,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) cycle
+ valid4(i)=.true.
idtone4(i,1:29)=itone(8:36)
idtone4(i,30:58)=itone(44:72)
itone4(i,1:79)=itone(1:79)
@@ -70,6 +74,7 @@ subroutine ft8sd1var(s8,itone,msgd,msg37,lft8sd,lcq)
else
nmatchditer1=0; ncrcpatyiter1=0
do i=1,4
+ if(.not.valid4(i)) cycle
nmatch1=0; ncrcpaty1=0
do k=1,58
if(idtone4(i,k).eq.itonedem(k)) then; nmatch1=nmatch1+1; if(k.gt.25) ncrcpaty1=ncrcpaty1+1; endif
diff --git a/lib/ft8var/ft8sdvar.f90 b/lib/ft8var/ft8sdvar.f90
index 202aa711..f6332e64 100644
--- a/lib/ft8var/ft8sdvar.f90
+++ b/lib/ft8var/ft8sdvar.f90
@@ -9,7 +9,7 @@ subroutine ft8sdvar(s8,srr,itone,msgd,msg37,lft8sd,lcq)
integer itone(79),itonedem(58),idtone(58),ip1(1)
integer*1 msgbits(77)
logical(1), intent(in) :: lcq
- logical(1) lft8sd,lmatched(58)
+ logical(1) lft8sd,lmatched(58),valid4(4)
if(index(msgd,' RR73').gt.0 .or. index(msgd,' 73').gt.0) return ! do not process 73 messages
! do not process messages with grid
@@ -39,13 +39,17 @@ subroutine ft8sdvar(s8,srr,itone,msgd,msg37,lft8sd,lcq)
i3=-1; n3=-1
msg372=msgd
call genft8sdvar(msg372,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) return
idtone(1:29)=itone(8:36)
idtone(30:58)=itone(44:72)
else
+ valid4=.false.
do i=1,4
msg372=msg4(i)
i3=-1; n3=-1
call genft8sdvar(msg372,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) cycle
+ valid4(i)=.true.
idtone4(i,1:29)=itone(8:36)
idtone4(i,30:58)=itone(44:72)
itone4(i,1:79)=itone(1:79)
@@ -67,6 +71,7 @@ subroutine ft8sdvar(s8,srr,itone,msgd,msg37,lft8sd,lcq)
else
nmatchditer1=0; nbaseiter1=0; ncrcpatyiter1=0;
do i=1,4
+ if(.not.valid4(i)) cycle
nmatch1=0; nbase1=0; ncrcpaty1=0
do k=1,58
if(idtone4(i,k).eq.itonedem(k)) then
diff --git a/lib/ft8var/ft8svar.f90 b/lib/ft8var/ft8svar.f90
index 17aa58f7..1d0cc4fc 100644
--- a/lib/ft8var/ft8svar.f90
+++ b/lib/ft8var/ft8svar.f90
@@ -1,7 +1,8 @@
subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
- use ft8_mod1, only : itone56,idtone56,msg,nlasttx,lastrxmsg,mycall,hiscall
+ use ft8_mod1, only : itone56,idtone56,msg,nlasttx,lastrxmsg,mycall,hiscall, &
+ idtone56_valid
real, intent(in) :: s8(0:7,79),srr
real s8_1(0:7,79),s8d(0:7,58),xsync(21),xmsync(21),xdata(58),xmdata(58),xnoise(79),xmnoise(79)
character, intent(out) :: msg37*37
@@ -9,6 +10,7 @@ subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
integer, intent(out) :: itone(79)
integer, intent(in) :: nft8rxfsens
integer itonedem(58),idtone(58),mrs(58),mrs2(58),mrs3(58),mrs4(58),ip1(1)
+ integer*1 msgbits(77)
logical(1), intent(in) :: stophint
logical(1), intent(out) :: lft8s
logical(1) lmatched(58),lmycall,lhiscall,lrrr,lr73,lcallingrprt,lastrrprt,lastreport,lgrid
@@ -53,12 +55,18 @@ subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
if(lastrxmsg(1)%lstate .and. .not.lmycall .and. lhiscall .and. nlasttx.eq.2) lcallingrprt=.true. ! calling with REPORT
if(lgrid .and. index(msg(53),trim(mycall)//' '//trim(hiscall)//' AA00').eq.1) then ! standard callsigns
+ idtone56(53,1:58)=0
+ itone56(53,1:79)=0
+ idtone56_valid(53)=.false.
i3=-1; n3=-1
- msg(53)=lastrxmsg(1)%lastmsg
- call genft8sdvar(msg(53),i3,n3,msgsent37,msgbits,itone)
- idtone56(53,1:29)=itone(8:36)
- idtone56(53,30:58)=itone(44:72)
- itone56(53,1:79)=itone(1:79)
+ call genft8sdvar(lastrxmsg(1)%lastmsg,i3,n3,msgsent37,msgbits,itone)
+ if(i3.ge.0) then
+ msg(53)=lastrxmsg(1)%lastmsg
+ idtone56(53,1:29)=itone(8:36)
+ idtone56(53,30:58)=itone(44:72)
+ itone56(53,1:79)=itone(1:79)
+ idtone56_valid(53)=.true.
+ endif
endif
do i=1,58
@@ -67,9 +75,11 @@ subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
enddo
nmycall1=0; nbase1=0
- do k=1,19
- if(idtone56(1,k).eq.itonedem(k)) then; if(k.lt.10) nmycall1=nmycall1+1; nbase1=nbase1+1; endif
- enddo
+ if(idtone56_valid(1)) then
+ do k=1,19
+ if(idtone56(1,k).eq.itonedem(k)) then; if(k.lt.10) nmycall1=nmycall1+1; nbase1=nbase1+1; endif
+ enddo
+ endif
! /'-01 ','-02 ','-03 ','-04 ','-05 ','-06 ','-07 ','-08 ','-09 ','-10 ',
! '-11 ','-12 ','-13 ','-14 ','-15 ','-16 ','-17 ','-18 ','-19 ','-20 ',
@@ -89,6 +99,7 @@ subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
nmatchditer1=0; ncrcpatyiter1=0; imax=0
do i=ilow,ihigh
+ if(.not.idtone56_valid(i)) cycle
if(lastreport .and. i.gt.26 .and. i.lt.54) cycle ! RREPORT is not a valid msg, direction change is not allowed
nmatch1=0; ncrcpaty1=0
do k=1,58
@@ -132,6 +143,7 @@ subroutine ft8svar(s8,srr,itone,msg37,lft8s,nft8rxfsens,stophint)
ref0oth=ref0mycl+ref0paty
ipk=0; u1=0.; u2=0.; u1paty=0.; u2paty=0.; u1oth=0.; u2oth=0.
do k=ilow,ihigh
+ if(.not.idtone56_valid(k)) cycle
if(lastreport .and. k.gt.26 .and. k.lt.54) cycle ! GRID, RREPORT is not a valid msg, direction change is not allowed
psum=0.0; ref=ref0; psumpaty=0.; refpaty=ref0paty; psumoth=0.; refoth=ref0oth
do j=1,58; i=idtone56(k,j); psum=psum + s8d(i,j)
diff --git a/lib/ft8var/gen_ft8wavevar.f90 b/lib/ft8var/gen_ft8wavevar.f90
index 2920332a..187e487a 100644
--- a/lib/ft8var/gen_ft8wavevar.f90
+++ b/lib/ft8var/gen_ft8wavevar.f90
@@ -10,6 +10,7 @@ subroutine gen_ft8wavevar(itone,nsym,nsps,bt,fsample,f0,cwave,wave,icmplx,nwave)
integer itone(nsym)
data ibt0/0/
save pulse,twopi,dt,hmod,ibt0,ctab
+!$omp threadprivate(pulse,twopi,dt,hmod,ibt0,ctab)
ibt=nint(10*bt)
if(ibt0.ne.ibt) then
diff --git a/lib/ft8var/genft8sdvar.f90 b/lib/ft8var/genft8sdvar.f90
index 57d1560e..ae2ca408 100644
--- a/lib/ft8var/genft8sdvar.f90
+++ b/lib/ft8var/genft8sdvar.f90
@@ -3,7 +3,7 @@ subroutine genft8sdvar(msg,i3,n3,msgsent,msgbits,itone)
! Encode an FT8 message, producing array itone().
- use packjt77sdvar
+ use packjt77
use ft8_mod1, only : icos7,graymap
character msg*37,msgsent*37,c77*77
integer*1 msgbits(77),codeword(174)
@@ -12,8 +12,16 @@ subroutine genft8sdvar(msg,i3,n3,msgsent,msgbits,itone)
i3=-1
n3=-1
- call pack77sdvar(msg,i3,n3,c77)
- call unpack77sdvar(c77,msgsent,unpk77_successvar)
+ call pack77(msg,i3,n3,c77,pack77_options(record_tx_hashes=.false.))
+ ! SD thresholds are calibrated for classic Type 1/2 templates only.
+ if(.not.(i3.ge.0 .and. (i3.eq.1 .or. i3.eq.2) .and. &
+ index(msg,'<').eq.0)) then
+ i3=-1
+ n3=-1
+ endif
+ if(i3.lt.0) go to 1
+ call unpack77_configured(c77,0,msgsent,unpk77_successvar, &
+ unpack77_options(record_hashes=.false.,record_recent_calls=.false.))
read(c77,'(77i1)',err=1) msgbits
if(unpk77_successvar) go to 2
1 msgbits=0
diff --git a/lib/ft8var/genft8var.f90 b/lib/ft8var/genft8var.f90
index 5166e580..86defc7e 100644
--- a/lib/ft8var/genft8var.f90
+++ b/lib/ft8var/genft8var.f90
@@ -9,14 +9,10 @@ subroutine genft8var(msg,i3,n3,ntxhash,msgsent,msgbits,itone)
integer itone(79)
logical unpk77_successvar
- i3=-1
- n3=-1
- call pack77var(msg,i3,n3,c77,ntxhash)
- if(ntxhash.eq.1) then
- call unpack77var(c77,0,msgsent,unpk77_successvar,26) !TX message, unpack to get msgsent, use TX hash tables and do not save RX hash values
- else
- call unpack77var(c77,0,msgsent,unpk77_successvar,27) !service message, unpack to get msgsent. Do not save hash values
- endif
+ call pack77(msg,i3,n3,c77, &
+ pack77_options(record_tx_hashes=ntxhash.eq.1))
+ call unpack77_configured(c77,0,msgsent,unpk77_successvar, &
+ unpack77_options(record_hashes=.false.,record_recent_calls=.false.))
read(c77,'(77i1)',err=1) msgbits
if(unpk77_successvar) go to 2
1 msgbits=0
diff --git a/lib/ft8var/jt65_mod9.f90 b/lib/ft8var/jt65_mod9.f90
index 6fc3413d..b116dc08 100644
--- a/lib/ft8var/jt65_mod9.f90
+++ b/lib/ft8var/jt65_mod9.f90
@@ -1,5 +1,7 @@
module jt65_mod9
! stores callsign DB in memory for false decodes checking
+
+ save
parameter (MAXC=200000)
! supporting 7-char Australian callsigns
diff --git a/lib/ft8var/osd174_91var.f90 b/lib/ft8var/osd174_91var.f90
index d46fd377..16aa6667 100644
--- a/lib/ft8var/osd174_91var.f90
+++ b/lib/ft8var/osd174_91var.f90
@@ -1,8 +1,10 @@
-subroutine osd174_91var(llr,apmask,ndeep,message77,cw,nhardmin,dmin,nthr)
+subroutine osd174_91var(llr,apmask,ndeep,message77,cw,nhardmin,dmin,nthr, &
+ progress_generation)
!
! An ordered-statistics decoder for the (174,91) code.
!
use ft8_mod1, only : first_osd,gen
+use decode_completion_module, only : write_decode_progress
integer, parameter:: N=174, K=91, M=N-K
integer*1 apmask(N),apmaskr(N)
integer*1 genmrb(K,N),g2(N,K)
@@ -12,7 +14,8 @@ 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)
+integer indx(N),progress_work
+integer, intent(in) :: progress_generation
real llr(N),rx(N),absrx(N)
include '/lib/ft8/ldpc_174_91_c_generator.f90'
logical reset
@@ -37,8 +40,8 @@ interface
end interface
npre1=0; npre2=0; d1=0.
-if(first_osd) then ! fill the generator matrix
!$omp critical(first_osd)
+if(first_osd) then ! fill the generator matrix
gen=0
do i=1,M
do j=1,23
@@ -55,8 +58,8 @@ if(first_osd) then ! fill the generator matrix
gen(irow,irow)=1
enddo
first_osd=.false.
-!$omp end critical(first_osd)
endif
+!$omp end critical(first_osd)
rx=llr
apmaskr=apmask
@@ -161,10 +164,13 @@ elseif(ndeep.eq.5) then
endif
do iorder=1,nord
+ progress_work=0
misub(1:K-iorder)=0
misub(K-iorder+1:K)=1
iflag=K-iorder+1
do while(iflag .ge.0)
+ progress_work=progress_work+1
+ if(mod(progress_work,32).eq.0) call write_decode_progress(progress_generation)
if(iorder.eq.nord .and. npre1.eq.0) then
iend=iflag
else
@@ -220,6 +226,7 @@ if(npre2.eq.1) then
reset=.true.
ntotal=0
do i1=K,1,-1
+ if(mod(i1,8).eq.0) call write_decode_progress(progress_generation)
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))
@@ -234,7 +241,10 @@ if(npre2.eq.1) then
misub(1:K-nord)=0
misub(K-nord+1:K)=1
iflag=K-nord+1
+ progress_work=0
do while(iflag .ge.0)
+ progress_work=progress_work+1
+ if(mod(progress_work,32).eq.0) call write_decode_progress(progress_generation)
me=ieor(m0,misub)
call mrbencode91var(me,ce,g2,N,K)
e2sub=ieor(ce(K+1:N),hdec(K+1:N))
@@ -397,4 +407,4 @@ subroutine fetchit91var(indexes,fp,np,reset,e2,ntau,i1,i2,nthr)
lastpat(nthr)=ipat
return
-end subroutine fetchit91var \ No newline at end of file
+end subroutine fetchit91var
diff --git a/lib/ft8var/packjt77sdvar.f90 b/lib/ft8var/packjt77sdvar.f90
deleted file mode 100644
index 5d02407c..00000000
--- a/lib/ft8var/packjt77sdvar.f90
+++ /dev/null
@@ -1,558 +0,0 @@
-
-module packjt77sdvar
-
-! These variables are accessible from outside via "use packjt77sdvar":
-! integer n28avar,n28bvar
-
- contains
-
-subroutine pack77sdvar(msg0,i3,n3,c77)
-
- use packjt
- character*37 msg,msg0
- character*13 w(19)
- character*77 c77
- integer nw(19)
-
- msg=msg0
-
-! Convert msg to upper case; collapse multiple blanks; parse into words.
- call split77var(msg,nwords,nw,w)
- i3=-1
- n3=-1
- if(msg(1:3).eq.'CQ ' .or. msg(1:3).eq.'DE ' .or. msg(1:4).eq.'QRZ ') go to 100
-
-! Check Type 1 (Standard 77-bit message) or Type 2, with optional "/P"
-100 call pack77_1var(nwords,w,i3,n3,c77)
- if(i3.ge.0) go to 900
-
-! It defaults to free text
- i3=0
- n3=0
- msg(14:)=' '
- call packtext77var(msg(1:13),c77(1:71))
- write(c77(72:77),'(2b3.3)') n3,i3
-
-900 return
-end subroutine pack77sdvar
-
-subroutine unpack77sdvar(c77,msg,unpk77_successvar)
-
- parameter (MAXGRID4=32400)
- integer*8 n58
- character*77 c77*77,msg*37,c*38,call_1*13,call_2*13,c11*11,grid4*4,crpt*3
- logical unpk28_success,unpk77_successvar
-
- data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ/'/
-
- unpk77_successvar=.true.
-
-! Check for bad data
- do i=1,77
- if(c77(i:i).ne.'0' .and. c77(i:i).ne.'1') then
- msg='failed unpack'
- unpk77_successvar=.false.
- return
- endif
- enddo
-
- read(c77(72:77),'(2b3)') n3,i3
- msg=repeat(' ',37)
- if(i3.eq.0 .and. n3.eq.0) then
-! 0.0 Free text
- call unpacktext77var(c77(1:71),msg(1:13))
- msg(14:)=' '
- msg=adjustl(msg)
-
- else if(i3.eq.1 .or. i3.eq.2) then
-! Type 1 (standard message) or Type 2 ("/P" form for EU VHF contest)
- read(c77,1000) n28avar,ipa,n28bvar,ipb,ir,igrid4,i3
-1000 format(2(b28,b1),b1,b15,b3)
- call unpack28var(n28avar,call_1,unpk28_success)
- if(.not.unpk28_success) unpk77_successvar=.false.
- call unpack28var(n28bvar,call_2,unpk28_success)
- if(.not.unpk28_success) unpk77_successvar=.false.
- if(call_1(1:3).eq.'CQ_') call_1(3:3)=' '
- if(index(call_1,'<').le.0) then
- i=index(call_1,' ')
- if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.1) call_1(i:i+1)='/R'
- if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.2) call_1(i:i+1)='/P'
- endif
- if(index(call_2,'<').le.0) then
- i=index(call_2,' ')
- if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.1) call_2(i:i+1)='/R'
- if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.2) call_2(i:i+1)='/P'
- endif
- if(igrid4.le.MAXGRID4) then
- n=igrid4
- j1=n/(18*10*10)
- n=n-j1*18*10*10
- j2=n/(10*10)
- n=n-j2*10*10
- j3=n/10
- j4=n-j3*10
- grid4(1:1)=char(j1+ichar('A'))
- grid4(2:2)=char(j2+ichar('A'))
- grid4(3:3)=char(j3+ichar('0'))
- grid4(4:4)=char(j4+ichar('0'))
- if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//grid4
- if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R '//grid4
- if(msg(1:3).eq.'CQ ' .and. ir.eq.1) unpk77_successvar=.false.
- else
- irpt=igrid4-MAXGRID4
- if(irpt.eq.1) msg=trim(call_1)//' '//trim(call_2)
- if(irpt.eq.2) msg=trim(call_1)//' '//trim(call_2)//' RRR'
- if(irpt.eq.3) msg=trim(call_1)//' '//trim(call_2)//' RR73'
- if(irpt.eq.4) msg=trim(call_1)//' '//trim(call_2)//' 73'
- if(irpt.ge.5) then
- write(crpt,'(i3.2)') irpt-35
- if(crpt(1:1).eq.' ') crpt(1:1)='+'
- if(ir.eq.0) msg=trim(call_1)//' '//trim(call_2)//' '//crpt
- if(ir.eq.1) msg=trim(call_1)//' '//trim(call_2)//' R'//crpt
- endif
- if(msg(1:3).eq.'CQ ' .and. irpt.ge.2) unpk77_successvar=.false.
- endif
-
- else if(i3.eq.4) then
- read(c77,1050) n12,n58,iflip,nrpt,icq
-1050 format(b12,b58,b1,b2,b1)
- if(icq.eq.1) then
- do i=11,1,-1
- j=mod(n58,38)+1
- c11(i:i)=c(j:j)
- n58=n58/38
- enddo
- call_2=adjustl(c11)//' '
- msg='CQ '//trim(call_2)
- if(msg(1:4).eq.'CQ <') unpk77_successvar=.false.
- else
- unpk77_successvar=.false.
- endif
- endif
-
- return
-end subroutine unpack77sdvar
-
-subroutine pack28var(c13,n28)
-
-! Pack a special token, a 22-bit hash code, or a valid base call into a 28-bit
-! integer.
-
- parameter (NTOKENS=2063592,MAX22=4194304)
- logical is_digit,is_letter
- character*13 c13
- character*6 callsign
- character*1 c
- character*4 c4
- character*37 a1
- character*36 a2
- character*10 a3
- character*27 a4
- data a1/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
- data a2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
- data a3/'0123456789'/
- data a4/' ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
-
- is_digit(c)=c.ge.'0' .and. c.le.'9'
- is_letter(c)=c.ge.'A' .and. c.le.'Z'
-
- n28=-1
-! Work-around for Swaziland prefix:
- if(c13(1:4).eq.'3DA0') callsign='3D0'//c13(5:7)
-! Work-around for Guinea prefixes:
- if(c13(1:2).eq.'3X' .and. c13(3:3).ge.'A' .and. &
- c13(3:3).le.'Z') callsign='Q'//c13(3:6)
-
-! Check for special tokens first
- if(c13(1:3).eq.'DE ') then
- n28=0
- go to 900
- endif
-
- if(c13(1:4).eq.'QRZ ') then
- n28=1
- go to 900
- endif
-
- if(c13(1:3).eq.'CQ ') then
- n28=2
- go to 900
- endif
-
- if(c13(1:3).eq.'CQ_') then
- n=len(trim(c13))
- if(n.ge.4 .and. n.le.7) then
- nlet=0
- nnum=0
- do i=4,n
- c=c13(i:i)
- if(c.ge.'A' .and. c.le.'Z') nlet=nlet+1
- if(c.ge.'0' .and. c.le.'9') nnum=nnum+1
- enddo
- if(nnum.eq.3 .and. nlet.eq.0) then
- read(c13(4:3+nnum),*) nqsy
- n28=3+nqsy
- go to 900
- endif
- if(nlet.ge.1 .and. nlet.le.4 .and. nnum.eq.0) then
- c4=c13(4:n)
- c4=adjustr(c4)
- m=0
- do i=1,4
- j=0
- c=c4(i:i)
- if(c.ge.'A' .and. c.le.'Z') j=ichar(c)-ichar('A')+1
- m=27*m + j
- enddo
- n28=3+1000+m
- go to 900
- endif
- endif
- endif
-
-! Check for standard callsign
- iarea=-1
- n=len(trim(c13))
- do i=n,2,-1
- if(is_digit(c13(i:i))) exit
- enddo
- iarea=i !Call-area digit
- npdig=0 !Digits before call area
- nplet=0 !Letters before call area
- do i=1,iarea-1
- if(is_digit(c13(i:i))) npdig=npdig+1
- if(is_letter(c13(i:i))) nplet=nplet+1
- enddo
- nslet=0
- do i=iarea+1,n
- if(is_letter(c13(i:i))) nslet=nslet+1
- enddo
-
- n=len(trim(c13))
-! This is a standard callsign
- if(iarea.eq.2) callsign=' '//c13(1:5)
- if(iarea.eq.3) callsign=c13(1:6)
- i1=index(a1,callsign(1:1))-1
- i2=index(a2,callsign(2:2))-1
- i3=index(a3,callsign(3:3))-1
- i4=index(a4,callsign(4:4))-1
- i5=index(a4,callsign(5:5))-1
- i6=index(a4,callsign(6:6))-1
- n28=36*10*27*27*27*i1 + 10*27*27*27*i2 + 27*27*27*i3 + 27*27*i4 + &
- 27*i5 + i6
- n28=n28 + NTOKENS + MAX22
-
-900 n28=iand(n28,ishft(1,28)-1)
- return
-end subroutine pack28var
-
-
-subroutine unpack28var(n28_0,c13,success)
-
- parameter (NTOKENS=2063592,MAX22=4194304)
- logical success
- character*13 c13
- character*37 c1
- character*36 c2
- character*10 c3
- character*27 c4
- data c1/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
- data c2/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
- data c3/'0123456789'/
- data c4/' ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
-
- success=.true.
- n28=n28_0
- if(n28.lt.NTOKENS) then
-! Special tokens DE, QRZ, CQ, CQ_nnn, CQ_aaaa
- if(n28.eq.0) c13='DE '
- if(n28.eq.1) c13='QRZ '
- if(n28.eq.2) c13='CQ '
- if(n28.le.2) go to 900
- if(n28.le.1002) then
- write(c13,1002) n28-3
-1002 format('CQ_',i3.3)
- go to 900
- endif
- if(n28.le.532443) then
- n=n28-1003
- n0=n
- i1=n/(27*27*27)
- n=n-27*27*27*i1
- i2=n/(27*27)
- n=n-27*27*i2
- i3=n/27
- i4=n-27*i3
- c13=c4(i1+1:i1+1)//c4(i2+1:i2+1)//c4(i3+1:i3+1)//c4(i4+1:i4+1)
- c13=adjustl(c13)
- c13='CQ_'//c13(1:10)
- go to 900
- endif
- endif
- n28=n28-NTOKENS
-
-! Standard callsign
- n=n28 - MAX22
- i1=n/(36*10*27*27*27)
- n=n-36*10*27*27*27*i1
- i2=n/(10*27*27*27)
- n=n-10*27*27*27*i2
- i3=n/(27*27*27)
- n=n-27*27*27*i3
- i4=n/(27*27)
- n=n-27*27*i4
- i5=n/27
- i6=n-27*i5
- c13=c1(i1+1:i1+1)//c2(i2+1:i2+1)//c3(i3+1:i3+1)//c4(i4+1:i4+1)// &
- c4(i5+1:i5+1)//c4(i6+1:i6+1)
- c13=adjustl(c13)
-
-900 i0=index(c13,' ')
- if(i0.ne.0 .and. i0.lt.len(trim(c13))) then
- c13='QU1RK'
- success=.false.
- endif
- return
-end subroutine unpack28var
-
-subroutine split77var(msg,nwords,nw,w)
-
-! Convert msg to upper case; collapse multiple blanks; parse into words.
-
- character*37 msg
- character*13 w(19)
- character*1 c,c0
- character*6 bcall_1
- logical ok1
- integer nw(19)
-
- iz=len(trim(msg))
- j=0
- k=0
- n=0
- c0=' '
- w=' '
- do i=1,iz
- if(ichar(msg(i:i)).eq.0) msg(i:i)=' '
- c=msg(i:i) !Single character
- if(c.eq.' ' .and. c0.eq.' ') cycle !Skip leading/repeated blanks
- if(c.ne.' ' .and. c0.eq.' ') then
- k=k+1 !New word
- n=0
- endif
- j=j+1 !Index in msg
- n=n+1 !Index in word
- if(c.ge.'a' .and. c.le.'z') c=char(ichar(c)-32) !Force upper case
- msg(j:j)=c
- if(n.le.13) w(k)(n:n)=c !Copy character c into word
- c0=c
- enddo
- iz=j !Message length
- nwords=k !Number of words in msg
- if(nwords.le.0) go to 900
- nw(k)=len(trim(w(k)))
- msg(iz+1:)=' '
- if(nwords.lt.3) go to 900
- call chkcall(w(3),bcall_1,ok1)
- if(ok1 .and. w(1)(1:3).eq.'CQ ') then
- w(1)='CQ_'//w(2)(1:10) !Make "CQ " into "CQ_"
- w(2:12)=w(3:13) !Move all remeining words down by one
- nwords=nwords-1
- endif
-
-900 return
-end subroutine split77var
-
-subroutine pack77_1var(nwords,w,i3,n3,c77)
-! Check Type 1 (Standard 77-bit message) and Type 2 (ditto, with a "/P" call)
-
- parameter (MAXGRID4=32400)
- character*13 w(19),c13
- character*77 c77
- character*6 bcall_1,bcall_2
- character*4 grid4
- character c1*1,c2*2
- logical is_grid4
- logical ok1,ok2
- is_grid4(grid4)=len(trim(grid4)).eq.4 .and. &
- grid4(1:1).ge.'A' .and. grid4(1:1).le.'R' .and. &
- grid4(2:2).ge.'A' .and. grid4(2:2).le.'R' .and. &
- grid4(3:3).ge.'0' .and. grid4(3:3).le.'9' .and. &
- grid4(4:4).ge.'0' .and. grid4(4:4).le.'9'
-
- if(nwords.lt.2 .or. nwords.gt.4) return
- call chkcall(w(1),bcall_1,ok1)
- call chkcall(w(2),bcall_2,ok2)
- if(w(1)(1:3).eq.'DE ' .or. w(1)(1:3).eq.'CQ_' .or. w(1)(1:3).eq.'CQ ' .or. &
- w(1)(1:4).eq.'QRZ ') ok1=.true.
- if(w(1)(1:1).eq.'<' .and. index(w(1),'>').ge.5) ok1=.true.
- if(w(2)(1:1).eq.'<' .and. index(w(2),'>').ge.5) ok2=.true.
- if(.not.ok1 .or. .not.ok2) return
- if(w(1)(1:1).eq.'<' .and. index(w(2),'/').gt.0) return
- if(w(2)(1:1).eq.'<' .and. index(w(1),'/').gt.0) return
- if(nwords.eq.2 .and. (.not.ok2 .or. index(w(2),'/').ge.2)) return
- if(nwords.eq.2) go to 10
-
- c1=w(nwords)(1:1)
- c2=w(nwords)(1:2)
- if(.not.is_grid4(w(nwords)(1:4)) .and. c1.ne.'+' .and. c1.ne.'-' &
- .and. c2.ne.'R+' .and. c2.ne.'R-' .and. trim(w(nwords)).ne.'RRR' .and. &
- trim(w(nwords)).ne.'RR73' .and. trim(w(nwords)).ne.'73') return
- if(c1.eq.'+' .or. c1.eq.'-') then
- ir=0
- read(w(nwords),*,err=900) irpt
- irpt=irpt+35
- else if(c2.eq.'R+' .or. c2.eq.'R-') then
- ir=1
- read(w(nwords)(2:),*) irpt
- irpt=irpt+35
- else if(trim(w(nwords)).eq.'RRR') then
- ir=0
- irpt=2
- else if(trim(w(nwords)).eq.'RR73') then
- ir=0
- irpt=3
- else if(trim(w(nwords)).eq.'73') then
- ir=0
- irpt=4
- endif
-
-! 1 WA9XYZ/R KA1ABC/R R FN42 28 1 28 1 1 15 74 Standard msg
-! 2 PA3XYZ/P GM4ABC/P R JO22 28 1 28 1 1 15 74 EU VHF contest
-
-10 i1psuffix=index(w(1)//' ' ,'/P ')
- i2psuffix=index(w(2)//' ','/P ')
- if(nwords.eq.2 .or. nwords.eq.3 .or. (nwords.eq.4 .and. &
- w(3)(1:2).eq.'R ')) then
- n3=0
- i3=1 !Type 1: Standard message, possibly with "/R"
- if (i1psuffix.ge.4.or.i2psuffix.ge.4) i3=2 !Type 2, with "/P"
- endif
- c13=bcall_1
- if(c13(1:3).eq.'CQ_' .or. w(1)(1:1).eq.'<') c13=w(1)
- call pack28var(c13,n28avar)
- c13=bcall_2
- if(w(2)(1:1).eq.'<') c13=w(2)
- call pack28var(c13,n28bvar)
- ipa=0
- ipb=0
- if(i1psuffix.ge.4.or.index(w(1)//' ','/R ').ge.4) ipa=1
- if(i2psuffix.ge.4.or.index(w(2)//' ','/R ').ge.4) ipb=1
-
- grid4=w(nwords)(1:4)
- if(is_grid4(grid4)) then
- ir=0
- if(w(3).eq.'R ') ir=1
- j1=(ichar(grid4(1:1))-ichar('A'))*18*10*10
- j2=(ichar(grid4(2:2))-ichar('A'))*10*10
- j3=(ichar(grid4(3:3))-ichar('0'))*10
- j4=(ichar(grid4(4:4))-ichar('0'))
- igrid4=j1+j2+j3+j4
- else
- igrid4=MAXGRID4 + irpt
- endif
- if(nwords.eq.2) then
- ir=0
- irpt=1
- igrid4=MAXGRID4+irpt
- endif
- write(c77,1000) n28avar,ipa,n28bvar,ipb,ir,igrid4,i3
-1000 format(2(b28.28,b1),b1,b15.15,b3.3)
- return
-
-900 return
-end subroutine pack77_1var
-
-subroutine packtext77var(c13,c71)
-
- character*13 c13,w
- character*71 c71
- character*42 c
- character*1 qa(10),qb(10)
- data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-./?'/
-
- call mp_short_init
- qa=char(0)
- w=adjustr(c13)
- do i=1,13
- j=index(c,w(i:i))-1
- if(j.lt.0) j=0
- call mp_short_mult(qb,qa(2:10),9,42) !qb(1:9)=42*qa(2:9)
- call mp_short_add(qa,qb(2:10),9,j) !qa(1:9)=qb(2:9)+j
- enddo
-
- write(c71,1010) qa(2:10)
-1010 format(b7.7,8b8.8)
-
- return
-end subroutine packtext77var
-
-subroutine unpacktext77var(c71,c13)
-
- integer*1 ia(10)
- character*1 qa(10),qb(10)
- character*13 c13
- character*71 c71
- character*42 c
- equivalence (qa,ia),(qb,ib)
- data c/' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-./?'/
-
- qa(1)=char(0)
- read(c71,1010) qa(2:10)
-1010 format(b7.7,8b8.8)
-
- do i=13,1,-1
- call mp_short_div(qb,qa(2:10),9,42,ir)
- c13(i:i)=c(ir+1:ir+1)
- qa(2:10)=qb(1:9)
- enddo
-
- return
-end subroutine unpacktext77var
-
-subroutine mp_short_opsvar(w,u)
- character*1 w(*),u(*)
- integer i,ireg,j,n,ir,iv,ii1,ii2
- character*1 creg(4)
- save ii1,ii2
- equivalence (ireg,creg)
-
- entry mp_short_init
- ireg=256*ichar('2')+ichar('1')
- do j=1,4
- if (creg(j).eq.'1') ii1=j
- if (creg(j).eq.'2') ii2=j
- enddo
- return
-
- entry mp_short_add(w,u,n,iv)
- ireg=256*iv
- do j=n,1,-1
- ireg=ichar(u(j))+ichar(creg(ii2))
- w(j+1)=creg(ii1)
- enddo
- w(1)=creg(ii2)
- return
-
- entry mp_short_mult(w,u,n,iv)
- ireg=0
- do j=n,1,-1
- ireg=ichar(u(j))*iv+ichar(creg(ii2))
- w(j+1)=creg(ii1)
- enddo
- w(1)=creg(ii2)
- return
-
- entry mp_short_div(w,u,n,iv,ir)
- ir=0
- do j=1,n
- i=256*ir+ichar(u(j))
- w(j)=char(i/iv)
- ir=mod(i,iv)
- enddo
- return
-
- return
-end subroutine mp_short_opsvar
-
-end module packjt77sdvar
diff --git a/lib/ft8var/subtractft8var.f90 b/lib/ft8var/subtractft8var.f90
index a15f9bfa..ae60652b 100644
--- a/lib/ft8var/subtractft8var.f90
+++ b/lib/ft8var/subtractft8var.f90
@@ -1,4 +1,4 @@
-subroutine subtractft8var(itone,f0,dt)
+subroutine subtractft8var(residual,itone,f0,dt,delta)
! Subtract an ft8 signal
!
@@ -7,20 +7,25 @@ subroutine subtractft8var(itone,f0,dt)
! Complex amp : cfilt(t) = LPF[ dd(t)*CONJG(cref(t)) ]
! Subtract : dd(t) = dd(t) - 2*REAL{cref*cfilt}
- use ft8_mod1, only : dd8,cw,NFILT1,NFILT2,endcorr
+ use ft8_mod1, only : cw,NFILT1,NFILT2,endcorr
+ use ft8_mtd_residual, only : mtd_start_sample
! NMAX=15*12000,NFFT=15*12000,NFRAME=1920*79
parameter (NFFT=180000,NMAX=180000,NFRAME=151680)
complex cref(nframe),cfilt(nmax)
- integer itone(79)
- save cfilt
- !$omp threadprivate(cfilt)
+ real, intent(inout) :: residual(NMAX)
+ real, intent(out), optional :: delta(NFRAME)
+ integer, intent(in) :: itone(79)
+ real, intent(in) :: f0,dt
+ save cref,cfilt
+ !$omp threadprivate(cref,cfilt)
- nstart=dt*12000+1
+ nstart=mtd_start_sample(dt)
+ if(present(delta)) delta=0.0
call gen_ft8wavevar(itone,79,1920,2.0,12000.0,f0,cref,xjunk,1,NFRAME)
do i=1,nframe
id=nstart-1+i
if(id.ge.1.and.id.le.NMAX) then
- cfilt(i)=dd8(id)*conjg(cref(i))
+ cfilt(i)=residual(id)*conjg(cref(i))
else
cfilt(i)=0.0
endif
@@ -33,9 +38,11 @@ subroutine subtractft8var(itone,f0,dt)
cfilt(nframe:nframe-NFILT1/2:-1)=cfilt(nframe:nframe-NFILT1/2:-1)*endcorr
do i=1,nframe
j=nstart+i-1
- if(j.ge.1 .and. j.le.NMAX) dd8(j)=dd8(j)-2*REAL(cfilt(i)*cref(i))
+ if(j.ge.1 .and. j.le.NMAX) then
+ correction=-2*REAL(cfilt(i)*cref(i))
+ residual(j)=residual(j)+correction
+ if(present(delta)) delta(i)=correction
+ endif
enddo
-!!!$omp flush(dd8) ! makes no difference in number of decoded messages
-
return
end subroutine subtractft8var
diff --git a/lib/ft8var/sync8dvar.f90 b/lib/ft8var/sync8dvar.f90
index 34874679..84b6507e 100644
--- a/lib/ft8var/sync8dvar.f90
+++ b/lib/ft8var/sync8dvar.f90
@@ -1,7 +1,8 @@
subroutine sync8dvar(cd0,i0,ctwk,itwk,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcqcand)
! Compute sync power for a complex, downsampled FT8 signal.
- use ft8_mod1, only : csync,csynce,csyncsd,csyncsdcq,csynccq
+ use ft8_mod1, only : csync,csynce,csyncsd,csyncsdcq,csynccq, &
+ csyncsd_valid,csyncsdcq_valid
complex, intent(in) :: cd0(-800:4000),ctwk(32)
complex csync1(0:18,32),csync2(32),z1,z2,z3,z4,zt1(0:6),zt2(0:6),zt3(0:6),zt4(0:7),zt5(0:18), &
@@ -9,9 +10,10 @@ subroutine sync8dvar(cd0,i0,ctwk,itwk,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcq
real sync1(0:20)!,sync2(0:20)
integer, intent(in) :: i0,ipass,iqso
logical(1), intent(in) :: lcq,lcallsstd,lcqcand
- logical(1) lastsync
+ logical(1) lastsync,lsync1_valid
- sync=0.; sync1=0.; zt1=0.; zt2=0.; zt3=0.; z11=0.; z22=0.; z33=0.!; sync2=0.
+ sync=0.; sync1=0.; zt1=0.; zt2=0.; zt3=0.; z4=0.; z11=0.; z22=0.; z33=0.!; sync2=0.
+ lsync1_valid=.false.
k=1
do i=0,6 ! Sum over 7 Costas frequencies and three Costas arrays
i1=i0+i*32; i2=i1+1152; i3=i1+2304 ! +36*32, +72*32
@@ -83,9 +85,15 @@ subroutine sync8dvar(cd0,i0,ctwk,itwk,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcq
endif
if(.not.lastsync) then
- if(iqso.gt.1 .and. iqso.lt.4 .and. lcallsstd) csync1=csynce; if(iqso.eq.4 .and. .not.lcq) csync1=csyncsd
+ if(iqso.gt.1 .and. iqso.lt.4 .and. lcallsstd) then
+ csync1=csynce
+ lsync1_valid=.true.
+ else if(iqso.eq.4 .and. .not.lcq .and. csyncsd_valid) then
+ csync1=csyncsd
+ lsync1_valid=.true.
+ endif
- if((iqso.eq.4 .and. .not.lcq) .or. ((iqso.eq.2 .or. iqso.eq.3) .and. lcallsstd)) then
+ if(lsync1_valid) then
zt5=0.
do i=0,18
csync2=csync1(i,1:32)
@@ -105,7 +113,7 @@ subroutine sync8dvar(cd0,i0,ctwk,itwk,sync,ipass,lastsync,iqso,lcq,lcallsstd,lcq
enddo
endif
- if(iqso.eq.4 .and. lcq) then
+ if(iqso.eq.4 .and. lcq .and. csyncsdcq_valid) then
do i=0,57
csync2=csyncsdcq(i,1:32)
if(itwk.eq.1) csync2=ctwk*csync2 !Tweak the frequency
diff --git a/lib/ft8var/sync8var.f90 b/lib/ft8var/sync8var.f90
index 6540d766..17b2b894 100644
--- a/lib/ft8var/sync8var.f90
+++ b/lib/ft8var/sync8var.f90
@@ -1,11 +1,18 @@
-subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothread,ncandthin,ndtcenter)
+subroutine sync8var(residual,nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass, &
+ lqsothread,ncandthin,ndtcenter,progress_generation)
- use ft8_mod1, only : dd8,windowx,facx,icos7,lagcc,lagccbail,nfawide,nfbwide
+ use ft8_mod1, only : windowx,facx,icos7,lagcc,lagccbail,nfawide,nfbwide
+ use decode_completion_module, only : write_decode_progress
+ real, intent(in) :: residual(180000)
include 'ft8_params.f90'
complex cx(0:NH1)
- real s(NH1,NHSYM),x(NFFT1),sync2d(NH1,jzb:jzt),red(NH1),candidate0(5,450),candidate(4,460),tall(30),freq,rcandthin,dtcenter
+ real, save :: s(NH1,NHSYM)
+ !$omp threadprivate(s)
+ real x(NFFT1),sync2d(NH1,jzb:jzt),red(NH1),candidate0(5,450),candidate(4,460),tall(30),freq,rcandthin,dtcenter
+ real candidate_sync(450)
integer jpeak(NH1),indx(NH1),ii(1)
- integer, intent(in) :: nfa,nfb,nfqso,jzb,jzt,ipass,ncandthin,ndtcenter
+ integer, parameter :: max_sync_stencil=16
+ integer, intent(in) :: nfa,nfb,nfqso,jzb,jzt,ipass,ncandthin,ndtcenter,progress_generation
logical(1) syncq(NH1,jzb:jzt),redcq(NH1),lcq,lcq2,lpass1,lpass2
logical(1), intent(in) :: lqsothread
equivalence (x,cx)
@@ -14,22 +21,26 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
tstep=0.04 ! NSTEP/12000.0
df=3.125 ! 12000.0/NFFT1 , Hz
syncq=.false.; redcq=.false.; candidate(4,:)=0.
+ ncand=0
rcandthin=ncandthin/100.;
dtcenter=ndtcenter/100.
+ if(nfa.gt.nfb .or. nfawide.gt.nfbwide) return
+
if(ipass.eq.1 .or. ipass.eq.4 .or. ipass.eq.7) then
do j=1,NHSYM
ia=(j-1)*NSTEP + 1
ib=ia+NSPS-1
x(1:759)=0.
- if(j.ne.1) then; x(760:960)=dd8(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
- x(961:2880)=facx*dd8(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
- if(j.ne.NHSYM) then; x(2881:3081)=dd8(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
+ if(j.ne.1) then; x(760:960)=residual(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
+ x(961:2880)=facx*residual(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
+ if(j.ne.NHSYM) then; x(2881:3081)=residual(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
x(3082:)=0.
call four2avar(cx,NFFT1,1,-1,0) !r2c FFT
do i=1,NH1
s(i,j)=SQRT(real(cx(i))**2 + aimag(cx(i))**2)
enddo
+ if(mod(j,16).eq.0) call write_decode_progress(progress_generation)
enddo
endif
if(ipass.eq.2 .or. ipass.eq.5 .or. ipass.eq.8) then
@@ -37,14 +48,15 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
ia=(j-1)*NSTEP + 1
ib=ia+NSPS-1
x(1:759)=0.
- if(j.ne.1) then; x(760:960)=dd8(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
- x(961:2880)=facx*dd8(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
- if(j.ne.NHSYM) then; x(2881:3081)=dd8(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
+ if(j.ne.1) then; x(760:960)=residual(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
+ x(961:2880)=facx*residual(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
+ if(j.ne.NHSYM) then; x(2881:3081)=residual(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
x(3082:)=0.
call four2avar(cx,NFFT1,1,-1,0) !r2c FFT
do i=1,NH1
s(i,j)=real(cx(i))**2 + aimag(cx(i))**2
enddo
+ if(mod(j,16).eq.0) call write_decode_progress(progress_generation)
enddo
endif
if(ipass.eq.3 .or. ipass.eq.6 .or. ipass.eq.9) then
@@ -52,18 +64,25 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
ia=(j-1)*NSTEP + 1
ib=ia+NSPS-1
x(1:759)=0.
- if(j.ne.1) then; x(760:960)=dd8(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
- x(961:2880)=facx*dd8(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
- if(j.ne.NHSYM) then; x(2881:3081)=dd8(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
+ if(j.ne.1) then; x(760:960)=residual(ia-201:ia-1)*windowx(200:0:-1); else; x(760:960)=0.; endif
+ x(961:2880)=facx*residual(ia:ib); x(961)=x(961)*1.9; x(2880)=x(2880)*1.9
+ if(j.ne.NHSYM) then; x(2881:3081)=residual(ib+1:ib+201)*windowx; else; x(2881:3081)=0.; endif
x(3082:)=0.
call four2avar(cx,NFFT1,1,-1,0) !r2c FFT
do i=1,NH1
s(i,j)=abs(real(cx(i))) + abs(aimag(cx(i)))
enddo
+ if(mod(j,16).eq.0) call write_decode_progress(progress_generation)
enddo
endif
- ia=max(1,nint(nfa/df)); ib=max(1,nint(nfb/df)); iaw=max(1,nint(nfawide/df)); ibw=max(1,nint(nfbwide/df))
+ ia=max(1,nint(nfa/df))
+ ib=min(NH1-max_sync_stencil,nint(nfb/df))
+ iaw=max(1,nint(nfawide/df))
+ ibw=min(NH1-max_sync_stencil,nint(nfbwide/df))
+ ia=max(ia,iaw)
+ ib=min(ib,ibw)
+ if(ia.gt.ib .or. iaw.gt.ibw) return
nssy=4 ! NSPS/NSTEP ! # steps per symbol
nssy36=144 ! nssy*36
nssy72=288 ! nssy*72
@@ -74,7 +93,7 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
nfos6=12 ! nfos*6
do j=jzb,jzt
do i=iaw,ibw
- ta=0.; tb=0.; tc=0.
+ ta=0.; tb=0.; tc=0.; tall=0.
do n=0,6
k=j+jstrt+nssy*n
if(k.gt.0) then
@@ -112,10 +131,11 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
endif
sync2d(i,j)=max(sync_abc,sync_bc); if(lcq) syncq(i,j)=.true.
enddo
+ if(mod(j-jzb+1,16).eq.0) call write_decode_progress(progress_generation)
enddo
else
! nfos6=15 ! 16i spec bw -1
- nfos6=16
+ nfos6=max_sync_stencil
do j=jzb,jzt
do i=iaw,ibw
ta=0.; tb=0.; tc=0.; tcq=0.; t0a=0.; t0b=0.; t0c=0.; t0cq=0.
@@ -151,6 +171,7 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
sync2d(i,j)=max(syncf,syncs)
if(syncf.gt.syncs) then; if(lcq) syncq(i,j)=.true.; else; if(lcq2) syncq(i,j)=.true.; endif
enddo
+ if(mod(j-jzb+1,16).eq.0) call write_decode_progress(progress_generation)
enddo
endif
@@ -226,10 +247,11 @@ subroutine sync8var(nfa,nfb,syncmin,nfqso,candidate,ncand,jzb,jzt,ipass,lqsothre
! Sort by sync
! call indexx(candidate0(3,1:ncand),ncand,indx)
- if(rcandthin.gt.0.99) then; call indexx(candidate0(3,1:ncand),ncand,indx)
+ if(rcandthin.gt.0.99) then; candidate_sync(1:ncand)=candidate0(3,1:ncand)
! sort by sync value with DT weight
- else; call indexx(candidate0(5,1:ncand),ncand,indx)
+ else; candidate_sync(1:ncand)=candidate0(5,1:ncand)
endif
+ call indexx(candidate_sync,ncand,indx)
! Sort by frequency
! call indexx(candidate0(1,1:ncand),ncand,indx)
diff --git a/lib/ft8var/tone8.f90 b/lib/ft8var/tone8.f90
index d5a95761..63e21e94 100644
--- a/lib/ft8var/tone8.f90
+++ b/lib/ft8var/tone8.f90
@@ -1,13 +1,15 @@
subroutine tone8(lmycallstd,lhiscallstd)
use ft8_mod1, only : itone56,idtone56,msg,csynce,mycall,hiscall,idtonecqdxcns,idtonedxcns73,mybcall,hisbcall,lhound, &
+ idtone56_valid, &
idtonefox73,idtonespec
- complex csig0(151680)
+ complex, allocatable :: csig0(:)
character msg37*37,msgsent37*37,mycall14*14,hiscall14*14
character*4 rpt(56)
integer itone(79),itone1(79)
integer*1 msgbits(77)
logical(1), intent(in) :: lmycallstd,lhiscallstd
+ logical(1) valid_first
data rpt/'-01 ','-02 ','-03 ','-04 ','-05 ','-06 ','-07 ','-08 ','-09 ','-10 ', &
'-11 ','-12 ','-13 ','-14 ','-15 ','-16 ','-17 ','-18 ','-19 ','-20 ', &
@@ -20,6 +22,11 @@ subroutine tone8(lmycallstd,lhiscallstd)
! integer itone56(56,79),idtone56(56,58)
! character*37 msg(56)
+ idtone56(1:56,1:58)=0
+ itone56(1:56,1:79)=0
+ idtone56_valid(1:56)=.false.
+ valid_first=.false.
+
if(lhound .and. len_trim(mybcall).gt.2 .and. len_trim(hisbcall).gt.2) then
msg37=''; msg37=trim(mybcall)//' '//trim(hisbcall)//' RR73'
i3=-1; n3=-1
@@ -58,10 +65,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg(i)=msg37
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- if(i.eq.1) itone1=itone
- idtone56(i,1:29)=itone(8:36)
- idtone56(i,30:58)=itone(44:72)
- itone56(i,1:79)=itone(1:79)
+ call store_tone_slot(i,itone,i3.ge.0,i.eq.1)
enddo
go to 2
endif
@@ -71,10 +75,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall14)//' '//trim(rpt(i))
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- if(i.eq.1) itone1=itone
- idtone56(i,1:29)=itone(8:36)
- idtone56(i,30:58)=itone(44:72)
- itone56(i,1:79)=itone(1:79)
+ call store_tone_slot(i,itone,i3.ge.0,i.eq.1)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall)//' '//trim(rpt(i))
msg(i)=msg37
enddo
@@ -82,9 +83,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg37=''; msg37=trim(mycall14)//' '//trim(hiscall)//' '//trim(rpt(i))
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- idtone56(i,1:29)=itone(8:36)
- idtone56(i,30:58)=itone(44:72)
- itone56(i,1:79)=itone(1:79)
+ call store_tone_slot(i,itone,i3.ge.0,.false.)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall)//' '//trim(rpt(i))
msg(i)=msg37
enddo
@@ -92,9 +91,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg(53)=msg37
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- idtone56(53,1:29)=itone(8:36)
- idtone56(53,30:58)=itone(44:72)
- itone56(53,1:79)=itone(1:79)
+ call store_tone_slot(53,itone,i3.ge.0,.false.)
go to 2
endif
@@ -103,10 +100,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg37=''; msg37=trim(mycall14)//' '//trim(hiscall)//' '//trim(rpt(i))
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- if(i.eq.1) itone1=itone
- idtone56(i,1:29)=itone(8:36)
- idtone56(i,30:58)=itone(44:72)
- itone56(i,1:79)=itone(1:79)
+ call store_tone_slot(i,itone,i3.ge.0,i.eq.1)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall)//' '//trim(rpt(i))
msg(i)=msg37
enddo
@@ -114,9 +108,7 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall14)//' '//trim(rpt(i))
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- idtone56(i,1:29)=itone(8:36)
- idtone56(i,30:58)=itone(44:72)
- itone56(i,1:79)=itone(1:79)
+ call store_tone_slot(i,itone,i3.ge.0,.false.)
msg37=''; msg37=trim(mycall)//' '//trim(hiscall)//' '//trim(rpt(i))
msg(i)=msg37
enddo
@@ -124,17 +116,37 @@ subroutine tone8(lmycallstd,lhiscallstd)
msg(53)=msg37
i3=-1; n3=-1
call genft8var(msg37,i3,n3,0,msgsent37,msgbits,itone)
- idtone56(53,1:29)=itone(8:36)
- idtone56(53,30:58)=itone(44:72)
- itone56(53,1:79)=itone(1:79)
+ call store_tone_slot(53,itone,i3.ge.0,.false.)
go to 2
endif
-2 m=13441 ! 7*1920+1
+2 if(.not.valid_first) return
+ allocate(csig0(151680))
+ m=13441 ! 7*1920+1
call gen_ft8wavevar(itone1,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
do j=0,18
do k=1,32; csynce(j,k)=csig0(m); m=m+60; enddo
enddo
return
+
+contains
+
+ subroutine store_tone_slot(islot,itone,valid,set_first)
+ integer, intent(in) :: islot,itone(79)
+ logical, intent(in) :: valid,set_first
+
+ ! Invalid generated messages leave the slot cleared/invalid; valid_first
+ ! prevents csynce from being regenerated from a stale first tone sequence.
+ if(.not.valid) return
+ if(set_first) then
+ itone1=itone
+ valid_first=.true.
+ endif
+ idtone56(islot,1:29)=itone(8:36)
+ idtone56(islot,30:58)=itone(44:72)
+ itone56(islot,1:79)=itone(1:79)
+ idtone56_valid(islot)=.true.
+ end subroutine store_tone_slot
+
end subroutine tone8
diff --git a/lib/ft8var/tonesdvar.f90 b/lib/ft8var/tonesdvar.f90
index b973ca77..50d3cb00 100644
--- a/lib/ft8var/tonesdvar.f90
+++ b/lib/ft8var/tonesdvar.f90
@@ -1,14 +1,15 @@
subroutine tonesdvar(msgd,lcq)
- use ft8_mod1, only : csyncsd,csyncsdcq,itone76,idtone76,msgsd76
- complex csig0(151680)
+ use ft8_mod1, only : csyncsd,csyncsdcq,itone76,idtone76,msgsd76, &
+ idtone76_valid,csyncsd_valid,csyncsdcq_valid
+ complex, allocatable :: csig0(:)
character, intent(in) :: msgd*37
character msg37*37,msgsent37*37,c1*12,c2*12,grid*6
character*4 rpt(75)
integer itone(79),itone1(79)
integer*1 msgbits(77)
logical(1), intent(in) :: lcq
- logical(1) lgrid,lr73
+ logical(1) lgrid,lr73,valid_first
data rpt/'+09 ','+08 ','+07 ','+06 ','+05 ','+04 ','+03 ','+02 ','+01 ','+00 ', &
'-01 ','-02 ','-03 ','-04 ','-05 ','-06 ','-07 ','-08 ','-09 ','-10 ', &
@@ -25,11 +26,21 @@ subroutine tonesdvar(msgd,lcq)
! complex csyncsd(0:18,32),csyncsdcq(0:71,32)
lgrid=.false.; lr73=.false.
+ valid_first=.false.
+ idtone76(1:76,1:58)=0
+ itone76(1:76,1:79)=0
+ idtone76_valid(1:76)=.false.
+ if(lcq) then
+ csyncsdcq_valid=.false.
+ else
+ csyncsd_valid=.false.
+ endif
if(lcq) then
msg37=msgd
i3=-1; n3=-1
call genft8sdvar(msg37,i3,n3,msgsent37,msgbits,itone)
+ if(i3.lt.0) return
else
c1=' '; c2=' '
ispc1=index(msgd,' '); ispc2=index(msgd((ispc1+1):),' ')+ispc1; ispc3=index(msgd((ispc2+1):),' ')+ispc2;
@@ -48,21 +59,31 @@ subroutine tonesdvar(msgd,lcq)
msgsd76(i)=msg37
i3=-1; n3=-1
call genft8sdvar(msg37,i3,n3,msgsent37,msgbits,itone)
- if(i.eq.1) itone1=itone
+ if(i3.lt.0) cycle
+ if(i.eq.1) then
+ itone1=itone
+ valid_first=.true.
+ endif
idtone76(i,1:29)=itone(8:36)
idtone76(i,30:58)=itone(44:72)
itone76(i,1:79)=itone(1:79)
+ idtone76_valid(i)=.true.
enddo
msg37=' '
msg37=trim(c1)//' '//trim(c2)//' '//trim(grid)
msgsd76(76)=msg37
i3=-1; n3=-1
call genft8sdvar(msg37,i3,n3,msgsent37,msgbits,itone)
- idtone76(76,1:29)=itone(8:36)
- idtone76(76,30:58)=itone(44:72)
- itone76(76,1:79)=itone(1:79)
+ if(i3.ge.0) then
+ idtone76(76,1:29)=itone(8:36)
+ idtone76(76,30:58)=itone(44:72)
+ itone76(76,1:79)=itone(1:79)
+ idtone76_valid(76)=.true.
+ endif
endif
+ if(.not.lcq .and. .not.valid_first) return
+ allocate(csig0(151680))
m=13441 ! 7*1920+1
if(lcq) then
call gen_ft8wavevar(itone,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
@@ -70,11 +91,13 @@ subroutine tonesdvar(msgd,lcq)
if(i.eq.29) m=m+13440
do j=1,32; csyncsdcq(i,j)=csig0(m); m=m+60; enddo
enddo
+ csyncsdcq_valid=.true.
else
call gen_ft8wavevar(itone1,79,1920,2.0,12000.0,0.0,csig0,xjunk,1,151680)
do i=0,18
do j=1,32; csyncsd(i,j)=csig0(m); m=m+60; enddo
enddo
+ csyncsd_valid=.true.
endif
return