Add more protection against the i0 crash that has occurred in getcandidates4.f90.

This commit is contained in:
Steve Franke 2019-06-04 14:53:45 -05:00
parent d03900d738
commit 97be1b46b9
2 changed files with 4 additions and 8 deletions

View File

@ -40,8 +40,8 @@ subroutine ft4_downsample(dd,newdata,f0,c)
c1=0. c1=0.
if(i0.ge.0 .and. i0.le.NMAX/2) c1(0)=cx(i0) if(i0.ge.0 .and. i0.le.NMAX/2) c1(0)=cx(i0)
do i=1,NFFT2/2 do i=1,NFFT2/2
if(i0+i.le.NMAX/2) c1(i)=cx(i0+i) if(i0+i.ge.0 .and. i0+i.le.NMAX/2) c1(i)=cx(i0+i)
if(i0-i.ge.0) c1(NFFT2-i)=cx(i0-i) if(i0-i.ge.0 .and. i0-i.le.NMAX/2) c1(NFFT2-i)=cx(i0-i)
enddo enddo
c1=c1*window/NFFT2 c1=c1*window/NFFT2
call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain

View File

@ -47,7 +47,7 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
nfa=fa/df nfa=fa/df
if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df) if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df)
nfb=fb/df nfb=fb/df
if(nfb.gt.nint(5000.0/df)) nfb=nint(5000.0/df) if(nfb.gt.nint(4910.0/df)) nfb=nint(4910.0/df)
ncand=0 ncand=0
call ft4_baseline(savg,nfa,nfb,sbase) call ft4_baseline(savg,nfa,nfb,sbase)
if(any(sbase(nfa:nfb).le.0)) return if(any(sbase(nfa:nfb).le.0)) return
@ -60,13 +60,9 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
del=0. del=0.
if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den
fpeak=(i+del)*df+f_offset fpeak=(i+del)*df+f_offset
if(fpeak.lt.0.0 .or. fpeak.gt.4910.0) cycle if(fpeak.lt.200.0 .or. fpeak.gt.4910.0) cycle
speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
ncand=ncand+1 ncand=ncand+1
if(ncand.gt.maxcand) then
ncand=maxcand
exit
endif
candidate(1,ncand)=fpeak candidate(1,ncand)=fpeak
candidate(2,ncand)=-99.99 candidate(2,ncand)=-99.99
candidate(3,ncand)=speak candidate(3,ncand)=speak