From b43567c38c2a963cfb955b88912fc4e43c7f9748 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 9 Jan 2017 22:54:47 +0000 Subject: [PATCH] Deal with the FreqCal edge case of FTol>DF Reduce the tolerance to +-DF in this case to avoid array bounds error. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7470 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/freqcal.f90 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/freqcal.f90 b/lib/freqcal.f90 index 4e2fcaef9..71b1c38b8 100644 --- a/lib/freqcal.f90 +++ b/lib/freqcal.f90 @@ -3,7 +3,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) parameter (NZ=30*12000,NFFT=55296,NH=NFFT/2) integer*2 id2(0:NZ-1) real x(0:NFFT-1) - real s(NH) + real s(0:NH) character line*80,cflag*1 complex cx(0:NH) equivalence (x,cx) @@ -17,8 +17,13 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) x=0.001*id2(k-NFFT:k-1) call four2a(x,NFFT,1,-1,0) !Compute spectrum, r2c df=12000.0/NFFT - ia=nint((noffset-ntol)/df) - ib=nint((noffset+ntol)/df) + if (ntol.gt.noffset) then + ia=0 + ib=nint((noffset*2)/df) + else + ia=nint((noffset-ntol)/df) + ib=nint((noffset+ntol)/df) + endif smax=0. s=0. do i=ia,ib