src/dierckx.f90: detect overflow in fpgrre

When a call to regrid results in ier=-1 (data needs to be refitted with
interpolating spline) the computation of the sum of the residuals can
overflow. In this case we can exit immediately (avoiding raising a FPE)
ignoring the results. The latter need to be recomputed anyway.
This commit is contained in:
Michele Guerini Rocco 2024-01-31 16:17:42 +01:00
parent b0674c2d9b
commit 19f6d7f2f0
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -1762,6 +1762,7 @@ contains
subroutine fpgrre(ifsx,ifsy,ifbx,ifby,x,mx,y,my,z,mz,kx,ky,tx,nx, &
ty,ny,p,c,nc,fp,fpx,fpy,mm,mynx,kx1,kx2,ky1,ky2,spx,spy,right,q, &
ax,ay,bx,by,nrx,nry)
use, intrinsic :: ieee_arithmetic, only : ieee_is_finite
! ..
! arguments
integer, intent(in) :: kx, kx1, kx2, ky, ky1, ky2, mm, mx, my, mz, &
@ -2087,6 +2088,7 @@ contains
term = (z(iz)-term)**2
! adjust the different parameters.
fp = fp+term
if (.not. ieee_is_finite(fp)) exit
fpx(numx1) = fpx(numx1)+term
fpy(numy1) = fpy(numy1)+term
fac = term*half