From 156f62d2fe55b349704c59a733e23234028d19db Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Thu, 2 May 2019 11:39:18 -0500 Subject: [PATCH 1/3] 1. Fix array bounds mismatch in subroutine call that was the likely cause of Fortran crashes, and 2. open up DT search range to +/- 0.77s --- lib/ft4_decode.f90 | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index 687a4ecc7..dc08df1b3 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -30,8 +30,7 @@ contains include 'ft4/ft4_params.f90' class(ft4_decoder), intent(inout) :: this procedure(ft4_decode_callback) :: callback - parameter (NSS=NSPS/NDOWN) - parameter (NZZ=18*3456) + parameter (NSS=NSPS/NDOWN,NDMAX=NMAX/NDOWN) character message*37,msgsent*37 character c77*77 character*37 decodes(100) @@ -42,8 +41,8 @@ contains character*6 hhmmss character*4 cqstr,cqstr0 - complex cd2(0:NZZ/NDOWN-1) !Complex waveform - complex cb(0:NZZ/NDOWN-1+NN*NSS) + complex cd2(0:NDMAX-1) !Complex waveform + complex cb(0:NDMAX-1) complex cd(0:NN*NSS-1) !Complex waveform complex ctwk(2*NSS),ctwk2(2*NSS,-16:16) complex csymb(NSS) @@ -52,7 +51,7 @@ contains real bmeta(2*NN),bmetb(2*NN),bmetc(2*NN) real a(5) - real dd(NZZ) + real dd(NMAX) real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND) real s2(0:255) real candidate(3,100) @@ -61,7 +60,7 @@ contains integer apbits(2*ND) integer apmy_ru(28),aphis_fd(28) integer icos4a(0:3),icos4b(0:3),icos4c(0:3),icos4d(0:3) - integer*2 iwave(NZZ) !Raw received data + integer*2 iwave(NMAX) !Raw received data integer*1 message77(77),rvec(77),apmask(2*ND),cw(2*ND) integer*1 hbits(2*NN) integer graymap(0:3) @@ -245,7 +244,7 @@ contains call ft4_downsample(dd,dobigfft,f0,cd2) !Downsample to 32 Sam/Sym call timer('ft4_down',1) if(dobigfft) dobigfft=.false. - sum2=sum(cd2*conjg(cd2))/(real(NZZ)/real(NDOWN)) + sum2=sum(cd2*conjg(cd2))/(real(NMAX)/real(NDOWN)) if(sum2.gt.0.0) cd2=cd2/sqrt(sum2) ! Sample rate is now 12000/16 = 750 samples/second do isync=1,2 @@ -253,15 +252,15 @@ contains idfmin=-12 idfmax=12 idfstp=3 - ibmin=0 - ibmax=800 + ibmin=-200 + ibmax=950 ibstp=4 else idfmin=idfbest-4 idfmax=idfbest+4 idfstp=1 ibmin=max(0,ibest-5) - ibmax=min(ibest+5,NZZ/NDOWN-1) + ibmax=min(ibest+5,NDMAX-1) ibstp=1 endif ibest=-1 @@ -287,7 +286,14 @@ contains call timer('ft4down ',1) sum2=sum(abs(cb)**2)/(real(NSS)*NN) if(sum2.gt.0.0) cb=cb/sqrt(sum2) - cd=cb(ibest:ibest+NN*NSS-1) + cd=0. + if(ibest.ge.0) then + it=min(NDMAX-1,ibest+NN*NSS-1) + np=it-ibest+1 + cd(0:np-1)=cb(ibest:it) + else + cd(-ibest:ibest+NN*NSS-1)=cb(0:NN*NSS+2*ibest-1) + endif call timer('four2a ',0) do k=1,NN i1=(k-1)*NSS From ab282fae78cf720a8a8d007e4f1ad62299014146 Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Fri, 3 May 2019 09:01:18 -0500 Subject: [PATCH 2/3] Add bLowSidelobes argument to the call to symspec. It is initialized to FALSE. --- lib/jt9.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jt9.f90 b/lib/jt9.f90 index aff2844ef..a0ffcda31 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -22,7 +22,8 @@ program jt9 !### ndepth was defined as 60001. Why??? integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0 - logical :: read_files = .true., tx9 = .false., display_help = .false. + logical :: read_files = .true., tx9 = .false., display_help = .false., & + bLowSidelobes = .false. type (option) :: long_options(26) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & @@ -242,7 +243,7 @@ program jt9 ingain=0 call timer('symspec ',0) nminw=1 - call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb, & + call symspec(shared_data,k,ntrperiod,nsps,ingain,bLowSidelobes,nminw,pxdb, & s,df3,ihsym,npts8,pxdbmax) call timer('symspec ',1) endif From 3611be8ba011392cf35f0bb29a49030e7b7adb59 Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Fri, 3 May 2019 10:51:45 -0500 Subject: [PATCH 3/3] Try to avoid an array bounds error that has been reported by a user. Cause unknown. --- lib/ft8/sync8.f90 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90 index 3924f1bad..219c6ebf1 100644 --- a/lib/ft8/sync8.f90 +++ b/lib/ft8/sync8.f90 @@ -89,7 +89,12 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, & enddo iz=ib-ia+1 call indexx(red(ia:ib),iz,indx) - ibase=indx(nint(0.40*iz)) - 1 + ia + npctile=nint(0.40*iz) + if(npctile.lt.1) then ! something is wrong; bail out + ncand=0 + return; + endif + ibase=indx(npctile) - 1 + ia if(ibase.lt.1) ibase=1 if(ibase.gt.nh1) ibase=nh1 base=red(ibase)