Try to avoid a crash in freqcal.f90 when data is all zeros.

This commit is contained in:
Steven Franke 2019-05-11 09:36:15 -05:00
parent c393740b0a
commit ab1454a24c

View File

@ -41,6 +41,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line)
endif endif
smax=0. smax=0.
s=0. s=0.
ipk=-99
do i=ia,ib do i=ia,ib
s(i)=real(cx(i))**2 + aimag(cx(i))**2 s(i)=real(cx(i))**2 + aimag(cx(i))**2
if(s(i).gt.smax) then if(s(i).gt.smax) then
@ -49,6 +50,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line)
endif endif
enddo enddo
if(ipk.ge.1) then
call peakup(s(ipk-1),s(ipk),s(ipk+1),dx) call peakup(s(ipk-1),s(ipk),s(ipk+1),dx)
fpeak=df * (ipk+dx) fpeak=df * (ipk+dx)
ap=(fpeak/fs+1.0/(2.0*NFFT)) ap=(fpeak/fs+1.0/(2.0*NFFT))
@ -67,6 +69,12 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line)
ave=xsum/nsum ave=xsum/nsum
snr=db(smax/ave) snr=db(smax/ave)
pave=db(ave) + 8.0 pave=db(ave) + 8.0
else
snr=-99.9
pave=-99.9
fpeak=-99.9
ferr=-99.9
endif
cflag=' ' cflag=' '
if(snr.lt.20.0) cflag='*' if(snr.lt.20.0) cflag='*'
n=n+1 n=n+1