diff --git a/lib/ft4/gen_ft4wave.f90 b/lib/ft4/gen_ft4wave.f90 index 410e83401..c4cd2eafb 100644 --- a/lib/ft4/gen_ft4wave.f90 +++ b/lib/ft4/gen_ft4wave.f90 @@ -13,7 +13,7 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave) twopi=8.0*atan(1.0) dt=1.0/fsample hmod=1.0 -! Compute the frequency-smoothing pulse +! Compute the smoothed frequency-deviation pulse do i=1,3*nsps tt=(i-1.5*nsps)/real(nsps) pulse(i)=gfsk_pulse(1.0,tt) diff --git a/lib/ft4/sync4d.f90 b/lib/ft4/sync4d.f90 index bda7ed4a2..28cb10b99 100644 --- a/lib/ft4/sync4d.f90 +++ b/lib/ft4/sync4d.f90 @@ -60,7 +60,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) z4=0. if(itwk.eq.1) csync2=ctwk*csynca !Tweak the frequency - if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2)) + if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) then + z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2)) + elseif( i1.lt.0 ) then + npts=(i1+4*NSS-1)/2 + if(npts.le.8) then + z1=0. + else + z1=sum(cd0(0:i1+4*NSS-1:2)*conjg(csync2(2*NSS-npts:))) + endif + endif if(itwk.eq.1) csync2=ctwk*csyncb !Tweak the frequency if(i2.ge.0 .and. i2+4*NSS-1.le.NP-1) z2=sum(cd0(i2:i2+4*NSS-1:2)*conjg(csync2)) @@ -69,8 +78,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) if(i3.ge.0 .and. i3+4*NSS-1.le.NP-1) z3=sum(cd0(i3:i3+4*NSS-1:2)*conjg(csync2)) if(itwk.eq.1) csync2=ctwk*csyncd !Tweak the frequency - if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2)) - + if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) then + z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2)) + elseif( i4+4*NSS-1.gt.NP-1 ) then + npts=(NP-1-i4+1)/2 + if(npts.le.8) then + z4=0. + else + z4=sum(cd0(i4:i4+2*npts-1:2)*conjg(csync2(1:npts))) + endif + endif sync = p(z1) + p(z2) + p(z3) + p(z4) return diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index fa53f57be..aa27387ce 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -262,8 +262,8 @@ contains idfmin=idfbest-4 idfmax=idfbest+4 idfstp=1 - ibmin=max(0,ibest-5) - ibmax=min(ibest+5,NDMAX-1) + ibmin=ibest-5 + ibmax=ibest+5 ibstp=1 endif ibest=-1