From 63ad9b565d7f1d86a78145a2744c36cc93b3032f Mon Sep 17 00:00:00 2001 From: Miguel Carvajal Date: Sun, 9 Oct 2016 17:18:14 -0300 Subject: [PATCH] Fixe real equality comparison error Changed the real equality comparison to an abs comparison --- .gitignore | 10 ++++++++++ src/mesh.f90 | 7 ++++--- src/optimize.f90 | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2abb306 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.cmake +*.mod +*.o +*.make +*.marks +*.link +*.stamp +*.build +link.txt +Makefile diff --git a/src/mesh.f90 b/src/mesh.f90 index 5e1620a..23329c0 100644 --- a/src/mesh.f90 +++ b/src/mesh.f90 @@ -48,7 +48,7 @@ function meshexp(rmin, rmax, a, N) result(mesh) real(dp) :: alpha, beta if (a < 0) then call stop_error("meshexp: a > 0 required") -else if (a == 1) then +else if (abs(a - 1) < tiny(1.0_dp)) then alpha = (rmax - rmin) / N do i = 1, N+1 mesh(i) = alpha * (i-1.0_dp) + rmin @@ -89,7 +89,8 @@ function meshexp_der(rmin, rmax, a, N) result(Rp) real(dp) :: alpha, beta if (a < 0) then call stop_error("meshexp_der: a > 0 required") -else if (a == 1) then +else if (abs(a - 1) < tiny(1.0_dp)) then + call stop_error("meshexp_der: a == 1 not implemented") else if (N > 1) then @@ -124,7 +125,7 @@ function meshexp_der2(rmin, rmax, a, N) result(Rpp) real(dp) :: alpha, beta if (a < 0) then call stop_error("meshexp_der2: a > 0 required") -else if (a == 1) then +else if (abs(a - 1) < tiny(1.0_dp)) then call stop_error("meshexp_der2: a == 1 not implemented") else if (N > 1) then diff --git a/src/optimize.f90 b/src/optimize.f90 index 7e7202d..02f1e9a 100644 --- a/src/optimize.f90 +++ b/src/optimize.f90 @@ -32,7 +32,7 @@ real(dp) function bisect(f, a, b, tol) result(c) do while (b_ - a_ > tol) c = (a_ + b_) / 2 fc = f(c) - if (fc == 0) return ! We need to make sure f(c) is not zero below + if (abs(fc) < tiny(1.0_dp)) return ! We need to make sure f(c) is not zero below if (fa * fc < 0) then b_ = c fb = fc