From 19f6d7f2f0dbaa7b3e4d40558599399b6d479e56 Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Wed, 31 Jan 2024 16:17:42 +0100 Subject: [PATCH] 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. --- src/dierckx.f90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dierckx.f90 b/src/dierckx.f90 index 4ee9771..d339d17 100644 --- a/src/dierckx.f90 +++ b/src/dierckx.f90 @@ -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