From e8c7af67262bdeb724532f04c64f9c5210f15131 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Mon, 11 Dec 2023 22:06:16 -0500 Subject: [PATCH] bugfix: return early if exactly equal --- src/Utilities/MathUtil.f90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Utilities/MathUtil.f90 b/src/Utilities/MathUtil.f90 index 029743a36eb..f01d6f7e39c 100644 --- a/src/Utilities/MathUtil.f90 +++ b/src/Utilities/MathUtil.f90 @@ -119,7 +119,10 @@ logical function is_close(a, b, rtol, atol, symmetric) logical(LGP) :: lsymmetric ! check for exact equality - if (a == b) is_close = .true. + if (a == b) then + is_close = .true. + return + end if ! process optional arguments if (.not. present(rtol)) then @@ -138,7 +141,6 @@ logical function is_close(a, b, rtol, atol, symmetric) lsymmetric = symmetric end if - ! approximate equality if (lsymmetric) then ! "weak" symmetric test, https://peps.python.org/pep-0485/#which-symmetric-test is_close = abs(a - b) <= max(lrtol * max(abs(a), abs(b)), latol)