From 06d648f1d7d43c6c9dcdebf0ada029bad5321526 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 27 Feb 2024 12:12:14 -0500 Subject: [PATCH] Protect against bounds error. --- lib/superfox/sfox_sync.f90 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/superfox/sfox_sync.f90 b/lib/superfox/sfox_sync.f90 index 09bf23869..cd9042a3c 100644 --- a/lib/superfox/sfox_sync.f90 +++ b/lib/superfox/sfox_sync.f90 @@ -136,17 +136,15 @@ subroutine sfox_sync(iwave,fsample,isync,f,t,fwidth) call peakup(s2(ipk-1),s2(ipk),s2(ipk+1),dxi) endif f=(ipk+dxi)*df2 + bw/2.0 - - call pctile(s2(ipk-100:ipk+100),201,48,base) - s2=s2-base -! do i=ipk-100,ipk+100 -! write(51,3051) i*df2,s2(i) -!3051 format(2f15.3) -! enddo - smax=maxval(s2(ipk-10:ipk+10)) - w=count(s2(ipk-10:ipk+10).gt.0.5*smax) fwidth=0. - if(w.gt.4.0) fwidth=sqrt(w*w - 4*4)*df2 + + if(ipk.gt.100 .and. ipk.lt.nfft2/4-100) then + call pctile(s2(ipk-100:ipk+100),201,48,base) + s2=s2-base + smax=maxval(s2(ipk-10:ipk+10)) + w=count(s2(ipk-10:ipk+10).gt.0.5*smax) + if(w.gt.4.0) fwidth=sqrt(w*w - 4*4)*df2 + endif return end subroutine sfox_sync